[Libreoffice-commits] .: 5 commits - tubes/CppunitTest_tubes_test.mk tubes/inc tubes/Library_tubes.mk tubes/qa tubes/source
Matus Kukan
mkukan at kemper.freedesktop.org
Thu Aug 16 02:42:50 PDT 2012
tubes/CppunitTest_tubes_test.mk | 11 --
tubes/Library_tubes.mk | 2
tubes/inc/tubes/contact-list.hxx | 5
tubes/inc/tubes/manager.hxx | 41 +------
tubes/qa/test_manager.cxx | 175 +++++++++++++-------------------
tubes/source/collaboration.cxx | 6 -
tubes/source/contact-list.cxx | 23 ----
tubes/source/contacts.cxx | 3
tubes/source/manager.cxx | 213 ++++++++++++---------------------------
9 files changed, 165 insertions(+), 314 deletions(-)
New commits:
commit 4662df8a7561ce71ba00accbb5170e10818d6008
Author: Matúš Kukan <matus.kukan at gmail.com>
Date: Thu Aug 16 10:53:35 2012 +0200
tubes: simplify and make more readable, I believe
Change-Id: I83a4332d9947d03382b10ea050f26bf3ed544299
diff --git a/tubes/inc/tubes/manager.hxx b/tubes/inc/tubes/manager.hxx
index ce17fd9..032f539 100644
--- a/tubes/inc/tubes/manager.hxx
+++ b/tubes/inc/tubes/manager.hxx
@@ -132,11 +132,6 @@ public:
// Only for callbacks.
static void addConference( TeleConference* pConference );
- static void setChannelReadyHandlerInvoked( bool b );
- static bool isChannelReadyHandlerInvoked();
- static void setAccountManagerReady( bool bPrepared);
- static void setAccountManagerReadyHandlerInvoked( bool b );
- static bool isAccountManagerReadyHandlerInvoked();
/// "LibreOfficeWhatEver"
static rtl::OString getFullClientName();
diff --git a/tubes/source/manager.cxx b/tubes/source/manager.cxx
index f1548c5..d8884ee 100644
--- a/tubes/source/manager.cxx
+++ b/tubes/source/manager.cxx
@@ -87,9 +87,9 @@ public:
TpBaseClient* mpClient;
TpBaseClient* mpFileTransferClient;
TpAccountManager* mpAccountManager;
- bool mbAccountManagerReady : 1;
- bool mbAccountManagerReadyHandlerInvoked : 1;
- bool mbChannelReadyHandlerInvoked : 1;
+ static bool mbAccountManagerReady;
+ static bool mbAccountManagerReadyHandlerInvoked;
+ static bool mbChannelReadyHandlerInvoked;
ContactList* mpContactList;
OString msCurrentUUID;
OString msNameSuffix;
@@ -102,9 +102,14 @@ public:
TeleManagerImpl();
~TeleManagerImpl();
+ static void AccountManagerReadyHandler( GObject* pSourceObject, GAsyncResult* pResult, gpointer pUserData );
+ static void ChannelReadyHandler( GObject* pSourceObject, GAsyncResult* pResult, gpointer pUserData );
};
TeleManagerImpl* TeleManager::pImpl = new TeleManagerImpl();
+bool TeleManagerImpl::mbAccountManagerReady;
+bool TeleManagerImpl::mbAccountManagerReadyHandlerInvoked;
+bool TeleManagerImpl::mbChannelReadyHandlerInvoked;
static void TeleManager_DBusChannelHandler(
TpSimpleHandler* /*handler*/,
@@ -307,14 +312,6 @@ static void TeleManager_TransferError( EmpathyFTHandler *handler, const GError *
g_object_unref( handler);
}
-static void lcl_iterateLoop( bool (*pFunc)() )
-{
- while (!(*pFunc)())
- {
- g_main_context_iteration( NULL, TRUE );
- }
-}
-
static void lcl_IncomingHandlerReady (
EmpathyFTHandler* pHandler,
GError* pError,
@@ -389,20 +386,20 @@ static void TeleManager_FileTransferHandler(
}
}
-static void TeleManager_ChannelReadyHandler(
+void TeleManagerImpl::ChannelReadyHandler(
GObject* pSourceObject,
GAsyncResult* pResult,
gpointer pUserData
)
{
- INFO_LOGGER_F( "TeleManager_ChannelReadyHandler");
+ INFO_LOGGER_F( "TeleManagerImpl::ChannelReadyHandler");
TeleConference* pConference = reinterpret_cast<TeleConference*>(pUserData);
- SAL_WARN_IF( !pConference, "tubes", "TeleManager_ChannelReadyHandler: no conference");
+ SAL_WARN_IF( !pConference, "tubes", "TeleManagerImpl::ChannelReadyHandler: no conference");
if (!pConference)
return;
- TeleManager::setChannelReadyHandlerInvoked( true );
+ mbChannelReadyHandlerInvoked = true;
TpAccountChannelRequest* pChannelRequest = TP_ACCOUNT_CHANNEL_REQUEST( pSourceObject);
GError* pError = NULL;
@@ -412,7 +409,7 @@ static void TeleManager_ChannelReadyHandler(
{
// "account isn't Enabled" means just that..
/* FIXME: detect and handle, domain=132, code=3 */
- SAL_WARN( "tubes", "TeleManager_ChannelReadyHandler: no channel: " << pError->message);
+ SAL_WARN( "tubes", "TeleManagerImpl::ChannelReadyHandler: no channel: " << pError->message);
g_error_free( pError);
return;
}
@@ -421,25 +418,25 @@ static void TeleManager_ChannelReadyHandler(
pConference->offerTube();
}
-static void TeleManager_AccountManagerReadyHandler(
+void TeleManagerImpl::AccountManagerReadyHandler(
GObject* pSourceObject,
GAsyncResult* pResult,
gpointer /*pUserData*/
)
{
- INFO_LOGGER_F( "TeleManager_AccountManagerReadyHandler");
+ INFO_LOGGER_F( "TeleManagerImpl::AccountManagerReadyHandler");
GError* pError = NULL;
gboolean bPrepared = tp_proxy_prepare_finish( pSourceObject, pResult, &pError);
- SAL_WARN_IF( !bPrepared, "tubes", "TeleManager_AccountManagerReadyHandler: not prepared");
+ SAL_WARN_IF( !bPrepared, "tubes", "TeleManagerImpl::AccountManagerReadyHandler: not prepared");
if (!bPrepared || pError)
{
- SAL_WARN_IF( pError, "tubes", "TeleManager_AccountManagerReadyHandler: error: " << pError->message);
+ SAL_WARN_IF( pError, "tubes", "TeleManagerImpl::AccountManagerReadyHandler: error: " << pError->message);
g_error_free( pError);
}
- TeleManager::setAccountManagerReady( bPrepared);
- TeleManager::setAccountManagerReadyHandlerInvoked( true);
+ mbAccountManagerReady = bPrepared;
+ mbAccountManagerReadyHandlerInvoked = true;
}
bool TeleManager::init( bool bListen )
@@ -513,9 +510,11 @@ bool TeleManager::createAccountManager()
pImpl->mpAccountManager = tp_account_manager_new_with_factory (pImpl->mpFactory);
tp_account_manager_set_default (pImpl->mpAccountManager);
- setAccountManagerReadyHandlerInvoked( false);
- tp_proxy_prepare_async( pImpl->mpAccountManager, NULL, TeleManager_AccountManagerReadyHandler, NULL);
- lcl_iterateLoop( &TeleManager::isAccountManagerReadyHandlerInvoked);
+ pImpl->mbAccountManagerReadyHandlerInvoked = false;
+ tp_proxy_prepare_async( pImpl->mpAccountManager, NULL, TeleManagerImpl::AccountManagerReadyHandler, NULL);
+ while (!pImpl->mbAccountManagerReadyHandlerInvoked)
+ g_main_context_iteration( NULL, TRUE);
+
return pImpl->mbAccountManagerReady;
}
@@ -661,14 +660,15 @@ TeleConference* TeleManager::startGroupSession( TpAccount *pAccount,
return NULL;
}
- setChannelReadyHandlerInvoked( false);
+ pImpl->mbChannelReadyHandlerInvoked = false;
TeleConference* pConference = new TeleConference( NULL, NULL, aSessionId );
tp_account_channel_request_create_and_handle_channel_async(
- pChannelRequest, NULL, TeleManager_ChannelReadyHandler, pConference);
+ pChannelRequest, NULL, TeleManagerImpl::ChannelReadyHandler, pConference);
- lcl_iterateLoop( &TeleManager::isChannelReadyHandlerInvoked);
+ while (!pImpl->mbChannelReadyHandlerInvoked)
+ g_main_context_iteration( NULL, TRUE );
g_object_unref( pChannelRequest);
g_hash_table_unref( pRequest);
@@ -736,14 +736,15 @@ TeleConference* TeleManager::startBuddySession( TpAccount *pAccount, TpContact *
return NULL;
}
- setChannelReadyHandlerInvoked( false);
+ pImpl->mbChannelReadyHandlerInvoked = false;
TeleConference* pConference = new TeleConference( NULL, NULL, createUuid(), true );
tp_account_channel_request_create_and_handle_channel_async(
- pChannelRequest, NULL, TeleManager_ChannelReadyHandler, pConference );
+ pChannelRequest, NULL, TeleManagerImpl::ChannelReadyHandler, pConference );
- lcl_iterateLoop( &TeleManager::isChannelReadyHandlerInvoked);
+ while (!pImpl->mbChannelReadyHandlerInvoked)
+ g_main_context_iteration( NULL, TRUE );
g_object_unref( pChannelRequest);
g_hash_table_unref( pRequest);
@@ -754,26 +755,6 @@ TeleConference* TeleManager::startBuddySession( TpAccount *pAccount, TpContact *
return pConference;
}
-void TeleManager::setAccountManagerReadyHandlerInvoked( bool b )
-{
- pImpl->mbAccountManagerReadyHandlerInvoked = b;
-}
-
-bool TeleManager::isAccountManagerReadyHandlerInvoked()
-{
- return pImpl->mbAccountManagerReadyHandlerInvoked;
-}
-
-void TeleManager::setChannelReadyHandlerInvoked( bool b )
-{
- pImpl->mbChannelReadyHandlerInvoked = b;
-}
-
-bool TeleManager::isChannelReadyHandlerInvoked()
-{
- return pImpl->mbChannelReadyHandlerInvoked;
-}
-
ContactList* TeleManager::getContactList()
{
if (!pImpl->mpContactList)
@@ -782,11 +763,6 @@ ContactList* TeleManager::getContactList()
return pImpl->mpContactList;
}
-void TeleManager::setAccountManagerReady( bool bPrepared)
-{
- pImpl->mbAccountManagerReady = bPrepared;
-}
-
rtl::OString TeleManager::getFullClientName()
{
OStringBuffer aBuf(64);
@@ -847,9 +823,6 @@ TeleManagerImpl::TeleManagerImpl()
mpClient( NULL),
mpFileTransferClient( NULL),
mpAccountManager( NULL),
- mbAccountManagerReady( false),
- mbAccountManagerReadyHandlerInvoked( false),
- mbChannelReadyHandlerInvoked( false),
mpContactList( NULL)
{
g_type_init();
commit 27861421a3b5f9045306195710a4c2b7bd1555ea
Author: Matúš Kukan <matus.kukan at gmail.com>
Date: Thu Aug 16 00:47:02 2012 +0200
tubes: do not include tubes' object files in unit test library
Instead link against the library again.
Unit test is now closer to what the real app looks like.
Only 4 more functions exported because of unit test.
Change-Id: I6fd784725564e577658d68ff7fe0595a79cf7639
diff --git a/tubes/CppunitTest_tubes_test.mk b/tubes/CppunitTest_tubes_test.mk
index 7c9f08a..f40f0f4 100644
--- a/tubes/CppunitTest_tubes_test.mk
+++ b/tubes/CppunitTest_tubes_test.mk
@@ -35,24 +35,14 @@ $(eval $(call gb_CppunitTest_set_include,tubes_test, \
$$(INCLUDE) \
))
-$(eval $(call gb_CppunitTest_use_packages,tubes_test,tubes_inc))
-
-$(eval $(call gb_CppunitTest_use_library_objects,tubes_test,tubes))
-
$(eval $(call gb_CppunitTest_use_libraries,tubes_test, \
- comphelper \
- cppu \
sal \
- svt \
- svxcore \
- tl \
+ tubes \
utl \
- vcl \
$(gb_STDLIBS) \
))
$(eval $(call gb_CppunitTest_use_externals,tubes_test,\
- gtk \
telepathy \
))
diff --git a/tubes/Library_tubes.mk b/tubes/Library_tubes.mk
index 2cdac5f..1c20e2b 100644
--- a/tubes/Library_tubes.mk
+++ b/tubes/Library_tubes.mk
@@ -27,6 +27,8 @@
$(eval $(call gb_Library_Library,tubes))
+$(eval $(call gb_Library_use_packages,tubes,tubes_inc))
+
$(eval $(call gb_Library_set_include,tubes,\
-I$(SRCDIR)/tubes/inc \
$$(INCLUDE) \
diff --git a/tubes/inc/tubes/contact-list.hxx b/tubes/inc/tubes/contact-list.hxx
index 6dc4f32..cc4ba29 100644
--- a/tubes/inc/tubes/contact-list.hxx
+++ b/tubes/inc/tubes/contact-list.hxx
@@ -29,6 +29,8 @@
#ifndef INCLUDED_TUBES_CONTACT_LIST_HXX
#define INCLUDED_TUBES_CONTACT_LIST_HXX
+#include <tubes/tubesdllapi.h>
+
#include <set>
#include <utility>
#include <vector>
@@ -46,7 +48,8 @@ public:
ContactList(TpAccountManager *pAccountManager);
~ContactList();
- AccountContactPairV getContacts();
+ // exported for unit test
+ TUBES_DLLPUBLIC AccountContactPairV getContacts();
private:
TpAccountManager* mpAccountManager;
diff --git a/tubes/inc/tubes/manager.hxx b/tubes/inc/tubes/manager.hxx
index 22a3dae..ce17fd9 100644
--- a/tubes/inc/tubes/manager.hxx
+++ b/tubes/inc/tubes/manager.hxx
@@ -81,7 +81,8 @@ public:
/** Fetches the contact list. Returns 0 before connect() is called successfully.
Is non-functional until prepareAccountManager().
*/
- static ContactList* getContactList();
+ // exported for unit test
+ TUBES_DLLPUBLIC static ContactList* getContactList();
/** Start a demo session where all local documents are shared to each other */
static TeleConference* startDemoSession();
@@ -112,7 +113,8 @@ public:
@param pBuddy
The buddy to be connected. Must be a contact of pAccount.
*/
- static TeleConference* startBuddySession( TpAccount *pAccount, TpContact *pBuddy );
+ // exported for unit test
+ TUBES_DLLPUBLIC static TeleConference* startBuddySession( TpAccount *pAccount, TpContact *pBuddy );
static void registerCollaboration( Collaboration* pCollaboration );
static void unregisterCollaboration( Collaboration* pCollaboration );
@@ -154,7 +156,8 @@ public:
used it must be called before the first TeleManager is instanciated and
connects.
*/
- static void addSuffixToNames( const char* pName );
+ // exported for unit test
+ TUBES_DLLPUBLIC static void addSuffixToNames( const char* pName );
private:
static TeleManagerImpl* pImpl;
diff --git a/tubes/qa/test_manager.cxx b/tubes/qa/test_manager.cxx
index a531265..2e5543e 100644
--- a/tubes/qa/test_manager.cxx
+++ b/tubes/qa/test_manager.cxx
@@ -36,13 +36,14 @@
#include <rtl/string.hxx>
#include <rtl/ustring.hxx>
#include <tubes/collaboration.hxx>
-#include <tubes/conference.hxx>
#include <tubes/contact-list.hxx>
#include <tubes/manager.hxx>
#include <unotools/localfilehelper.hxx>
#include <telepathy-glib/telepathy-glib.h>
+class TeleConference;
+
namespace {
class TestTeleTubes: public CppUnit::TestFixture
@@ -53,24 +54,20 @@ public:
~TestTeleTubes() {}
// This could happen in costructor wasn't there TestTeleTubes instance for each test:
void testInitialize();
- void testCreateAccountManager();
- void testRegisterClients();
+ void testInitTeleManager();
void testContactList();
void testStartBuddySession();
void testSendPacket();
- void testReceivePacket();
void testDestroyTeleTubes();
void testFailAlways();
// Order is significant.
CPPUNIT_TEST_SUITE( TestTeleTubes );
CPPUNIT_TEST( testInitialize );
- CPPUNIT_TEST( testCreateAccountManager );
- CPPUNIT_TEST( testRegisterClients );
+ CPPUNIT_TEST( testInitTeleManager );
CPPUNIT_TEST( testContactList );
CPPUNIT_TEST( testStartBuddySession );
CPPUNIT_TEST( testSendPacket );
- CPPUNIT_TEST( testReceivePacket );
CPPUNIT_TEST( testDestroyTeleTubes );
#if 0
CPPUNIT_TEST( testFailAlways ); // test failure displays SAL_LOG, uncomment for debugging
@@ -80,12 +77,11 @@ public:
class TestCollaboration;
// static, not members, so they actually survive cppunit test iteration
-static TestCollaboration* mpCollaboration = NULL;
-static TeleConference* mpConference1 = NULL;
-static TeleConference* mpConference2 = NULL;
+static TestCollaboration* mpCollaboration1 = NULL;
+static TestCollaboration* mpCollaboration2 = NULL;
static TpAccount* mpOffererAccount = NULL;
static TpContact* mpAccepterContact = NULL;
-static bool mbFileSentSuccess = false;
+//static bool mbFileSentSuccess = false;
static bool mbPacketReceived = false;
static OUString maTestConfigIniURL;
static OString maOffererIdentifier;
@@ -130,19 +126,13 @@ void TestTeleTubes::testInitialize()
maAccepterIdentifier = OUStringToOString( aAccepterIdentifier, RTL_TEXTENCODING_UTF8);
g_timeout_add_seconds (10, timed_out, NULL);
- mpCollaboration = new TestCollaboration();
+ mpCollaboration1 = new TestCollaboration();
+ mpCollaboration2 = new TestCollaboration();
}
-void TestTeleTubes::testCreateAccountManager()
+void TestTeleTubes::testInitTeleManager()
{
- bool bConnected = TeleManager::createAccountManager();
- CPPUNIT_ASSERT( bConnected == true);
-}
-
-void TestTeleTubes::testRegisterClients()
-{
- bool bRegistered = TeleManager::registerClients();
- CPPUNIT_ASSERT( bRegistered == true);
+ CPPUNIT_ASSERT( TeleManager::init( true));
}
void TestTeleTubes::testContactList()
@@ -185,41 +175,39 @@ void TestTeleTubes::testContactList()
mpAccepterContact);
}
+/* FIXME: do we need the possibility to pass function to Collaboration::SendFile() ?
static void lcl_FileSent( bool success, void * )
{
mbFileSentSuccess = success;
}
+*/
void TestTeleTubes::testStartBuddySession()
{
+ TeleConference* pConference = NULL;
CPPUNIT_ASSERT( mpOffererAccount != 0);
CPPUNIT_ASSERT( mpAccepterContact != 0);
- mpConference1 = TeleManager::startBuddySession( mpOffererAccount, mpAccepterContact);
- CPPUNIT_ASSERT( mpConference1 != NULL);
- mpConference1->sendFile( mpAccepterContact, maTestConfigIniURL, lcl_FileSent, NULL);
+ pConference = TeleManager::startBuddySession( mpOffererAccount, mpAccepterContact);
+ CPPUNIT_ASSERT( pConference != NULL);
+ mpCollaboration1->SetConference( pConference );
+ mpCollaboration1->SendFile( mpAccepterContact, maTestConfigIniURL );
- while (!mbFileSentSuccess)
- g_main_context_iteration( NULL, TRUE);
+ //while (!mbFileSentSuccess)
+ // g_main_context_iteration( NULL, TRUE);
// This checks that the file was received and msCurrentUUID set (see manager.cxx)
while (!TeleManager::hasWaitingConference())
g_main_context_iteration( NULL, TRUE);
- mpConference2 = TeleManager::getConference();
- CPPUNIT_ASSERT( mpConference2 != NULL);
- mpCollaboration->SetConference( mpConference2 );
+ pConference = TeleManager::getConference();
+ CPPUNIT_ASSERT( pConference != NULL);
+ mpCollaboration2->SetConference( pConference );
}
void TestTeleTubes::testSendPacket()
{
- bool bSentPacket = false;
- if (mpConference1)
- bSentPacket = mpConference1->sendPacket( "from 1 to 2");
- CPPUNIT_ASSERT( bSentPacket);
-}
+ mpCollaboration1->SendPacket( "from 1 to 2");
-void TestTeleTubes::testReceivePacket()
-{
while (!mbPacketReceived)
g_main_context_iteration( NULL, TRUE);
}
@@ -234,14 +222,9 @@ void TestTeleTubes::testDestroyTeleTubes()
g_object_unref(mpAccepterContact);
mpAccepterContact = NULL;
}
-
- if (mpConference1)
- mpConference1->close();
- delete mpConference1;
-
- if (mpConference2)
- mpConference2->close();
- delete mpConference2;
+ // Closes the TeleConference in destructor:
+ delete mpCollaboration1;
+ delete mpCollaboration2;
TeleManager::finalize();
}
diff --git a/tubes/source/collaboration.cxx b/tubes/source/collaboration.cxx
index c957091..a6e5ec0 100644
--- a/tubes/source/collaboration.cxx
+++ b/tubes/source/collaboration.cxx
@@ -42,12 +42,14 @@ void Collaboration::Invite( TpContact* pContact ) const
void Collaboration::SendFile( TpContact* pContact, const OUString& rURL ) const
{
- mpConference->sendFile( pContact, rURL, NULL, NULL );
+ if (mpConference)
+ mpConference->sendFile( pContact, rURL, NULL, NULL );
}
void Collaboration::SendPacket( const OString& rPacket ) const
{
- mpConference->sendPacket( rPacket );
+ if (mpConference)
+ mpConference->sendPacket( rPacket );
}
void Collaboration::SetConference( TeleConference* pConference )
commit d59a7fda64d6bc773548b124a42c97df08b6ee3a
Author: Matúš Kukan <matus.kukan at gmail.com>
Date: Thu Aug 16 00:08:20 2012 +0200
tubes: implement simple TestCollaboration to test receiving packets
Change-Id: I46621589f2e1282fbaf369bdb387bb63c5768206
diff --git a/tubes/qa/test_manager.cxx b/tubes/qa/test_manager.cxx
index fbd9a64..a531265 100644
--- a/tubes/qa/test_manager.cxx
+++ b/tubes/qa/test_manager.cxx
@@ -35,6 +35,7 @@
#include <rtl/bootstrap.hxx>
#include <rtl/string.hxx>
#include <rtl/ustring.hxx>
+#include <tubes/collaboration.hxx>
#include <tubes/conference.hxx>
#include <tubes/contact-list.hxx>
#include <tubes/manager.hxx>
@@ -68,8 +69,8 @@ public:
CPPUNIT_TEST( testRegisterClients );
CPPUNIT_TEST( testContactList );
CPPUNIT_TEST( testStartBuddySession );
- //CPPUNIT_TEST( testSendPacket );
- //CPPUNIT_TEST( testReceivePacket );
+ CPPUNIT_TEST( testSendPacket );
+ CPPUNIT_TEST( testReceivePacket );
CPPUNIT_TEST( testDestroyTeleTubes );
#if 0
CPPUNIT_TEST( testFailAlways ); // test failure displays SAL_LOG, uncomment for debugging
@@ -77,16 +78,31 @@ public:
CPPUNIT_TEST_SUITE_END();
};
+class TestCollaboration;
// static, not members, so they actually survive cppunit test iteration
+static TestCollaboration* mpCollaboration = NULL;
static TeleConference* mpConference1 = NULL;
static TeleConference* mpConference2 = NULL;
static TpAccount* mpOffererAccount = NULL;
static TpContact* mpAccepterContact = NULL;
static bool mbFileSentSuccess = false;
+static bool mbPacketReceived = false;
static OUString maTestConfigIniURL;
static OString maOffererIdentifier;
static OString maAccepterIdentifier;
+class TestCollaboration : public Collaboration
+{
+ virtual void EndCollaboration() const {}
+ virtual void PacketReceived( const OString& rPacket ) const
+ {
+ CPPUNIT_ASSERT( rPacket == "from 1 to 2");
+ mbPacketReceived = true;
+ }
+ virtual void SaveAndSendFile( TpContact* ) const {}
+ virtual void StartCollaboration( TeleConference* ) {}
+};
+
static gboolean timed_out( void * )
{
CPPUNIT_ASSERT_MESSAGE( "Test took longer than ten seconds!", false);
@@ -114,6 +130,7 @@ void TestTeleTubes::testInitialize()
maAccepterIdentifier = OUStringToOString( aAccepterIdentifier, RTL_TEXTENCODING_UTF8);
g_timeout_add_seconds (10, timed_out, NULL);
+ mpCollaboration = new TestCollaboration();
}
void TestTeleTubes::testCreateAccountManager()
@@ -190,6 +207,7 @@ void TestTeleTubes::testStartBuddySession()
mpConference2 = TeleManager::getConference();
CPPUNIT_ASSERT( mpConference2 != NULL);
+ mpCollaboration->SetConference( mpConference2 );
}
void TestTeleTubes::testSendPacket()
@@ -202,7 +220,8 @@ void TestTeleTubes::testSendPacket()
void TestTeleTubes::testReceivePacket()
{
- // TODO implement me
+ while (!mbPacketReceived)
+ g_main_context_iteration( NULL, TRUE);
}
void TestTeleTubes::testDestroyTeleTubes()
commit ece8eadbc0ba433c85c313eb11f0233aeae24cb9
Author: Matúš Kukan <matus.kukan at gmail.com>
Date: Wed Aug 15 14:50:03 2012 +0200
tubes: fix unittest again and simplify
- killed GMailLoop, seems to work with g_main_context_iteration( NULL, TRUE);
- added test for sending and also receiving file
Change-Id: Ida11f875709dab71d404697e8c39fe4548f653b0
diff --git a/tubes/CppunitTest_tubes_test.mk b/tubes/CppunitTest_tubes_test.mk
index 6b3b40d..7c9f08a 100644
--- a/tubes/CppunitTest_tubes_test.mk
+++ b/tubes/CppunitTest_tubes_test.mk
@@ -52,6 +52,7 @@ $(eval $(call gb_CppunitTest_use_libraries,tubes_test, \
))
$(eval $(call gb_CppunitTest_use_externals,tubes_test,\
+ gtk \
telepathy \
))
diff --git a/tubes/inc/tubes/manager.hxx b/tubes/inc/tubes/manager.hxx
index 06f682d..22a3dae 100644
--- a/tubes/inc/tubes/manager.hxx
+++ b/tubes/inc/tubes/manager.hxx
@@ -156,8 +156,6 @@ public:
*/
static void addSuffixToNames( const char* pName );
- static TpAccount* getAccount( const rtl::OString& rAccountID );
-
private:
static TeleManagerImpl* pImpl;
diff --git a/tubes/qa/test_manager.cxx b/tubes/qa/test_manager.cxx
index 76f093c..fbd9a64 100644
--- a/tubes/qa/test_manager.cxx
+++ b/tubes/qa/test_manager.cxx
@@ -58,12 +58,9 @@ public:
void testStartBuddySession();
void testSendPacket();
void testReceivePacket();
- void testSendFile();
void testDestroyTeleTubes();
void testFailAlways();
- static void FileSent( bool success, void *user_data);
-
// Order is significant.
CPPUNIT_TEST_SUITE( TestTeleTubes );
CPPUNIT_TEST( testInitialize );
@@ -71,9 +68,8 @@ public:
CPPUNIT_TEST( testRegisterClients );
CPPUNIT_TEST( testContactList );
CPPUNIT_TEST( testStartBuddySession );
- CPPUNIT_TEST( testSendPacket );
- CPPUNIT_TEST( testReceivePacket );
- CPPUNIT_TEST( testSendFile );
+ //CPPUNIT_TEST( testSendPacket );
+ //CPPUNIT_TEST( testReceivePacket );
CPPUNIT_TEST( testDestroyTeleTubes );
#if 0
CPPUNIT_TEST( testFailAlways ); // test failure displays SAL_LOG, uncomment for debugging
@@ -83,22 +79,18 @@ public:
// static, not members, so they actually survive cppunit test iteration
static TeleConference* mpConference1 = NULL;
+static TeleConference* mpConference2 = NULL;
+static TpAccount* mpOffererAccount = NULL;
static TpContact* mpAccepterContact = NULL;
-static GMainLoop* mpMainLoop = NULL;
-static bool maFileSentSuccess = false;
-static sal_uInt32 mnSentPackets = 0;
+static bool mbFileSentSuccess = false;
static OUString maTestConfigIniURL;
static OString maOffererIdentifier;
static OString maAccepterIdentifier;
-static gboolean
-timed_out (void *user_data)
+static gboolean timed_out( void * )
{
CPPUNIT_ASSERT_MESSAGE( "Test took longer than ten seconds!", false);
- GMainLoop *loop = reinterpret_cast<GMainLoop *>(user_data);
-
- g_main_loop_quit (loop);
return FALSE;
}
@@ -121,24 +113,24 @@ void TestTeleTubes::testInitialize()
aTestConfig.getFrom("accepter", aAccepterIdentifier));
maAccepterIdentifier = OUStringToOString( aAccepterIdentifier, RTL_TEXTENCODING_UTF8);
- mpMainLoop = g_main_loop_new (NULL, FALSE);
- g_timeout_add_seconds (10, timed_out, mpMainLoop);
+ g_timeout_add_seconds (10, timed_out, NULL);
}
-void TestTeleTubes::testContactList()
+void TestTeleTubes::testCreateAccountManager()
{
- ContactList *cl = TeleManager::getContactList();
-
- AccountContactPairV pairs;
-
- pairs = cl->getContacts();
- guint i;
+ bool bConnected = TeleManager::createAccountManager();
+ CPPUNIT_ASSERT( bConnected == true);
+}
- /* FIXME: this is racy, because we can't be 100% sure that MC has finished
- * discovering what we support and passing that on to the connection
- * manager...
- */
+void TestTeleTubes::testRegisterClients()
+{
+ bool bRegistered = TeleManager::registerClients();
+ CPPUNIT_ASSERT( bRegistered == true);
+}
+void TestTeleTubes::testContactList()
+{
+ AccountContactPairV pairs = TeleManager::getContactList()->getContacts();
/* Both our accounts are meant to be signed in, and they both should be
* capable of LibreOffice tubes because this test runs after we register
* our handler. */
@@ -148,97 +140,90 @@ void TestTeleTubes::testContactList()
pairs.size() > 0 );
CPPUNIT_ASSERT(!mpAccepterContact);
- for (i = 0; i < pairs.size(); i++)
+ for (guint i = 0; i < pairs.size(); i++)
{
AccountContactPair pair = pairs[i];
- /* FIXME: verify that pair.first is the offerer account */
- if (tp_contact_get_identifier(pair.second) == maAccepterIdentifier) {
+ if (tp_account_get_normalized_name (pair.first) == maOffererIdentifier &&
+ tp_contact_get_identifier (pair.second) == maAccepterIdentifier)
+ {
+ mpOffererAccount = pair.first;
+ g_object_ref (mpOffererAccount);
mpAccepterContact = pair.second;
- g_object_ref(mpAccepterContact);
+ g_object_ref (mpAccepterContact);
}
g_object_unref (pair.first);
g_object_unref (pair.second);
}
CPPUNIT_ASSERT_MESSAGE(
+ "Couldn't find offerer account. "
+ "Make sure both your test accounts are signed in "
+ "and are on each other's contact lists",
+ mpOffererAccount);
+ CPPUNIT_ASSERT_MESSAGE(
"Couldn't find accepter contact. "
"Make sure both your test accounts are signed in "
"and are on each other's contact lists",
mpAccepterContact);
}
+static void lcl_FileSent( bool success, void * )
+{
+ mbFileSentSuccess = success;
+}
+
void TestTeleTubes::testStartBuddySession()
{
- TpAccount *pAcc1 = TeleManager::getAccount(maOffererIdentifier);
- CPPUNIT_ASSERT( pAcc1 != 0);
- /* This has to run after testContactList has run successfully. */
+ CPPUNIT_ASSERT( mpOffererAccount != 0);
CPPUNIT_ASSERT( mpAccepterContact != 0);
- mpConference1 = TeleManager::startBuddySession( pAcc1, mpAccepterContact);
+ mpConference1 = TeleManager::startBuddySession( mpOffererAccount, mpAccepterContact);
CPPUNIT_ASSERT( mpConference1 != NULL);
-}
+ mpConference1->sendFile( mpAccepterContact, maTestConfigIniURL, lcl_FileSent, NULL);
-void TestTeleTubes::testCreateAccountManager()
-{
- bool bConnected = TeleManager::createAccountManager();
- CPPUNIT_ASSERT( bConnected == true);
-}
+ while (!mbFileSentSuccess)
+ g_main_context_iteration( NULL, TRUE);
-void TestTeleTubes::testRegisterClients()
-{
- bool bRegistered = TeleManager::registerClients();
- CPPUNIT_ASSERT( bRegistered == true);
+ // This checks that the file was received and msCurrentUUID set (see manager.cxx)
+ while (!TeleManager::hasWaitingConference())
+ g_main_context_iteration( NULL, TRUE);
+
+ mpConference2 = TeleManager::getConference();
+ CPPUNIT_ASSERT( mpConference2 != NULL);
}
void TestTeleTubes::testSendPacket()
{
- OString aPacket( "from 1 to 2" );
-
- bool bSentPacket = mpConference1->sendPacket( aPacket );
- CPPUNIT_ASSERT( bSentPacket );
- mnSentPackets++;
+ bool bSentPacket = false;
+ if (mpConference1)
+ bSentPacket = mpConference1->sendPacket( "from 1 to 2");
+ CPPUNIT_ASSERT( bSentPacket);
}
void TestTeleTubes::testReceivePacket()
{
- /* We can't get to the TeleConference accepting our packets.
- * It's stored in TeleManager but available only after receiving file
- * and extracting UUID from the name.
- */
-
// TODO implement me
}
-void TestTeleTubes::FileSent( bool success, void * )
-{
- maFileSentSuccess = success;
- g_main_loop_quit (mpMainLoop);
-}
-
-void TestTeleTubes::testSendFile()
-{
- /* This has to run after testContactList has run successfully. */
- CPPUNIT_ASSERT( mpAccepterContact != 0);
-
- mpConference1->sendFile( mpAccepterContact, maTestConfigIniURL,
- &TestTeleTubes::FileSent, NULL);
- /* Waiting for event: FileSent quits the mainloop */
- g_main_loop_run( mpMainLoop);
-
- CPPUNIT_ASSERT( maFileSentSuccess);
- // Currently there is no way to check that the file was received !
-}
-
void TestTeleTubes::testDestroyTeleTubes()
{
+ if (mpOffererAccount) {
+ g_object_unref(mpOffererAccount);
+ mpOffererAccount = NULL;
+ }
if (mpAccepterContact) {
g_object_unref(mpAccepterContact);
mpAccepterContact = NULL;
}
- g_main_loop_unref( mpMainLoop );
+
if (mpConference1)
mpConference1->close();
delete mpConference1;
+
+ if (mpConference2)
+ mpConference2->close();
+ delete mpConference2;
+
TeleManager::finalize();
}
@@ -247,7 +232,6 @@ void TestTeleTubes::testFailAlways()
CPPUNIT_ASSERT( false);
}
-
CPPUNIT_TEST_SUITE_REGISTRATION( TestTeleTubes);
}
diff --git a/tubes/source/contacts.cxx b/tubes/source/contacts.cxx
index 2a75f23..5a46248 100644
--- a/tubes/source/contacts.cxx
+++ b/tubes/source/contacts.cxx
@@ -230,6 +230,9 @@ public:
// FIXME: ref the TpAccount, TpContact ...
maACs.push_back( AccountContactPair( it->first, it->second ) );
pEntry->SetUserData( &maACs.back() );
+
+ g_object_unref (it->first);
+ g_object_unref (it->second);
}
}
Show();
diff --git a/tubes/source/manager.cxx b/tubes/source/manager.cxx
index de87a52..f1548c5 100644
--- a/tubes/source/manager.cxx
+++ b/tubes/source/manager.cxx
@@ -266,6 +266,10 @@ void TeleManager_fileReceived( const OUString& rStr, const OString& rUuid )
css::uno::Reference< css::lang::XMultiServiceFactory > rFactory =
::comphelper::getProcessServiceFactory();
+ // Should happen only for unit test
+ if (rFactory == NULL)
+ return;
+
css::uno::Sequence < css::beans::PropertyValue > args(0);
try
{
@@ -336,6 +340,7 @@ static void lcl_IncomingHandlerReady (
g_signal_connect( pHandler, "transfer-done", G_CALLBACK (TeleManager_TransferDone), NULL);
g_signal_connect( pHandler, "transfer-error", G_CALLBACK (TeleManager_TransferError), NULL);
+ SAL_INFO ("tubes", "lcl_IncomingHandlerReady: starting file transfer..");
empathy_ft_handler_start_transfer( pHandler);
}
@@ -777,47 +782,11 @@ ContactList* TeleManager::getContactList()
return pImpl->mpContactList;
}
-TpAccount* TeleManager::getAccount( const rtl::OString& rAccountID )
-{
- INFO_LOGGER_F( "TeleManager::getMyAccount");
-
- SAL_WARN_IF( !pImpl->mbAccountManagerReady, "tubes",
- "TeleManager::getMyAccount: Account Manager not prepared");
- if (!pImpl->mbAccountManagerReady)
- return NULL;
-
- GList* pAccounts = tp_account_manager_get_valid_accounts( pImpl->mpAccountManager);
- SAL_WARN_IF( !pAccounts, "tubes", "TeleManager::getMyAccount: no valid accounts");
- if (!pAccounts)
- return NULL;
-
- // Find our account to use.
- TpAccount* pAccount = NULL;
- for (GList* pA = pAccounts; pA; pA = pA->next)
- {
- TpAccount* pAcc = TP_ACCOUNT( pA->data);
- const gchar* pID = tp_account_get_normalized_name( pAcc);
- if (pID && rAccountID == pID)
- {
- pAccount = pAcc;
- break; // for
- }
- }
- g_list_free( pAccounts);
-
- SAL_WARN_IF( !pAccount, "tubes", "TeleManager::getMyAccount: no account");
- if (!pAccount)
- return NULL;
-
- return pAccount;
-}
-
void TeleManager::setAccountManagerReady( bool bPrepared)
{
pImpl->mbAccountManagerReady = bPrepared;
}
-
rtl::OString TeleManager::getFullClientName()
{
OStringBuffer aBuf(64);
@@ -825,7 +794,6 @@ rtl::OString TeleManager::getFullClientName()
return aBuf.makeStringAndClear();
}
-
rtl::OString TeleManager::getFullServiceName()
{
OStringBuffer aBuf(64);
@@ -833,7 +801,6 @@ rtl::OString TeleManager::getFullServiceName()
return aBuf.makeStringAndClear();
}
-
rtl::OString TeleManager::getFullObjectPath()
{
OStringBuffer aBuf(64);
commit 766a0247fc3ac49b25aab69948e4d0a5df334ff9
Author: Matúš Kukan <matus.kukan at gmail.com>
Date: Wed Aug 15 14:10:22 2012 +0200
tubes: also prepare the Account Manager when creating; and simplify
Change-Id: I7705d627d17f20c3c81de7aa4debbefc127354b0
diff --git a/tubes/inc/tubes/manager.hxx b/tubes/inc/tubes/manager.hxx
index 38e5d8c..06f682d 100644
--- a/tubes/inc/tubes/manager.hxx
+++ b/tubes/inc/tubes/manager.hxx
@@ -57,16 +57,8 @@ class TeleManager
{
TeleManager();
~TeleManager();
-public:
-
- enum AccountManagerStatus
- {
- AMS_UNINITIALIZED = 0,
- AMS_INPREPARATION,
- AMS_UNPREPARABLE,
- AMS_PREPARED
- };
+public:
/** Prepare tube manager with account and service to be offered/listened
to.
*/
@@ -80,23 +72,12 @@ public:
/** Get a conference with current UUID to set a session. */
TUBES_DLLPUBLIC static TeleConference* getConference();
- /** Connect to DBus and create AccountManager. */
+ /** Connect to DBus, create and prepare the Telepathy Account Manager. */
static bool createAccountManager();
/** Setup client handlers. */
static bool registerClients();
- /** Prepare the Telepathy Account Manager.
- Requires createAccountManager() to have succeeded.
-
- Invokes an async call that is not ready until meAccountManagerStatus is
- set! Until that is AMS_PREPARED nothing else will work.
-
- TODO: this needs some signalling mechanism
- */
- static void prepareAccountManager();
- static AccountManagerStatus getAccountManagerStatus();
-
/** Fetches the contact list. Returns 0 before connect() is called successfully.
Is non-functional until prepareAccountManager().
*/
@@ -151,12 +132,10 @@ public:
static void addConference( TeleConference* pConference );
static void setChannelReadyHandlerInvoked( bool b );
static bool isChannelReadyHandlerInvoked();
+ static void setAccountManagerReady( bool bPrepared);
static void setAccountManagerReadyHandlerInvoked( bool b );
static bool isAccountManagerReadyHandlerInvoked();
- /** Only the callback of prepareAccountManager() is to set this. */
- static void setAccountManagerReady( bool bPrepared);
-
/// "LibreOfficeWhatEver"
static rtl::OString getFullClientName();
diff --git a/tubes/qa/test_manager.cxx b/tubes/qa/test_manager.cxx
index 00ce9e5..76f093c 100644
--- a/tubes/qa/test_manager.cxx
+++ b/tubes/qa/test_manager.cxx
@@ -55,7 +55,6 @@ public:
void testCreateAccountManager();
void testRegisterClients();
void testContactList();
- void testPrepareAccountManager();
void testStartBuddySession();
void testSendPacket();
void testReceivePacket();
@@ -70,7 +69,6 @@ public:
CPPUNIT_TEST( testInitialize );
CPPUNIT_TEST( testCreateAccountManager );
CPPUNIT_TEST( testRegisterClients );
- CPPUNIT_TEST( testPrepareAccountManager );
CPPUNIT_TEST( testContactList );
CPPUNIT_TEST( testStartBuddySession );
CPPUNIT_TEST( testSendPacket );
@@ -129,8 +127,6 @@ void TestTeleTubes::testInitialize()
void TestTeleTubes::testContactList()
{
- CPPUNIT_ASSERT( TeleManager::getAccountManagerStatus() == TeleManager::AMS_PREPARED);
-
ContactList *cl = TeleManager::getContactList();
AccountContactPairV pairs;
@@ -172,13 +168,6 @@ void TestTeleTubes::testContactList()
mpAccepterContact);
}
-void TestTeleTubes::testPrepareAccountManager()
-{
- TeleManager::prepareAccountManager();
- TeleManager::AccountManagerStatus eStatus = TeleManager::getAccountManagerStatus();
- CPPUNIT_ASSERT( eStatus == TeleManager::AMS_PREPARED);
-}
-
void TestTeleTubes::testStartBuddySession()
{
TpAccount *pAcc1 = TeleManager::getAccount(maOffererIdentifier);
diff --git a/tubes/source/contact-list.cxx b/tubes/source/contact-list.cxx
index 03fc3b1..e240ece 100644
--- a/tubes/source/contact-list.cxx
+++ b/tubes/source/contact-list.cxx
@@ -40,29 +40,6 @@ ContactList::ContactList(TpAccountManager *pAccountManager)
SAL_WARN_IF( !mpAccountManager, "tubes",
"ContactList::ContactList: passed a null account manager");
g_object_ref( mpAccountManager);
-
- /* Tell the client factory (which creates and prepares proxy objects) to
- * get the features we need ready before giving us any objects.
- */
- TpSimpleClientFactory *factory = tp_proxy_get_factory (mpAccountManager);
- /* We need every online account's connection object to be available... */
- tp_simple_client_factory_add_account_features_varargs (factory,
- TP_ACCOUNT_FEATURE_CONNECTION,
- 0);
- /* ...and we want those connection objects to have the contact list
- * available... */
- tp_simple_client_factory_add_connection_features_varargs (factory,
- TP_CONNECTION_FEATURE_CONTACT_LIST,
- 0);
- /* ...and those contacts should have their alias and their capabilities
- * available.
- */
- tp_simple_client_factory_add_contact_features_varargs (factory,
- TP_CONTACT_FEATURE_ALIAS,
- TP_CONTACT_FEATURE_AVATAR_DATA,
- TP_CONTACT_FEATURE_CAPABILITIES,
- TP_CONTACT_FEATURE_PRESENCE,
- TP_CONTACT_FEATURE_INVALID);
}
ContactList::~ContactList()
diff --git a/tubes/source/manager.cxx b/tubes/source/manager.cxx
index d900cb6..de87a52 100644
--- a/tubes/source/manager.cxx
+++ b/tubes/source/manager.cxx
@@ -83,11 +83,11 @@ using namespace osl;
class TeleManagerImpl
{
public:
- TpAutomaticClientFactory* mpFactory;
+ TpSimpleClientFactory* mpFactory;
TpBaseClient* mpClient;
TpBaseClient* mpFileTransferClient;
TpAccountManager* mpAccountManager;
- TeleManager::AccountManagerStatus meAccountManagerStatus;
+ bool mbAccountManagerReady : 1;
bool mbAccountManagerReadyHandlerInvoked : 1;
bool mbChannelReadyHandlerInvoked : 1;
ContactList* mpContactList;
@@ -441,7 +441,6 @@ bool TeleManager::init( bool bListen )
{
if (createAccountManager())
{
- prepareAccountManager();
if (bListen && !registerClients())
SAL_WARN( "tubes", "TeleManager::init: Could not register client handlers." );
@@ -478,22 +477,41 @@ bool TeleManager::createAccountManager()
return false;
}
- pImpl->mpFactory = tp_automatic_client_factory_new( pDBus);
+ pImpl->mpFactory = TP_SIMPLE_CLIENT_FACTORY( tp_automatic_client_factory_new( pDBus));
g_object_unref( pDBus);
SAL_WARN_IF( !pImpl->mpFactory, "tubes", "TeleManager::createAccountManager: no client factory");
if (!pImpl->mpFactory)
return false;
- TpAccountManager* pAccountManager = tp_account_manager_new_with_factory (
- TP_SIMPLE_CLIENT_FACTORY (pImpl->mpFactory));
- tp_account_manager_set_default( pAccountManager);
-
- /* Takes our ref. */
- pImpl->mpAccountManager = pAccountManager;
+ /* Tell the client factory (which creates and prepares proxy objects) to
+ * get the features we need ready before giving us any objects.
+ */
+ /* We need every online account's connection object to be available... */
+ tp_simple_client_factory_add_account_features_varargs (pImpl->mpFactory,
+ TP_ACCOUNT_FEATURE_CONNECTION,
+ 0);
+ /* ...and we want those connection objects to have the contact list
+ * available... */
+ tp_simple_client_factory_add_connection_features_varargs (pImpl->mpFactory,
+ TP_CONNECTION_FEATURE_CONTACT_LIST,
+ 0);
+ /* ...and those contacts should have their alias and their capabilities
+ * available.
+ */
+ tp_simple_client_factory_add_contact_features_varargs (pImpl->mpFactory,
+ TP_CONTACT_FEATURE_ALIAS,
+ TP_CONTACT_FEATURE_AVATAR_DATA,
+ TP_CONTACT_FEATURE_CAPABILITIES,
+ TP_CONTACT_FEATURE_PRESENCE,
+ TP_CONTACT_FEATURE_INVALID);
- pImpl->mpContactList = new ContactList(pAccountManager);
+ pImpl->mpAccountManager = tp_account_manager_new_with_factory (pImpl->mpFactory);
+ tp_account_manager_set_default (pImpl->mpAccountManager);
- return true;
+ setAccountManagerReadyHandlerInvoked( false);
+ tp_proxy_prepare_async( pImpl->mpAccountManager, NULL, TeleManager_AccountManagerReadyHandler, NULL);
+ lcl_iterateLoop( &TeleManager::isAccountManagerReadyHandlerInvoked);
+ return pImpl->mbAccountManagerReady;
}
bool TeleManager::registerClients()
@@ -508,7 +526,7 @@ bool TeleManager::registerClients()
return true;
pImpl->mpClient = tp_simple_handler_new_with_factory(
- TP_SIMPLE_CLIENT_FACTORY (pImpl->mpFactory), // factory
+ pImpl->mpFactory, // factory
FALSE, // bypass_approval
FALSE, // requests
getFullClientName().getStr(), // name
@@ -556,7 +574,7 @@ bool TeleManager::registerClients()
* user isn't prompted before the channel gets passed to us.
*/
pImpl->mpFileTransferClient = tp_simple_handler_new_with_factory (
- TP_SIMPLE_CLIENT_FACTORY( pImpl->mpFactory), // factory
+ pImpl->mpFactory, // factory
TRUE, // bypass_approval
FALSE, // requests
getFullClientName().getStr(), // name
@@ -731,45 +749,6 @@ TeleConference* TeleManager::startBuddySession( TpAccount *pAccount, TpContact *
return pConference;
}
-void TeleManager::prepareAccountManager()
-{
- INFO_LOGGER_F( "TeleManager::prepareAccountManager");
-
- MutexGuard aGuard( GetMutex());
-
- SAL_INFO_IF( pImpl->meAccountManagerStatus == AMS_PREPARED, "tubes",
- "TeleManager::prepareAccountManager: already prepared");
- if (pImpl->meAccountManagerStatus == AMS_PREPARED)
- return;
-
- SAL_WARN_IF( pImpl->meAccountManagerStatus == AMS_INPREPARATION, "tubes",
- "TeleManager::prepareAccountManager: already in preparation");
- if (pImpl->meAccountManagerStatus == AMS_INPREPARATION)
- return;
-
- SAL_WARN_IF( pImpl->meAccountManagerStatus != AMS_UNINITIALIZED, "tubes",
- "TeleManager::prepareAccountManager: yet another attempt");
-
- SAL_WARN_IF( !pImpl->mpAccountManager, "tubes",
- "TeleManager::prepareAccountManager: called before ::connect()");
- if (!pImpl->mpAccountManager)
- return;
-
- pImpl->meAccountManagerStatus = AMS_INPREPARATION;
- setAccountManagerReadyHandlerInvoked( false);
-
- tp_proxy_prepare_async( pImpl->mpAccountManager, NULL, TeleManager_AccountManagerReadyHandler, NULL);
-
- lcl_iterateLoop( &TeleManager::isAccountManagerReadyHandlerInvoked);
-}
-
-
-TeleManager::AccountManagerStatus TeleManager::getAccountManagerStatus()
-{
- return pImpl->meAccountManagerStatus;
-}
-
-
void TeleManager::setAccountManagerReadyHandlerInvoked( bool b )
{
pImpl->mbAccountManagerReadyHandlerInvoked = b;
@@ -792,6 +771,9 @@ bool TeleManager::isChannelReadyHandlerInvoked()
ContactList* TeleManager::getContactList()
{
+ if (!pImpl->mpContactList)
+ pImpl->mpContactList = new ContactList (pImpl->mpAccountManager);
+
return pImpl->mpContactList;
}
@@ -799,9 +781,9 @@ TpAccount* TeleManager::getAccount( const rtl::OString& rAccountID )
{
INFO_LOGGER_F( "TeleManager::getMyAccount");
- SAL_WARN_IF( pImpl->meAccountManagerStatus != AMS_PREPARED, "tubes",
+ SAL_WARN_IF( !pImpl->mbAccountManagerReady, "tubes",
"TeleManager::getMyAccount: Account Manager not prepared");
- if (pImpl->meAccountManagerStatus != AMS_PREPARED)
+ if (!pImpl->mbAccountManagerReady)
return NULL;
GList* pAccounts = tp_account_manager_get_valid_accounts( pImpl->mpAccountManager);
@@ -832,7 +814,7 @@ TpAccount* TeleManager::getAccount( const rtl::OString& rAccountID )
void TeleManager::setAccountManagerReady( bool bPrepared)
{
- pImpl->meAccountManagerStatus = (bPrepared ? AMS_PREPARED : AMS_UNPREPARABLE);
+ pImpl->mbAccountManagerReady = bPrepared;
}
@@ -898,9 +880,10 @@ TeleManagerImpl::TeleManagerImpl()
mpClient( NULL),
mpFileTransferClient( NULL),
mpAccountManager( NULL),
- meAccountManagerStatus( TeleManager::AMS_UNINITIALIZED),
+ mbAccountManagerReady( false),
mbAccountManagerReadyHandlerInvoked( false),
- mbChannelReadyHandlerInvoked( false)
+ mbChannelReadyHandlerInvoked( false),
+ mpContactList( NULL)
{
g_type_init();
}
More information about the Libreoffice-commits
mailing list