示例#1
0
static void text_message_with_credential_from_auth_cb(void) {
	char* to;
	LinphoneChatRoom* chat_room;
	LinphoneCoreVTable* vtable = linphone_core_v_table_new();
	LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
	LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc");
	text_message_with_credential_from_auth_cb_auth_info=linphone_auth_info_clone((LinphoneAuthInfo*)(linphone_core_get_auth_info_list(marie->lc)->data));

	/*to force cb to be called*/
	linphone_core_clear_all_auth_info(marie->lc);
	vtable->auth_info_requested=text_message_with_credential_from_auth_cb_auth_info_requested;
	linphone_core_add_listener(marie->lc, vtable);

	to = linphone_address_as_string(marie->identity);
	chat_room = linphone_core_create_chat_room(pauline->lc,to);
	ms_free(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,&marie->stat.number_of_LinphoneMessageReceived,1));
	CU_ASSERT_EQUAL(marie->stat.number_of_LinphoneMessageReceivedLegacy,1);

	CU_ASSERT_PTR_NOT_NULL(linphone_core_get_chat_room(marie->lc,pauline->identity));

	linphone_core_manager_destroy(marie);
	linphone_core_manager_destroy(pauline);
}
示例#2
0
extern "C" void
Java_com_acsoftware_android_domophone_LibLP_nRegister(JNIEnv* env, jobject thiz, jstring jIdent, jstring jHost) {
    
    char buffer[256] = {0};
    const char* ident = jIdent?env->GetStringUTFChars(jIdent, NULL):NULL;
    const char* host = jHost?env->GetStringUTFChars(jHost, NULL):NULL;
    
    if ( _RegistrationInProgress
         || !lc
         || !ident
         || !host
         || strlen(ident)+strlen(host) >= 256 ) return;
    
   // [self timerInitialize];
    
    if ( Java_com_acsoftware_android_domophone_LibLP_nRegistered(env, thiz, jIdent, jHost) != 2 ) {
        
        _RegistrationInProgress = 1;
        //lastIdent = Ident;
        //lastHost = Host;
        
        CallMethod(env, "BeforeRegisterEvent");
        
        
        Java_com_acsoftware_android_domophone_LibLP_nTerminateCall(env, thiz);
        Java_com_acsoftware_android_domophone_LibLP_nUnregister(env, thiz);
        
	    linphone_core_clear_all_auth_info(lc);
        linphone_core_clear_proxy_config(lc);
        
        LCSipTransports transportValue;
        linphone_core_get_sip_transports(lc, &transportValue);
        
        if (transportValue.tcp_port == 0) transportValue.tcp_port=transportValue.udp_port + transportValue.tls_port;
        transportValue.udp_port=0;
        transportValue.tls_port=0;
        linphone_core_set_sip_transports(lc, &transportValue);
        
        LinphoneProxyConfig* proxy_cfg = linphone_proxy_config_new();
        
        snprintf(buffer, 256, "sip:%s@%s", ident, host);
        
        linphone_proxy_config_set_identity(proxy_cfg, buffer);
        
        snprintf(buffer, 256, "sip:%s", host);
        
        linphone_proxy_config_set_server_addr(proxy_cfg, buffer);
        linphone_proxy_config_enable_register(proxy_cfg, true);
        linphone_proxy_config_expires(proxy_cfg, DEFAULT_EXPIRES);
        linphone_core_add_proxy_config(lc,proxy_cfg);
        linphone_core_set_default_proxy(lc,proxy_cfg);
        
        linphone_core_set_network_reachable(lc, true);
    } else {
        CallMethod(env, "SipRegisteredEvent");
    }
    
    if ( ident ) {
        env->ReleaseStringUTFChars(jIdent, ident);
    }
    
    if ( host ) {
        env->ReleaseStringUTFChars(jHost, host);
    }
    
};