diff options
author | Chris Toshok <toshok@helixcode.com> | 2000-12-30 13:25:57 +0800 |
---|---|---|
committer | Chris Toshok <toshok@src.gnome.org> | 2000-12-30 13:25:57 +0800 |
commit | c4dfc8669bf21acf8c06cc7f79d0864c8e3d4fab (patch) | |
tree | c8ac453d3b440e00f0de9481441b5c9ad60491aa /addressbook | |
parent | 5e2b0aaf12ece4d701550cfda441eaaa38b89113 (diff) | |
download | gsoc2013-evolution-c4dfc8669bf21acf8c06cc7f79d0864c8e3d4fab.tar.gz gsoc2013-evolution-c4dfc8669bf21acf8c06cc7f79d0864c8e3d4fab.tar.zst gsoc2013-evolution-c4dfc8669bf21acf8c06cc7f79d0864c8e3d4fab.zip |
new function, calling our new config ui code. (control_activate): no
2000-12-29 Chris Toshok <toshok@helixcode.com>
* gui/component/addressbook.c (config_cb): new function, calling
our new config ui code.
(control_activate): no longer load evolution-addressbook-ldap.xml,
as it's not there.
* gui/component/addressbook-component.c (owner_set_cb):
setup_ldap_storage => addressbook_storage_setup.
* gui/component/Makefile.am (evolution_addressbook_SOURCES):
remove e-ldap-storage.[ch] and add addressbook-storage.[ch].
(glade_DATA): remove ldap-server-dialog.glade and add
addressbook-config.glade.
(EXTRA_DIST): same.
* gui/component/addressbook-config.[ch]: add another dialog to
give a list of our sources and offer the Add/Delete/Edit
interface. This plugs into the previous dialog work (the source
editor.)
* gui/component/addressbook-storage.[ch]: new files, containing
the remains of e-ldap-storage.[ch] and adding the new
AddressbookSource type and it's subordinates. Also, the xml
format has changed slightly and the file name is no longer
~/evolution/ldap-servers.xml - it's
~/evolution/addressbook-sources.xml.
* gui/component/addressbook-config.glade: new file, new config
interface.
* gui/component/ldap-server-dialog.glade: removed.
* gui/component/e-ldap-storage.[ch]: removed.
svn path=/trunk/; revision=7198
Diffstat (limited to 'addressbook')
-rw-r--r-- | addressbook/ChangeLog | 35 | ||||
-rw-r--r-- | addressbook/gui/component/Makefile.am | 12 | ||||
-rw-r--r-- | addressbook/gui/component/addressbook-component.c | 6 | ||||
-rw-r--r-- | addressbook/gui/component/addressbook-config.c | 418 | ||||
-rw-r--r-- | addressbook/gui/component/addressbook-config.glade | 158 | ||||
-rw-r--r-- | addressbook/gui/component/addressbook-config.h | 28 | ||||
-rw-r--r-- | addressbook/gui/component/addressbook-storage.c | 521 | ||||
-rw-r--r-- | addressbook/gui/component/addressbook-storage.h | 80 | ||||
-rw-r--r-- | addressbook/gui/component/addressbook.c | 49 | ||||
-rw-r--r-- | addressbook/gui/component/e-ldap-storage.c | 317 | ||||
-rw-r--r-- | addressbook/gui/component/e-ldap-storage.h | 44 | ||||
-rw-r--r-- | addressbook/gui/component/ldap-server-dialog.glade | 400 |
12 files changed, 1186 insertions, 882 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog index e6c5b083b5..9b3df92dbb 100644 --- a/addressbook/ChangeLog +++ b/addressbook/ChangeLog @@ -1,3 +1,38 @@ +2000-12-29 Chris Toshok <toshok@helixcode.com> + + * gui/component/addressbook.c (config_cb): new function, calling + our new config ui code. + (control_activate): no longer load evolution-addressbook-ldap.xml, + as it's not there. + + * gui/component/addressbook-component.c (owner_set_cb): + setup_ldap_storage => addressbook_storage_setup. + + * gui/component/Makefile.am (evolution_addressbook_SOURCES): + remove e-ldap-storage.[ch] and add addressbook-storage.[ch]. + (glade_DATA): remove ldap-server-dialog.glade and add + addressbook-config.glade. + (EXTRA_DIST): same. + + * gui/component/addressbook-config.[ch]: add another dialog to + give a list of our sources and offer the Add/Delete/Edit + interface. This plugs into the previous dialog work (the source + editor.) + + * gui/component/addressbook-storage.[ch]: new files, containing + the remains of e-ldap-storage.[ch] and adding the new + AddressbookSource type and it's subordinates. Also, the xml + format has changed slightly and the file name is no longer + ~/evolution/ldap-servers.xml - it's + ~/evolution/addressbook-sources.xml. + + * gui/component/addressbook-config.glade: new file, new config + interface. + + * gui/component/ldap-server-dialog.glade: removed. + + * gui/component/e-ldap-storage.[ch]: removed. + 2000-12-28 Chris Toshok <toshok@helixcode.com> * gui/component/Makefile.am (evolution_addressbook_SOURCES): add diff --git a/addressbook/gui/component/Makefile.am b/addressbook/gui/component/Makefile.am index 4b13a297f2..b4f5bd1a09 100644 --- a/addressbook/gui/component/Makefile.am +++ b/addressbook/gui/component/Makefile.am @@ -31,14 +31,12 @@ evolution_addressbook_SOURCES = \ addressbook-config.c \ addressbook-config.h \ addressbook-factory.c \ + addressbook-storage.c \ + addressbook-storage.h \ addressbook.c \ addressbook.h \ e-cardlist-model.c \ - e-cardlist-model.h \ - e-ldap-server-dialog.c \ - e-ldap-server-dialog.h \ - e-ldap-storage.c \ - e-ldap-storage.h + e-cardlist-model.h evolution_addressbook_LDADD = \ select-names/libeselectnames.la \ @@ -63,12 +61,12 @@ oafdir = $(datadir)/oaf oaf_DATA = GNOME_Evolution_Addressbook.oafinfo gladedir = $(datadir)/evolution/glade -glade_DATA = ldap-server-dialog.glade +glade_DATA = addressbook-config.glade EXTRA_DIST = \ $(glade_DATA) \ $(oaf_DATA) \ - ldap-server-dialog.glade.h + addressbook-config.glade if ENABLE_PURIFY PLINK = $(LIBTOOL) --mode=link $(PURIFY) $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ diff --git a/addressbook/gui/component/addressbook-component.c b/addressbook/gui/component/addressbook-component.c index 8e9b506634..209c965e8d 100644 --- a/addressbook/gui/component/addressbook-component.c +++ b/addressbook/gui/component/addressbook-component.c @@ -30,9 +30,9 @@ #include "evolution-shell-component.h" #include "evolution-storage.h" +#include "addressbook-storage.h" #include "addressbook-component.h" #include "addressbook.h" -#include "e-ldap-storage.h" @@ -84,8 +84,8 @@ owner_set_cb (EvolutionShellComponent *shell_component, if (global_shell_client == NULL) global_shell_client = shell_client; - - setup_ldap_storage (shell_component, evolution_homedir); + + addressbook_storage_setup (shell_component, evolution_homedir); } static void diff --git a/addressbook/gui/component/addressbook-config.c b/addressbook/gui/component/addressbook-config.c index 5cf672912f..57e21340c7 100644 --- a/addressbook/gui/component/addressbook-config.c +++ b/addressbook/gui/component/addressbook-config.c @@ -4,27 +4,11 @@ #include <gnome.h> #include <gtkhtml/gtkhtml.h> +#include <glade/glade.h> #include <gal/widgets/e-unicode.h> #include "e-util/e-html-utils.h" - -typedef enum { - ADDRESSBOOK_SOURCE_FILE, -#if HAVE_LDAP - ADDRESSBOOK_SOURCE_LDAP, -#endif - ADDRESSBOOK_SOURCE_LAST -} AddressbookSourceType; - -#if HAVE_LDAP -typedef enum { - LDAP_AUTH_NONE, - LDAP_AUTH_SIMPLE, -#if LDAP_SASL - LDAP_AUTH_SASL, -#endif - LDAP_AUTH_LAST -} LDAPAuthType; -#endif +#include "addressbook-config.h" +#include "addressbook-storage.h" typedef struct _AddressbookSourceDialog AddressbookSourceDialog; typedef struct _AddressbookSourcePageItem AddressbookSourcePageItem; @@ -38,7 +22,12 @@ struct _AddressbookSourceDialog { GtkWidget *source_option; GtkWidget *notebook; - AddressbookSourcePageItem *source; + 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 { @@ -59,17 +48,18 @@ struct _AddressbookSourcePageItem { GtkWidget *host; GtkWidget *port; GtkWidget *rootdn; + GtkWidget *scope_optionmenu; GtkWidget *auth_optionmenu; GtkWidget *auth_notebook; + GList *auths; LDAPAuthPageItem *auth; }; -#if HAVE_LDAP struct _LDAPAuthPageItem { gint pnum; - LDAPAuthType auth_type; + AddressbookLDAPAuthType auth_type; AddressbookSourceDialog *dialog; AddressbookSourcePageItem *page; @@ -81,7 +71,6 @@ struct _LDAPAuthPageItem { GtkWidget *binddn; GtkWidget *remember_passwd; }; -#endif static void html_size_req (GtkWidget *widget, GtkRequisition *requisition) @@ -146,10 +135,8 @@ static const char * addressbook_config_source_label (AddressbookSourceType type) { switch (type) { -#if HAVE_LDAP case ADDRESSBOOK_SOURCE_LDAP: return _("LDAP Server"); -#endif case ADDRESSBOOK_SOURCE_FILE: return _("File"); default: @@ -158,34 +145,46 @@ addressbook_config_source_label (AddressbookSourceType type) } } -#if HAVE_LDAP static const char * -addressbook_config_auth_label (AddressbookSourceType type) +addressbook_config_auth_label (AddressbookLDAPAuthType type) { switch (type) { - case LDAP_AUTH_NONE: + case ADDRESSBOOK_LDAP_AUTH_NONE: return _("None (anonymous mode)"); - case LDAP_AUTH_SIMPLE: + case ADDRESSBOOK_LDAP_AUTH_SIMPLE: return _("Password"); -#if LDAP_SASL - case LDAP_AUTH_SASL: + case ADDRESSBOOK_LDAP_AUTH_SASL: return _("SASL"); -#endif default: g_assert(0); return _("Unknown auth type"); } } -#endif + +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 = dialog->source; + AddressbookSourcePageItem *source_page = dialog->source_page; - if (source == NULL) + if (source_page == NULL) complete = FALSE; if (complete) { @@ -196,25 +195,24 @@ addressbook_source_edit_changed (GtkWidget *item, AddressbookSourceDialog *dialo } if (complete) { - if (source->source_type == ADDRESSBOOK_SOURCE_FILE) { + if (source_page->source_type == ADDRESSBOOK_SOURCE_FILE) { if (complete) { - data = e_utf8_gtk_editable_get_chars (GTK_EDITABLE (source->path), 0, -1); + data = e_utf8_gtk_editable_get_chars (GTK_EDITABLE (source_page->path), 0, -1); if (!data || !*data) complete = FALSE; g_free (data); } } -#if HAVE_LDAP else { if (complete) { - data = e_utf8_gtk_editable_get_chars (GTK_EDITABLE (source->host), 0, -1); + 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->port), 0, -1); + 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 */ @@ -222,26 +220,23 @@ addressbook_source_edit_changed (GtkWidget *item, AddressbookSourceDialog *dialo } if (complete) { - LDAPAuthPageItem *auth_page = source->auth; + LDAPAuthPageItem *auth_page = source_page->auth; - if (auth_page->auth_type == LDAP_AUTH_SIMPLE) { + 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); } -#ifdef LDAP_SASL - else if (auth_page->auth_type == LDAP_AUTH_SASL) { + else if (auth_page->auth_type == ADDRESSBOOK_LDAP_AUTH_SASL) { } -#endif - data = e_utf8_gtk_editable_get_chars (GTK_EDITABLE (source->port), 0, -1); + 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); } } -#endif } gnome_dialog_set_sensitive (GNOME_DIALOG (dialog->dialog), 0, complete); @@ -253,7 +248,7 @@ 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 = sitem; + sitem->dialog->source_page = sitem; addressbook_source_edit_changed (item, sitem->dialog); } @@ -279,8 +274,6 @@ table_add_elem (AddressbookSourceDialog *dialog, GtkWidget *table, return entry; } -#if HAVE_LDAP - static void ldap_auth_type_menuitem_activate (GtkWidget *item, gpointer data) { @@ -296,7 +289,7 @@ ldap_auth_type_menuitem_activate (GtkWidget *item, gpointer data) static LDAPAuthPageItem * addressbook_ldap_auth_item_new (AddressbookSourceDialog *dialog, AddressbookSourcePageItem *page, - LDAPAuthType type) + AddressbookLDAPAuthType type) { LDAPAuthPageItem *item = g_new0 (LDAPAuthPageItem, 1); GtkWidget *table = NULL; @@ -309,9 +302,9 @@ addressbook_ldap_auth_item_new (AddressbookSourceDialog *dialog, item->vbox = gtk_vbox_new (FALSE, 0); switch (type) { - case LDAP_AUTH_NONE: + case ADDRESSBOOK_LDAP_AUTH_NONE: break; - case LDAP_AUTH_SIMPLE: + case ADDRESSBOOK_LDAP_AUTH_SIMPLE: table = gtk_table_new (2, 2, FALSE); item->binddn = table_add_elem (dialog, table, row++, _("Bind DN:")); @@ -323,10 +316,8 @@ addressbook_ldap_auth_item_new (AddressbookSourceDialog *dialog, gtk_box_pack_start (GTK_BOX (item->vbox), table, TRUE, TRUE, 0); break; -#if LDAP_SASL - case LDAP_AUTH_SASL: + case ADDRESSBOOK_LDAP_AUTH_SASL: break; -#endif default: g_assert (0); return item; @@ -342,7 +333,6 @@ addressbook_ldap_auth_item_new (AddressbookSourceDialog *dialog, return item; } -#endif static AddressbookSourcePageItem * addressbook_source_item_new (AddressbookSourceDialog *dialog, AddressbookSourceType type) @@ -358,7 +348,6 @@ addressbook_source_item_new (AddressbookSourceDialog *dialog, AddressbookSourceT item->vbox = gtk_vbox_new (FALSE, 0); switch (type) { -#if HAVE_LDAP case ADDRESSBOOK_SOURCE_LDAP: { GtkWidget *label; GtkWidget *menu; @@ -374,6 +363,37 @@ addressbook_source_item_new (AddressbookSourceDialog *dialog, AddressbookSourceT item->rootdn = table_add_elem (dialog, table, row++, _("Root DN:")); + 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++; + gtk_box_pack_start (GTK_BOX (item->vbox), table, TRUE, FALSE, 0); @@ -383,11 +403,18 @@ addressbook_source_item_new (AddressbookSourceDialog *dialog, AddressbookSourceT item->auth_notebook = gtk_notebook_new(); gtk_notebook_set_show_tabs (GTK_NOTEBOOK (item->auth_notebook), FALSE); - for (i = 0; i < LDAP_AUTH_LAST; i++) { + for (i = 0; i < ADDRESSBOOK_LDAP_AUTH_LAST; i++) { LDAPAuthPageItem *auth_item; +#ifndef LDAP_SASL + /* skip the sasl stuff if we're not configured for it. */ + if (i == ADDRESSBOOK_LDAP_AUTH_SASL) + continue; +#endif 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; @@ -423,7 +450,6 @@ addressbook_source_item_new (AddressbookSourceDialog *dialog, AddressbookSourceT TRUE, TRUE, 0); break; } -#endif case ADDRESSBOOK_SOURCE_FILE: { table = gtk_table_new (2, 2, FALSE); item->path = table_add_elem (dialog, table, row++, _("Path:")); @@ -451,12 +477,83 @@ addressbook_source_item_new (AddressbookSourceDialog *dialog, AddressbookSourceT } static void -addressbook_source_ok_clicked (GtkWidget *widget, AddressbookSourceDialog *sdialog) +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); + + 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); + } + else { + e_utf8_gtk_entry_set_text (GTK_ENTRY (source_page->path), source->file.path); + } +} + +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); + } + + addressbook_storage_init_source_uri (source); + + return source; +} + +static void +addressbook_source_dialog_ok_clicked (GtkWidget *widget, AddressbookSourceDialog *dialog) { + dialog->source = addressbook_source_dialog_get_source (dialog); } static AddressbookSourceDialog* -addressbook_source_dialog (GtkWidget *parent) +addressbook_source_dialog (AddressbookSource *source, GtkWidget *parent) { GtkWidget *html; GtkWidget *table; @@ -468,7 +565,10 @@ addressbook_source_dialog (GtkWidget *parent) int i; int row = 0; - dialog->dialog = gnome_dialog_new (_("Add Addressbook"), NULL); + if (source) + dialog->dialog = gnome_dialog_new (_("Edit Addressbook"), NULL); + else + dialog->dialog = gnome_dialog_new (_("Add Addressbook"), NULL); gtk_window_set_modal (GTK_WINDOW (dialog->dialog), TRUE); gtk_window_set_policy (GTK_WINDOW (dialog->dialog), @@ -507,6 +607,8 @@ addressbook_source_dialog (GtkWidget *parent) item = addressbook_source_item_new (dialog, i); + dialog->source_pages = g_list_append (dialog->source_pages, item); + item->item = gtk_menu_item_new_with_label (addressbook_config_source_label (i)); if (!first_item) @@ -560,19 +662,201 @@ addressbook_source_dialog (GtkWidget *parent) gnome_dialog_set_default (GNOME_DIALOG (dialog->dialog), 0); + /* fill in source info if there is some */ + if (source) + addressbook_source_dialog_set_source (dialog, source); + gnome_dialog_set_sensitive (GNOME_DIALOG (dialog->dialog), 0, FALSE); gnome_dialog_button_connect( GNOME_DIALOG (dialog->dialog), 0, - GTK_SIGNAL_FUNC (addressbook_source_ok_clicked), + GTK_SIGNAL_FUNC (addressbook_source_dialog_ok_clicked), dialog); return dialog; } +static AddressbookSourceDialog * +addressbook_config_source (AddressbookSource *source, GtkWidget *parent) +{ + AddressbookSourceDialog* dialog = addressbook_source_dialog (source, parent); + + dialog->id = gnome_dialog_run_and_close (GNOME_DIALOG (dialog->dialog)); + + return dialog; +} + + + +typedef struct { + GladeXML *gui; + GNOME_Evolution_Shell shell; + GtkWidget *dialog; + GtkWidget *clistSources; + GtkWidget *addSource; + GtkWidget *editSource; + GtkWidget *deleteSource; + gint source_row; +} AddressbookDialog; + +static void +update_sensitivity (AddressbookDialog *dialog) +{ + gboolean sensitive = dialog->source_row != -1; + + gtk_widget_set_sensitive (dialog->editSource, sensitive); + gtk_widget_set_sensitive (dialog->deleteSource, sensitive); +} + +static void +add_source_clicked (GtkWidget *widget, AddressbookDialog *dialog) +{ + AddressbookSourceDialog *sdialog; + + sdialog = addressbook_config_source (NULL, dialog->dialog); + if (sdialog->id == 0) { + /* Ok was clicked */ + AddressbookSource *source = sdialog->source; + gint row; + gchar *text[2]; + + text[0] = source->name; + text[1] = source->uri; + + 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)); + update_sensitivity (dialog); + } +} + +static void +edit_source_clicked (GtkWidget *widget, AddressbookDialog *dialog) +{ + AddressbookSource *source; + AddressbookSourceDialog *sdialog; + + source = gtk_clist_get_row_data (GTK_CLIST (dialog->clistSources), dialog->source_row); + + sdialog = addressbook_config_source (source, dialog->dialog); + if (sdialog->id == 0) { + /* Ok was clicked */ + source = sdialog->source; + e_utf8_gtk_clist_set_text (GTK_CLIST (dialog->clistSources), dialog->source_row, 0, source->uri); + gtk_clist_set_row_data (GTK_CLIST (dialog->clistSources), dialog->source_row, source); + gnome_property_box_changed (GNOME_PROPERTY_BOX (dialog->dialog)); + update_sensitivity (dialog); + } +} + +static void +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)); + update_sensitivity (dialog); +} + +static void +sources_select_row (GtkWidget *widget, gint row, gint column, + GdkEventButton *event, AddressbookDialog *dialog) +{ + dialog->source_row = row; + + update_sensitivity (dialog); +} + +static void +addressbook_dialog_apply (GnomePropertyBox *property_box, gint page_num, AddressbookDialog *dialog) +{ + int i; + + if (page_num != -1) + return; + + addressbook_storage_clear_sources(); + + for (i = 0; i < GTK_CLIST(dialog->clistSources)->rows; i ++) { + AddressbookSource *source = (AddressbookSource*)gtk_clist_get_row_data (GTK_CLIST (dialog->clistSources), i); + addressbook_storage_add_source (addressbook_source_copy (source)); + } +} + +static void +addressbook_dialog_close (GnomePropertyBox *property_box, AddressbookDialog *dialog) +{ + gtk_object_unref (GTK_OBJECT (dialog->gui)); + /* more stuff dude */ + g_free (dialog); +} + void -addressbook_config_source () +addressbook_config (GNOME_Evolution_Shell shell) { - AddressbookSourceDialog* dialog = addressbook_source_dialog (NULL); + AddressbookDialog *dialog; + GladeXML *gui; + GtkWidget *clist; + GList *l; + + dialog = g_new0 (AddressbookDialog, 1); + + dialog->source_row = -1; + + gui = glade_xml_new (EVOLUTION_GLADEDIR "/addressbook-config.glade", NULL); + dialog->gui = gui; + dialog->shell = shell; + + dialog->dialog = glade_xml_get_widget (gui, "dialog"); + + clist = glade_xml_get_widget (gui, "clistSources"); + dialog->clistSources = clist; + + gtk_clist_column_titles_passive (GTK_CLIST (clist)); + gtk_clist_set_column_width (GTK_CLIST (clist), 0, 80); + + dialog->addSource = glade_xml_get_widget (gui, "addSource"); + gtk_signal_connect (GTK_OBJECT(dialog->addSource), "clicked", + GTK_SIGNAL_FUNC (add_source_clicked), + dialog); + + dialog->editSource = glade_xml_get_widget (gui, "editSource"); + gtk_signal_connect (GTK_OBJECT(dialog->editSource), "clicked", + GTK_SIGNAL_FUNC (edit_source_clicked), + dialog); + + dialog->deleteSource = glade_xml_get_widget (gui, "deleteSource"); + gtk_signal_connect (GTK_OBJECT(dialog->deleteSource), "clicked", + GTK_SIGNAL_FUNC (delete_source_clicked), + dialog); + + update_sensitivity (dialog); + + l = addressbook_storage_get_sources (); + for (; l != NULL; l = l->next) { + AddressbookSource *source; + gint row; + gchar *text[2]; + + source = addressbook_source_copy ((AddressbookSource*)l->data); + + text[0] = source->name; + text[1] = source->uri; + + 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); + } + + gtk_signal_connect (GTK_OBJECT (clist), "select_row", + GTK_SIGNAL_FUNC (sources_select_row), + dialog); + + gtk_signal_connect (GTK_OBJECT (dialog->dialog), "apply", + addressbook_dialog_apply, dialog); + + gtk_signal_connect (GTK_OBJECT (dialog->dialog), "destroy", + addressbook_dialog_close, dialog); + + gtk_window_set_default_size (GTK_WINDOW (dialog->dialog), 300, 350); - gnome_dialog_run_and_close (GNOME_DIALOG (dialog->dialog)); + gtk_widget_show (dialog->dialog); } diff --git a/addressbook/gui/component/addressbook-config.glade b/addressbook/gui/component/addressbook-config.glade new file mode 100644 index 0000000000..9194a27c5d --- /dev/null +++ b/addressbook/gui/component/addressbook-config.glade @@ -0,0 +1,158 @@ +<?xml version="1.0"?> +<GTK-Interface> + +<project> + <directory></directory> + <source_directory>src</source_directory> + <pixmaps_directory>pixmaps</pixmaps_directory> + <language>C</language> + <gnome_support>True</gnome_support> + <gettext_support>True</gettext_support> +</project> + +<widget> + <class>GnomePropertyBox</class> + <name>dialog</name> + <width>460</width> + <height>360</height> + <position>GTK_WIN_POS_NONE</position> + <modal>False</modal> + <allow_shrink>False</allow_shrink> + <allow_grow>False</allow_grow> + <auto_shrink>False</auto_shrink> + + <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> + <child> + <padding>0</padding> + <expand>True</expand> + <fill>True</fill> + </child> + + <widget> + <class>GtkHBox</class> + <name>hbox2</name> + <homogeneous>False</homogeneous> + <spacing>0</spacing> + + <widget> + <class>GtkScrolledWindow</class> + <name>scrolledwindow1</name> + <hscrollbar_policy>GTK_POLICY_NEVER</hscrollbar_policy> + <vscrollbar_policy>GTK_POLICY_AUTOMATIC</vscrollbar_policy> + <hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy> + <vupdate_policy>GTK_UPDATE_CONTINUOUS</vupdate_policy> + <child> + <padding>0</padding> + <expand>True</expand> + <fill>True</fill> + </child> + + <widget> + <class>GtkCList</class> + <name>clistSources</name> + <can_focus>True</can_focus> + <columns>2</columns> + <column_widths>80,80</column_widths> + <selection_mode>GTK_SELECTION_SINGLE</selection_mode> + <show_titles>True</show_titles> + <shadow_type>GTK_SHADOW_IN</shadow_type> + + <widget> + <class>GtkLabel</class> + <child_name>CList:title</child_name> + <name>label10</name> + <label>Name</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> + <child_name>CList:title</child_name> + <name>label11</name> + <label>URI</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>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> + <child> + <padding>0</padding> + <expand>False</expand> + <fill>False</fill> + </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> + </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>Delete</label> + <relief>GTK_RELIEF_NORMAL</relief> + </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> + +</GTK-Interface> diff --git a/addressbook/gui/component/addressbook-config.h b/addressbook/gui/component/addressbook-config.h index f21e8cfebb..51fe555f00 100644 --- a/addressbook/gui/component/addressbook-config.h +++ b/addressbook/gui/component/addressbook-config.h @@ -1,3 +1,31 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* addressbook-storage.h + * + * Copyright (C) 2000 Helix Code, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Author: Chris Toshok + */ +#ifndef __ADDRESSBOOK_CONFIG_H__ +#define __ADDRESSBOOK_CONFIG_H__ +#include "addressbook-storage.h" + +void addressbook_config (GNOME_Evolution_Shell shell); + +#endif /* __ADDRESSBOOK_CONFIG_H__ */ diff --git a/addressbook/gui/component/addressbook-storage.c b/addressbook/gui/component/addressbook-storage.c new file mode 100644 index 0000000000..af4613b9a2 --- /dev/null +++ b/addressbook/gui/component/addressbook-storage.c @@ -0,0 +1,521 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-ldap-storage.c + * + * Copyright (C) 2000 Helix Code, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Author: Chris Toshok + */ + +/* The ldap server 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> + <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 +#include <config.h> +#endif + +#include <bonobo.h> + +#include "evolution-shell-component.h" +#include "evolution-storage.h" + +#include <gnome-xml/parser.h> +#include <gnome-xml/xmlmemory.h> + +#include "addressbook-storage.h" + +#include <gal/util/e-util.h> +#include <gal/util/e-xml-utils.h> + +#include <sys/types.h> +#include <sys/fcntl.h> +#include <sys/stat.h> +#include <errno.h> + +#define ADDRESSBOOK_SOURCES_XML "addressbook-sources.xml" + +static gboolean load_source_data (EvolutionStorage *storage, const char *file_path); +static gboolean save_source_data (const char *file_path); + +GList *sources; +EvolutionStorage *storage; +static char *storage_path; + +void +addressbook_storage_setup (EvolutionShellComponent *shell_component, + const char *evolution_homedir) +{ + EvolutionShellClient *shell_client; + GNOME_Evolution_Shell corba_shell; + + shell_client = evolution_shell_component_get_owner (shell_component); + if (shell_client == CORBA_OBJECT_NIL) { + g_warning ("We have no shell!?"); + return; + } + + corba_shell = bonobo_object_corba_objref (BONOBO_OBJECT (shell_client)); + + storage = evolution_storage_new (_("Other Contacts"), NULL, NULL); + if (evolution_storage_register_on_shell (storage, corba_shell) != EVOLUTION_STORAGE_OK) { + g_warning ("Cannot register storage"); + return; + } + + sources = NULL; + + gtk_object_set_data (GTK_OBJECT (shell_component), "e-storage", storage); + + if (storage_path) + g_free (storage_path); + storage_path = g_strdup_printf ("%s/" ADDRESSBOOK_SOURCES_XML, evolution_homedir); + load_source_data (storage, storage_path); +} + +static char * +get_string_value (xmlNode *node, + const char *name) +{ + xmlNode *p; + xmlChar *xml_string; + char *retval; + + p = e_xml_get_child_by_name (node, (xmlChar *) name); + if (p == NULL) + return NULL; + + p = e_xml_get_child_by_name (p, (xmlChar *) "text"); + if (p == NULL) /* there's no text between the tags, return the empty string */ + return g_strdup(""); + + xml_string = xmlNodeListGetString (node->doc, p, 1); + retval = g_strdup ((char *) xml_string); + xmlFree (xml_string); + + return retval; +} + +static char * +ldap_unparse_auth (AddressbookLDAPAuthType auth_type) +{ + switch (auth_type) { + case ADDRESSBOOK_LDAP_AUTH_NONE: + return "none"; + case ADDRESSBOOK_LDAP_AUTH_SIMPLE: + return "simple"; + case ADDRESSBOOK_LDAP_AUTH_SASL: + return "sasl"; + default: + g_assert(0); + return "none"; + } +} + +static AddressbookLDAPAuthType +ldap_parse_auth (const char *auth) +{ + if (!auth) + return ADDRESSBOOK_LDAP_AUTH_NONE; + + if (!strcmp (auth, "simple")) + return ADDRESSBOOK_LDAP_AUTH_SIMPLE; + else if (!strcmp (auth, "sasl")) + return ADDRESSBOOK_LDAP_AUTH_SASL; + else + return ADDRESSBOOK_LDAP_AUTH_NONE; +} + +static char * +ldap_unparse_scope (AddressbookLDAPScopeType scope_type) +{ + switch (scope_type) { + case ADDRESSBOOK_LDAP_SCOPE_BASE: + return "base"; + case ADDRESSBOOK_LDAP_SCOPE_ONELEVEL: + return "one"; + case ADDRESSBOOK_LDAP_SCOPE_SUBTREE: + return "sub"; + default: + g_assert(0); + return ""; + } +} + +static AddressbookLDAPScopeType +ldap_parse_scope (const char *scope) +{ + if (!scope) + return ADDRESSBOOK_LDAP_SCOPE_SUBTREE; /* XXX good default? */ + + if (!strcmp (scope, "base")) + return ADDRESSBOOK_LDAP_SCOPE_BASE; + else if (!strcmp (scope, "one")) + return ADDRESSBOOK_LDAP_SCOPE_ONELEVEL; + else + return ADDRESSBOOK_LDAP_SCOPE_SUBTREE; +} + +void +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); +} + +static gboolean +load_source_data (EvolutionStorage *storage, + const char *file_path) +{ + xmlDoc *doc; + xmlNode *root; + xmlNode *child; + + tryagain: + doc = xmlParseFile (file_path); + if (doc == NULL) { + /* check to see if a ldapserver.xml.new file is + there. if it is, rename it and run with it */ + char *new_path = g_strdup_printf ("%s.new", file_path); + struct stat sb; + + if (stat (new_path, &sb) == 0) { + int rv; + + rv = rename (new_path, file_path); + g_free (new_path); + + if (0 > rv) { + g_error ("Failed to rename %s: %s\n", + ADDRESSBOOK_SOURCES_XML, + strerror(errno)); + return FALSE; + } + else { + goto tryagain; + } + } + + g_free (new_path); + return TRUE; + } + + root = xmlDocGetRootElement (doc); + if (root == NULL || strcmp (root->name, "addressbooks") != 0) { + xmlFreeDoc (doc); + return FALSE; + } + + for (child = root->childs; child; child = child->next) { + char *path; + AddressbookSource *source; + + source = g_new0 (AddressbookSource, 1); + + 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"); + } + else { + g_warning ("unknown node '%s' in %s", child->name, file_path); + g_free (source); + continue; + } + + addressbook_storage_init_source_uri (source); + + source->name = get_string_value (child, "name"); + source->description = get_string_value (child, "description"); + + path = g_strdup_printf ("/%s", source->name); + evolution_storage_new_folder (storage, path, source->name, + "contacts", source->uri, + source->description, FALSE); + + sources = g_list_append (sources, source); + + g_free (path); + } + + xmlFreeDoc (doc); + + return TRUE; +} + +static void +ldap_source_foreach(AddressbookSource *source, xmlNode *root) +{ + xmlNode *source_root = xmlNewNode (NULL, + (xmlChar *) "contactserver"); + + 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 *) "port", + (xmlChar *) source->ldap.port); + xmlNewChild (source_root, NULL, (xmlChar *) "host", + (xmlChar *) source->ldap.host); + xmlNewChild (source_root, NULL, (xmlChar *) "rootdn", + (xmlChar *) source->ldap.rootdn); + xmlNewChild (source_root, NULL, (xmlChar *) "scope", + (xmlChar *) ldap_unparse_scope(source->ldap.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) + xmlNewChild (source_root, NULL, (xmlChar *) "rememberpass", + NULL); + } +} + +static void +file_source_foreach (AddressbookSource *source, xmlNode *root) +{ + xmlNode *source_root = xmlNewNode (NULL, + (xmlChar *) "contactserver"); + + 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) +{ + xmlDoc *doc; + xmlNode *root; + int fd, rv; + xmlChar *buf; + int buf_size; + char *new_path = g_strdup_printf ("%s.new", file_path); + + doc = xmlNewDoc ((xmlChar *) "1.0"); + root = xmlNewDocNode (doc, NULL, (xmlChar *) "addressbooks", NULL); + xmlDocSetRootElement (doc, root); + + g_list_foreach (sources, source_foreach, root); + + fd = open (new_path, O_CREAT | O_TRUNC | O_WRONLY, 0600); + fchmod (fd, 0600); + + xmlDocDumpMemory (doc, &buf, &buf_size); + + if (buf == NULL) { + g_error ("Failed to write %s: xmlBufferCreate() == NULL", ADDRESSBOOK_SOURCES_XML); + return FALSE; + } + + rv = write (fd, buf, buf_size); + xmlFree (buf); + close (fd); + + if (0 > rv) { + g_error ("Failed to write new %s: %s\n", ADDRESSBOOK_SOURCES_XML, strerror(errno)); + unlink (new_path); + return FALSE; + } + else { + if (0 > rename (new_path, file_path)) { + g_error ("Failed to rename %s: %s\n", ADDRESSBOOK_SOURCES_XML, strerror(errno)); + unlink (new_path); + return FALSE; + } + return TRUE; + } +} + +void +addressbook_storage_add_source (AddressbookSource *source) +{ + char *path; + + sources = g_list_append (sources, source); + + /* and then to the ui */ + path = g_strdup_printf ("/%s", source->name); + evolution_storage_new_folder (storage, path, source->name, "contacts", + source->uri, source->description, FALSE); + + g_free (path); + + save_source_data (storage_path); +} + +void +addressbook_storage_remove_source (const char *name) +{ + char *path; + AddressbookSource *source = NULL; + GList *l; + + /* remove it from our hashtable */ + for (l = sources; l; l = l->next) { + AddressbookSource *s = l->data; + if (!strcmp (s->name, name)) { + source = s; + break; + } + } + + if (!source) + return; + + sources = g_list_remove_link (sources, l); + g_list_free_1 (l); + + addressbook_source_free (source); + + /* and then from the ui */ + path = g_strdup_printf ("/%s", name); + evolution_storage_removed_folder (storage, path); + + g_free (path); + + save_source_data (storage_path); +} + +GList * +addressbook_storage_get_sources () +{ + return sources; +} + +void +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); + } + else { + g_free (source->file.path); + } + + g_free (source); +} + +static void +addressbook_source_foreach (AddressbookSource *source, gpointer data) +{ + char *path = g_strdup_printf ("/%s", source->name); + + evolution_storage_removed_folder (storage, path); + + g_free (path); + + addressbook_source_free (source); +} + +void +addressbook_storage_clear_sources () +{ + g_list_foreach (sources, (GFunc)addressbook_source_foreach, NULL); + g_list_free (sources); + sources = NULL; +} + +AddressbookSource * +addressbook_source_copy (const AddressbookSource *source) +{ + AddressbookSource *copy; + + copy = g_new0 (AddressbookSource, 1); + copy->name = g_strdup (source->name); + copy->description = g_strdup (source->description); + 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 = source->ldap.binddn; + copy->ldap.remember_passwd = source->ldap.remember_passwd; + } + else { + copy->file.path = g_strdup (source->file.path); + } + return copy; +} diff --git a/addressbook/gui/component/addressbook-storage.h b/addressbook/gui/component/addressbook-storage.h new file mode 100644 index 0000000000..0262207603 --- /dev/null +++ b/addressbook/gui/component/addressbook-storage.h @@ -0,0 +1,80 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* addressbook-storage.h + * + * Copyright (C) 2000 Helix Code, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Author: Chris Toshok + */ + +#ifndef __ADDRESSBOOK_STORAGE_H__ +#define __ADDRESSBOOK_STORAGE_H__ + +#include "evolution-shell-component.h" + +typedef enum { + ADDRESSBOOK_SOURCE_FILE, + ADDRESSBOOK_SOURCE_LDAP, + ADDRESSBOOK_SOURCE_LAST +} AddressbookSourceType; + +typedef enum { + ADDRESSBOOK_LDAP_AUTH_NONE, + ADDRESSBOOK_LDAP_AUTH_SIMPLE, + ADDRESSBOOK_LDAP_AUTH_SASL, /* XXX currently unsupported */ + ADDRESSBOOK_LDAP_AUTH_LAST +} AddressbookLDAPAuthType; + +typedef enum { + ADDRESSBOOK_LDAP_SCOPE_SUBTREE, + ADDRESSBOOK_LDAP_SCOPE_BASE, + ADDRESSBOOK_LDAP_SCOPE_ONELEVEL, + ADDRESSBOOK_LDAP_SCOPE_LAST +} AddressbookLDAPScopeType; + +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 *uri; /* filled in from the above */ +} AddressbookSource; + +void addressbook_storage_setup (EvolutionShellComponent *shell_component, + const char *evolution_homedir); + +GList *addressbook_storage_get_sources (void); +void addressbook_storage_clear_sources (void); +AddressbookSource *addressbook_source_copy (const AddressbookSource *source); +void addressbook_source_free (AddressbookSource *source); +void addressbook_storage_init_source_uri (AddressbookSource *source); + +void addressbook_storage_add_source (AddressbookSource *source); +void addressbook_storage_remove_source (const char *name); + +#endif /* __ADDRESSBOOK_STORAGE_H__ */ diff --git a/addressbook/gui/component/addressbook.c b/addressbook/gui/component/addressbook.c index 0392caf3b6..49367bd041 100644 --- a/addressbook/gui/component/addressbook.c +++ b/addressbook/gui/component/addressbook.c @@ -29,7 +29,7 @@ #include "e-contact-editor.h" #include "e-contact-save-as.h" -#include "e-ldap-server-dialog.h" +#include "addressbook-config.h" #include <addressbook/printing/e-contact-print.h> @@ -127,46 +127,13 @@ new_contact_cb (BonoboUIComponent *uih, void *user_data, const char *path) gtk_object_sink(GTK_OBJECT(card)); } -#ifdef HAVE_LDAP static void -null_cb (EBook *book, EBookStatus status, gpointer closure) +config_cb (BonoboUIComponent *uih, void *user_data, const char *path) { + addressbook_config (NULL /* XXX */); } static void -new_server_cb (BonoboUIComponent *uih, void *user_data, const char *path) -{ - ELDAPServer *server = g_new (ELDAPServer, 1); - EBook *book; - AddressbookView *view = (AddressbookView *) user_data; - - /* fill in the defaults */ - server->name = g_strdup(""); - server->host = g_strdup(""); - server->port = g_strdup_printf("%d", 389); - server->description = g_strdup(""); - server->rootdn = g_strdup(""); - server->uri = g_strdup_printf ("ldap://%s:%s/%s", server->host, server->port, server->rootdn); - e_ldap_server_editor_show (server); - - gtk_object_get(GTK_OBJECT(view->view), - "book", &book, - NULL); - - g_assert (E_IS_BOOK (book)); - - /* write out the new server info */ - e_ldap_storage_add_server (server); - - /* now update the view */ - e_book_unload_uri (book); - if (! e_book_load_uri (book, server->uri, null_cb, NULL)) { - g_warning ("error calling load_uri!\n"); - } -} -#endif - -static void search_cb (BonoboUIComponent *uih, void *user_data, const char *path) { EBook *book; @@ -302,14 +269,13 @@ BonoboUIVerb verbs [] = { BONOBO_UI_UNSAFE_VERB ("ViewNewContact", new_contact_cb), BONOBO_UI_UNSAFE_VERB ("ToolSearch", search_cb), + BONOBO_UI_UNSAFE_VERB ("AddressbookConfig", config_cb), + BONOBO_UI_UNSAFE_VERB ("ContactNew", new_contact_cb), /* BONOBO_UI_UNSAFE_VERB ("ContactFind", find_contact_cb),*/ BONOBO_UI_UNSAFE_VERB ("ContactDelete", delete_contact_cb), BONOBO_UI_UNSAFE_VERB ("ContactViewAll", show_all_contacts_cb), BONOBO_UI_UNSAFE_VERB ("ContactStop", stop_loading_cb), -#ifdef HAVE_LDAP - BONOBO_UI_UNSAFE_VERB ("ContactNewServer", new_server_cb), -#endif BONOBO_UI_VERB_END }; @@ -333,11 +299,6 @@ control_activate (BonoboControl *control, bonobo_ui_util_set_ui (uic, EVOLUTION_DATADIR, "evolution-addressbook.xml", "evolution-addressbook"); -#ifdef HAVE_LDAP - bonobo_ui_util_set_ui (uic, EVOLUTION_DATADIR, - "evolution-addressbook-ldap.xml", - "evolution-addressbook"); -#endif e_addressbook_view_setup_menus (view->view, uic); diff --git a/addressbook/gui/component/e-ldap-storage.c b/addressbook/gui/component/e-ldap-storage.c deleted file mode 100644 index 065adbf50f..0000000000 --- a/addressbook/gui/component/e-ldap-storage.c +++ /dev/null @@ -1,317 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-ldap-storage.c - * - * Copyright (C) 2000 Helix Code, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Chris Toshok - */ - -/* The ldap server file goes like this: - - <?xml version="1.0"?> - <contactservers> - <contactserver> - <name>LDAP Server</name> - <description>This is my company address book.</description> - <host>ldap.server.com</host> - <port>389</port> - <rootdn></rootdn> - </contactserver> - </contactservers> - - FIXME: Do we want to use a namespace for this? - FIXME: Do we want to have an internationalized description? - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <bonobo.h> - -#include "evolution-shell-component.h" -#include "evolution-storage.h" - -#include <gnome-xml/parser.h> -#include <gnome-xml/xmlmemory.h> - -#include "e-ldap-storage.h" -#include "e-ldap-server-dialog.h" - -#include <gal/util/e-util.h> -#include <gal/util/e-xml-utils.h> - -#include <sys/types.h> -#include <sys/fcntl.h> -#include <sys/stat.h> -#include <errno.h> - -#define LDAPSERVER_XML "ldapservers.xml" - -static gboolean load_ldap_data (EvolutionStorage *storage, const char *file_path); -static gboolean save_ldap_data (const char *file_path); - -GHashTable *servers; -EvolutionStorage *storage; -static char *ldapservers; - -void -setup_ldap_storage (EvolutionShellComponent *shell_component, - const char *evolution_homedir) -{ - EvolutionShellClient *shell_client; - GNOME_Evolution_Shell corba_shell; - - shell_client = evolution_shell_component_get_owner (shell_component); - if (shell_client == CORBA_OBJECT_NIL) { - g_warning ("We have no shell!?"); - return; - } - - corba_shell = bonobo_object_corba_objref (BONOBO_OBJECT (shell_client)); - - storage = evolution_storage_new (_("External Directories"), NULL, NULL); - if (evolution_storage_register_on_shell (storage, corba_shell) != EVOLUTION_STORAGE_OK) { - g_warning ("Cannot register storage"); - return; - } - - /* save the storage for later */ - servers = g_hash_table_new (g_str_hash, g_str_equal); - - gtk_object_set_data (GTK_OBJECT (shell_component), "e-storage", storage); - - if (ldapservers) - g_free (ldapservers); - ldapservers = g_strdup_printf ("%s/" LDAPSERVER_XML, evolution_homedir); - load_ldap_data (storage, ldapservers); -} - -static char * -get_string_value (xmlNode *node, - const char *name) -{ - xmlNode *p; - xmlChar *xml_string; - char *retval; - - p = e_xml_get_child_by_name (node, (xmlChar *) name); - if (p == NULL) - return NULL; - - p = e_xml_get_child_by_name (p, (xmlChar *) "text"); - if (p == NULL) /* there's no text between the tags, return the empty string */ - return g_strdup(""); - - xml_string = xmlNodeListGetString (node->doc, p, 1); - retval = g_strdup ((char *) xml_string); - xmlFree (xml_string); - - return retval; -} - -static gboolean -load_ldap_data (EvolutionStorage *storage, - const char *file_path) -{ - xmlDoc *doc; - xmlNode *root; - xmlNode *child; - - tryagain: - doc = xmlParseFile (file_path); - if (doc == NULL) { - /* check to see if a ldapserver.xml.new file is - there. if it is, rename it and run with it */ - char *new_path = g_strdup_printf ("%s.new", file_path); - struct stat sb; - - if (stat (new_path, &sb) == 0) { - int rv; - - rv = rename (new_path, file_path); - g_free (new_path); - - if (0 > rv) { - g_error ("Failed to rename ldapserver.xml: %s\n", strerror(errno)); - return FALSE; - } - else { - goto tryagain; - } - } - - g_free (new_path); - return TRUE; - } - - root = xmlDocGetRootElement (doc); - if (root == NULL || strcmp (root->name, "contactservers") != 0) { - xmlFreeDoc (doc); - return FALSE; - } - - for (child = root->childs; child; child = child->next) { - char *path; - ELDAPServer *server; - - if (strcmp (child->name, "contactserver")) { - g_warning ("unknown node '%s' in %s", child->name, file_path); - continue; - } - - server = g_new (ELDAPServer, 1); - - server->name = get_string_value (child, "name"); - server->description = get_string_value (child, "description"); - server->port = get_string_value (child, "port"); - server->host = get_string_value (child, "host"); - server->rootdn = get_string_value (child, "rootdn"); - server->scope = get_string_value (child, "scope"); - server->uri = g_strdup_printf ("ldap://%s:%s/%s??%s", server->host, server->port, server->rootdn, server->scope); - - path = g_strdup_printf ("/%s", server->name); - evolution_storage_new_folder (storage, path, server->name, - "contacts", server->uri, - server->description, FALSE); - - g_hash_table_insert (servers, server->name, server); - - g_free (path); - } - - xmlFreeDoc (doc); - - return TRUE; -} - -static void -ldap_server_foreach(gpointer key, gpointer value, gpointer user_data) -{ - ELDAPServer *server = (ELDAPServer*)value; - xmlNode *root = (xmlNode*)user_data; - xmlNode *server_root = xmlNewNode (NULL, - (xmlChar *) "contactserver"); - - xmlAddChild (root, server_root); - - xmlNewChild (server_root, NULL, (xmlChar *) "name", - (xmlChar *) server->name); - xmlNewChild (server_root, NULL, (xmlChar *) "description", - (xmlChar *) server->description); - - xmlNewChild (server_root, NULL, (xmlChar *) "port", - (xmlChar *) server->port); - xmlNewChild (server_root, NULL, (xmlChar *) "host", - (xmlChar *) server->host); - xmlNewChild (server_root, NULL, (xmlChar *) "rootdn", - (xmlChar *) server->rootdn); - xmlNewChild (server_root, NULL, (xmlChar *) "scope", - (xmlChar *) server->scope); -} - -static gboolean -save_ldap_data (const char *file_path) -{ - xmlDoc *doc; - xmlNode *root; - int fd, rv; - xmlChar *buf; - int buf_size; - char *new_path = g_strdup_printf ("%s.new", file_path); - - doc = xmlNewDoc ((xmlChar *) "1.0"); - root = xmlNewDocNode (doc, NULL, (xmlChar *) "contactservers", NULL); - xmlDocSetRootElement (doc, root); - - g_hash_table_foreach (servers, ldap_server_foreach, root); - - fd = open (new_path, O_CREAT | O_TRUNC | O_WRONLY, 0600); - fchmod (fd, 0600); - - xmlDocDumpMemory (doc, &buf, &buf_size); - - if (buf == NULL) { - g_error ("Failed to write ldapserver.xml: xmlBufferCreate() == NULL"); - return FALSE; - } - - rv = write (fd, buf, buf_size); - xmlFree (buf); - close (fd); - - if (0 > rv) { - g_error ("Failed to write new ldapserver.xml: %s\n", strerror(errno)); - unlink (new_path); - return FALSE; - } - else { - if (0 > rename (new_path, file_path)) { - g_error ("Failed to rename ldapserver.xml: %s\n", strerror(errno)); - unlink (new_path); - return FALSE; - } - return TRUE; - } -} - -void -e_ldap_storage_add_server (ELDAPServer *server) -{ - char *path; - /* add it to our hashtable */ - g_hash_table_insert (servers, server->name, server); - - /* and then to the ui */ - path = g_strdup_printf ("/%s", server->name); - evolution_storage_new_folder (storage, path, server->name, "contacts", - server->uri, server->description, FALSE); - - g_free (path); - - save_ldap_data (ldapservers); -} - -void -e_ldap_storage_remove_server (char *name) -{ - char *path; - ELDAPServer *server; - - /* remove it from our hashtable */ - server = (ELDAPServer*)g_hash_table_lookup (servers, name); - g_hash_table_remove (servers, name); - - g_free (server->name); - g_free (server->description); - g_free (server->host); - g_free (server->port); - g_free (server->rootdn); - g_free (server->scope); - g_free (server->uri); - - g_free (server); - - /* and then from the ui */ - path = g_strdup_printf ("/%s", name); - evolution_storage_removed_folder (storage, path); - - g_free (path); - - save_ldap_data (ldapservers); -} diff --git a/addressbook/gui/component/e-ldap-storage.h b/addressbook/gui/component/e-ldap-storage.h deleted file mode 100644 index 9d3e35b4db..0000000000 --- a/addressbook/gui/component/e-ldap-storage.h +++ /dev/null @@ -1,44 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-ldap-storage.h - * - * Copyright (C) 2000 Helix Code, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Chris Toshok - */ - -#ifndef __E_LDAP_STORAGE_H__ -#define __E_LDAP_STORAGE_H__ - -#include "evolution-shell-component.h" - -typedef struct { - char *name; - char *description; - char *host; - char *port; - char *rootdn; - char *scope; - char *uri; /* filled in from the above */ -} ELDAPServer; - -void setup_ldap_storage (EvolutionShellComponent *shell_component, - const char *evolution_homedir); -void e_ldap_storage_add_server (ELDAPServer *server); -void e_ldap_storage_remove_server (char *name); - -#endif /* __E_LDAP_STORAGE_H__ */ diff --git a/addressbook/gui/component/ldap-server-dialog.glade b/addressbook/gui/component/ldap-server-dialog.glade deleted file mode 100644 index a4dad9c2c2..0000000000 --- a/addressbook/gui/component/ldap-server-dialog.glade +++ /dev/null @@ -1,400 +0,0 @@ -<?xml version="1.0"?> -<GTK-Interface> - -<project> - <name>newserver</name> - <program_name>newserver</program_name> - <directory></directory> - <source_directory>src</source_directory> - <pixmaps_directory>pixmaps</pixmaps_directory> - <language>C</language> - <gnome_support>True</gnome_support> - <gettext_support>True</gettext_support> - <output_main_file>False</output_main_file> - <output_translatable_strings>True</output_translatable_strings> - <translatable_strings_file>ldap-server-dialog.glade.h</translatable_strings_file> -</project> - -<widget> - <class>GnomeDialog</class> - <name>ldap-server-dialog</name> - <type>GTK_WINDOW_TOPLEVEL</type> - <position>GTK_WIN_POS_NONE</position> - <modal>False</modal> - <allow_shrink>False</allow_shrink> - <allow_grow>False</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-vbox1</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_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>GtkVBox</class> - <name>vbox1</name> - <homogeneous>False</homogeneous> - <spacing>0</spacing> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkTable</class> - <name>table2</name> - <rows>5</rows> - <columns>2</columns> - <homogeneous>False</homogeneous> - <row_spacing>0</row_spacing> - <column_spacing>0</column_spacing> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkEntry</class> - <name>description-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>GtkEntry</class> - <name>server-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>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> - - <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></text> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>3</top_attach> - <bottom_attach>4</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>GtkEntry</class> - <name>root-dn-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>4</top_attach> - <bottom_attach>5</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>GtkAlignment</class> - <name>alignment1</name> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xscale>1</xscale> - <yscale>1</yscale> - <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>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>True</yfill> - </child> - - <widget> - <class>GtkLabel</class> - <name>label1</name> - <label>Description:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - </widget> - </widget> - - <widget> - <class>GtkAlignment</class> - <name>alignment2</name> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xscale>1</xscale> - <yscale>1</yscale> - <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>True</yfill> - </child> - - <widget> - <class>GtkLabel</class> - <name>label2</name> - <label>LDAP Server:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - </widget> - </widget> - - <widget> - <class>GtkAlignment</class> - <name>alignment3</name> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xscale>1</xscale> - <yscale>1</yscale> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>3</top_attach> - <bottom_attach>4</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>True</yfill> - </child> - - <widget> - <class>GtkLabel</class> - <name>label3</name> - <label>Port Number:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - </widget> - </widget> - - <widget> - <class>GtkAlignment</class> - <name>alignment4</name> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xscale>1</xscale> - <yscale>1</yscale> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>4</top_attach> - <bottom_attach>5</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>True</yfill> - </child> - - <widget> - <class>GtkLabel</class> - <name>label4</name> - <label>Root DN:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - </widget> - </widget> - - <widget> - <class>GtkEntry</class> - <name>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>GtkAlignment</class> - <name>alignment5</name> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xscale>1</xscale> - <yscale>1</yscale> - <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>True</yfill> - </child> - - <widget> - <class>GtkLabel</class> - <name>label5</name> - <label>Name:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - </widget> - </widget> - </widget> - </widget> - </widget> -</widget> - -</GTK-Interface> |