Esempio n. 1
0
void SIP_Account::set_proxy(LinphoneProxyConfig *cfg)
{
	const char *tmp;
	QTextCodec::setCodecForCStrings(QTextCodec::codecForName("utf8"));
	QTextCodec *codec = QTextCodec::codecForCStrings();
	QString a;
	_cfg = cfg;
	if (cfg){
		linphone_proxy_config_edit(cfg);
		tmp = linphone_proxy_config_get_identity(cfg);
		a = codec->toUnicode(tmp);
		ui->lineEdit_account->setText(a);
		tmp = linphone_proxy_config_get_addr(cfg);
		a = codec->toUnicode(tmp);
		ui->lineEdit_proxy->setText(a);
		tmp=linphone_proxy_config_get_route(cfg);
		if (tmp) {
			a = codec->toUnicode(tmp);
			ui->lineEdit_route->setText(a);
		}
		ui->checkBox_register->setChecked(linphone_proxy_config_register_enabled(cfg));
		ui->spinBox_Regtime->setValue(linphone_proxy_config_get_expires(cfg));
		ui->checkBox_publish->setChecked(linphone_proxy_config_publish_enabled(cfg));
	}
}
Esempio n. 2
0
static void linphone_core_migrate_proxy_config(LinphoneCore *lc, LinphoneTransportType type){
	const MSList *elem;
	for(elem=linphone_core_get_proxy_config_list(lc);elem!=NULL;elem=elem->next){
		LinphoneProxyConfig *cfg=(LinphoneProxyConfig*)elem->data;
		const char *proxy=linphone_proxy_config_get_addr(cfg);
		const char *route=linphone_proxy_config_get_route(cfg);
		LinphoneAddress *proxy_addr=linphone_address_new(proxy);
		LinphoneAddress *route_addr=NULL;
		char *tmp;
		if (route) route_addr=linphone_address_new(route);
		if (proxy_addr){
			linphone_address_set_transport(proxy_addr,type);
			tmp=linphone_address_as_string(proxy_addr);
			linphone_proxy_config_set_server_addr(cfg,tmp);
			ms_free(tmp);
			linphone_address_destroy(proxy_addr);
		}
		if (route_addr){
			linphone_address_set_transport(route_addr,type);
			tmp=linphone_address_as_string(route_addr);
			linphone_proxy_config_set_route(cfg,tmp);
			ms_free(tmp);
			linphone_address_destroy(route_addr);
		}
	}
}
Esempio n. 3
0
static void proxy_transport_change(){
	LinphoneCoreManager* lcm = create_lcm();
	stats* counters = &lcm->stat;
	LinphoneProxyConfig* proxy_config;
	LinphoneAddress* addr;
	char* addr_as_string;
	LinphoneAuthInfo *info=linphone_auth_info_new(test_username,NULL,test_password,NULL,auth_domain,NULL); /*create authentication structure from identity*/
	linphone_core_add_auth_info(lcm->lc,info); /*add authentication info to LinphoneCore*/

	register_with_refresh_base(lcm->lc,FALSE,auth_domain,NULL);

	linphone_core_get_default_proxy(lcm->lc,&proxy_config);
	reset_counters(counters); /*clear stats*/
	linphone_proxy_config_edit(proxy_config);

	CU_ASSERT_FALSE(wait_for_until(lcm->lc,lcm->lc,&counters->number_of_LinphoneRegistrationCleared,1,3000));
	addr = linphone_address_new(linphone_proxy_config_get_addr(proxy_config));

	if (LinphoneTransportTcp == linphone_address_get_transport(addr)) {
		linphone_address_set_transport(addr,LinphoneTransportUdp);
	} else {
		linphone_address_set_transport(addr,LinphoneTransportTcp);
	}
	linphone_proxy_config_set_server_addr(proxy_config,addr_as_string=linphone_address_as_string(addr));

	linphone_proxy_config_done(proxy_config);

	CU_ASSERT(wait_for(lcm->lc,lcm->lc,&counters->number_of_LinphoneRegistrationOk,1));
	/*as we change p[roxy server destination, we should'nt be notified about the clear*/
	CU_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationCleared,0);
	ms_free(addr_as_string);
	linphone_address_destroy(addr);
	linphone_core_manager_destroy(lcm);

}
Esempio n. 4
0
void linphone_proxy_config_set_sip_setup(LinphoneProxyConfig *cfg, const char *type){
	if (cfg->type)
		ms_free(cfg->type);
	cfg->type=ms_strdup(type);
	if (linphone_proxy_config_get_addr(cfg)==NULL){
		/*put a placeholder so that the sip setup gets saved into the config */
		linphone_proxy_config_set_server_addr(cfg,"sip:undefined");
	}
}
Esempio n. 5
0
static void registration_state_changed(struct _LinphoneCore *lc, LinphoneProxyConfig *cfg, LinphoneRegistrationState cstate, const char *message)
{
	Q_UNUSED(lc)
	Q_UNUSED(message)

	SipClient *sc = SipClient::instance();
	sc->registrationStateChangedCb(cstate);

	printf("New registration state %s for user id [%s] at proxy [%s]\n",
		linphone_registration_state_to_string(cstate),
		linphone_proxy_config_get_identity(cfg),
		linphone_proxy_config_get_addr(cfg));
}
Esempio n. 6
0
static void registration_state_changed(struct _LinphoneCore *lc, LinphoneProxyConfig *cfg, LinphoneRegistrationState cstate, const char *message)
{
//	Q_UNUSED(message)

    qDebug() << __func__
             << "New registration state:" << linphone_registration_state_to_string(cstate)
             << "User:"******"Proxy:" << linphone_proxy_config_get_addr(cfg)
             << "Message:" << message;

    QLinPhoneCore *lcc = static_cast<QLinPhoneCore *>(linphone_core_get_user_data(lc));
    lcc->setRegistrationState(static_cast<enum QLinPhoneCore::RegistrationState>(cstate));
}
void registration_state_changed(struct _LinphoneCore *lc, LinphoneProxyConfig *cfg, LinphoneRegistrationState cstate, const char *message){
		stats* counters;
		ms_message("New registration state %s for user id [%s] at proxy [%s]\n"
				,linphone_registration_state_to_string(cstate)
				,linphone_proxy_config_get_identity(cfg)
				,linphone_proxy_config_get_addr(cfg));
		counters = get_stats(lc);
		switch (cstate) {
		case LinphoneRegistrationNone:counters->number_of_LinphoneRegistrationNone++;break;
		case LinphoneRegistrationProgress:counters->number_of_LinphoneRegistrationProgress++;break;
		case LinphoneRegistrationOk:counters->number_of_LinphoneRegistrationOk++;break;
		case LinphoneRegistrationCleared:counters->number_of_LinphoneRegistrationCleared++;break;
		case LinphoneRegistrationFailed:counters->number_of_LinphoneRegistrationFailed++;break;
		default:
			BC_FAIL("unexpected event");break;
		}

}
Esempio n. 8
0
static void text_message_compatibility_mode(void) {
	char route[256];
	LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc");
	LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc");
	LinphoneProxyConfig* proxy;
	LinphoneAddress* proxy_address;
	char*tmp;
	LCSipTransports transport;
	char* to = linphone_address_as_string(pauline->identity);
	LinphoneChatRoom* chat_room;

	linphone_core_get_default_proxy(marie->lc,&proxy);
	CU_ASSERT_PTR_NOT_NULL (proxy);
	proxy_address=linphone_address_new(linphone_proxy_config_get_addr(proxy));
	linphone_address_clean(proxy_address);
	tmp=linphone_address_as_string_uri_only(proxy_address);
	linphone_proxy_config_set_server_addr(proxy,tmp);
	sprintf(route,"sip:%s",test_route);
	linphone_proxy_config_set_route(proxy,route);
	ms_free(tmp);
	linphone_address_destroy(proxy_address);
	linphone_core_get_sip_transports(marie->lc,&transport);
	transport.udp_port=0;
	transport.tls_port=0;
	transport.dtls_port=0;
	/*only keep tcp*/
	linphone_core_set_sip_transports(marie->lc,&transport);
	marie->stat.number_of_LinphoneRegistrationOk=0;

	CU_ASSERT_TRUE (wait_for(marie->lc,marie->lc,&marie->stat.number_of_LinphoneRegistrationOk,1));

	chat_room = linphone_core_create_chat_room(marie->lc,to);
	{
		int dummy=0;
		wait_for_until(marie->lc,pauline->lc,&dummy,1,100); /*just to have time to purge message stored in the server*/
		reset_counters(&marie->stat);
		reset_counters(&pauline->stat);
	}
	linphone_chat_room_send_message(chat_room,"Bla bla bla bla");
	CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneMessageReceived,1));
	CU_ASSERT_EQUAL(pauline->stat.number_of_LinphoneMessageReceivedLegacy,1);
	linphone_core_manager_destroy(marie);
	linphone_core_manager_destroy(pauline);
}
Esempio n. 9
0
/*the purpose of this test is to check that will not block the proxy config during SSL handshake for entire life in case of mistaken configuration*/
static void tls_with_non_tls_server(){
	LinphoneCoreManager *mgr;
	LinphoneProxyConfig* proxy_cfg;
	LinphoneAddress* addr;
	char tmp[256];
	LinphoneCore *lc;
	
	mgr=linphone_core_manager_new2( "marie_rc", 0);
	lc=mgr->lc;
	sal_set_transport_timeout(lc->sal,3000);
	linphone_core_get_default_proxy(lc,&proxy_cfg);
	linphone_proxy_config_edit(proxy_cfg);
	addr=linphone_address_new(linphone_proxy_config_get_addr(proxy_cfg));
	snprintf(tmp,sizeof(tmp),"sip:%s:%i;transport=tls"	,linphone_address_get_domain(addr)
			,(linphone_address_get_port(addr)>0?linphone_address_get_port(addr):5060));
	linphone_proxy_config_set_server_addr(proxy_cfg,tmp);
	linphone_proxy_config_done(proxy_cfg);
	linphone_address_destroy(addr);
	CU_ASSERT_TRUE(wait_for_until(lc,lc,&mgr->stat.number_of_LinphoneRegistrationFailed,1,5000));
	linphone_core_manager_destroy(mgr);
}
static void tls_with_non_tls_server(){
	LinphoneCoreManager *mgr;
	LinphoneProxyConfig* proxy_cfg;
	LinphoneAddress* addr;
	char tmp[256];
	LinphoneCore *lc;
	
	mgr=linphone_core_manager_new2( "marie_rc", 0);
	lc=mgr->lc;
	linphone_core_get_default_proxy(lc,&proxy_cfg);
	linphone_proxy_config_edit(proxy_cfg);
	addr=linphone_address_new(linphone_proxy_config_get_addr(proxy_cfg));
	snprintf(tmp,sizeof(tmp),"sip:%s:%i;transport=tls"	,linphone_address_get_domain(addr)
			,(linphone_address_get_port_int(addr)>0?linphone_address_get_port_int(addr):5060));
	linphone_proxy_config_set_server_addr(proxy_cfg,tmp);
	linphone_proxy_config_done(proxy_cfg);
	linphone_address_destroy(addr);
	/* FIXME http://git.linphone.org/mantis/view.php?id=758
	CU_ASSERT_TRUE(wait_for(lc,lc,&mgr->stat.number_of_LinphoneRegistrationFailed,1));
	*/
	linphone_core_manager_destroy(mgr);
}
Esempio n. 11
0
/**
 * Registration state notification callback
 */
static void registration_state_changed(LinphoneCore *lc, LinphoneProxyConfig *cfg, LinphoneRegistrationState cstate, const char *message){
	printf("New registration state %s for user id [%s] at proxy [%s]\n"
			,linphone_registration_state_to_string(cstate)
			,linphone_proxy_config_get_identity(cfg)
			,linphone_proxy_config_get_addr(cfg));
}
Esempio n. 12
0
extern "C" jint
Java_com_acsoftware_android_domophone_LibLP_nRegistered(JNIEnv* env, jobject thiz, jstring jIdent, jstring jHost) {
    
    jint result = 0;
    
    if ( lc ) {
        
        char* ident = jIdent?(char*)env->GetStringUTFChars(jIdent, NULL):NULL;
        char* host = jHost?(char*)env->GetStringUTFChars(jHost, NULL):NULL;
        
        int s;
        
        if ( ident ) {
            char *i = NULL;
            
            if ( ident != NULL && host != NULL ) {
                s = strlen(ident)+strlen(host)+6;
                i = (char*)malloc(s+1);
                
                snprintf(i, s, "sip:%s@%s", ident, host);
            }
            
            
            env->ReleaseStringUTFChars(jIdent, ident);
            ident = i;
        }
        
        if ( host ) {
            s = strlen(host)+7;
            char *h = (char*)malloc(s+1);
            
            snprintf(h, s, "sip:%s", host);
            
            env->ReleaseStringUTFChars(jHost, host);
            host = h;
        }
        
        
        LinphoneProxyConfig* proxy_cfg = linphone_core_get_default_proxy_config(lc);
        
        if ( proxy_cfg
            && linphone_proxy_config_is_registered(proxy_cfg) == 1 )
        {
            if ( ( ident && strlen(ident) > 0 ) || ( host && strlen(host) > 0 ) ) {
                
                const char *cident = linphone_proxy_config_get_identity(proxy_cfg);
                const char *chost = linphone_proxy_config_get_addr(proxy_cfg);
                
                __android_log_write(ANDROID_LOG_DEBUG, "LIBLP-cident", cident);
                __android_log_write(ANDROID_LOG_DEBUG, "LIBLP-ident", ident);
                __android_log_write(ANDROID_LOG_DEBUG, "LIBLP-chost", chost);
                __android_log_write(ANDROID_LOG_DEBUG, "LIBLP-host", host);
                
                if ( strcmp(cident, ident) == 0
                    && strcmp(chost, host) == 0 )
                    result = 2;
            };
            
            if ( result == 0 ) {
                result = 1;
            }
            
            if ( ident ) {
                free(ident);
            }
            
            if ( host ) {
                free(host);
            }
        };
    };
    
    return result;
    
}