aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui/component/addressbook-storage.c
diff options
context:
space:
mode:
authorChris Toshok <toshok@ximian.com>2002-04-19 05:26:48 +0800
committerChris Toshok <toshok@src.gnome.org>2002-04-19 05:26:48 +0800
commit9b7cc54d6ff67c83590706ee0b6749a7e1f3ca21 (patch)
tree3738f8f1fb02399157515420ff995ad5a428936f /addressbook/gui/component/addressbook-storage.c
parent0c7e55e75cc787269ab570588f3873b6279aede1 (diff)
downloadgsoc2013-evolution-9b7cc54d6ff67c83590706ee0b6749a7e1f3ca21.tar.gz
gsoc2013-evolution-9b7cc54d6ff67c83590706ee0b6749a7e1f3ca21.tar.zst
gsoc2013-evolution-9b7cc54d6ff67c83590706ee0b6749a7e1f3ca21.zip
fix memory leaks.
2002-04-18 Chris Toshok <toshok@ximian.com> * backend/pas/pas-backend-ldap.c (get_ldap_library_info): fix memory leaks. * gui/component/GNOME_Evolution_Addressbook.oaf.in: remove the Addressbook_ConfigControl stuff to LDAP_ConfigControl. * gui/component/Makefile.am (evolution_addressbook_SOURCES): remove addressbook-config.* and add ldap-config.* (glade_DATA): same. (evolution_addressbook_LDADD): add LDAP_LIBS. * gui/component/addressbook-component.c (owner_set_cb): addressbook_config_register_factory => ldap_config_register_factory. * gui/component/addressbook.c (book_open_cb): remove source->type check - they're always LDAP. (load_uri_cb): same. * gui/component/addressbook-storage.c (ldap_unparse_ssl): new function. (ldap_parse_ssl): new function. (addressbook_storage_init_source_uri): use a more flexible scheme to build up the uri's, and add in the ssl parameter. (load_source_data): fill in source->ssl, and remove source->type assignment. (addressbook_source_copy): copy source->ssl, and remove source->type copy. (create_ldap_folder): addressbook_create_new_source => ldap_config_create_new_source. * gui/component/addressbook-storage.h: remove AddressbookSourceType (it was always LDAP), and add AddressbookLDAPSSLType. svn path=/trunk/; revision=16524
Diffstat (limited to 'addressbook/gui/component/addressbook-storage.c')
-rw-r--r--addressbook/gui/component/addressbook-storage.c65
1 files changed, 53 insertions, 12 deletions
diff --git a/addressbook/gui/component/addressbook-storage.c b/addressbook/gui/component/addressbook-storage.c
index 95af6c52ad..2b54c5019e 100644
--- a/addressbook/gui/component/addressbook-storage.c
+++ b/addressbook/gui/component/addressbook-storage.c
@@ -65,7 +65,7 @@
#include "evolution-shell-component.h"
-#include "addressbook-config.h"
+#include "ldap-config.h"
#define ADDRESSBOOK_SOURCES_XML "addressbook-sources.xml"
@@ -151,7 +151,7 @@ create_ldap_folder (EvolutionStorage *storage, const Bonobo_Listener listener,
notify_listener (listener, GNOME_Evolution_Storage_INVALID_URI);
return;
}
- addressbook_create_new_source (path + 1, NULL);
+ ldap_config_create_new_source (path + 1, NULL);
notify_listener (listener, GNOME_Evolution_Storage_OK);
}
@@ -322,6 +322,38 @@ ldap_parse_scope (const char *scope)
}
#endif
+static char *
+ldap_unparse_ssl (AddressbookLDAPSSLType ssl_type)
+{
+ switch (ssl_type) {
+ case ADDRESSBOOK_LDAP_SSL_NEVER:
+ return "never";
+ case ADDRESSBOOK_LDAP_SSL_WHENEVER_POSSIBLE:
+ return "whenever_possible";
+ case ADDRESSBOOK_LDAP_SSL_ALWAYS:
+ return "always";
+ default:
+ g_assert(0);
+ return "";
+ }
+}
+
+#ifdef HAVE_LDAP
+static AddressbookLDAPSSLType
+ldap_parse_ssl (const char *ssl)
+{
+ if (!ssl)
+ return ADDRESSBOOK_LDAP_SSL_WHENEVER_POSSIBLE; /* XXX good default? */
+
+ if (!strcmp (ssl, "always"))
+ return ADDRESSBOOK_LDAP_SSL_ALWAYS;
+ else if (!strcmp (ssl, "never"))
+ return ADDRESSBOOK_LDAP_SSL_NEVER;
+ else
+ return ADDRESSBOOK_LDAP_SSL_WHENEVER_POSSIBLE;
+}
+#endif
+
const char*
addressbook_storage_auth_type_to_string (AddressbookLDAPAuthType auth_type)
{
@@ -331,18 +363,27 @@ addressbook_storage_auth_type_to_string (AddressbookLDAPAuthType auth_type)
void
addressbook_storage_init_source_uri (AddressbookSource *source)
{
+ GString *str;
+
if (source->uri)
g_free (source->uri);
+ str = g_string_new ("ldap://");
+
+ g_string_sprintfa (str, "%s:%s/%s?"/*trigraph prevention*/"?%s",
+ source->host, source->port, source->rootdn, ldap_unparse_scope (source->scope));
+
if (source->limit != 100)
- source->uri = g_strdup_printf ("ldap://%s:%s/%s?"/*trigraph prevention*/ "?%s;limit=%d",
- source->host, source->port,
- source->rootdn, ldap_unparse_scope(source->scope),
- source->limit);
- else
- source->uri = g_strdup_printf ("ldap://%s:%s/%s?"/*trigraph prevention*/ "?%s",
- source->host, source->port,
- source->rootdn, ldap_unparse_scope(source->scope));
+ g_string_sprintfa (str, ";limit=%d", source->limit);
+
+ if (source->ssl != ADDRESSBOOK_LDAP_SSL_WHENEVER_POSSIBLE)
+ g_string_sprintfa (str, ";ssl=%s", ldap_unparse_ssl (source->ssl));
+
+ /* XXX need to do timeout info */
+
+ source->uri = str->str;
+
+ g_string_free (str, FALSE);
}
#ifdef HAVE_LDAP
@@ -395,12 +436,12 @@ load_source_data (const char *file_path)
source = g_new0 (AddressbookSource, 1);
if (!strcmp (child->name, "contactserver")) {
- source->type = ADDRESSBOOK_SOURCE_LDAP;
source->port = get_string_value (child, "port");
source->host = get_string_value (child, "host");
source->rootdn = get_string_value (child, "rootdn");
source->scope = ldap_parse_scope (get_string_value (child, "scope"));
source->auth = ldap_parse_auth (get_string_value (child, "authmethod"));
+ source->ssl = ldap_parse_ssl (get_string_value (child, "ssl"));
source->email_addr = get_string_value (child, "emailaddr");
source->binddn = get_string_value (child, "binddn");
source->limit = get_integer_value (child, "limit", 100);
@@ -645,7 +686,6 @@ addressbook_source_copy (const AddressbookSource *source)
copy = g_new0 (AddressbookSource, 1);
copy->name = g_strdup (source->name);
copy->description = g_strdup (source->description);
- copy->type = source->type;
copy->uri = g_strdup (source->uri);
copy->host = g_strdup (source->host);
@@ -653,6 +693,7 @@ addressbook_source_copy (const AddressbookSource *source)
copy->rootdn = g_strdup (source->rootdn);
copy->scope = source->scope;
copy->auth = source->auth;
+ copy->ssl = source->ssl;
copy->email_addr = g_strdup (source->email_addr);
copy->binddn = g_strdup (source->binddn);
copy->remember_passwd = source->remember_passwd;