Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow building on libpurple 2.10.x #17

Merged
merged 1 commit into from
Oct 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions matrix-api.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
/* libpurple */
#include <debug.h>
#include <ntlm.h>
#include <libpurple/version.h>

#include "libmatrix.h"
#include "matrix-json.h"
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);

Expand All @@ -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
Expand Down
6 changes: 4 additions & 2 deletions matrix-room.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}


Expand Down