From 9b1f4e133bc79b2cac6cf342972c713739b075a6 Mon Sep 17 00:00:00 2001 From: Chris Toshok Date: Fri, 25 Jan 2002 04:22:58 +0000 Subject: [ fixes bug 16097 ] gui love for the new auth stuff. 2002-01-24 Chris Toshok [ fixes bug 16097 ] * gui/component/addressbook-config.glade: gui love for the new auth stuff. * gui/component/addressbook.c (load_uri_cb): track change to auth, and offer up different prompt strings depending on which method (binddn or email) we're using. * gui/component/addressbook-storage.c (ldap_unparse_auth): use the new auth types for ldap. (ldap_parse_auth): same. (addressbook_storage_auth_type_to_string): new function. (load_source_data): get the binddn too. (ldap_source_foreach): store out binddn or emailaddr, depending on the auth type chosen. * gui/component/addressbook-storage.h: add the more detailed auth types, add "binddn" to the source structure, and add a prototype for addressbook_storage_auth_type_to_string. * gui/component/addressbook-config.c (auth_checkbutton_changed): set the auth stuff (in)sensitive. (auth_optionmenu_activated): new function. (addressbook_source_dialog_set_source): track UI change. (addressbook_source_dialog_get_source): same. (add_scope_activate_cb): rename add_activate_cb to this to distinguish it from the auth stuff. (add_auth_activate_cb): new function. (addressbook_source_dialog): track change to auth UI stuff. (addressbook_storage_auth_type_to_string): new function. * backend/ebook/e-book.h: add auth_method arg to e_book_authenticate_user. * backend/ebook/e-book.c (e_book_authenticate_user): track change to prototype - add auth_method arg, and pass it along to the CORBA call. * backend/ebook/test-client.c (book_open_cb): track api change - keep this building. * backend/pas/pas-book.h: add auth_method slot in PASRequest. * backend/pas/pas-book.c (pas_book_queue_authenticate_user): add auth_method arg and add it to the PASRequest. (impl_GNOME_Evolution_Addressbook_Book_authenticateUser): track idl change, add auth_method and pass it along to pas_book_queue_authenticate_user. * backend/pas/pas-backend-ldap.c (pas_backend_ldap_process_authenticate_user): support both "ldap/simple-email" and "ldap/simple-binddn" auth methods. * backend/idl/addressbook.idl: add "in string authMethod" to authenticateUser. svn path=/trunk/; revision=15467 --- addressbook/gui/component/addressbook-config.c | 79 +++-- addressbook/gui/component/addressbook-config.glade | 322 +++++++++++++++++---- addressbook/gui/component/addressbook.c | 20 +- 3 files changed, 340 insertions(+), 81 deletions(-) (limited to 'addressbook/gui') diff --git a/addressbook/gui/component/addressbook-config.c b/addressbook/gui/component/addressbook-config.c index 33feb391ab..5061e6368b 100644 --- a/addressbook/gui/component/addressbook-config.c +++ b/addressbook/gui/component/addressbook-config.c @@ -29,15 +29,19 @@ struct _AddressbookSourceDialog { GtkWidget *name; GtkWidget *host; + + GtkWidget *auth_checkbutton; + GtkWidget *auth_optionmenu; + GtkWidget *auth_notebook; GtkWidget *email; - GtkWidget *email_label; + GtkWidget *binddn; + int auth; GtkWidget *port; GtkWidget *rootdn; GtkWidget *limit; GtkWidget *scope_optionmenu; AddressbookLDAPScopeType ldap_scope; - GtkWidget *auth_checkbutton; gint id; /* button we closed the dialog with */ @@ -83,14 +87,14 @@ auth_checkbutton_changed (GtkWidget *item, AddressbookSourceDialog *dialog) /* make sure the change is reflected by the state of the dialog's OK button */ addressbook_source_edit_changed (item, dialog); - gtk_widget_set_sensitive (dialog->email_label, + gtk_widget_set_sensitive (dialog->auth_optionmenu, + gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(dialog->auth_checkbutton))); + gtk_widget_set_sensitive (dialog->auth_notebook, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(dialog->auth_checkbutton))); - gtk_entry_set_editable (GTK_ENTRY(dialog->email), - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(dialog->auth_checkbutton))); } static void -option_menuitem_activated (GtkWidget *item, AddressbookSourceDialog *dialog) +scope_optionmenu_activated (GtkWidget *item, AddressbookSourceDialog *dialog) { /* make sure the change is reflected by the state of the dialog's OK button */ addressbook_source_edit_changed (item, dialog); @@ -99,6 +103,18 @@ option_menuitem_activated (GtkWidget *item, AddressbookSourceDialog *dialog) item); } +static void +auth_optionmenu_activated (GtkWidget *item, AddressbookSourceDialog *dialog) +{ + /* make sure the change is reflected by the state of the dialog's OK button */ + addressbook_source_edit_changed (item, dialog); + + dialog->auth = g_list_index (gtk_container_children (GTK_CONTAINER (item->parent)), + item) + 1; + + gtk_notebook_set_page (GTK_NOTEBOOK(dialog->auth_notebook), dialog->auth - 1); +} + typedef struct { GtkWidget *notebook; int page_num; @@ -132,18 +148,24 @@ addressbook_source_dialog_set_source (AddressbookSourceDialog *dialog, Addressbo e_utf8_gtk_entry_set_text (GTK_ENTRY (dialog->name), source ? source->name : ""); e_utf8_gtk_entry_set_text (GTK_ENTRY (dialog->host), source ? source->host : ""); e_utf8_gtk_entry_set_text (GTK_ENTRY (dialog->email), source ? source->email_addr : ""); + e_utf8_gtk_entry_set_text (GTK_ENTRY (dialog->binddn), source ? source->binddn : ""); e_utf8_gtk_entry_set_text (GTK_ENTRY (dialog->port), source ? source->port : "389"); e_utf8_gtk_entry_set_text (GTK_ENTRY (dialog->rootdn), source ? source->rootdn : ""); + string = g_strdup_printf ("%d", source ? source->limit : 100); e_utf8_gtk_entry_set_text (GTK_ENTRY (dialog->limit), string); g_free (string); - gtk_option_menu_set_history (GTK_OPTION_MENU(dialog->scope_optionmenu), source ? source->scope : ADDRESSBOOK_LDAP_SCOPE_ONELEVEL); + dialog->auth = source ? source->auth : ADDRESSBOOK_LDAP_AUTH_NONE; + if (dialog->auth != ADDRESSBOOK_LDAP_AUTH_NONE) + gtk_option_menu_set_history (GTK_OPTION_MENU(dialog->auth_optionmenu), dialog->auth - 1); + dialog->ldap_scope = source ? source->scope : ADDRESSBOOK_LDAP_SCOPE_ONELEVEL; + gtk_option_menu_set_history (GTK_OPTION_MENU(dialog->scope_optionmenu), dialog->ldap_scope); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(dialog->auth_checkbutton), source && source->auth == ADDRESSBOOK_LDAP_AUTH_SIMPLE); - gtk_widget_set_sensitive (dialog->email_label, source && source->auth == ADDRESSBOOK_LDAP_AUTH_SIMPLE); - gtk_entry_set_editable (GTK_ENTRY(dialog->email), source && source->auth == ADDRESSBOOK_LDAP_AUTH_SIMPLE); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(dialog->auth_checkbutton), source && source->auth != ADDRESSBOOK_LDAP_AUTH_NONE); + gtk_widget_set_sensitive (dialog->auth_optionmenu, source && source->auth != ADDRESSBOOK_LDAP_AUTH_NONE); + gtk_widget_set_sensitive (dialog->auth_notebook, source && source->auth != ADDRESSBOOK_LDAP_AUTH_NONE); } static AddressbookSource * @@ -154,12 +176,12 @@ addressbook_source_dialog_get_source (AddressbookSourceDialog *dialog) source->name = e_utf8_gtk_entry_get_text (GTK_ENTRY (dialog->name)); source->host = e_utf8_gtk_entry_get_text (GTK_ENTRY (dialog->host)); source->email_addr = e_utf8_gtk_entry_get_text (GTK_ENTRY (dialog->email)); + source->binddn = e_utf8_gtk_entry_get_text (GTK_ENTRY (dialog->binddn)); source->port = e_utf8_gtk_entry_get_text (GTK_ENTRY (dialog->port)); source->rootdn = e_utf8_gtk_entry_get_text (GTK_ENTRY (dialog->rootdn)); source->limit = atoi(e_utf8_gtk_entry_get_text (GTK_ENTRY (dialog->limit))); source->scope = dialog->ldap_scope; - source->auth = (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->auth_checkbutton)) - ? ADDRESSBOOK_LDAP_AUTH_SIMPLE : ADDRESSBOOK_LDAP_AUTH_NONE); + source->auth = dialog->auth; addressbook_storage_init_source_uri (source); @@ -173,12 +195,20 @@ addressbook_source_dialog_ok_clicked (GtkWidget *widget, AddressbookSourceDialog } static void -add_activate_cb (GtkWidget *item, AddressbookSourceDialog *dialog) +add_scope_activate_cb (GtkWidget *item, AddressbookSourceDialog *dialog) +{ + gtk_signal_connect (GTK_OBJECT (item), "activate", + GTK_SIGNAL_FUNC (scope_optionmenu_activated), dialog); +} + +static void +add_auth_activate_cb (GtkWidget *item, AddressbookSourceDialog *dialog) { gtk_signal_connect (GTK_OBJECT (item), "activate", - GTK_SIGNAL_FUNC (option_menuitem_activated), dialog); + GTK_SIGNAL_FUNC (auth_optionmenu_activated), dialog); } + static AddressbookSourceDialog* addressbook_source_dialog (GladeXML *gui, AddressbookSource *source, GtkWidget *parent) { @@ -214,18 +244,25 @@ addressbook_source_dialog (GladeXML *gui, AddressbookSource *source, GtkWidget * GTK_SIGNAL_FUNC (addressbook_source_edit_changed), dialog); add_focus_handler (dialog->host, dialog->basic_notebook, 1); - dialog->email = glade_xml_get_widget (gui, "email-address-entry"); - gtk_signal_connect (GTK_OBJECT (dialog->email), "changed", - GTK_SIGNAL_FUNC (addressbook_source_edit_changed), dialog); - add_focus_handler (dialog->email, dialog->basic_notebook, 2); - - dialog->email_label = glade_xml_get_widget (gui, "email-address-label"); + /* BASIC -> AUTH STUFF */ + dialog->auth_notebook = glade_xml_get_widget (gui, "auth-notebook"); dialog->auth_checkbutton = glade_xml_get_widget (gui, "auth-checkbutton"); add_focus_handler (dialog->auth_checkbutton, dialog->basic_notebook, 2); gtk_signal_connect (GTK_OBJECT (dialog->auth_checkbutton), "toggled", GTK_SIGNAL_FUNC (auth_checkbutton_changed), dialog); + dialog->auth_optionmenu = glade_xml_get_widget (gui, "auth-optionmenu"); + menu = gtk_option_menu_get_menu (GTK_OPTION_MENU(dialog->auth_optionmenu)); + gtk_container_foreach (GTK_CONTAINER (menu), (GtkCallback)add_auth_activate_cb, dialog); + add_focus_handler (dialog->auth_optionmenu, dialog->basic_notebook, 3); + + dialog->email = glade_xml_get_widget (gui, "email-entry"); + add_focus_handler (dialog->email, dialog->basic_notebook, 4); + + dialog->binddn = glade_xml_get_widget (gui, "dn-entry"); + add_focus_handler (dialog->binddn, dialog->basic_notebook, 5); + /* ADVANCED STUFF */ dialog->port = glade_xml_get_widget (gui, "port-entry"); gtk_signal_connect (GTK_OBJECT (dialog->port), "changed", @@ -240,7 +277,7 @@ addressbook_source_dialog (GladeXML *gui, AddressbookSource *source, GtkWidget * dialog->scope_optionmenu = glade_xml_get_widget (gui, "scope-optionmenu"); add_focus_handler (dialog->scope_optionmenu, dialog->advanced_notebook, 2); menu = gtk_option_menu_get_menu (GTK_OPTION_MENU(dialog->scope_optionmenu)); - gtk_container_foreach (GTK_CONTAINER (menu), (GtkCallback)add_activate_cb, dialog); + gtk_container_foreach (GTK_CONTAINER (menu), (GtkCallback)add_scope_activate_cb, dialog); dialog->limit = glade_xml_get_widget (gui, "limit-entry"); gtk_signal_connect (GTK_OBJECT (dialog->limit), "changed", diff --git a/addressbook/gui/component/addressbook-config.glade b/addressbook/gui/component/addressbook-config.glade index 50b36e2462..23ef8105a5 100644 --- a/addressbook/gui/component/addressbook-config.glade +++ b/addressbook/gui/component/addressbook-config.glade @@ -2,6 +2,8 @@ + addressbook-config-mockup + addressbook-config-mockup src pixmaps @@ -94,7 +96,7 @@ vbox1 3 False - 6 + 3 GtkLabel @@ -117,7 +119,7 @@ GtkTable table1 3 - 3 + 2 2 False 3 @@ -229,36 +231,15 @@ False - - - GtkCheckButton - auth-checkbutton - True - - False - True - - 0 - 2 - 2 - 3 - 0 - 0 - False - False - False - False - True - False - - - GtkHBox - hbox4 - False - 0 + GtkAlignment + alignment2 + 0 + 0.5 + 1 + 1 0 False @@ -266,35 +247,187 @@ - GtkLabel - email-address-label - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - 0 - False - False - - + GtkVBox + auth-vbox + False + 3 - - GtkEntry - email-address-entry - True - True - True - 0 - - - 0 - True - True - + + GtkHBox + hbox9 + False + 0 + + 0 + False + False + + + + GtkCheckButton + auth-checkbutton + True + + False + True + + 0 + False + False + + + + + GtkHBox + hbox10 + False + 3 + + 0 + True + True + + + + GtkOptionMenu + auth-optionmenu + True + Email address +Distinguished name (DN) + + 0 + + 0 + False + False + + + + + + + GtkNotebook + auth-notebook + False + False + GTK_POS_TOP + False + 2 + 2 + False + + 0 + True + True + + + + GtkHBox + hbox5 + 3 + False + 3 + + + GtkLabel + email-label + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + email-entry + + 0 + False + False + + + + + GtkEntry + email-entry + True + True + True + 0 + + + 0 + True + True + + + + + + GtkLabel + Notebook:tab + label52 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkHBox + hbox6 + False + 3 + + + GtkLabel + dn-label + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + dn-entry + + 0 + False + False + + + + + GtkEntry + dn-entry + True + True + True + 0 + + + 0 + True + True + + + + + + GtkLabel + Notebook:tab + label53 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + @@ -364,6 +497,56 @@ 0 + + GtkLabel + label57 + + GTK_JUSTIFY_CENTER + True + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + Notebook:tab + label56 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + label61 + + GTK_JUSTIFY_CENTER + True + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + Notebook:tab + label60 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + GtkLabel label48 @@ -388,6 +571,31 @@ 0 0 + + + GtkLabel + label59 + + GTK_JUSTIFY_CENTER + True + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + Notebook:tab + label58 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + diff --git a/addressbook/gui/component/addressbook.c b/addressbook/gui/component/addressbook.c index 93c3bdf246..74aceb9c4e 100644 --- a/addressbook/gui/component/addressbook.c +++ b/addressbook/gui/component/addressbook.c @@ -641,7 +641,7 @@ load_uri_cb (EBook *book, EBookStatus status, gpointer closure) if (source && source->type == ADDRESSBOOK_SOURCE_LDAP && - source->auth == ADDRESSBOOK_LDAP_AUTH_SIMPLE) { + source->auth != ADDRESSBOOK_LDAP_AUTH_NONE) { const char *password; char *pass_dup = NULL; @@ -651,7 +651,12 @@ load_uri_cb (EBook *book, EBookStatus status, gpointer closure) char *prompt; gboolean remember; - prompt = g_strdup_printf (_("Enter password for %s (user %s)"), source->name, source->email_addr); + if (source->auth == ADDRESSBOOK_LDAP_AUTH_SIMPLE_BINDDN) + prompt = g_strdup_printf (_("Enter password for %s (user %s)"), + source->name, source->binddn); + else + prompt = g_strdup_printf (_("Enter password for %s (user %s)"), + source->name, source->email_addr); remember = source->remember_passwd; pass_dup = e_passwords_ask_password ( prompt, load_uri_data->uri, prompt, TRUE, @@ -665,7 +670,16 @@ load_uri_cb (EBook *book, EBookStatus status, gpointer closure) } if (password || pass_dup) { - e_book_authenticate_user (book, source->email_addr, password ? password : pass_dup, + char *user; + + if (source->auth == ADDRESSBOOK_LDAP_AUTH_SIMPLE_BINDDN) + user = source->binddn; + else + user = source->email_addr; + if (!user) + user = ""; + e_book_authenticate_user (book, user, password ? password : pass_dup, + addressbook_storage_auth_type_to_string (source->auth), load_uri_auth_cb, closure); g_free (pass_dup); return; -- cgit v1.2.3