diff plugins/ssl/ssl-gnutls.c @ 7862:01e6e9c46a01

[gaim-migrate @ 8516] " Patch 1: sslconn.patch Fixes a buglet where ssl_init() would not actually init the loaded SSL plugin until the second time it was called." --Bill Tompkins (obobo) committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Sun, 14 Dec 2003 16:35:35 +0000
parents 99ffabc6ce73
children 1976914caa51
line wrap: on
line diff
--- a/plugins/ssl/ssl-gnutls.c	Sun Dec 14 16:23:53 2003 +0000
+++ b/plugins/ssl/ssl-gnutls.c	Sun Dec 14 16:35:35 2003 +0000
@@ -40,16 +40,20 @@
 
 static gnutls_certificate_client_credentials xcred;
 
-static gboolean
-ssl_gnutls_init(void)
+static void
+ssl_gnutls_init_gnutls(void)
 {
 	gnutls_global_init();
 
 	gnutls_certificate_allocate_credentials(&xcred);
 	gnutls_certificate_set_x509_trust_file(xcred, "ca.pem",
 										   GNUTLS_X509_FMT_PEM);
+}
 
-	return TRUE;
+static gboolean
+ssl_gnutls_init(void)
+{
+   return TRUE;
 }
 
 static void
@@ -177,8 +181,12 @@
 plugin_load(GaimPlugin *plugin)
 {
 #ifdef HAVE_GNUTLS
-	gaim_ssl_set_ops(&ssl_ops);
+	if (!gaim_ssl_get_ops()) {
+		gaim_ssl_set_ops(&ssl_ops);
+	}
 
+   /* Init GNUTLS now so others can use it even if sslconn never does */
+   ssl_gnutls_init_gnutls();
 	return TRUE;
 #else
 	return FALSE;
@@ -189,7 +197,9 @@
 plugin_unload(GaimPlugin *plugin)
 {
 #ifdef HAVE_GNUTLS
-	gaim_ssl_set_ops(NULL);
+	if (gaim_ssl_get_ops() == &ssl_ops) {
+		gaim_ssl_set_ops(NULL);
+	}
 #endif
 
 	return TRUE;