aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui/component/e-ldap-storage.c
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/component/e-ldap-storage.c
parentbc4c507c9ef59d92272fccef9cda4994ce507e0a (diff)
downloadgsoc2013-evolution-2ca2244e6b47fa020ba10bcfb6836033ddfc3cc8.tar
gsoc2013-evolution-2ca2244e6b47fa020ba10bcfb6836033ddfc3cc8.tar.gz
gsoc2013-evolution-2ca2244e6b47fa020ba10bcfb6836033ddfc3cc8.tar.bz2
gsoc2013-evolution-2ca2244e6b47fa020ba10bcfb6836033ddfc3cc8.tar.lz
gsoc2013-evolution-2ca2244e6b47fa020ba10bcfb6836033ddfc3cc8.tar.xz
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/component/e-ldap-storage.c')
-rw-r--r--addressbook/gui/component/e-ldap-storage.c58
1 files changed, 43 insertions, 15 deletions
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)
+{
+}