Implement media_download

This commit is contained in:
Gergely Polonkai 2016-01-15 13:13:38 +01:00
parent 0b0be1d460
commit 7ed72bffc1
2 changed files with 33 additions and 1 deletions

View File

@ -1109,11 +1109,38 @@ i_get_user_presence(MatrixAPI *api,
_send(MATRIX_HTTP_API(api),
callback, user_data,
CALL_API,
"GET", path, NULL, NULL,
FALSE, error);
g_free(path);
}
static void
i_media_download(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
const gchar *server_name,
const gchar *media_id,
GError **error)
{
gchar *encoded_server_name, *encoded_media_id, *path;
encoded_server_name = soup_uri_encode(server_name, NULL);
encoded_media_id = soup_uri_encode(media_id, NULL);
path = g_strdup_printf("download/%s/%s",
encoded_server_name,
encoded_media_id);
g_free(encoded_server_name);
g_free(encoded_media_id);
_send(MATRIX_HTTP_API(api),
callback, user_data,
CALL_MEDIA,
"GET", path, NULL, NULL,
TRUE, error);
g_free(path);
}
static void
matrix_http_api_matrix_api_init(MatrixAPIInterface *iface)
{
@ -1125,7 +1152,7 @@ matrix_http_api_matrix_api_init(MatrixAPIInterface *iface)
iface->get_homeserver = i_get_homeserver;
/* Media */
iface->media_download = NULL;
iface->media_download = i_media_download;
iface->media_thumbnail = NULL;
iface->media_upload = NULL;

View File

@ -89,6 +89,11 @@ get_user_presence_finished(MatrixAPI *api,
soup_uri_get_scheme(avatar_uri),
soup_uri_get_host(avatar_uri),
soup_uri_get_path(avatar_uri));
matrix_api_media_download(api,
NULL, NULL,
soup_uri_get_host(avatar_uri),
soup_uri_get_path(avatar_uri) + 1,
NULL);
soup_uri_free(avatar_uri);
}