Exemplo n.º 1
0
LinphoneFriend * linphone_friend_new_from_config_file(LinphoneCore *lc, int index){
	const char *tmp;
	char item[50];
	int a;
	LinphoneFriend *lf;
	LpConfig *config=lc->config;

	sprintf(item,"friend_%i",index);

	if (!lp_config_has_section(config,item)){
		return NULL;
	}

	tmp=lp_config_get_string(config,item,"url",NULL);
	if (tmp==NULL) {
		return NULL;
	}
	lf=linphone_core_create_friend_with_address(lc, tmp);
	if (lf==NULL) {
		return NULL;
	}
	tmp=lp_config_get_string(config,item,"pol",NULL);
	if (tmp==NULL) linphone_friend_set_inc_subscribe_policy(lf,LinphoneSPWait);
	else{
		linphone_friend_set_inc_subscribe_policy(lf,__policy_str_to_enum(tmp));
	}
	a=lp_config_get_int(config,item,"subscribe",0);
	linphone_friend_send_subscribe(lf,a);
	a = lp_config_get_int(config, item, "presence_received", 0);
	lf->presence_received = (bool_t)a;

	linphone_friend_set_ref_key(lf,lp_config_get_string(config,item,"refkey",NULL));
	return lf;
}
Exemplo n.º 2
0
static void linphone_remote_provisioning_apply(LinphoneCore *lc, const char *xml) {
	xml2lpc_context *context = xml2lpc_context_new(xml2lpc_callback, lc);
	int result = xml2lpc_set_xml_string(context, xml);
	char * error_msg = NULL;
	if (result == 0) {
		LpConfig * lpc = linphone_core_get_config(lc);
		result = xml2lpc_convert(context, lpc);
		if (result == 0) {
			// if the remote provisioning added a proxy config and none was set before, set it
			if (lp_config_has_section(lpc, "proxy_0") && lp_config_get_int(lpc, "sip", "default_proxy", -1) == -1){
				lp_config_set_int(lpc, "sip", "default_proxy", 0);
			}
			lp_config_sync(lpc);

		} else {
			error_msg = "xml to lpc failed";
		}
	} else {
		error_msg = "invalid xml";
	}

	xml2lpc_context_destroy(context);
	linphone_configuring_terminated(lc
									,error_msg ? LinphoneConfiguringFailed : LinphoneConfiguringSuccessful
									, error_msg);
}
Exemplo n.º 3
0
LinphoneAuthInfo *linphone_auth_info_new_from_config_file(LpConfig * config, int pos)
{
	char key[50];
	const char *username,*userid,*passwd,*ha1,*realm;
	
	sprintf(key,"auth_info_%i",pos);
	if (!lp_config_has_section(config,key)){
		return NULL;
	}
	
	username=lp_config_get_string(config,key,"username",NULL);
	userid=lp_config_get_string(config,key,"userid",NULL);
	passwd=lp_config_get_string(config,key,"passwd",NULL);
	ha1=lp_config_get_string(config,key,"ha1",NULL);
	realm=lp_config_get_string(config,key,"realm",NULL);
	return linphone_auth_info_new(username,userid,passwd,ha1,realm);
}
Exemplo n.º 4
0
void call_logs_read_from_config_file(LinphoneCore *lc){
	char logsection[32];
	int i;
	const char *tmp;
	uint64_t sec;
	LpConfig *cfg=lc->config;
	for(i=0;;++i){
		snprintf(logsection,sizeof(logsection),"call_log_%i",i);
		if (lp_config_has_section(cfg,logsection)){
			LinphoneCallLog *cl;
			LinphoneAddress *from=NULL,*to=NULL;
			tmp=lp_config_get_string(cfg,logsection,"from",NULL);
			if (tmp) from=linphone_address_new(tmp);
			tmp=lp_config_get_string(cfg,logsection,"to",NULL);
			if (tmp) to=linphone_address_new(tmp);
			if (!from || !to)
				continue;
			cl=linphone_call_log_new(lp_config_get_int(cfg,logsection,"dir",0),from,to);
			cl->status=lp_config_get_int(cfg,logsection,"status",0);
			sec=lp_config_get_int64(cfg,logsection,"start_date_time",0);
			if (sec) {
				/*new call log format with date expressed in seconds */
				cl->start_date_time=(time_t)sec;
				set_call_log_date(cl,cl->start_date_time);
			}else{
				tmp=lp_config_get_string(cfg,logsection,"start_date",NULL);
				if (tmp) {
					strncpy(cl->start_date,tmp,sizeof(cl->start_date));
					cl->start_date_time=string_to_time(cl->start_date);
				}
			}
			cl->duration=lp_config_get_int(cfg,logsection,"duration",0);
			tmp=lp_config_get_string(cfg,logsection,"refkey",NULL);
			if (tmp) cl->refkey=ms_strdup(tmp);
			cl->quality=lp_config_get_float(cfg,logsection,"quality",-1);
			cl->video_enabled=lp_config_get_int(cfg,logsection,"video_enabled",0);
			tmp=lp_config_get_string(cfg,logsection,"call_id",NULL);
			if (tmp) cl->call_id=ms_strdup(tmp);
			lc->call_logs=ms_list_append(lc->call_logs,cl);
		}else break;
	}
}
Exemplo n.º 5
0
void linphone_nat_policy_save_to_config(const LinphoneNatPolicy *policy) {
	LpConfig *config = policy->lc->config;
	char *section;
	int index;
	bool_t finished = FALSE;

	for (index = 0; finished != TRUE; index++) {
		section = belle_sip_strdup_printf("nat_policy_%i", index);
		if (lp_config_has_section(config, section)) {
			const char *config_ref = lp_config_get_string(config, section, "ref", NULL);
			if ((config_ref != NULL) && (strcmp(config_ref, policy->ref) == 0)) {
				_linphone_nat_policy_save_to_config(policy, config, index);
				finished = TRUE;
			}
		} else {
			_linphone_nat_policy_save_to_config(policy, config, index);
			finished = TRUE;
		}
		belle_sip_free(section);
	}
}
Exemplo n.º 6
0
LinphoneProxyConfig *linphone_proxy_config_new_from_config_file(LpConfig *config, int index)
{
	const char *tmp;
	const char *identity;
	const char *proxy;
	LinphoneProxyConfig *cfg;
	char key[50];
	
	sprintf(key,"proxy_%i",index);

	if (!lp_config_has_section(config,key)){
		return NULL;
	}

	cfg=linphone_proxy_config_new();

	identity=lp_config_get_string(config,key,"reg_identity",NULL);	
	proxy=lp_config_get_string(config,key,"reg_proxy",NULL);
	
	linphone_proxy_config_set_identity(cfg,identity);
	linphone_proxy_config_set_server_addr(cfg,proxy);
	
	tmp=lp_config_get_string(config,key,"reg_route",NULL);
	if (tmp!=NULL) linphone_proxy_config_set_route(cfg,tmp);

	linphone_proxy_config_expires(cfg,lp_config_get_int(config,key,"reg_expires",600));
	linphone_proxy_config_enableregister(cfg,lp_config_get_int(config,key,"reg_sendregister",0));
	
	linphone_proxy_config_enable_publish(cfg,lp_config_get_int(config,key,"publish",0));

	linphone_proxy_config_set_dial_escape_plus(cfg,lp_config_get_int(config,key,"dial_escape_plus",0));
	linphone_proxy_config_set_dial_prefix(cfg,lp_config_get_string(config,key,"dial_prefix",NULL));
	
	tmp=lp_config_get_string(config,key,"type",NULL);
	if (tmp!=NULL && strlen(tmp)>0) 
		linphone_proxy_config_set_sip_setup(cfg,tmp);

	return cfg;
}
Exemplo n.º 7
0
LinphoneNatPolicy * linphone_core_create_nat_policy_from_config(LinphoneCore *lc, const char *ref) {
	LpConfig *config = lc->config;
	LinphoneNatPolicy *policy = NULL;
	char *section;
	int index;
	bool_t finished = FALSE;

	for (index = 0; finished != TRUE; index++) {
		section = belle_sip_strdup_printf("nat_policy_%i", index);
		if (lp_config_has_section(config, section)) {
			const char *config_ref = lp_config_get_string(config, section, "ref", NULL);
			if ((config_ref != NULL) && (strcmp(config_ref, ref) == 0)) {
				const char *server = lp_config_get_string(config, section, "stun_server", NULL);
				const char *username = lp_config_get_string(config, section, "stun_server_username", NULL);
				bctbx_list_t *l = lp_config_get_string_list(config, section, "protocols", NULL);
				policy = _linphone_nat_policy_new_with_ref(lc, ref);
				if (server != NULL) linphone_nat_policy_set_stun_server(policy, server);
				if (username != NULL) linphone_nat_policy_set_stun_server_username(policy, username);
				if (l != NULL) {
					bool_t upnp_enabled = FALSE;
					bctbx_list_t *elem;
					for (elem = l; elem != NULL; elem = elem->next) {
						const char *value = (const char *)elem->data;
						if (strcmp(value, "stun") == 0) linphone_nat_policy_enable_stun(policy, TRUE);
						else if (strcmp(value, "turn") == 0) linphone_nat_policy_enable_turn(policy, TRUE);
						else if (strcmp(value, "ice") == 0) linphone_nat_policy_enable_ice(policy, TRUE);
						else if (strcmp(value, "upnp") == 0) upnp_enabled = TRUE;
					}
					if (upnp_enabled) linphone_nat_policy_enable_upnp(policy, TRUE);
				}
				finished = TRUE;
			}
		} else finished = TRUE;
		belle_sip_free(section);
	}
	return policy;
}
Exemplo n.º 8
0
LinphoneAuthInfo *linphone_auth_info_new_from_config_file(LpConfig * config, int pos)
{
	char key[50];
	const char *username,*userid,*passwd,*ha1,*realm,*domain,*tls_cert_path,*tls_key_path;
	LinphoneAuthInfo *ret;

	sprintf(key, "auth_info_%i", pos);
	if (!lp_config_has_section(config, key)) {
		return NULL;
	}

	username = lp_config_get_string(config, key, "username", NULL);
	userid = lp_config_get_string(config, key, "userid", NULL);
	passwd = lp_config_get_string(config, key, "passwd", NULL);
	ha1 = lp_config_get_string(config, key, "ha1", NULL);
	realm = lp_config_get_string(config, key, "realm", NULL);
	domain = lp_config_get_string(config, key, "domain", NULL);
	tls_cert_path = lp_config_get_string(config, key, "client_cert_chain", NULL);
	tls_key_path = lp_config_get_string(config, key, "client_cert_key", NULL);
	ret = linphone_auth_info_new(username, userid, passwd, ha1, realm, domain);
	linphone_auth_info_set_tls_cert_path(ret, tls_cert_path);
	linphone_auth_info_set_tls_key_path(ret, tls_key_path);
	return ret;
}