From 165bf85c4d07928acf01c43c49c7e65c16b28ac8 Mon Sep 17 00:00:00 2001 From: Chris Toshok Date: Mon, 1 May 2000 00:23:53 +0000 Subject: added e-ldap-server-dialog.c (glade_DATA): added ldap-server-dialog.glade * gui/component/Makefile.am (evolution_addressbook_SOURCES): added e-ldap-server-dialog.c (glade_DATA): added ldap-server-dialog.glade * gui/component/ldap-server-dialog.glade: new file. * gui/component/e-ldap-server-dialog.h: new file. * gui/component/e-ldap-server-dialog.c: new file, contains logic associated with ldap server dialog. * gui/component/addressbook.c (control_deactivate): remove the directory server menu item. (null_cb): do nothing callback for e_book_load_uri call. should change to (at the very least) pop up a dialog if there was an error. (new_server_cb): new function - really just switches to a particular ldap server, since the information isn't saved anywhere. (control_activate): add directory server menu item. svn path=/trunk/; revision=2700 --- addressbook/ChangeLog | 23 ++ addressbook/gui/component/Makefile.am | 7 + addressbook/gui/component/addressbook.c | 77 +++-- addressbook/gui/component/e-ldap-server-dialog.c | 128 ++++++++ addressbook/gui/component/e-ldap-server-dialog.h | 14 + addressbook/gui/component/ldap-server-dialog.glade | 338 +++++++++++++++++++++ 6 files changed, 556 insertions(+), 31 deletions(-) create mode 100644 addressbook/gui/component/e-ldap-server-dialog.c create mode 100644 addressbook/gui/component/e-ldap-server-dialog.h create mode 100644 addressbook/gui/component/ldap-server-dialog.glade diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog index 9861c23da5..40d4cc9ae7 100644 --- a/addressbook/ChangeLog +++ b/addressbook/ChangeLog @@ -1,3 +1,26 @@ +2000-04-30 Chris Toshok + + * gui/component/Makefile.am (evolution_addressbook_SOURCES): added + e-ldap-server-dialog.c + (glade_DATA): added ldap-server-dialog.glade + + * gui/component/ldap-server-dialog.glade: new file. + + * gui/component/e-ldap-server-dialog.h: new file. + + * gui/component/e-ldap-server-dialog.c: new file, contains logic + associated with ldap server dialog. + + * gui/component/addressbook.c (control_deactivate): remove the + directory server menu item. + (null_cb): do nothing callback for e_book_load_uri call. should + change to (at the very least) pop up a dialog if there was an + error. + (new_server_cb): new function - really just switches to a + particular ldap server, since the information isn't saved + anywhere. + (control_activate): add directory server menu item. + 2000-04-30 Chris Toshok * backend/ebook/e-book.c (e_book_load_uri): create the book diff --git a/addressbook/gui/component/Makefile.am b/addressbook/gui/component/Makefile.am index 38eb1a0c38..8b247a50b8 100644 --- a/addressbook/gui/component/Makefile.am +++ b/addressbook/gui/component/Makefile.am @@ -1,3 +1,6 @@ +CPPFLAGS = \ + -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" + INCLUDES = \ -DG_LOG_DOMAIN=\"evolution-addressbook\" \ $(EXTRA_GNOME_CFLAGS) \ @@ -19,6 +22,7 @@ bin_PROGRAMS = \ evolution-addressbook evolution_addressbook_SOURCES = \ + e-ldap-server-dialog.c \ addressbook-factory.c \ addressbook.c \ addressbook.h @@ -44,6 +48,9 @@ gnorbadir = $(sysconfdir)/CORBA/servers gnorba_DATA = addressbook.gnorba endif +gladedir = $(datadir)/evolution/glade +glade_DATA = ldap-server-dialog.glade + EXTRA_DIST = \ addressbook.gnorba \ addressbook.oafinfo diff --git a/addressbook/gui/component/addressbook.c b/addressbook/gui/component/addressbook.c index d634d5a926..e559c39ea4 100644 --- a/addressbook/gui/component/addressbook.c +++ b/addressbook/gui/component/addressbook.c @@ -20,6 +20,7 @@ #include #include "e-minicard-view.h" #include "e-contact-editor.h" +#include "e-ldap-server-dialog.h" #ifdef USING_OAF #define CONTROL_FACTORY_ID "OAFIID:control-factory:addressbook:3e10597b-0591-4d45-b082-d781b7aa6e17" @@ -32,6 +33,7 @@ control_deactivate (BonoboControl *control, BonoboUIHandler *uih) { /* how to remove a menu item */ bonobo_ui_handler_menu_remove (uih, "/Actions/New Contact"); + bonobo_ui_handler_menu_remove (uih, "/Actions/New Directory Server"); /* remove our toolbar */ bonobo_ui_handler_dock_remove (uih, "/Toolbar"); @@ -42,34 +44,6 @@ do_nothing_cb (BonoboUIHandler *uih, void *user_data, const char *path) { printf ("Yow! I am called back!\n"); } - - -#define BLANK_VCARD \ -"BEGIN:VCARD -" \ -"FN: -" \ -"N: -" \ -"BDAY: -" \ -"TEL;WORK: -" \ -"TEL;CELL: -" \ -"EMAIL;INTERNET: -" \ -"EMAIL;INTERNET: -" \ -"ADR;WORK;POSTAL: -" \ -"ADR;HOME;POSTAL;INTL: -" \ -"END:VCARD -" \ -" -" - static void card_added_cb (EBook* book, EBookStatus status, const char *id, @@ -121,6 +95,42 @@ new_contact_cb (BonoboUIHandler *uih, void *user_data, const char *path) } +static void +null_cb (EBook *book, EBookStatus status, gpointer closure) +{ +} + +static void +new_server_cb (BonoboUIHandler *uih, void *user_data, const char *path) +{ + EMinicardView *minicard_view = E_MINICARD_VIEW (user_data); + ELDAPServer server; + char *uri; + EBook *book; + + /* fill in the defaults */ + server.host = g_strdup(""); + server.port = 389; + server.description = g_strdup(""); + server.rootdn = g_strdup(""); + + e_ldap_server_editor_show (&server); + + gtk_object_get(GTK_OBJECT(minicard_view), "book", &book, NULL); + g_assert (E_IS_BOOK (book)); + + /* XXX write out the new server info */ + + /* now update the view */ + uri = g_strdup_printf ("ldap://%s:%d/%s", server.host, server.port, server.rootdn); + + e_book_unload_uri (book); + + if (! e_book_load_uri (book, uri, null_cb, NULL)) { + g_warning ("error calling load_uri!\n"); + } +} + static void find_contact_cb (BonoboUIHandler *uih, void *user_data, const char *path) { @@ -143,7 +153,6 @@ find_contact_cb (BonoboUIHandler *uih, void *user_data, const char *path) gnome_dialog_close_hides (GNOME_DIALOG (dlg), TRUE); result = gnome_dialog_run_and_close (GNOME_DIALOG (dlg)); - /* If the user clicks "okay"...*/ if (result == 0) { search_text = gtk_entry_get_text(GTK_ENTRY(search_entry)); @@ -221,7 +230,6 @@ make_quick_search_widget (GtkSignalFunc start_search_func, return search_vbox; } - static void control_activate (BonoboControl *control, BonoboUIHandler *uih, EMinicardView *minicard_view) @@ -242,6 +250,13 @@ control_activate (BonoboControl *control, BonoboUIHandler *uih, 0, 0, new_contact_cb, (gpointer)minicard_view); + bonobo_ui_handler_menu_new_item (uih, "/Actions/New Directory Server", + N_("N_ew Directory Server"), + NULL, -1, + BONOBO_UI_HANDLER_PIXMAP_NONE, NULL, + 0, 0, new_server_cb, + (gpointer)minicard_view); + toolbar = gtk_toolbar_new (GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_BOTH); @@ -261,7 +276,7 @@ control_activate (BonoboControl *control, BonoboUIHandler *uih, FALSE, TRUE, 0); gtk_widget_show_all (hbox); - + toolbar_control = bonobo_control_new (hbox); bonobo_ui_handler_dock_add ( uih, "/Toolbar", diff --git a/addressbook/gui/component/e-ldap-server-dialog.c b/addressbook/gui/component/e-ldap-server-dialog.c new file mode 100644 index 0000000000..d64549cc2d --- /dev/null +++ b/addressbook/gui/component/e-ldap-server-dialog.c @@ -0,0 +1,128 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * e-ldap-server-dialog.c + * Copyright (C) 2000 Helix Code, Inc. + * Author: Chris Toshok + * + * This library 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 library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + + +#include +#include +#include "e-ldap-server-dialog.h" + +typedef struct { + GladeXML *gui; + GtkWidget *dialog; + ELDAPServer *server; +} ELDAPServerDialog; + +static void +fill_in_server_info (ELDAPServerDialog *dialog) +{ + ELDAPServer *ldap_server = dialog->server; + GtkEditable *editable; + int position; + char buf[128]; + + /* the server description */ + position = 0; + editable = GTK_EDITABLE(glade_xml_get_widget(dialog->gui, "description-entry")); + gtk_editable_delete_text (editable, 0, -1); + gtk_editable_insert_text (editable, ldap_server->description, strlen (ldap_server->description), &position); + + /* the server hostname */ + position = 0; + editable = GTK_EDITABLE(glade_xml_get_widget(dialog->gui, "server-entry")); + gtk_editable_delete_text (editable, 0, -1); + gtk_editable_insert_text (editable, ldap_server->host, strlen (ldap_server->host), &position); + + /* the server port */ + position = 0; + g_snprintf (buf, sizeof(buf), "%d", ldap_server->port); + editable = GTK_EDITABLE(glade_xml_get_widget(dialog->gui, "port-entry")); + gtk_editable_delete_text (editable, 0, -1); + gtk_editable_insert_text (editable, buf, strlen (buf), &position); + + /* the root dn */ + position = 0; + editable = GTK_EDITABLE(glade_xml_get_widget(dialog->gui, "root-dn-entry")); + gtk_editable_delete_text (editable, 0, -1); + gtk_editable_insert_text (editable, ldap_server->rootdn, strlen (ldap_server->rootdn), &position); +} + +static void +extract_server_info (ELDAPServerDialog *dialog) +{ + ELDAPServer *ldap_server = dialog->server; + GtkEditable *editable; + char *description, *server, *port, *rootdn; + + /* the server description */ + editable = GTK_EDITABLE(glade_xml_get_widget(dialog->gui, "description-entry")); + description = gtk_editable_get_chars(editable, 0, -1); + if (description && *description) { + if (ldap_server->description) + g_free(ldap_server->description); + ldap_server->description = description; + } + + /* the server hostname */ + editable = GTK_EDITABLE(glade_xml_get_widget(dialog->gui, "server-entry")); + server = gtk_editable_get_chars(editable, 0, -1); + if (server && *server) { + if (ldap_server->host) + g_free(ldap_server->host); + ldap_server->host = server; + } + + /* the server port */ + editable = GTK_EDITABLE(glade_xml_get_widget(dialog->gui, "port-entry")); + port = gtk_editable_get_chars(editable, 0, -1); + if (port && *port) { + ldap_server->port = atoi(port); + } + g_free(port); + + /* the root dn */ + editable = GTK_EDITABLE(glade_xml_get_widget(dialog->gui, "root-dn-entry")); + rootdn = gtk_editable_get_chars(editable, 0, -1); + if (rootdn && *rootdn) { + if (ldap_server->rootdn) + g_free (ldap_server->rootdn); + ldap_server->rootdn = rootdn; + } +} + +void +e_ldap_server_editor_show(ELDAPServer *server) +{ + ELDAPServerDialog *dialog = g_new0(ELDAPServerDialog, 1); + + dialog->server = server; + dialog->gui = glade_xml_new (EVOLUTION_GLADEDIR "/ldap-server-dialog.glade", NULL); + + dialog->dialog = glade_xml_get_widget(dialog->gui, "ldap-server-dialog"); + + fill_in_server_info (dialog); + + gnome_dialog_run (GNOME_DIALOG(dialog->dialog)); + + extract_server_info (dialog); + + gnome_dialog_close (GNOME_DIALOG(dialog->dialog)); +} diff --git a/addressbook/gui/component/e-ldap-server-dialog.h b/addressbook/gui/component/e-ldap-server-dialog.h new file mode 100644 index 0000000000..f0e73d1ebc --- /dev/null +++ b/addressbook/gui/component/e-ldap-server-dialog.h @@ -0,0 +1,14 @@ + +#ifndef __E_LDAP_SERVER_DIALOG_H__ +#define __E_LDAP_SERVER_DIALOG_H__ + +typedef struct { + char *description; + char *host; + int port; + char *rootdn; +} ELDAPServer; + +void e_ldap_server_editor_show(ELDAPServer *server); + +#endif /* __E_LDAP_SERVER_DIALOG_H__ */ diff --git a/addressbook/gui/component/ldap-server-dialog.glade b/addressbook/gui/component/ldap-server-dialog.glade new file mode 100644 index 0000000000..7905f11805 --- /dev/null +++ b/addressbook/gui/component/ldap-server-dialog.glade @@ -0,0 +1,338 @@ + + + + + newserver + newserver + + src + pixmaps + C + True + True + + + + GnomeDialog + ldap-server-dialog + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + False + False + False + False + False + + + GtkVBox + GnomeDialog:vbox + dialog-vbox1 + False + 8 + + 4 + True + True + + + + GtkHButtonBox + GnomeDialog:action_area + dialog-action_area1 + GTK_BUTTONBOX_END + 8 + 85 + 27 + 7 + 0 + + 0 + False + True + GTK_PACK_END + + + + GtkButton + button1 + True + True + GNOME_STOCK_BUTTON_OK + + + + GtkButton + button3 + True + True + GNOME_STOCK_BUTTON_CANCEL + + + + + GtkVBox + vbox1 + False + 0 + + 0 + True + True + + + + GtkTable + table2 + 4 + 2 + False + 0 + 0 + + 0 + True + True + + + + GtkEntry + description-entry + True + True + True + 0 + + + 1 + 2 + 0 + 1 + 0 + 0 + True + False + False + False + True + False + + + + + GtkEntry + server-entry + True + True + True + 0 + + + 1 + 2 + 1 + 2 + 0 + 0 + True + False + False + False + True + False + + + + + GtkEntry + port-entry + True + True + True + 0 + + + 1 + 2 + 2 + 3 + 0 + 0 + True + False + False + False + True + False + + + + + GtkEntry + root-dn-entry + True + True + True + 0 + + + 1 + 2 + 3 + 4 + 0 + 0 + True + False + False + False + True + False + + + + + GtkAlignment + alignment1 + 0.5 + 0.5 + 1 + 1 + + 0 + 1 + 0 + 1 + 0 + 0 + True + False + False + False + True + True + + + + GtkLabel + label1 + + GTK_JUSTIFY_CENTER + False + 0 + 0.5 + 0 + 0 + + + + + GtkAlignment + alignment2 + 0.5 + 0.5 + 1 + 1 + + 0 + 1 + 1 + 2 + 0 + 0 + False + False + False + False + True + True + + + + GtkLabel + label2 + + GTK_JUSTIFY_CENTER + False + 0 + 0.5 + 0 + 0 + + + + + GtkAlignment + alignment3 + 0.5 + 0.5 + 1 + 1 + + 0 + 1 + 2 + 3 + 0 + 0 + False + False + False + False + True + True + + + + GtkLabel + label3 + + GTK_JUSTIFY_CENTER + False + 0 + 0.5 + 0 + 0 + + + + + GtkAlignment + alignment4 + 0.5 + 0.5 + 1 + 1 + + 0 + 1 + 3 + 4 + 0 + 0 + False + False + False + False + True + True + + + + GtkLabel + label4 + + GTK_JUSTIFY_CENTER + False + 0 + 0.5 + 0 + 0 + + + + + + + + -- cgit