Kaydet (Commit) 4662df8a authored tarafından Matúš Kukan's avatar Matúš Kukan

tubes: simplify and make more readable, I believe

Change-Id: I83a4332d9947d03382b10ea050f26bf3ed544299
üst 27861421
...@@ -132,11 +132,6 @@ public: ...@@ -132,11 +132,6 @@ public:
// Only for callbacks. // Only for callbacks.
static void addConference( TeleConference* pConference ); 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" /// "LibreOfficeWhatEver"
static rtl::OString getFullClientName(); static rtl::OString getFullClientName();
......
...@@ -87,9 +87,9 @@ public: ...@@ -87,9 +87,9 @@ public:
TpBaseClient* mpClient; TpBaseClient* mpClient;
TpBaseClient* mpFileTransferClient; TpBaseClient* mpFileTransferClient;
TpAccountManager* mpAccountManager; TpAccountManager* mpAccountManager;
bool mbAccountManagerReady : 1; static bool mbAccountManagerReady;
bool mbAccountManagerReadyHandlerInvoked : 1; static bool mbAccountManagerReadyHandlerInvoked;
bool mbChannelReadyHandlerInvoked : 1; static bool mbChannelReadyHandlerInvoked;
ContactList* mpContactList; ContactList* mpContactList;
OString msCurrentUUID; OString msCurrentUUID;
OString msNameSuffix; OString msNameSuffix;
...@@ -102,9 +102,14 @@ public: ...@@ -102,9 +102,14 @@ public:
TeleManagerImpl(); TeleManagerImpl();
~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(); TeleManagerImpl* TeleManager::pImpl = new TeleManagerImpl();
bool TeleManagerImpl::mbAccountManagerReady;
bool TeleManagerImpl::mbAccountManagerReadyHandlerInvoked;
bool TeleManagerImpl::mbChannelReadyHandlerInvoked;
static void TeleManager_DBusChannelHandler( static void TeleManager_DBusChannelHandler(
TpSimpleHandler* /*handler*/, TpSimpleHandler* /*handler*/,
...@@ -307,14 +312,6 @@ static void TeleManager_TransferError( EmpathyFTHandler *handler, const GError * ...@@ -307,14 +312,6 @@ static void TeleManager_TransferError( EmpathyFTHandler *handler, const GError *
g_object_unref( handler); g_object_unref( handler);
} }
static void lcl_iterateLoop( bool (*pFunc)() )
{
while (!(*pFunc)())
{
g_main_context_iteration( NULL, TRUE );
}
}
static void lcl_IncomingHandlerReady ( static void lcl_IncomingHandlerReady (
EmpathyFTHandler* pHandler, EmpathyFTHandler* pHandler,
GError* pError, GError* pError,
...@@ -389,20 +386,20 @@ static void TeleManager_FileTransferHandler( ...@@ -389,20 +386,20 @@ static void TeleManager_FileTransferHandler(
} }
} }
static void TeleManager_ChannelReadyHandler( void TeleManagerImpl::ChannelReadyHandler(
GObject* pSourceObject, GObject* pSourceObject,
GAsyncResult* pResult, GAsyncResult* pResult,
gpointer pUserData gpointer pUserData
) )
{ {
INFO_LOGGER_F( "TeleManager_ChannelReadyHandler"); INFO_LOGGER_F( "TeleManagerImpl::ChannelReadyHandler");
TeleConference* pConference = reinterpret_cast<TeleConference*>(pUserData); 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) if (!pConference)
return; return;
TeleManager::setChannelReadyHandlerInvoked( true ); mbChannelReadyHandlerInvoked = true;
TpAccountChannelRequest* pChannelRequest = TP_ACCOUNT_CHANNEL_REQUEST( pSourceObject); TpAccountChannelRequest* pChannelRequest = TP_ACCOUNT_CHANNEL_REQUEST( pSourceObject);
GError* pError = NULL; GError* pError = NULL;
...@@ -412,7 +409,7 @@ static void TeleManager_ChannelReadyHandler( ...@@ -412,7 +409,7 @@ static void TeleManager_ChannelReadyHandler(
{ {
// "account isn't Enabled" means just that.. // "account isn't Enabled" means just that..
/* FIXME: detect and handle, domain=132, code=3 */ /* 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); g_error_free( pError);
return; return;
} }
...@@ -421,25 +418,25 @@ static void TeleManager_ChannelReadyHandler( ...@@ -421,25 +418,25 @@ static void TeleManager_ChannelReadyHandler(
pConference->offerTube(); pConference->offerTube();
} }
static void TeleManager_AccountManagerReadyHandler( void TeleManagerImpl::AccountManagerReadyHandler(
GObject* pSourceObject, GObject* pSourceObject,
GAsyncResult* pResult, GAsyncResult* pResult,
gpointer /*pUserData*/ gpointer /*pUserData*/
) )
{ {
INFO_LOGGER_F( "TeleManager_AccountManagerReadyHandler"); INFO_LOGGER_F( "TeleManagerImpl::AccountManagerReadyHandler");
GError* pError = NULL; GError* pError = NULL;
gboolean bPrepared = tp_proxy_prepare_finish( pSourceObject, pResult, &pError); 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) 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); g_error_free( pError);
} }
TeleManager::setAccountManagerReady( bPrepared); mbAccountManagerReady = bPrepared;
TeleManager::setAccountManagerReadyHandlerInvoked( true); mbAccountManagerReadyHandlerInvoked = true;
} }
bool TeleManager::init( bool bListen ) bool TeleManager::init( bool bListen )
...@@ -513,9 +510,11 @@ bool TeleManager::createAccountManager() ...@@ -513,9 +510,11 @@ bool TeleManager::createAccountManager()
pImpl->mpAccountManager = tp_account_manager_new_with_factory (pImpl->mpFactory); pImpl->mpAccountManager = tp_account_manager_new_with_factory (pImpl->mpFactory);
tp_account_manager_set_default (pImpl->mpAccountManager); tp_account_manager_set_default (pImpl->mpAccountManager);
setAccountManagerReadyHandlerInvoked( false); pImpl->mbAccountManagerReadyHandlerInvoked = false;
tp_proxy_prepare_async( pImpl->mpAccountManager, NULL, TeleManager_AccountManagerReadyHandler, NULL); tp_proxy_prepare_async( pImpl->mpAccountManager, NULL, TeleManagerImpl::AccountManagerReadyHandler, NULL);
lcl_iterateLoop( &TeleManager::isAccountManagerReadyHandlerInvoked); while (!pImpl->mbAccountManagerReadyHandlerInvoked)
g_main_context_iteration( NULL, TRUE);
return pImpl->mbAccountManagerReady; return pImpl->mbAccountManagerReady;
} }
...@@ -661,14 +660,15 @@ TeleConference* TeleManager::startGroupSession( TpAccount *pAccount, ...@@ -661,14 +660,15 @@ TeleConference* TeleManager::startGroupSession( TpAccount *pAccount,
return NULL; return NULL;
} }
setChannelReadyHandlerInvoked( false); pImpl->mbChannelReadyHandlerInvoked = false;
TeleConference* pConference = new TeleConference( NULL, NULL, aSessionId ); TeleConference* pConference = new TeleConference( NULL, NULL, aSessionId );
tp_account_channel_request_create_and_handle_channel_async( 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_object_unref( pChannelRequest);
g_hash_table_unref( pRequest); g_hash_table_unref( pRequest);
...@@ -736,14 +736,15 @@ TeleConference* TeleManager::startBuddySession( TpAccount *pAccount, TpContact * ...@@ -736,14 +736,15 @@ TeleConference* TeleManager::startBuddySession( TpAccount *pAccount, TpContact *
return NULL; return NULL;
} }
setChannelReadyHandlerInvoked( false); pImpl->mbChannelReadyHandlerInvoked = false;
TeleConference* pConference = new TeleConference( NULL, NULL, createUuid(), true ); TeleConference* pConference = new TeleConference( NULL, NULL, createUuid(), true );
tp_account_channel_request_create_and_handle_channel_async( 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_object_unref( pChannelRequest);
g_hash_table_unref( pRequest); g_hash_table_unref( pRequest);
...@@ -754,26 +755,6 @@ TeleConference* TeleManager::startBuddySession( TpAccount *pAccount, TpContact * ...@@ -754,26 +755,6 @@ TeleConference* TeleManager::startBuddySession( TpAccount *pAccount, TpContact *
return pConference; 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() ContactList* TeleManager::getContactList()
{ {
if (!pImpl->mpContactList) if (!pImpl->mpContactList)
...@@ -782,11 +763,6 @@ ContactList* TeleManager::getContactList() ...@@ -782,11 +763,6 @@ ContactList* TeleManager::getContactList()
return pImpl->mpContactList; return pImpl->mpContactList;
} }
void TeleManager::setAccountManagerReady( bool bPrepared)
{
pImpl->mbAccountManagerReady = bPrepared;
}
rtl::OString TeleManager::getFullClientName() rtl::OString TeleManager::getFullClientName()
{ {
OStringBuffer aBuf(64); OStringBuffer aBuf(64);
...@@ -847,9 +823,6 @@ TeleManagerImpl::TeleManagerImpl() ...@@ -847,9 +823,6 @@ TeleManagerImpl::TeleManagerImpl()
mpClient( NULL), mpClient( NULL),
mpFileTransferClient( NULL), mpFileTransferClient( NULL),
mpAccountManager( NULL), mpAccountManager( NULL),
mbAccountManagerReady( false),
mbAccountManagerReadyHandlerInvoked( false),
mbChannelReadyHandlerInvoked( false),
mpContactList( NULL) mpContactList( NULL)
{ {
g_type_init(); g_type_init();
......
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