summaryrefslogtreecommitdiff
path: root/tubes
diff options
context:
space:
mode:
Diffstat (limited to 'tubes')
-rw-r--r--tubes/inc/tubes/manager.hxx75
-rw-r--r--tubes/qa/test_manager.cxx22
-rw-r--r--tubes/source/contacts.cxx13
-rw-r--r--tubes/source/manager.cxx208
4 files changed, 125 insertions, 193 deletions
diff --git a/tubes/inc/tubes/manager.hxx b/tubes/inc/tubes/manager.hxx
index 533233a102b0..b0825a34b59b 100644
--- a/tubes/inc/tubes/manager.hxx
+++ b/tubes/inc/tubes/manager.hxx
@@ -55,6 +55,8 @@ typedef struct _TpContact TpContact;
class TeleManager
{
+ TeleManager();
+ ~TeleManager();
public:
enum AccountManagerStatus
@@ -68,16 +70,21 @@ public:
/** Prepare tube manager with account and service to be offered/listened
to.
*/
- TUBES_DLLPUBLIC TeleManager();
- TUBES_DLLPUBLIC ~TeleManager();
+ TUBES_DLLPUBLIC static bool init( bool bListen );
- TUBES_DLLPUBLIC bool init( bool bListen );
+ TUBES_DLLPUBLIC static void finalize();
+
+ /** True if there has been tube channel received and is still not used. */
+ TUBES_DLLPUBLIC static bool hasWaitingConference();
+
+ /** Get a conference with current UUID to set a session. */
+ TUBES_DLLPUBLIC static TeleConference* getConference();
/** Connect to DBus and create AccountManager. */
- bool createAccountManager();
+ static bool createAccountManager();
/** Setup client handlers. */
- bool registerClients();
+ static bool registerClients();
/** Prepare the Telepathy Account Manager.
Requires createAccountManager() to have succeeded.
@@ -87,16 +94,16 @@ public:
TODO: this needs some signalling mechanism
*/
- void prepareAccountManager();
- AccountManagerStatus getAccountManagerStatus() const;
+ static void prepareAccountManager();
+ static AccountManagerStatus getAccountManagerStatus();
/** Fetches the contact list. Returns 0 before connect() is called successfully.
Is non-functional until prepareAccountManager().
*/
- ContactList* getContactList() const;
+ static ContactList* getContactList();
/** Start a demo session where all local documents are shared to each other */
- TeleConference* startDemoSession();
+ static TeleConference* startDemoSession();
/** Start a group session in a MUC.
@@ -112,7 +119,7 @@ public:
empty, only the conference's UUID is used and rConferenceRoom is
ignored, hopefully resulting in a local DBus tube.
*/
- TeleConference* startGroupSession( TpAccount *pAccount,
+ static TeleConference* startGroupSession( TpAccount *pAccount,
const rtl::OUString& rConferenceRoom,
const rtl::OUString& rConferenceServer );
@@ -124,47 +131,30 @@ public:
@param pBuddy
The buddy to be connected. Must be a contact of pAccount.
*/
- TeleConference* startBuddySession( TpAccount *pAccount, TpContact *pBuddy );
-
- /** Get a conference with current UUID to set a session. */
- TUBES_DLLPUBLIC static TeleConference* getConference();
+ static TeleConference* startBuddySession( TpAccount *pAccount, TpContact *pBuddy );
- static void registerCollaboration( Collaboration* pCollaboration );
- static void unregisterCollaboration( Collaboration* pCollaboration );
+ static void registerCollaboration( Collaboration* pCollaboration );
+ static void unregisterCollaboration( Collaboration* pCollaboration );
/** Display contact list dialog for all documents. */
- static void displayAllContacts();
+ static void displayAllContacts();
- static void registerDemoConference( TeleConference* pConference );
- static void unregisterDemoConference( TeleConference* pConference );
+ static void registerDemoConference( TeleConference* pConference );
+ static void unregisterDemoConference( TeleConference* pConference );
/** Broadcast packet to all conferences. Used for demo mode. */
- static void broadcastPacket( const OString& rPacket );
-
- /** True if there has been tube channel received and is still not used. */
- TUBES_DLLPUBLIC static bool hasWaitingConference();
- static void setCurrentUuid( const OString& rUuid );
-
- void disconnect();
+ static void broadcastPacket( const OString& rPacket );
+ static void setCurrentUuid( const OString& rUuid );
static rtl::OString createUuid();
-
// Only for callbacks.
static void addConference( TeleConference* pConference );
static void setChannelReadyHandlerInvoked( bool b );
- bool isChannelReadyHandlerInvoked() const;
- void setAccountManagerReadyHandlerInvoked( bool b );
- bool isAccountManagerReadyHandlerInvoked() const;
+ static bool isChannelReadyHandlerInvoked();
+ static void setAccountManagerReadyHandlerInvoked( bool b );
+ static bool isAccountManagerReadyHandlerInvoked();
/** Only the callback of prepareAccountManager() is to set this. */
- void setAccountManagerReady( bool bPrepared);
-
- 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 );
+ static void setAccountManagerReady( bool bPrepared);
/// "LibreOfficeWhatEver"
static rtl::OString getFullClientName();
@@ -186,19 +176,14 @@ public:
*/
static void addSuffixToNames( const char* pName );
- TpAccount* getAccount( const rtl::OString& rAccountID );
+ static TpAccount* getAccount( const rtl::OString& rAccountID );
private:
- void ensureLegacyChannel( TpAccount* pAccount, TpContact* pBuddy );
-
static TeleManagerImpl* pImpl;
- static sal_uInt32 nRefCount;
- static rtl::OString aNameSuffix;
static ::osl::Mutex& GetMutex();
};
-
#endif // INCLUDED_TUBES_MANAGER_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/tubes/qa/test_manager.cxx b/tubes/qa/test_manager.cxx
index 850d5d5fab92..00ce9e5c8488 100644
--- a/tubes/qa/test_manager.cxx
+++ b/tubes/qa/test_manager.cxx
@@ -85,7 +85,6 @@ public:
// static, not members, so they actually survive cppunit test iteration
static TeleConference* mpConference1 = NULL;
-static TeleManager* mpManager = NULL;
static TpContact* mpAccepterContact = NULL;
static GMainLoop* mpMainLoop = NULL;
static bool maFileSentSuccess = false;
@@ -126,16 +125,13 @@ void TestTeleTubes::testInitialize()
mpMainLoop = g_main_loop_new (NULL, FALSE);
g_timeout_add_seconds (10, timed_out, mpMainLoop);
-
- mpManager = new TeleManager();
}
void TestTeleTubes::testContactList()
{
- CPPUNIT_ASSERT( mpManager);
- CPPUNIT_ASSERT( mpManager->getAccountManagerStatus() == TeleManager::AMS_PREPARED);
+ CPPUNIT_ASSERT( TeleManager::getAccountManagerStatus() == TeleManager::AMS_PREPARED);
- ContactList *cl = mpManager->getContactList();
+ ContactList *cl = TeleManager::getContactList();
AccountContactPairV pairs;
@@ -178,30 +174,30 @@ void TestTeleTubes::testContactList()
void TestTeleTubes::testPrepareAccountManager()
{
- mpManager->prepareAccountManager();
- TeleManager::AccountManagerStatus eStatus = mpManager->getAccountManagerStatus();
+ TeleManager::prepareAccountManager();
+ TeleManager::AccountManagerStatus eStatus = TeleManager::getAccountManagerStatus();
CPPUNIT_ASSERT( eStatus == TeleManager::AMS_PREPARED);
}
void TestTeleTubes::testStartBuddySession()
{
- TpAccount *pAcc1 = mpManager->getAccount(maOffererIdentifier);
+ TpAccount *pAcc1 = TeleManager::getAccount(maOffererIdentifier);
CPPUNIT_ASSERT( pAcc1 != 0);
/* This has to run after testContactList has run successfully. */
CPPUNIT_ASSERT( mpAccepterContact != 0);
- mpConference1 = mpManager->startBuddySession( pAcc1, mpAccepterContact);
+ mpConference1 = TeleManager::startBuddySession( pAcc1, mpAccepterContact);
CPPUNIT_ASSERT( mpConference1 != NULL);
}
void TestTeleTubes::testCreateAccountManager()
{
- bool bConnected = mpManager->createAccountManager();
+ bool bConnected = TeleManager::createAccountManager();
CPPUNIT_ASSERT( bConnected == true);
}
void TestTeleTubes::testRegisterClients()
{
- bool bRegistered = mpManager->registerClients();
+ bool bRegistered = TeleManager::registerClients();
CPPUNIT_ASSERT( bRegistered == true);
}
@@ -254,7 +250,7 @@ void TestTeleTubes::testDestroyTeleTubes()
if (mpConference1)
mpConference1->close();
delete mpConference1;
- delete mpManager;
+ TeleManager::finalize();
}
void TestTeleTubes::testFailAlways()
diff --git a/tubes/source/contacts.cxx b/tubes/source/contacts.cxx
index c6037f42bd96..37a9de46a904 100644
--- a/tubes/source/contacts.cxx
+++ b/tubes/source/contacts.cxx
@@ -68,7 +68,6 @@ class TubeContacts : public ModelessDialog
PushButton maBtnListen;
SvxSimpleTableContainer maListContainer;
SvxSimpleTable maList;
- TeleManager* mpManager;
Collaboration* mpCollaboration;
DECL_LINK( BtnDemoHdl, void * );
@@ -105,13 +104,13 @@ class TubeContacts : public ModelessDialog
void Listen()
{
- if (!mpManager->registerClients())
+ if (!TeleManager::registerClients())
SAL_INFO( "sc.tubes", "Could not register client handlers." );
}
void StartDemoSession()
{
- TeleConference* pConference = mpManager->startDemoSession();
+ TeleConference* pConference = TeleManager::startDemoSession();
if (!pConference)
SAL_WARN( "tubes", "Could not start demo session!" );
else
@@ -132,7 +131,7 @@ class TubeContacts : public ModelessDialog
TpAccount* pAccount = pAC->mpAccount;
TpContact* pContact = pAC->mpContact;
SAL_INFO( "tubes", "picked " << tp_contact_get_identifier( pContact ) );
- TeleConference* pConference = mpManager->startBuddySession( pAccount, pContact );
+ TeleConference* pConference = TeleManager::startBuddySession( pAccount, pContact );
if (!pConference)
SAL_WARN( "tubes", "Could not start session with " <<
tp_contact_get_identifier( pContact ) );
@@ -154,7 +153,7 @@ class TubeContacts : public ModelessDialog
{
TpAccount* pAccount = pAC->mpAccount;
SAL_INFO( "tubes", "picked " << tp_account_get_display_name( pAccount ) );
- TeleConference* pConference = mpManager->startGroupSession( pAccount,
+ TeleConference* pConference = TeleManager::startGroupSession( pAccount,
rtl::OUString("liboroom"), rtl::OUString("conference.jabber.org") );
if (!pConference)
SAL_WARN( "tubes", "Could not start group session." );
@@ -176,7 +175,6 @@ public:
maBtnListen( this, TubesResId( BTN_LISTEN ) ),
maListContainer( this, TubesResId( CTL_LIST ) ),
maList( maListContainer ),
- mpManager( new TeleManager() ),
mpCollaboration( pCollaboration )
{
Hide();
@@ -201,7 +199,6 @@ public:
}
virtual ~TubeContacts()
{
- delete mpManager;
}
static rtl::OUString fromUTF8( const char *pStr )
@@ -214,7 +211,7 @@ public:
{
SAL_INFO( "sc.tubes", "Populating contact list dialog" );
maList.Clear();
- ContactList *pContacts = mpManager->getContactList();
+ ContactList *pContacts = TeleManager::getContactList();
if ( pContacts )
{
AccountContactPairV aPairs = pContacts->getContacts();
diff --git a/tubes/source/manager.cxx b/tubes/source/manager.cxx
index 4d0fc66946c2..b4fb93b001d0 100644
--- a/tubes/source/manager.cxx
+++ b/tubes/source/manager.cxx
@@ -71,21 +71,14 @@ struct InfoLogger
};
}
#define INFO_LOGGER_F(s) InfoLogger aLogger(0,(s))
-#define INFO_LOGGER(s) InfoLogger aLogger(this,(s))
#else
#define INFO_LOGGER_F(s)
-#define INFO_LOGGER(s)
#endif // SAL_LOG_INFO
using namespace rtl;
using namespace osl;
-
-TeleManagerImpl* TeleManager::pImpl = NULL;
-sal_uInt32 TeleManager::nRefCount = 0;
-rtl::OString TeleManager::aNameSuffix;
-
/** Refcounted singleton implementation class. */
class TeleManagerImpl
{
@@ -99,6 +92,7 @@ public:
bool mbChannelReadyHandlerInvoked : 1;
ContactList* mpContactList;
OString msCurrentUUID;
+ OString msNameSuffix;
typedef std::map< OString, TeleConference* > MapStringConference;
MapStringConference maAcceptedConferences;
typedef std::set< TeleConference* > DemoConferences;
@@ -110,6 +104,8 @@ public:
~TeleManagerImpl();
};
+TeleManagerImpl* TeleManager::pImpl = new TeleManagerImpl();
+
bool tb_account_is_online( TpAccount* pAccount );
bool tb_contact_is_online( TpContact* pContact );
@@ -145,7 +141,7 @@ static void contact_presence_changed_cb( TpContact* pContact,
}
}
-void TeleManager_DBusChannelHandler(
+static void TeleManager_DBusChannelHandler(
TpSimpleHandler* /*handler*/,
TpAccount* pAccount,
TpConnection* /*connection*/,
@@ -153,16 +149,11 @@ void TeleManager_DBusChannelHandler(
GList* /*requests_satisfied*/,
gint64 /*user_action_time*/,
TpHandleChannelsContext* pContext,
- gpointer pUserData)
+ gpointer /*pUserData*/ )
{
bool aAccepted = false;
INFO_LOGGER_F( "TeleManager_DBusChannelHandler");
- TeleManager* pManager = reinterpret_cast<TeleManager*>(pUserData);
- SAL_WARN_IF( !pManager, "tubes", "TeleManager_DBusChannelHandler: no manager");
- if (!pManager)
- return;
-
for (GList* p = pChannels; p; p = p->next)
{
TpChannel* pChannel = TP_CHANNEL(p->data);
@@ -179,7 +170,7 @@ void TeleManager_DBusChannelHandler(
TeleConference* pConference = new TeleConference( pAccount, TP_DBUS_TUBE_CHANNEL( pChannel ) );
pConference->acceptTube();
- pManager->addConference( pConference );
+ TeleManager::addConference( pConference );
g_signal_connect( pAccount, "presence-changed",
G_CALLBACK (account_presence_changed_cb), pConference );
@@ -209,6 +200,8 @@ void TeleManager_DBusChannelHandler(
void TeleManager::addConference( TeleConference* pConference )
{
+ MutexGuard aGuard( GetMutex());
+
SAL_WARN_IF( pConference->getUuid().isEmpty(), "tubes",
"Adding conference with empty UUID should not happen!" );
pImpl->maAcceptedConferences[ pConference->getUuid() ] = pConference;
@@ -216,6 +209,8 @@ void TeleManager::addConference( TeleConference* pConference )
TeleConference* TeleManager::getConference()
{
+ MutexGuard aGuard( GetMutex());
+
TeleManagerImpl::MapStringConference::const_iterator it =
pImpl->maAcceptedConferences.find( pImpl->msCurrentUUID );
TeleConference* pConference = NULL;
@@ -229,16 +224,22 @@ TeleConference* TeleManager::getConference()
void TeleManager::registerCollaboration( Collaboration* pCollaboration )
{
+ MutexGuard aGuard( GetMutex());
+
pImpl->maCollaborations.insert( pCollaboration );
}
void TeleManager::unregisterCollaboration( Collaboration* pCollaboration )
{
+ MutexGuard aGuard( GetMutex());
+
pImpl->maCollaborations.erase( pCollaboration );
}
void TeleManager::displayAllContacts()
{
+ MutexGuard aGuard( GetMutex());
+
for (TeleManagerImpl::Collaborations::iterator it = pImpl->maCollaborations.begin();
it != pImpl->maCollaborations.end(); ++it)
(*it)->DisplayContacts();
@@ -246,16 +247,22 @@ void TeleManager::displayAllContacts()
void TeleManager::registerDemoConference( TeleConference* pConference )
{
+ MutexGuard aGuard( GetMutex());
+
pImpl->maDemoConferences.insert( pConference );
}
void TeleManager::unregisterDemoConference( TeleConference* pConference )
{
+ MutexGuard aGuard( GetMutex());
+
pImpl->maDemoConferences.erase( pConference );
}
void TeleManager::broadcastPacket( const OString& rPacket )
{
+ MutexGuard aGuard( GetMutex());
+
INFO_LOGGER_F( "TeleManager::broadcastPacket" );
for (TeleManagerImpl::DemoConferences::iterator it = pImpl->maDemoConferences.begin();
it != pImpl->maDemoConferences.end(); ++it)
@@ -265,11 +272,15 @@ void TeleManager::broadcastPacket( const OString& rPacket )
bool TeleManager::hasWaitingConference()
{
- return pImpl && !pImpl->msCurrentUUID.isEmpty();
+ MutexGuard aGuard( GetMutex());
+
+ return !pImpl->msCurrentUUID.isEmpty();
}
void TeleManager::setCurrentUuid( const OString& rUuid )
{
+ MutexGuard aGuard( GetMutex());
+
pImpl->msCurrentUUID = rUuid;
}
@@ -335,14 +346,19 @@ static void TeleManager_TransferError( EmpathyFTHandler *handler, const GError *
g_object_unref( handler);
}
-static void
-TeleManager_IncomingHandlerReady (
+static void lcl_iterateLoop( bool (*pFunc)() )
+{
+ while (!(*pFunc)())
+ {
+ g_main_context_iteration( NULL, TRUE );
+ }
+}
+
+static void lcl_IncomingHandlerReady (
EmpathyFTHandler* pHandler,
GError* pError,
- void* pUserData)
+ void* /*pUserData*/ )
{
- TeleManager* pManager = reinterpret_cast<TeleManager*>(pUserData);
-
if (pError)
{
SAL_INFO ("tubes", "failed to prepare incoming transfer: " << pError->message);
@@ -361,8 +377,8 @@ TeleManager_IncomingHandlerReady (
empathy_ft_handler_incoming_set_destination( pHandler, pDestination);
g_object_unref( pDestination);
- g_signal_connect( pHandler, "transfer-done", G_CALLBACK (TeleManager_TransferDone), pManager);
- g_signal_connect( pHandler, "transfer-error", G_CALLBACK (TeleManager_TransferError), pManager);
+ g_signal_connect( pHandler, "transfer-done", G_CALLBACK (TeleManager_TransferDone), NULL);
+ g_signal_connect( pHandler, "transfer-error", G_CALLBACK (TeleManager_TransferError), NULL);
empathy_ft_handler_start_transfer( pHandler);
}
@@ -374,16 +390,11 @@ static void TeleManager_FileTransferHandler(
GList* /*requests_satisfied*/,
gint64 /*user_action_time*/,
TpHandleChannelsContext* pContext,
- gpointer pUserData)
+ gpointer /*pUserData*/ )
{
bool aAccepted = false;
INFO_LOGGER_F( "TeleManager_FileTransferHandler");
- TeleManager* pManager = reinterpret_cast<TeleManager*>(pUserData);
- SAL_WARN_IF( !pManager, "tubes", "TeleManager_FileTransferHandler: no manager");
- if (!pManager)
- return;
-
for (GList* p = pChannels; p; p = p->next)
{
TpChannel* pChannel = TP_CHANNEL(p->data);
@@ -395,7 +406,7 @@ static void TeleManager_FileTransferHandler(
{
SAL_INFO( "tubes", "accepting file transfer");
empathy_ft_handler_new_incoming( TP_FILE_TRANSFER_CHANNEL( pChannel),
- TeleManager_IncomingHandlerReady, pManager);
+ lcl_IncomingHandlerReady, NULL);
aAccepted = true;
}
else
@@ -452,16 +463,11 @@ static void TeleManager_ChannelReadyHandler(
static void TeleManager_AccountManagerReadyHandler(
GObject* pSourceObject,
GAsyncResult* pResult,
- gpointer pUserData
+ gpointer /*pUserData*/
)
{
INFO_LOGGER_F( "TeleManager_AccountManagerReadyHandler");
- TeleManager* pManager = reinterpret_cast<TeleManager*>(pUserData);
- SAL_WARN_IF( !pManager, "tubes", "TeleManager_AccountManagerReadyHandler: no manager");
- if (!pManager)
- return;
-
GError* pError = NULL;
gboolean bPrepared = tp_proxy_prepare_finish( pSourceObject, pResult, &pError);
SAL_WARN_IF( !bPrepared, "tubes", "TeleManager_AccountManagerReadyHandler: not prepared");
@@ -471,35 +477,8 @@ static void TeleManager_AccountManagerReadyHandler(
g_error_free( pError);
}
- pManager->setAccountManagerReady( bPrepared);
- pManager->setAccountManagerReadyHandlerInvoked( true);
-}
-
-
-TeleManager::TeleManager()
-{
- SAL_INFO( "tubes", "TeleManager::get: count: " << nRefCount );
- // The glib object types need to be initialized, else we aren't going
- // anywhere.
- g_type_init();
-
- MutexGuard aGuard( GetMutex());
- ++nRefCount;
- if (!pImpl)
- pImpl = new TeleManagerImpl;
-}
-
-TeleManager::~TeleManager()
-{
- MutexGuard aGuard( GetMutex());
- if (!--nRefCount)
- {
- disconnect();
-
- delete pImpl;
- pImpl = NULL;
- }
- SAL_INFO( "tubes", "TeleManager::unref: count: " << nRefCount );
+ TeleManager::setAccountManagerReady( bPrepared);
+ TeleManager::setAccountManagerReadyHandlerInvoked( true);
}
bool TeleManager::init( bool bListen )
@@ -518,9 +497,14 @@ bool TeleManager::init( bool bListen )
return false;
}
+void TeleManager::finalize()
+{
+ delete pImpl;
+}
+
bool TeleManager::createAccountManager()
{
- INFO_LOGGER( "TeleManager::createAccountManager");
+ INFO_LOGGER_F( "TeleManager::createAccountManager");
MutexGuard aGuard( GetMutex());
@@ -558,7 +542,7 @@ bool TeleManager::createAccountManager()
bool TeleManager::registerClients()
{
- INFO_LOGGER( "TeleManager::registerClients");
+ INFO_LOGGER_F( "TeleManager::registerClients");
MutexGuard aGuard( GetMutex());
@@ -574,7 +558,7 @@ bool TeleManager::registerClients()
getFullClientName().getStr(), // name
FALSE, // uniquify
TeleManager_DBusChannelHandler, // callback
- this, // user_data
+ NULL, // user_data
NULL // destroy
);
SAL_WARN_IF( !pImpl->mpClient, "tubes", "TeleManager::registerClients: no client");
@@ -622,7 +606,7 @@ bool TeleManager::registerClients()
getFullClientName().getStr(), // name
TRUE, // uniquify to get a different bus name to the main client, above
TeleManager_FileTransferHandler, // callback
- this, // user_data, unused
+ NULL, // user_data
NULL // destroy
);
tp_base_client_take_handler_filter( pImpl->mpFileTransferClient,
@@ -645,7 +629,7 @@ bool TeleManager::registerClients()
TeleConference* TeleManager::startDemoSession()
{
- INFO_LOGGER( "TeleManager::startDemoSession");
+ INFO_LOGGER_F( "TeleManager::startDemoSession");
TeleConference* pConference = new TeleConference( NULL, NULL, "demo" );
registerDemoConference( pConference );
@@ -658,7 +642,7 @@ TeleConference* TeleManager::startGroupSession( TpAccount *pAccount,
const rtl::OUString& rUConferenceRoom,
const rtl::OUString& rUConferenceServer )
{
- INFO_LOGGER( "TeleManager::startGroupSession");
+ INFO_LOGGER_F( "TeleManager::startGroupSession");
OString aSessionId( TeleManager::createUuid());
@@ -705,7 +689,7 @@ TeleConference* TeleManager::startGroupSession( TpAccount *pAccount,
tp_account_channel_request_create_and_handle_channel_async(
pChannelRequest, NULL, TeleManager_ChannelReadyHandler, pConference);
- iterateLoop( &TeleManager::isChannelReadyHandlerInvoked);
+ lcl_iterateLoop( &TeleManager::isChannelReadyHandlerInvoked);
g_object_unref( pChannelRequest);
g_hash_table_unref( pRequest);
@@ -720,7 +704,7 @@ TeleConference* TeleManager::startGroupSession( TpAccount *pAccount,
}
-void TeleManager::ensureLegacyChannel( TpAccount* pAccount, TpContact* pBuddy )
+static void lcl_ensureLegacyChannel( TpAccount* pAccount, TpContact* pBuddy )
{
/* This is a workaround for a Telepathy bug.
* <https://bugs.freedesktop.org/show_bug.cgi?id=47760>. The first time you
@@ -751,9 +735,9 @@ void TeleManager::ensureLegacyChannel( TpAccount* pAccount, TpContact* pBuddy )
/* TODO: factor out common code with startGroupSession() */
TeleConference* TeleManager::startBuddySession( TpAccount *pAccount, TpContact *pBuddy )
{
- INFO_LOGGER( "TeleManager::startBuddySession");
+ INFO_LOGGER_F( "TeleManager::startBuddySession");
- ensureLegacyChannel( pAccount, pBuddy );
+ lcl_ensureLegacyChannel( pAccount, pBuddy );
const char *pIdentifier = tp_contact_get_identifier( pBuddy);
SAL_INFO( "tubes", "TeleManager::startBuddySession: creating channel request from "
@@ -783,7 +767,7 @@ TeleConference* TeleManager::startBuddySession( TpAccount *pAccount, TpContact *
tp_account_channel_request_create_and_handle_channel_async(
pChannelRequest, NULL, TeleManager_ChannelReadyHandler, pConference );
- iterateLoop( &TeleManager::isChannelReadyHandlerInvoked);
+ lcl_iterateLoop( &TeleManager::isChannelReadyHandlerInvoked);
g_object_unref( pChannelRequest);
g_hash_table_unref( pRequest);
@@ -802,7 +786,7 @@ TeleConference* TeleManager::startBuddySession( TpAccount *pAccount, TpContact *
void TeleManager::prepareAccountManager()
{
- INFO_LOGGER( "TeleManager::prepareAccountManager");
+ INFO_LOGGER_F( "TeleManager::prepareAccountManager");
MutexGuard aGuard( GetMutex());
@@ -827,13 +811,13 @@ void TeleManager::prepareAccountManager()
pImpl->meAccountManagerStatus = AMS_INPREPARATION;
setAccountManagerReadyHandlerInvoked( false);
- tp_proxy_prepare_async( pImpl->mpAccountManager, NULL, TeleManager_AccountManagerReadyHandler, this);
+ tp_proxy_prepare_async( pImpl->mpAccountManager, NULL, TeleManager_AccountManagerReadyHandler, NULL);
- iterateLoop( &TeleManager::isAccountManagerReadyHandlerInvoked);
+ lcl_iterateLoop( &TeleManager::isAccountManagerReadyHandlerInvoked);
}
-TeleManager::AccountManagerStatus TeleManager::getAccountManagerStatus() const
+TeleManager::AccountManagerStatus TeleManager::getAccountManagerStatus()
{
return pImpl->meAccountManagerStatus;
}
@@ -844,7 +828,7 @@ void TeleManager::setAccountManagerReadyHandlerInvoked( bool b )
pImpl->mbAccountManagerReadyHandlerInvoked = b;
}
-bool TeleManager::isAccountManagerReadyHandlerInvoked() const
+bool TeleManager::isAccountManagerReadyHandlerInvoked()
{
return pImpl->mbAccountManagerReadyHandlerInvoked;
}
@@ -854,19 +838,19 @@ void TeleManager::setChannelReadyHandlerInvoked( bool b )
pImpl->mbChannelReadyHandlerInvoked = b;
}
-bool TeleManager::isChannelReadyHandlerInvoked() const
+bool TeleManager::isChannelReadyHandlerInvoked()
{
return pImpl->mbChannelReadyHandlerInvoked;
}
-ContactList* TeleManager::getContactList() const
+ContactList* TeleManager::getContactList()
{
return pImpl->mpContactList;
}
TpAccount* TeleManager::getAccount( const rtl::OString& rAccountID )
{
- INFO_LOGGER( "TeleManager::getMyAccount");
+ INFO_LOGGER_F( "TeleManager::getMyAccount");
SAL_WARN_IF( pImpl->meAccountManagerStatus != AMS_PREPARED, "tubes",
"TeleManager::getMyAccount: Account Manager not prepared");
@@ -899,21 +883,6 @@ TpAccount* TeleManager::getAccount( const rtl::OString& rAccountID )
return pAccount;
}
-void TeleManager::disconnect()
-{
- INFO_LOGGER( "TeleManager::disconnect");
-
- if (!pImpl->mpClient)
- return;
-
- tp_base_client_unregister( pImpl->mpClient);
- pImpl->mpClient = NULL;
-
- tp_base_client_unregister( pImpl->mpFileTransferClient);
- pImpl->mpFileTransferClient = NULL;
-}
-
-
void TeleManager::setAccountManagerReady( bool bPrepared)
{
pImpl->meAccountManagerStatus = (bPrepared ? AMS_PREPARED : AMS_UNPREPARABLE);
@@ -923,7 +892,7 @@ void TeleManager::setAccountManagerReady( bool bPrepared)
rtl::OString TeleManager::getFullClientName()
{
OStringBuffer aBuf(64);
- aBuf.append( RTL_CONSTASCII_STRINGPARAM( LIBO_CLIENT_SUFFIX)).append( aNameSuffix);
+ aBuf.append( RTL_CONSTASCII_STRINGPARAM( LIBO_CLIENT_SUFFIX)).append( pImpl->msNameSuffix);
return aBuf.makeStringAndClear();
}
@@ -931,7 +900,7 @@ rtl::OString TeleManager::getFullClientName()
rtl::OString TeleManager::getFullServiceName()
{
OStringBuffer aBuf(64);
- aBuf.append( RTL_CONSTASCII_STRINGPARAM( LIBO_DTUBE_SERVICE)).append( aNameSuffix);
+ aBuf.append( RTL_CONSTASCII_STRINGPARAM( LIBO_DTUBE_SERVICE)).append( pImpl->msNameSuffix);
return aBuf.makeStringAndClear();
}
@@ -939,29 +908,11 @@ rtl::OString TeleManager::getFullServiceName()
rtl::OString TeleManager::getFullObjectPath()
{
OStringBuffer aBuf(64);
- aBuf.append( '/').append( RTL_CONSTASCII_STRINGPARAM( LIBO_DTUBE_SERVICE)).append( aNameSuffix);
+ aBuf.append( '/').append( RTL_CONSTASCII_STRINGPARAM( LIBO_DTUBE_SERVICE)).append( pImpl->msNameSuffix);
OString aStr( aBuf.makeStringAndClear().replace( '.', '/'));
return aStr;
}
-void TeleManager::iterateLoop( CallBackInvokedFunc pFunc )
-{
- while (!(*pFunc)())
- {
- g_main_context_iteration( NULL, TRUE );
- }
-}
-
-
-void TeleManager::iterateLoop( ManagerCallBackInvokedFunc pFunc )
-{
- while (!(this->*pFunc)())
- {
- g_main_context_iteration( NULL, TRUE );
- }
-}
-
-// static
rtl::OString TeleManager::createUuid()
{
sal_uInt8 nId[16];
@@ -975,8 +926,6 @@ rtl::OString TeleManager::createUuid()
return rtl::OString( aBuf);
}
-
-// static
Mutex& TeleManager::GetMutex()
{
static Mutex* pMutex = NULL;
@@ -989,10 +938,9 @@ Mutex& TeleManager::GetMutex()
return *pMutex;
}
-// static
void TeleManager::addSuffixToNames( const char* pName )
{
- aNameSuffix = pName;
+ pImpl->msNameSuffix = pName;
}
// ===========================================================================
@@ -1007,9 +955,9 @@ TeleManagerImpl::TeleManagerImpl()
mbAccountManagerReadyHandlerInvoked( false),
mbChannelReadyHandlerInvoked( false)
{
+ g_type_init();
}
-
TeleManagerImpl::~TeleManagerImpl()
{
// There may be unused conferences left opened, so close them.
@@ -1017,12 +965,18 @@ TeleManagerImpl::~TeleManagerImpl()
for (MapStringConference::iterator it = maAcceptedConferences.begin();
it != maAcceptedConferences.end(); ++it)
it->second->close();
- if (mpFactory)
- g_object_unref( mpFactory);
if (mpClient)
+ {
+ tp_base_client_unregister( mpClient);
g_object_unref( mpClient);
+ }
if (mpFileTransferClient)
+ {
+ tp_base_client_unregister( mpFileTransferClient);
g_object_unref( mpFileTransferClient);
+ }
+ if (mpFactory)
+ g_object_unref( mpFactory);
if (mpAccountManager)
g_object_unref( mpAccountManager);
if (mpContactList)