summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2012-02-21 13:25:24 +0000
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2012-02-21 13:29:26 +0000
commit81fe73ceb5b0693a92c2247bdb1da11b363b79dd (patch)
treede31a0f1bf925060ad8f81f2911d639b3c700435
parent17af336d3fe42109e9ab067c27bd9f20a915f9e5 (diff)
GNUTLS backend: don't use 0 as an error domain
It's never been considered valid, and since GLib 2.31.something it issues a warning, which breaks the Gabble regression tests. We're still using 0 as the error code because WockyTLSError has apparently never actually defined what its error enum is, and in its existing uses in the OpenSSL backend it's an OpenSSL error code, which is obviously not applicable here. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=46379 Reviewed-by: Vivek Dasmohapatra <vivek@collabora.co.uk>
-rw-r--r--wocky/Makefile.am1
-rw-r--r--wocky/wocky-openssl.c22
-rw-r--r--wocky/wocky-tls-common.c52
-rw-r--r--wocky/wocky-tls.c17
4 files changed, 58 insertions, 34 deletions
diff --git a/wocky/Makefile.am b/wocky/Makefile.am
index 74ce41a..a9805a9 100644
--- a/wocky/Makefile.am
+++ b/wocky/Makefile.am
@@ -144,6 +144,7 @@ handwritten_sources = \
wocky-session.c \
wocky-stanza.c \
wocky-utils.c \
+ wocky-tls-common.c \
wocky-tls-handler.c \
wocky-tls-connector.c \
wocky-xep-0115-capabilities.c \
diff --git a/wocky/wocky-openssl.c b/wocky/wocky-openssl.c
index c9fd71f..2762c12 100644
--- a/wocky/wocky-openssl.c
+++ b/wocky/wocky-openssl.c
@@ -233,28 +233,6 @@ G_DEFINE_TYPE (WockyTLSOutputStream, wocky_tls_output_stream, G_TYPE_OUTPUT_STRE
WOCKY_TYPE_TLS_OUTPUT_STREAM, \
WockyTLSOutputStream))
-GQuark
-wocky_tls_cert_error_quark (void)
-{
- static GQuark quark = 0;
-
- if (quark == 0)
- quark = g_quark_from_static_string ("wocky-tls-cert-error");
-
- return quark;
-}
-
-GQuark
-wocky_tls_error_quark (void)
-{
- static GQuark quark = 0;
-
- if (quark == 0)
- quark = g_quark_from_static_string ("wocky-tls-error");
-
- return quark;
-}
-
/* Ok: This function tries to retrieve the error that caused a problem from *
* bottom of the openssl error stack: The errnum argument is the error code *
* returned by the last openssl operation which MAY NOT have come from the *
diff --git a/wocky/wocky-tls-common.c b/wocky/wocky-tls-common.c
new file mode 100644
index 0000000..bf7d0c6
--- /dev/null
+++ b/wocky/wocky-tls-common.c
@@ -0,0 +1,52 @@
+/*
+ * Wocky TLS integration - common stuff for GNUTLS and OpenSSL backends
+ * (This would be called wocky-tls.c, but that's the GNUTLS backend for
+ * historical reasons.)
+ *
+ * Copyright © 2008 Christian Kellner, Samuel Cormier-Iijima
+ * Copyright © 2008-2009 Codethink Limited
+ * Copyright © 2009-2012 Collabora Limited
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2 of the licence or (at
+ * your option) any later version.
+ *
+ * Authors: Vivek Dasmohapatra <vivek@collabora.co.uk>
+ * Ryan Lortie <desrt@desrt.ca>
+ * Christian Kellner <gicmo@gnome.org>
+ * Samuel Cormier-Iijima <sciyoshi@gmail.com>
+ *
+ * Based on an unmerged gnio feature. See wocky-tls.c for details.
+ */
+
+#include "config.h"
+
+#include "wocky-tls.h"
+
+GQuark
+wocky_tls_cert_error_quark (void)
+{
+ static GQuark quark = 0;
+
+ if (quark == 0)
+ quark = g_quark_from_static_string ("wocky-tls-cert-error");
+
+ return quark;
+}
+
+GQuark
+wocky_tls_error_quark (void)
+{
+ static GQuark quark = 0;
+
+ if (quark == 0)
+ quark = g_quark_from_static_string ("wocky-tls-error");
+
+ return quark;
+}
+
+/* this file is "borrowed" from an unmerged gnio feature: */
+/* Local Variables: */
+/* c-file-style: "gnu" */
+/* End: */
diff --git a/wocky/wocky-tls.c b/wocky/wocky-tls.c
index 609688b..a3729b0 100644
--- a/wocky/wocky-tls.c
+++ b/wocky/wocky-tls.c
@@ -1,4 +1,7 @@
/*
+ * Wocky TLS integration - GNUTLS implementation
+ * (just named -tls for historical reasons)
+ *
* Copyright © 2008 Christian Kellner, Samuel Cormier-Iijima
* Copyright © 2008-2009 Codethink Limited
* Copyright © 2009 Collabora Limited
@@ -261,17 +264,6 @@ G_DEFINE_TYPE (WockyTLSOutputStream, wocky_tls_output_stream, G_TYPE_OUTPUT_STRE
WOCKY_TYPE_TLS_OUTPUT_STREAM, \
WockyTLSOutputStream))
-GQuark
-wocky_tls_cert_error_quark (void)
-{
- static GQuark quark = 0;
-
- if (quark == 0)
- quark = g_quark_from_static_string ("wocky-tls-cert-error");
-
- return quark;
-}
-
static const gchar *hdesc_to_string (long desc)
{
#define HDESC(x) case GNUTLS_HANDSHAKE_##x: return #x; break;
@@ -310,7 +302,8 @@ wocky_tls_set_error (GError **error,
int code = (int) result;
if (result < 0)
- g_set_error (error, 0, 0, "%d: %s", code, error_to_string (code));
+ g_set_error (error, WOCKY_TLS_ERROR, 0, "%d: %s",
+ code, error_to_string (code));
return result < 0;
}