aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui
diff options
context:
space:
mode:
authorChris Toshok <toshok@helixcode.com>2000-07-06 04:07:46 +0800
committerChris Toshok <toshok@src.gnome.org>2000-07-06 04:07:46 +0800
commit2ca2244e6b47fa020ba10bcfb6836033ddfc3cc8 (patch)
treea5f1c34e58dee9beb85aedf093422cf1d4c716c5 /addressbook/gui
parentbc4c507c9ef59d92272fccef9cda4994ce507e0a (diff)
downloadgsoc2013-evolution-2ca2244e6b47fa020ba10bcfb6836033ddfc3cc8.tar.gz
gsoc2013-evolution-2ca2244e6b47fa020ba10bcfb6836033ddfc3cc8.tar.zst
gsoc2013-evolution-2ca2244e6b47fa020ba10bcfb6836033ddfc3cc8.zip
call e_ldap_storage_add_server call.
2000-07-05 Chris Toshok <toshok@helixcode.com> * gui/component/addressbook.c (new_server_cb): call e_ldap_storage_add_server call. * gui/component/ldap-server-dialog.glade: add name row. * gui/component/e-ldap-server-dialog.h: remove the ELDAPServer type. * gui/component/e-ldap-server-dialog.c (extract_server_info): add support for the name-entry. * gui/component/e-ldap-server-dialog.c (fill_in_server_info): same. * gui/component/e-ldap-storage.h: add ELDAPServer type, and add prototypes for e_ldap_storage_add_server and e_ldap_storage_remove_server. * gui/component/e-ldap-storage.c (e_ldap_storage_add_server): new function, add it to our hash table, add a shell folder, and save out the metadata. (ldap_server_foreach): add the ldap server info under a "contactserver" node. (setup_ldap_storage): create our hashtable. svn path=/trunk/; revision=3895
Diffstat (limited to 'addressbook/gui')
-rw-r--r--addressbook/gui/component/addressbook.c24
-rw-r--r--addressbook/gui/component/e-ldap-server-dialog.c19
-rw-r--r--addressbook/gui/component/e-ldap-server-dialog.h7
-rw-r--r--addressbook/gui/component/e-ldap-storage.c58
-rw-r--r--addressbook/gui/component/e-ldap-storage.h11
-rw-r--r--addressbook/gui/component/ldap-server-dialog.glade165
-rw-r--r--addressbook/gui/component/ldap-server-dialog.glade.h1
7 files changed, 191 insertions, 94 deletions
diff --git a/addressbook/gui/component/addressbook.c b/addressbook/gui/component/addressbook.c
index 97cdb04b53..f248e1e4bd 100644
--- a/addressbook/gui/component/addressbook.c
+++ b/addressbook/gui/component/addressbook.c
@@ -186,19 +186,19 @@ null_cb (EBook *book, EBookStatus status, gpointer closure)
static void
new_server_cb (BonoboUIHandler *uih, void *user_data, const char *path)
{
- ELDAPServer server;
- char *uri;
+ ELDAPServer *server = g_new (ELDAPServer, 1);
EBook *book;
AddressbookView *view = (AddressbookView *) user_data;
GtkObject *object;
/* 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);
+ server->name = g_strdup("");
+ server->host = g_strdup("");
+ server->port = 389;
+ server->description = g_strdup("");
+ server->rootdn = g_strdup("");
+ server->uri = g_strdup_printf ("ldap://%s:%d/%s", server->host, server->port, server->rootdn);
+ e_ldap_server_editor_show (server);
if (view->view)
object = GTK_OBJECT(view->view);
@@ -207,14 +207,12 @@ new_server_cb (BonoboUIHandler *uih, void *user_data, const char *path)
gtk_object_get(object, "book", &book, NULL);
g_assert (E_IS_BOOK (book));
- /* XXX write out the new server info */
+ /* write out the new server info */
+ e_ldap_storage_add_server (server);
/* 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)) {
+ if (! e_book_load_uri (book, server->uri, null_cb, NULL)) {
g_warning ("error calling load_uri!\n");
}
}
diff --git a/addressbook/gui/component/e-ldap-server-dialog.c b/addressbook/gui/component/e-ldap-server-dialog.c
index d64549cc2d..2242282f3f 100644
--- a/addressbook/gui/component/e-ldap-server-dialog.c
+++ b/addressbook/gui/component/e-ldap-server-dialog.c
@@ -39,6 +39,12 @@ fill_in_server_info (ELDAPServerDialog *dialog)
int position;
char buf[128];
+ /* the name */
+ position = 0;
+ editable = GTK_EDITABLE(glade_xml_get_widget(dialog->gui, "name-entry"));
+ gtk_editable_delete_text (editable, 0, -1);
+ gtk_editable_insert_text (editable, ldap_server->name, strlen (ldap_server->name), &position);
+
/* the server description */
position = 0;
editable = GTK_EDITABLE(glade_xml_get_widget(dialog->gui, "description-entry"));
@@ -70,7 +76,16 @@ extract_server_info (ELDAPServerDialog *dialog)
{
ELDAPServer *ldap_server = dialog->server;
GtkEditable *editable;
- char *description, *server, *port, *rootdn;
+ char *description, *server, *port, *rootdn, *name;
+
+ /* the server name */
+ editable = GTK_EDITABLE(glade_xml_get_widget(dialog->gui, "name-entry"));
+ name = gtk_editable_get_chars(editable, 0, -1);
+ if (name && *name) {
+ if (ldap_server->name)
+ g_free(ldap_server->name);
+ ldap_server->name = name;
+ }
/* the server description */
editable = GTK_EDITABLE(glade_xml_get_widget(dialog->gui, "description-entry"));
@@ -111,7 +126,7 @@ extract_server_info (ELDAPServerDialog *dialog)
void
e_ldap_server_editor_show(ELDAPServer *server)
{
- ELDAPServerDialog *dialog = g_new0(ELDAPServerDialog, 1);
+ ELDAPServerDialog *dialog = g_new0 (ELDAPServerDialog, 1);
dialog->server = server;
dialog->gui = glade_xml_new (EVOLUTION_GLADEDIR "/ldap-server-dialog.glade", NULL);
diff --git a/addressbook/gui/component/e-ldap-server-dialog.h b/addressbook/gui/component/e-ldap-server-dialog.h
index f0e73d1ebc..e5ae169f5c 100644
--- a/addressbook/gui/component/e-ldap-server-dialog.h
+++ b/addressbook/gui/component/e-ldap-server-dialog.h
@@ -2,12 +2,7 @@
#ifndef __E_LDAP_SERVER_DIALOG_H__
#define __E_LDAP_SERVER_DIALOG_H__
-typedef struct {
- char *description;
- char *host;
- int port;
- char *rootdn;
-} ELDAPServer;
+#include "e-ldap-storage.h"
void e_ldap_server_editor_show(ELDAPServer *server);
diff --git a/addressbook/gui/component/e-ldap-storage.c b/addressbook/gui/component/e-ldap-storage.c
index e3663452bc..ab3fc21fdb 100644
--- a/addressbook/gui/component/e-ldap-storage.c
+++ b/addressbook/gui/component/e-ldap-storage.c
@@ -60,13 +60,13 @@ static gboolean load_ldap_data (EvolutionStorage *storage, const char *file_path
static gboolean save_ldap_data (const char *file_path);
GHashTable *servers;
+EvolutionStorage *storage;
void
setup_ldap_storage (EvolutionShellComponent *shell_component)
{
EvolutionShellClient *shell_client;
Evolution_Shell corba_shell;
- EvolutionStorage *storage;
char *path;
shell_client = evolution_shell_component_get_owner (shell_component);
@@ -84,6 +84,8 @@ setup_ldap_storage (EvolutionShellComponent *shell_component)
}
/* 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);
path = g_strdup_printf ("%s/evolution/" LDAPSERVER_XML, g_get_home_dir());
@@ -135,26 +137,25 @@ load_ldap_data (EvolutionStorage *storage,
for (child = root->childs; child; child = child->next) {
char *path;
- char *name;
- char *uri;
- char *description;
+ ELDAPServer *server;
if (strcmp (child->name, "contactserver")) {
g_warning ("unknown node '%s' in %s", child->name, file_path);
continue;
}
- name = get_string_value (child, "name");
- uri = get_string_value (child, "uri");
- description = get_string_value (child, "description");
+ server = g_new (ELDAPServer, 1);
+
+ server->name = get_string_value (child, "name");
+ server->uri = get_string_value (child, "uri");
+ server->description = get_string_value (child, "description");
+
+ path = g_strdup_printf ("/%s", server->name);
+ evolution_storage_new_folder (storage, path, "contacts", server->uri, server->description);
- path = g_strdup_printf ("/%s", name);
- evolution_storage_new_folder (storage, path, "contacts", uri, description);
+ g_hash_table_insert (servers, server->name, server);
g_free (path);
- g_free (name);
- g_free (uri);
- g_free (description);
}
xmlFreeDoc (doc);
@@ -167,15 +168,19 @@ ldap_server_foreach(gpointer key, gpointer value, gpointer user_data)
{
ELDAPServer *server = (ELDAPServer*)value;
xmlNode *root = (xmlNode*)user_data;
+ xmlNode *server_root = xmlNewDocNode (root, NULL,
+ (xmlChar *) "contactserver", NULL);
- xmlNewChild (root, NULL, (xmlChar *) "name",
+ xmlAddChild (root, server_root);
+
+ xmlNewChild (server_root, NULL, (xmlChar *) "name",
(xmlChar *) server->name);
- xmlNewChild (root, NULL, (xmlChar *) "uri",
+ xmlNewChild (server_root, NULL, (xmlChar *) "uri",
(xmlChar *) server->uri);
if (server->description)
- xmlNewChild (root, NULL, (xmlChar *) "description",
+ xmlNewChild (server_root, NULL, (xmlChar *) "description",
(xmlChar *) server->description);
}
@@ -200,3 +205,26 @@ save_ldap_data (const char *file_path)
xmlFreeDoc (doc);
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, "contacts", server->uri, server->description);
+
+ g_free (path);
+
+ path = g_strdup_printf ("%s/evolution/" LDAPSERVER_XML, g_get_home_dir());
+ save_ldap_data (path);
+ g_free (path);
+}
+
+void
+e_ldap_storage_remove_server (char *name)
+{
+}
diff --git a/addressbook/gui/component/e-ldap-storage.h b/addressbook/gui/component/e-ldap-storage.h
index c91a060dca..cf11e9a6fb 100644
--- a/addressbook/gui/component/e-ldap-storage.h
+++ b/addressbook/gui/component/e-ldap-storage.h
@@ -26,6 +26,17 @@
#include "evolution-shell-component.h"
+typedef struct {
+ char *name;
+ char *description;
+ char *host;
+ int port;
+ char *rootdn;
+ char *uri;
+} ELDAPServer;
+
void setup_ldap_storage (EvolutionShellComponent *shell_component);
+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
index 71090f53dd..a4dad9c2c2 100644
--- a/addressbook/gui/component/ldap-server-dialog.glade
+++ b/addressbook/gui/component/ldap-server-dialog.glade
@@ -10,17 +10,7 @@
<language>C</language>
<gnome_support>True</gnome_support>
<gettext_support>True</gettext_support>
- <use_widget_names>False</use_widget_names>
<output_main_file>False</output_main_file>
- <output_support_files>True</output_support_files>
- <output_build_files>True</output_build_files>
- <backup_source_files>True</backup_source_files>
- <main_source_file>interface.c</main_source_file>
- <main_header_file>interface.h</main_header_file>
- <handler_source_file>callbacks.c</handler_source_file>
- <handler_header_file>callbacks.h</handler_header_file>
- <support_source_file>support.c</support_source_file>
- <support_header_file>support.h</support_header_file>
<output_translatable_strings>True</output_translatable_strings>
<translatable_strings_file>ldap-server-dialog.glade.h</translatable_strings_file>
</project>
@@ -50,6 +40,40 @@
</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>
@@ -63,7 +87,7 @@
<widget>
<class>GtkTable</class>
<name>table2</name>
- <rows>4</rows>
+ <rows>5</rows>
<columns>2</columns>
<homogeneous>False</homogeneous>
<row_spacing>0</row_spacing>
@@ -85,8 +109,8 @@
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
- <top_attach>0</top_attach>
- <bottom_attach>1</bottom_attach>
+ <top_attach>1</top_attach>
+ <bottom_attach>2</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>True</xexpand>
@@ -109,8 +133,8 @@
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
- <top_attach>1</top_attach>
- <bottom_attach>2</bottom_attach>
+ <top_attach>2</top_attach>
+ <bottom_attach>3</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>True</xexpand>
@@ -133,8 +157,8 @@
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
- <top_attach>2</top_attach>
- <bottom_attach>3</bottom_attach>
+ <top_attach>3</top_attach>
+ <bottom_attach>4</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>True</xexpand>
@@ -157,8 +181,8 @@
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
- <top_attach>3</top_attach>
- <bottom_attach>4</bottom_attach>
+ <top_attach>4</top_attach>
+ <bottom_attach>5</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>True</xexpand>
@@ -180,8 +204,8 @@
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
- <top_attach>0</top_attach>
- <bottom_attach>1</bottom_attach>
+ <top_attach>1</top_attach>
+ <bottom_attach>2</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>True</xexpand>
@@ -215,8 +239,8 @@
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
- <top_attach>1</top_attach>
- <bottom_attach>2</bottom_attach>
+ <top_attach>2</top_attach>
+ <bottom_attach>3</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
@@ -250,8 +274,8 @@
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
- <top_attach>2</top_attach>
- <bottom_attach>3</bottom_attach>
+ <top_attach>3</top_attach>
+ <bottom_attach>4</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
@@ -285,8 +309,8 @@
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
- <top_attach>3</top_attach>
- <bottom_attach>4</bottom_attach>
+ <top_attach>4</top_attach>
+ <bottom_attach>5</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
@@ -309,40 +333,65 @@
<ypad>0</ypad>
</widget>
</widget>
- </widget>
- </widget>
- <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>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>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>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>GtkButton</class>
- <name>button3</name>
- <can_default>True</can_default>
- <can_focus>True</can_focus>
- <stock_button>GNOME_STOCK_BUTTON_CANCEL</stock_button>
+ <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>
diff --git a/addressbook/gui/component/ldap-server-dialog.glade.h b/addressbook/gui/component/ldap-server-dialog.glade.h
index 68b45bdb34..c99dfa3cb5 100644
--- a/addressbook/gui/component/ldap-server-dialog.glade.h
+++ b/addressbook/gui/component/ldap-server-dialog.glade.h
@@ -8,3 +8,4 @@ gchar *s = N_("Description:");
gchar *s = N_("LDAP Server:");
gchar *s = N_("Port Number:");
gchar *s = N_("Root DN:");
+gchar *s = N_("Name:");