Commit 743002cf authored by Emmanuel Milou's avatar Emmanuel Milou

Registration Error Handling: add host unreachable

But introduces a bug: sometimes seg fault
parent 7d80c0b1
......@@ -170,6 +170,9 @@ const gchar * account_state_name(account_state_t s)
case ACCOUNT_STATE_ERROR_NETWORK:
state = _("Network unreachable");
break;
case ACCOUNT_STATE_ERROR_HOST:
state = _("Host unreachable");
break;
default:
state = _("Invalid");
break;
......
......@@ -37,7 +37,8 @@ typedef enum
ACCOUNT_STATE_TRYING,
ACCOUNT_STATE_ERROR,
ACCOUNT_STATE_ERROR_AUTH,
ACCOUNT_STATE_ERROR_NETWORK
ACCOUNT_STATE_ERROR_NETWORK,
ACCOUNT_STATE_ERROR_HOST
} account_state_t;
/** @struct account_t
......
......@@ -171,6 +171,10 @@ sflphone_fill_account_list()
{
a->state = ACCOUNT_STATE_ERROR_NETWORK;
}
else if(strcmp( status , "ERROR_HOST") == 0 )
{
a->state = ACCOUNT_STATE_ERROR_HOST;
}
else
{
a->state = ACCOUNT_STATE_INVALID;
......
......@@ -1970,7 +1970,8 @@ ManagerImpl::getAccountDetails(const AccountID& accountID)
(state == VoIPLink::Trying ? "TRYING":
(state == VoIPLink::ErrorAuth ? "ERROR_AUTH":
(state == VoIPLink::ErrorNetwork ? "ERROR_NETWORK":
(state == VoIPLink::Error ? "ERROR": "ERROR"))))))
(state == VoIPLink::ErrorHost ? "ERROR_HOST":
(state == VoIPLink::Error ? "ERROR": "ERROR")))))))
)
);
a.insert(
......@@ -2098,21 +2099,15 @@ ManagerImpl::setAccountDetails( const ::DBus::String& accountID,
}
saveConfig();
Account* acc = getAccount(accountID);
acc->loadConfig();
if (acc->isEnabled()) {
// Verify we aren't already registered, then register
if (acc->getRegistrationState() != VoIPLink::Registered) {
_debug("SET ACCOUNTS DETAILS - non registered - > registered\n");
acc->registerVoIPLink();
}
} else {
// Verify we are already registered, then unregister
//if (acc->getRegistrationState() == VoIPLink::Registered) {
_debug("SET ACCOUNTS DETAILS - registered - > non registered\n");
acc->unregisterVoIPLink();
//}
}
if (acc->isEnabled()){
acc->unregisterVoIPLink();
acc->registerVoIPLink();}
else
acc->unregisterVoIPLink();
// Update account details
if (_dbus) _dbus->getConfigurationManager()->accountsChanged();
}
......@@ -2129,6 +2124,7 @@ ManagerImpl::sendRegister( const ::DBus::String& accountID , bool expire )
// Update the active field
setConfig( accountID, CONFIG_ACCOUNT_ENABLE, expire );
Account* acc = getAccount(accountID);
acc->loadConfig();
// Test on the value freshly updated
......
......@@ -87,7 +87,6 @@ SIPVoIPLink::init()
// Pour éviter qu'on refasse l'init sans avoir considéré l'erreur,
// s'il y en a une ?
_initDone = true;
// check networking capabilities
if ( !checkNetwork() ) {
_debug("! SIP FAILURE: Unable to determine network capabilities\n");
......@@ -155,7 +154,6 @@ void
SIPVoIPLink::terminate()
{
terminateSIPCall();
if (_initDone) {
// TODO The next line makes the daemon crash on
// account delete if at least one account is registered.
// It should called only when the last account
......@@ -242,7 +240,6 @@ SIPVoIPLink::getEvent()
if(_eXosipRegID == EXOSIP_ERROR_STD){
_debug("Successfully Unregister account ID = %s\n" , getAccountID().c_str());
setRegistrationState(Unregistered);
//if( _evThread ) _evThread->stop();
}
else{
_debug("Successfully Register account ID = %s\n" , getAccountID().c_str());
......@@ -1463,7 +1460,11 @@ SIPVoIPLink::SIPCallServerFailure(eXosip_event_t *event)
void
SIPVoIPLink::SIPRegistrationFailure( eXosip_event_t* event )
{
if(!event->response) {return ;}
if(!event->response){
setRegistrationState(ErrorHost);
return ;
}
switch( event->response->status_code ) {
case SIP_FORBIDDEN:
_debug("SIP forbidden\n");
......
......@@ -112,6 +112,9 @@ VoIPLink::setRegistrationState(const enum RegistrationState state, const int& er
case Unregistered:
Manager::instance().unregistrationSucceed(acc_ID);
break;
case ErrorHost:
Manager::instance().registrationFailed(acc_ID);
break;
}
}
......
......@@ -44,7 +44,7 @@ public:
VoIPLink(const AccountID& accountID);
virtual ~VoIPLink (void);
enum RegistrationState {Unregistered, Trying, Registered, Error, ErrorAuth , ErrorNetwork};
enum RegistrationState {Unregistered, Trying, Registered, Error, ErrorAuth , ErrorNetwork , ErrorHost};
// Pure virtual functions
virtual void getEvent (void) = 0;
......
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