Implement /initialSync

This commit is contained in:
Gergely Polonkai 2015-12-15 09:32:19 +01:00
parent 9f763865db
commit 056c4c1ce7
3 changed files with 45 additions and 0 deletions

View File

@ -60,6 +60,7 @@ matrix_http_api_get_base_url
matrix_http_api_gen_parameters matrix_http_api_gen_parameters
matrix_http_api_register_account matrix_http_api_register_account
matrix_http_api_login matrix_http_api_login
matrix_http_api_initial_sync
<SUBSECTION Standard> <SUBSECTION Standard>
MatrixHTTPAPI MatrixHTTPAPI
MatrixHTTPAPIClass MatrixHTTPAPIClass

View File

@ -83,6 +83,7 @@ matrix_http_api_matrix_api_init(MatrixAPIInterface *iface)
{ {
iface->login = matrix_http_api_login; iface->login = matrix_http_api_login;
iface->register_account = matrix_http_api_register_account; iface->register_account = matrix_http_api_register_account;
iface->initial_sync = matrix_http_api_initial_sync;
} }
static void static void
@ -591,3 +592,42 @@ matrix_http_api_register_account(MatrixAPI *api,
login_type, login_type,
parameters); parameters);
} }
/**
* matrix_http_api_initial_sync:
* @api: a #MatrixHTTPAPI object
* @callback: (scope async): the function to call when the request is
* finished
* @user_data: user data to pass to the callback function
* @limit: maximum number of messages to return for each room
*
* Perform /initialSync
*/
void
matrix_http_api_initial_sync(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
guint limit)
{
JsonBuilder *builder;
JsonNode *content,
*node;
builder = json_builder_new();
json_builder_begin_object(builder);
node = json_node_new(JSON_NODE_VALUE);
json_node_set_int(node, limit);
json_builder_set_member_name(builder, "limit");
json_builder_add_value(builder, node);
json_builder_end_object(builder);
content = json_builder_get_root(builder);
matrix_http_api_send(MATRIX_HTTP_API(api),
callback, user_data,
"POST", "/initialSync",
content,
NULL);
}

View File

@ -64,6 +64,10 @@ void matrix_http_api_register_account(MatrixAPI *api,
gpointer user_data, gpointer user_data,
gchar *login_type, gchar *login_type,
GHashTable *parameters); GHashTable *parameters);
void matrix_http_api_initial_sync(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
guint limit);
G_END_DECLS G_END_DECLS