diff --git a/vpn-daemons/pptp/auth-dialog-general/chap-auth-module.c b/vpn-daemons/pptp/auth-dialog-general/chap-auth-module.c index e1d2f85a70..9512d71f83 100644 --- a/vpn-daemons/pptp/auth-dialog-general/chap-auth-module.c +++ b/vpn-daemons/pptp/auth-dialog-general/chap-auth-module.c @@ -25,8 +25,8 @@ struct _GnomeGenericAuthModuleImpl { }; #define GLADE_FILE "nm-ppp-auth.glade" -//#define GLADE_WIDGET "auth-chap-widget" -#define GLADE_WIDGET "table1" +#define GLADE_WIDGET "auth-chap-widget" +//#define GLADE_WIDGET "table1" #define AUTH_TYPE "CHAP" #define AUTH_TYPE_DISPLAY_NAME "CHAP Version 1" @@ -34,8 +34,8 @@ struct _GnomeGenericAuthModuleImpl { static void entry_changed (GtkWidget *widget,gpointer data) { - GnomeGenericAuthModuleImpl *impl = (GnomeGenericAuthModuleImpl *) data; - g_warning("Entry: %s",gtk_entry_get_text(GTK_ENTRY(widget))); +// GnomeGenericAuthModuleImpl *impl = (GnomeGenericAuthModuleImpl *) data; + g_warning("Entry: %s (%s)",gtk_entry_get_text(GTK_ENTRY(widget)), gtk_widget_get_name(widget)); } static void @@ -47,11 +47,11 @@ GtkWidget *w; g_warning("Clearing widget"); gtk_entry_set_text(impl->w_username,""); gtk_entry_set_text(impl->w_password,""); -// gtk_widget_grab_focus (GTK_WIDGET(impl->w_username)); -g_warning("Username %s", GTK_WIDGET_CAN_FOCUS(impl->widget) ? "Can focus" : "Can't focus" ); -g_warning("Username %s", GTK_WIDGET_VISIBLE(impl->widget) ? "Is visible" : "Is not visible"); -g_warning("Username %s", GTK_WIDGET_SENSITIVE(impl->widget) ? "Is sensitive" : "Is not sensitive"); - g_warning("Widget: %s",gtk_widget_get_name(impl->widget)); + gtk_widget_grab_focus (GTK_WIDGET(impl->w_username)); +//g_warning("Username %s", GTK_WIDGET_CAN_FOCUS(impl->w_username) ? "Can focus" : "Can't focus" ); +//g_warning("Username %s", GTK_WIDGET_VISIBLE(impl->w_username) ? "Is visible" : "Is not visible"); +//g_warning("Username %s", GTK_WIDGET_SENSITIVE(impl->w_username) ? "Is sensitive" : "Is not sensitive"); +//g_warning("Widget: %s",gtk_widget_get_name(impl->widget)); impl->w_username = GTK_ENTRY(glade_xml_get_widget(impl->xml, "username")); g_signal_connect (impl->w_username, "changed", G_CALLBACK (entry_changed), impl); // gtk_widget_grab_focus (GTK_WIDGET(impl->w_username)); @@ -98,7 +98,6 @@ impl_set_secret (GnomeGenericAuthModule *self, const char *object, const char *s { GnomeGenericAuthModuleImpl *impl = (GnomeGenericAuthModuleImpl *) self->data; -g_warning("Setting secret: %s=%s",object,secret); if (strcmp(object,"password")==0) { gtk_entry_set_text(impl->w_password,secret); } else { @@ -150,8 +149,9 @@ impl_get_object (void) { char *glade_file; GnomeGenericAuthModuleImpl *impl; - GtkWidget *w; +// GtkWidget *w; +g_warning("get widget"); impl = g_new0 (GnomeGenericAuthModuleImpl, 1); glade_file = g_strdup_printf ("%s/%s", GLADEDIR, GLADE_FILE); impl->xml = glade_xml_new (glade_file, NULL, GETTEXT_PACKAGE); @@ -166,7 +166,6 @@ impl_get_object (void) impl->w_username = GTK_ENTRY(glade_xml_get_widget(impl->xml,"username")); impl->w_password = GTK_ENTRY(glade_xml_get_widget(impl->xml,"password")); - g_signal_connect (impl->w_username, "activate", G_CALLBACK (goto_next), impl); g_signal_connect (impl->w_password, "activate", G_CALLBACK (goto_next), impl); diff --git a/vpn-daemons/pptp/auth-dialog-general/gnome-generic-auth-dialog.c b/vpn-daemons/pptp/auth-dialog-general/gnome-generic-auth-dialog.c index 2a1437edb2..6116666e3a 100644 --- a/vpn-daemons/pptp/auth-dialog-general/gnome-generic-auth-dialog.c +++ b/vpn-daemons/pptp/auth-dialog-general/gnome-generic-auth-dialog.c @@ -67,6 +67,7 @@ struct GnomeGenericAuthDialogDetails GtkWidget *current_widget; GtkWidget *widget_holder; + GtkWidget *current_widget_old_parent; GtkComboBox *auth_type_combo; @@ -96,8 +97,8 @@ static void gnome_generic_auth_dialog_finalize (GObject * /* GtkDialog callbacks */ -static void dialog_show_callback (GtkWidget *widget, - gpointer callback_data); +//static void dialog_show_callback (GtkWidget *widget, +// gpointer callback_data); static void dialog_close_callback (GtkWidget *widget, gpointer callback_data); @@ -220,7 +221,7 @@ load_all_modules (GnomeGenericAuthDialog *dialog) while ((f = g_dir_read_name (dir)) != NULL) { char *so_path; - GKeyFile *keyfile; +// GKeyFile *keyfile; if (!g_str_has_suffix (f, ".so")) continue; @@ -277,9 +278,49 @@ gnome_generic_auth_dialog_finalize (GObject *object) (* G_OBJECT_CLASS (parent_class)->finalize) (object); } -static void -dialog_close_callback (GtkWidget *widget, gpointer callback_data) +static void auth_widget_reparent(GnomeGenericAuthDialog *dialog, GtkWidget *new_parent) { + if (dialog->details->current_widget==NULL) { + if (dialog->details->current_widget_old_parent!=NULL) { + g_error("parent previously was not restored to widget"); + } + return; + } + if ((new_parent==NULL) && (dialog->details->current_widget_old_parent==NULL)) { + return; + } else if (new_parent==NULL) { + gtk_widget_reparent(dialog->details->current_widget,dialog->details->current_widget_old_parent); + dialog->details->current_widget_old_parent=NULL; + return; + } else if (dialog->details->current_widget_old_parent==NULL) { + dialog->details->current_widget_old_parent=gtk_widget_get_parent(dialog->details->current_widget); + } + + gtk_widget_reparent(dialog->details->current_widget,new_parent); +} + +static void auth_widget_get_current(GnomeGenericAuthDialog *dialog) +{ + GSList *auth_modules; + + if (dialog->details->current_widget!=NULL) { + auth_widget_reparent(dialog,NULL); + dialog->details->current_widget=NULL; + } + + auth_modules=dialog->details->auth_modules; + + if (dialog->details->current_module != NULL) { + dialog->details->current_widget = dialog->details->current_module->get_widget (dialog->details->current_module); + } +} + +static void +dialog_close_callback (GtkWidget *widget, gpointer user_data) +{ + GnomeGenericAuthDialog *dialog = (GnomeGenericAuthDialog *) user_data; + + auth_widget_reparent(dialog,NULL); gtk_widget_hide (widget); } @@ -287,13 +328,12 @@ static void auth_type_changed_callback (GtkWidget *widget, gpointer user_data) { GnomeGenericAuthDialog *dialog = (GnomeGenericAuthDialog *) user_data; - GnomeGenericAuthModule *module; GList *i; GList *children; GtkWidget *w; GSList *auth_modules; GtkWidget *widget_holder; - GtkWidget *widget_holder_parent; +// GtkWidget *widget_holder_parent; GtkComboBox *auth_type_combo; auth_modules=dialog->details->auth_modules; @@ -303,51 +343,20 @@ auth_type_changed_callback (GtkWidget *widget, gpointer user_data) g_return_if_fail(widget_holder!=NULL); g_return_if_fail(GTK_IS_CONTAINER(widget_holder)); -// g_object_ref (G_OBJECT (widget_holder)); - if (dialog->details->current_widget!=NULL) { - gtk_widget_hide_all(dialog->details->current_widget); - /* remove existing VPN widget */ - children = gtk_container_get_children (GTK_CONTAINER (widget_holder)); - for (i = children; i != NULL; i = g_list_next (i)) { - w = GTK_WIDGET (i->data); - g_object_ref (G_OBJECT (w)); - gtk_widget_hide_all (w); - gtk_container_remove (GTK_CONTAINER (widget_holder), w); - } - g_list_free (children); - } + auth_widget_reparent(dialog,NULL); /* show appropriate child */ - module = (GnomeGenericAuthModule *) + dialog->details->current_module = (GnomeGenericAuthModule *) g_slist_nth_data (auth_modules, gtk_combo_box_get_active (GTK_COMBO_BOX(auth_type_combo))); - if (module == NULL) return; + if (dialog->details->current_module == NULL) return; - w = module->get_widget (module); - if (w != NULL) { - GtkWidget *old_parent; - gtk_widget_ref (w); - gtk_widget_hide_all (w); - old_parent = gtk_widget_get_parent (w); - if (old_parent != NULL) - gtk_container_remove (GTK_CONTAINER (old_parent), w); - gtk_container_add (GTK_CONTAINER (widget_holder), w); - gtk_widget_unref (w); + auth_widget_get_current(dialog); + auth_widget_reparent(dialog,dialog->details->widget_holder); - gtk_widget_show_all (w); - gtk_widget_grab_focus (w); - } - - dialog->details->current_module=module; - dialog->details->current_widget=w; -// widget_holder_parent = gtk_widget_get_parent (widget_holder); -// if (widget_holder_parent != NULL) -// gtk_container_resize_children (GTK_CONTAINER (widget_holder_parent)); -// gtk_container_resize_children (GTK_CONTAINER (widget_holder)); -// gtk_container_resize_children (GTK_CONTAINER (dialog)); -// g_object_unref (G_OBJECT (widget_holder)); - -// vpn_ui->set_validity_changed_callback (vpn_ui, vpn_druid_vpn_validity_changed, NULL); +// dialog->details->current_module->set_validity_changed_callback ( +// dialog->details->current_module, +// auth_widget_validity_changed, NULL); } gboolean @@ -678,7 +687,6 @@ gnome_generic_auth_dialog_lookup_in_keyring (GnomeGenericAuthDialog *dialog) { for (item = keyring_result; item != NULL; item=g_list_next(item)) { data = (GnomeKeyringNetworkPasswordData *)item->data; if (strcmp(data->authtype,first_auth_type)==0) { -g_warning("Setting: '%s' '%s' '%s' '%s' '%d' '%s' '%s'",data->user,data->server,data->domain,data->protocol,data->port,data->object,data->password); if (data->user!=NULL) gnome_generic_auth_dialog_set_user(dialog, data->user); if (data->server!=NULL) gnome_generic_auth_dialog_set_server(dialog, data->server); if (data->domain!=NULL) gnome_generic_auth_dialog_set_domain(dialog, data->domain); @@ -745,7 +753,6 @@ gnome_generic_auth_dialog_new (const char *dialog_title, load_all_modules(dialog); - if (dialog->details->auth_modules==NULL) { g_warning("gnome-generic-auth-dialog: Cannot find any authentication modules!"); g_free(dialog); @@ -844,7 +851,7 @@ gnome_generic_auth_dialog_new (const char *dialog_title, TRUE, /* fill */ 0); /* padding */ - gtk_widget_show_all (GTK_DIALOG (dialog)->vbox); + gtk_widget_show (GTK_DIALOG (dialog)->vbox); dialog->details->remember_session_button = gtk_check_button_new_with_mnemonic (_("_Remember for this session")); @@ -876,6 +883,7 @@ gnome_generic_auth_dialog_run_and_block (GnomeGenericAuthDialog *dialog) save_to_keyring_as_needed(dialog); + auth_widget_reparent(dialog,NULL); gtk_widget_hide (GTK_WIDGET (dialog)); return button_clicked == GTK_RESPONSE_OK; diff --git a/vpn-daemons/pptp/auth-dialog-general/main.c b/vpn-daemons/pptp/auth-dialog-general/main.c index bc73e7e352..112b171d49 100644 --- a/vpn-daemons/pptp/auth-dialog-general/main.c +++ b/vpn-daemons/pptp/auth-dialog-general/main.c @@ -33,36 +33,13 @@ #define SERVICE_NAME "org.freedesktop.NetworkManager.ppp_starter" -static void save_auth_info (const char *connection_name, const char *service_name, const char *keyring, - const char *auth_type, const char *username, const char *password) -{ - guint32 item_id; - GnomeKeyringResult keyring_result; - - keyring_result = gnome_keyring_set_network_password_sync (keyring, - username, - NULL, - connection_name, - "password", - service_name, - auth_type, - 0, - password, - &item_id); - if (keyring_result != GNOME_KEYRING_RESULT_OK) - { - g_warning ("Couldn't store authentication information in keyring, code %d", (int) keyring_result); - } - -} - static GSList * get_passwords (const char *connection_name, const char *service_name, gboolean retry) { GSList *result; char *prompt; GnomeGenericAuthDialog *dialog; - GnomeGenericAuthDialogRemember remember; +// GnomeGenericAuthDialogRemember remember; result = NULL; @@ -95,27 +72,20 @@ get_passwords (const char *connection_name, const char *service_name, gboolean r GSList *secrets; GSList *item; const char *username; - char *password; +// char *password; const char *auth_type; username = gnome_generic_auth_dialog_get_user (dialog); - secrets = gnome_generic_auth_dialog_get_secrets (dialog); auth_type = gnome_generic_auth_dialog_get_auth_type (dialog); -// DEBUG: Force auth_type, username, password -// result = g_slist_append (result, g_strdup("CHAP")); -// result = g_slist_append (result, g_strdup("username")); -// result = g_slist_append (result, g_strdup("password")); + secrets = gnome_generic_auth_dialog_get_secrets (dialog); result = g_slist_append (result, g_strdup(auth_type)); -g_warning("Secret: %s",auth_type); result = g_slist_append (result, g_strdup(username)); -g_warning("Secret: %s",username); for (item=secrets; item!=NULL; item=g_slist_next(item)) { g_free(item->data); item = g_slist_next(item); -g_warning("Secret: %s",(char *)item->data); result = g_slist_append (result, item->data); } g_slist_free(secrets); diff --git a/vpn-daemons/pptp/auth-dialog-general/mschapv2-auth-module.c b/vpn-daemons/pptp/auth-dialog-general/mschapv2-auth-module.c index 021b6285e9..cd57da4cfd 100644 --- a/vpn-daemons/pptp/auth-dialog-general/mschapv2-auth-module.c +++ b/vpn-daemons/pptp/auth-dialog-general/mschapv2-auth-module.c @@ -133,7 +133,7 @@ impl_get_object (void) { char *glade_file; GnomeGenericAuthModuleImpl *impl; - GtkWidget *w; +// GtkWidget *w; impl = g_new0 (GnomeGenericAuthModuleImpl, 1); glade_file = g_strdup_printf ("%s/%s", GLADEDIR, GLADE_FILE); diff --git a/vpn-daemons/pptp/auth-dialog-general/nm-ppp-auth.glade b/vpn-daemons/pptp/auth-dialog-general/nm-ppp-auth.glade index 4e7efe9d1f..6386ae3a0b 100644 --- a/vpn-daemons/pptp/auth-dialog-general/nm-ppp-auth.glade +++ b/vpn-daemons/pptp/auth-dialog-general/nm-ppp-auth.glade @@ -136,6 +136,7 @@ Please select an appropriate authentication type and provide the necessary crede 0.5 0 0 + auth-type 0 @@ -147,6 +148,7 @@ Please select an appropriate authentication type and provide the necessary crede True + True 0