# HG changeset patch
# Node ID 410aa84fe520
# Parent  b481323d02d5
diff --git a/libpurple/account.h b/libpurple/account.h
--- a/libpurple/account.h
+++ b/libpurple/account.h
@@ -40,6 +40,7 @@
 #include "buddy.h"
 #include "connection.h"
 #include "group.h"
+#include "purpleconnectionerrorinfo.h"
 #include "purpleprotocol.h"
 #include "purpleproxyinfo.h"
 #include "status.h"
diff --git a/libpurple/connection.h b/libpurple/connection.h
--- a/libpurple/connection.h
+++ b/libpurple/connection.h
@@ -34,9 +34,6 @@
 #define PURPLE_TYPE_CONNECTION_UI_OPS  (purple_connection_ui_ops_get_type())
 typedef struct _PurpleConnectionUiOps PurpleConnectionUiOps;
 
-#define PURPLE_TYPE_CONNECTION_ERROR_INFO  (purple_connection_error_info_get_type())
-typedef struct _PurpleConnectionErrorInfo PurpleConnectionErrorInfo;
-
 /* This is meant to track use-after-free errors.
  * TODO: it should be disabled in released code. */
 #define PURPLE_ASSERT_CONNECTION_IS_VALID(gc) \
@@ -102,102 +99,10 @@
  */
 #define PURPLE_CONNECTION_ERROR (g_quark_from_static_string("purple-connection-error"))
 
-/**
- * PurpleConnectionError:
- * @PURPLE_CONNECTION_ERROR_NETWORK_ERROR: There was an error sending or
- *         receiving on the network socket, or there was some protocol error
- *         (such as the server sending malformed data).
- * @PURPLE_CONNECTION_ERROR_INVALID_USERNAME: The username supplied was not
- *         valid.
- * @PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED: The username, password or
- *         some other credential was incorrect.  Use
- *         #PURPLE_CONNECTION_ERROR_INVALID_USERNAME instead if the username
- *         is known to be invalid.
- * @PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE: libpurple doesn't speak
- *         any of the authentication methods the server offered.
- * @PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT: libpurple was built without SSL
- *         support, and the connection needs SSL.
- * @PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR: There was an error negotiating
- *         SSL on this connection, or the server does not support encryption
- *         but an account option was set to require it.
- * @PURPLE_CONNECTION_ERROR_NAME_IN_USE: Someone is already connected to the
- *         server using the name you are trying to connect with.
- * @PURPLE_CONNECTION_ERROR_INVALID_SETTINGS: The username/server/other
- *         preference for the account isn't valid.  For instance, on IRC the
- *         username cannot contain white space.  This reason should not be used
- *         for incorrect passwords etc: use
- *         #PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED for that.
- * @PURPLE_CONNECTION_ERROR_CERT_NOT_PROVIDED: The server did not provide a
- *         SSL certificate.
- * @PURPLE_CONNECTION_ERROR_CERT_UNTRUSTED: The server's SSL certificate could
- *         not be trusted.
- * @PURPLE_CONNECTION_ERROR_CERT_EXPIRED: The server's SSL certificate has
- *         expired.
- * @PURPLE_CONNECTION_ERROR_CERT_NOT_ACTIVATED: The server's SSL certificate is
- *         not yet valid.
- * @PURPLE_CONNECTION_ERROR_CERT_HOSTNAME_MISMATCH: The server's SSL
- *         certificate did not match its hostname.
- * @PURPLE_CONNECTION_ERROR_CERT_FINGERPRINT_MISMATCH: The server's SSL
- *         certificate does not have the expected fingerprint.
- * @PURPLE_CONNECTION_ERROR_CERT_SELF_SIGNED: The server's SSL certificate is
- *         self-signed.
- * @PURPLE_CONNECTION_ERROR_CERT_OTHER_ERROR: There was some other error
- *         validating the server's SSL certificate.
- * @PURPLE_CONNECTION_ERROR_OTHER_ERROR: Some other error occurred which fits
- *         into none of the other categories.
- *
- * Possible errors that can cause a connection to be closed.
- */
-typedef enum
-{
-	PURPLE_CONNECTION_ERROR_NETWORK_ERROR = 0,
-	PURPLE_CONNECTION_ERROR_INVALID_USERNAME = 1,
-	PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED = 2,
-	PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE = 3,
-	PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT = 4,
-	PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR = 5,
-	PURPLE_CONNECTION_ERROR_NAME_IN_USE = 6,
-
-	/* TODO This reason really shouldn't be necessary. Usernames and
-	 *      other account preferences should be validated when the
-	 *      account is created. */
-	PURPLE_CONNECTION_ERROR_INVALID_SETTINGS = 7,
-
-	PURPLE_CONNECTION_ERROR_CERT_NOT_PROVIDED = 8,
-	PURPLE_CONNECTION_ERROR_CERT_UNTRUSTED = 9,
-	PURPLE_CONNECTION_ERROR_CERT_EXPIRED = 10,
-	PURPLE_CONNECTION_ERROR_CERT_NOT_ACTIVATED = 11,
-	PURPLE_CONNECTION_ERROR_CERT_HOSTNAME_MISMATCH = 12,
-	PURPLE_CONNECTION_ERROR_CERT_FINGERPRINT_MISMATCH = 13,
-	PURPLE_CONNECTION_ERROR_CERT_SELF_SIGNED = 14,
-	PURPLE_CONNECTION_ERROR_CERT_OTHER_ERROR = 15,
-
-	PURPLE_CONNECTION_ERROR_CUSTOM_TEMPORARY = 16,
-	PURPLE_CONNECTION_ERROR_CUSTOM_FATAL = 17,
-
-	/* purple_connection_error() in connection.c uses the fact that
-	 * this is the last member of the enum when sanity-checking; if other
-	 * reasons are added after it, the check must be updated.
-	 */
-	PURPLE_CONNECTION_ERROR_OTHER_ERROR = 18
-} PurpleConnectionError;
-
-/**
- * PurpleConnectionErrorInfo:
- * @type: The type of error.
- * @description: A localised, human-readable description of the error.
- *
- * Holds the type of an error along with its description.
- */
-struct _PurpleConnectionErrorInfo
-{
-	PurpleConnectionError type;
-	char *description;
-};
-
 #include <time.h>
 
 #include "account.h"
+#include "purpleconnectionerrorinfo.h"
 #include "purpleprotocol.h"
 #include "status.h"
 
@@ -277,13 +182,6 @@
 G_DECLARE_FINAL_TYPE(PurpleConnection, purple_connection, PURPLE, CONNECTION, GObject)
 
 /**
- * purple_connection_error_info_get_type:
- *
- * Returns: The #GType for the #PurpleConnectionErrorInfo boxed structure.
- */
-GType purple_connection_error_info_get_type(void);
-
-/**
  * purple_connection_set_state:
  * @gc:    The connection.
  * @state: The connection state.
diff --git a/libpurple/connection.c b/libpurple/connection.c
--- a/libpurple/connection.c
+++ b/libpurple/connection.c
@@ -101,10 +101,6 @@
 
 static int connections_handle;
 
-static PurpleConnectionErrorInfo *
-purple_connection_error_info_new(PurpleConnectionError type,
-                                 const gchar *description);
-
 G_DEFINE_TYPE(PurpleConnection, purple_connection, G_TYPE_OBJECT)
 
 /**************************************************************************
@@ -522,22 +518,6 @@
 	}
 }
 
-static PurpleConnectionErrorInfo *
-purple_connection_error_info_new(PurpleConnectionError type,
-                                 const gchar *description)
-{
-	PurpleConnectionErrorInfo *err;
-
-	g_return_val_if_fail(description != NULL, NULL);
-
-	err = g_new(PurpleConnectionErrorInfo, 1);
-
-	err->type = type;
-	err->description = g_strdup(description);
-
-	return err;
-}
-
 /**************************************************************************
  * GBoxed code
  **************************************************************************/
@@ -567,36 +547,6 @@
 	return type;
 }
 
-static PurpleConnectionErrorInfo *
-purple_connection_error_info_copy(PurpleConnectionErrorInfo *err)
-{
-	g_return_val_if_fail(err != NULL, NULL);
-
-	return purple_connection_error_info_new(err->type, err->description);
-}
-
-static void
-purple_connection_error_info_free(PurpleConnectionErrorInfo *err) {
-	g_return_if_fail(err != NULL);
-
-	g_free(err->description);
-	g_free(err);
-}
-
-GType
-purple_connection_error_info_get_type(void) {
-	static GType type = 0;
-
-	if (type == 0) {
-		type = g_boxed_type_register_static("PurpleConnectionErrorInfo",
-				(GBoxedCopyFunc)purple_connection_error_info_copy,
-				(GBoxedFreeFunc)purple_connection_error_info_free);
-	}
-
-	return type;
-}
-
-
 /**************************************************************************
  * Helpers
  **************************************************************************/
diff --git a/libpurple/meson.build b/libpurple/meson.build
--- a/libpurple/meson.build
+++ b/libpurple/meson.build
@@ -44,6 +44,7 @@
 	'purplebuddypresence.c',
 	'purplechatconversation.c',
 	'purplechatuser.c',
+	'purpleconnectionerrorinfo.c',
 	'purpleconversation.c',
 	'purpleconversationmanager.c',
 	'purpleconversationuiops.c',
@@ -144,6 +145,7 @@
 	'purplebuddypresence.h',
 	'purplechatconversation.h',
 	'purplechatuser.h',
+	'purpleconnectionerrorinfo.h',
 	'purpleconversation.h',
 	'purpleconversationmanager.h',
 	'purpleconversationuiops.h',
@@ -251,6 +253,7 @@
 	'notify.h',
 	'plugins.h',
 	'purplechatuser.h',
+	'purpleconnectionerrorinfo.h',
 	'purpleconversation.h',
 	'purpleimconversation.h',
 	'purplemessage.h',
diff --git a/libpurple/purpleconnectionerrorinfo.h b/libpurple/purpleconnectionerrorinfo.h
new file mode 100644
--- /dev/null
+++ b/libpurple/purpleconnectionerrorinfo.h
@@ -0,0 +1,165 @@
+/*
+ * Purple - Internet Messaging Library
+ * Copyright (C) Pidgin Developers <devel@pidgin.im>
+ *
+ * This library 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 License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <https://www.gnu.org/licenses/>.
+ */
+
+#if !defined(PURPLE_GLOBAL_HEADER_INSIDE) && !defined(PURPLE_COMPILATION)
+# error "only <purple.h> may be included directly"
+#endif
+
+#ifndef PURPLE_CONNECTION_ERROR_INFO_H
+#define PURPLE_CONNECTION_ERROR_INFO_H
+
+#include <glib.h>
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+/**
+ * PurpleConnectionError:
+ * @PURPLE_CONNECTION_ERROR_NETWORK_ERROR: There was an error sending or
+ *         receiving on the network socket, or there was some protocol error
+ *         (such as the server sending malformed data).
+ * @PURPLE_CONNECTION_ERROR_INVALID_USERNAME: The username supplied was not
+ *         valid.
+ * @PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED: The username, password or
+ *         some other credential was incorrect.  Use
+ *         #PURPLE_CONNECTION_ERROR_INVALID_USERNAME instead if the username
+ *         is known to be invalid.
+ * @PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE: libpurple doesn't speak
+ *         any of the authentication methods the server offered.
+ * @PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT: libpurple was built without SSL
+ *         support, and the connection needs SSL.
+ * @PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR: There was an error negotiating
+ *         SSL on this connection, or the server does not support encryption
+ *         but an account option was set to require it.
+ * @PURPLE_CONNECTION_ERROR_NAME_IN_USE: Someone is already connected to the
+ *         server using the name you are trying to connect with.
+ * @PURPLE_CONNECTION_ERROR_INVALID_SETTINGS: The username/server/other
+ *         preference for the account isn't valid.  For instance, on IRC the
+ *         username cannot contain white space.  This reason should not be used
+ *         for incorrect passwords etc: use
+ *         #PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED for that.
+ * @PURPLE_CONNECTION_ERROR_CERT_NOT_PROVIDED: The server did not provide a
+ *         SSL certificate.
+ * @PURPLE_CONNECTION_ERROR_CERT_UNTRUSTED: The server's SSL certificate could
+ *         not be trusted.
+ * @PURPLE_CONNECTION_ERROR_CERT_EXPIRED: The server's SSL certificate has
+ *         expired.
+ * @PURPLE_CONNECTION_ERROR_CERT_NOT_ACTIVATED: The server's SSL certificate is
+ *         not yet valid.
+ * @PURPLE_CONNECTION_ERROR_CERT_HOSTNAME_MISMATCH: The server's SSL
+ *         certificate did not match its hostname.
+ * @PURPLE_CONNECTION_ERROR_CERT_FINGERPRINT_MISMATCH: The server's SSL
+ *         certificate does not have the expected fingerprint.
+ * @PURPLE_CONNECTION_ERROR_CERT_SELF_SIGNED: The server's SSL certificate is
+ *         self-signed.
+ * @PURPLE_CONNECTION_ERROR_CERT_OTHER_ERROR: There was some other error
+ *         validating the server's SSL certificate.
+ * @PURPLE_CONNECTION_ERROR_OTHER_ERROR: Some other error occurred which fits
+ *         into none of the other categories.
+ *
+ * Possible errors that can cause a connection to be closed.
+ */
+typedef enum
+{
+	PURPLE_CONNECTION_ERROR_NETWORK_ERROR = 0,
+	PURPLE_CONNECTION_ERROR_INVALID_USERNAME = 1,
+	PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED = 2,
+	PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE = 3,
+	PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT = 4,
+	PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR = 5,
+	PURPLE_CONNECTION_ERROR_NAME_IN_USE = 6,
+
+	/* TODO This reason really shouldn't be necessary. Usernames and
+	 *      other account preferences should be validated when the
+	 *      account is created. */
+	PURPLE_CONNECTION_ERROR_INVALID_SETTINGS = 7,
+
+	PURPLE_CONNECTION_ERROR_CERT_NOT_PROVIDED = 8,
+	PURPLE_CONNECTION_ERROR_CERT_UNTRUSTED = 9,
+	PURPLE_CONNECTION_ERROR_CERT_EXPIRED = 10,
+	PURPLE_CONNECTION_ERROR_CERT_NOT_ACTIVATED = 11,
+	PURPLE_CONNECTION_ERROR_CERT_HOSTNAME_MISMATCH = 12,
+	PURPLE_CONNECTION_ERROR_CERT_FINGERPRINT_MISMATCH = 13,
+	PURPLE_CONNECTION_ERROR_CERT_SELF_SIGNED = 14,
+	PURPLE_CONNECTION_ERROR_CERT_OTHER_ERROR = 15,
+
+	PURPLE_CONNECTION_ERROR_CUSTOM_TEMPORARY = 16,
+	PURPLE_CONNECTION_ERROR_CUSTOM_FATAL = 17,
+
+	/* purple_connection_error() in connection.c uses the fact that
+	 * this is the last member of the enum when sanity-checking; if other
+	 * reasons are added after it, the check must be updated.
+	 */
+	PURPLE_CONNECTION_ERROR_OTHER_ERROR = 18
+} PurpleConnectionError;
+
+/**
+ * PurpleConnectionErrorInfo:
+ * @type: The type of error.
+ * @description: A localised, human-readable description of the error.
+ *
+ * Holds the type of an error along with its description.
+ */
+typedef struct
+{
+	PurpleConnectionError type;
+	char *description;
+} PurpleConnectionErrorInfo;
+
+
+#define PURPLE_TYPE_CONNECTION_ERROR_INFO (purple_connection_error_info_get_type())
+GType purple_connection_error_info_get_type(void);
+
+/**
+ * purple_connection_error_info_new:
+ * @type: The [enum@Purple.PurpleConnectionError] of the error.
+ * @description: The description of the error.
+ *
+ * Creates a new error info with the given properties.
+ *
+ * Returns: (transfer full): The new instance.
+ *
+ * Since: 3.0.0
+ */
+PurpleConnectionErrorInfo *purple_connection_error_info_new(PurpleConnectionError type, const gchar *description);
+
+/**
+ * purple_connection_error_info_copy:
+ * @info: The instance to copy.
+ *
+ * Creates a copy of @info.
+ *
+ * Returns: (transfer full): A new copy of @info.
+ *
+ * Since: 3.0.0
+ */
+PurpleConnectionErrorInfo *purple_connection_error_info_copy(PurpleConnectionErrorInfo *info);
+
+/**
+ * purple_connection_error_info_free:
+ * @info: The instance to free.
+ *
+ * Frees the memory associated with @info.
+ *
+ * Since: 3.0.0
+ */
+void purple_connection_error_info_free(PurpleConnectionErrorInfo *info);
+
+G_END_DECLS
+
+#endif /* PURPLE_CONNECTION_ERROR_INFO_H */
diff --git a/libpurple/purpleconnectionerrorinfo.c b/libpurple/purpleconnectionerrorinfo.c
new file mode 100644
--- /dev/null
+++ b/libpurple/purpleconnectionerrorinfo.c
@@ -0,0 +1,58 @@
+/*
+ * Purple - Internet Messaging Library
+ * Copyright (C) Pidgin Developers <devel@pidgin.im>
+ *
+ * This library 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 License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <https://www.gnu.org/licenses/>.
+ */
+
+#include "purpleconnectionerrorinfo.h"
+
+G_DEFINE_BOXED_TYPE(PurpleConnectionErrorInfo, purple_connection_error_info,
+                    purple_connection_error_info_copy,
+                    purple_connection_error_info_free)
+
+/******************************************************************************
+ * Public API
+ *****************************************************************************/
+PurpleConnectionErrorInfo *
+purple_connection_error_info_new(PurpleConnectionError type,
+                                 const gchar *description)
+{
+	PurpleConnectionErrorInfo *info;
+
+	g_return_val_if_fail(description != NULL, NULL);
+
+	info = g_new(PurpleConnectionErrorInfo, 1);
+
+	info->type = type;
+	info->description = g_strdup(description);
+
+	return info;
+}
+
+PurpleConnectionErrorInfo *
+purple_connection_error_info_copy(PurpleConnectionErrorInfo *info)
+{
+	g_return_val_if_fail(info != NULL, NULL);
+
+	return purple_connection_error_info_new(info->type, info->description);
+}
+
+void
+purple_connection_error_info_free(PurpleConnectionErrorInfo *info) {
+	g_return_if_fail(info != NULL);
+
+	g_free(info->description);
+	g_free(info);
+}
