diff options
Diffstat (limited to 'addressbook/gui')
-rw-r--r-- | addressbook/gui/component/addressbook-config.c | 4 | ||||
-rw-r--r-- | addressbook/gui/component/addressbook-storage.c | 14 | ||||
-rw-r--r-- | addressbook/gui/component/addressbook-storage.h | 1 | ||||
-rw-r--r-- | addressbook/gui/component/addressbook.c | 55 |
4 files changed, 74 insertions, 0 deletions
diff --git a/addressbook/gui/component/addressbook-config.c b/addressbook/gui/component/addressbook-config.c index ae15b7aaf1..7439fd5b6a 100644 --- a/addressbook/gui/component/addressbook-config.c +++ b/addressbook/gui/component/addressbook-config.c @@ -501,6 +501,10 @@ addressbook_source_dialog_set_source (AddressbookSourceDialog *dialog, Addressbo auth_page = g_list_nth_data (source_page->auths, source->ldap.auth); ldap_auth_type_menuitem_activate (auth_page->item, auth_page); gtk_option_menu_set_history (GTK_OPTION_MENU(source_page->auth_optionmenu), auth_page->auth_type); + + if (auth_page->auth_type == ADDRESSBOOK_LDAP_AUTH_SIMPLE) { + e_utf8_gtk_entry_set_text (GTK_ENTRY (auth_page->binddn), source->ldap.binddn); + } } else { e_utf8_gtk_entry_set_text (GTK_ENTRY (source_page->path), source->file.path); diff --git a/addressbook/gui/component/addressbook-storage.c b/addressbook/gui/component/addressbook-storage.c index e1b02ec93a..df11a38cbe 100644 --- a/addressbook/gui/component/addressbook-storage.c +++ b/addressbook/gui/component/addressbook-storage.c @@ -456,6 +456,20 @@ addressbook_storage_get_sources () return sources; } +AddressbookSource * +addressbook_storage_get_source_by_uri (const char *uri) +{ + GList *l; + + for (l = sources; l ; l = l->next) { + AddressbookSource *source = l->data; + if (!strcmp (uri, source->uri)) + return source; + } + + return NULL; +} + void addressbook_source_free (AddressbookSource *source) { diff --git a/addressbook/gui/component/addressbook-storage.h b/addressbook/gui/component/addressbook-storage.h index 0262207603..518977598e 100644 --- a/addressbook/gui/component/addressbook-storage.h +++ b/addressbook/gui/component/addressbook-storage.h @@ -69,6 +69,7 @@ void addressbook_storage_setup (EvolutionShellComponent *shell_component, const char *evolution_homedir); GList *addressbook_storage_get_sources (void); +AddressbookSource *addressbook_storage_get_source_by_uri (const char *uri); void addressbook_storage_clear_sources (void); AddressbookSource *addressbook_source_copy (const AddressbookSource *source); void addressbook_source_free (AddressbookSource *source); diff --git a/addressbook/gui/component/addressbook.c b/addressbook/gui/component/addressbook.c index bdad6ae04c..e9d4f45527 100644 --- a/addressbook/gui/component/addressbook.c +++ b/addressbook/gui/component/addressbook.c @@ -44,6 +44,7 @@ typedef struct { BonoboControl *control; BonoboPropertyBag *properties; char *uri; + char *passwd; } AddressbookView; static void @@ -328,19 +329,73 @@ addressbook_view_free(AddressbookView *view) { if (view->properties) bonobo_object_unref(BONOBO_OBJECT(view->properties)); + g_free(view->passwd); g_free(view->uri); g_free(view); } static void +book_auth_cb (EBook *book, EBookStatus status, gpointer closure) +{ + AddressbookView *view = closure; + if (status == E_BOOK_STATUS_SUCCESS) { + gtk_object_set(GTK_OBJECT(view->view), + "book", book, + NULL); + } + else { + /* pop up a nice dialog, or redo the authentication + bit some number of times. */ + } +} + +static void +passwd_cb (gchar *string, gpointer data) +{ + AddressbookView *view = (AddressbookView*)data; + + view->passwd = g_strdup (string); +} + +static void book_open_cb (EBook *book, EBookStatus status, gpointer closure) { if (status == E_BOOK_STATUS_SUCCESS) { AddressbookView *view = closure; + AddressbookSource *source; + + /* check if the addressbook needs authentication */ + + source = addressbook_storage_get_source_by_uri (view->uri); + if (source && + source->type == ADDRESSBOOK_SOURCE_LDAP && + source->ldap.auth == ADDRESSBOOK_LDAP_AUTH_SIMPLE) { + int button; + char *msg = g_strdup_printf (_("Enter password for %s"), source->ldap.binddn); + /* give a password prompt for the binddn */ + GtkWidget *dialog = gnome_request_dialog (TRUE, msg, NULL, + 0, passwd_cb, view, NULL); + + button = gnome_dialog_run_and_close (GNOME_DIALOG (dialog)); + + if (button == 0 && *(view->passwd)) { + e_book_authenticate_user (book, source->ldap.binddn, view->passwd, + book_auth_cb, closure); + memset (view->passwd, 0, strlen (view->passwd)); /* clear out the passwd */ + g_free (view->passwd); + view->passwd = NULL; + return; + } + } + + /* if they either didn't configure the source to use + authentication, or they canceled the dialog, + proceed without authenticating */ gtk_object_set(GTK_OBJECT(view->view), "book", book, NULL); + } else { GtkWidget *warning_dialog, *label, *href; warning_dialog = gnome_dialog_new ( |