diff --git a/src/account.cpp b/src/account.cpp index a34da5011336d93a18f8daf92d65d0fdb5cefdbb..71dde896dcadc9457150b748721a47ccf14effd9 100644 --- a/src/account.cpp +++ b/src/account.cpp @@ -27,6 +27,7 @@ Account::Account(const AccountID& accountID) : _accountID(accountID) _shouldRegisterOnStart = false; _enabled = false; _registered = false; + _state = false; } diff --git a/src/account.h b/src/account.h index 0301649e2d0d7122549fe87afaaf87a1e2587634..8ef3c766334ba0b5b733441fd552402a28dfad6b 100644 --- a/src/account.h +++ b/src/account.h @@ -102,6 +102,11 @@ public: */ bool isEnabled() { return _enabled; } + /** + * Tell if the latest registration succeed or failed + */ + bool setState(bool state) { _state = state; } + private: /** * Create a unique voIPLink() depending on the protocol @@ -145,6 +150,11 @@ protected: */ bool _registered; + /** + * The latest registration was a success or not + */ + bool _state; + }; #endif diff --git a/src/managerimpl.cpp b/src/managerimpl.cpp index c73c8dbf9bef7db78c6e82466432421dd5be4f0a..4449308f8a97ae4bf5d689e5e418856e801158bc 100644 --- a/src/managerimpl.cpp +++ b/src/managerimpl.cpp @@ -440,8 +440,19 @@ ManagerImpl::registerVoIPLink(const AccountID& accountId) { _debug("Register VoIP Link\n"); int returnValue = false; - if (accountExists( accountId ) ) { - returnValue = getAccount(accountId)->registerAccount(); + // right now, we don't support two SIP account + // so we close everything before registring a new account + Account* account = getAccount(accountId); + if (account != 0) { + AccountMap::iterator iter = _accountMap.begin(); + while ( iter != _accountMap.end() ) { + if ( iter->second ) { + iter->second->unregisterAccount(); + iter->second->terminate(); + } + iter++; + } + returnValue = account->registerAccount(); } return returnValue; } @@ -453,7 +464,7 @@ ManagerImpl::unregisterVoIPLink(const AccountID& accountId) _debug("Unregister VoIP Link\n"); int returnValue = false; if (accountExists( accountId ) ) { - returnValue = getAccount(accountId)->registerAccount(); + returnValue = getAccount(accountId)->unregisterAccount(); } return returnValue; } @@ -739,20 +750,28 @@ void ManagerImpl::stopVoiceMessageNotification(const AccountID& accountId) { if (_gui) _gui->sendVoiceNbMessage(accountId, std::string("0")); -} +} //THREAD=VoIP void ManagerImpl::registrationSucceed(const AccountID& accountid) { - if (_gui) _gui->sendRegistrationState(accountid, true); + Account* acc = getAccount(accountid); + if ( acc ) { + acc->setState(true); + if (_gui) _gui->sendRegistrationState(accountid, true); + } } //THREAD=VoIP void ManagerImpl::registrationFailed(const AccountID& accountid) { - if (_gui) _gui->sendRegistrationState(accountid, false); + Account* acc = getAccount(accountid); + if ( acc ) { + acc->setState(false); + if (_gui) _gui->sendRegistrationState(accountid, false); + } } /** diff --git a/src/sipaccount.cpp b/src/sipaccount.cpp index ba027b7f2b41c67da69ec8a6ed45060222586a2b..3b46ae666bb467892518149126662470b020bb44 100644 --- a/src/sipaccount.cpp +++ b/src/sipaccount.cpp @@ -55,6 +55,7 @@ bool SIPAccount::registerAccount() { if (_link) { + init(); // init if not enable unregisterAccount(); SIPVoIPLink* tmplink = dynamic_cast<SIPVoIPLink*> (_link); if (tmplink) { diff --git a/src/sipvoiplink.cpp b/src/sipvoiplink.cpp index 8137b61b1865d2f5c10f0613783a2f12548d28cc..52491d7776f07cca6abe92408b7aa071c2968e4b 100644 --- a/src/sipvoiplink.cpp +++ b/src/sipvoiplink.cpp @@ -224,7 +224,7 @@ SIPVoIPLink::getEvent() _debug("EXOSIP_REGISTRATION_REFRESHED event is not implemented\n"); break; case EXOSIP_REGISTRATION_TERMINATED: /** 04 < UA is not registred any more. */ - _debug("EXOSIP_REGISTRATION_TERMINATED event is not implmeneted\n"); + _debug("EXOSIP_REGISTRATION_TERMINATED event is not implemented\n"); break; /* INVITE related events within calls */