/pidgin/main: 2522d124d883: update purple_http_response_get_data...
Gary Kramlich
grim at reaperworld.com
Thu Jan 17 00:21:54 EST 2013
Changeset: 2522d124d883d737fef7e9b126c179dadaa6c2b7
Author: Gary Kramlich <grim at reaperworld.com>
Date: 2013-01-16 23:21 -0600
Branch: default
URL: http://hg.pidgin.im/pidgin/main/rev/2522d124d883
Description:
update purple_http_response_get_data to take a second parameter that is a return address for the size of the data
diffstat:
libpurple/http.c | 18 +++++++++++++-----
libpurple/http.h | 3 ++-
libpurple/obsolete.c | 11 +++++++----
pidgin/plugins/relnot.c | 2 +-
4 files changed, 23 insertions(+), 11 deletions(-)
diffs (81 lines):
diff --git a/libpurple/http.c b/libpurple/http.c
--- a/libpurple/http.c
+++ b/libpurple/http.c
@@ -2016,14 +2016,22 @@ gsize purple_http_response_get_data_len(
return response->contents->len;
}
-const gchar * purple_http_response_get_data(PurpleHttpResponse *response)
+const gchar * purple_http_response_get_data(PurpleHttpResponse *response, size_t *len)
{
+ const gchar *ret = "";
+
g_return_val_if_fail(response != NULL, NULL);
- if (response->contents == NULL)
- return "";
-
- return response->contents->str;
+ if (response->contents != NULL) {
+ ret = response->contents->str;
+ if(len)
+ *len = response->contents->len;
+ } else {
+ if(len)
+ *len = 0;
+ }
+
+ return ret;
}
const GList * purple_http_response_get_all_headers(PurpleHttpResponse *response)
diff --git a/libpurple/http.h b/libpurple/http.h
--- a/libpurple/http.h
+++ b/libpurple/http.h
@@ -528,9 +528,10 @@ gsize purple_http_response_get_data_len(
* Response data is not written, if writer callback was set for request.
*
* @param response The response.
+ * @param len Return address for the size of the data. Can be NULL.
* @return The data.
*/
-const gchar * purple_http_response_get_data(PurpleHttpResponse *response);
+const gchar * purple_http_response_get_data(PurpleHttpResponse *response, size_t *len);
/**
* Gets all headers got with response.
diff --git a/libpurple/obsolete.c b/libpurple/obsolete.c
--- a/libpurple/obsolete.c
+++ b/libpurple/obsolete.c
@@ -80,12 +80,15 @@ static void purple_util_fetch_url_cb(Pur
PurpleHttpResponse *response, gpointer _wrap_data)
{
PurpleUtilLegacyWrapData *wrap_data = _wrap_data;
+ const char *data = NULL;
+ size_t len;
- if (wrap_data->cb && !wrap_data->url_data->cancelled)
- wrap_data->cb(wrap_data->url_data, wrap_data->user_data,
- purple_http_response_get_data(response),
- purple_http_response_get_data_len(response),
+ if (wrap_data->cb && !wrap_data->url_data->cancelled) {
+ data = purple_http_response_get_data(response, &len);
+
+ wrap_data->cb(wrap_data->url_data, wrap_data->user_data, data, len,
purple_http_response_get_error(response));
+ }
g_free(wrap_data->url_data);
g_free(wrap_data);
diff --git a/pidgin/plugins/relnot.c b/pidgin/plugins/relnot.c
--- a/pidgin/plugins/relnot.c
+++ b/pidgin/plugins/relnot.c
@@ -74,7 +74,7 @@ static void version_fetch_cb(PurpleHttpC
if(!purple_http_response_is_successfull(response))
return;
- changelog = purple_http_response_get_data(response);
+ changelog = purple_http_response_get_data(response, NULL);
while(changelog[i] && changelog[i] != '\n') i++;
More information about the Commits
mailing list