aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--addressbook/ChangeLog23
-rw-r--r--addressbook/gui/component/Makefile.am7
-rw-r--r--addressbook/gui/component/addressbook.c77
-rw-r--r--addressbook/gui/component/e-ldap-server-dialog.c128
-rw-r--r--addressbook/gui/component/e-ldap-server-dialog.h14
-rw-r--r--addressbook/gui/component/ldap-server-dialog.glade338
6 files changed, 556 insertions, 31 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index 9861c23da5..40d4cc9ae7 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,5 +1,28 @@
2000-04-30 Chris Toshok <toshok@helixcode.com>
+ * 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 <toshok@helixcode.com>
+
* backend/ebook/e-book.c (e_book_load_uri): create the book
listener here, since it's destroyed in unload_uri.
(e_book_construct): remove the book listener construction here.
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 <e-util/e-canvas.h>
#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,
@@ -122,6 +96,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)
{
gint result;
@@ -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 <toshok@helixcode.com>
+ *
+ * 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 <gnome.h>
+#include <glade/glade.h>
+#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 @@
+<?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>
+</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>4</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>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>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>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>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>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>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>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>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>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>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>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>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>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>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>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>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>
+ </widget>
+ </widget>
+</widget>
+
+</GTK-Interface>