--- a/libpurple/protocols/facebook/api.c Thu Jul 04 00:27:14 2019 -0400
+++ b/libpurple/protocols/facebook/api.c Thu Oct 10 01:39:27 2019 -0400
@@ -20,6 +20,7 @@
#include <json-glib/json-glib.h>
+#include <libsoup/soup.h> @@ -50,7 +51,7 @@
@@ -182,7 +183,7 @@
FbApiPrivate *priv = FB_API(obj)->priv;
- fb_http_conns_cancel_all(priv->cons);
+ soup_session_abort(priv->cons); g_hash_table_iter_init(&iter, priv->data);
while (g_hash_table_iter_next(&iter, NULL, (gpointer) &fata)) {
@@ -194,7 +195,7 @@
g_object_unref(priv->mqtt);
- fb_http_conns_free(priv->cons);
+ g_object_unref(priv->cons); g_hash_table_destroy(priv->data);
g_queue_free_full(priv->msgs, (GDestroyNotify) fb_api_message_free);
@@ -524,7 +525,7 @@
- priv->cons = fb_http_conns_new();
+ priv->cons = soup_session_new(); priv->msgs = g_queue_new();
priv->data = g_hash_table_new_full(g_direct_hash, g_direct_equal,
@@ -686,36 +687,27 @@
-fb_api_http_chk(FbApi *api, PurpleHttpConnection *con, PurpleHttpResponse *res,
+fb_api_http_chk(FbApi *api, SoupMessage *res, JsonNode **root) - FbApiPrivate *priv = api->priv;
- if (fb_http_conns_is_canceled(priv->cons)) {
+ msg = res->reason_phrase; + code = res->status_code; + data = res->response_body->data; + size = res->response_body->length; + fb_util_debug(FB_UTIL_DEBUG_INFO, "HTTP Response (%p):", res); + fb_util_debug(FB_UTIL_DEBUG_INFO, " Response Error: %s (%d)", msg, + fb_util_debug(FB_UTIL_DEBUG_INFO, " Response Error: %d", code); - msg = purple_http_response_get_error(res);
- code = purple_http_response_get_code(res);
- data = purple_http_response_get_data(res, &size);
- fb_http_conns_remove(priv->cons, con);
- emsg = g_strdup_printf("%s (%d)", msg, code);
- emsg = g_strdup_printf("%d", code);
- fb_util_debug(FB_UTIL_DEBUG_INFO, "HTTP Response (%p):", con);
- fb_util_debug(FB_UTIL_DEBUG_INFO, " Response Error: %s", emsg);
if (G_LIKELY(size > 0)) {
fb_util_debug(FB_UTIL_DEBUG_INFO, " Response Data: %.*s",
@@ -742,10 +734,10 @@
-static PurpleHttpConnection *
fb_api_http_req(FbApi *api, const gchar *url, const gchar *name,
const gchar *method, FbHttpParams *params,
- PurpleHttpCallback callback)
+ SoupSessionCallback callback) FbApiPrivate *priv = api->priv;
@@ -754,8 +746,7 @@
- PurpleHttpConnection *ret;
- PurpleHttpRequest *req;
fb_http_params_set_str(params, "api_key", FB_API_KEY);
fb_http_params_set_str(params, "device_id", priv->did);
@@ -767,9 +758,7 @@
fb_http_params_set_str(params, "locale", val);
- req = purple_http_request_new(url);
- purple_http_request_set_max_len(req, -1);
- purple_http_request_set_method(req, "POST");
+ msg = soup_message_new("POST", url); /* Ensure an old signature is not computed */
g_hash_table_remove(params, "sig");
@@ -794,30 +783,30 @@
if (priv->token != NULL) {
data = g_strdup_printf("OAuth %s", priv->token);
- purple_http_request_header_set(req, "Authorization", data);
+ soup_message_headers_replace(msg->request_headers, "Authorization", - purple_http_request_header_set(req, "User-Agent", FB_API_AGENT);
- purple_http_request_header_set(req, "Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
+ soup_message_headers_replace(msg->request_headers, "User-Agent", data = fb_http_params_close(params, NULL);
- purple_http_request_set_contents(req, data, -1);
- ret = purple_http_request(priv->gc, req, callback, api);
- fb_http_conns_add(priv->cons, ret);
- purple_http_request_unref(req);
- fb_util_debug(FB_UTIL_DEBUG_INFO, "HTTP Request (%p):", ret);
+ soup_message_set_request(msg, + "application/x-www-form-urlencoded; charset=utf-8", + SOUP_MEMORY_TAKE, data, -1); + soup_session_queue_message(priv->cons, msg, callback, api); + fb_util_debug(FB_UTIL_DEBUG_INFO, "HTTP Request (%p):", msg); fb_util_debug(FB_UTIL_DEBUG_INFO, " Request URL: %s", url);
fb_util_debug(FB_UTIL_DEBUG_INFO, " Request Data: %s", data);
-static PurpleHttpConnection *
fb_api_http_query(FbApi *api, gint64 query, JsonBuilder *builder,
- PurpleHttpCallback hcb)
+ SoupSessionCallback hcb) @@ -865,19 +854,16 @@
-fb_api_cb_http_bool(PurpleHttpConnection *con, PurpleHttpResponse *res,
+fb_api_cb_http_bool(G_GNUC_UNUSED SoupSession *session, SoupMessage *res,
- if (!fb_api_http_chk(api, con, res, NULL)) {
+ if (!fb_api_http_chk(api, res, NULL)) { - hata = purple_http_response_get_data(res, NULL);
- if (!purple_strequal(hata, "true")) {
+ if (!purple_strequal(res->response_body->data, "true")) { fb_api_error_literal(api, FB_API_ERROR,
_("Failed generic API operation"));
@@ -1057,7 +1043,7 @@
-fb_api_cb_seqid(PurpleHttpConnection *con, PurpleHttpResponse *res,
+fb_api_cb_seqid(G_GNUC_UNUSED SoupSession *session, SoupMessage *res, @@ -1067,7 +1053,7 @@
- if (!fb_api_http_chk(api, con, res, &root)) {
+ if (!fb_api_http_chk(api, res, &root)) { @@ -2068,7 +2054,7 @@
-fb_api_cb_attach(PurpleHttpConnection *con, PurpleHttpResponse *res,
+fb_api_cb_attach(G_GNUC_UNUSED SoupSession *session, SoupMessage *res, @@ -2083,7 +2069,7 @@
static const gchar *imgexts[] = {".jpg", ".png", ".gif"};
- if (!fb_api_http_chk(api, con, res, &root)) {
+ if (!fb_api_http_chk(api, res, &root)) { @@ -2098,7 +2084,7 @@
- msg = fb_api_data_take(api, con);
+ msg = fb_api_data_take(api, res); str = fb_json_values_next_str(values, NULL);
name = g_ascii_strdown(str, -1);
@@ -2124,7 +2110,7 @@
fb_api_attach(FbApi *api, FbId aid, const gchar *msgid, FbApiMessage *msg)
- PurpleHttpConnection *http;
prms = fb_http_params_new();
fb_http_params_set_str(prms, "mid", msgid);
@@ -2137,7 +2123,7 @@
-fb_api_cb_auth(PurpleHttpConnection *con, PurpleHttpResponse *res,
+fb_api_cb_auth(G_GNUC_UNUSED SoupSession *session, SoupMessage *res, @@ -2146,7 +2132,7 @@
- if (!fb_api_http_chk(api, con, res, &root)) {
+ if (!fb_api_http_chk(api, res, &root)) { @@ -2205,7 +2191,7 @@
-fb_api_cb_contact(PurpleHttpConnection *con, PurpleHttpResponse *res,
+fb_api_cb_contact(G_GNUC_UNUSED SoupSession *session, SoupMessage *res, @@ -2216,7 +2202,7 @@
- if (!fb_api_http_chk(api, con, res, &root)) {
+ if (!fb_api_http_chk(api, res, &root)) { @@ -2358,7 +2344,7 @@
-fb_api_cb_contacts(PurpleHttpConnection *con, PurpleHttpResponse *res,
+fb_api_cb_contacts(G_GNUC_UNUSED SoupSession *session, SoupMessage *res, @@ -2375,7 +2361,7 @@
- if (!fb_api_http_chk(api, con, res, &root)) {
+ if (!fb_api_http_chk(api, res, &root)) { @@ -2686,7 +2672,7 @@
-fb_api_cb_unread_msgs(PurpleHttpConnection *con, PurpleHttpResponse *res,
+fb_api_cb_unread_msgs(G_GNUC_UNUSED SoupSession *session, SoupMessage *res, @@ -2704,7 +2690,7 @@
- if (!fb_api_http_chk(api, con, res, &root)) {
+ if (!fb_api_http_chk(api, res, &root)) { @@ -2818,7 +2804,7 @@
-fb_api_cb_unread(PurpleHttpConnection *con, PurpleHttpResponse *res,
+fb_api_cb_unread(G_GNUC_UNUSED SoupSession *session, SoupMessage *res, @@ -2829,7 +2815,7 @@
- if (!fb_api_http_chk(api, con, res, &root)) {
+ if (!fb_api_http_chk(api, res, &root)) { @@ -2899,7 +2885,7 @@
-fb_api_cb_sticker(PurpleHttpConnection *con, PurpleHttpResponse *res,
+fb_api_cb_sticker(G_GNUC_UNUSED SoupSession *session, SoupMessage *res, @@ -2910,7 +2896,7 @@
- if (!fb_api_http_chk(api, con, res, &root)) {
+ if (!fb_api_http_chk(api, res, &root)) { @@ -2926,7 +2912,7 @@
- msg = fb_api_data_take(api, con);
+ msg = fb_api_data_take(api, res); msg->flags |= FB_API_MESSAGE_FLAG_IMAGE;
msg->text = fb_json_values_next_str_dup(values, NULL);
msgs = g_slist_prepend(msgs, msg);
@@ -2941,7 +2927,7 @@
fb_api_sticker(FbApi *api, FbId sid, FbApiMessage *msg)
- PurpleHttpConnection *http;
bldr = fb_json_bldr_new(JSON_NODE_OBJECT);
fb_json_bldr_arr_begin(bldr, "0");
@@ -3028,8 +3014,8 @@
-fb_api_cb_thread(PurpleHttpConnection *con, PurpleHttpResponse *res,
+fb_api_cb_thread(G_GNUC_UNUSED SoupSession *session, SoupMessage *res, @@ -3037,7 +3023,7 @@
- if (!fb_api_http_chk(api, con, res, &root)) {
+ if (!fb_api_http_chk(api, res, &root)) { @@ -3088,7 +3074,7 @@
-fb_api_cb_thread_create(PurpleHttpConnection *con, PurpleHttpResponse *res,
+fb_api_cb_thread_create(G_GNUC_UNUSED SoupSession *session, SoupMessage *res, @@ -3098,7 +3084,7 @@
- if (!fb_api_http_chk(api, con, res, &root)) {
+ if (!fb_api_http_chk(api, res, &root)) { @@ -3222,7 +3208,7 @@
-fb_api_cb_threads(PurpleHttpConnection *con, PurpleHttpResponse *res,
+fb_api_cb_threads(G_GNUC_UNUSED SoupSession *session, SoupMessage *res, @@ -3235,7 +3221,7 @@
- if (!fb_api_http_chk(api, con, res, &root)) {
+ if (!fb_api_http_chk(api, res, &root)) { --- a/libpurple/protocols/facebook/data.c Thu Jul 04 00:27:14 2019 -0400
+++ b/libpurple/protocols/facebook/data.c Thu Oct 10 01:39:27 2019 -0400
@@ -19,6 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
+#include <libsoup/soup.h> @@ -30,7 +31,7 @@
PurpleRoomlist *roomlist;
@@ -91,7 +92,7 @@
- fb_http_conns_cancel_all(priv->cons);
+ soup_session_abort(priv->cons); g_hash_table_iter_init(&iter, priv->evs);
while (g_hash_table_iter_next(&iter, NULL, &ptr)) {
@@ -102,7 +103,7 @@
g_object_unref(priv->api);
- fb_http_conns_free(priv->cons);
+ g_object_unref(priv->cons); g_queue_free_full(priv->msgs, (GDestroyNotify) fb_api_message_free);
g_hash_table_destroy(priv->imgs);
@@ -124,7 +125,7 @@
FbDataPrivate *priv = fb_data_get_instance_private(fata);
- priv->cons = fb_http_conns_new();
+ priv->cons = soup_session_new(); priv->msgs = g_queue_new();
priv->imgs = g_hash_table_new_full(g_direct_hash, g_direct_equal,
@@ -553,22 +554,17 @@
-fb_data_image_cb(PurpleHttpConnection *con, PurpleHttpResponse *res,
+fb_data_image_cb(G_GNUC_UNUSED SoupSession *session, SoupMessage *res, FbDataImagePrivate *priv = img->priv;
- FbDataPrivate *driv = priv->fata->priv;
- if (fb_http_conns_is_canceled(driv->cons)) {
- fb_http_conns_remove(driv->cons, con);
fb_http_error_chk(res, &err);
- priv->image = (guint8 *) purple_http_response_get_data(res, &priv->size);
+ priv->image = (guint8 *)res->response_body->data; + priv->size = res->response_body->length; if (G_LIKELY(err == NULL)) {
@@ -588,7 +584,6 @@
- PurpleHttpConnection *con;
g_return_if_fail(FB_IS_DATA(fata));
@@ -607,7 +602,7 @@
g_hash_table_iter_init(&iter, priv->imgs);
while (g_hash_table_iter_next(&iter, (gpointer *) &img, NULL)) {
- PurpleHttpRequest *req;
if (fb_data_image_get_active(img)) {
@@ -616,12 +611,9 @@
img->priv->active = TRUE;
url = fb_data_image_get_url(img);
- req = purple_http_request_new(url);
- purple_http_request_set_max_len(req, FB_DATA_ICON_SIZE_MAX);
- con = purple_http_request(priv->gc, req,
- fb_data_image_cb, img);
- fb_http_conns_add(priv->cons, con);
- purple_http_request_unref(req);
+ msg = soup_message_new("GET", url); + // purple_http_request_set_max_len(req, FB_DATA_ICON_SIZE_MAX); + soup_session_queue_message(priv->cons, msg, fb_data_image_cb, img); if (++active >= FB_DATA_ICON_MAX) {