Commit 7d80c0b1 authored by Emmanuel Milou's avatar Emmanuel Milou

SIP registration errors handling

Add ERROR_AUTHENTIFICATION and ERROR_NETWORK to the account state

Registration possible if the account is in ERROR state
parent c39f2734
......@@ -167,6 +167,9 @@ const gchar * account_state_name(account_state_t s)
case ACCOUNT_STATE_ERROR_AUTH:
state = _("Bad authentification");
break;
case ACCOUNT_STATE_ERROR_NETWORK:
state = _("Network unreachable");
break;
default:
state = _("Invalid");
break;
......
......@@ -36,7 +36,8 @@ typedef enum
ACCOUNT_STATE_UNREGISTERED,
ACCOUNT_STATE_TRYING,
ACCOUNT_STATE_ERROR,
ACCOUNT_STATE_ERROR_AUTH
ACCOUNT_STATE_ERROR_AUTH,
ACCOUNT_STATE_ERROR_NETWORK
} account_state_t;
/** @struct account_t
......
......@@ -167,6 +167,10 @@ sflphone_fill_account_list()
{
a->state = ACCOUNT_STATE_ERROR_AUTH;
}
else if(strcmp( status , "ERROR_NETWORK") == 0 )
{
a->state = ACCOUNT_STATE_ERROR_NETWORK;
}
else
{
a->state = ACCOUNT_STATE_INVALID;
......
......@@ -30,12 +30,6 @@ sflphone_throw_exception( int err )
case ALSA_CAPTURE_DEVICE:
markup = g_markup_printf_escaped(_("<b>ALSA notification</b>\n\nError while opening capture device"));
break;
case REGISTRATION_FORBIDDEN:
markup = g_markup_printf_escaped(_("<b>Account Registration</b>\n\nBad authentification"));
break;
case REGISTRATION_UNAUTHORIZED:
markup = g_markup_printf_escaped(_("<b>Account Registration</b>\n\nBad authentification"));
break;
}
main_window_error_message( markup );
free( markup );
......
......@@ -48,10 +48,7 @@
// Error codes for error handling
#define ALSA_CAPTURE_DEVICE 0x0001
#define ALSA_PLAYBACK_DEVICE 0x0010
#define REGISTRATION_FORBIDDEN 0x0011
#define REGISTRATION_UNAUTHORIZED 0x0100
#define REGISTRATION_UNREACHABLE 0x0101
#define NETWORK_UNREACHABLE 0x0110
#define NETWORK_UNREACHABLE 0x0011
// Customizing-related parameters
#define TONE_WITHOUT_MESSAGE 0
......
......@@ -117,9 +117,6 @@ typedef short int16;
#define NO_ERROR 0x0000
#define ALSA_CAPTURE_DEVICE 0x0001
#define ALSA_PLAYBACK_DEVICE 0x0010
#define REGISTRATION_FORBIDDEN 0x0011
#define REGISTRATION_UNAUTHORIZED 0x0100
#define REGISTRATION_UNREACHABLE 0x0101
#define NETWORK_UNREACHABLE 0x0110
#define NETWORK_UNREACHABLE 0x0011
#endif // __GLOBAL_H__
......@@ -833,7 +833,7 @@ IAXVoIPLink::iaxHandleRegReply(iax_event* event)
_mutexIAX.leaveMutex();
_regSession = NULL;
setRegistrationState(Error, REGISTRATION_FORBIDDEN);
setRegistrationState(Error);
//Manager::instance().registrationFailed(getAccountID());
}
......
......@@ -1969,7 +1969,8 @@ ManagerImpl::getAccountDetails(const AccountID& accountID)
(state == VoIPLink::Unregistered ? "UNREGISTERED":
(state == VoIPLink::Trying ? "TRYING":
(state == VoIPLink::ErrorAuth ? "ERROR_AUTH":
(state == VoIPLink::Error ? "ERROR": "ERROR")))))
(state == VoIPLink::ErrorNetwork ? "ERROR_NETWORK":
(state == VoIPLink::Error ? "ERROR": "ERROR"))))))
)
);
a.insert(
......@@ -2107,11 +2108,10 @@ ManagerImpl::setAccountDetails( const ::DBus::String& accountID,
}
} else {
// Verify we are already registered, then unregister
if (acc->getRegistrationState() == VoIPLink::Registered) {
//if (acc->getRegistrationState() == VoIPLink::Registered) {
_debug("SET ACCOUNTS DETAILS - registered - > non registered\n");
acc->unregisterVoIPLink();
//unregisterAccount(accountID);
}
//}
}
// Update account details
if (_dbus) _dbus->getConfigurationManager()->accountsChanged();
......@@ -2128,33 +2128,18 @@ 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
if ( acc->isEnabled() ) {
// As we don't support multiple SIP account, we have to unregister everything before
//AccountMap::iterator iter = _accountMap.begin();
//while ( iter != _accountMap.end() ) {
//if ( iter->second ) {
//setConfig( iter->first , CONFIG_ACCOUNT_ENABLE , false );
//iter->second->unregisterVoIPLink();
//}
//iter++;
//}
// Verify we aren't already registered, then register
//if (acc->getRegistrationState() != VoIPLink::Registered) {
_debug("Send register for account %s\n" , accountID.c_str());
//setConfig( accountID , CONFIG_ACCOUNT_ENABLE , true );
acc->registerVoIPLink();
//}
} else {
// Verify we are already registered, then unregister
if (acc->getRegistrationState() == VoIPLink::Registered) {
_debug("Send unregister for account %s\n" , accountID.c_str());
acc->unregisterVoIPLink();
}
}
}
......
......@@ -200,6 +200,8 @@ SIPVoIPLink::loadSIPLocalIP()
if (_localIPAddress == "127.0.0.1") {
char* myIPAddress = new char[65];
if (eXosip_guess_localip(AF_INET, myIPAddress, 64) == EXOSIP_ERROR_STD) {
// Update the registration state if no network capabilities found
setRegistrationState( ErrorNetwork );
returnValue = false;
} else {
_localIPAddress = std::string(myIPAddress);
......@@ -457,6 +459,7 @@ SIPVoIPLink::sendRegister()
{
if (_eXosipRegID != EXOSIP_ERROR_STD) {
_debug("nlvnslvnlsnvaljsdnvjlasnvlsfvbnnns sjvlsvn\n");
Manager::instance().displayError("! SIP Error: Registration already sent. Try to unregister");
return false;
}
......@@ -1464,7 +1467,7 @@ SIPVoIPLink::SIPRegistrationFailure( eXosip_event_t* event )
switch( event->response->status_code ) {
case SIP_FORBIDDEN:
_debug("SIP forbidden\n");
setRegistrationState(ErrorAuth, REGISTRATION_FORBIDDEN);
setRegistrationState(ErrorAuth);
break;
case SIP_UNAUTHORIZED:
_debug("SIP unauthorized\n");
......
......@@ -106,6 +106,9 @@ VoIPLink::setRegistrationState(const enum RegistrationState state, const int& er
case ErrorAuth:
Manager::instance().registrationFailed(acc_ID);
break;
case ErrorNetwork:
Manager::instance().registrationFailed(acc_ID);
break;
case Unregistered:
Manager::instance().unregistrationSucceed(acc_ID);
break;
......
......@@ -44,7 +44,7 @@ public:
VoIPLink(const AccountID& accountID);
virtual ~VoIPLink (void);
enum RegistrationState {Unregistered, Trying, Registered, Error, ErrorAuth};
enum RegistrationState {Unregistered, Trying, Registered, Error, ErrorAuth , ErrorNetwork};
// 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