示例#1
0
void linphone_gtk_set_in_conference(LinphoneCall *call){
	GtkWidget *mw=linphone_gtk_get_main_window();
	GtkWidget *participant=find_conferencee_from_call(call);
	
	if (participant==NULL){
		GtkWidget *tab=get_conference_tab(mw);
		const LinphoneAddress *addr=linphone_call_get_remote_address(call);
		participant=linphone_gtk_create_widget("main","callee_frame");
		GtkWidget *sound_meter;
		GtkWidget *viewswitch=linphone_gtk_get_widget(mw,"viewswitch");
		gchar *markup;
		if (linphone_address_get_display_name(addr)!=NULL){
			markup=g_strdup_printf("<b>%s</b>",linphone_address_get_display_name(addr));
		}else{
			char *tmp=linphone_address_as_string_uri_only(addr);
			markup=g_strdup_printf("%s",tmp);
			ms_free(tmp);
		}
		gtk_label_set_markup(GTK_LABEL(linphone_gtk_get_widget(participant,"callee_name_label")),markup);
		g_free(markup);
		sound_meter=linphone_gtk_get_widget(participant,"sound_indicator");
		linphone_gtk_init_audio_meter(sound_meter, (get_volume_t) linphone_call_get_play_volume, call);
		gtk_box_pack_start(GTK_BOX(tab),participant,FALSE,FALSE,PADDING_PIXELS);
		g_object_set_data_full(G_OBJECT(participant),"call",linphone_call_ref(call),(GDestroyNotify)linphone_call_unref);
		gtk_widget_show(participant);
		gtk_notebook_set_current_page(GTK_NOTEBOOK(viewswitch),
			                          gtk_notebook_page_num(GTK_NOTEBOOK(viewswitch),tab));
	}
}
示例#2
0
static int sip_login_do_login(SipSetupContext * ctx, const char *uri, const char *passwd){
	LinphoneProxyConfig *cfg=sip_setup_context_get_proxy_config(ctx);
	LinphoneCore *lc=linphone_proxy_config_get_core(cfg);
	LinphoneAuthInfo *auth;
	LinphoneAddress *parsed_uri;
	char *tmp;

	parsed_uri=linphone_address_new(uri);
	if (parsed_uri==NULL){
		return -1;
	}
	if (linphone_address_get_display_name(parsed_uri)!=NULL){
		guess_display_name(parsed_uri);
	}
	tmp=linphone_address_as_string(parsed_uri);
	linphone_proxy_config_set_identity(cfg,tmp);
	if (passwd ) {
		auth=linphone_auth_info_new(linphone_address_get_username(parsed_uri),NULL,passwd,NULL,NULL);
		linphone_core_add_auth_info(lc,auth);
	}
	linphone_proxy_config_enable_register(cfg,TRUE);
	linphone_proxy_config_done(cfg);
	ms_free(tmp);
	linphone_address_destroy(parsed_uri);
	ms_message("SipLogin: done");
	return 0;
}
示例#3
0
文件: friend.c 项目: 42p/linphone
void linphone_core_migrate_friends_from_rc_to_db(LinphoneCore *lc) {
	LpConfig *lpc = NULL;
	LinphoneFriend *lf = NULL;
	LinphoneFriendList *lfl = linphone_core_get_default_friend_list(lc);
	int i;
#ifndef SQLITE_STORAGE_ENABLED
	ms_warning("linphone has been compiled without sqlite, can't migrate friends");
	return;
#endif
	if (!lc) {
		return;
	}

	lpc = linphone_core_get_config(lc);
	if (!lpc) {
		ms_warning("this core has been started without a rc file, nothing to migrate");
		return;
	}
	if (lp_config_get_int(lpc, "misc", "friends_migration_done", 0) == 1) {
		ms_warning("the friends migration has already been done, skipping...");
		return;
	}

	if (bctbx_list_size(linphone_friend_list_get_friends(lfl)) > 0 && lfl->storage_id == 0) {
		linphone_core_remove_friend_list(lc, lfl);
		lfl = linphone_core_create_friend_list(lc);
		linphone_core_add_friend_list(lc, lfl);
		linphone_friend_list_unref(lfl);
	}

	for (i = 0; (lf = linphone_friend_new_from_config_file(lc, i)) != NULL; i++) {
		char friend_section[32];

		const LinphoneAddress *addr = linphone_friend_get_address(lf);
		if (addr) {
			const char *displayName = linphone_address_get_display_name(addr);
			char *address = NULL;
			if (!displayName) {
				displayName = linphone_address_get_username(addr);
			}

			address = linphone_address_as_string(addr);
			if (!linphone_friend_create_vcard(lf, displayName)) {
				ms_warning("Couldn't create vCard for friend %s", address);
			} else {
				linphone_vcard_add_sip_address(linphone_friend_get_vcard(lf), address);
			}
			ms_free(address);

			linphone_friend_list_add_friend(lfl, lf);
			linphone_friend_unref(lf);

			snprintf(friend_section, sizeof(friend_section), "friend_%i", i);
			lp_config_clean_section(lpc, friend_section);
		}
	}

	ms_debug("friends migration successful: %i friends migrated", i);
	lp_config_set_int(lpc, "misc", "friends_migration_done", 1);
}
QString AccountSettingsModel::displayName() const {
    if (!_proxyConfig) {
        return NULL;
    }
    const LinphoneAddress *addr = linphone_proxy_config_get_identity_address(_proxyConfig);
    return linphone_address_get_display_name(addr);
}
示例#5
0
const char* get_display_name(const LinphoneAddress *from){
	const char *display;
	display=linphone_address_get_display_name(from);
	if (display==NULL || display[0]=='\0') {
		display=linphone_address_get_username(from);
	}
	return display;
}
示例#6
0
void conferenceframe::set_in_conference(LinphoneCall *call)
{
	const LinphoneAddress *addr;
	QProgressBar *progressBar_speaker=NULL;
	QLabel *urilabel=NULL;
	sound_indicator* si;
	char *tmp;
	QString markup;
	int call_count=0;
	if(!call) return;
	if(_conferencealls.value(call)) return;
	call_count = _conferencealls.count();
	addr=linphone_call_get_remote_address(call);
	if (linphone_address_get_display_name(addr)!=NULL){
		markup.sprintf("<b>%s</b>",linphone_address_get_display_name(addr));
	}else{
		tmp=linphone_address_as_string_uri_only(addr);
		markup.sprintf("%s",tmp);
		ms_free(tmp);
	}
	si = new sound_indicator;
	/* 创建界面 */
	progressBar_speaker = new QProgressBar(this);
	progressBar_speaker->setStyleSheet("QProgressBar::chunk {background-color: grey;} QProgressBar{text-align: center;}");
	progressBar_speaker->setTextVisible(false);
	progressBar_speaker->setEnabled(true);
	progressBar_speaker->setValue(0);
	progressBar_speaker->setRange(0,100);
	QSizePolicy sizePolicy3(QSizePolicy::Expanding, QSizePolicy::Fixed);
	sizePolicy3.setHorizontalStretch(0);
	sizePolicy3.setVerticalStretch(0);
	sizePolicy3.setHeightForWidth(progressBar_speaker->sizePolicy().hasHeightForWidth());
	progressBar_speaker->setSizePolicy(sizePolicy3);
    progressBar_speaker->setAutoFillBackground(false);
	progressBar_speaker->setOrientation(Qt::Horizontal);
	progressBar_speaker->setInvertedAppearance(false);
	urilabel = new QLabel(this);
	urilabel->setText(markup);
	ui->gridLayout->addWidget(progressBar_speaker, call_count+1, 3, 1, 1);
	ui->gridLayout->addWidget(urilabel, call_count+1, 2, 1, 1);

	si->sound_meter = progressBar_speaker;
	si->speaker_last_value = 0;
	si->urilabel = urilabel;
	_conferencealls.insert(call, si);
}
示例#7
0
文件: friend.c 项目: 42p/linphone
const char * linphone_friend_get_name(const LinphoneFriend *lf) {
	if (lf && lf->vcard) {
		return linphone_vcard_get_full_name(lf->vcard);
	} else if (lf && lf->uri) {
		LinphoneAddress *fr = lf->uri;
		return linphone_address_get_display_name(fr);
	}
	return NULL;
}
示例#8
0
const char* GetDisplayNameFromLinphoneAddress(const LinphoneAddress *address)
{
    if (!address)
        return NULL;

    const char *displayName = linphone_address_get_display_name(address);
    if (!displayName)
        displayName = linphone_address_get_username(address);
    if (!displayName)
        displayName = linphone_address_as_string_uri_only(address);
    return displayName;
}
示例#9
0
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;
}
示例#10
0
static void display_peer_name_in_label(GtkWidget *label, const LinphoneAddress *from){
	const char *displayname=NULL;
	const char *id;
	char *uri_label;
	displayname=linphone_address_get_display_name(from);
	id=linphone_address_as_string_uri_only(from);
	
	if (displayname!=NULL){
		uri_label=g_markup_printf_escaped("<span size=\"large\">%s</span>\n<i>%s</i>", 
			displayname,id);
	}else
		uri_label=g_markup_printf_escaped("<span size=\"large\"><i>%s</i></span>\n",id);
	gtk_label_set_markup(GTK_LABEL(label),uri_label);
	g_free(uri_label);
}
示例#11
0
void linphone_gtk_call_log_update(GtkWidget *w){
	GtkTreeView *v=GTK_TREE_VIEW(linphone_gtk_get_widget(w,"logs_view"));
	GtkListStore *store;
	const MSList *logs;

	store=(GtkListStore*)gtk_tree_view_get_model(v);
	if (store==NULL){
		store=gtk_list_store_new(3,G_TYPE_STRING,G_TYPE_STRING, G_TYPE_POINTER);
		gtk_tree_view_set_model(v,GTK_TREE_MODEL(store));
		g_object_unref(G_OBJECT(store));
	}
	gtk_list_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;
		LinphoneAddress *la=cl->dir==LinphoneCallIncoming ? cl->from : cl->to;
		char *addr= linphone_address_as_string_uri_only (la);
		const char *display;
		gchar *logtxt;
		gchar quality[20];
		
		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 (cl->quality!=-1){
			snprintf(quality,sizeof(quality),"%.1f",cl->quality);
		}
		logtxt=g_markup_printf_escaped("<big><b>%s</b></big>\t<small><i>%s</i>\t<i>Quality: %s</i></small>\n"
		                               "%s\t%i minutes %i seconds\t",display, addr, cl->quality!=-1 ? quality : _("n/a"),
		                               cl->start_date,
		                               cl->duration/60,cl->duration%60);
		gtk_list_store_append (store,&iter);
		gtk_list_store_set (store,&iter,
		               0, cl->dir==LinphoneCallOutgoing ? GTK_STOCK_GO_UP : GTK_STOCK_GO_DOWN,
		               1, logtxt,2,la,-1);
		ms_free(addr);
		g_free(logtxt);
	}
	
}
示例#12
0
文件: friend.c 项目: 42p/linphone
bool_t linphone_friend_create_vcard(LinphoneFriend *fr, const char *name) {
	LinphoneVcard *vcard = NULL;
	const char *fullName = NULL;
	LinphoneAddress *addr = NULL;

	if (!fr || fr->vcard) {
		ms_error("Friend is either null or already has a vcard");
		return FALSE;
	}

	addr = fr->uri;
	if (!addr && !name) {
		ms_error("friend doesn't have an URI and name parameter is null");
		return FALSE;
	}

	if (name) {
		fullName = name;
	} else {
		const char *displayName = linphone_address_get_display_name(addr);
		if (!displayName) {
			fullName = linphone_address_get_username(addr);
		} else {
			fullName = displayName;
		}
	}

	if (!fullName) {
		ms_error("Couldn't determine the name to use for the vCard");
		return FALSE;
	}

	vcard = linphone_vcard_new();
	linphone_vcard_set_full_name(vcard, fullName);
	linphone_friend_set_vcard(fr, vcard);
	return TRUE;
}
示例#13
0
char *linphone_gtk_address(const LinphoneAddress *addr) {
    const char *displayname=linphone_address_get_display_name(addr);
    if (!displayname) return linphone_address_as_string_uri_only(addr);
    return ms_strdup(displayname);
}
示例#14
0
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);
	}
}
示例#15
0
const char * linphone_friend_get_name(const LinphoneFriend *lf) {
	LinphoneAddress *fr = lf->uri;
	if (fr == NULL) return NULL;
	return linphone_address_get_display_name(fr);
}
StringPtr AddressAPI::getDisplayName() const {
	CORE_MUTEX
	
	FBLOG_DEBUG("AddressAPI::getDisplayName", "this=" << this);
	return CHARPTR_TO_STRING(linphone_address_get_display_name(mAddress));
}