return i->userid;
}
+const char *linphone_auth_info_get_realm(const LinphoneAuthInfo *i){
+ return i->realm;
+}
+const char *linphone_auth_info_get_ha1(const LinphoneAuthInfo *i){
+ return i->ha1;
+}
+
/**
* Sets the password.
**/
if (userid && strlen(userid)>0) info->userid=ms_strdup(userid);
}
+/**
+ * Sets realm.
+**/
+void linphone_auth_info_set_realm(LinphoneAuthInfo *info, const char *realm){
+ if (info->realm){
+ ms_free(info->realm);
+ info->realm=NULL;
+ }
+ if (realm && strlen(realm)>0) info->realm=ms_strdup(realm);
+}
+/**
+ * Sets ha1.
+**/
+void linphone_auth_info_set_ha1(LinphoneAuthInfo *info, const char *ha1){
+ if (info->ha1){
+ ms_free(info->ha1);
+ info->ha1=NULL;
+ }
+ if (ha1 && strlen(ha1)>0) info->ha1=ms_strdup(ha1);
+}
+
/**
* Destroys a LinphoneAuthInfo object.
**/
sprintf(key,"auth_info_%i",pos);
lp_config_clean_section(config,key);
- if (obj==NULL){
+ if (obj==NULL || lp_config_get_int(config, "sip", "store_auth_info", 1) == 0){
return;
}
if (obj->username!=NULL){
return ret;
}
+static void write_auth_infos(LinphoneCore *lc){
+ MSList *elem;
+ int i;
+
+ if (!linphone_core_ready(lc)) return;
+ for(elem=lc->auth_info,i=0;elem!=NULL;elem=ms_list_next(elem),i++){
+ LinphoneAuthInfo *ai=(LinphoneAuthInfo*)(elem->data);
+ linphone_auth_info_write_config(lc->config,ai,i);
+ }
+ linphone_auth_info_write_config(lc->config,NULL,i); /* mark the end */
+}
+
/**
* Adds authentication information to the LinphoneCore.
*
{
LinphoneAuthInfo *ai;
MSList *elem;
+ MSList *l;
/* find if we are attempting to modify an existing auth info */
ai=(LinphoneAuthInfo*)linphone_core_find_auth_info(lc,info->realm,info->username);
}
lc->auth_info=ms_list_append(lc->auth_info,linphone_auth_info_clone(info));
/* retry pending authentication operations */
- for(elem=sal_get_pending_auths(lc->sal);elem!=NULL;elem=elem->next){
+ for(l=elem=sal_get_pending_auths(lc->sal);elem!=NULL;elem=elem->next){
const char *username,*realm;
SalOp *op=(SalOp*)elem->data;
LinphoneAuthInfo *ai;
ai->usecount++;
}
}
+ ms_list_free(l);
+ write_auth_infos(lc);
}
* Removes an authentication information object.
**/
void linphone_core_remove_auth_info(LinphoneCore *lc, const LinphoneAuthInfo *info){
- int i;
- MSList *elem;
LinphoneAuthInfo *r;
r=(LinphoneAuthInfo*)linphone_core_find_auth_info(lc,info->realm,info->username);
if (r){
lc->auth_info=ms_list_remove(lc->auth_info,r);
/*printf("len=%i newlen=%i\n",len,newlen);*/
linphone_auth_info_destroy(r);
- for (elem=lc->auth_info,i=0;elem!=NULL;elem=ms_list_next(elem),i++){
- linphone_auth_info_write_config(lc->config,(LinphoneAuthInfo*)elem->data,i);
- }
- linphone_auth_info_write_config(lc->config,NULL,i);
+ write_auth_infos(lc);
}
}