aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook
diff options
context:
space:
mode:
authorChris Toshok <toshok@helixcode.com>2000-07-07 13:12:03 +0800
committerChris Toshok <toshok@src.gnome.org>2000-07-07 13:12:03 +0800
commitb292770082677236d9504b3c546c14b6788b4684 (patch)
tree05965edb9da78ce2947d24c71e2cdce626d9963d /addressbook
parentbad08008b022dd9b9cbc250de526c7ef115532d7 (diff)
downloadgsoc2013-evolution-b292770082677236d9504b3c546c14b6788b4684.tar
gsoc2013-evolution-b292770082677236d9504b3c546c14b6788b4684.tar.gz
gsoc2013-evolution-b292770082677236d9504b3c546c14b6788b4684.tar.bz2
gsoc2013-evolution-b292770082677236d9504b3c546c14b6788b4684.tar.lz
gsoc2013-evolution-b292770082677236d9504b3c546c14b6788b4684.tar.xz
gsoc2013-evolution-b292770082677236d9504b3c546c14b6788b4684.tar.zst
gsoc2013-evolution-b292770082677236d9504b3c546c14b6788b4684.zip
add scope to ELDAPServer, and make port a string.
2000-07-06 Chris Toshok <toshok@helixcode.com> * gui/component/e-ldap-storage.h: add scope to ELDAPServer, and make port a string. * gui/component/e-ldap-storage.c (load_ldap_data): don't load a uri, load all the bits and pieces and build up the uri when creating the folder, according to the openldap url format. (ldap_server_foreach): store out each of the individual uri pieces. (e_ldap_storage_remove_server): free the new fields. (get_string_value): if the text is empty, return the empty string instead of NULL. * gui/component/e-ldap-server-dialog.c (extract_server_info): port is a string now. (fill_in_server_info): port is a string now. svn path=/trunk/; revision=3942
Diffstat (limited to 'addressbook')
-rw-r--r--addressbook/ChangeLog17
-rw-r--r--addressbook/gui/component/e-ldap-server-dialog.c9
-rw-r--r--addressbook/gui/component/e-ldap-storage.c62
-rw-r--r--addressbook/gui/component/e-ldap-storage.h5
4 files changed, 73 insertions, 20 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index 87950b1cef..61b0e1025e 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,3 +1,20 @@
+2000-07-06 Chris Toshok <toshok@helixcode.com>
+
+ * gui/component/e-ldap-storage.h: add scope to ELDAPServer, and
+ make port a string.
+
+ * gui/component/e-ldap-storage.c (load_ldap_data): don't load a
+ uri, load all the bits and pieces and build up the uri when
+ creating the folder, according to the openldap url format.
+ (ldap_server_foreach): store out each of the individual uri
+ pieces.
+ (e_ldap_storage_remove_server): free the new fields.
+ (get_string_value): if the text is empty, return the empty string
+ instead of NULL.
+
+ * gui/component/e-ldap-server-dialog.c (extract_server_info): port is a string now.
+ (fill_in_server_info): port is a string now.
+
2000-07-06 Christopher James Lahey <clahey@helixcode.com>
* contact-editor/e-contact-editor.c: Changed "FIXME: Save and
diff --git a/addressbook/gui/component/e-ldap-server-dialog.c b/addressbook/gui/component/e-ldap-server-dialog.c
index 2242282f3f..172f43280b 100644
--- a/addressbook/gui/component/e-ldap-server-dialog.c
+++ b/addressbook/gui/component/e-ldap-server-dialog.c
@@ -37,7 +37,6 @@ fill_in_server_info (ELDAPServerDialog *dialog)
ELDAPServer *ldap_server = dialog->server;
GtkEditable *editable;
int position;
- char buf[128];
/* the name */
position = 0;
@@ -59,10 +58,9 @@ fill_in_server_info (ELDAPServerDialog *dialog)
/* 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);
+ gtk_editable_insert_text (editable, ldap_server->port, strlen (ldap_server->port), &position);
/* the root dn */
position = 0;
@@ -109,9 +107,10 @@ extract_server_info (ELDAPServerDialog *dialog)
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);
+ if (ldap_server->port)
+ g_free (ldap_server->port);
+ ldap_server->port = port;
}
- g_free(port);
/* the root dn */
editable = GTK_EDITABLE(glade_xml_get_widget(dialog->gui, "root-dn-entry"));
diff --git a/addressbook/gui/component/e-ldap-storage.c b/addressbook/gui/component/e-ldap-storage.c
index ab3fc21fdb..052413d6bd 100644
--- a/addressbook/gui/component/e-ldap-storage.c
+++ b/addressbook/gui/component/e-ldap-storage.c
@@ -28,7 +28,9 @@
<contactserver>
<name>LDAP Server</name>
<description>This is my company address book.</description>
- <uri>ldap://ldap.somewhere.net/</uri>
+ <host>ldap.server.com</host>
+ <port>389</port>
+ <rootdn></rootdn>
</contactserver>
</contactservers>
@@ -106,8 +108,8 @@ get_string_value (xmlNode *node,
return NULL;
p = e_xml_get_child_by_name (p, (xmlChar *) "text");
- if (p == NULL)
- return NULL;
+ 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);
@@ -147,8 +149,12 @@ load_ldap_data (EvolutionStorage *storage,
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");
+ 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, "contacts", server->uri, server->description);
@@ -168,20 +174,24 @@ 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);
+ 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 *) "uri",
- (xmlChar *) server->uri);
-
- if (server->description)
- xmlNewChild (server_root, NULL, (xmlChar *) "description",
- (xmlChar *) server->description);
+ 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->port);
+ xmlNewChild (server_root, NULL, (xmlChar *) "rootdn",
+ (xmlChar *) server->port);
+ xmlNewChild (server_root, NULL, (xmlChar *) "scope",
+ (xmlChar *) server->scope);
}
static gboolean
@@ -227,4 +237,30 @@ e_ldap_storage_add_server (ELDAPServer *server)
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);
+
+ path = g_strdup_printf ("%s/evolution/" LDAPSERVER_XML, g_get_home_dir());
+ save_ldap_data (path);
+ g_free (path);
}
diff --git a/addressbook/gui/component/e-ldap-storage.h b/addressbook/gui/component/e-ldap-storage.h
index cf11e9a6fb..d9870ae69f 100644
--- a/addressbook/gui/component/e-ldap-storage.h
+++ b/addressbook/gui/component/e-ldap-storage.h
@@ -30,9 +30,10 @@ typedef struct {
char *name;
char *description;
char *host;
- int port;
+ char *port;
char *rootdn;
- char *uri;
+ char *scope;
+ char *uri; /* filled in from the above */
} ELDAPServer;
void setup_ldap_storage (EvolutionShellComponent *shell_component);