/soc/2015/jgeboski/facebook: f9437ac8aa5d: facebook: correctly p...
James Geboski
jgeboski at gmail.com
Sat Aug 1 17:27:14 EDT 2015
Changeset: f9437ac8aa5d9f6224db752114b0023fc73a97ed
Author: James Geboski <jgeboski at gmail.com>
Date: 2015-08-01 16:49 -0400
Branch: facebook
URL: https://hg.pidgin.im/soc/2015/jgeboski/facebook/rev/f9437ac8aa5d
Description:
facebook: correctly propagate MQTT SSL errors
diffstat:
libpurple/protocols/facebook/facebook.c | 8 +++++++-
libpurple/protocols/facebook/mqtt.c | 23 +++++++++++++++++++++--
libpurple/protocols/facebook/mqtt.h | 4 ++++
3 files changed, 32 insertions(+), 3 deletions(-)
diffs (91 lines):
diff --git a/libpurple/protocols/facebook/facebook.c b/libpurple/protocols/facebook/facebook.c
--- a/libpurple/protocols/facebook/facebook.c
+++ b/libpurple/protocols/facebook/facebook.c
@@ -189,6 +189,13 @@ fb_cb_api_error(FbApi *api, GError *erro
PurpleConnection *gc;
PurpleConnectionError errc;
+ gc = fb_data_get_connection(fata);
+
+ if (error->domain == FB_MQTT_SSL_ERROR) {
+ purple_connection_ssl_error(gc, error->code);
+ return;
+ }
+
if ((error->domain == FB_HTTP_ERROR) &&
(error->code >= 400) &&
(error->code <= 500))
@@ -200,7 +207,6 @@ fb_cb_api_error(FbApi *api, GError *erro
errc = PURPLE_CONNECTION_ERROR_NETWORK_ERROR;
}
- gc = fb_data_get_connection(fata);
purple_connection_error(gc, errc, error->message);
}
diff --git a/libpurple/protocols/facebook/mqtt.c b/libpurple/protocols/facebook/mqtt.c
--- a/libpurple/protocols/facebook/mqtt.c
+++ b/libpurple/protocols/facebook/mqtt.c
@@ -170,6 +170,18 @@ fb_mqtt_error_quark(void)
return q;
}
+GQuark
+fb_mqtt_ssl_error_quark(void)
+{
+ static GQuark q = 0;
+
+ if (G_UNLIKELY(q == 0)) {
+ q = g_quark_from_static_string("fb-mqtt-ssl-error-quark");
+ }
+
+ return q;
+}
+
FbMqtt *
fb_mqtt_new(PurpleConnection *gc)
{
@@ -550,13 +562,20 @@ static void
fb_mqtt_cb_open_error(PurpleSslConnection *ssl, PurpleSslErrorType error,
gpointer data)
{
+ const gchar *str;
FbMqtt *mqtt = data;
FbMqttPrivate *priv = mqtt->priv;
+ GError *err;
+
+ str = purple_ssl_strerror(error);
+ err = g_error_new_literal(FB_MQTT_SSL_ERROR, error, str);
+
+ g_signal_emit_by_name(mqtt, "error", err);
+ g_error_free(err);
/* Do not call purple_ssl_close() from the error_func */
priv->gsc = NULL;
-
- fb_mqtt_error(mqtt, FB_MQTT_ERROR_GENERAL, _("Failed to connect"));
+ fb_mqtt_close(mqtt);
}
void
diff --git a/libpurple/protocols/facebook/mqtt.h b/libpurple/protocols/facebook/mqtt.h
--- a/libpurple/protocols/facebook/mqtt.h
+++ b/libpurple/protocols/facebook/mqtt.h
@@ -53,6 +53,7 @@
#define FB_MQTT_MESSAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), FB_TYPE_MQTT_MESSAGE, FbMqttMessageClass))
#define FB_MQTT_ERROR fb_mqtt_error_quark()
+#define FB_MQTT_SSL_ERROR fb_mqtt_ssl_error_quark()
typedef enum _FbMqttConnectFlags FbMqttConnectFlags;
typedef enum _FbMqttError FbMqttError;
@@ -147,6 +148,9 @@ fb_mqtt_message_get_type(void);
GQuark
fb_mqtt_error_quark(void);
+GQuark
+fb_mqtt_ssl_error_quark(void);
+
FbMqtt *
fb_mqtt_new(PurpleConnection *gc);
More information about the Commits
mailing list