Implement get_presence_list

This commit is contained in:
Gergely Polonkai 2016-01-15 10:37:10 +01:00
parent a037cb7aad
commit 0b003dd612
2 changed files with 25 additions and 2 deletions

View File

@ -583,7 +583,8 @@ _response_callback(SoupSession *session,
message); message);
} }
} }
} else { // Not a JSON object } else if (!JSON_NODE_HOLDS_ARRAY(content)) {
// Not a JSON object, neither an array
err = g_error_new(MATRIX_API_ERROR, err = g_error_new(MATRIX_API_ERROR,
MATRIX_API_ERROR_BAD_RESPONSE, MATRIX_API_ERROR_BAD_RESPONSE,
"Bad response (not a JSON object)"); "Bad response (not a JSON object)");
@ -991,6 +992,27 @@ i_join_room(MatrixAPI *api,
g_free(path); g_free(path);
} }
static void
i_get_presence_list(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
const gchar *user_id,
GError **error)
{
gchar *encoded_user_id;
gchar *path;
encoded_user_id = soup_uri_encode(user_id, NULL);
path = g_strdup_printf("presence/list/%s", encoded_user_id);
g_free(encoded_user_id);
_send(MATRIX_HTTP_API(api),
callback, user_data,
"GET", path, NULL, NULL,
error);
g_free(path);
}
static void static void
matrix_http_api_matrix_api_init(MatrixAPIInterface *iface) matrix_http_api_matrix_api_init(MatrixAPIInterface *iface)
{ {
@ -1007,7 +1029,7 @@ matrix_http_api_matrix_api_init(MatrixAPIInterface *iface)
iface->media_upload = NULL; iface->media_upload = NULL;
/* Presence */ /* Presence */
iface->get_presence_list = NULL; iface->get_presence_list = i_get_presence_list;
iface->update_presence_list = NULL; iface->update_presence_list = NULL;
iface->get_user_presence = NULL; iface->get_user_presence = NULL;
iface->set_user_presence = NULL; iface->set_user_presence = NULL;

View File

@ -102,6 +102,7 @@ login_finished(MatrixAPI *api, JsonNode *content, gpointer data, GError *err)
"GLib SDK test room", "GLib SDK test room",
MATRIX_API_ROOM_VISIBILITY_DEFAULT, MATRIX_API_ROOM_VISIBILITY_DEFAULT,
NULL, NULL, NULL, NULL); NULL, NULL, NULL, NULL);
matrix_api_get_presence_list(api, NULL, NULL, user_id, NULL);
} else { } else {
g_printf("Login unsuccessful!\n"); g_printf("Login unsuccessful!\n");
} }