static LinphoneAccountCreatorStatus validate_uri(const char* username, const char* domain, const char* route, const char* display_name) { LinphoneAddress* addr; LinphoneAccountCreatorStatus status = LinphoneAccountCreatorOK; LinphoneProxyConfig* proxy = linphone_proxy_config_new(); linphone_proxy_config_set_identity(proxy, "sip:[email protected]"); if (route && linphone_proxy_config_set_route(proxy, route) != 0) { status = LinphoneAccountCreatorRouteInvalid; goto end; } if (username) { addr = linphone_proxy_config_normalize_sip_uri(proxy, username); } else { addr = linphone_address_clone(linphone_proxy_config_get_identity_address(proxy)); } if (addr == NULL) { status = LinphoneAccountCreatorUsernameInvalid; goto end; } if (domain && linphone_address_set_domain(addr, domain) != 0) { status = LinphoneAccountCreatorDomainInvalid; } if (display_name && (!strlen(display_name) || linphone_address_set_display_name(addr, display_name) != 0)) { status = LinphoneAccountCreatorDisplayNameInvalid; } linphone_address_unref(addr); end: linphone_proxy_config_destroy(proxy); return status; }
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; }
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); } }
int linphone_friend_set_name(LinphoneFriend *lf, const char *name){ LinphoneAddress *fr = lf->uri; LinphoneVcard *vcard = NULL; bool_t vcard_created = FALSE; vcard = lf->vcard; if (!vcard) { linphone_friend_create_vcard(lf, name); vcard = lf->vcard; vcard_created = TRUE; } if (vcard) { linphone_vcard_set_full_name(vcard, name); if (fr && vcard_created) { // SIP address wasn't set yet, let's do it char *address = linphone_address_as_string_uri_only(fr); linphone_vcard_edit_main_sip_address(vcard, address); ms_free(address); } } if (!fr && !vcard) { ms_warning("linphone_friend_set_address() must be called before linphone_friend_set_name() to be able to set display name."); return -1; } else if (fr) { linphone_address_set_display_name(fr, name); } return 0; }
static char *guess_contact_for_register(LinphoneProxyConfig *obj){ LinphoneAddress *proxy=linphone_address_new(obj->reg_proxy); char *ret=NULL; const char *host; if (proxy==NULL) return NULL; host=linphone_address_get_domain (proxy); if (host!=NULL){ LinphoneAddress *contact; char localip[LINPHONE_IPADDR_SIZE]; LCSipTransports tr; linphone_core_get_local_ip(obj->lc,host,localip); contact=linphone_address_new(obj->reg_identity); linphone_address_set_domain (contact,localip); linphone_address_set_port_int(contact,linphone_core_get_sip_port(obj->lc)); linphone_address_set_display_name(contact,NULL); linphone_core_get_sip_transports(obj->lc,&tr); if (tr.udp_port <= 0) { if (tr.tcp_port>0) { sal_address_set_param(contact,"transport","tcp"); } else if (tr.tls_port>0) { sal_address_set_param(contact,"transport","tls"); } } ret=linphone_address_as_string(contact); linphone_address_destroy(contact); } linphone_address_destroy (proxy); return ret; }
static LinphoneAccountCreatorStatus validate_uri(const char* username, const char* domain, const char* route, const char* display_name) { LinphoneProxyConfig* proxy = linphone_proxy_config_new(); LinphoneAddress* addr; linphone_proxy_config_set_identity(proxy, "sip:[email protected]"); if (route && linphone_proxy_config_set_route(proxy, route) != 0) { linphone_proxy_config_destroy(proxy); return LinphoneAccountCreatorRouteInvalid; } if (username) { addr = linphone_proxy_config_normalize_sip_uri(proxy, username); } else { addr = linphone_address_clone(linphone_proxy_config_get_identity_address(proxy)); } linphone_proxy_config_destroy(proxy); if (addr == NULL) { return LinphoneAccountCreatorUsernameInvalid; } if (domain) { ms_error("TODO: detect invalid domain"); linphone_address_set_domain(addr, domain); } if (display_name) { ms_error("TODO: detect invalid display name"); linphone_address_set_display_name(addr, display_name); } linphone_address_unref(addr); return LinphoneAccountCreatorOk; }
LinphoneProxyConfig * linphone_account_creator_configure(const LinphoneAccountCreator *creator) { LinphoneAuthInfo *info; LinphoneProxyConfig *cfg = linphone_core_create_proxy_config(creator->core); char *identity_str = _get_identity(creator); LinphoneAddress *identity = linphone_address_new(identity_str); char *route = NULL; char *domain = NULL; ms_free(identity_str); if (creator->display_name) { linphone_address_set_display_name(identity, creator->display_name); } if (creator->route) { route = ms_strdup_printf("%s;transport=%s", creator->route, linphone_transport_to_string(creator->transport)); } if (creator->domain) { domain = ms_strdup_printf("%s;transport=%s", creator->domain, linphone_transport_to_string(creator->transport)); } linphone_proxy_config_set_identity_address(cfg, identity); linphone_proxy_config_set_server_addr(cfg, domain); linphone_proxy_config_set_route(cfg, route); linphone_proxy_config_enable_publish(cfg, FALSE); linphone_proxy_config_enable_register(cfg, TRUE); if (strcmp(creator->domain, "sip.linphone.org") == 0) { linphone_proxy_config_enable_avpf(cfg, TRUE); // If account created on sip.linphone.org, we configure linphone to use TLS by default if (linphone_core_sip_transport_supported(creator->core, LinphoneTransportTls)) { LinphoneAddress *addr = linphone_address_new(linphone_proxy_config_get_server_addr(cfg)); char *tmp; linphone_address_set_transport(addr, LinphoneTransportTls); tmp = linphone_address_as_string(addr); linphone_proxy_config_set_server_addr(cfg, tmp); linphone_proxy_config_set_route(cfg, tmp); ms_free(tmp); linphone_address_destroy(addr); } linphone_core_set_stun_server(creator->core, "stun.linphone.org"); linphone_core_set_firewall_policy(creator->core, LinphonePolicyUseIce); } info = linphone_auth_info_new(linphone_address_get_username(identity), // username NULL, //user id creator->password, // passwd creator->password ? NULL : creator->ha1, // ha1 !creator->password && creator->ha1 ? linphone_address_get_domain(identity) : NULL, // realm - assumed to be domain linphone_address_get_domain(identity) // domain ); linphone_core_add_auth_info(creator->core, info); linphone_address_destroy(identity); if (linphone_core_add_proxy_config(creator->core, cfg) != -1) { linphone_core_set_default_proxy(creator->core, cfg); return cfg; } linphone_core_remove_auth_info(creator->core, info); linphone_proxy_config_unref(cfg); return NULL; }
int linphone_friend_set_name(LinphoneFriend *lf, const char *name){ LinphoneAddress *fr=lf->uri; if (fr==NULL){ ms_error("linphone_friend_set_sip_addr() must be called before linphone_friend_set_name()."); return -1; } linphone_address_set_display_name(fr,name); return 0; }
void AccountSettingsModel::setDisplayName(const QString& displayName) { if (!_proxyConfig) { return; } const char *identity = linphone_proxy_config_get_identity(_proxyConfig); LinphoneAddress *addr = linphone_core_create_address(LinphoneManager::getInstance()->getLc(), identity); linphone_address_set_display_name(addr, displayName.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 guess_display_name(LinphoneAddress *from){ char *dn=(char*)ms_malloc(strlen(linphone_address_get_username(from))+3); const char *it; char *wptr=dn; bool_t begin=TRUE; bool_t surname=0; for(it=linphone_address_get_username(from);*it!='\0';++it){ if (begin){ *wptr=toupper(*it); begin=FALSE; }else if (*it=='.'){ if (surname) break; *wptr=' '; begin=TRUE; surname=TRUE; }else *wptr=*it; wptr++; } linphone_address_set_display_name(from,dn); ms_free(dn); }
void linphone_gtk_call_log_update(GtkWidget *w){ GtkTreeView *v=GTK_TREE_VIEW(linphone_gtk_get_widget(w,"logs_view")); GtkTreeStore *store; const MSList *logs; GtkTreeSelection *select; GtkWidget *notebook=linphone_gtk_get_widget(w,"viewswitch"); gint nb; store=(GtkTreeStore*)gtk_tree_view_get_model(v); if (store==NULL){ store=gtk_tree_store_new(3,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_POINTER,G_TYPE_STRING); gtk_tree_view_set_model(v,GTK_TREE_MODEL(store)); g_object_unref(G_OBJECT(store)); fill_renderers(GTK_TREE_VIEW(linphone_gtk_get_widget(w,"logs_view"))); select=gtk_tree_view_get_selection(v); gtk_tree_selection_set_mode(select, GTK_SELECTION_SINGLE); g_signal_connect_swapped(G_OBJECT(select),"changed",(GCallback)call_log_selection_changed,v); g_signal_connect(G_OBJECT(notebook),"focus-tab",(GCallback)linphone_gtk_call_log_reset_missed_call,NULL); g_signal_connect(G_OBJECT(v),"button-press-event",(GCallback)linphone_gtk_call_log_button_pressed,NULL); } nb=linphone_core_get_missed_calls_count(linphone_gtk_get_core()); if(nb > 0) linphone_gtk_call_log_display_missed_call(nb); gtk_tree_store_clear (store); for (logs=linphone_core_get_call_logs(linphone_gtk_get_core());logs!=NULL;logs=logs->next){ LinphoneCallLog *cl=(LinphoneCallLog*)logs->data; GtkTreeIter iter, iter2; LinphoneAddress *la=linphone_call_log_get_dir(cl)==LinphoneCallIncoming ? linphone_call_log_get_from(cl) : linphone_call_log_get_to(cl); char *addr= linphone_address_as_string(la); const char *display; gchar *logtxt, *headtxt, *minutes, *seconds; gchar quality[20]; const char *status=NULL; gchar *start_date=NULL; LinphoneFriend *lf=NULL; int duration=linphone_call_log_get_duration(cl); time_t start_date_time=linphone_call_log_get_start_date(cl); const gchar *call_status_icon_name; #if GLIB_CHECK_VERSION(2,30,0) // The g_date_time_format function exists since 2.26.0 but the '%c' format is only supported since 2.30.0 if (start_date_time){ GDateTime *dt=g_date_time_new_from_unix_local(start_date_time); start_date=g_date_time_format(dt,"%c"); g_date_time_unref(dt); } #else start_date=g_strdup(ctime(&start_date_time)); if (start_date[strlen(start_date) - 1] == '\n') { start_date[strlen(start_date) - 1] = '\0'; } #endif lf=linphone_core_get_friend_by_address(linphone_gtk_get_core(),addr); if(lf != NULL){ /*update display name from friend*/ display = linphone_friend_get_name(lf); if (display != NULL) linphone_address_set_display_name(la, display); } else { display=linphone_address_get_display_name(la); } if (display==NULL){ display=linphone_address_get_username (la); if (display==NULL){ display=linphone_address_get_domain (la); } } if (linphone_call_log_get_quality(cl)!=-1){ snprintf(quality,sizeof(quality),"%.1f",linphone_call_log_get_quality(cl)); }else snprintf(quality,sizeof(quality)-1,"%s",_("n/a")); switch(linphone_call_log_get_status(cl)){ case LinphoneCallAborted: status=_("Aborted"); break; case LinphoneCallMissed: status=_("Missed"); break; case LinphoneCallDeclined: status=_("Declined"); break; default: break; } minutes=g_markup_printf_escaped( ngettext("%i minute", "%i minutes", duration/60), duration/60); seconds=g_markup_printf_escaped( ngettext("%i second", "%i seconds", duration%60), duration%60); if (status==NULL) { headtxt=g_markup_printf_escaped("<big><b>%s</b></big>\t%s",display,start_date ? start_date : ""); logtxt=g_markup_printf_escaped( _("<small><i>%s</i>\t" "<i>Quality: %s</i></small>\n%s\t%s\t"), addr, quality, minutes, seconds); } else { headtxt=g_markup_printf_escaped(_("<big><b>%s</b></big>\t%s"),display,start_date ? start_date : ""); logtxt=g_markup_printf_escaped( "<small><i>%s</i></small>\t" "\n%s",addr, status); } g_free(minutes); g_free(seconds); if (start_date) g_free(start_date); gtk_tree_store_append (store,&iter,NULL); call_status_icon_name = linphone_call_log_get_dir(cl) == LinphoneCallOutgoing ? "linphone-call-status-outgoing" : "linphone-call-status-incoming"; gtk_tree_store_set (store,&iter, 0, call_status_icon_name, 1, headtxt,2,cl,-1); gtk_tree_store_append (store,&iter2,&iter); gtk_tree_store_set (store,&iter2,1,logtxt,-1); ms_free(addr); g_free(logtxt); g_free(headtxt); } }
void AddressAPI::setDisplayName(StringPtr const &displayname) { CORE_MUTEX FBLOG_DEBUG("AddressAPI::setDisplayName", "this=" << this << "\t" << "displayname=" << displayname); linphone_address_set_display_name(mAddress, STRING_TO_CHARPTR(displayname)); }