changeset 18968:1677ead39ee3

- Add purple_ssl_strerror for handy error description power!
author William Ehlhardt <williamehlhardt@gmail.com>
date Wed, 27 Jun 2007 04:56:21 +0000
parents cf3d2780138e
children 17a6a99e7230
files libpurple/sslconn.c libpurple/sslconn.h
diffstat 2 files changed, 24 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/sslconn.c	Wed Jun 27 04:29:24 2007 +0000
+++ b/libpurple/sslconn.c	Wed Jun 27 04:56:21 2007 +0000
@@ -156,6 +156,22 @@
 	gsc->inpa = purple_input_add(gsc->fd, PURPLE_INPUT_READ, recv_cb, gsc);
 }
 
+const gchar *
+purple_ssl_strerror(PurpleSslErrorType error)
+{
+	switch(error) {
+		case PURPLE_SSL_CONNECT_FAILED:
+			return _("SSL Connection Failed");
+		case PURPLE_SSL_HANDSHAKE_FAILED:
+			return _("SSL Handshake Failed");
+		case PURPLE_SSL_CERTIFICATE_INVALID:
+			return _("SSL peer presented an invalid certificate");
+		default:
+			purple_debug_warning("sslconn", "Unknown SSL error code %d\n", error);
+			return _("Unknown SSL error");
+	}
+}
+
 PurpleSslConnection *
 purple_ssl_connect_fd(PurpleAccount *account, int fd,
 					PurpleSslInputFunction func,
--- a/libpurple/sslconn.h	Wed Jun 27 04:29:24 2007 +0000
+++ b/libpurple/sslconn.h	Wed Jun 27 04:56:21 2007 +0000
@@ -145,6 +145,14 @@
 gboolean purple_ssl_is_supported(void);
 
 /**
+ * Returns a human-readable string for an SSL error
+ *
+ * @param error      Error code
+ * @return Human-readable error explanation
+ */
+const gchar * purple_ssl_strerror(PurpleSslErrorType error);
+
+/**
  * Makes a SSL connection to the specified host and port.  The caller
  * should keep track of the returned value and use it to cancel the
  * connection, if needed.