From e32948f788632fb5edf431a0e4867edae50aeaa6 Mon Sep 17 00:00:00 2001 From: "Dr. David Alan Gilbert" Date: Sun, 16 Oct 2016 02:23:36 +0100 Subject: [PATCH] Allow building on libpurple 2.10.x In 2f143058d I used the purple_util_fetch_url_request_data_len_with_account which turns out to be new in libpurple 2.11 and ubuntu is still stuck on 2.10. This is a build hack that allows building on 2.10 but doesn't allow sending images. Signed-off-by: Dr. David Alan Gilbert --- matrix-api.c | 20 ++++++++++++++++++++ matrix-room.c | 6 ++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/matrix-api.c b/matrix-api.c index 6992b55..f5a7ebf 100644 --- a/matrix-api.c +++ b/matrix-api.c @@ -28,6 +28,7 @@ /* libpurple */ #include #include +#include #include "libmatrix.h" #include "matrix-json.h" @@ -456,6 +457,7 @@ static GString *_build_request(PurpleAccount *acct, const gchar *url, * @returns handle for the request, or NULL if the request couldn't be started * (eg, invalid hostname). In this case, the error_callback will have * been called already. + * Note: extra_data/extra_len is only available on libpurple >=2.11.0 */ static MatrixApiRequestData *matrix_api_start_full(const gchar *url, const gchar *method, const gchar *extra_headers, @@ -485,6 +487,16 @@ static MatrixApiRequestData *matrix_api_start_full(const gchar *url, return NULL; } +#if !PURPLE_VERSION_CHECK(2,11,0) + if (extra_len) { + gchar *error_msg; + error_msg = g_strdup_printf(_("Feature not available on old purple version")); + error_callback(conn, user_data, error_msg); + g_free(error_msg); + return NULL; + } +#endif + request = _build_request(conn->pc->account, url, method, extra_headers, body, extra_data, extra_len); @@ -499,11 +511,19 @@ static MatrixApiRequestData *matrix_api_start_full(const gchar *url, data->bad_response_callback = bad_response_callback; data->user_data = user_data; +#if PURPLE_VERSION_CHECK(2,11,0) purple_data = purple_util_fetch_url_request_data_len_with_account( conn -> pc -> account, url, FALSE, NULL, TRUE, request->str, request->len, TRUE, max_len, matrix_api_complete, data); +#else + purple_data = purple_util_fetch_url_request_len_with_account( + conn -> pc -> account, + url, FALSE, NULL, TRUE, request->str, TRUE, + max_len, matrix_api_complete, + data); +#endif if(purple_data == NULL) { /* we couldn't start the request. In this case, our callback will diff --git a/matrix-room.c b/matrix-room.c index b8af68e..89db8e5 100644 --- a/matrix-room.c +++ b/matrix-room.c @@ -497,8 +497,10 @@ static void _send_image_hook(MatrixRoomEvent *event, gboolean just_free) _image_upload_complete, _image_upload_error, _image_upload_bad_response, sied); - purple_conversation_set_data(sied->conv, PURPLE_CONV_DATA_ACTIVE_SEND, - fetch_data); + if (fetch_data) { + purple_conversation_set_data(sied->conv, PURPLE_CONV_DATA_ACTIVE_SEND, + fetch_data); + } }