Ejemplo n.º 1
0
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);
}
StringPtr AuthInfoAPI::getPasswd() const {
	CORE_MUTEX
	
	FBLOG_DEBUG("AuthInfoAPI::getPasswd", "this=" << this);
	return CHARPTR_TO_STRING(linphone_auth_info_get_passwd(mAuthInfo));
}