G_MODULE_EXPORT void linphone_gtk_login_frame_connect_clicked(GtkWidget *button){ GtkWidget *mw=gtk_widget_get_toplevel(button); const char *username; const char *password; char *identity; gboolean autologin; LinphoneProxyConfig *cfg=(LinphoneProxyConfig*)g_object_get_data(G_OBJECT(mw),"login_proxy_config"); LinphoneAddress *from; SipSetupContext *ssctx=linphone_proxy_config_get_sip_setup_context(cfg); username=gtk_entry_get_text(GTK_ENTRY(linphone_gtk_get_widget(mw,"login_username"))); password=gtk_entry_get_text(GTK_ENTRY(linphone_gtk_get_widget(mw,"login_password"))); if (username==NULL || username[0]=='\0') return; autologin=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(mw,"automatic_login"))); linphone_gtk_set_ui_config_int("automatic_login",autologin); linphone_gtk_set_ui_config("login_username",username); from=linphone_address_new(linphone_proxy_config_get_identity(cfg)); linphone_address_set_username(from,username); identity=linphone_address_as_string(from); do_login(ssctx,identity,password); /*we need to refresh the identities since the proxy config may have changed.*/ linphone_gtk_load_identities(); }
LinphoneAddress *account_manager_check_account(AccountManager *m, LinphoneProxyConfig *cfg){ LinphoneCore *lc=linphone_proxy_config_get_core(cfg); const char *identity=linphone_proxy_config_get_identity(cfg); LinphoneAddress *id_addr=linphone_address_new(identity); Account *account=account_manager_get_account(m,id_addr); LinphoneAuthInfo *ai; char *tmp; bool_t create_account=FALSE; if (!account){ account=account_new(id_addr,m->unique_id); ms_message("No account for %s exists, going to create one.",identity); create_account=TRUE; m->accounts=ms_list_append(m->accounts,account); } /*modify the username of the identity of the proxy config*/ linphone_address_set_username(id_addr, linphone_address_get_username(account->modified_identity)); tmp=linphone_address_as_string(id_addr); linphone_proxy_config_set_identity(cfg,tmp); ms_free(tmp); if (create_account){ account_create_on_server(account,cfg); } ai=linphone_auth_info_new(linphone_address_get_username(account->modified_identity), NULL, account->password,NULL,NULL,linphone_address_get_domain(account->modified_identity)); linphone_core_add_auth_info(lc,ai); linphone_auth_info_destroy(ai); linphone_address_unref(id_addr); return account->modified_identity; }
static void sip_update_within_icoming_reinvite_with_no_sdp(void) { LinphoneCoreManager *mgr; char *identity_char; char *scen; FILE * sipp_out; /*currently we use direct connection because sipp do not properly set ACK request uri*/ mgr= linphone_core_manager_new2( "empty_rc", FALSE); mgr->identity= linphone_core_get_primary_contact_parsed(mgr->lc); linphone_address_set_username(mgr->identity,"marie"); identity_char=linphone_address_as_string(mgr->identity); linphone_core_set_primary_contact(mgr->lc,identity_char); linphone_core_iterate(mgr->lc); scen = bc_tester_res("sipp/sip_update_within_icoming_reinvite_with_no_sdp.xml"); sipp_out = sip_start(scen, linphone_address_get_username(mgr->identity),NULL, mgr->identity); if (sipp_out) { BC_ASSERT_TRUE(wait_for(mgr->lc, mgr->lc, &mgr->stat.number_of_LinphoneCallIncomingReceived, 1)); linphone_core_accept_call(mgr->lc, linphone_core_get_current_call(mgr->lc)); BC_ASSERT_TRUE(wait_for(mgr->lc, mgr->lc, &mgr->stat.number_of_LinphoneCallStreamsRunning, 2)); BC_ASSERT_TRUE(wait_for(mgr->lc, mgr->lc, &mgr->stat.number_of_LinphoneCallEnd, 1)); pclose(sipp_out); } linphone_core_manager_destroy(mgr); }
void linphone_core_interpret_friend_uri(LinphoneCore *lc, const char *uri, char **result){ LinphoneAddress *fr=NULL; *result=NULL; fr=linphone_address_new(uri); if (fr==NULL){ char *tmp=NULL; if (strchr(uri,'@')!=NULL){ LinphoneAddress *u; /*try adding sip:*/ tmp=ms_strdup_printf("sip:%s",uri); u=linphone_address_new(tmp); if (u!=NULL){ *result=tmp; } }else if (lc->default_proxy!=NULL){ /*try adding domain part from default current proxy*/ LinphoneAddress * id=linphone_address_new(linphone_core_get_identity(lc)); if ((id!=NULL) && (uri[0] != '\0')){ linphone_address_set_display_name(id,NULL); linphone_address_set_username(id,uri); *result=linphone_address_as_string(id); linphone_address_unref(id); } } if (*result){ /*looks good */ ms_message("%s interpreted as %s",uri,*result); }else{ ms_warning("Fail to interpret friend uri %s",uri); } }else { *result=linphone_address_as_string(fr); linphone_address_unref(fr); } }
static LinphoneCoreManager* presence_linphone_core_manager_new(char* username) { LinphoneCoreManager* mgr= linphone_core_manager_new2( "empty_rc", FALSE); char* identity_char; mgr->identity= linphone_core_get_primary_contact_parsed(mgr->lc); linphone_address_set_username(mgr->identity,username); identity_char=linphone_address_as_string(mgr->identity); linphone_core_set_primary_contact(mgr->lc,identity_char); return mgr; }
LinphoneAddress * create_linphone_address(const char * domain) { LinphoneAddress *addr = linphone_address_new(NULL); CU_ASSERT_PTR_NOT_NULL_FATAL(addr); linphone_address_set_username(addr,test_username); CU_ASSERT_STRING_EQUAL(test_username,linphone_address_get_username(addr)); if (!domain) domain= test_route; linphone_address_set_domain(addr,domain); CU_ASSERT_STRING_EQUAL(domain,linphone_address_get_domain(addr)); linphone_address_set_display_name(addr, NULL); linphone_address_set_display_name(addr, "Mr Tester"); CU_ASSERT_STRING_EQUAL("Mr Tester",linphone_address_get_display_name(addr)); return addr; }
Account *account_new(LinphoneAddress *identity, const char *unique_id){ char *modified_username; Account *obj=ms_new0(Account,1); /* we need to inhibit leak detector because the two LinphoneAddress will remain behond the scope of the test being run */ belle_sip_object_inhibit_leak_detector(TRUE); obj->identity=linphone_address_clone(identity); obj->password=sal_get_random_token(8); obj->modified_identity=linphone_address_clone(identity); modified_username=ms_strdup_printf("%s_%s",linphone_address_get_username(identity), unique_id); linphone_address_set_username(obj->modified_identity, modified_username); ms_free(modified_username); belle_sip_object_inhibit_leak_detector(FALSE); return obj; };
/*static void dest_server_server_resolved(void *data, const char *name, struct addrinfo *ai_list) { *(struct addrinfo **)data =ai_list; }*/ static void sip_update_within_icoming_reinvite_with_no_sdp(void) { LinphoneCoreManager *mgr; /* LinphoneProxyConfig *proxy = linphone_core_get_default_proxy_config(mgr->lc); LinphoneAddress *dest = linphone_address_new(linphone_proxy_config_get_route(proxy) ?linphone_proxy_config_get_route(proxy):linphone_proxy_config_get_server_addr(proxy)); struct addrinfo *addrinfo = NULL; char ipstring [INET6_ADDRSTRLEN]; int err; int port = linphone_address_get_port(dest);*/ char *identity_char; char *scen; FILE * sipp_out; /*currently we use direct connection because sipp do not properly set ACK request uri*/ mgr= linphone_core_manager_new2( "empty_rc", FALSE); mgr->identity= linphone_core_get_primary_contact_parsed(mgr->lc); linphone_address_set_username(mgr->identity,"marie"); identity_char=linphone_address_as_string(mgr->identity); linphone_core_set_primary_contact(mgr->lc,identity_char); linphone_core_iterate(mgr->lc); /* sal_resolve_a( mgr->lc->sal ,linphone_address_get_domain(dest) ,linphone_address_get_port(dest) ,AF_INET ,(SalResolverCallback)dest_server_server_resolved ,&addrinfo); linphone_address_destroy(dest); dest=linphone_address_new(NULL); wait_for(mgr->lc, mgr->lc, (int*)&addrinfo, 1); err=getnameinfo((struct sockaddr *)addrinfo->ai_addr,addrinfo->ai_addrlen,ipstring,INET6_ADDRSTRLEN,NULL,0,NI_NUMERICHOST); linphone_address_set_domain(dest, ipstring); if (port > 0) linphone_address_set_port(dest, port); */ scen = bc_tester_res("sipp/sip_update_within_icoming_reinvite_with_no_sdp.xml"); sipp_out = sip_start(scen, linphone_address_get_username(mgr->identity), mgr->identity); if (sipp_out) { BC_ASSERT_TRUE(wait_for(mgr->lc, mgr->lc, &mgr->stat.number_of_LinphoneCallIncomingReceived, 1)); linphone_core_accept_call(mgr->lc, linphone_core_get_current_call(mgr->lc)); BC_ASSERT_TRUE(wait_for(mgr->lc, mgr->lc, &mgr->stat.number_of_LinphoneCallStreamsRunning, 2)); BC_ASSERT_TRUE(wait_for(mgr->lc, mgr->lc, &mgr->stat.number_of_LinphoneCallEnd, 1)); pclose(sipp_out); } linphone_core_manager_destroy(mgr); }
static gboolean do_login_noprompt(LinphoneProxyConfig *cfg){ SipSetupContext *ssctx=linphone_proxy_config_get_sip_setup_context(cfg); LinphoneAddress *addr; const char *username; char *tmp; if (ssctx==NULL) return TRUE;/*not ready ?*/ username=linphone_gtk_get_ui_config ("login_username",NULL); if (username==NULL) { linphone_gtk_set_ui_config_int("automatic_login",0); linphone_gtk_show_login_frame(cfg); return FALSE; } addr=linphone_address_new(linphone_proxy_config_get_identity(cfg)); linphone_address_set_username(addr,username); tmp=linphone_address_as_string (addr); do_login(ssctx,tmp,NULL); linphone_address_destroy(addr); return FALSE; }
void AccountSettingsModel::setUsername(const QString& username) { if (!_authInfo || !_proxyConfig) { return; } LinphoneAuthInfo *ai = linphone_auth_info_clone(_authInfo); linphone_auth_info_set_username(ai, username.toUtf8().constData()); linphone_core_remove_auth_info(LinphoneManager::getInstance()->getLc(), _authInfo); linphone_core_add_auth_info(LinphoneManager::getInstance()->getLc(), ai); _authInfo = ai; const char *identity = linphone_proxy_config_get_identity(_proxyConfig); LinphoneAddress *addr = linphone_core_create_address(LinphoneManager::getInstance()->getLc(), identity); linphone_address_set_username(addr, username.toUtf8().constData()); linphone_proxy_config_edit(_proxyConfig); linphone_proxy_config_set_identity_address(_proxyConfig, addr); linphone_proxy_config_done(_proxyConfig); linphone_address_destroy(addr); }
static void call_with_multiple_video_mline_in_sdp(void) { LinphoneCoreManager *mgr; char *identity_char; char *scen; FILE * sipp_out; LinphoneCall *call = NULL; /*currently we use direct connection because sipp do not properly set ACK request uri*/ mgr= linphone_core_manager_new2( "empty_rc", FALSE); mgr->identity = linphone_core_get_primary_contact_parsed(mgr->lc); linphone_address_set_username(mgr->identity,"marie"); identity_char = linphone_address_as_string(mgr->identity); linphone_core_set_primary_contact(mgr->lc,identity_char); linphone_core_iterate(mgr->lc); scen = bc_tester_res("sipp/call_with_multiple_video_mline_in_sdp.xml"); sipp_out = sip_start(scen, linphone_address_get_username(mgr->identity), NULL, mgr->identity); if (sipp_out) { BC_ASSERT_TRUE(wait_for(mgr->lc, mgr->lc, &mgr->stat.number_of_LinphoneCallIncomingReceived, 1)); call = linphone_core_get_current_call(mgr->lc); BC_ASSERT_PTR_NOT_NULL(call); if (call) { linphone_core_accept_call(mgr->lc, call); BC_ASSERT_TRUE(wait_for(mgr->lc, mgr->lc, &mgr->stat.number_of_LinphoneCallStreamsRunning, 1)); BC_ASSERT_EQUAL(call->main_audio_stream_index, 0, int, "%d"); BC_ASSERT_EQUAL(call->main_video_stream_index, 1, int, "%d"); BC_ASSERT_TRUE(call->main_text_stream_index > 3); BC_ASSERT_TRUE(linphone_call_log_video_enabled(linphone_call_get_call_log(call))); check_rtcp(call); } BC_ASSERT_TRUE(wait_for(mgr->lc, mgr->lc, &mgr->stat.number_of_LinphoneCallEnd, 1)); pclose(sipp_out); } linphone_core_manager_destroy(mgr); }
static void call_invite_200ok_without_contact_header(void) { LinphoneCoreManager *mgr; char *identity_char; char *scen; FILE * sipp_out; LinphoneCall *call = NULL; /*currently we use direct connection because sipp do not properly set ACK request uri*/ mgr= linphone_core_manager_new2("empty_rc", FALSE); mgr->identity = linphone_core_get_primary_contact_parsed(mgr->lc); linphone_address_set_username(mgr->identity,"marie"); identity_char = linphone_address_as_string(mgr->identity); linphone_core_set_primary_contact(mgr->lc,identity_char); linphone_core_iterate(mgr->lc); scen = bc_tester_res("sipp/call_invite_200ok_without_contact_header.xml"); sipp_out = sip_start_recv(scen); if (sipp_out) { call = linphone_core_invite(mgr->lc, "[email protected]"); BC_ASSERT_PTR_NOT_NULL(call); BC_ASSERT_TRUE(wait_for(mgr->lc, mgr->lc, &mgr->stat.number_of_LinphoneCallOutgoingInit, 1)); BC_ASSERT_TRUE(wait_for(mgr->lc, mgr->lc, &mgr->stat.number_of_LinphoneCallOutgoingProgress, 1)); BC_ASSERT_TRUE(wait_for(mgr->lc, mgr->lc, &mgr->stat.number_of_LinphoneCallOutgoingRinging, 1)); /*assert that the call never gets connected nor terminated*/ BC_ASSERT_FALSE(wait_for(mgr->lc, mgr->lc, &mgr->stat.number_of_LinphoneCallConnected, 1)); BC_ASSERT_EQUAL(mgr->stat.number_of_LinphoneCallEnd, 0, int, "%d"); BC_ASSERT_EQUAL(mgr->stat.number_of_LinphoneCallError, 0, int, "%d"); linphone_core_terminate_call(mgr->lc, call); BC_ASSERT_TRUE(wait_for(mgr->lc, mgr->lc, &mgr->stat.number_of_LinphoneCallEnd, 1)); BC_ASSERT_TRUE(wait_for(mgr->lc, mgr->lc, &mgr->stat.number_of_LinphoneCallReleased, 1)); pclose(sipp_out); } linphone_core_manager_destroy(mgr); }
void linphone_gtk_show_login_frame(LinphoneProxyConfig *cfg){ GtkWidget *mw=linphone_gtk_get_main_window(); GtkWidget *label=linphone_gtk_get_widget(mw,"login_label"); const LinphoneAuthInfo *ai; gchar *str; LinphoneAddress *from; LinphoneCore *lc=linphone_gtk_get_core(); int nettype; const char *passwd=NULL; if (linphone_core_get_download_bandwidth(lc)==512 && linphone_core_get_upload_bandwidth(lc)==512) nettype=NetworkKindOpticalFiber; else nettype=NetworkKindAdsl; gtk_combo_box_set_active(GTK_COMBO_BOX(linphone_gtk_get_widget(mw,"login_internet_kind")),nettype); gtk_combo_box_set_active(GTK_COMBO_BOX(linphone_gtk_get_widget(mw,"internet_kind")),nettype); if (linphone_gtk_get_ui_config_int("automatic_login",0) ){ g_timeout_add(250,(GSourceFunc)do_login_noprompt,cfg); return; } { const char *login_image=linphone_gtk_get_ui_config("login_image",NULL); if (login_image){ GdkPixbuf *pbuf=create_pixbuf (login_image); gtk_image_set_from_pixbuf (GTK_IMAGE(linphone_gtk_get_widget(mw,"login_image")), pbuf); g_object_unref(G_OBJECT(pbuf)); } } gtk_widget_hide(linphone_gtk_get_widget(mw,"disconnect_item")); gtk_widget_hide(linphone_gtk_get_widget(mw,"main_frame")); gtk_widget_show(linphone_gtk_get_widget(mw,"login_frame")); gtk_widget_set_sensitive(linphone_gtk_get_widget(mw,"main_menu"),FALSE); gtk_widget_set_sensitive(linphone_gtk_get_widget(mw,"options_menu"),FALSE); str=g_strdup_printf(_("Please enter login information for %s"),linphone_proxy_config_get_domain(cfg)); gtk_label_set_text(GTK_LABEL(label),str); g_object_set_data(G_OBJECT(mw),"login_proxy_config",cfg); g_free(str); from=linphone_address_new(linphone_proxy_config_get_identity(cfg)); if (linphone_address_get_username(from)[0]=='?'){ const char *username=linphone_gtk_get_ui_config ("login_username",NULL); if (username) linphone_address_set_username(from,username); } ai=linphone_core_find_auth_info(lc,linphone_proxy_config_get_domain(cfg),linphone_address_get_username(from)); /*display the last entered username, if not '?????'*/ if (linphone_address_get_username(from)[0]!='?') gtk_entry_set_text(GTK_ENTRY(linphone_gtk_get_widget(mw,"login_username")), linphone_address_get_username(from)); if (ai) passwd=linphone_auth_info_get_passwd(ai); gtk_entry_set_text(GTK_ENTRY(linphone_gtk_get_widget(mw,"login_password")), passwd!=NULL ? passwd : ""); linphone_address_destroy(from); }
void AddressAPI::setUsername(StringPtr const &username) { CORE_MUTEX FBLOG_DEBUG("AddressAPI::setUsername", "this=" << this << "\t" << "username=" << username); linphone_address_set_username(mAddress, STRING_TO_CHARPTR(username)); }