diff --git a/coreapi/callbacks.c b/coreapi/callbacks.c index 642e3d188..3df4906a5 100644 --- a/coreapi/callbacks.c +++ b/coreapi/callbacks.c @@ -24,6 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "private.h" #include "mediastreamer2/mediastream.h" +static void register_failure(SalOp *op, SalError error, SalReason reason, const char *details); static void linphone_connect_incoming(LinphoneCore *lc, LinphoneCall *call){ if (lc->ringstream!=NULL){ @@ -426,6 +427,9 @@ static void auth_requested(SalOp *h, const char *realm, const char *username){ sal_op_authenticate(h,&sai); ai->usecount++; }else{ + if (ai && ai->works==FALSE) { + register_failure(h, SalErrorFailure, SalReasonForbidden, _("Authentication failure")); + } if (lc->vtable.auth_info_requested) lc->vtable.auth_info_requested(lc,realm,username); } @@ -446,6 +450,7 @@ static void register_success(SalOp *op, bool_t registered){ char *msg; cfg->registered=registered; + linphone_proxy_config_set_error(cfg,LinphoneErrorNone); linphone_proxy_config_set_state(cfg, registered ? LinphoneRegistrationOk : LinphoneRegistrationCleared , registered ? "Registration sucessful" : "Unregistration done"); if (lc->vtable.display_status){ @@ -473,6 +478,11 @@ static void register_failure(SalOp *op, SalError error, SalReason reason, const lc->vtable.display_status(lc,msg); ms_free(msg); } + if (error== SalErrorFailure && reason == SalReasonForbidden) { + linphone_proxy_config_set_error(cfg, LinphoneErrorBadCredentials); + } else if (error == SalErrorNoResponse) { + linphone_proxy_config_set_error(cfg, LinphoneErrorNoResponse); + } linphone_proxy_config_set_state(cfg,LinphoneRegistrationFailed,details); } diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index b21573b5c..00a9298c1 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -218,7 +218,7 @@ LinphoneCallLog *linphone_call_get_call_log(const LinphoneCall *call); const char *linphone_call_get_refer_to(const LinphoneCall *call); bool_t linphone_call_has_transfer_pending(const LinphoneCall *call); int linphone_call_get_duration(const LinphoneCall *call); -const LinphoneCallParams linphone_call_get_current_params(const LinphoneCall *call); +LinphoneCallParams linphone_call_get_current_params(const LinphoneCall *call); void linphone_call_enable_camera(LinphoneCall *lc, bool_t enabled); bool_t linphone_call_camera_enabled(const LinphoneCall *lc); LinphoneError linphone_call_get_error(const LinphoneCall *call); diff --git a/coreapi/private.h b/coreapi/private.h index 943bd29c9..7680db74c 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -192,7 +192,7 @@ void linphone_core_stop_waiting(LinphoneCore *lc); int linphone_core_start_invite(LinphoneCore *lc, LinphoneCall *call, LinphoneProxyConfig *dest_proxy); void linphone_core_start_pending_refered_calls(LinphoneCore *lc); extern SalCallbacks linphone_sal_callbacks; - +void linphone_proxy_config_set_error(LinphoneProxyConfig *cfg,LinphoneError error); struct _LinphoneProxyConfig { @@ -216,6 +216,7 @@ struct _LinphoneProxyConfig bool_t dial_escape_plus; void* user_data; time_t deletion_date; + LinphoneError error; }; struct _LinphoneAuthInfo diff --git a/coreapi/proxy.c b/coreapi/proxy.c index 251bdbb13..07a8e6c81 100644 --- a/coreapi/proxy.c +++ b/coreapi/proxy.c @@ -829,5 +829,11 @@ LinphoneRegistrationState linphone_proxy_config_get_state(const LinphoneProxyCon } return NULL; } +LinphoneError linphone_proxy_config_get_error(const LinphoneProxyConfig *cfg) { + return cfg->error; +} +void linphone_proxy_config_set_error(LinphoneProxyConfig *cfg,LinphoneError error) { + cfg->error = error; +}