Kaydet (Commit) 510576b6 authored tarafından Matúš Kukan's avatar Matúš Kukan

tubes: finish efforts to make TeleManager static

Change-Id: I1d25a6074c3465a6e8c1df3127093d30d913b65d
üst b870f142
......@@ -42,10 +42,6 @@
#include <com/sun/star/uno/Reference.h>
#include <osl/mutex.hxx>
#ifdef ENABLE_TELEPATHY
class TeleManager;
#endif
using namespace com::sun::star::task;
using namespace com::sun::star::uno;
using namespace com::sun::star::lang;
......@@ -209,9 +205,6 @@ class Desktop : public Application
sal_uInt16 m_nAppEvents;
BootstrapError m_aBootstrapError;
BootstrapStatus m_aBootstrapStatus;
#ifdef ENABLE_TELEPATHY
TeleManager* m_pTeleManager;
#endif
std::auto_ptr< Lockfile > m_pLockfile;
Timer m_firstRunTimer;
......
......@@ -618,9 +618,6 @@ throw()
Desktop::Desktop()
: m_bServicesRegistered( false )
, m_aBootstrapError( BE_OK )
#ifdef ENABLE_TELEPATHY
, m_pTeleManager( NULL )
#endif
{
RTL_LOGFILE_TRACE( "desktop (cd100003) ::Desktop::Desktop" );
}
......@@ -628,7 +625,7 @@ Desktop::Desktop()
Desktop::~Desktop()
{
#ifdef ENABLE_TELEPATHY
delete m_pTeleManager;
TeleManager::finalize();
#endif
}
......@@ -1711,9 +1708,8 @@ int Desktop::Main()
SetSplashScreenProgress(60);
#ifdef ENABLE_TELEPATHY
m_pTeleManager = new TeleManager();
bool bListen = rCmdLineArgs.IsInvisible();
m_pTeleManager->init( bListen );
TeleManager::init( bListen );
#endif
if ( !pExecGlobals->bRestartRequested )
......
......@@ -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: */
......@@ -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()
......
......@@ -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();
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment