im.pidgin.cpw.resiak.disconnectreason: 01a63059fae1683476c49e5e5ade731afcc22d68

resiak at soc.pidgin.im resiak at soc.pidgin.im
Wed Oct 3 13:55:58 EDT 2007


revision:            01a63059fae1683476c49e5e5ade731afcc22d68
date:                2007-09-19T15:00:48
author:              resiak at soc.pidgin.im
branch:              im.pidgin.cpw.resiak.disconnectreason
changelog:
Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
to a PurpleDisconnectReason then calls purple_connection_error_reason().

manifest:
format_version "1"

new_manifest [12d21b93174876e7fbc7ef18483f1b9d4339c51a]

old_revision [9c6ac6e5bbd0d341259039d91bf74c84337a235c]

patch "libpurple/connection.c"
 from [88dcdd279f96ecf42ef0be512e31e8d567db74b0]
   to [54035c86fa011ee27210d3e662b715f023bc0bbb]

patch "libpurple/connection.h"
 from [c47390c398d40e68551b880bfef86622f0b2d1a9]
   to [c471b66ce9c6730e895e13e365656971946db7ce]

patch "libpurple/sslconn.h"
 from [9345fc0da1fe13e953208fb5a4e7ca9ba6f95b52]
   to [5a87990f45a43cf57856586e88692eb2a62ffa22]
-------------- next part --------------
#
#
# patch "libpurple/connection.c"
#  from [88dcdd279f96ecf42ef0be512e31e8d567db74b0]
#    to [54035c86fa011ee27210d3e662b715f023bc0bbb]
# 
# patch "libpurple/connection.h"
#  from [c47390c398d40e68551b880bfef86622f0b2d1a9]
#    to [c471b66ce9c6730e895e13e365656971946db7ce]
# 
# patch "libpurple/sslconn.h"
#  from [9345fc0da1fe13e953208fb5a4e7ca9ba6f95b52]
#    to [5a87990f45a43cf57856586e88692eb2a62ffa22]
#
============================================================
--- libpurple/connection.c	88dcdd279f96ecf42ef0be512e31e8d567db74b0
+++ libpurple/connection.c	54035c86fa011ee27210d3e662b715f023bc0bbb
@@ -525,6 +525,29 @@ purple_connection_error_reason (PurpleCo
 			purple_connection_get_account(gc));
 }
 
+void
+purple_connection_ssl_error (PurpleConnection *gc,
+                             PurpleSslErrorType ssl_error)
+{
+	PurpleDisconnectReason reason;
+
+	switch (ssl_error) {
+		case PURPLE_SSL_HANDSHAKE_FAILED:
+		case PURPLE_SSL_CONNECT_FAILED:
+			reason = PURPLE_REASON_ENCRYPTION_ERROR;
+			break;
+		case PURPLE_SSL_CERTIFICATE_INVALID:
+			/* TODO: maybe PURPLE_SSL_* should be more specific? */
+			reason = PURPLE_REASON_CERT_OTHER_ERROR;
+			break;
+		default:
+			g_assert_not_reached ();
+			reason = PURPLE_REASON_ENCRYPTION_ERROR;
+	}
+
+	purple_connection_error_reason (gc, reason, purple_ssl_strerror(ssl_error));
+}
+
 gboolean
 purple_connection_reason_is_fatal (PurpleDisconnectReason reason)
 {
============================================================
--- libpurple/connection.h	c47390c398d40e68551b880bfef86622f0b2d1a9
+++ libpurple/connection.h	c471b66ce9c6730e895e13e365656971946db7ce
@@ -121,6 +121,7 @@ typedef enum
 #include "account.h"
 #include "plugin.h"
 #include "status.h"
+#include "sslconn.h"
 
 /** Connection UI operations.  Used to notify the user of changes to
  *  connections, such as being disconnected, and to respond to the
@@ -389,6 +390,15 @@ purple_connection_error_reason (PurpleCo
                                 const char *description);
 
 /**
+ * Closes a connection due to an SSL error; this is basically a shortcut to
+ * turning the #PurpleSslErrorType into a #PurpleDisconnectReason and a
+ * human-readable string and then calling purple_connection_error_reason().
+ */
+void
+purple_connection_ssl_error (PurpleConnection *gc,
+                             PurpleSslErrorType ssl_error);
+
+/**
  * Reports whether a disconnection reason is fatal (in which case the account
  * should probably not be automatically reconnected) or transient (so
  * auto-reconnection is a good idea.
============================================================
--- libpurple/sslconn.h	9345fc0da1fe13e953208fb5a4e7ca9ba6f95b52
+++ libpurple/sslconn.h	5a87990f45a43cf57856586e88692eb2a62ffa22
@@ -26,11 +26,6 @@
 #ifndef _PURPLE_SSLCONN_H_
 #define _PURPLE_SSLCONN_H_
 
-#include "certificate.h"
-#include "proxy.h"
-
-#define PURPLE_SSL_DEFAULT_PORT 443
-
 typedef enum
 {
 	PURPLE_SSL_HANDSHAKE_FAILED = 1,
@@ -38,6 +33,11 @@ typedef enum
 	PURPLE_SSL_CERTIFICATE_INVALID = 3
 } PurpleSslErrorType;
 
+#include "certificate.h"
+#include "proxy.h"
+
+#define PURPLE_SSL_DEFAULT_PORT 443
+
 typedef struct _PurpleSslConnection PurpleSslConnection;
 
 typedef void (*PurpleSslInputFunction)(gpointer, PurpleSslConnection *,


More information about the Commits mailing list