From 2ca2244e6b47fa020ba10bcfb6836033ddfc3cc8 Mon Sep 17 00:00:00 2001 From: Chris Toshok Date: Wed, 5 Jul 2000 20:07:46 +0000 Subject: call e_ldap_storage_add_server call. 2000-07-05 Chris Toshok * 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 --- addressbook/gui/component/e-ldap-storage.c | 58 ++++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 15 deletions(-) (limited to 'addressbook/gui/component/e-ldap-storage.c') 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) +{ +} -- cgit v1.2.3