diff options
author | Chris Toshok <toshok@ximian.com> | 2001-08-10 01:21:46 +0800 |
---|---|---|
committer | Chris Toshok <toshok@src.gnome.org> | 2001-08-10 01:21:46 +0800 |
commit | 30876e0d14b1ac0bb110dc8a1635eb434205f5fb (patch) | |
tree | 6b4042ba9aa3cfbb35e91bc98fc928fce0854b0c | |
parent | 44f7f1b1aeed1f1ec213fdacd1d1af5bc59be95d (diff) | |
download | gsoc2013-evolution-30876e0d14b1ac0bb110dc8a1635eb434205f5fb.tar gsoc2013-evolution-30876e0d14b1ac0bb110dc8a1635eb434205f5fb.tar.gz gsoc2013-evolution-30876e0d14b1ac0bb110dc8a1635eb434205f5fb.tar.bz2 gsoc2013-evolution-30876e0d14b1ac0bb110dc8a1635eb434205f5fb.tar.lz gsoc2013-evolution-30876e0d14b1ac0bb110dc8a1635eb434205f5fb.tar.xz gsoc2013-evolution-30876e0d14b1ac0bb110dc8a1635eb434205f5fb.tar.zst gsoc2013-evolution-30876e0d14b1ac0bb110dc8a1635eb434205f5fb.zip |
[ Fixes ximian bugs #5080, #6021, #6704, #6705 ]
2001-08-09 Chris Toshok <toshok@ximian.com>
[ Fixes ximian bugs #5080, #6021, #6704, #6705 ]
* gui/component/addressbook.c (book_open_cb): create our own
dialog that prompts for both the email address and the password.
the email address is stored in the source and filled in for the
user after the first time they enter one and press OK.
* gui/component/addressbook-storage.c (create_ldap_folder): has a
return value, not a int* parameter.
(create_ldap_folder): new function, we can create ldap servers
from the File->New->Folder menu item now.
(register_storage): hook up the "create_folder" signal.
(addressbook_storage_init_source_uri): remove the file case, we
only build ldap uris here.
(load_source_data): remove the file source stuff, and handle
"emailaddr".
(save_source_data): call ldap_source_foreach directly.
(addressbook_source_free): remove file source stuff.
(addressbook_source_copy): same.
* gui/component/addressbook-storage.h: get rid of all the file
source stuff from AddressbookSource, since this is only being used
for ldap servers.
* backend/pas/pas-backend-ldap.c
(pas_backend_ldap_process_authenticate_user): look up the ldap
entry based on the provided email address and use the resulting
DN/passwd to authenticate.
* gui/component/addressbook-config.c: pretty much gutted to make
it work with the new UI.
* gui/component/addressbook-config.glade: new version from anna.
svn path=/trunk/; revision=11834
-rw-r--r-- | addressbook/ChangeLog | 36 | ||||
-rw-r--r-- | addressbook/backend/pas/pas-backend-ldap.c | 43 | ||||
-rw-r--r-- | addressbook/gui/component/addressbook-config.c | 843 | ||||
-rw-r--r-- | addressbook/gui/component/addressbook-config.glade | 830 | ||||
-rw-r--r-- | addressbook/gui/component/addressbook-config.h | 3 | ||||
-rw-r--r-- | addressbook/gui/component/addressbook-storage.c | 142 | ||||
-rw-r--r-- | addressbook/gui/component/addressbook-storage.h | 19 | ||||
-rw-r--r-- | addressbook/gui/component/addressbook.c | 84 |
8 files changed, 1116 insertions, 884 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog index fe76b3ccaf..f2509fd5cd 100644 --- a/addressbook/ChangeLog +++ b/addressbook/ChangeLog @@ -1,3 +1,39 @@ +2001-08-09 Chris Toshok <toshok@ximian.com> + + [ Fixes ximian bugs #5080, #6021, #6704, #6705 ] + + * gui/component/addressbook.c (book_open_cb): create our own + dialog that prompts for both the email address and the password. + the email address is stored in the source and filled in for the + user after the first time they enter one and press OK. + + * gui/component/addressbook-storage.c (create_ldap_folder): has a + return value, not a int* parameter. + (create_ldap_folder): new function, we can create ldap servers + from the File->New->Folder menu item now. + (register_storage): hook up the "create_folder" signal. + (addressbook_storage_init_source_uri): remove the file case, we + only build ldap uris here. + (load_source_data): remove the file source stuff, and handle + "emailaddr". + (save_source_data): call ldap_source_foreach directly. + (addressbook_source_free): remove file source stuff. + (addressbook_source_copy): same. + + * gui/component/addressbook-storage.h: get rid of all the file + source stuff from AddressbookSource, since this is only being used + for ldap servers. + + * backend/pas/pas-backend-ldap.c + (pas_backend_ldap_process_authenticate_user): look up the ldap + entry based on the provided email address and use the resulting + DN/passwd to authenticate. + + * gui/component/addressbook-config.c: pretty much gutted to make + it work with the new UI. + + * gui/component/addressbook-config.glade: new version from anna. + 2001-08-09 Christopher James Lahey <clahey@ximian.com> * gui/widgets/e-addressbook-view.c (SPEC): Upped the minimum width diff --git a/addressbook/backend/pas/pas-backend-ldap.c b/addressbook/backend/pas/pas-backend-ldap.c index 43cbe50c3a..804012d983 100644 --- a/addressbook/backend/pas/pas-backend-ldap.c +++ b/addressbook/backend/pas/pas-backend-ldap.c @@ -2056,18 +2056,45 @@ pas_backend_ldap_process_authenticate_user (PASBackend *backend, PASRequest *req) { PASBackendLDAP *bl = PAS_BACKEND_LDAP (backend); - int ldap_error = ldap_simple_bind_s(bl->priv->ldap, - req->user, - req->passwd); + int ldap_error; + char *query; + LDAPMessage *res, *e; + + query = g_strdup_printf ("(mail=%s)", req->user); + + if (ldap_search_s (bl->priv->ldap, + bl->priv->ldap_rootdn, + bl->priv->ldap_scope, + query, + NULL, 0, &res) != -1) { + char *dn; + + e = ldap_first_entry (bl->priv->ldap, res); + dn = ldap_get_dn (bl->priv->ldap, e); + + printf ("authenticating as %s\n", dn); + + ldap_error = ldap_simple_bind_s(bl->priv->ldap, + dn, + req->passwd); - pas_book_respond_authenticate_user (book, - ldap_error_to_response (ldap_error)); + pas_book_respond_authenticate_user (book, + ldap_error_to_response (ldap_error)); + + bl->priv->writable = (ldap_error == LDAP_SUCCESS); + + if (!bl->priv->evolutionPersonChecked) + check_schema_support (bl); + + ldap_msgfree (res); + } + else { + pas_book_respond_authenticate_user (book, GNOME_Evolution_Addressbook_BookListener_PermissionDenied); + } - bl->priv->writable = (ldap_error == LDAP_SUCCESS); pas_book_report_writable (book, bl->priv->writable); - if (!bl->priv->evolutionPersonChecked) - check_schema_support (bl); + g_free (query); } static void diff --git a/addressbook/gui/component/addressbook-config.c b/addressbook/gui/component/addressbook-config.c index 003b29b96a..3a29402453 100644 --- a/addressbook/gui/component/addressbook-config.c +++ b/addressbook/gui/component/addressbook-config.c @@ -6,7 +6,6 @@ #include <libgnome/gnome-defs.h> #include <libgnome/gnome-i18n.h> #include <libgnomeui/gnome-dialog.h> -#include <libgnomeui/gnome-propertybox.h> #include <libgnomeui/gnome-stock.h> #include <glade/glade.h> #include <gal/widgets/e-unicode.h> @@ -15,185 +14,35 @@ #include "addressbook-config.h" #include "addressbook-storage.h" -/* #define INCLUDE_FILE_SOURCE */ - typedef struct _AddressbookSourceDialog AddressbookSourceDialog; typedef struct _AddressbookSourcePageItem AddressbookSourcePageItem; -typedef struct _LDAPAuthPageItem LDAPAuthPageItem; struct _AddressbookSourceDialog { - GtkWidget *html; - GtkWidget *dialog; - GtkWidget *vbox; - GtkWidget *name; - GtkWidget *description; - GtkWidget *source_option; - GtkWidget *notebook; - - GList *source_pages; - AddressbookSourcePageItem *source_page; - - gint id; /* button we closed the dialog with */ - - AddressbookSource *source; /* our result if the Ok button was clicked */ -}; - -struct _AddressbookSourcePageItem { - gint pnum; - - AddressbookSourceType source_type; - - AddressbookSourceDialog *dialog; + GladeXML *gui; - GtkWidget *item; - GtkWidget *vbox; + GtkWidget *dialog; - /* file: addressbook's */ - GtkWidget *path; - GtkWidget *creat; + GtkWidget *basic_notebook; + GtkWidget *advanced_notebook; - /* ldap: addressbook's */ + GtkWidget *name; GtkWidget *host; + GtkWidget *port; GtkWidget *rootdn; GtkWidget *scope_optionmenu; - GtkWidget *auth_optionmenu; - GtkWidget *auth_notebook; - - GList *auths; - LDAPAuthPageItem *auth; -}; - -struct _LDAPAuthPageItem { - gint pnum; + GtkWidget *auth_checkbutton; - AddressbookLDAPAuthType auth_type; - - AddressbookSourceDialog *dialog; - AddressbookSourcePageItem *page; - - GtkWidget *item; - GtkWidget *vbox; + gint id; /* button we closed the dialog with */ - /* simple (password) auth */ - GtkWidget *binddn; - GtkWidget *remember_passwd; + AddressbookSource *source; /* our result if the Ok button was clicked */ }; static void -html_size_req (GtkWidget *widget, GtkRequisition *requisition) -{ - requisition->height = GTK_LAYOUT (widget)->height; -} - -/* Returns a GtkHTML which is already inside a GtkScrolledWindow. If - * @white is TRUE, the GtkScrolledWindow will be inside a GtkFrame. - */ -static GtkWidget * -html_new (gboolean white) -{ - GtkWidget *html, *scrolled, *frame; - GtkStyle *style; - - html = gtk_html_new (); - GTK_LAYOUT (html)->height = 0; - gtk_signal_connect (GTK_OBJECT (html), "size_request", - GTK_SIGNAL_FUNC (html_size_req), NULL); - gtk_html_set_editable (GTK_HTML (html), FALSE); - style = gtk_rc_get_style (html); - if (style) { - gtk_html_set_default_background_color (GTK_HTML (html), - white ? &style->white : - &style->bg[0]); - } - gtk_widget_set_sensitive (html, FALSE); - scrolled = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled), - GTK_POLICY_NEVER, - GTK_POLICY_NEVER); - gtk_container_add (GTK_CONTAINER (scrolled), html); - - if (white) { - frame = gtk_frame_new (NULL); - gtk_frame_set_shadow_type (GTK_FRAME (frame), - GTK_SHADOW_ETCHED_IN); - gtk_container_add (GTK_CONTAINER (frame), scrolled); - gtk_widget_show_all (frame); - } else - gtk_widget_show_all (scrolled); - - return html; -} - -static void -put_html (GtkHTML *html, char *text) -{ - GtkHTMLStream *handle; - - text = e_text_to_html (text, E_TEXT_TO_HTML_CONVERT_NL); - handle = gtk_html_begin (html); - gtk_html_write (html, handle, "<HTML><BODY>", 12); - gtk_html_write (html, handle, text, strlen (text)); - gtk_html_write (html, handle, "</BODY></HTML>", 14); - g_free (text); - gtk_html_end (html, handle, GTK_HTML_STREAM_OK); -} - -#ifdef INCLUDE_FILE_SOURCE -static const char * -addressbook_config_source_label (AddressbookSourceType type) -{ - switch (type) { - case ADDRESSBOOK_SOURCE_LDAP: - return _("LDAP Server"); - case ADDRESSBOOK_SOURCE_FILE: - return _("File"); - default: - g_assert(0); - return _("Unknown addressbook type"); - } -} -#endif - -static const char * -addressbook_config_auth_label (AddressbookLDAPAuthType type) -{ - switch (type) { - case ADDRESSBOOK_LDAP_AUTH_NONE: - return _("None (anonymous mode)"); - case ADDRESSBOOK_LDAP_AUTH_SIMPLE: - return _("Password"); - default: - g_assert(0); - return _("Unknown auth type"); - } -} - -static const char * -addressbook_config_scope_label (AddressbookLDAPScopeType scope) -{ - switch (scope) { - case ADDRESSBOOK_LDAP_SCOPE_BASE: - return _("Base"); - case ADDRESSBOOK_LDAP_SCOPE_ONELEVEL: - return _("One"); - case ADDRESSBOOK_LDAP_SCOPE_SUBTREE: - return _("Subtree"); - default: - g_assert (0); - return _("Unknown scope type"); - } -} - -static void addressbook_source_edit_changed (GtkWidget *item, AddressbookSourceDialog *dialog) { char *data; gboolean complete = TRUE; - AddressbookSourcePageItem *source_page = dialog->source_page; - - if (source_page == NULL) - complete = FALSE; if (complete) { data = e_utf8_gtk_editable_get_chars (GTK_EDITABLE (dialog->name), 0, -1); @@ -203,415 +52,73 @@ addressbook_source_edit_changed (GtkWidget *item, AddressbookSourceDialog *dialo } if (complete) { - if (source_page->source_type == ADDRESSBOOK_SOURCE_FILE) { - if (complete) { - data = e_utf8_gtk_editable_get_chars (GTK_EDITABLE (source_page->path), 0, -1); - if (!data || !*data) - complete = FALSE; - g_free (data); - } + if (complete) { + data = e_utf8_gtk_editable_get_chars (GTK_EDITABLE (dialog->host), 0, -1); + if (!data || !*data) + complete = FALSE; + g_free (data); } - else { - if (complete) { - data = e_utf8_gtk_editable_get_chars (GTK_EDITABLE (source_page->host), 0, -1); - if (!data || !*data) - complete = FALSE; - g_free (data); - } - - if (complete) { - data = e_utf8_gtk_editable_get_chars (GTK_EDITABLE (source_page->port), 0, -1); - if (!data || !*data) - complete = FALSE; - /* XXX more validation on port here */ - g_free (data); - } - - if (complete) { - LDAPAuthPageItem *auth_page = source_page->auth; - - if (auth_page->auth_type == ADDRESSBOOK_LDAP_AUTH_SIMPLE) { - data = e_utf8_gtk_editable_get_chars (GTK_EDITABLE (auth_page->binddn), 0, -1); - if (!data || !*data) - complete = FALSE; - g_free (data); - } - data = e_utf8_gtk_editable_get_chars (GTK_EDITABLE (source_page->port), 0, -1); - if (!data || !*data) - complete = FALSE; + + if (complete) { + data = e_utf8_gtk_editable_get_chars (GTK_EDITABLE (dialog->port), 0, -1); + if (!data || !*data) + complete = FALSE; /* XXX more validation on port here */ - g_free (data); - } + g_free (data); } } gnome_dialog_set_sensitive (GNOME_DIALOG (dialog->dialog), 0, complete); } -static void -source_type_menuitem_activate (GtkWidget *item, gpointer data) -{ - AddressbookSourcePageItem *sitem = data; - - gtk_notebook_set_page (GTK_NOTEBOOK(sitem->dialog->notebook), sitem->pnum); - sitem->dialog->source_page = sitem; - - addressbook_source_edit_changed (item, sitem->dialog); -} - typedef struct { - AddressbookSourceDialog *dialog; - char *help_text; + GtkWidget *notebook; + int page_num; } FocusHelpClosure; static void -free_focus_help_closure (gpointer data) +focus_help (GtkWidget *w, GdkEventFocus *event, FocusHelpClosure *closure) { - FocusHelpClosure *closure = data; - g_free(closure->help_text); - g_free(closure); + gtk_notebook_set_page (GTK_NOTEBOOK(closure->notebook), closure->page_num); } -static gint -focus_help (GtkWidget *widget, GdkEventFocus *event, FocusHelpClosure *closure) -{ - put_html (GTK_HTML(closure->dialog->html), closure->help_text); - return FALSE; -} - -static GtkWidget * -table_add_elem (AddressbookSourceDialog *dialog, GtkWidget *table, - int row, - const char *label_text, - char *help_text) +static void +add_focus_handler (GtkWidget *widget, GtkWidget *notebook, int page_num) { - GtkWidget *label, *entry; - FocusHelpClosure *focus_closure; + FocusHelpClosure *focus_closure = g_new0 (FocusHelpClosure, 1); + focus_closure->notebook = notebook; + focus_closure->page_num = page_num; - label = gtk_label_new (label_text); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, - row, row + 1, GTK_FILL, 0, 0, 0); - gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5); - - entry = gtk_entry_new (); - gtk_table_attach (GTK_TABLE (table), entry, 1, 3, row, row + 1, - GTK_EXPAND | GTK_FILL, 0, 0, 0); - - gtk_signal_connect (GTK_OBJECT (entry), "changed", - GTK_SIGNAL_FUNC (addressbook_source_edit_changed), dialog); - - focus_closure = g_new0 (FocusHelpClosure, 1); - focus_closure->dialog = dialog; - focus_closure->help_text = g_strdup(help_text); - - gtk_signal_connect_full (GTK_OBJECT (entry), + gtk_signal_connect_full (GTK_OBJECT (widget), "focus_in_event" /* XXX */, (GtkSignalFunc) focus_help, NULL, focus_closure, - (GtkDestroyNotify) free_focus_help_closure, + (GtkDestroyNotify) g_free, FALSE, FALSE); - return entry; -} - -static void -ldap_auth_type_menuitem_activate (GtkWidget *item, gpointer data) -{ - LDAPAuthPageItem *auth_item = data; - - gtk_notebook_set_page (GTK_NOTEBOOK(auth_item->page->auth_notebook), auth_item->pnum); - - auth_item->page->auth = auth_item; - - addressbook_source_edit_changed (item, auth_item->dialog); -} - -static LDAPAuthPageItem * -addressbook_ldap_auth_item_new (AddressbookSourceDialog *dialog, - AddressbookSourcePageItem *page, - AddressbookLDAPAuthType type) -{ - LDAPAuthPageItem *item = g_new0 (LDAPAuthPageItem, 1); - GtkWidget *table = NULL; - int row = 0; - - item->pnum = type; - item->auth_type = type; - item->dialog = dialog; - item->page = page; - item->vbox = gtk_vbox_new (FALSE, 0); - - switch (type) { - case ADDRESSBOOK_LDAP_AUTH_NONE: - break; - case ADDRESSBOOK_LDAP_AUTH_SIMPLE: - table = gtk_table_new (2, 2, FALSE); - item->binddn = table_add_elem (dialog, table, row++, - _("Bind DN:"), - _("FIXME Bind DN Help text here")); - - item->remember_passwd = gtk_check_button_new_with_label (_("Remember this password")); - - gtk_table_attach (GTK_TABLE (table), item->remember_passwd, 1, 2, - row, row + 1, GTK_FILL, 0, 0, 0); - - gtk_box_pack_start (GTK_BOX (item->vbox), table, - TRUE, TRUE, 0); - break; - default: - g_assert (0); - return item; - } - - if (table) { - gtk_table_set_row_spacings (GTK_TABLE (table), 2); - gtk_table_set_col_spacings (GTK_TABLE (table), 10); - gtk_container_set_border_width (GTK_CONTAINER (table), 8); - } - - gtk_widget_show_all (item->vbox); - - return item; -} - -static AddressbookSourcePageItem * -addressbook_source_item_new (AddressbookSourceDialog *dialog, AddressbookSourceType type) -{ - AddressbookSourcePageItem *item = g_new0 (AddressbookSourcePageItem, 1); - GtkWidget *table = NULL; -#if 0 - GtkWidget *advanced_button; -#endif - int row = 0; - - item->pnum = type; - item->source_type = type; - item->dialog = dialog; - - item->vbox = gtk_vbox_new (FALSE, 0); - - switch (type) { - case ADDRESSBOOK_SOURCE_LDAP: { - GtkWidget *label; - GtkWidget *menu; - int i; - LDAPAuthPageItem *first_item = NULL; - int position; - - table = gtk_table_new (6, 2, FALSE); - - item->host = table_add_elem (dialog, table, row++, - _("Host:"), - _("FIXME Host help text here.")); - item->rootdn = table_add_elem (dialog, table, row++, - _("Root DN:"), - _("FIXME Root DN help text here.")); - - /* XXX BEGIN PUT IN ADVANCED DIALOG */ - item->port = table_add_elem (dialog, table, row++, - _("Port:"), - _("FIXME Port help text here.")); - gtk_editable_insert_text (GTK_EDITABLE (item->port), "389", 3, &position); - - item->scope_optionmenu = gtk_option_menu_new (); - menu = gtk_menu_new (); - - for (i = 0; i < ADDRESSBOOK_LDAP_SCOPE_LAST; i ++) { - GtkWidget *scope_item = gtk_menu_item_new_with_label (addressbook_config_scope_label (i)); - - gtk_signal_connect (GTK_OBJECT (scope_item), "activate", - GTK_SIGNAL_FUNC (addressbook_source_edit_changed), - dialog); - - gtk_menu_append (GTK_MENU (menu), scope_item); - gtk_widget_show (scope_item); - } - - gtk_option_menu_set_menu (GTK_OPTION_MENU (item->scope_optionmenu), menu); - // ldap_auth_type_menuitem_activate (first_item->item, first_item); - gtk_option_menu_set_history (GTK_OPTION_MENU(item->scope_optionmenu), 0); - label = gtk_label_new (_("Search Scope:")); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, - row, row + 1, GTK_FILL, 0, 0, 0); - gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5); - - gtk_table_attach (GTK_TABLE (table), - item->scope_optionmenu, - 1, 2, row, row + 1, - GTK_EXPAND | GTK_FILL, 0, - 0, 0); - - row++; - /* XXX END PUT IN ADVANCED DIALOG */ - - item->auth_optionmenu = gtk_option_menu_new (); - menu = gtk_menu_new (); - - item->auth_notebook = gtk_notebook_new(); - gtk_notebook_set_show_tabs (GTK_NOTEBOOK (item->auth_notebook), FALSE); - - for (i = 0; i < ADDRESSBOOK_LDAP_AUTH_LAST; i++) { - LDAPAuthPageItem *auth_item; - - auth_item = addressbook_ldap_auth_item_new (dialog, item, i); - - item->auths = g_list_append (item->auths, auth_item); - - if (!first_item) - first_item = auth_item; - - auth_item->item = gtk_menu_item_new_with_label (addressbook_config_auth_label (i)); - - gtk_notebook_append_page (GTK_NOTEBOOK (item->auth_notebook), - auth_item->vbox, NULL); - - gtk_signal_connect (GTK_OBJECT (auth_item->item), "activate", - GTK_SIGNAL_FUNC (ldap_auth_type_menuitem_activate), - auth_item); - - gtk_menu_append (GTK_MENU (menu), auth_item->item); - gtk_widget_show (auth_item->item); - } - - gtk_option_menu_set_menu (GTK_OPTION_MENU (item->auth_optionmenu), menu); - ldap_auth_type_menuitem_activate (first_item->item, first_item); - gtk_option_menu_set_history (GTK_OPTION_MENU(item->auth_optionmenu), 0); - - label = gtk_label_new (_("Authentication:")); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, - row, row + 1, GTK_FILL, 0, 0, 0); - gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5); - - gtk_table_attach (GTK_TABLE (table), - item->auth_optionmenu, - 1, 2, row, row + 1, - GTK_EXPAND | GTK_FILL, 0, - 0, 0); - - row++; - - gtk_box_pack_start (GTK_BOX (item->vbox), table, - TRUE, FALSE, 0); - - gtk_box_pack_start (GTK_BOX (item->vbox), item->auth_notebook, - TRUE, TRUE, 0); - -#if 0 - table = gtk_table_new (1, 4, FALSE); - - advanced_button = gtk_button_new_with_label (_("Advanced LDAP Options")); - - gtk_table_attach (GTK_TABLE (table), - advanced_button, - 3, 4, 0, 1, - 0, 0, - 0, 0); - - - gtk_box_pack_start (GTK_BOX (item->vbox), table, - FALSE, FALSE, 0); - - gtk_signal_connect (GTK_OBJECT (advanced_button), "clicked", - GTK_SIGNAL_FUNC (), dialog); -#endif - - break; - } - case ADDRESSBOOK_SOURCE_FILE: { - table = gtk_table_new (2, 2, FALSE); - item->path = table_add_elem (dialog, table, row++, - _("Path:"), - _("FIXME Path Help text here")); - - gtk_box_pack_start (GTK_BOX (item->vbox), table, - TRUE, TRUE, 0); - - item->creat = gtk_check_button_new_with_label (_("Create path if it doesn't exist.")); - gtk_table_attach (GTK_TABLE (table), item->creat, 1, 2, - row, row + 1, GTK_FILL, 0, 0, 0); - break; - } - default: - g_assert(0); - return item; - } - - gtk_table_set_row_spacings (GTK_TABLE (table), 2); - gtk_table_set_col_spacings (GTK_TABLE (table), 10); - gtk_container_set_border_width (GTK_CONTAINER (table), 8); - - gtk_widget_show_all (item->vbox); - - return item; } static void addressbook_source_dialog_set_source (AddressbookSourceDialog *dialog, AddressbookSource *source) { - AddressbookSourcePageItem *source_page; - - e_utf8_gtk_entry_set_text (GTK_ENTRY (dialog->name), source->name); - e_utf8_gtk_entry_set_text (GTK_ENTRY (dialog->description), source->description); - - /* choose the correct server page */ - source_page = g_list_nth_data (dialog->source_pages, source->type); - source_type_menuitem_activate (source_page->item, source_page); - gtk_option_menu_set_history (GTK_OPTION_MENU(dialog->source_option), source->type); - - if (source->type == ADDRESSBOOK_SOURCE_LDAP) { - LDAPAuthPageItem *auth_page; - - e_utf8_gtk_entry_set_text (GTK_ENTRY (source_page->host), source->ldap.host); - e_utf8_gtk_entry_set_text (GTK_ENTRY (source_page->port), source->ldap.port); - e_utf8_gtk_entry_set_text (GTK_ENTRY (source_page->rootdn), source->ldap.rootdn); + 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->port), source ? source->port : "389"); + e_utf8_gtk_entry_set_text (GTK_ENTRY (dialog->rootdn), source ? source->rootdn : ""); - gtk_option_menu_set_history (GTK_OPTION_MENU(source_page->scope_optionmenu), source->ldap.scope); - - 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); - } + gtk_option_menu_set_history (GTK_OPTION_MENU(dialog->scope_optionmenu), source ? source->scope : 0); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(dialog->auth_checkbutton), source->auth == ADDRESSBOOK_LDAP_AUTH_SIMPLE); } static AddressbookSource * addressbook_source_dialog_get_source (AddressbookSourceDialog *dialog) { AddressbookSource *source = g_new0 (AddressbookSource, 1); - AddressbookSourcePageItem *source_page; - - source_page = dialog->source_page; - source->name = e_utf8_gtk_entry_get_text (GTK_ENTRY (dialog->name)); - source->description = e_utf8_gtk_entry_get_text (GTK_ENTRY (dialog->description)); - source->type = source_page->source_type; - - if (source->type == ADDRESSBOOK_SOURCE_FILE) { - source->file.path = e_utf8_gtk_entry_get_text (GTK_ENTRY (source_page->path)); - } - else { - LDAPAuthPageItem *auth_page; - - source->ldap.host = e_utf8_gtk_entry_get_text (GTK_ENTRY (source_page->host)); - source->ldap.port = e_utf8_gtk_entry_get_text (GTK_ENTRY (source_page->port)); - source->ldap.rootdn = e_utf8_gtk_entry_get_text (GTK_ENTRY (source_page->rootdn)); - - auth_page = source_page->auth; - - source->ldap.auth = auth_page->auth_type; - if (source->ldap.auth == ADDRESSBOOK_LDAP_AUTH_SIMPLE) { - source->ldap.binddn = e_utf8_gtk_entry_get_text (GTK_ENTRY (auth_page->binddn)); - source->ldap.remember_passwd = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (auth_page->remember_passwd)); - } - - 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); - } + 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->port = e_utf8_gtk_entry_get_text (GTK_ENTRY (dialog->port)); + source->rootdn = e_utf8_gtk_entry_get_text (GTK_ENTRY (dialog->rootdn)); + source->auth = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->auth_checkbutton)) ? ADDRESSBOOK_LDAP_AUTH_SIMPLE : ADDRESSBOOK_LDAP_AUTH_NONE; addressbook_storage_init_source_uri (source); @@ -624,162 +131,61 @@ addressbook_source_dialog_ok_clicked (GtkWidget *widget, AddressbookSourceDialog dialog->source = addressbook_source_dialog_get_source (dialog); } -static void -addressbook_source_dialog_destroy (AddressbookSourceDialog *dialog) -{ - GList *s; - - for (s = dialog->source_pages; s; s = s->next) { - AddressbookSourcePageItem *source_item = s->data; - - g_list_foreach (source_item->auths, (GFunc)g_free, NULL); - g_list_free (source_item->auths); - g_free (source_item); - } - - g_list_free (dialog->source_pages); - - if (dialog->source) - addressbook_source_free (dialog->source); - g_free (dialog); -} - static AddressbookSourceDialog* -addressbook_source_dialog (AddressbookSource *source, GtkWidget *parent) +addressbook_source_dialog (GladeXML *gui, AddressbookSource *source, GtkWidget *parent) { - GtkWidget *table; AddressbookSourceDialog *dialog = g_new0 (AddressbookSourceDialog, 1); - GtkWidget *vbox, *dialog_vbox; -#ifdef INCLUDE_FILE_SOURCE - GtkWidget *menu; -#endif - AddressbookSourcePageItem *first_item = NULL; - GtkWidget *area; - int i; - int row = 0; - char *tmp_utf; + + dialog->gui = gui; + + dialog->dialog = glade_xml_get_widget (gui, "add_addressbook"); if (source) - dialog->dialog = gnome_dialog_new (_("Edit Addressbook"), NULL); - else - dialog->dialog = gnome_dialog_new (_("Add Addressbook"), NULL); + gtk_window_set_title (GTK_WINDOW (dialog->dialog), _("Edit Addressbook")); gtk_window_set_modal (GTK_WINDOW (dialog->dialog), TRUE); gtk_window_set_policy (GTK_WINDOW (dialog->dialog), FALSE, TRUE, FALSE); -#if 0 - gtk_window_set_default_size (GTK_WINDOW (dialog->dialog), 300, 300); -#endif + gnome_dialog_set_parent (GNOME_DIALOG (dialog->dialog), GTK_WINDOW (parent)); - dialog->vbox = gtk_vbox_new (FALSE, 5); - dialog_vbox = GNOME_DIALOG (dialog->dialog)->vbox; - - vbox = gtk_vbox_new (FALSE, 0); - - dialog->html = html_new (FALSE); - tmp_utf = e_utf8_from_locale_string ( - _("Select the kind of addressbook you have, and enter " - "the relevant information about it.")); - put_html (GTK_HTML (dialog->html), tmp_utf); - g_free (tmp_utf); - - table = gtk_table_new (2, 2, FALSE); - - dialog->name = table_add_elem (dialog, table, row++, - _("Name:"), - _("FIXME Name help text here")); - dialog->description = table_add_elem (dialog, table, row++, - _("Description:"), - _("FIXME Description help text here")); + dialog->basic_notebook = glade_xml_get_widget (gui, "basic-notebook"); + dialog->advanced_notebook = glade_xml_get_widget (gui, "advanced-notebook"); - gtk_table_set_row_spacings (GTK_TABLE (table), 2); - gtk_table_set_col_spacings (GTK_TABLE (table), 10); - gtk_container_set_border_width (GTK_CONTAINER (table), 8); - - dialog->notebook = gtk_notebook_new(); - gtk_notebook_set_show_tabs (GTK_NOTEBOOK (dialog->notebook), FALSE); - -#ifdef INCLUDE_FILE_SOURCE - dialog->source_option = gtk_option_menu_new (); - menu = gtk_menu_new (); -#endif - - for (i = ADDRESSBOOK_SOURCE_LDAP; - i < ADDRESSBOOK_SOURCE_LAST; - i ++) { - AddressbookSourcePageItem *item; - - item = addressbook_source_item_new (dialog, i); - - dialog->source_pages = g_list_append (dialog->source_pages, item); - -#ifdef INCLUDE_FILE_SOURCE - item->item = gtk_menu_item_new_with_label (addressbook_config_source_label (i)); -#endif - - if (!first_item) - first_item = item; - - gtk_notebook_append_page (GTK_NOTEBOOK (dialog->notebook), - item->vbox, NULL); - - gtk_signal_connect (GTK_OBJECT (item->item), "activate", - GTK_SIGNAL_FUNC (source_type_menuitem_activate), - item); - -#ifdef INCLUDE_FILE_SOURCE - gtk_menu_append (GTK_MENU (menu), item->item); -#endif - gtk_widget_show (item->item); - } - -#ifdef INCLUDE_FILE_SOURCE - gtk_option_menu_set_menu (GTK_OPTION_MENU (dialog->source_option), menu); -#endif - source_type_menuitem_activate (first_item->item, first_item); -#ifdef INCLUDE_FILE_SOURCE - gtk_option_menu_set_history (GTK_OPTION_MENU(dialog->source_option), 0); -#endif - - gtk_box_pack_start (GTK_BOX (vbox), dialog->html->parent, - FALSE, TRUE, 0); - - gtk_box_pack_start (GTK_BOX (vbox), table, - FALSE, FALSE, 0); - -#ifdef INCLUDE_FILE_SOURCE - gtk_box_pack_start (GTK_BOX (vbox), dialog->source_option, - FALSE, FALSE, 0); -#endif - - gtk_box_pack_start (GTK_BOX (dialog->vbox), vbox, FALSE, TRUE, 0); - - gtk_box_pack_start (GTK_BOX (dialog->vbox), dialog->notebook, - TRUE, TRUE, 0); + /* BASIC STUFF */ + dialog->name = glade_xml_get_widget (gui, "account-name-entry"); + gtk_signal_connect (GTK_OBJECT (dialog->name), "changed", + GTK_SIGNAL_FUNC (addressbook_source_edit_changed), dialog); + add_focus_handler (dialog->name, dialog->basic_notebook, 0); - /* hook our ui into the gnome-dialog */ - gtk_box_pack_start (GTK_BOX (dialog_vbox), dialog->vbox, TRUE, TRUE, 0); + dialog->host = glade_xml_get_widget (gui, "server-name-entry"); + gtk_signal_connect (GTK_OBJECT (dialog->host), "changed", + GTK_SIGNAL_FUNC (addressbook_source_edit_changed), dialog); + add_focus_handler (dialog->host, dialog->basic_notebook, 1); - gtk_widget_show_all (dialog->vbox); + 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 (addressbook_source_edit_changed), dialog); - /* Buttons */ - area = GNOME_DIALOG (dialog->dialog)->action_area; - gtk_widget_show (area); - gtk_button_box_set_layout (GTK_BUTTON_BOX (area), GTK_BUTTONBOX_END); - gtk_button_box_set_spacing (GTK_BUTTON_BOX (area), 8); + /* ADVANCED STUFF */ + dialog->port = glade_xml_get_widget (gui, "port-entry"); + gtk_signal_connect (GTK_OBJECT (dialog->port), "changed", + GTK_SIGNAL_FUNC (addressbook_source_edit_changed), dialog); + add_focus_handler (dialog->port, dialog->advanced_notebook, 0); - gnome_dialog_append_button (GNOME_DIALOG (dialog->dialog), - GNOME_STOCK_BUTTON_OK); - gnome_dialog_append_button (GNOME_DIALOG (dialog->dialog), - GNOME_STOCK_BUTTON_CANCEL); + dialog->rootdn = glade_xml_get_widget (gui, "rootdn-entry"); + gtk_signal_connect (GTK_OBJECT (dialog->rootdn), "changed", + GTK_SIGNAL_FUNC (addressbook_source_edit_changed), dialog); + add_focus_handler (dialog->rootdn, dialog->advanced_notebook, 1); - gnome_dialog_set_default (GNOME_DIALOG (dialog->dialog), 0); + dialog->scope_optionmenu = glade_xml_get_widget (gui, "scope-optionmenu"); + add_focus_handler (dialog->scope_optionmenu, dialog->advanced_notebook, 2); + /* XXX changed */ /* fill in source info if there is some */ - if (source) - addressbook_source_dialog_set_source (dialog, source); + addressbook_source_dialog_set_source (dialog, source); gnome_dialog_set_sensitive (GNOME_DIALOG (dialog->dialog), 0, FALSE); @@ -791,15 +197,44 @@ addressbook_source_dialog (AddressbookSource *source, GtkWidget *parent) } static AddressbookSourceDialog * -addressbook_config_source (AddressbookSource *source, GtkWidget *parent) +addressbook_config_source_with_gui (GladeXML *gui, AddressbookSource *source, GtkWidget *parent) { - AddressbookSourceDialog* dialog = addressbook_source_dialog (source, parent); + AddressbookSourceDialog* dialog; + + dialog = addressbook_source_dialog (gui, source, parent); + + gnome_dialog_close_hides (GNOME_DIALOG(dialog->dialog), TRUE); dialog->id = gnome_dialog_run_and_close (GNOME_DIALOG (dialog->dialog)); return dialog; } +void +addressbook_create_new_source (char *new_source, GtkWidget *parent) +{ + AddressbookSourceDialog *dialog; + GladeXML *gui; + + gui = glade_xml_new (EVOLUTION_GLADEDIR "/addressbook-config.glade", NULL); + + dialog = addressbook_source_dialog (gui, NULL, parent); + + e_utf8_gtk_entry_set_text (GTK_ENTRY (dialog->name), new_source); + + gnome_dialog_close_hides (GNOME_DIALOG(dialog->dialog), TRUE); + + dialog->id = gnome_dialog_run_and_close (GNOME_DIALOG (dialog->dialog)); + + gtk_object_unref (GTK_OBJECT (dialog->gui)); + + if (dialog->id == 0) { + /* Ok was clicked */ + addressbook_storage_add_source (addressbook_source_copy(dialog->source)); + addressbook_storage_write_sources(); + } +} + typedef struct { @@ -827,7 +262,7 @@ add_source_clicked (GtkWidget *widget, AddressbookDialog *dialog) { AddressbookSourceDialog *sdialog; - sdialog = addressbook_config_source (NULL, dialog->dialog); + sdialog = addressbook_config_source_with_gui (dialog->gui, NULL, dialog->dialog); if (sdialog->id == 0) { /* Ok was clicked */ AddressbookSource *source = addressbook_source_copy(sdialog->source); @@ -835,15 +270,14 @@ add_source_clicked (GtkWidget *widget, AddressbookDialog *dialog) gchar *text[2]; text[0] = source->name; - text[1] = source->uri; + text[1] = source->host; row = e_utf8_gtk_clist_append (GTK_CLIST(dialog->clistSources), text); gtk_clist_set_row_data_full (GTK_CLIST(dialog->clistSources), row, source, (GtkDestroyNotify) addressbook_source_free); - gnome_property_box_changed (GNOME_PROPERTY_BOX (dialog->dialog)); + gnome_dialog_set_sensitive (GNOME_DIALOG(dialog->dialog), 0, TRUE); + gnome_dialog_set_sensitive (GNOME_DIALOG(dialog->dialog), 1, TRUE); update_sensitivity (dialog); } - - addressbook_source_dialog_destroy (sdialog); } static void @@ -854,19 +288,18 @@ edit_source_clicked (GtkWidget *widget, AddressbookDialog *dialog) source = gtk_clist_get_row_data (GTK_CLIST (dialog->clistSources), dialog->source_row); - sdialog = addressbook_config_source (source, dialog->dialog); + sdialog = addressbook_config_source_with_gui (dialog->gui, source, dialog->dialog); if (sdialog->id == 0) { /* Ok was clicked */ source = addressbook_source_copy(sdialog->source); e_utf8_gtk_clist_set_text (GTK_CLIST (dialog->clistSources), dialog->source_row, 0, source->name); - e_utf8_gtk_clist_set_text (GTK_CLIST (dialog->clistSources), dialog->source_row, 1, source->uri); + e_utf8_gtk_clist_set_text (GTK_CLIST (dialog->clistSources), dialog->source_row, 1, source->host); gtk_clist_set_row_data (GTK_CLIST (dialog->clistSources), dialog->source_row, source); - gnome_property_box_changed (GNOME_PROPERTY_BOX (dialog->dialog)); + gnome_dialog_set_sensitive (GNOME_DIALOG(dialog->dialog), 0, TRUE); + gnome_dialog_set_sensitive (GNOME_DIALOG(dialog->dialog), 1, TRUE); update_sensitivity (dialog); } - - addressbook_source_dialog_destroy (sdialog); } static void @@ -874,7 +307,8 @@ delete_source_clicked (GtkWidget *widget, AddressbookDialog *dialog) { gtk_clist_remove (GTK_CLIST (dialog->clistSources), dialog->source_row); dialog->source_row = -1; - gnome_property_box_changed (GNOME_PROPERTY_BOX(dialog->dialog)); + gnome_dialog_set_sensitive (GNOME_DIALOG(dialog->dialog), 0, TRUE); + gnome_dialog_set_sensitive (GNOME_DIALOG(dialog->dialog), 1, TRUE); update_sensitivity (dialog); } @@ -888,12 +322,17 @@ sources_select_row (GtkWidget *widget, gint row, gint column, } static void -addressbook_dialog_apply (GnomePropertyBox *property_box, gint page_num, AddressbookDialog *dialog) +addressbook_dialog_close (GtkWidget *w, AddressbookDialog *dialog) { - int i; + gtk_widget_destroy (dialog->dialog); + gtk_object_unref (GTK_OBJECT (dialog->gui)); + g_free (dialog); +} - if (page_num != -1) - return; +static void +addressbook_dialog_apply (GtkWidget *w, AddressbookDialog *dialog) +{ + int i; addressbook_storage_clear_sources(); @@ -903,13 +342,16 @@ addressbook_dialog_apply (GnomePropertyBox *property_box, gint page_num, Address } addressbook_storage_write_sources(); + + gnome_dialog_set_sensitive (GNOME_DIALOG(dialog->dialog), 0, FALSE); + gnome_dialog_set_sensitive (GNOME_DIALOG(dialog->dialog), 1, FALSE); } static void -addressbook_dialog_close (GnomePropertyBox *property_box, AddressbookDialog *dialog) +addressbook_dialog_ok (GtkWidget *w, AddressbookDialog *dialog) { - gtk_object_unref (GTK_OBJECT (dialog->gui)); - g_free (dialog); + addressbook_dialog_apply(w, dialog); + addressbook_dialog_close(w, dialog); } void @@ -928,7 +370,7 @@ addressbook_config (GNOME_Evolution_Shell shell) dialog->gui = gui; dialog->shell = shell; - dialog->dialog = glade_xml_get_widget (gui, "dialog"); + dialog->dialog = glade_xml_get_widget (gui, "addressbook_sources"); clist = glade_xml_get_widget (gui, "clistSources"); dialog->clistSources = clist; @@ -951,6 +393,8 @@ addressbook_config (GNOME_Evolution_Shell shell) GTK_SIGNAL_FUNC (delete_source_clicked), dialog); + gnome_dialog_set_sensitive (GNOME_DIALOG(dialog->dialog), 0, FALSE); + gnome_dialog_set_sensitive (GNOME_DIALOG(dialog->dialog), 1, FALSE); update_sensitivity (dialog); l = addressbook_storage_get_sources (); @@ -962,7 +406,7 @@ addressbook_config (GNOME_Evolution_Shell shell) source = addressbook_source_copy ((AddressbookSource*)l->data); text[0] = source->name; - text[1] = source->uri; + text[1] = source->host; row = e_utf8_gtk_clist_append (GTK_CLIST(clist), text); gtk_clist_set_row_data_full (GTK_CLIST(clist), row, source, (GtkDestroyNotify) addressbook_source_free); @@ -972,13 +416,14 @@ addressbook_config (GNOME_Evolution_Shell shell) GTK_SIGNAL_FUNC (sources_select_row), dialog); - gtk_signal_connect (GTK_OBJECT (dialog->dialog), "apply", - addressbook_dialog_apply, dialog); + gnome_dialog_button_connect (GNOME_DIALOG(dialog->dialog), + 0 /* OK */, addressbook_dialog_ok, dialog); - gtk_signal_connect (GTK_OBJECT (dialog->dialog), "destroy", - addressbook_dialog_close, dialog); + gnome_dialog_button_connect (GNOME_DIALOG(dialog->dialog), + 1 /* APPLY */, addressbook_dialog_apply, dialog); - gtk_window_set_default_size (GTK_WINDOW (dialog->dialog), 300, 350); + gnome_dialog_button_connect (GNOME_DIALOG(dialog->dialog), + 2 /* CLOSE */, addressbook_dialog_close, dialog); - gtk_widget_show (dialog->dialog); + gnome_dialog_run (GNOME_DIALOG(dialog->dialog)); } diff --git a/addressbook/gui/component/addressbook-config.glade b/addressbook/gui/component/addressbook-config.glade index c327cc04cc..5962fe4193 100644 --- a/addressbook/gui/component/addressbook-config.glade +++ b/addressbook/gui/component/addressbook-config.glade @@ -11,44 +11,725 @@ </project> <widget> - <class>GnomePropertyBox</class> - <name>dialog</name> - <width>460</width> - <height>360</height> + <class>GnomeDialog</class> + <name>add_addressbook</name> + <visible>False</visible> + <title>Add Addressbook</title> + <type>GTK_WINDOW_TOPLEVEL</type> <position>GTK_WIN_POS_NONE</position> <modal>False</modal> + <default_width>417</default_width> + <default_height>332</default_height> <allow_shrink>False</allow_shrink> - <allow_grow>False</allow_grow> + <allow_grow>True</allow_grow> <auto_shrink>False</auto_shrink> + <auto_close>False</auto_close> + <hide_on_close>False</hide_on_close> <widget> - <class>GtkNotebook</class> - <child_name>GnomePropertyBox:notebook</child_name> - <name>notebook1</name> - <can_focus>True</can_focus> - <show_tabs>True</show_tabs> - <show_border>True</show_border> - <tab_pos>GTK_POS_TOP</tab_pos> - <scrollable>False</scrollable> - <tab_hborder>2</tab_hborder> - <tab_vborder>2</tab_vborder> - <popup_enable>False</popup_enable> + <class>GtkVBox</class> + <child_name>GnomeDialog:vbox</child_name> + <name>dialog-vbox1</name> + <homogeneous>False</homogeneous> + <spacing>8</spacing> <child> - <padding>0</padding> + <padding>4</padding> <expand>True</expand> <fill>True</fill> </child> <widget> + <class>GtkHButtonBox</class> + <child_name>GnomeDialog:action_area</child_name> + <name>dialog-action_area1</name> + <layout_style>GTK_BUTTONBOX_END</layout_style> + <spacing>8</spacing> + <child_min_width>85</child_min_width> + <child_min_height>27</child_min_height> + <child_ipad_x>7</child_ipad_x> + <child_ipad_y>0</child_ipad_y> + <child> + <padding>0</padding> + <expand>False</expand> + <fill>True</fill> + <pack>GTK_PACK_END</pack> + </child> + + <widget> + <class>GtkButton</class> + <name>button1</name> + <can_default>True</can_default> + <can_focus>True</can_focus> + <stock_button>GNOME_STOCK_BUTTON_OK</stock_button> + </widget> + + <widget> + <class>GtkButton</class> + <name>button3</name> + <can_default>True</can_default> + <can_focus>True</can_focus> + <stock_button>GNOME_STOCK_BUTTON_CANCEL</stock_button> + </widget> + </widget> + + <widget> + <class>GtkNotebook</class> + <name>notebook2</name> + <can_focus>True</can_focus> + <show_tabs>True</show_tabs> + <show_border>True</show_border> + <tab_pos>GTK_POS_TOP</tab_pos> + <scrollable>False</scrollable> + <tab_hborder>2</tab_hborder> + <tab_vborder>2</tab_vborder> + <popup_enable>False</popup_enable> + <child> + <padding>0</padding> + <expand>True</expand> + <fill>True</fill> + </child> + + <widget> + <class>GtkVBox</class> + <name>vbox1</name> + <border_width>3</border_width> + <homogeneous>False</homogeneous> + <spacing>6</spacing> + + <widget> + <class>GtkLabel</class> + <name>label29</name> + <label>The information below is required in order to add an addressbook. </label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>True</wrap> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + <child> + <padding>0</padding> + <expand>False</expand> + <fill>False</fill> + </child> + </widget> + + <widget> + <class>GtkTable</class> + <name>table1</name> + <border_width>3</border_width> + <rows>3</rows> + <columns>2</columns> + <homogeneous>False</homogeneous> + <row_spacing>3</row_spacing> + <column_spacing>3</column_spacing> + <child> + <padding>0</padding> + <expand>False</expand> + <fill>True</fill> + </child> + + <widget> + <class>GtkLabel</class> + <name>label15</name> + <label>_Account name:</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>False</wrap> + <xalign>0</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + <default_focus_target>account-name-entry</default_focus_target> + <child> + <left_attach>0</left_attach> + <right_attach>1</right_attach> + <top_attach>0</top_attach> + <bottom_attach>1</bottom_attach> + <xpad>0</xpad> + <ypad>0</ypad> + <xexpand>False</xexpand> + <yexpand>False</yexpand> + <xshrink>False</xshrink> + <yshrink>False</yshrink> + <xfill>True</xfill> + <yfill>False</yfill> + </child> + </widget> + + <widget> + <class>GtkEntry</class> + <name>account-name-entry</name> + <can_focus>True</can_focus> + <editable>True</editable> + <text_visible>True</text_visible> + <text_max_length>0</text_max_length> + <text></text> + <child> + <left_attach>1</left_attach> + <right_attach>2</right_attach> + <top_attach>0</top_attach> + <bottom_attach>1</bottom_attach> + <xpad>0</xpad> + <ypad>0</ypad> + <xexpand>True</xexpand> + <yexpand>False</yexpand> + <xshrink>False</xshrink> + <yshrink>False</yshrink> + <xfill>True</xfill> + <yfill>False</yfill> + </child> + </widget> + + <widget> + <class>GtkLabel</class> + <name>label16</name> + <label>_Server name:</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>False</wrap> + <xalign>0</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + <default_focus_target>server-name-entry</default_focus_target> + <child> + <left_attach>0</left_attach> + <right_attach>1</right_attach> + <top_attach>1</top_attach> + <bottom_attach>2</bottom_attach> + <xpad>0</xpad> + <ypad>0</ypad> + <xexpand>False</xexpand> + <yexpand>False</yexpand> + <xshrink>False</xshrink> + <yshrink>False</yshrink> + <xfill>True</xfill> + <yfill>False</yfill> + </child> + </widget> + + <widget> + <class>GtkEntry</class> + <name>server-name-entry</name> + <can_focus>True</can_focus> + <editable>True</editable> + <text_visible>True</text_visible> + <text_max_length>0</text_max_length> + <text></text> + <child> + <left_attach>1</left_attach> + <right_attach>2</right_attach> + <top_attach>1</top_attach> + <bottom_attach>2</bottom_attach> + <xpad>0</xpad> + <ypad>0</ypad> + <xexpand>True</xexpand> + <yexpand>False</yexpand> + <xshrink>False</xshrink> + <yshrink>False</yshrink> + <xfill>True</xfill> + <yfill>False</yfill> + </child> + </widget> + + <widget> + <class>GtkCheckButton</class> + <name>auth-checkbutton</name> + <can_focus>True</can_focus> + <label>_My server requires authentication</label> + <active>False</active> + <draw_indicator>True</draw_indicator> + <child> + <left_attach>0</left_attach> + <right_attach>2</right_attach> + <top_attach>2</top_attach> + <bottom_attach>3</bottom_attach> + <xpad>0</xpad> + <ypad>0</ypad> + <xexpand>False</xexpand> + <yexpand>False</yexpand> + <xshrink>False</xshrink> + <yshrink>False</yshrink> + <xfill>True</xfill> + <yfill>False</yfill> + </child> + </widget> + </widget> + + <widget> + <class>GtkNotebook</class> + <name>basic-notebook</name> + <show_tabs>False</show_tabs> + <show_border>False</show_border> + <tab_pos>GTK_POS_TOP</tab_pos> + <scrollable>False</scrollable> + <tab_hborder>2</tab_hborder> + <tab_vborder>2</tab_vborder> + <popup_enable>False</popup_enable> + <child> + <padding>0</padding> + <expand>True</expand> + <fill>True</fill> + </child> + + <widget> + <class>GtkLabel</class> + <name>label28</name> + <label>This name will be used to identify your account. It is for display purposes only.</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>True</wrap> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + </widget> + + <widget> + <class>GtkLabel</class> + <child_name>Notebook:tab</child_name> + <name>label18</name> + <label>label18</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>False</wrap> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + </widget> + + <widget> + <class>GtkLabel</class> + <name>label31</name> + <label>This is the name of the server where your addressbook is located.</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>True</wrap> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + </widget> + + <widget> + <class>GtkLabel</class> + <child_name>Notebook:tab</child_name> + <name>label19</name> + <label>label19</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>False</wrap> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + </widget> + </widget> + </widget> + + <widget> + <class>GtkLabel</class> + <child_name>Notebook:tab</child_name> + <name>label12</name> + <label>Basic</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>False</wrap> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + </widget> + + <widget> + <class>GtkVBox</class> + <name>vbox2</name> + <border_width>3</border_width> + <homogeneous>False</homogeneous> + <spacing>3</spacing> + + <widget> + <class>GtkLabel</class> + <name>label30</name> + <label>This information is not required for most ldap servers. </label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>True</wrap> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + <child> + <padding>0</padding> + <expand>False</expand> + <fill>False</fill> + </child> + </widget> + + <widget> + <class>GtkTable</class> + <name>table2</name> + <border_width>3</border_width> + <rows>3</rows> + <columns>2</columns> + <homogeneous>False</homogeneous> + <row_spacing>3</row_spacing> + <column_spacing>3</column_spacing> + <child> + <padding>0</padding> + <expand>False</expand> + <fill>False</fill> + </child> + + <widget> + <class>GtkLabel</class> + <name>label22</name> + <label>_Port:</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>False</wrap> + <xalign>0</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + <default_focus_target>port-entry</default_focus_target> + <child> + <left_attach>0</left_attach> + <right_attach>1</right_attach> + <top_attach>0</top_attach> + <bottom_attach>1</bottom_attach> + <xpad>0</xpad> + <ypad>0</ypad> + <xexpand>False</xexpand> + <yexpand>False</yexpand> + <xshrink>False</xshrink> + <yshrink>False</yshrink> + <xfill>True</xfill> + <yfill>False</yfill> + </child> + </widget> + + <widget> + <class>GtkEntry</class> + <name>port-entry</name> + <can_focus>True</can_focus> + <editable>True</editable> + <text_visible>True</text_visible> + <text_max_length>0</text_max_length> + <text>389</text> + <child> + <left_attach>1</left_attach> + <right_attach>2</right_attach> + <top_attach>0</top_attach> + <bottom_attach>1</bottom_attach> + <xpad>0</xpad> + <ypad>0</ypad> + <xexpand>True</xexpand> + <yexpand>False</yexpand> + <xshrink>False</xshrink> + <yshrink>False</yshrink> + <xfill>True</xfill> + <yfill>False</yfill> + </child> + </widget> + + <widget> + <class>GtkLabel</class> + <name>label23</name> + <label>Search _base:</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>False</wrap> + <xalign>0</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + <default_focus_target>rootdn-entry</default_focus_target> + <child> + <left_attach>0</left_attach> + <right_attach>1</right_attach> + <top_attach>1</top_attach> + <bottom_attach>2</bottom_attach> + <xpad>0</xpad> + <ypad>0</ypad> + <xexpand>False</xexpand> + <yexpand>False</yexpand> + <xshrink>False</xshrink> + <yshrink>False</yshrink> + <xfill>True</xfill> + <yfill>False</yfill> + </child> + </widget> + + <widget> + <class>GtkEntry</class> + <name>rootdn-entry</name> + <can_focus>True</can_focus> + <editable>True</editable> + <text_visible>True</text_visible> + <text_max_length>0</text_max_length> + <text></text> + <child> + <left_attach>1</left_attach> + <right_attach>2</right_attach> + <top_attach>1</top_attach> + <bottom_attach>2</bottom_attach> + <xpad>0</xpad> + <ypad>0</ypad> + <xexpand>True</xexpand> + <yexpand>False</yexpand> + <xshrink>False</xshrink> + <yshrink>False</yshrink> + <xfill>True</xfill> + <yfill>False</yfill> + </child> + </widget> + + <widget> + <class>GtkLabel</class> + <name>label24</name> + <label>Search s_cope: </label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>False</wrap> + <xalign>0</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + <child> + <left_attach>0</left_attach> + <right_attach>1</right_attach> + <top_attach>2</top_attach> + <bottom_attach>3</bottom_attach> + <xpad>0</xpad> + <ypad>0</ypad> + <xexpand>False</xexpand> + <yexpand>False</yexpand> + <xshrink>False</xshrink> + <yshrink>False</yshrink> + <xfill>True</xfill> + <yfill>False</yfill> + </child> + </widget> + + <widget> + <class>GtkAlignment</class> + <name>alignment1</name> + <xalign>7.45058e-09</xalign> + <yalign>7.45058e-09</yalign> + <xscale>0</xscale> + <yscale>1</yscale> + <child> + <left_attach>1</left_attach> + <right_attach>2</right_attach> + <top_attach>2</top_attach> + <bottom_attach>3</bottom_attach> + <xpad>0</xpad> + <ypad>0</ypad> + <xexpand>True</xexpand> + <yexpand>False</yexpand> + <xshrink>False</xshrink> + <yshrink>False</yshrink> + <xfill>True</xfill> + <yfill>False</yfill> + </child> + + <widget> + <class>GtkOptionMenu</class> + <name>scope-optionmenu</name> + <can_focus>True</can_focus> + <items>One +Base +Sub +</items> + <initial_choice>0</initial_choice> + </widget> + </widget> + </widget> + + <widget> + <class>GtkNotebook</class> + <name>advanced-notebook</name> + <show_tabs>False</show_tabs> + <show_border>False</show_border> + <tab_pos>GTK_POS_TOP</tab_pos> + <scrollable>False</scrollable> + <tab_hborder>2</tab_hborder> + <tab_vborder>2</tab_vborder> + <popup_enable>False</popup_enable> + <child> + <padding>0</padding> + <expand>True</expand> + <fill>True</fill> + </child> + + <widget> + <class>GtkLabel</class> + <name>label35</name> + <label>This is the port that your ldap server uses.</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>True</wrap> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + </widget> + + <widget> + <class>GtkLabel</class> + <child_name>Notebook:tab</child_name> + <name>label25</name> + <label>label18</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>False</wrap> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + </widget> + + <widget> + <class>GtkLabel</class> + <name>label36</name> + <label>This is the base node for all your searches on the ldap server. Contact your server administrator for more information.</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>True</wrap> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + </widget> + + <widget> + <class>GtkLabel</class> + <child_name>Notebook:tab</child_name> + <name>label26</name> + <label>label19</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>False</wrap> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + </widget> + + <widget> + <class>GtkLabel</class> + <name>label37</name> + <label>This information is used by your ldap server to specify which nodes are used in a search. Contact your server administrator for more information.</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>True</wrap> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + </widget> + + <widget> + <class>GtkLabel</class> + <child_name>Notebook:tab</child_name> + <name>label27</name> + <label>label20</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>False</wrap> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + </widget> + </widget> + </widget> + + <widget> + <class>GtkLabel</class> + <child_name>Notebook:tab</child_name> + <name>label13</name> + <label>Advanced</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>False</wrap> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + </widget> + </widget> + </widget> +</widget> + +<widget> + <class>GnomeDialog</class> + <name>addressbook_sources</name> + <visible>False</visible> + <type>GTK_WINDOW_TOPLEVEL</type> + <position>GTK_WIN_POS_NONE</position> + <modal>False</modal> + <default_width>355</default_width> + <default_height>285</default_height> + <allow_shrink>True</allow_shrink> + <allow_grow>True</allow_grow> + <auto_shrink>False</auto_shrink> + <auto_close>False</auto_close> + <hide_on_close>False</hide_on_close> + + <widget> + <class>GtkVBox</class> + <child_name>GnomeDialog:vbox</child_name> + <name>dialog-vbox2</name> + <homogeneous>False</homogeneous> + <spacing>8</spacing> + <child> + <padding>4</padding> + <expand>True</expand> + <fill>True</fill> + </child> + + <widget> + <class>GtkHButtonBox</class> + <child_name>GnomeDialog:action_area</child_name> + <name>dialog-action_area2</name> + <layout_style>GTK_BUTTONBOX_END</layout_style> + <spacing>8</spacing> + <child_min_width>85</child_min_width> + <child_min_height>27</child_min_height> + <child_ipad_x>7</child_ipad_x> + <child_ipad_y>0</child_ipad_y> + <child> + <padding>0</padding> + <expand>False</expand> + <fill>True</fill> + <pack>GTK_PACK_END</pack> + </child> + + <widget> + <class>GtkButton</class> + <name>button7</name> + <can_default>True</can_default> + <can_focus>True</can_focus> + <stock_button>GNOME_STOCK_BUTTON_OK</stock_button> + </widget> + + <widget> + <class>GtkButton</class> + <name>button8</name> + <can_default>True</can_default> + <can_focus>True</can_focus> + <stock_button>GNOME_STOCK_BUTTON_APPLY</stock_button> + </widget> + + <widget> + <class>GtkButton</class> + <name>button9</name> + <can_default>True</can_default> + <can_focus>True</can_focus> + <stock_button>GNOME_STOCK_BUTTON_CLOSE</stock_button> + </widget> + </widget> + + <widget> <class>GtkHBox</class> - <name>hbox2</name> + <name>hbox3</name> <homogeneous>False</homogeneous> <spacing>0</spacing> + <child> + <padding>0</padding> + <expand>True</expand> + <fill>True</fill> + </child> <widget> <class>GtkScrolledWindow</class> - <name>scrolledwindow1</name> - <hscrollbar_policy>GTK_POLICY_NEVER</hscrollbar_policy> + <name>scrolledwindow2</name> + <hscrollbar_policy>GTK_POLICY_AUTOMATIC</hscrollbar_policy> <vscrollbar_policy>GTK_POLICY_AUTOMATIC</vscrollbar_policy> <hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy> <vupdate_policy>GTK_UPDATE_CONTINUOUS</vupdate_policy> @@ -63,7 +744,7 @@ <name>clistSources</name> <can_focus>True</can_focus> <columns>2</columns> - <column_widths>80,80</column_widths> + <column_widths>100,80</column_widths> <selection_mode>GTK_SELECTION_SINGLE</selection_mode> <show_titles>True</show_titles> <shadow_type>GTK_SHADOW_IN</shadow_type> @@ -71,8 +752,8 @@ <widget> <class>GtkLabel</class> <child_name>CList:title</child_name> - <name>label10</name> - <label>Name</label> + <name>label43</name> + <label>Account Name</label> <justify>GTK_JUSTIFY_CENTER</justify> <wrap>False</wrap> <xalign>0.5</xalign> @@ -84,8 +765,8 @@ <widget> <class>GtkLabel</class> <child_name>CList:title</child_name> - <name>label11</name> - <label>URI</label> + <name>label44</name> + <label>Server Name</label> <justify>GTK_JUSTIFY_CENTER</justify> <wrap>False</wrap> <xalign>0.5</xalign> @@ -97,14 +778,10 @@ </widget> <widget> - <class>GtkVButtonBox</class> - <name>vbuttonbox2</name> - <layout_style>GTK_BUTTONBOX_START</layout_style> - <spacing>10</spacing> - <child_min_width>85</child_min_width> - <child_min_height>27</child_min_height> - <child_ipad_x>7</child_ipad_x> - <child_ipad_y>0</child_ipad_y> + <class>GtkVBox</class> + <name>vbox4</name> + <homogeneous>False</homogeneous> + <spacing>0</spacing> <child> <padding>0</padding> <expand>False</expand> @@ -112,46 +789,67 @@ </child> <widget> - <class>GtkButton</class> - <name>addSource</name> - <can_default>True</can_default> - <can_focus>True</can_focus> - <label>_Add</label> - <relief>GTK_RELIEF_NORMAL</relief> + <class>GtkLabel</class> + <name>label45</name> + <label> +</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>False</wrap> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + <child> + <padding>0</padding> + <expand>False</expand> + <fill>False</fill> + </child> </widget> <widget> - <class>GtkButton</class> - <name>editSource</name> - <can_default>True</can_default> - <can_focus>True</can_focus> - <label>_Edit</label> - <relief>GTK_RELIEF_NORMAL</relief> - </widget> + <class>GtkVButtonBox</class> + <name>vbuttonbox3</name> + <layout_style>GTK_BUTTONBOX_START</layout_style> + <spacing>0</spacing> + <child_min_width>85</child_min_width> + <child_min_height>27</child_min_height> + <child_ipad_x>7</child_ipad_x> + <child_ipad_y>0</child_ipad_y> + <child> + <padding>0</padding> + <expand>True</expand> + <fill>True</fill> + </child> - <widget> - <class>GtkButton</class> - <name>deleteSource</name> - <can_default>True</can_default> - <can_focus>True</can_focus> - <label>De_lete</label> - <relief>GTK_RELIEF_NORMAL</relief> + <widget> + <class>GtkButton</class> + <name>addSource</name> + <can_default>True</can_default> + <can_focus>True</can_focus> + <label>_Add</label> + <relief>GTK_RELIEF_NORMAL</relief> + </widget> + + <widget> + <class>GtkButton</class> + <name>editSource</name> + <can_default>True</can_default> + <can_focus>True</can_focus> + <label>_Edit</label> + <relief>GTK_RELIEF_NORMAL</relief> + </widget> + + <widget> + <class>GtkButton</class> + <name>deleteSource</name> + <can_default>True</can_default> + <can_focus>True</can_focus> + <label>De_lete</label> + <relief>GTK_RELIEF_NORMAL</relief> + </widget> </widget> </widget> </widget> - - <widget> - <class>GtkLabel</class> - <child_name>Notebook:tab</child_name> - <name>label8</name> - <label>Addressbook Sources</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - </widget> </widget> </widget> diff --git a/addressbook/gui/component/addressbook-config.h b/addressbook/gui/component/addressbook-config.h index 95635b8918..980fe2e5eb 100644 --- a/addressbook/gui/component/addressbook-config.h +++ b/addressbook/gui/component/addressbook-config.h @@ -26,6 +26,7 @@ #include "addressbook-storage.h" -void addressbook_config (GNOME_Evolution_Shell shell); +void addressbook_config (GNOME_Evolution_Shell shell); +void addressbook_create_new_source (char *new_source, GtkWidget *parent); #endif /* __ADDRESSBOOK_CONFIG_H__ */ diff --git a/addressbook/gui/component/addressbook-storage.c b/addressbook/gui/component/addressbook-storage.c index 0dc8cd6295..e4bb8e1441 100644 --- a/addressbook/gui/component/addressbook-storage.c +++ b/addressbook/gui/component/addressbook-storage.c @@ -21,29 +21,20 @@ * Author: Chris Toshok */ -/* The ldap server file goes like this: +/* The addressbook-sources.xml file goes like this: <?xml version="1.0"?> <addressbooks> <contactserver> <name>LDAP Server</name> - <description>This is my company address book.</description> <host>ldap.server.com</host> <port>389</port> <rootdn></rootdn> <authmethod>simple</authmethod> - <binddn>cn=Chris Toshok,dc=helixcode,dc=com</binddn> + <emailaddr>toshok@blubag.com</emailaddr> <rememberpass/> </contactserver> - <contactfile> - <name>On Disk Contacts</name> - <description>This is one of my private contact dbs.</description> - <path>/home/toshok/contacts/work-contacts.db</path> - </contactfile> </addressbooks> - - FIXME: Do we want to use a namespace for this? - FIXME: Do we want to have an internationalized description? */ #ifdef HAVE_CONFIG_H @@ -110,14 +101,27 @@ addressbook_storage_setup (EvolutionShellComponent *shell_component, } #ifdef HAVE_LDAP -static void +static int remove_ldap_folder (EvolutionStorage *storage, const CORBA_char *path, const CORBA_char *physical_uri, - int *result, gpointer data) + gpointer data) { addressbook_storage_remove_source (path + 1); addressbook_storage_write_sources(); - *result = GNOME_Evolution_Storage_OK; + return GNOME_Evolution_Storage_OK; +} +static int +create_ldap_folder (EvolutionStorage *storage, + const CORBA_char *path, const CORBA_char *type, + const CORBA_char *description, const CORBA_char *parent_physical_uri, + int *result, gpointer data) +{ + if (strcmp (type, "contacts")) + return GNOME_Evolution_Storage_UNSUPPORTED_TYPE; + + addressbook_create_new_source (path + 1, NULL); + + return GNOME_Evolution_Storage_OK; } #endif @@ -132,6 +136,9 @@ register_storage (void) gtk_signal_connect (GTK_OBJECT (storage), "remove_folder", GTK_SIGNAL_FUNC(remove_ldap_folder), NULL); + gtk_signal_connect (GTK_OBJECT (storage), + "create_folder", + GTK_SIGNAL_FUNC(create_ldap_folder), NULL); result = evolution_storage_register_on_shell (storage, corba_shell); switch (result) { case EVOLUTION_STORAGE_OK: @@ -252,13 +259,9 @@ addressbook_storage_init_source_uri (AddressbookSource *source) if (source->uri) g_free (source->uri); - if (source->type == ADDRESSBOOK_SOURCE_LDAP) - source->uri = g_strdup_printf ("ldap://%s:%s/%s??%s", - source->ldap.host, source->ldap.port, - source->ldap.rootdn, ldap_unparse_scope(source->ldap.scope)); - else - source->uri = g_strdup_printf ("file://%s", - source->file.path); + source->uri = g_strdup_printf ("ldap://%s:%s/%s??%s", + source->host, source->port, + source->rootdn, ldap_unparse_scope(source->scope)); } static gboolean @@ -311,16 +314,12 @@ load_source_data (const char *file_path) if (!strcmp (child->name, "contactserver")) { source->type = ADDRESSBOOK_SOURCE_LDAP; - source->ldap.port = get_string_value (child, "port"); - source->ldap.host = get_string_value (child, "host"); - source->ldap.rootdn = get_string_value (child, "rootdn"); - source->ldap.scope = ldap_parse_scope (get_string_value (child, "scope")); - source->ldap.auth = ldap_parse_auth (get_string_value (child, "authmethod")); - source->ldap.binddn = get_string_value (child, "binddn"); - } - else if (!strcmp (child->name, "contactfile")) { - source->type = ADDRESSBOOK_SOURCE_FILE; - source->file.path = get_string_value (child, "path"); + source->port = get_string_value (child, "port"); + source->host = get_string_value (child, "host"); + source->rootdn = get_string_value (child, "rootdn"); + source->scope = ldap_parse_scope (get_string_value (child, "scope")); + source->auth = ldap_parse_auth (get_string_value (child, "authmethod")); + source->email_addr = get_string_value (child, "emailaddr"); } else { g_warning ("unknown node '%s' in %s", child->name, file_path); @@ -364,53 +363,24 @@ ldap_source_foreach(AddressbookSource *source, xmlNode *root) (xmlChar *) source->description); xmlNewChild (source_root, NULL, (xmlChar *) "port", - (xmlChar *) source->ldap.port); + (xmlChar *) source->port); xmlNewChild (source_root, NULL, (xmlChar *) "host", - (xmlChar *) source->ldap.host); + (xmlChar *) source->host); xmlNewChild (source_root, NULL, (xmlChar *) "rootdn", - (xmlChar *) source->ldap.rootdn); + (xmlChar *) source->rootdn); xmlNewChild (source_root, NULL, (xmlChar *) "scope", - (xmlChar *) ldap_unparse_scope(source->ldap.scope)); + (xmlChar *) ldap_unparse_scope(source->scope)); xmlNewChild (source_root, NULL, (xmlChar *) "authmethod", - (xmlChar *) ldap_unparse_auth(source->ldap.auth)); - if (source->ldap.auth == ADDRESSBOOK_LDAP_AUTH_SIMPLE) { - xmlNewChild (source_root, NULL, (xmlChar *) "binddn", - (xmlChar *) source->ldap.binddn); - if (source->ldap.remember_passwd) + (xmlChar *) ldap_unparse_auth(source->auth)); + if (source->auth == ADDRESSBOOK_LDAP_AUTH_SIMPLE) { + xmlNewChild (source_root, NULL, (xmlChar *) "emailaddr", + (xmlChar *) source->email_addr); + if (source->remember_passwd) xmlNewChild (source_root, NULL, (xmlChar *) "rememberpass", NULL); } } -static void -file_source_foreach (AddressbookSource *source, xmlNode *root) -{ - xmlNode *source_root = xmlNewNode (NULL, - (xmlChar *) "contactfile"); - - xmlAddChild (root, source_root); - - xmlNewChild (source_root, NULL, (xmlChar *) "name", - (xmlChar *) source->name); - xmlNewChild (source_root, NULL, (xmlChar *) "description", - (xmlChar *) source->description); - - xmlNewChild (source_root, NULL, (xmlChar *) "path", - (xmlChar *) source->file.path); -} - -static void -source_foreach(gpointer value, gpointer user_data) -{ - AddressbookSource *source = value; - xmlNode *root = user_data; - - if (source->type == ADDRESSBOOK_SOURCE_LDAP) - ldap_source_foreach(source, root); - else - file_source_foreach(source, root); -} - static gboolean save_source_data (const char *file_path) { @@ -425,7 +395,7 @@ save_source_data (const char *file_path) root = xmlNewDocNode (doc, NULL, (xmlChar *) "addressbooks", NULL); xmlDocSetRootElement (doc, root); - g_list_foreach (sources, source_foreach, root); + g_list_foreach (sources, (GFunc)ldap_source_foreach, root); fd = open (new_path, O_CREAT | O_TRUNC | O_WRONLY, 0600); fchmod (fd, 0600); @@ -532,14 +502,10 @@ addressbook_source_free (AddressbookSource *source) g_free (source->name); g_free (source->description); g_free (source->uri); - if (source->type == ADDRESSBOOK_SOURCE_LDAP) { - g_free (source->ldap.host); - g_free (source->ldap.port); - g_free (source->ldap.rootdn); - g_free (source->ldap.binddn); - } else { - g_free (source->file.path); - } + g_free (source->host); + g_free (source->port); + g_free (source->rootdn); + g_free (source->email_addr); g_free (source); } @@ -582,17 +548,13 @@ addressbook_source_copy (const AddressbookSource *source) copy->type = source->type; copy->uri = g_strdup (source->uri); - if (copy->type == ADDRESSBOOK_SOURCE_LDAP) { - copy->ldap.host = g_strdup (source->ldap.host); - copy->ldap.port = g_strdup (source->ldap.port); - copy->ldap.rootdn = g_strdup (source->ldap.rootdn); - copy->ldap.scope = source->ldap.scope; - copy->ldap.auth = source->ldap.auth; - copy->ldap.binddn = g_strdup (source->ldap.binddn); - copy->ldap.remember_passwd = source->ldap.remember_passwd; - } - else { - copy->file.path = g_strdup (source->file.path); - } + copy->host = g_strdup (source->host); + copy->port = g_strdup (source->port); + copy->rootdn = g_strdup (source->rootdn); + copy->scope = source->scope; + copy->auth = source->auth; + copy->email_addr = g_strdup (source->email_addr); + copy->remember_passwd = source->remember_passwd; + return copy; } diff --git a/addressbook/gui/component/addressbook-storage.h b/addressbook/gui/component/addressbook-storage.h index f2a1910e13..8f260b9d07 100644 --- a/addressbook/gui/component/addressbook-storage.h +++ b/addressbook/gui/component/addressbook-storage.h @@ -49,18 +49,13 @@ typedef struct { AddressbookSourceType type; char *name; char *description; - struct { - char *path; - } file; - struct { - char *host; - char *port; - char *rootdn; - AddressbookLDAPScopeType scope; - AddressbookLDAPAuthType auth; - char *binddn; /* used in AUTH_SIMPLE */ - gboolean remember_passwd; - } ldap; + char *host; + char *port; + char *rootdn; + AddressbookLDAPScopeType scope; + AddressbookLDAPAuthType auth; + char *email_addr; /* used in AUTH_SIMPLE */ + gboolean remember_passwd; char *uri; /* filled in from the above */ } AddressbookSource; diff --git a/addressbook/gui/component/addressbook.c b/addressbook/gui/component/addressbook.c index 04abcd005f..28e7aa6504 100644 --- a/addressbook/gui/component/addressbook.c +++ b/addressbook/gui/component/addressbook.c @@ -374,23 +374,90 @@ book_open_cb (EBook *book, EBookStatus status, gpointer closure) if (source && source->type == ADDRESSBOOK_SOURCE_LDAP && - source->ldap.auth == ADDRESSBOOK_LDAP_AUTH_SIMPLE) { + source->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); - + char *msg = g_strdup_printf (_("Please enter your email address and password for access to %s"), source->name); + GtkWidget *dialog; + GtkWidget *hbox; + GtkWidget *table; + GtkWidget *label; + GtkWidget *email_entry; + GtkWidget *password_entry; + + dialog = gnome_dialog_new (_("LDAP Authentication"), + GNOME_STOCK_BUTTON_OK, + GNOME_STOCK_BUTTON_CANCEL, + NULL); + + label = gtk_label_new (msg); + gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); + gtk_box_pack_start (GTK_BOX (GNOME_DIALOG(dialog)->vbox), label, FALSE, FALSE, 0); + g_free (msg); + + table = gtk_table_new (2, 2, FALSE); + label = gtk_label_new (_("Email Address:")); + gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_RIGHT); + gtk_table_attach (GTK_TABLE (table), label, + 0, 1, + 0, 1, + 0, 0, 0, 3); + email_entry = gtk_entry_new (); + gtk_table_attach (GTK_TABLE (table), email_entry, + 1, 2, + 0, 1, + GTK_EXPAND | GTK_FILL, 0, 0, 3); + + hbox = gtk_hbox_new (FALSE, 2); + label = gtk_label_new (_("Password:")); + gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_RIGHT); + gtk_table_attach (GTK_TABLE (table), label, + 0, 1, + 1, 2, + GTK_FILL, 0, 0, 3); + password_entry = gtk_entry_new (); + gtk_entry_set_visibility (GTK_ENTRY(password_entry), FALSE); + gtk_table_attach (GTK_TABLE (table), password_entry, + 1, 2, + 1, 2, + GTK_EXPAND | GTK_FILL, 0, 0, 3); + + gtk_box_pack_start (GTK_BOX (GNOME_DIALOG(dialog)->vbox), table, TRUE, TRUE, 0); + + gtk_widget_show_all (GNOME_DIALOG(dialog)->vbox); + + /* fill in the saved email address for this source if there is one */ + if (source->email_addr && *source->email_addr) { + e_utf8_gtk_entry_set_text (GTK_ENTRY(email_entry), + source->email_addr); + gtk_window_set_focus (GTK_WINDOW (dialog), + password_entry); + } + else { + gtk_window_set_focus (GTK_WINDOW (dialog), + email_entry); + } + + /* run the dialog */ + gnome_dialog_close_hides (GNOME_DIALOG(dialog), TRUE); button = gnome_dialog_run_and_close (GNOME_DIALOG (dialog)); - if (button == 0 && *(view->passwd)) { - e_book_authenticate_user (book, source->ldap.binddn, view->passwd, + /* and get out the information if the user clicks ok */ + if (button == 0) { + g_free (source->email_addr); + source->email_addr = e_utf8_gtk_entry_get_text (GTK_ENTRY(email_entry)); + addressbook_storage_write_sources(); + view->passwd = e_utf8_gtk_entry_get_text (GTK_ENTRY(password_entry)); + e_book_authenticate_user (book, source->email_addr, view->passwd, book_auth_cb, closure); memset (view->passwd, 0, strlen (view->passwd)); /* clear out the passwd */ g_free (view->passwd); view->passwd = NULL; + gtk_widget_destroy (dialog); return; } + else { + gtk_widget_destroy (dialog); + } } @@ -783,3 +850,4 @@ addressbook_factory_init (void) g_error ("I could not register a Addressbook factory."); } } + |