diff --git a/sflphone-gtk/src/Makefile.am b/sflphone-gtk/src/Makefile.am index c76597cb990ec08b1a8254754ebb21d8b3e2b4d9..343942f4f75ca432d9c4d9b7ae3642c4bac3490b 100644 --- a/sflphone-gtk/src/Makefile.am +++ b/sflphone-gtk/src/Makefile.am @@ -2,8 +2,9 @@ bin_PROGRAMS = sflphone-gtk sflphone_gtk_SOURCES = \ main.c \ + errors.c \ dbus.c \ - SFLnotify.c \ + sflnotify.c \ mainwindow.c \ calllist.c \ dialpad.c \ @@ -21,8 +22,8 @@ sflphone_gtk_SOURCES = \ glwidget.c \ MemManager.c -noinst_HEADERS = actions.h dbus.h SFLnotify.h mainwindow.h calllist.h dialpad.h codeclist.h\ - callmanager-glue.h configurationmanager-glue.h instance-glue.h menus.h calltree.h screen.h configwindow.h \ +noinst_HEADERS = actions.h dbus.h sflnotify.h mainwindow.h calllist.h dialpad.h codeclist.h\ + callmanager-glue.h errors.h sflphone_const.h configurationmanager-glue.h instance-glue.h menus.h calltree.h screen.h configwindow.h \ accountlist.h accountwindow.h marshaller.h sliders.h statusicon.h EXTRA_DIST = marshaller.list sflphone_gtk_LDADD = $(DEPS_LIBS) -lnotify diff --git a/sflphone-gtk/src/accountlist.c b/sflphone-gtk/src/accountlist.c index e423420bad0c86040b7630f35f8882aa31a5d50f..d695c09d072341317d84035b627e35659660d62b 100644 --- a/sflphone-gtk/src/accountlist.c +++ b/sflphone-gtk/src/accountlist.c @@ -164,6 +164,9 @@ const gchar * account_state_name(account_state_t s) case ACCOUNT_STATE_ERROR: state = _("Error"); break; + case ACCOUNT_STATE_ERROR_AUTH: + state = _("Bad authentification"); + break; default: state = _("Invalid"); break; diff --git a/sflphone-gtk/src/accountlist.h b/sflphone-gtk/src/accountlist.h index 56cc530c505559d0829d994734e5ba5caeb0bed5..1bc24fcb41bda2afbc1d049c274672e7552b6473 100644 --- a/sflphone-gtk/src/accountlist.h +++ b/sflphone-gtk/src/accountlist.h @@ -26,25 +26,6 @@ * @brief A list to hold accounts. */ -#define ACCOUNT_TYPE "Account.type" -#define ACCOUNT_ALIAS "Account.alias" -#define ACCOUNT_ENABLED "Account.enable" -//#define ACCOUNT_REGISTER "Account.autoregister" - -#define ACCOUNT_SIP_FULL_NAME "SIP.fullName" -#define ACCOUNT_SIP_HOST_PART "SIP.hostPart" -#define ACCOUNT_SIP_USER_PART "SIP.userPart" -#define ACCOUNT_SIP_AUTH_NAME "SIP.username" -#define ACCOUNT_SIP_PASSWORD "SIP.password" -#define ACCOUNT_SIP_PROXY "SIP.proxy" -#define ACCOUNT_SIP_STUN_SERVER "STUN.server" -#define ACCOUNT_SIP_STUN_ENABLED "STUN.enable" - -#define ACCOUNT_IAX_FULL_NAME "IAX.fullName" -#define ACCOUNT_IAX_HOST "IAX.host" -#define ACCOUNT_IAX_USER "IAX.user" -#define ACCOUNT_IAX_PASS "IAX.pass" - /** @enum account_state_t * This enum have all the states an account can take. */ @@ -54,7 +35,8 @@ typedef enum ACCOUNT_STATE_REGISTERED, ACCOUNT_STATE_UNREGISTERED, ACCOUNT_STATE_TRYING, - ACCOUNT_STATE_ERROR + ACCOUNT_STATE_ERROR, + ACCOUNT_STATE_ERROR_AUTH } account_state_t; /** @struct account_t diff --git a/sflphone-gtk/src/actions.c b/sflphone-gtk/src/actions.c index 5bf1ed6442c04174b9bc224680e5f593db508045..17fe14861de29f0d2f0c5ccbcd37757ce6a9135f 100644 --- a/sflphone-gtk/src/actions.c +++ b/sflphone-gtk/src/actions.c @@ -33,12 +33,6 @@ #include <sys/types.h> #include <unistd.h> -#define ALSA_ERROR_CAPTURE_DEVICE 0 -#define ALSA_ERROR_PLAYBACK_DEVICE 1 - -#define TONE_WITHOUT_MESSAGE 0 -#define TONE_WITH_MESSAGE 1 - guint voice_mails; void @@ -53,7 +47,7 @@ sflphone_notify_voice_mail ( const gchar* accountID , guint count ) g_sprintf(message, _("%d voice mails"), count); else g_sprintf(message, _("%d voice mail"), count); - status_bar_message_add(message, __MSG_VOICE_MAILS); + statusbar_push_message(message, __MSG_VOICE_MAILS); g_free(message); } // TODO: add ifdef @@ -75,7 +69,7 @@ status_bar_display_account( call_t* c) msg = g_markup_printf_escaped("%s account- %s" , (gchar*)g_hash_table_lookup( acc->properties , ACCOUNT_TYPE), (gchar*)g_hash_table_lookup( acc->properties , ACCOUNT_ALIAS)); - status_bar_message_add( msg , __MSG_ACCOUNT_DEFAULT); + statusbar_push_message( msg , __MSG_ACCOUNT_DEFAULT); g_free(msg); } } @@ -169,6 +163,10 @@ sflphone_fill_account_list() { a->state = ACCOUNT_STATE_ERROR; } + else if(strcmp( status , "ERROR_AUTH") == 0 ) + { + a->state = ACCOUNT_STATE_ERROR_AUTH; + } else { a->state = ACCOUNT_STATE_INVALID; @@ -624,22 +622,6 @@ sflphone_set_current_account() account_list_set_current_pos( 0 ); } -void -sflphone_throw_exception( int errCode ) -{ - gchar* markup = malloc(1000); - switch( errCode ){ - case ALSA_ERROR_PLAYBACK_DEVICE: - sprintf( markup , _("<b>ALSA notification</b>\n\nError while opening playback device")); - break; - case ALSA_ERROR_CAPTURE_DEVICE: - sprintf( markup , _("<b>ALSA notification</b>\n\nError while opening capture device")); - break; - } - main_window_error_message( markup ); - free( markup ); -} - /* Internal to action - get the codec list */ void diff --git a/sflphone-gtk/src/actions.h b/sflphone-gtk/src/actions.h index 5dcbd9751bcdc7a06a0fa5772000f4bb6b0c206e..74143f0c380eb276ba5723dc87b90bcc52bfcef3 100644 --- a/sflphone-gtk/src/actions.h +++ b/sflphone-gtk/src/actions.h @@ -21,20 +21,14 @@ #ifndef __ACTIONS_H__ #define __ACTIONS_H__ -#define _(STRING) gettext( STRING ) - #include <libintl.h> #include <locale.h> #include <calllist.h> #include <accountlist.h> #include <codeclist.h> - -#define __MSG_INCOMING_CALL 0 -#define __MSG_CALLING 1 -#define __MSG_VOICE_MAILS 2 -#define __MSG_ACCOUNT_DEFAULT 3 - +#include <sflphone_const.h> +#include <errors.h> /** @file actions.h * @brief General functions that change the state of the application. @@ -117,6 +111,5 @@ void sflphone_place_call ( call_t * c ); void sflphone_fill_account_list(); void sflphone_set_current_account(); -void sflphone_throw_exception( int errCode ); void sflphone_fill_codec_list(); #endif diff --git a/sflphone-gtk/src/configwindow.c b/sflphone-gtk/src/configwindow.c index 83111e66f36288d5e1e4b7b243411153519d6bd4..a1ec38a159a1592288e18ce4728b7df58bc4419e 100644 --- a/sflphone-gtk/src/configwindow.c +++ b/sflphone-gtk/src/configwindow.c @@ -60,6 +60,8 @@ GtkWidget *pluginComboBox; GtkWidget *codecMoveUpButton; GtkWidget *codecMoveDownButton; +GtkWidget* status; + account_t *selectedAccount; // Account properties @@ -1362,7 +1364,8 @@ show_accounts_window( void ) gtk_box_pack_start( GTK_BOX( dialog->vbox ), accountFrame , TRUE, TRUE, 0); gtk_container_set_border_width(GTK_CONTAINER(accountFrame), 10); gtk_widget_show(accountFrame); - // Accounts tab + + // Accounts tab tab = create_accounts_tab(); gtk_container_add(GTK_CONTAINER(accountFrame) , tab); @@ -1371,3 +1374,4 @@ show_accounts_window( void ) dialogOpen=FALSE; gtk_widget_destroy(GTK_WIDGET(dialog)); } + diff --git a/sflphone-gtk/src/dbus.c b/sflphone-gtk/src/dbus.c index 907fb0af84e3fdd149c074a0fd0aea97850bb271..c48476be4590180f8e7b8068a52a70c970d0ba32 100644 --- a/sflphone-gtk/src/dbus.c +++ b/sflphone-gtk/src/dbus.c @@ -367,8 +367,6 @@ dbus_accept (const call_t * c) void dbus_refuse (const call_t * c) { - // Remove the account message from the status bar stack - status_bar_message_remove( __MSG_ACCOUNT_DEFAULT ); status_tray_icon_blink( FALSE ); GError *error = NULL; org_sflphone_SFLphone_CallManager_refuse ( callManagerProxy, c->callID, &error); diff --git a/sflphone-gtk/src/dbus.h b/sflphone-gtk/src/dbus.h index 7899db4411fb2d65b4a1a1836bdbc7c312bf2a66..6b9ada699595204be49392e9d81cf4dabaf6701d 100644 --- a/sflphone-gtk/src/dbus.h +++ b/sflphone-gtk/src/dbus.h @@ -25,7 +25,7 @@ #include <accountlist.h> #include <calllist.h> -#include <SFLnotify.h> +#include <sflnotify.h> /** @file dbus.h * @brief General DBus functions wrappers. diff --git a/sflphone-gtk/src/errors.c b/sflphone-gtk/src/errors.c new file mode 100644 index 0000000000000000000000000000000000000000..d9e5b1437dac382692f90bee85bf5a559c9d54dc --- /dev/null +++ b/sflphone-gtk/src/errors.c @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2008 Savoir-Faire Linux inc. + * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include <errors.h> + + void +sflphone_throw_exception( int err ) +{ + gchar* markup; + switch( err ){ + case ALSA_PLAYBACK_DEVICE: + markup = g_markup_printf_escaped(_("<b>ALSA notification</b>\n\nError while opening playback device")); + break; + 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 ); +} diff --git a/sflphone-gtk/src/errors.h b/sflphone-gtk/src/errors.h new file mode 100644 index 0000000000000000000000000000000000000000..19cb349f7aef3f283a03f4526d32b8d240ca8f48 --- /dev/null +++ b/sflphone-gtk/src/errors.h @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2008 Savoir-Faire Linux inc. + * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef __ERRORS_H +#define __ERRORS_H + +#include <sflphone_const.h> + +void sflphone_throw_exception( int err ); + +#endif diff --git a/sflphone-gtk/src/mainwindow.c b/sflphone-gtk/src/mainwindow.c index 7de3e52e6ca8bfb52732d3e939acf37dc67a03fb..396193abd83d41208c18b2961072122dada0dec6 100644 --- a/sflphone-gtk/src/mainwindow.c +++ b/sflphone-gtk/src/mainwindow.c @@ -246,13 +246,13 @@ main_window_dialpad(gboolean show){ } void -status_bar_message_add(const gchar * message, guint id) +statusbar_push_message(const gchar * message, guint id) { gtk_statusbar_push(GTK_STATUSBAR(statusBar), id, message); } void -status_bar_message_remove(guint id) +statusbar_pop_message(guint id) { gtk_statusbar_pop(GTK_STATUSBAR(statusBar), id); } diff --git a/sflphone-gtk/src/mainwindow.h b/sflphone-gtk/src/mainwindow.h index d1bf8a02e561624995f4d0414c03cf652b68fe07..a138a70b494bdefe10f8de97d85049513ec674ca 100644 --- a/sflphone-gtk/src/mainwindow.h +++ b/sflphone-gtk/src/mainwindow.h @@ -43,7 +43,7 @@ void main_window_warning_message(gchar * markup); void main_window_info_message(gchar * markup); -void status_bar_message_add(const gchar * message , guint id); -void status_bar_message_remove(guint id); +void statusbar_push_message( const gchar* message , guint id ); +void statusbar_pop_message( guint id ); #endif diff --git a/sflphone-gtk/src/sflphone_const.h b/sflphone-gtk/src/sflphone_const.h new file mode 100644 index 0000000000000000000000000000000000000000..76520ca15ac1e6f38169b1496772a19fd0557d25 --- /dev/null +++ b/sflphone-gtk/src/sflphone_const.h @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2008 Savoir-Faire Linux inc. + * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef __SFLPHONE_CONST_H +#define __SFLPHONE_CONST_H + +#include <libintl.h> +#include "dbus.h" + +// Locale +#define _(STRING) gettext( STRING ) + +// Generic parameters for accounts registration +#define ACCOUNT_TYPE "Account.type" +#define ACCOUNT_ALIAS "Account.alias" +#define ACCOUNT_ENABLED "Account.enable" +// SIP specific parameters +#define ACCOUNT_SIP_FULL_NAME "SIP.fullName" +#define ACCOUNT_SIP_HOST_PART "SIP.hostPart" +#define ACCOUNT_SIP_USER_PART "SIP.userPart" +#define ACCOUNT_SIP_AUTH_NAME "SIP.username" +#define ACCOUNT_SIP_PASSWORD "SIP.password" +#define ACCOUNT_SIP_PROXY "SIP.proxy" +#define ACCOUNT_SIP_STUN_SERVER "STUN.server" +#define ACCOUNT_SIP_STUN_ENABLED "STUN.enable" +// IAX2 specific parameters +#define ACCOUNT_IAX_FULL_NAME "IAX.fullName" +#define ACCOUNT_IAX_HOST "IAX.host" +#define ACCOUNT_IAX_USER "IAX.user" +#define ACCOUNT_IAX_PASS "IAX.pass" + +// 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 + +// Customizing-related parameters +#define TONE_WITHOUT_MESSAGE 0 +#define TONE_WITH_MESSAGE 1 +#define MINIMIZED TRUE +#define __POPUP_WINDOW ( dbus_popup_mode() ) + +// Messages ID for status bar +#define __MSG_INCOMING_CALL 0 +#define __MSG_CALLING 1 +#define __MSG_VOICE_MAILS 2 +#define __MSG_ACCOUNT_DEFAULT 3 + +// Desktop notifications +#define __TIMEOUT_MODE "default" +#define __TIMEOUT_TIME 30000 // 30 secondes + +#endif diff --git a/sflphone-gtk/src/statusicon.h b/sflphone-gtk/src/statusicon.h index b3f6ba7d15ad5280e6c57b52d00fb5bbbad12ad1..2dc55b8db418085ba6a1769d9666c5fd78dd8625 100644 --- a/sflphone-gtk/src/statusicon.h +++ b/sflphone-gtk/src/statusicon.h @@ -20,9 +20,9 @@ #ifndef __STATUSICON_H__ #define __STATUSICON_H__ -#define MINIMIZED TRUE #include <gtk/gtk.h> +#include <sflphone_const.h> /** @file statusicon.h * @brief The status icon. */ diff --git a/src/audio/audiolayer.cpp b/src/audio/audiolayer.cpp index 0b357382001a8bea9b22c903d793430ab0c837ea..ff13e4f9c566082804bbfee7751873cd63f8c4fc 100644 --- a/src/audio/audiolayer.cpp +++ b/src/audio/audiolayer.cpp @@ -313,7 +313,7 @@ AudioLayer::open_device(std::string pcm_p, std::string pcm_c, int flag) _debugAlsa("Opening capture device %s\n", pcm_c.c_str()); if(err = snd_pcm_open(&_CaptureHandle, pcm_c.c_str(), SND_PCM_STREAM_CAPTURE, 0) < 0){ _debugAlsa("Error while opening capture device %s\n", pcm_c.c_str()); - setErrorMessage( ERROR_ALSA_CAPTURE_DEVICE ); + setErrorMessage( ALSA_CAPTURE_DEVICE ); return false; } @@ -343,7 +343,7 @@ AudioLayer::open_device(std::string pcm_p, std::string pcm_c, int flag) _debugAlsa(" Opening playback device %s\n", pcm_p.c_str()); if(err = snd_pcm_open(&_PlaybackHandle, pcm_p.c_str(), SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK ) < 0){ _debugAlsa("Error while opening playback device %s\n", pcm_c.c_str()); - setErrorMessage( ERROR_ALSA_PLAYBACK_DEVICE ); + setErrorMessage( ALSA_PLAYBACK_DEVICE ); return false; } if( err = snd_pcm_hw_params_malloc( &hwParams ) < 0 ) { diff --git a/src/global.h b/src/global.h index e09409da50cf14ffa85c7e263155085af1792673..748d9d4ed11d53611396538e0c2f9a920131db8e 100644 --- a/src/global.h +++ b/src/global.h @@ -113,10 +113,13 @@ typedef short int16; #define START_HIDDEN 1 #define WINDOW_POPUP 1 -#define ERROR_ALSA_CAPTURE_DEVICE 0 -#define ERROR_ALSA_PLAYBACK_DEVICE 1 -//#define ERROR_ALSA_OPENING_CAPTURE_DEVICE 0 -//#define ERROR_ALSA_OPENING_CAPTURE_DEVICE 0 -//#define ERROR_ALSA_OPENING_CAPTURE_DEVICE 0 +// Error codes for error handling +#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 #endif // __GLOBAL_H__ diff --git a/src/iaxvoiplink.cpp b/src/iaxvoiplink.cpp index 9efe1b2fde235cc1cf0915476e6f0f512e337799..63286e92f923b36fbd943ffae053d5e9ce8848df 100644 --- a/src/iaxvoiplink.cpp +++ b/src/iaxvoiplink.cpp @@ -833,7 +833,7 @@ IAXVoIPLink::iaxHandleRegReply(iax_event* event) _mutexIAX.leaveMutex(); _regSession = NULL; - setRegistrationState(Error, "Registration failed"); + setRegistrationState(Error, REGISTRATION_FORBIDDEN); //Manager::instance().registrationFailed(getAccountID()); } diff --git a/src/managerimpl.cpp b/src/managerimpl.cpp index 53edb26da43784a081ce286da2f7e88543e06809..998d925b5b340eeac05bf087b3c1f76f7bb57a04 100644 --- a/src/managerimpl.cpp +++ b/src/managerimpl.cpp @@ -1966,9 +1966,10 @@ ManagerImpl::getAccountDetails(const AccountID& accountID) std::pair<std::string, std::string>( "Status", (state == VoIPLink::Registered ? "REGISTERED": - (state == VoIPLink::Unregistered ? "UNREGISTERED": - (state == VoIPLink::Trying ? "TRYING": - (state == VoIPLink::Error ? "ERROR": "ERROR")))) + (state == VoIPLink::Unregistered ? "UNREGISTERED": + (state == VoIPLink::Trying ? "TRYING": + (state == VoIPLink::ErrorAuth ? "ERROR_AUTH": + (state == VoIPLink::Error ? "ERROR": "ERROR"))))) ) ); a.insert( diff --git a/src/sipvoiplink.cpp b/src/sipvoiplink.cpp index 46104ceb6cc0f41fb490d029baa51f34286f70ad..e6a18c7993e82a7d5266319d42d199ccef479c97 100644 --- a/src/sipvoiplink.cpp +++ b/src/sipvoiplink.cpp @@ -213,7 +213,7 @@ SIPVoIPLink::loadSIPLocalIP() void SIPVoIPLink::parseRequestUri( osip_uri_t* req ) { - _debug("%d\n",req->url_header); + // _debug("%d\n",req->url_header); } void @@ -229,10 +229,7 @@ SIPVoIPLink::getEvent() return; } - parseRequestUri( event->request->req_uri); - - //if(event->request->line != 0) - _debug("%s\n\n" , event->request->req_uri); + _debug("> SIP Event: [cdt=%4d:%4d:%4d] type=#%03d %s \n", event->cid, event->did, event->tid, event->type, event->textinfo); switch (event->type) { /* REGISTER related events */ case EXOSIP_REGISTRATION_NEW: /** 00 < announce new registration. */ @@ -251,14 +248,15 @@ SIPVoIPLink::getEvent() } break; case EXOSIP_REGISTRATION_FAILURE: /** 02 < user is not registred. */ - setRegistrationState(Error, "SIP registration failure."); + SIPRegistrationFailure( event ); _debugMid(" !EXOSIP_REGISTRATION_FAILURE\n"); break; case EXOSIP_REGISTRATION_REFRESHED: /** 03 < registration has been refreshed. */ _debugMid(" !EXOSIP_REGISTRATION_REFRESHED event is not implemented\n"); break; case EXOSIP_REGISTRATION_TERMINATED: /** 04 < UA is not registred any more. */ - setRegistrationState(Unregistered, "Registration terminated by remote host"); + //setRegistrationState(Unregistered, "Registration terminated by remote host"); + setRegistrationState(Unregistered); _debugMid(" !EXOSIP_REGISTRATION_TERMINATED event is not implemented\n"); break; @@ -1459,6 +1457,24 @@ SIPVoIPLink::SIPCallServerFailure(eXosip_event_t *event) } } +void +SIPVoIPLink::SIPRegistrationFailure( eXosip_event_t* event ) +{ + if(!event->response) {return ;} + switch( event->response->status_code ) { + case SIP_FORBIDDEN: + _debug("SIP forbidden\n"); + setRegistrationState(ErrorAuth, REGISTRATION_FORBIDDEN); + break; + case SIP_UNAUTHORIZED: + _debug("SIP unauthorized\n"); + setRegistrationState(Error); + break; + default: + _debug("Unknown error: %s\n" , event->response->status_code); + } +} + void SIPVoIPLink::SIPCallAck(eXosip_event_t *event) { diff --git a/src/sipvoiplink.h b/src/sipvoiplink.h index 72e9e657bfddec53aad56f6bf9ceee877b4ce280..68191520d26e0eaa5135303515358da6c95c57fe 100644 --- a/src/sipvoiplink.h +++ b/src/sipvoiplink.h @@ -189,6 +189,7 @@ private: */ void SIPCallServerFailure(eXosip_event_t *event); + void SIPRegistrationFailure( eXosip_event_t *event ); /** * Handling ack (restart audio if reinvite) * @param event eXosip Event diff --git a/src/voiplink.cpp b/src/voiplink.cpp index 26f35ebc560feaf824555c76537aba42ef3763de..a164a581af498c42e55b927c917946f271d2d8f8 100644 --- a/src/voiplink.cpp +++ b/src/voiplink.cpp @@ -25,7 +25,7 @@ #include "voiplink.h" #include "manager.h" -VoIPLink::VoIPLink(const AccountID& accountID) : _accountID(accountID), _localIPAddress("127.0.0.1"), _localPort(0), _registrationError(""), _initDone(false) +VoIPLink::VoIPLink(const AccountID& accountID) : _accountID(accountID), _localIPAddress("127.0.0.1"), _localPort(0), _registrationError(NO_ERROR), _initDone(false) { } @@ -82,13 +82,12 @@ VoIPLink::clearCallMap() } void -VoIPLink::setRegistrationState(const enum RegistrationState state, const std::string& errorMessage) +VoIPLink::setRegistrationState(const enum RegistrationState state, const int& errorCode) { _registrationState = state; - _registrationError = errorMessage; + _registrationError = errorCode; std::string acc_ID = getAccountID(); - _debug("Set registration state for account %s\n" , acc_ID.c_str()); /** Push to the GUI when state changes */ switch (state) { @@ -99,6 +98,12 @@ VoIPLink::setRegistrationState(const enum RegistrationState state, const std::st Manager::instance().registrationTrying( acc_ID); break; case Error: + Manager::instance().registrationFailed(acc_ID); + // Notify the error to the client + if( _registrationError != NO_ERROR ) + Manager::instance().notifyErrClient( errorCode ); + break; + case ErrorAuth: Manager::instance().registrationFailed(acc_ID); break; case Unregistered: @@ -110,7 +115,7 @@ VoIPLink::setRegistrationState(const enum RegistrationState state, const std::st void VoIPLink::setRegistrationState(const enum RegistrationState state) { - setRegistrationState(state, ""); + setRegistrationState(state, NO_ERROR); } // NOW diff --git a/src/voiplink.h b/src/voiplink.h index 887ea7973bc670418752a7918b4f62a24dc01a3b..3bbb3c5d838a683fc7480aa9afd9bbe0b3eed1d4 100644 --- a/src/voiplink.h +++ b/src/voiplink.h @@ -44,7 +44,7 @@ public: VoIPLink(const AccountID& accountID); virtual ~VoIPLink (void); - enum RegistrationState {Unregistered, Trying, Registered, Error}; + enum RegistrationState {Unregistered, Trying, Registered, Error, ErrorAuth}; // Pure virtual functions virtual void getEvent (void) = 0; @@ -141,7 +141,7 @@ public: /** * Get registration error message, if set. */ - std::string getRegistrationError() { return _registrationError; } + int getRegistrationError() { return _registrationError; } /** * Set new registration state @@ -150,7 +150,7 @@ public: * GUI when the state changes. */ void setRegistrationState(const enum RegistrationState state, - const std::string& errorMessage); + const int& errorCode); /** * Same, but with default error value to "" @@ -179,9 +179,9 @@ private: enum RegistrationState _registrationState; /** - * Registration error message + * Registration error code -> refers to global.h */ - std::string _registrationError; + int _registrationError; protected: /** Add a call to the call map (protected by mutex)