diff --git a/coreapi/authentication.c b/coreapi/authentication.c index 3b7db3122..4e32d5be3 100644 --- a/coreapi/authentication.c +++ b/coreapi/authentication.c @@ -53,7 +53,6 @@ LinphoneAuthInfo *linphone_auth_info_new(const char *username, const char *useri if (ha1!=NULL && (strlen(ha1)>0)) obj->ha1=ms_strdup(ha1); if (realm!=NULL && (strlen(realm)>0)) obj->realm=ms_strdup(realm); if (domain!=NULL && (strlen(domain)>0)) obj->domain=ms_strdup(domain); - obj->works=FALSE; return obj; } @@ -65,8 +64,6 @@ LinphoneAuthInfo *linphone_auth_info_clone(const LinphoneAuthInfo *ai){ if (ai->ha1) obj->ha1=ms_strdup(ai->ha1); if (ai->realm) obj->realm=ms_strdup(ai->realm); if (ai->domain) obj->domain=ms_strdup(ai->domain); - obj->works=FALSE; - obj->usecount=0; return obj; } @@ -337,19 +334,26 @@ LinphoneAuthInfo * linphone_core_create_auth_info(LinphoneCore *lc, const char * * * This information will be used during all SIP transacations that require authentication. **/ -void linphone_core_add_auth_info(LinphoneCore *lc, const LinphoneAuthInfo *info) -{ +void linphone_core_add_auth_info(LinphoneCore *lc, const LinphoneAuthInfo *info){ LinphoneAuthInfo *ai; MSList *elem; MSList *l; + int restarted_op_count=0; + bool_t updating=FALSE; + if (info->ha1==NULL && info->passwd==NULL){ + ms_error("linphone_core_add_auth_info(): info supplied with empty password or ha1."); + return; + } /* find if we are attempting to modify an existing auth info */ ai=(LinphoneAuthInfo*)linphone_core_find_auth_info(lc,info->realm,info->username,info->domain); if (ai!=NULL && ai->domain && info->domain && strcmp(ai->domain, info->domain)==0){ lc->auth_info=ms_list_remove(lc->auth_info,ai); linphone_auth_info_destroy(ai); + updating=TRUE; } lc->auth_info=ms_list_append(lc->auth_info,linphone_auth_info_clone(info)); + /* retry pending authentication operations */ for(l=elem=sal_get_pending_auths(lc->sal);elem!=NULL;elem=elem->next){ SalOp *op=(SalOp*)elem->data; @@ -372,9 +376,20 @@ void linphone_core_add_auth_info(LinphoneCore *lc, const LinphoneAuthInfo *info) } } sal_op_authenticate(op,&sai); - ai->usecount++; + restarted_op_count++; } } + if (l){ + ms_message("linphone_core_add_auth_info(): restarted [%i] operation(s) after %s auth info for\n" + "\tusername: [%s]\n" + "\trealm [%s]\n" + "\tdomain [%s]\n", + restarted_op_count, + updating ? "updating" : "adding", + info->username ? info->username : "", + info->realm ? info->realm : "", + info->domain ? info->domain : ""); + } ms_list_free(l); write_auth_infos(lc); } diff --git a/coreapi/callbacks.c b/coreapi/callbacks.c index 13ac204f7..2a98769e7 100644 --- a/coreapi/callbacks.c +++ b/coreapi/callbacks.c @@ -952,8 +952,6 @@ static bool_t fill_auth_info(LinphoneCore *lc, SalAuthInfo* sai) { sai->userid=ms_strdup(ai->userid?ai->userid:ai->username); sai->password=ai->passwd?ms_strdup(ai->passwd):NULL; sai->ha1=ai->ha1?ms_strdup(ai->ha1):NULL; - ai->usecount++; - ai->last_use_time=ms_time(NULL); return TRUE; } else { return FALSE; diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index be3107b01..91f82e770 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -1374,7 +1374,10 @@ static void linphone_core_init(LinphoneCore * lc, const LinphoneCoreVTable *vtab remote_provisioning_uri = linphone_core_get_provisioning_uri(lc); if (remote_provisioning_uri) { - linphone_remote_provisioning_download_and_apply(lc, remote_provisioning_uri); + int err=linphone_remote_provisioning_download_and_apply(lc, remote_provisioning_uri); + if (err==-1){ + linphone_configuring_terminated(lc, LinphoneConfiguringFailed, "Bad URI"); + } } else { linphone_configuring_terminated(lc, LinphoneConfiguringSkipped, NULL); } diff --git a/coreapi/private.h b/coreapi/private.h index 89d4ae7b1..1c9c8e5a1 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -427,9 +427,6 @@ struct _LinphoneAuthInfo char *passwd; char *ha1; char *domain; - int usecount; - time_t last_use_time; - bool_t works; }; typedef enum _LinphoneIsComposingState { @@ -811,7 +808,7 @@ void linphone_core_invalidate_friend_subscriptions(LinphoneCore *lc); ****************************************************************************/ void linphone_configuring_terminated(LinphoneCore *lc, LinphoneConfiguringState state, const char *message); -void linphone_remote_provisioning_download_and_apply(LinphoneCore *lc, const char *remote_provisioning_uri); +int linphone_remote_provisioning_download_and_apply(LinphoneCore *lc, const char *remote_provisioning_uri); /***************************************************************************** diff --git a/coreapi/remote_provisioning.c b/coreapi/remote_provisioning.c index 99b4c1292..1749fa317 100644 --- a/coreapi/remote_provisioning.c +++ b/coreapi/remote_provisioning.c @@ -79,22 +79,24 @@ static void belle_request_process_auth_requested(void *ctx, belle_sip_auth_event linphone_configuring_terminated(lc, LinphoneConfiguringFailed, "http auth requested"); } -void linphone_remote_provisioning_download_and_apply(LinphoneCore *lc, const char *remote_provisioning_uri) { +int linphone_remote_provisioning_download_and_apply(LinphoneCore *lc, const char *remote_provisioning_uri) { + belle_generic_uri_t *uri=belle_generic_uri_parse(remote_provisioning_uri); belle_http_request_listener_callbacks_t belle_request_listener = { belle_request_process_response_event, belle_request_process_io_error, belle_request_process_timeout, belle_request_process_auth_requested }; - belle_http_request_listener_t *listener = belle_http_request_listener_create_from_callbacks(&belle_request_listener, lc); - belle_http_request_t *request = belle_http_request_create( - "GET", - belle_generic_uri_parse(remote_provisioning_uri), - NULL - ); + belle_http_request_t *request; + if (uri==NULL) { + belle_sip_error("Invalid provisioning URI [%s]",remote_provisioning_uri); + return -1; + } + request=belle_http_request_create("GET",uri, NULL); belle_http_provider_send_request(lc->http_provider, request, listener); + return 0; } void linphone_core_set_provisioning_uri(LinphoneCore *lc, const char*uri){ diff --git a/gtk/config-fetching.c b/gtk/config-fetching.c index bc7a44336..e275662e1 100644 --- a/gtk/config-fetching.c +++ b/gtk/config-fetching.c @@ -33,11 +33,11 @@ void linphone_gtk_config_uri_changed(GtkWidget *button){ GtkWidget *w=gtk_widget_get_toplevel(button); GtkWidget *entry=linphone_gtk_get_widget(w,"uri_entry"); const char *uri=gtk_entry_get_text(GTK_ENTRY(entry)); - if (uri && strcmp(uri,"https://")!=0){/*not just the hint text*/ - /*set provisionning uri to the core*/ - linphone_core_set_provisioning_uri(linphone_gtk_get_core(),uri); - gtk_widget_destroy(w); - } + + if (uri && (strlen(uri)==0 || strcmp(uri,"https://")==0)) uri=NULL; + + linphone_core_set_provisioning_uri(linphone_gtk_get_core(),uri); + gtk_widget_destroy(w); if (uri){ linphone_gtk_schedule_restart();