Start redefining MatrixAPI methods based on the Matrix.org API
This commit is contained in:
parent
ded4fc04bd
commit
503ff71f3c
@ -19,30 +19,114 @@ matrix_client_get_type
|
|||||||
<FILE>matrix-api</FILE>
|
<FILE>matrix-api</FILE>
|
||||||
<TITLE>MatrixAPI</TITLE>
|
<TITLE>MatrixAPI</TITLE>
|
||||||
MatrixAPICallback
|
MatrixAPICallback
|
||||||
matrix_api_ban_user
|
MatrixAPIRoomPreset
|
||||||
|
MatrixAPIRoomVisibility
|
||||||
|
MatrixAPIResizeMethod
|
||||||
|
MatrixAPIPresence
|
||||||
|
MatrixAPIPusher
|
||||||
|
MatrixAPIPusherKind
|
||||||
|
MatrixAPIPusherConditionKind
|
||||||
|
MatrixAPIEventDirection
|
||||||
|
MatrixAPIReceiptType
|
||||||
|
|
||||||
|
<SUBSECTION>
|
||||||
|
matrix_api_set_token
|
||||||
|
matrix_api_get_token
|
||||||
|
|
||||||
|
<SUBSECTION>
|
||||||
|
matrix_api_media_download
|
||||||
|
matrix_api_media_thumbnail
|
||||||
|
matrix_api_media_upload
|
||||||
|
|
||||||
|
<SUBSECTION>
|
||||||
|
matrix_api_get_presence_list
|
||||||
|
matrix_api_update_presence_list
|
||||||
|
matrix_api_get_user_presence
|
||||||
|
matrix_api_set_user_presence
|
||||||
|
|
||||||
|
<SUBSECTION>
|
||||||
|
matrix_api_modify_pusher
|
||||||
|
matrix_api_get_pushers
|
||||||
|
matrix_api_delete_pusher
|
||||||
|
matrix_api_get_pusher
|
||||||
|
matrix_api_add_pusher
|
||||||
|
matrix_api_toggle_pusher
|
||||||
|
|
||||||
|
<SUBSECTION>
|
||||||
matrix_api_create_room
|
matrix_api_create_room
|
||||||
matrix_api_event_stream
|
|
||||||
matrix_api_get_emote_body
|
<SUBSECTION>
|
||||||
matrix_api_get_html_body
|
matrix_api_delete_room_alias
|
||||||
matrix_api_get_text_body
|
matrix_api_get_room_id
|
||||||
matrix_api_get_room_name
|
matrix_api_create_room_alias
|
||||||
matrix_api_get_room_state
|
|
||||||
matrix_api_get_room_topic
|
<SUBSECTION>
|
||||||
matrix_api_initial_sync
|
matrix_api_list_public_rooms
|
||||||
|
|
||||||
|
<SUBSECTION>
|
||||||
|
matrix_api_ban_user
|
||||||
|
matrix_api_forget_room
|
||||||
|
matrix_api_invite_user_3rdparty
|
||||||
matrix_api_invite_user
|
matrix_api_invite_user
|
||||||
matrix_api_join_room
|
matrix_api_join_room
|
||||||
matrix_api_kick_user
|
|
||||||
matrix_api_leave_room
|
matrix_api_leave_room
|
||||||
matrix_api_login
|
|
||||||
matrix_api_register_account
|
<SUBSECTION>
|
||||||
matrix_api_send_emote
|
matrix_api_event_stream
|
||||||
matrix_api_send_message
|
matrix_api_get_event
|
||||||
|
matrix_api_initial_sync
|
||||||
|
matrix_api_get_event_context
|
||||||
|
matrix_api_initial_sync_room
|
||||||
|
matrix_api_list_room_members
|
||||||
|
matrix_api_list_room_messages
|
||||||
|
matrix_api_send_event_receipt
|
||||||
|
matrix_api_redact_event
|
||||||
matrix_api_send_message_event
|
matrix_api_send_message_event
|
||||||
matrix_api_send_state_event
|
matrix_api_get_room_state
|
||||||
matrix_api_set_membership
|
matrix_api_send_room_event
|
||||||
|
matrix_api_notify_room_typing
|
||||||
|
matrix_api_sync
|
||||||
|
matrix_api_create_filter
|
||||||
|
matrix_api_download_filter
|
||||||
|
|
||||||
|
<SUBSECTION>
|
||||||
|
matrix_api_whois
|
||||||
|
|
||||||
|
<SUBSECTION>
|
||||||
|
matrix_api_login
|
||||||
|
matrix_api_token_refresh
|
||||||
|
|
||||||
|
<SUBSECTION>
|
||||||
|
matrix_api_get_3pids
|
||||||
|
matrix_api_add_3pid
|
||||||
|
matrix_api_change_password
|
||||||
|
matrix_api_get_profile
|
||||||
|
matrix_api_get_avatar_url
|
||||||
|
matrix_api_set_avatar_url
|
||||||
|
matrix_api_get_display_name
|
||||||
|
matrix_api_set_display_name
|
||||||
|
matrix_api_register_account
|
||||||
|
matrix_api_set_account_data
|
||||||
|
matrix_api_get_room_tags
|
||||||
|
matrix_api_delete_room_tag
|
||||||
|
matrix_api_add_room_tag
|
||||||
|
|
||||||
|
<SUBSECTION>
|
||||||
|
matrix_api_get_turn_server
|
||||||
|
|
||||||
<SUBSECTION>
|
<SUBSECTION>
|
||||||
MatrixAPIError
|
MatrixAPIError
|
||||||
MATRIX_API_ERROR
|
MATRIX_API_ERROR
|
||||||
|
|
||||||
|
<SUBSECTION>
|
||||||
|
MatrixAPIEventFormat
|
||||||
|
MatrixAPIFilter
|
||||||
|
MatrixAPIRoomFilter
|
||||||
|
MatrixAPIEventFilter
|
||||||
|
MatrixAPIPresenceFilter
|
||||||
|
MatrixAPIStateEvent
|
||||||
|
MatrixAPI3PidCredential
|
||||||
|
|
||||||
<SUBSECTION Standard>
|
<SUBSECTION Standard>
|
||||||
MatrixAPI
|
MatrixAPI
|
||||||
MatrixAPIInterface
|
MatrixAPIInterface
|
||||||
@ -54,6 +138,24 @@ MATRIX_IS_API
|
|||||||
MATRIX_API_GET_IFACE
|
MATRIX_API_GET_IFACE
|
||||||
MatrixApiPrivate
|
MatrixApiPrivate
|
||||||
matrix_api_get_type
|
matrix_api_get_type
|
||||||
|
MATRIX_TYPE_API_EVENT_DIRECTION
|
||||||
|
matrix_api_event_direction_get_type
|
||||||
|
MATRIX_TYPE_API_EVENT_FORMAT
|
||||||
|
matrix_api_event_format_get_type
|
||||||
|
MATRIX_TYPE_API_PRESENCE
|
||||||
|
matrix_api_presence_get_type
|
||||||
|
MATRIX_TYPE_API_PUSHER_CONDITION_KIND
|
||||||
|
matrix_api_pusher_condition_kind_get_type
|
||||||
|
MATRIX_TYPE_API_PUSHER_KIND
|
||||||
|
matrix_api_pusher_kind_get_type
|
||||||
|
MATRIX_TYPE_API_RECEIPT_TYPE
|
||||||
|
matrix_api_receipt_type_get_type
|
||||||
|
MATRIX_TYPE_API_RESIZE_METHOD
|
||||||
|
matrix_api_resize_method_get_type
|
||||||
|
MATRIX_TYPE_API_ROOM_PRESET
|
||||||
|
matrix_api_room_preset_get_type
|
||||||
|
MATRIX_TYPE_API_ROOM_VISIBILITY
|
||||||
|
matrix_api_room_visibility_get_type
|
||||||
<SUBSECTION Private>
|
<SUBSECTION Private>
|
||||||
matrix_api_error_quark
|
matrix_api_error_quark
|
||||||
</SECTION>
|
</SECTION>
|
||||||
@ -64,7 +166,6 @@ matrix_http_api_new
|
|||||||
matrix_http_api_get_validate_certificate
|
matrix_http_api_get_validate_certificate
|
||||||
matrix_http_api_set_validate_certificate
|
matrix_http_api_set_validate_certificate
|
||||||
matrix_http_api_get_base_url
|
matrix_http_api_get_base_url
|
||||||
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
|
matrix_http_api_initial_sync
|
||||||
|
2102
src/matrix-api.c
2102
src/matrix-api.c
File diff suppressed because it is too large
Load Diff
1024
src/matrix-api.h
1024
src/matrix-api.h
File diff suppressed because it is too large
Load Diff
@ -50,7 +50,6 @@
|
|||||||
|
|
||||||
typedef struct _MatrixHTTPAPIPrivate {
|
typedef struct _MatrixHTTPAPIPrivate {
|
||||||
SoupSession *soup_session;
|
SoupSession *soup_session;
|
||||||
guint txn_id;
|
|
||||||
SoupURI *uri;
|
SoupURI *uri;
|
||||||
gchar *token;
|
gchar *token;
|
||||||
gboolean validate_certificate;
|
gboolean validate_certificate;
|
||||||
@ -82,10 +81,6 @@ static void
|
|||||||
matrix_http_api_matrix_api_init(MatrixAPIInterface *iface)
|
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->initial_sync = matrix_http_api_initial_sync;
|
|
||||||
iface->create_room = matrix_http_api_create_room;
|
|
||||||
iface->join_room = matrix_http_api_join_room;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -264,7 +259,6 @@ matrix_http_api_init(MatrixHTTPAPI *api)
|
|||||||
{
|
{
|
||||||
MatrixHTTPAPIPrivate *priv = matrix_http_api_get_instance_private(api);
|
MatrixHTTPAPIPrivate *priv = matrix_http_api_get_instance_private(api);
|
||||||
|
|
||||||
priv->txn_id = 0;
|
|
||||||
priv->uri = NULL;
|
priv->uri = NULL;
|
||||||
priv->token = NULL;
|
priv->token = NULL;
|
||||||
priv->validate_certificate = TRUE;
|
priv->validate_certificate = TRUE;
|
||||||
@ -430,196 +424,6 @@ response_callback(SoupSession *session,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
update_query_params(gchar *key, gchar *value, SoupURI *uri)
|
|
||||||
{
|
|
||||||
soup_uri_set_query_from_fields(uri, key, value, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
matrix_http_api_send(MatrixHTTPAPI *api,
|
|
||||||
MatrixAPICallback callback,
|
|
||||||
gpointer user_data,
|
|
||||||
const gchar *method,
|
|
||||||
const gchar *path,
|
|
||||||
JsonNode *content,
|
|
||||||
GHashTable *params)
|
|
||||||
{
|
|
||||||
MatrixHTTPAPIPrivate *priv = matrix_http_api_get_instance_private(api);
|
|
||||||
SoupMessage *msg;
|
|
||||||
JsonGenerator *generator;
|
|
||||||
gsize datalen;
|
|
||||||
gchar *data;
|
|
||||||
gchar *url;
|
|
||||||
MatrixHTTPAPIRequest *request;
|
|
||||||
SoupURI *uri;
|
|
||||||
|
|
||||||
if (!g_str_is_ascii(method)) {
|
|
||||||
g_warning("Method must be ASCII encoded!");
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((g_ascii_strcasecmp("POST", method) != 0)
|
|
||||||
&& (g_ascii_strcasecmp("GET", method) != 0)
|
|
||||||
&& (g_ascii_strcasecmp("PUT", method) != 0)
|
|
||||||
&& (g_ascii_strcasecmp("DELETE", method) != 0)) {
|
|
||||||
g_warning("Invalid method name '%s'", method);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (content) {
|
|
||||||
generator = json_generator_new();
|
|
||||||
json_generator_set_root(generator, content);
|
|
||||||
data = json_generator_to_data(generator, &datalen);
|
|
||||||
} else {
|
|
||||||
data = g_strdup("");
|
|
||||||
}
|
|
||||||
|
|
||||||
uri = soup_uri_new_with_base(priv->uri, path);
|
|
||||||
|
|
||||||
if (params) {
|
|
||||||
g_hash_table_foreach(params, (GHFunc)update_query_params, uri);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (priv->token) {
|
|
||||||
update_query_params("access_token", priv->token, uri);
|
|
||||||
}
|
|
||||||
|
|
||||||
url = soup_uri_to_string(uri, FALSE);
|
|
||||||
soup_uri_free(uri);
|
|
||||||
g_debug("Sending %s to %s", method, url);
|
|
||||||
|
|
||||||
msg = soup_message_new(method, url);
|
|
||||||
g_free(url);
|
|
||||||
soup_message_set_flags(msg, SOUP_MESSAGE_NO_REDIRECT);
|
|
||||||
soup_message_set_request(msg,
|
|
||||||
"application/json",
|
|
||||||
SOUP_MEMORY_TAKE,
|
|
||||||
data,
|
|
||||||
datalen);
|
|
||||||
request = g_new0(MatrixHTTPAPIRequest, 1);
|
|
||||||
request->request_content = content;
|
|
||||||
request->api = api;
|
|
||||||
request->callback = callback;
|
|
||||||
request->callback_data = user_data;
|
|
||||||
|
|
||||||
g_object_ref(msg);
|
|
||||||
soup_session_queue_message(priv->soup_session,
|
|
||||||
msg,
|
|
||||||
(SoupSessionCallback)response_callback, request);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
update_parameters(gchar *key, gchar *value, JsonBuilder *builder)
|
|
||||||
{
|
|
||||||
JsonNode *node = json_node_new(JSON_NODE_VALUE);
|
|
||||||
|
|
||||||
json_node_set_string(node, value);
|
|
||||||
json_builder_set_member_name(builder, key);
|
|
||||||
json_builder_add_value(builder, node);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
matrix_http_api_login_or_register(MatrixAPI *api,
|
|
||||||
MatrixAPICallback callback,
|
|
||||||
gpointer user_data,
|
|
||||||
gchar *type,
|
|
||||||
gchar *login_type,
|
|
||||||
GHashTable *parameters)
|
|
||||||
{
|
|
||||||
JsonBuilder *builder;
|
|
||||||
JsonNode *content,
|
|
||||||
*node;
|
|
||||||
|
|
||||||
builder = json_builder_new();
|
|
||||||
json_builder_begin_object(builder);
|
|
||||||
|
|
||||||
node = json_node_new(JSON_NODE_VALUE);
|
|
||||||
json_node_set_string(node, login_type);
|
|
||||||
json_builder_set_member_name(builder, "type");
|
|
||||||
json_builder_add_value(builder, node);
|
|
||||||
|
|
||||||
g_hash_table_foreach(parameters, (GHFunc)update_parameters, builder);
|
|
||||||
|
|
||||||
json_builder_end_object(builder);
|
|
||||||
|
|
||||||
content = json_builder_get_root(builder);
|
|
||||||
|
|
||||||
matrix_http_api_send(MATRIX_HTTP_API(api),
|
|
||||||
callback, user_data,
|
|
||||||
"POST", type,
|
|
||||||
content,
|
|
||||||
parameters);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* matrix_http_api_login:
|
|
||||||
* @api: a #MatrixAPI implementation
|
|
||||||
* @callback: (scope async) (allow-none): the function to call when
|
|
||||||
* the request is finished
|
|
||||||
* @user_data: user data to pass to the callback function
|
|
||||||
* @login_type: the login type to use
|
|
||||||
* @parameters: parameters to send with the login request
|
|
||||||
*
|
|
||||||
* Perform /login
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
matrix_http_api_login(MatrixAPI *api,
|
|
||||||
MatrixAPICallback callback,
|
|
||||||
gpointer user_data,
|
|
||||||
gchar *login_type,
|
|
||||||
GHashTable *parameters)
|
|
||||||
{
|
|
||||||
matrix_http_api_login_or_register(api,
|
|
||||||
callback,
|
|
||||||
user_data,
|
|
||||||
"login",
|
|
||||||
login_type,
|
|
||||||
parameters);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* matrix_http_api_gen_parameters:
|
|
||||||
* @param1_name: name of the first parameter
|
|
||||||
* @...: value of the first parameter, followed by name/value pairs,
|
|
||||||
* terminated by a NULL value as a parameter name
|
|
||||||
*
|
|
||||||
* Generate a GHashTable suitable as the parameters argument for
|
|
||||||
* different API calls.
|
|
||||||
*
|
|
||||||
* Returns: (transfer full): a #GHashTable with the specified
|
|
||||||
* parameter table
|
|
||||||
*/
|
|
||||||
GHashTable *
|
|
||||||
matrix_http_api_gen_parameters(const gchar *param1_name, ...)
|
|
||||||
{
|
|
||||||
GHashTable *table;
|
|
||||||
va_list var_args;
|
|
||||||
gchar *name;
|
|
||||||
|
|
||||||
g_return_val_if_fail(param1_name != NULL, NULL);
|
|
||||||
|
|
||||||
table = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
|
|
||||||
|
|
||||||
va_start(var_args, param1_name);
|
|
||||||
|
|
||||||
name = (gchar *)param1_name;
|
|
||||||
|
|
||||||
while (name) {
|
|
||||||
gchar *value = va_arg(var_args, gchar *);
|
|
||||||
|
|
||||||
g_hash_table_insert(table, name, value);
|
|
||||||
|
|
||||||
name = va_arg(var_args, gchar *);
|
|
||||||
}
|
|
||||||
|
|
||||||
va_end(var_args);
|
|
||||||
|
|
||||||
return table;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* matrix_http_api_get_base_url:
|
* matrix_http_api_get_base_url:
|
||||||
* @api: a #MatrixHTTPAPI implementation
|
* @api: a #MatrixHTTPAPI implementation
|
||||||
@ -636,153 +440,49 @@ matrix_http_api_get_base_url(MatrixHTTPAPI *api)
|
|||||||
return soup_uri_to_string(priv->uri, FALSE);
|
return soup_uri_to_string(priv->uri, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
static void
|
||||||
* matrix_http_api_register_account:
|
matrix_http_api_send(MatrixAPI *api,
|
||||||
* @api: a #MatrixAPI implementation
|
|
||||||
* @callback: (scope async) (allow-none): the function to call when
|
|
||||||
* the request is finished
|
|
||||||
* @user_data: user data to pass to the callback function
|
|
||||||
* @login_type: the login type to use
|
|
||||||
* @parameters: parameters to send with the registration request
|
|
||||||
*
|
|
||||||
* Perform /register
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
matrix_http_api_register_account(MatrixAPI *api,
|
|
||||||
MatrixAPICallback callback,
|
MatrixAPICallback callback,
|
||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
gchar *login_type,
|
const gchar *method,
|
||||||
GHashTable *parameters)
|
const gchar *path,
|
||||||
|
const JsonNode *content,
|
||||||
|
GError **error)
|
||||||
{
|
{
|
||||||
matrix_http_api_login_or_register(api,
|
if (!g_str_is_ascii(method)) {
|
||||||
callback,
|
g_warning("Method must be ASCII encoded!");
|
||||||
user_data,
|
|
||||||
"register",
|
|
||||||
login_type,
|
|
||||||
parameters);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* matrix_http_api_initial_sync:
|
|
||||||
* @api: a #MatrixHTTPAPI object
|
|
||||||
* @callback: (scope async) (allow-none): 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)
|
|
||||||
{
|
|
||||||
GHashTable *query_params;
|
|
||||||
gchar *limit_string = g_strdup_printf("%d", limit);
|
|
||||||
|
|
||||||
query_params = matrix_http_api_gen_parameters("limit", limit_string, NULL);
|
|
||||||
g_free(limit_string);
|
|
||||||
|
|
||||||
matrix_http_api_send(MATRIX_HTTP_API(api),
|
|
||||||
callback, user_data,
|
|
||||||
"POST", "initialSync",
|
|
||||||
NULL,
|
|
||||||
query_params);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* matrix_http_api_create_room:
|
|
||||||
* @api: a #MatrixHTTPAPI object
|
|
||||||
* @callback: (scope async) (allow-none): the function to call when
|
|
||||||
* the request is finished
|
|
||||||
* @user_data: user data to pass to the callback function
|
|
||||||
* @room_alias: an alias for the room
|
|
||||||
* @is_public: set to %TRUE if the room should be publicly visible
|
|
||||||
* @invitees: a list of user IDs to initially invite to the room
|
|
||||||
*
|
|
||||||
* Perform /createRoom
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
matrix_http_api_create_room(MatrixAPI *api,
|
|
||||||
MatrixAPICallback callback,
|
|
||||||
gpointer user_data,
|
|
||||||
gchar *room_alias,
|
|
||||||
gboolean is_public,
|
|
||||||
GStrv invitees)
|
|
||||||
{
|
|
||||||
JsonBuilder *builder;
|
|
||||||
JsonNode *content,
|
|
||||||
*node;
|
|
||||||
|
|
||||||
builder = json_builder_new();
|
|
||||||
json_builder_begin_object(builder);
|
|
||||||
|
|
||||||
node = json_node_new(JSON_NODE_VALUE);
|
|
||||||
json_node_set_string(node, is_public ? "public" : "private");
|
|
||||||
json_builder_set_member_name(builder, "visibility");
|
|
||||||
json_builder_add_value(builder, node);
|
|
||||||
|
|
||||||
if (room_alias && *room_alias) {
|
|
||||||
node = json_node_new(JSON_NODE_VALUE);
|
|
||||||
json_node_set_string(node, room_alias);
|
|
||||||
json_builder_set_member_name(builder, "room_alias_name");
|
|
||||||
json_builder_add_value(builder, node);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (invitees && *invitees) {
|
|
||||||
JsonArray *user_array = json_array_new();
|
|
||||||
gchar **user_id;
|
|
||||||
|
|
||||||
for (user_id = invitees; *user_id; user_id++) {
|
|
||||||
json_array_add_string_element(user_array, *user_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
node = json_node_new(JSON_NODE_ARRAY);
|
|
||||||
json_node_set_array(node, user_array);
|
|
||||||
json_builder_set_member_name(builder, "invite");
|
|
||||||
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", "createRoom",
|
|
||||||
content,
|
|
||||||
NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* matrix_http_api_join_room:
|
|
||||||
* @api: a #MatrixHTTPAPI object
|
|
||||||
* @callback: (scope async) (allow-none): the function to call when
|
|
||||||
* the request is finished
|
|
||||||
* @user_data: user data to pass to the callback function
|
|
||||||
* @room_id_or_alias: an alias or the ID of the room
|
|
||||||
*
|
|
||||||
* Perform /join/$room_id
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
matrix_http_api_join_room(MatrixAPI *api,
|
|
||||||
MatrixAPICallback callback,
|
|
||||||
gpointer user_data,
|
|
||||||
gchar *room_id_or_alias)
|
|
||||||
{
|
|
||||||
gchar *path, *escaped_alias;
|
|
||||||
|
|
||||||
if (!room_id_or_alias && !*room_id_or_alias) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
escaped_alias = soup_uri_encode(room_id_or_alias, NULL);
|
if ((g_ascii_strcasecmp("GET", method) != 0)
|
||||||
path = g_strdup_printf("join/%s", escaped_alias);
|
&& (g_ascii_strcasecmp("POST", method) != 0)
|
||||||
g_free(escaped_alias);
|
&& (g_ascii_strcasecmp("PUT", method) != 0)
|
||||||
|
&& (g_ascii_strcasecmp("DELETE", method) != 0)) {
|
||||||
|
g_warning("Invalid method name '%s'", method);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
matrix_http_api_send(MATRIX_HTTP_API(api),
|
}
|
||||||
callback, user_data,
|
|
||||||
"POST", path,
|
void
|
||||||
NULL, NULL);
|
matrix_http_api_login(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
const gchar *type,
|
||||||
|
const JsonNode *content,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
JsonNode *body;
|
||||||
|
JsonObject *root_object;
|
||||||
|
|
||||||
|
body = json_node_copy((JsonNode *)content);
|
||||||
|
root_object = json_node_get_object(body);
|
||||||
|
json_object_set_string_member(root_object, "type", type);
|
||||||
|
|
||||||
|
matrix_http_api_send(api,
|
||||||
|
callback, user_data,
|
||||||
|
"POST", "/login", body,
|
||||||
|
error);
|
||||||
}
|
}
|
||||||
|
@ -52,32 +52,354 @@ void matrix_http_api_set_validate_certificate(MatrixHTTPAPI *api,
|
|||||||
gboolean matrix_http_api_get_validate_certificate(MatrixHTTPAPI *api);
|
gboolean matrix_http_api_get_validate_certificate(MatrixHTTPAPI *api);
|
||||||
const gchar *matrix_http_api_get_base_url(MatrixHTTPAPI *api);
|
const gchar *matrix_http_api_get_base_url(MatrixHTTPAPI *api);
|
||||||
|
|
||||||
GHashTable *matrix_http_api_gen_parameters(const gchar *param1_name, ...);
|
|
||||||
MatrixHTTPAPI *matrix_http_api_new(const gchar *base_url, const gchar *token);
|
MatrixHTTPAPI *matrix_http_api_new(const gchar *base_url, const gchar *token);
|
||||||
void matrix_http_api_login(MatrixAPI *api,
|
|
||||||
|
/* Media */
|
||||||
|
void matrix_http_api_media_download(MatrixAPI *api,
|
||||||
MatrixAPICallback callback,
|
MatrixAPICallback callback,
|
||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
gchar *login_type,
|
const gchar *server_name,
|
||||||
GHashTable *parameters);
|
const gchar *media_id);
|
||||||
void matrix_http_api_register_account(MatrixAPI *api,
|
void matrix_http_api_media_thumbnail(MatrixAPI *api,
|
||||||
MatrixAPICallback callback,
|
MatrixAPICallback callback,
|
||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
gchar *login_type,
|
const gchar *server_name,
|
||||||
GHashTable *parameters);
|
const gchar *media_id,
|
||||||
void matrix_http_api_initial_sync(MatrixAPI *api,
|
guint width,
|
||||||
|
guint height,
|
||||||
|
MatrixAPIResizeMethod method);
|
||||||
|
void matrix_http_api_media_upload(MatrixAPI *api,
|
||||||
MatrixAPICallback callback,
|
MatrixAPICallback callback,
|
||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
guint limit);
|
const gchar *content_type,
|
||||||
|
const GByteArray *content);
|
||||||
|
|
||||||
|
/* Presence */
|
||||||
|
void matrix_http_api_get_presence_list(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
const gchar *user_id);
|
||||||
|
void matrix_http_api_update_presence_list(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
const gchar *user_id,
|
||||||
|
GList *drop_ids,
|
||||||
|
GList *invite_ids);
|
||||||
|
void matrix_http_api_get_user_presence(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
const gchar *user_id);
|
||||||
|
void matrix_http_api_set_user_presence(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
const gchar *user_id,
|
||||||
|
MatrixAPIPresence presence,
|
||||||
|
const gchar *status_message);
|
||||||
|
|
||||||
|
/* Push notifications */
|
||||||
|
void matrix_http_api_set_pushers(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
MatrixAPIPusher *pusher);
|
||||||
|
void matrix_http_api_get_pushers(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data);
|
||||||
|
void matrix_http_api_delete_pusher(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
const gchar *scope,
|
||||||
|
MatrixAPIPusherKind kind,
|
||||||
|
const gchar *rule_id);
|
||||||
|
void matrix_http_api_get_pusher(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
const gchar *scope,
|
||||||
|
MatrixAPIPusherKind kind,
|
||||||
|
const gchar *rule_id);
|
||||||
|
void matrix_http_api_add_pusher(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
const gchar *scope,
|
||||||
|
MatrixAPIPusherKind kind,
|
||||||
|
const gchar *rule_id,
|
||||||
|
const gchar *before,
|
||||||
|
const gchar *after,
|
||||||
|
GList *actions,
|
||||||
|
GList *conditions);
|
||||||
|
void matrix_http_api_toggle_pusher(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
const gchar *scope,
|
||||||
|
MatrixAPIPusherKind kind,
|
||||||
|
const gchar *rule_id,
|
||||||
|
gboolean enabled);
|
||||||
|
|
||||||
|
/* Room creation */
|
||||||
void matrix_http_api_create_room(MatrixAPI *api,
|
void matrix_http_api_create_room(MatrixAPI *api,
|
||||||
MatrixAPICallback callback,
|
MatrixAPICallback callback,
|
||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
gchar *room_alias,
|
MatrixAPIRoomPreset preset,
|
||||||
gboolean is_public,
|
const gchar *room_name,
|
||||||
GStrv invitees);
|
const gchar *room_alias,
|
||||||
|
const gchar *topic,
|
||||||
|
MatrixAPIRoomVisibility visibility,
|
||||||
|
JsonNode *creation_content,
|
||||||
|
GList *initial_state,
|
||||||
|
GList *invitees);
|
||||||
|
|
||||||
|
/* Room directory */
|
||||||
|
void matrix_http_api_delete_room_alias(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
const gchar *room_alias);
|
||||||
|
void matrix_http_api_get_room_id(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
const gchar *room_alias);
|
||||||
|
void matrix_http_api_create_room_alias(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
const gchar *room_id,
|
||||||
|
const gchar *room_alias);
|
||||||
|
|
||||||
|
/* Room discovery */
|
||||||
|
void matrix_http_api_list_public_rooms(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
/* Room membership */
|
||||||
|
|
||||||
|
void matrix_http_api_ban_user(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
const gchar *room_id,
|
||||||
|
const gchar *user_id,
|
||||||
|
const gchar *reason);
|
||||||
|
void matrix_http_api_forget_room(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
const gchar *room_id);
|
||||||
|
void matrix_http_api_invite_user_3rdparty(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
const gchar *room_id,
|
||||||
|
const gchar *address,
|
||||||
|
const gchar *medium,
|
||||||
|
const gchar *id_server);
|
||||||
|
void matrix_http_api_invite_user(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
const gchar *room_id,
|
||||||
|
const gchar *user_id);
|
||||||
void matrix_http_api_join_room(MatrixAPI *api,
|
void matrix_http_api_join_room(MatrixAPI *api,
|
||||||
MatrixAPICallback callback,
|
MatrixAPICallback callback,
|
||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
gchar *room_id_or_alias);
|
const gchar *room_id_or_alias);
|
||||||
|
void matrix_http_api_leave_room(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
const gchar *room_id);
|
||||||
|
|
||||||
|
/* Room participation */
|
||||||
|
|
||||||
|
void matrix_http_api_event_stream(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
const gchar *from_token,
|
||||||
|
gulong timeout);
|
||||||
|
void matrix_http_api_get_event(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
const gchar *event_id);
|
||||||
|
void matrix_http_api_initial_sync(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
guint limit,
|
||||||
|
gboolean archived);
|
||||||
|
void matrix_http_api_get_event_context(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
const gchar *room_id,
|
||||||
|
const gchar *event_id,
|
||||||
|
guint limit);
|
||||||
|
void matrix_http_api_initial_sync_room(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
const gchar *room_id);
|
||||||
|
void matrix_http_api_list_room_members(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
const gchar *room_id);
|
||||||
|
void matrix_http_api_list_room_messages(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
const gchar *room_id,
|
||||||
|
const gchar *from_token,
|
||||||
|
MatrixAPIEventDirection direction,
|
||||||
|
guint limit);
|
||||||
|
void matrix_http_api_send_event_receipt(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
const gchar *room_id,
|
||||||
|
MatrixAPIReceiptType type,
|
||||||
|
const gchar *event_id,
|
||||||
|
JsonNode *receipt);
|
||||||
|
void matrix_http_api_redact_event(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
const gchar *room_id,
|
||||||
|
const gchar *event_id,
|
||||||
|
const gchar *txn_id,
|
||||||
|
const gchar *reason);
|
||||||
|
void matrix_http_api_send_message_event(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
const gchar *room_id,
|
||||||
|
const gchar *event_type,
|
||||||
|
const gchar *txn_id,
|
||||||
|
const JsonNode *content);
|
||||||
|
void matrix_http_api_get_room_state(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
const gchar *room_id,
|
||||||
|
const gchar *event_type,
|
||||||
|
const gchar *state_key);
|
||||||
|
void matrix_http_api_send_room_event(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
const gchar *room_id,
|
||||||
|
const gchar *event_type,
|
||||||
|
const gchar *state_key,
|
||||||
|
JsonNode *content);
|
||||||
|
void matrix_http_api_notify_room_typing(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
const gchar *user_id,
|
||||||
|
const gchar *room_id,
|
||||||
|
guint timeout,
|
||||||
|
gboolean typing);
|
||||||
|
void matrix_http_api_sync(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
const gchar *filter_id,
|
||||||
|
const JsonNode *filter,
|
||||||
|
const gchar *since,
|
||||||
|
gboolean full_state,
|
||||||
|
gboolean set_presence,
|
||||||
|
gulong timeout);
|
||||||
|
void matrix_http_api_create_filter(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
const gchar *user_id,
|
||||||
|
MatrixAPIFilter *filter);
|
||||||
|
void matrix_http_api_download_filter(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
const gchar *user_id,
|
||||||
|
const gchar *filter_id);
|
||||||
|
|
||||||
|
/* Search */
|
||||||
|
void *search_reserved;
|
||||||
|
|
||||||
|
/* Server administration */
|
||||||
|
|
||||||
|
void matrix_http_api_whois(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
const gchar *user_id);
|
||||||
|
|
||||||
|
/* Session management */
|
||||||
|
|
||||||
|
void matrix_http_api_login(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
const gchar *type,
|
||||||
|
const JsonNode *content,
|
||||||
|
GError **error);
|
||||||
|
void matrix_http_api_token_refresh(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
const gchar *refresh_token);
|
||||||
|
|
||||||
|
/* User data */
|
||||||
|
|
||||||
|
void matrix_http_api_get_3pids(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data);
|
||||||
|
void matrix_http_api_add_3pid(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
gboolean bind_creds,
|
||||||
|
GList *threepid_creds);
|
||||||
|
void matrix_http_api_change_password(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
const gchar *new_password);
|
||||||
|
void matrix_http_api_get_profile(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
const gchar *user_id);
|
||||||
|
void matrix_http_api_get_avatar_url(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
const gchar *user_id);
|
||||||
|
void matrix_http_api_set_avatar_url(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
const gchar *user_id,
|
||||||
|
const gchar *avatar_url);
|
||||||
|
void matrix_http_api_get_display_name(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
const gchar *user_id);
|
||||||
|
void matrix_http_api_set_display_name(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
const gchar *user_id,
|
||||||
|
const gchar *display_name);
|
||||||
|
void matrix_http_api_register_account(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
gboolean bind_email,
|
||||||
|
const gchar *username,
|
||||||
|
const gchar *password);
|
||||||
|
void matrix_http_api_set_account_data(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
const gchar *user_id,
|
||||||
|
const gchar *type,
|
||||||
|
JsonNode *content);
|
||||||
|
void matrix_http_api_set_room_account_data(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
const gchar *user_id,
|
||||||
|
const gchar *room_id,
|
||||||
|
const gchar *type,
|
||||||
|
JsonNode *content);
|
||||||
|
void matrix_http_api_get_room_tags(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
const gchar *user_id,
|
||||||
|
const gchar *room_id);
|
||||||
|
void matrix_http_api_delete_room_tag(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
const gchar *user_id,
|
||||||
|
const gchar *room_id,
|
||||||
|
const gchar *tag);
|
||||||
|
void matrix_http_api_add_room_tag(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
const gchar *user_id,
|
||||||
|
const gchar *room_id,
|
||||||
|
const gchar *tag,
|
||||||
|
JsonNode *content);
|
||||||
|
|
||||||
|
/* VoIP */
|
||||||
|
|
||||||
|
void matrix_http_api_get_turn_server(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
@ -36,6 +36,10 @@ create_room_finished(MatrixAPI *api,
|
|||||||
gpointer data,
|
gpointer data,
|
||||||
GError *err)
|
GError *err)
|
||||||
{
|
{
|
||||||
|
if (err) {
|
||||||
|
g_debug("Error: %s", err->message);
|
||||||
|
}
|
||||||
|
|
||||||
g_printf("Room registered\n");
|
g_printf("Room registered\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,10 +72,13 @@ login_finished(MatrixAPI *api, JsonNode *content, gpointer data, GError *err)
|
|||||||
|
|
||||||
g_printf("Logged in as %s\n", user_id);
|
g_printf("Logged in as %s\n", user_id);
|
||||||
|
|
||||||
matrix_http_api_create_room(api,
|
/* matrix_http_api_create_room(api, */
|
||||||
create_room_finished, NULL,
|
/* create_room_finished, NULL, */
|
||||||
"matrix-glib-sdk-test", TRUE,
|
/* MATRIX_API_ROOM_PRESET_PUBLIC, */
|
||||||
NULL);
|
/* "matrix-glib-sdk-test", NULL, */
|
||||||
|
/* "GLib SDK test room", */
|
||||||
|
/* MATRIX_API_ROOM_VISIBILITY_DEFAULT, */
|
||||||
|
/* NULL, NULL, NULL); */
|
||||||
} else {
|
} else {
|
||||||
g_printf("Login unsuccessful!\n");
|
g_printf("Login unsuccessful!\n");
|
||||||
}
|
}
|
||||||
@ -86,6 +93,8 @@ main(int argc, char *argv[])
|
|||||||
GOptionContext *opts;
|
GOptionContext *opts;
|
||||||
GError *err = NULL;
|
GError *err = NULL;
|
||||||
gchar *url;
|
gchar *url;
|
||||||
|
JsonBuilder *builder;
|
||||||
|
JsonNode *login_content;
|
||||||
|
|
||||||
opts = g_option_context_new(NULL);
|
opts = g_option_context_new(NULL);
|
||||||
g_option_context_add_main_entries(opts, entries, NULL);
|
g_option_context_add_main_entries(opts, entries, NULL);
|
||||||
@ -111,19 +120,31 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* [ ] register
|
* [ ] register
|
||||||
* [X] login
|
* [ ] login
|
||||||
* [X] create_room
|
* [ ] create_room
|
||||||
* [ ] join_room
|
* [ ] join_room
|
||||||
*/
|
*/
|
||||||
api = matrix_http_api_new(url, NULL);
|
api = matrix_http_api_new(url, NULL);
|
||||||
params = matrix_http_api_gen_parameters(
|
builder = json_builder_new();
|
||||||
"user", user,
|
json_builder_begin_object(builder);
|
||||||
"password", password,
|
json_builder_set_member_name(builder, "user");
|
||||||
NULL);
|
json_builder_add_string_value(builder, user);
|
||||||
|
json_builder_set_member_name(builder, "password");
|
||||||
|
json_builder_add_string_value(builder, password);
|
||||||
|
json_builder_end_object(builder);
|
||||||
|
login_content = json_builder_get_root(builder);
|
||||||
|
|
||||||
matrix_http_api_login(MATRIX_API(api),
|
matrix_http_api_login(MATRIX_API(api),
|
||||||
login_finished, loop,
|
login_finished, loop,
|
||||||
"m.login.password",
|
"m.login.password",
|
||||||
params);
|
login_content,
|
||||||
|
&err);
|
||||||
|
|
||||||
|
if (err) {
|
||||||
|
g_warning("Error: %s", err->message);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
g_info("Entering main loop");
|
g_info("Entering main loop");
|
||||||
g_main_loop_run(loop);
|
g_main_loop_run(loop);
|
||||||
|
Loading…
Reference in New Issue
Block a user