diff --git a/docs/reference/matrix-glib/matrix-glib-sections.txt b/docs/reference/matrix-glib/matrix-glib-sections.txt
index 5de37d8..a00900e 100644
--- a/docs/reference/matrix-glib/matrix-glib-sections.txt
+++ b/docs/reference/matrix-glib/matrix-glib-sections.txt
@@ -19,30 +19,114 @@ matrix_client_get_type
private
+ * @MATRIX_API_ROOM_VISIBILITY_PUBLIC: make the room visible in the
+ * public room list
+ * @MATRIX_API_ROOM_VISIBILITY_PRIVATE: hide the room from the public
+ * room list
+ *
+ * Visibility values for room creation. Not to be confused with join
+ * rules.
+ */
+
+/**
+ * MatrixAPIResizeMethod:
+ * @MATRIX_API_RESIZE_METHOD_CROP: crop thumbnail to the requested
+ * size
+ * @MATRIX_API_RESIZE_METHOD_SCALE: scale thumbnail to the requested
+ * size
+ *
+ * Resizing methods for matrix_api_media_thumbnail().
+ */
+
+/**
+ * MatrixAPIPresence:
+ * @MATRIX_API_PRESENCE_ONLINE: user is online
+ * @MATRIX_API_PRESENCE_OFFLINE: user is offline
+ * @MATRIX_API_PRESENCE_UNAVAILABLE: user is unavailable (i.e. busy)
+ * @MATRIX_API_PRESENCE_FREE_FOR_CHAT: user is free for chat
+ *
+ * Presence values for matrix_api_set_user_presence() and other
+ * presence related queries.
+ */
+
+/**
+ * MatrixAPIPusherKind:
+ * @MATRIX_API_PUSHER_KIND_OVERRIDE: highest priority rules
+ * @MATRIX_API_PUSHER_KIND_SENDER: for (unencrypted) messages that
+ * match certain patterns
+ * @MATRIX_API_PUSHER_KIND_ROOM: for all messages for a given
+ * room. The rule ID of a room rule is
+ * always the ID of the room that it
+ * affects
+ * @MATRIX_API_PUSHER_KIND_CONTENT: for messages from a specific
+ * Matrix user ID. The rule ID of
+ * such rules is always the Matrix ID
+ * of the user whose messages they'd
+ * apply to
+ * @MATRIX_API_PUSHER_KIND_UNDERRIDE: lowest priority rules
+ *
+ * Pusher types.
+ */
+
+/**
+ * MatrixAPIPusherConditionKind:
+ * @MATRIX_API_PUSHER_CONDITION_KIND_EVENT_MATCH: glob pattern match
+ * on a field of the
+ * event. Requires a
+ * key
and
+ * a
+ * pattern
+ * parameter
+ * @MATRIX_API_PUSHER_CONDITION_KIND_PROFILE_TAG: matches the profile
+ * tag of the device
+ * that the
+ * notification would
+ * be delivered
+ * to. Requires a
+ * profile_tag
+ * parameter
+ * @MATRIX_API_PUSHER_CONDITION_KIND_CONTAINS_DISPLAY_NAME: matches
+ * unencrypted
+ * messages
+ * where the
+ * content's
+ * body
+ * contains
+ * the
+ * owner's
+ * display
+ * name in
+ * that room.
+ * @MATRIX_API_PUSHER_CONDITION_KIND_ROOM_MEMBER_COUNT: matches the
+ * current number
+ * of members in
+ * the
+ * room. Requires
+ * an
+ * is
+ * parameter,
+ * which must be
+ * an integer,
+ * optionally
+ * prefixed by
+ * ==
,
+ * <
,
+ * >
,
+ * <=
+ * or
+ * >=
. If
+ * the prefix is
+ * omitted, it
+ * defaults to
+ * ==
+ *
+ * Condition types for pushers.
+ */
+
+/**
+ * MatrixAPIEventDirection:
+ * @MATRIX_API_EVENT_DIRECTION_FORWARD: List events after the
+ * specified one
+ * @MATRIX_API_EVENT_DIRECTION_BACKWARD: List events before the
+ * specified one
+ *
+ * Direction of events when requesting an event context.
+ */
+
+/**
+ * MatrixAPIReceiptType:
+ * @MATRIX_API_RECEIPT_TYPE_READ: indicate that the message has been
+ * read
+ *
+ * Receipt types of acknowledgment.
+ */
+
+/**
+ * MatrixAPIEventFormat:
+ * @MATRIX_API_EVENT_FORMAT_DEFAULT: event format will be omitted from
+ * the filter, so the server will
+ * use its default (usually
+ * @MATRIX_API_EVENT_FORMAT_FEDERATION)
+ * @MATRIX_API_EVENT_FORMAT_CLIENT: return the events in a format
+ * suitable for clients
+ * @MATRIX_API_EVENT_FORMAT_FEDERATION: return the raw event as
+ * receieved over federation
+ *
+ * Event format received when synchronizing.
+ */
+
+/**
+ * MatrixAPIPusher:
+ * @app_display_name: a string that will allow the user to identify
+ * what application owns the pusher
+ * @app_id: a reverse DNS style identifier for the application. It is
+ * recommended that this ends with the platform, such that
+ * different platform versions get different app
+ * identifiers. Maximum length is 64 characters, which is
+ * currently not enforced by this SDK
+ * @append: if %TRUE, the homeserver should add another pusher with
+ * the given push key and app ID in addition to any others
+ * with different user IDs. Otherwise, the homeserver must
+ * remove any other pushers with the same App ID and pushkey
+ * for different users
+ * @device_display_name: a string that will allow the user to identify
+ * what device owns this pusher
+ * @kind: the kind of pusher to configure. http
makes a
+ * pusher that sends HTTP pokes. %NULL deletes the pusher.
+ * @lang: the preferred language for receiving notifications,
+ * e.g. en
or en-US
+ * @profile_tag: a string that determines what set of device rules
+ * will be matched when evaluating push rules for this
+ * pusher. It is an arbitrary string. Multiple devices
+ * may use the same profile_tag
. It is
+ * advised that when an app's data is copied or restored
+ * to a different device, this value remain the
+ * same. Client apps should offer ways to change the
+ * profile_tag, optionally copying rules from the old
+ * profile tag. Maximum length is 32 bytes, which is
+ * currently not enforced by this SDK
+ * @pushkey: a unique identifier for this pusher. The value you should
+ * use for this is the routing or destination address
+ * information for the notification, for example, the APNS
+ * token for APNS or the Registration ID for GCM. If your
+ * notification client has no such concept, use any unique
+ * identifier. Maximum length is 512 bytes, which is
+ * currently not enforced by this SDK
+ * @data: A dictionary of information for the pusher implementation
+ * itself. For example, if kind is http
, this
+ * should contain url
which is the URL to use to
+ * send notifications to.
+ *
+ * Ruleset for creating pushers.
+ */
+
+/**
+ * MatrixAPI3PidCredential:
+ * @client_secret: the client secret used in the session with the
+ * Identity Server
+ * @id_server: the Identity Server to use
+ * @session_id: the session identifier given by the Identity Server
+ *
+ * Structure to store credentials to use with Identity Server
+ * communication.
+ */
+
+/**
+ * MatrixAPIEventFilter:
+ * @rooms: (element-type GString): a list of room IDs to include. If
+ * %NULL, all rooms will be included. A *
can be
+ * used as a wildcard to match any sequence of characters
+ * @not_rooms: (element-type GString): a list of room IDs to
+ * exclude. If %NULL, no rooms are excluded. A matching
+ * room will be excluded even if it is listed in @rooms. A
+ * *
can be used as a wildcard to match any
+ * sequence of characters
+ * @limit: the maximum number of events to return. If 0
,
+ * no limit is applied
+ * @senders: (element-type GString): a list of senders IDs to
+ * include. If %NULL then all senders are included. A
+ * *
can be used as a wildcard to match any
+ * sequence of characters
+ * @not_senders: (element-type GString): a list of sender IDs to
+ * exclude. If %NULL then no senders are excluded. A
+ * matching sender will be excluded even if it is listed
+ * in the @senders filter. A *
can be used
+ * as a wildcard to match any sequence of characters
+ * @types: (element-type GString): a list of event types to
+ * include. If %NULL then all event types are included. A
+ * *
can be used as a wildcard to match any
+ * sequence of characters
+ * @not_types: (element-type GString): a list of event types to
+ * exclude. If this list is absent then no event types are
+ * excluded. A matching type will be excluded even if it
+ * is listed in the @types filter. A *
can be
+ * used as a wildcard to match any sequence of characters
+ *
+ * A struct to hold event filters.
+ */
+
+/**
+ * MatrixAPIRoomFilter:
+ * @ephemeral: the events that aren't recorded in the room history,
+ * e.g. typing and receipts, to include for rooms
+ * @include_leave: include rooms that the user has left in the sync
+ * @state: the state events to include for rooms
+ * @timeline: the message and state update events to include for rooms
+ *
+ * A struct to hold a room event filter
+ */
+
+/**
+ * MatrixAPIPresenceFilter:
+ * @limit: the maximum number of events to return. If 0
,
+ * no limit will be applied
+ * @senders: (element-type GString): a list of senders IDs to
+ * include. If %NULL then all senders are included. A
+ * *
can be used as a wildcard to match any
+ * sequence of characters
+ * @not_senders: (element-type GString): a list of sender IDs to
+ * exclude. If %NULL then no senders are excluded. A
+ * matching sender will be excluded even if it is listed
+ * in the @senders filter. A *
can be used
+ * as a wildcard to match any sequence of characters
+ * @types: (element-type GString): a list of event types to
+ * include. If %NULL then all event types are included. A
+ * *
can be used as a wildcard to match any
+ * sequence of characters
+ * @not_types: (element-type GString): a list of event types to
+ * exclude. If %NULL then no event types are excluded. A
+ * matching type will be excluded even if it is listed in
+ * the @types filter. A *
can be used as a
+ * wildcard to match any sequence of characters
+ *
+ * A struct to hold a presence filter.
+ */
+
+/**
+ * MatrixAPIFilter:
+ * @event_fields: (element-type GString): list of event fields to
+ * include. If %NULL then all fields are included. The
+ * entries may include .
charaters to
+ * indicate sub-fields. So
+ * ['content.body']
will include the
+ * body
field of the content
+ * object. A literal .
character in a
+ * field name may be escaped using a \
. A
+ * server may include more fields than were requested
+ * @event_format: the format to use for
+ * events. %MATRIX_API_EVENT_FORMAT_CLIENT will return
+ * the events in a format suitable for
+ * clients. %MATRIX_API_EVENT_FORMAT_FEDERATION will
+ * return the raw event as receieved over
+ * federation. The default is
+ * %MATRIX_API_EVENT_FORMAT_CLIENT
+ * @presence: the presence updates to include
+ * @room: room filters
+ *
+ * A struct to define an event filter.
+ */
+
+/**
+ * MatrixAPIStateEvent:
+ * @type: the event type
+ * @state_key: the key of the state event
+ * @content: the contents of the state event
+ *
+ * A struct to hold a state event filter.
+ */
+
/**
* matrix_api_error_quark:
*
@@ -110,8 +423,632 @@ G_DEFINE_INTERFACE(MatrixAPI, matrix_api, G_TYPE_OBJECT);
static void
matrix_api_default_init(MatrixAPIInterface *iface)
{
+ /**
+ * MatrixAPI:token:
+ *
+ * The token to use for authorization. The matrix_http_api_login()
+ * and matrix_http_api_register_account() calls set this
+ * automatically.
+ */
+ g_object_interface_install_property(
+ iface,
+ g_param_spec_string("token", "Authorization token",
+ "The authorization token to use in requests",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
}
+/* Property getters and setters */
+
+/**
+ * matrix_api_get_token:
+ * @api: a #MatrixAPI implementation
+ *
+ * Get the authorization token currently set. See
+ * matrix_api_set_token() for limitations.
+ *
+ * Returns: (transfer none) (allow-none): the authorization token that
+ * will be used in subsequent requests, or %NULL if none
+ * set. The returned value is owned by the @api object and
+ * should not be freed nor modified
+ */
+const gchar *
+matrix_api_get_token(MatrixAPI *api)
+{
+ g_return_if_fail(MATRIX_IS_API(api));
+
+ return MATRIX_API_GET_IFACE(api)
+ ->get_token(api);
+}
+
+/**
+ * matrix_api_set_token:
+ * @api: a #MatrixAPI implementation
+ * @token: the authorization token to set
+ *
+ * Set the authorization token to use in subsequent requests.
+ *
+ * mxc://
URI (the
+ * authority component)
+ * @media_id: the media ID from the mxc://
URI (the path
+ * component)
+ * @error: (allow-none): a #GError
+ *
+ * Download content from the content repository.
+ */
+void
+matrix_api_media_download(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *server_name,
+ const gchar *media_id,
+ GError **error)
+{
+ g_return_if_fail(MATRIX_IS_API(api));
+
+ MATRIX_API_GET_IFACE(api)
+ ->media_download(api,
+ callback, user_data,
+ server_name, media_id, error);
+}
+
+/**
+ * matrix_api_media_thumbnail:
+ * @api: a #MatrixAPI implementation
+ * @callback: (scope async) (allow-none): a function to call when the
+ * request is finished
+ * @user_data: user data to pass to the callback function @callback
+ * @server_name: the server name from the mxc://
URI (the
+ * authority component)
+ * @media_id: the media ID from the mxc://
URI (the path
+ * component)
+ * @width: the desired width of the thumbnail, or 0 to use the default
+ * @height: the desired height of the thumbnail, or 0 to use the
+ * default
+ * @method: the resizing method to use
+ * @error: (allow-none): a #GError
+ *
+ * Download a thumbnail of the content from the content
+ * repository. The actual thumbnail may not match the size specified.
+ */
+void
+matrix_api_media_thumbnail(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *server_name,
+ const gchar *media_id,
+ guint width,
+ guint height,
+ MatrixAPIResizeMethod method,
+ GError **error)
+{
+ g_return_if_fail(MATRIX_IS_API(api));
+
+ MATRIX_API_GET_IFACE(api)
+ ->media_thumbnail(api,
+ callback, user_data,
+ server_name, media_id,
+ width, height, method,
+ error);
+}
+
+/**
+ * matrix_api_media_upload:
+ * @api: a #MatrixAPI implementation
+ * @callback: (scope async) (allow-none): a function to call when the
+ * request is finished
+ * @user_data: user data to pass to the callback function @callback
+ * @content_type: (allow-none): the content type of the file being
+ * uploaded
+ * @content: the content to be uploaded
+ * @error: a #GError
+ *
+ * Upload some content to the content repository.
+ */
+void
+matrix_api_media_upload(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *content_type,
+ const GByteArray *content,
+ GError **error)
+{
+ g_return_if_fail(MATRIX_IS_API(api));
+
+ MATRIX_API_GET_IFACE(api)
+ ->media_upload(api, callback, user_data, content_type, content, error);
+}
+
+/* Presence */
+
+/**
+ * matrix_api_get_presence_list:
+ * @api: a #MatrixAPI implementation
+ * @callback: (scope async) (allow-none): a function to call when the
+ * request is finished
+ * @user_data: user data to pass to the callback function @callback
+ * @user_id: the user whose presence list should be retrieved
+ * @error: a #GError
+ *
+ * Retrieve a list of presence events for every user on this list.
+ */
+void
+matrix_api_get_presence_list(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *user_id,
+ GError **error)
+{
+ g_return_if_fail(MATRIX_IS_API(api));
+
+ MATRIX_API_GET_IFACE(api)
+ ->get_presence_list(api, callback, user_data, user_id, error);
+}
+
+/**
+ * matrix_api_update_presence_list:
+ * @api: a #MatrixAPI implementation
+ * @callback: (scope async) (allow-none): a function to call when the
+ * request is finished
+ * @user_data: user data to pass to the callback function @callback
+ * @user_id: the user whose presence list is being modified
+ * @drop_ids: (element-type GString): a list of user IDs to remove
+ * from the list
+ * @invite_ids: (element-type GString): a list of user IDs to add to
+ * the list
+ * @error: a #GError
+ *
+ * Add or remove users from the specified user's presence list.
+ */
+void
+matrix_api_update_presence_list(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *user_id,
+ GList *drop_ids,
+ GList *invite_ids,
+ GError **error)
+{
+ g_return_if_fail(MATRIX_IS_API(api));
+
+ MATRIX_API_GET_IFACE(api)
+ ->update_presence_list(api,
+ callback, user_data,
+ user_id, drop_ids, invite_ids, error);
+}
+
+/**
+ * matrix_api_get_user_presence:
+ * @api: a #MatrixAPI implementation
+ * @callback: (scope async) (allow-none): a function to call when the
+ * request is finished
+ * @user_data: user data to pass to the callback function @callback
+ * @user_id: the user whose presence list is being modified
+ * @error: a #GError
+ *
+ * Get the given user's presence state.
+ */
+void
+matrix_api_get_user_presence(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *user_id,
+ GError **error)
+{
+ g_return_if_fail(MATRIX_IS_API(api));
+
+ MATRIX_API_GET_IFACE(api)
+ ->get_user_presence(api,
+ callback, user_data,
+ user_id, error);
+}
+
+/**
+ * matrix_api_set_user_presence:
+ * @api: a #MatrixAPI implementation
+ * @callback: (scope async) (allow-none): a function to call when the
+ * request is finished
+ * @user_data: user data to pass to the callback function @callback
+ * @user_id: the user whose presence list is being modified
+ * @presence: the new presence state
+ * @status_message: a status message attached to this state
+ * @error: a #GError
+ *
+ * Set the given user's presence. You cannot set the presence of
+ * another user.
+ */
+void
+matrix_api_set_user_presence(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *user_id,
+ MatrixAPIPresence presence,
+ const gchar *status_message,
+ GError **error)
+{
+ g_return_if_fail(MATRIX_IS_API(api));
+
+ MATRIX_API_GET_IFACE(api)
+ ->set_user_presence(api,
+ callback, user_data,
+ user_id, presence, status_message,
+ error);
+}
+
+/* Push notifications */
+
+/**
+ * matrix_api_modify_pusher:
+ * @api: a #MatrixAPI implementation
+ * @callback: (scope async) (allow-none): a function to call when the
+ * request is finished
+ * @user_data: user data to pass to the callback function @callback
+ * @pusher: the pusher information
+ * @error: a #GError
+ *
+ * Modify a pushers for the active user on this homeserver.
+ */
+void
+matrix_api_modify_pusher(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ MatrixAPIPusher *pusher,
+ GError **error)
+{
+ g_return_if_fail(MATRIX_IS_API(api));
+
+ MATRIX_API_GET_IFACE(api)
+ ->modify_pusher(api,
+ callback, user_data,
+ pusher, error);
+}
+
+/**
+ * matrix_api_get_pushers:
+ * @api: a #MatrixAPI implementation
+ * @callback: (scope async) (allow-none): a function to call when the
+ * request is finished
+ * @user_data: user data to pass to the callback function @callback
+ * @error: a #GError
+ *
+ * Retrieve all push rulesets.
+ */
+void
+matrix_api_get_pushers(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ GError **error)
+{
+ g_return_if_fail(MATRIX_IS_API(api));
+
+ MATRIX_API_GET_IFACE(api)
+ ->get_pushers(api, callback, user_data, error);
+}
+
+/**
+ * matrix_api_delete_pusher:
+ * @api: a #MatrixAPI implementation
+ * @callback: (scope async) (allow-none): a function to call when the
+ * request is finished
+ * @user_data: user data to pass to the callback function @callback
+ * @scope: either global
to specify global rules, or
+ * device/<profile tag>
for rules for a
+ * given profile tag
.
+ * @kind: the kind of rule
+ * @rule_id: an identifier for the rule
+ * @error: a #GError
+ *
+ * Delete a push rule.
+ */
+void
+matrix_api_delete_pusher(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *scope,
+ MatrixAPIPusherKind kind,
+ const gchar *rule_id,
+ GError **error)
+{
+ g_return_if_fail(MATRIX_IS_API(api));
+
+ MATRIX_API_GET_IFACE(api)
+ ->delete_pusher(api,
+ callback, user_data,
+ scope, kind, rule_id, error);
+}
+
+/**
+ * matrix_api_get_pusher:
+ * @api: a #MatrixAPI implementation
+ * @callback: (scope async) (allow-none): a function to call when the
+ * request is finished
+ * @user_data: user data to pass to the callback function @callback
+ * @scope: either global
to specify global rules, or
+ * device/<profile tag>
for rules for a
+ * given profile tag
.
+ * @kind: the kind of rule
+ * @rule_id: an identifier for the rule
+ * @error: a #GError
+ *
+ * Retrieve a specific push rule.
+ */
+void
+matrix_api_get_pusher(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *scope,
+ MatrixAPIPusherKind kind,
+ const gchar *rule_id,
+ GError **error)
+{
+ g_return_if_fail(MATRIX_IS_API(api));
+
+ MATRIX_API_GET_IFACE(api)
+ ->get_pusher(api,
+ callback, user_data,
+ scope, kind, rule_id, error);
+}
+
+/**
+ * matrix_api_add_pusher:
+ * @api: a #MatrixAPI implementation
+ * @callback: (scope async) (allow-none): a function to call when the
+ * request is finished
+ * @user_data: user data to pass to the callback function @callback
+ * @scope: either global
to specify global rules, or
+ * device/<profile tag>
for rules for a
+ * given profile tag
.
+ * @kind: the kind of rule
+ * @rule_id: an identifier for the rule
+ * @before: (allow-none): make the new rule the next-most important
+ * than this rule ID
+ * @after: (allow-none): make the new rule the next-less important
+ * than this rule ID
+ * @actions: (element-type GString): the actions to perform when the
+ * conditions for this rule are met
+ * @conditions: (element-type MatrixAPIPusherConditionKind) (allow-none):
+ * the conditions that must hold true for an event for a
+ * rule to be applied. A rule with no conditions always
+ * matches
+ * @error: a #GError
+ *
+ * Add or change a push rule.
+ */
+void
+matrix_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,
+ GError **error)
+{
+ g_return_if_fail(MATRIX_IS_API(api));
+
+ MATRIX_API_GET_IFACE(api)
+ ->add_pusher(api,
+ callback, user_data,
+ scope, kind, rule_id, before, after,
+ actions, conditions,
+ error);
+}
+
+/**
+ * matrix_api_toggle_pusher:
+ * @api: a #MatrixAPI implementation
+ * @callback: (scope async) (allow-none): a function to call when the
+ * request is finished
+ * @user_data: user data to pass to the callback function @callback
+ * @scope: either global
to specify global rules, or
+ * device/<profile tag>
for rules for a
+ * given profile tag
.
+ * @kind: the kind of rule
+ * @rule_id: an identifier for the rule
+ * @enabled: if %TRUE, the rule will be enabled, otherwise it gets
+ * disabled
+ * @error: a #GError
+ *
+ * Enable or disable the specified push rule.
+ */
+void matrix_api_toggle_pusher(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *scope,
+ MatrixAPIPusherKind kind,
+ const gchar *rule_id,
+ gboolean enabled,
+ GError **error)
+{
+ g_return_if_fail(MATRIX_IS_API(api));
+
+ MATRIX_API_GET_IFACE(api)
+ ->toggle_pusher(api,
+ callback, user_data,
+ scope, kind, rule_id, enabled, error);
+}
+
+/* Room creation */
+
+/**
+ * matrix_api_create_room:
+ * @api: a #MatrixAPI implementation
+ * @callback: (scope async) (allow-none): the function to call when
+ * the request is finished
+ * @user_data: (allow-none): user data to pass to the callback function
+ * @preset: a room preset to use
+ * @room_name: (allow-none): the desired name for the room
+ * @room_alias: (allow-none): the alias of the room
+ * @topic: (allow-none): the topic of the room
+ * @visibility: the initial visibility of the room
+ * @creation_content: (allow-none): extra keys to be added to the
+ * content of m.room.create
+ * @initial_state: (element-type MatrixAPIStateEvent) (allow-none): A
+ * list of state events to set in the new room
+ * @invitees: (element-type GString) (allow-none): list of user IDs to
+ * invite to the new room
+ * @error: (allow-none): a #GError
+ *
+ * Create a new room with the given name and invite the users in
+ * @invitees.
+ */
+void
+matrix_api_create_room(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ MatrixAPIRoomPreset preset,
+ const gchar *room_name,
+ const gchar *room_alias,
+ const gchar *topic,
+ MatrixAPIRoomVisibility visibility,
+ JsonNode *creation_content,
+ GList *initial_state,
+ GList *invitees,
+ GError **error)
+{
+ g_return_if_fail(MATRIX_IS_API(api));
+
+ MATRIX_API_GET_IFACE(api)
+ ->create_room(api, callback, user_data,
+ preset, room_name, room_alias, topic,
+ visibility, creation_content,
+ initial_state, invitees,
+ error);
+}
+
+/* Room directory */
+
+/**
+ * matrix_api_delete_room_alias:
+ * @api: a #MatrixAPI implementation
+ * @callback: (scope async) (allow-none): the function to call when
+ * the request is finished
+ * @user_data: (allow-none): user data to pass to the callback function
+ * @room_alias: the alias name to remove
+ * @error: a #GError
+ *
+ * Remove the mapping of @room_alias to its room ID
+ *
+ * Servers may choose to implement additional access control checks
+ * here, for instance that room aliases can only be deleted by their
+ * creator or a server administrator.
+ */
+void
+matrix_api_delete_room_alias(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *room_alias,
+ GError **error)
+{
+ g_return_if_fail(MATRIX_IS_API(api));
+
+ MATRIX_API_GET_IFACE(api)
+ ->delete_room_alias(api, callback, user_data, room_alias, error);
+}
+
+/**
+ * matrix_api_get_room_id:
+ * @api: a #MatrixAPI implementation
+ * @callback: (scope async) (allow-none): the function to call when
+ * the request is finished
+ * @user_data: (allow-none): user data to pass to the callback function
+ * @room_alias: the room alias
+ * @error: a #GError
+ *
+ * Get the room ID corresponding to this room alias.
+ */
+void
+matrix_api_get_room_id(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *room_alias,
+ GError **error)
+{
+ g_return_if_fail(MATRIX_IS_API(api));
+
+ MATRIX_API_GET_IFACE(api)
+ ->get_room_id(api, callback, user_data, room_alias, error);
+}
+
+/**
+ * matrix_api_create_room_alias:
+ * @api: a #MatrixAPI implementation
+ * @callback: (scope async) (allow-none): the function to call when
+ * the request is finished
+ * @user_data: (allow-none): user data to pass to the callback function
+ * @room_id: the room ID to add this alias to
+ * @room_alias: the room alias to set
+ * @error: a #GError
+ *
+ * Create a new mapping from room alias to room ID.
+ */
+void
+matrix_api_create_room_alias(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *room_id,
+ const gchar *room_alias,
+ GError **error)
+{
+ g_return_if_fail(MATRIX_IS_API(api));
+
+ MATRIX_API_GET_IFACE(api)
+ ->create_room_alias(api,
+ callback, user_data,
+ room_id, room_alias,
+ error);
+}
+
+/* Room discovery */
+
+/**
+ * matrix_api_list_public_rooms:
+ * @api: a #MatrixAPI implementation
+ * @callback: (scope async) (allow-none): the function to call when
+ * the request is finished
+ * @user_data: (allow-none): user data to pass to the callback function
+ * @error: a #GError
+ *
+ * List the public rooms on the server.
+ */
+void
+matrix_api_list_public_rooms(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ GError **error)
+{
+ g_return_if_fail(MATRIX_IS_API(api));
+
+ MATRIX_API_GET_IFACE(api)
+ ->list_public_rooms(api, callback, user_data, error);
+}
+
+/* Room membership */
+
/**
* matrix_api_ban_user:
* @api: a #MatrixAPI implementation
@@ -121,6 +1058,7 @@ matrix_api_default_init(MatrixAPIInterface *iface)
* @room_id: the room ID where the user should be banned
* @user_id: the user ID to ban
* @reason: (allow-none): the reason of the ban
+ * @error: (allow-none): a #GError
*
* Ban the specified user from the specified room. An optional reason
* can be specified.
@@ -129,153 +1067,87 @@ void
matrix_api_ban_user(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
- gchar *room_id,
- gchar *user_id,
- gchar *reason)
+ const gchar *room_id,
+ const gchar *user_id,
+ const gchar *reason,
+ GError **error)
{
g_return_if_fail(MATRIX_IS_API(api));
MATRIX_API_GET_IFACE(api)
- ->ban_user(api, callback, user_data, room_id, user_id, reason);
+ ->ban_user(api, callback, user_data, room_id, user_id, reason, error);
}
/**
- * matrix_api_create_room:
+ * matrix_api_forget_room:
* @api: a #MatrixAPI implementation
* @callback: (scope async): the function to call when the request is
* finished
* @user_data: user data to pass to the callback function
- * @alias: the alias (name) of the room
- * @is_public: if %TRUE, the room will be accessible for anyone
- * @invitees: (allow-none): list of user IDs to invite to the new room
+ * @room_id: the room ID to forget
+ * @error: a #GError
*
- * Create a new room with the given name and invite the users in
- * @invitees.
+ * Stop the requesting user remembering about a particular room.
+ *
+ * In general, history is a first class citizen in Matrix. After this
+ * API is called, however, a user will no longer be able to retrieve
+ * history for this room. If all users on a homeserver forget a room,
+ * the room is eligible for deletion from that homeserver.
+ *
+ * If the user is currently joined to the room, they will implicitly
+ * leave the room as part of this API call.
*/
void
-matrix_api_create_room(MatrixAPI *api,
+matrix_api_forget_room(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
- gchar *alias,
- gboolean is_public,
- GStrv invitees)
+ const gchar *room_id,
+ GError **error)
{
g_return_if_fail(MATRIX_IS_API(api));
MATRIX_API_GET_IFACE(api)
- ->create_room(api, callback, user_data, alias, is_public, invitees);
+ ->forget_room(api, callback, user_data, room_id, error);
}
/**
- * matrix_api_event_stream:
+ * matrix_api_invite_user_3rdparty:
* @api: a #MatrixAPI implementation
* @callback: (scope async): the function to call when the request is
* finished
* @user_data: user data to pass to the callback function
- * @from_token: (allow-none): events will be listed from this token
- * @timeout: timeout of the request
+ * @room_id: the room ID to which to invite the user
+ * @address: the invitee's 3rd party identifier
+ * @medium: the kind of address being passed in the address field,
+ * e.g. email
+ * @id_server: the hostname+port of the identity server which should
+ * be used for 3rd party identifier lookups
+ * @error: a #GError
*
- * Get the event stream, optionally beginning from @from_token.
+ * Invite a user to the room by a 3rd party identifier. They do not
+ * start participating in the room until they actually join the room.
+ *
+ * If the identity server does not know a Matrix user identifier for
+ * the passed third party identifier, the homeserver will issue an
+ * invitation which can be accepted upon providing proof of ownership
+ * of the third party identifier.
*/
-void
-matrix_api_event_stream(MatrixAPI *api,
- MatrixAPICallback callback,
- gpointer user_data,
- gchar *from_token,
- gulong timeout)
+void matrix_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,
+ GError **error)
{
g_return_if_fail(MATRIX_IS_API(api));
MATRIX_API_GET_IFACE(api)
- ->event_stream(api, callback, user_data, from_token, timeout);
-}
-
-/**
- * matrix_api_get_room_name:
- * @api: a #MatrixAPI implementation
- * @callback: (scope async): the function to call when the request is
- * finished
- * @user_data: user data to pass to the callback function
- * @room_id: the room ID to get a name for
- *
- * Get the name (alias) of a room.
- */
-void
-matrix_api_get_room_name(MatrixAPI *api,
- MatrixAPICallback callback,
- gpointer user_data,
- gchar *room_id)
-{
- g_return_if_fail(MATRIX_IS_API(api));
-
- MATRIX_API_GET_IFACE(api)
- ->get_room_name(api, callback, user_data, room_id);
-}
-
-/**
- * matrix_api_get_room_state:
- * @api: a #MatrixAPI implementation
- * @callback: (scope async): the function to call when the request is
- * finished
- * @user_data: user data to pass to the callback function
- * @room_id: the room ID to get a state for
- *
- * Get the state of a room.
- */
-void
-matrix_api_get_room_state(MatrixAPI *api,
- MatrixAPICallback callback,
- gpointer user_data,
- gchar *room_id)
-{
- g_return_if_fail(MATRIX_IS_API(api));
-
- MATRIX_API_GET_IFACE(api)
- ->get_room_state(api, callback, user_data, room_id);
-}
-
-/**
- * matrix_api_get_room_topic:
- * @api: a #MatrixAPI implementation
- * @callback: (scope async): the function to call when the request is
- * finished
- * @user_data: user data to pass to the callback function
- * @room_id: the room ID to get a topic for
- *
- * Get the topic of a room.
- */
-void
-matrix_api_get_room_topic(MatrixAPI *api,
- MatrixAPICallback callback,
- gpointer user_data,
- gchar *room_id)
-{
- g_return_if_fail(MATRIX_IS_API(api));
-
- MATRIX_API_GET_IFACE(api)
- ->get_room_topic(api, callback, user_data, room_id);
-}
-
-/**
- * matrix_api_initial_sync:
- * @api: a #MatrixAPI implementation
- * @callback: (scope async): the function to call when the request is
- * finished
- * @user_data: user data to pass to the callback function
- * @limit: the maximum number of events to get
- *
- * perform an initial sync of events
- */
-void
-matrix_api_initial_sync(MatrixAPI *api,
- MatrixAPICallback callback,
- gpointer user_data,
- guint limit)
-{
- g_return_if_fail(MATRIX_IS_API(api));
-
- MATRIX_API_GET_IFACE(api)
- ->initial_sync(api, callback, user_data, limit);
+ ->invite_user_3rdparty(api,
+ callback, user_data,
+ room_id, address, medium, id_server,
+ error);
}
/**
@@ -286,6 +1158,7 @@ matrix_api_initial_sync(MatrixAPI *api,
* @user_data: user data to pass to the callback function
* @room_id: the room ID to invite the user to
* @user_id: the user ID to invite
+ * @error: a #GError
*
* Invite a user to a room.
*/
@@ -293,13 +1166,14 @@ void
matrix_api_invite_user(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
- gchar *room_id,
- gchar *user_id)
+ const gchar *room_id,
+ const gchar *user_id,
+ GError **error)
{
g_return_if_fail(MATRIX_IS_API(api));
MATRIX_API_GET_IFACE(api)
- ->invite_user(api, callback, user_data, room_id, user_id);
+ ->invite_user(api, callback, user_data, room_id, user_id, error);
}
/**
@@ -309,6 +1183,7 @@ matrix_api_invite_user(MatrixAPI *api,
* finished
* @user_data: user data to pass to the callback function
* @room_id_or_alias: the room ID or room alias to join to
+ * @error: a #GError
*
* Join a room.
*/
@@ -316,38 +1191,13 @@ void
matrix_api_join_room(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
- gchar *room_id_or_alias)
+ const gchar *room_id_or_alias,
+ GError **error)
{
g_return_if_fail(MATRIX_IS_API(api));
MATRIX_API_GET_IFACE(api)
- ->join_room(api, callback, user_data, room_id_or_alias);
-}
-
-/**
- * matrix_api_kick_user:
- * @api: a #MatrixAPI implementation
- * @callback: (scope async): the function to call when the request is
- * finished
- * @user_data: user data to pass to the callback function
- * @room_id: the room ID to kick the user from
- * @user_id: the user to kick
- * @reason: (allow-none): the reason of kicking
- *
- * Kick a user from a room, with an optional reason.
- */
-void
-matrix_api_kick_user(MatrixAPI *api,
- MatrixAPICallback callback,
- gpointer user_data,
- gchar *room_id,
- gchar *user_id,
- gchar *reason)
-{
- g_return_if_fail(MATRIX_IS_API(api));
-
- MATRIX_API_GET_IFACE(api)
- ->kick_user(api, callback, user_data, room_id, user_id, reason);
+ ->join_room(api, callback, user_data, room_id_or_alias, error);
}
/**
@@ -357,6 +1207,7 @@ matrix_api_kick_user(MatrixAPI *api,
* finished
* @user_data: user data to pass to the callback function
* @room_id: the room ID to kick the user from
+ * @error: a #GError
*
* Leave a room
*/
@@ -364,117 +1215,283 @@ void
matrix_api_leave_room(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
- gchar *room_id)
+ const gchar *room_id,
+ GError **error)
{
g_return_if_fail(MATRIX_IS_API(api));
MATRIX_API_GET_IFACE(api)
- ->leave_room(api, callback, user_data, room_id);
+ ->leave_room(api, callback, user_data, room_id, error);
}
+/* Room participation */
+
/**
- * matrix_api_login:
+ * matrix_api_event_stream:
* @api: a #MatrixAPI implementation
* @callback: (scope async): 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: (allow-none): parameters to pass for the login request
+ * @from_token: (allow-none): events will be listed from this token
+ * @timeout: timeout of the request
+ * @error: a #GError
*
- * Attempt to login with type @login_type. Implementations of this
- * method must set the token property on a successful login.
+ * Get the event stream, optionally beginning from @from_token.
*/
void
-matrix_api_login(MatrixAPI *api,
- MatrixAPICallback callback,
- gpointer user_data,
- gchar *login_type,
- GHashTable *parameters)
-{
- g_return_if_fail(MATRIX_IS_API(api));
-
- MATRIX_API_GET_IFACE(api)
- ->login(api, callback, user_data, login_type, parameters);
-}
-
-/**
- * matrix_api_register_account:
- * @api: a #MatrixAPI implementation
- * @callback: (scope async): 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: (allow-none): parameters to pass for the registration
- * request
- *
- * Attempt to register with type @login_type. Implementations of this
- * method must set the token property on a successful login.
- */
-void
-matrix_api_register_account(MatrixAPI *api,
- MatrixAPICallback callback,
- gpointer user_data,
- gchar *login_type,
- GHashTable *parameters)
-{
- g_return_if_fail(MATRIX_IS_API(api));
-
- MATRIX_API_GET_IFACE(api)
- ->register_account(api, callback, user_data, login_type, parameters);
-}
-
-/**
- * matrix_api_send_emote:
- * @api: a #MatrixAPI implementation
- * @callback: (scope async): the function to call when the request is
- * finished
- * @user_data: user data to pass to the callback function
- * @room_id: the room to send the emote to
- * @text_content: the emote text to send
- *
- * Send an emote to the room.
- */
-void
-matrix_api_send_emote(MatrixAPI *api,
- MatrixAPICallback callback,
- gpointer user_data,
- gchar *room_id,
- gchar *text_content)
-{
- g_return_if_fail(MATRIX_IS_API(api));
-
- MATRIX_API_GET_IFACE(api)
- ->send_emote(api, callback, user_data, room_id, text_content);
-}
-
-/**
- * matrix_api_send_message:
- * @api: a #MatrixAPI implementation
- * @callback: (scope async): the function to call when the request is
- * finished
- * @user_data: user data to pass to the callback function
- * @room_id: the room to send the emote to
- * @text_content: the emote text to send
- * @msg_type: the type of the message to be sent
- *
- * Send a custom message to the room.
- */
-void
-matrix_api_send_message(MatrixAPI *api,
+matrix_api_event_stream(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
- gchar *room_id,
- gchar *text_content,
- gchar *msg_type)
+ const gchar *from_token,
+ gulong timeout,
+ GError **error)
{
g_return_if_fail(MATRIX_IS_API(api));
MATRIX_API_GET_IFACE(api)
- ->send_message(api,
+ ->event_stream(api, callback, user_data, from_token, timeout, error);
+}
+
+/**
+ * matrix_api_get_event:
+ * @api: a #MatrixAPI implementation
+ * @callback: (scope async): the function to call when the request is
+ * finished
+ * @user_data: user data to pass to the callback function
+ * @event_id: the event ID to get
+ * @error: a #GError
+ *
+ * Get a single event by event ID.
+ */
+void
+matrix_api_get_event(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *event_id,
+ GError **error)
+{
+ g_return_if_fail(MATRIX_IS_API(api));
+
+ MATRIX_API_GET_IFACE(api)
+ ->get_event(api, callback, user_data, event_id, error);
+}
+
+/**
+ * matrix_api_initial_sync:
+ * @api: a #MatrixAPI implementation
+ * @callback: (scope async): the function to call when the request is
+ * finished
+ * @user_data: user data to pass to the callback function
+ * @limit: the maximum number of events to get
+ * @archived: whether to include rooms that the user has left
+ * @error: a #GError
+ *
+ * perform an initial sync of events
+ */
+void
+matrix_api_initial_sync(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ guint limit,
+ gboolean archived,
+ GError **error)
+{
+ g_return_if_fail(MATRIX_IS_API(api));
+
+ MATRIX_API_GET_IFACE(api)
+ ->initial_sync(api, callback, user_data, limit, archived, error);
+}
+
+/**
+ * matrix_api_get_event_context:
+ * @api: a #MatrixAPI implementation
+ * @callback: (scope async): the function to call when the request is
+ * finished
+ * @user_data: user data to pass to the callback function
+ * @room_id: the room to get events from
+ * @event_id: the event to get context around
+ * @limit: the maximum number of events to get. If 0, a default value
+ * is used (10, according to the specification)
+ * @error: a #GError
+ *
+ * Gets a number of events that happened just before and after the
+ * specified event.
+ */
+void
+matrix_api_get_event_context(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *room_id,
+ const gchar *event_id,
+ guint limit,
+ GError **error)
+{
+ g_return_if_fail(MATRIX_IS_API(api));
+
+ MATRIX_API_GET_IFACE(api)
+ ->get_event_context(api,
+ callback, user_data,
+ room_id, event_id, limit, error);
+}
+
+/**
+ * matrix_api_initial_sync_room:
+ * @api: a #MatrixAPI implementation
+ * @callback: (scope async): the function to call when the request is
+ * finished
+ * @user_data: user data to pass to the callback function
+ * @room_id: the room to get the data for
+ * @error: a #GError
+ *
+ * Get a copy of the current state and the most recent messages in a
+ * room.
+ */
+void
+matrix_api_initial_sync_room(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *room_id,
+ GError **error)
+{
+ g_return_if_fail(MATRIX_IS_API(api));
+
+ MATRIX_API_GET_IFACE(api)
+ ->initial_sync_room(api, callback, user_data, room_id, error);
+}
+
+/**
+ * matrix_api_list_room_members:
+ * @api: a #MatrixAPI implementation
+ * @callback: (scope async): the function to call when the request is
+ * finished
+ * @user_data: user data to pass to the callback function
+ * @room_id: the room to get the member events for
+ * @error: a #GError
+ *
+ * Get the list of members for a room.
+ */
+void
+matrix_api_list_room_members(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *room_id,
+ GError **error)
+{
+ g_return_if_fail(MATRIX_IS_API(api));
+
+ MATRIX_API_GET_IFACE(api)
+ ->list_room_members(api, callback, user_data, room_id, error);
+}
+
+/**
+ * matrix_api_list_room_messages:
+ * @api: a #MatrixAPI implementation
+ * @callback: (scope async): the function to call when the request is
+ * finished
+ * @user_data: user data to pass to the callback function
+ * @room_id: the room to get the events for
+ * @from_token: the token to start returning events from. This token
+ * can be obtained by calling matrix_api_initial_sync()
+ * or matrix_api_initial_sync_room()
+ * @direction: the direction of the returned events
+ * @limit: the maximum number of events to return. If 0, a default
+ * value will be used (10, according to the specification
+ * @error: a #GError
+ *
+ * Get a list of message and state events for a room.
+ */
+void
+matrix_api_list_room_messages(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *room_id,
+ const gchar *from_token,
+ MatrixAPIEventDirection direction,
+ guint limit,
+ GError **error)
+{
+ g_return_if_fail(MATRIX_IS_API(api));
+
+ MATRIX_API_GET_IFACE(api)
+ ->list_room_messages(api,
+ callback, user_data,
+ room_id, from_token, direction, limit,
+ error);
+}
+
+/**
+ * matrix_api_send_event_receipt:
+ * @api: a #MatrixAPI implementation
+ * @callback: (scope async): the function to call when the request is
+ * finished
+ * @user_data: user data to pass to the callback function
+ * @room_id: the room in which to send the event
+ * @type: type of the receipt
+ * @event_id: the event ID to acknowledge up to
+ * @receipt: extra receipt information to attach. Note that the server
+ * will automatically attach the ts
field
+ * @error: a #GError
+ *
+ * Update the marker for the given receipt type to the event ID specified.
+ */
+void
+matrix_api_send_event_receipt(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *room_id,
+ MatrixAPIReceiptType type,
+ const gchar *event_id,
+ JsonNode *receipt,
+ GError **error)
+{
+ g_return_if_fail(MATRIX_IS_API(api));
+
+ MATRIX_API_GET_IFACE(api)
+ ->send_event_receipt(api,
+ callback, user_data,
+ room_id, type, event_id, receipt,
+ error);
+}
+
+/**
+ * matrix_api_redact_event:
+ * @api: a #MatrixAPI implementation
+ * @callback: (scope async): the function to call when the request is
+ * finished
+ * @user_data: user data to pass to the callback function
+ * @room_id: the room from which to redact the event
+ * @event_id: the event ID to acknowledge up to
+ * @txn_id: the transaction ID for this event. Clients should generate
+ * a unique ID; it will be used by the server to ensure
+ * idempotency of requests
+ * @reason: (allow-none): the reason for the event being redacted
+ * @error: a #GError
+ *
+ * Strip all information out of an event which isn't critical to the
+ * integrity of the server-side representation of the room. This
+ * cannot be undone.
+ *
+ * Users may redact their own events, and any user with a power level
+ * greater than or equal to redact
power level of the
+ * room may redact events there.
+ */
+void
+matrix_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,
+ GError **error)
+{
+ g_return_if_fail(MATRIX_IS_API(api));
+
+ MATRIX_API_GET_IFACE(api)
+ ->redact_event(api,
callback, user_data,
- room_id,
- text_content,
- msg_type);
+ room_id, event_id, txn_id, reason,
+ error);
}
/**
@@ -483,9 +1500,13 @@ matrix_api_send_message(MatrixAPI *api,
* @callback: (scope async): the function to call when the request is
* finished
* @user_data: user data to pass to the callback function
- * @room_id: the room to send the emote to
- * @event_type: the type of the event to send
+ * @room_id: the room to send the event to
+ * @event_type: the type of event to send
+ * @txn_id: the transaction ID for this event. Clients should generate
+ * a unique ID; it will be used by the server to ensure
+ * idempotency of requests
* @content: the content of the event as a #JsonNode
+ * @error: a #GError
*
* Send a message event to the room.
*/
@@ -493,9 +1514,11 @@ void
matrix_api_send_message_event(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
- gchar *room_id,
- gchar *event_type,
- JsonNode *content)
+ const gchar *room_id,
+ const gchar *event_type,
+ const gchar *txn_id,
+ const JsonNode *content,
+ GError **error)
{
g_return_if_fail(MATRIX_IS_API(api));
@@ -503,72 +1526,703 @@ matrix_api_send_message_event(MatrixAPI *api,
->send_message_event(api,
callback, user_data,
room_id,
- event_type,
- content);
+ event_type, txn_id,
+ content, error);
}
/**
- * matrix_api_send_state_event:
+ * matrix_api_get_room_state:
* @api: a #MatrixAPI implementation
* @callback: (scope async): the function to call when the request is
* finished
* @user_data: user data to pass to the callback function
- * @room_id: the room to send the emote to
- * @event_type: the type of the event to send
- * @content: the content of the event as a #JsonNode
- * @state_key: the state key to send
+ * @room_id: the room ID to get a state for
+ * @event_type: (allow-none): the type of state to look up
+ * @state_key: (allow-none): the key of the state to look up. If
+ * @event_type is %NULL, this parameter is ignored
+ * @error: a #GError
*
- * Send a state event to the room
+ * Look up the contents of a state event in a room. If both
+ * @event_type and @state_key are empty, get a list of state events
+ * for that room.
*/
void
-matrix_api_send_state_event(MatrixAPI *api,
- MatrixAPICallback callback,
- gpointer user_data,
- gchar *room_id,
- gchar *event_type,
- JsonNode *content,
- gchar *state_key)
-{
- g_return_if_fail(MATRIX_IS_API(api));
-
- MATRIX_API_GET_IFACE(api)
- ->send_state_event(api,
- callback, user_data,
- room_id,
- event_type,
- content,
- state_key);
-}
-
-/**
- * matrix_api_set_membership:
- * @api: a #MatrixAPI implementation
- * @callback: (scope async): the function to call when the request is
- * finished
- * @user_data: user data to pass to the callback function
- * @room_id: the room to send the emote to
- * @user_id: the user of whom membership will be set
- * @membership: the new membership of the user
- * @reason: (allow-none): the reason of the change
- *
- * Set the membership of the user for the given room.
- */
-void
-matrix_api_set_membership(MatrixAPI *api,
+matrix_api_get_room_state(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
- gchar *room_id,
- gchar *user_id,
- gchar *membership,
- gchar *reason)
+ const gchar *room_id,
+ const gchar *event_type,
+ const gchar *state_key,
+ GError **error)
{
g_return_if_fail(MATRIX_IS_API(api));
MATRIX_API_GET_IFACE(api)
- ->set_membership(api,
+ ->get_room_state(api,
callback, user_data,
- room_id,
- user_id,
- membership,
- reason);
+ room_id, event_type, state_key, error);
+}
+
+/**
+ * matrix_api_send_room_event:
+ * @api: a #MatrixAPI implementation
+ * @callback: (scope async): the function to call when the request is
+ * finished
+ * @user_data: user data to pass to the callback function
+ * @room_id: the room ID to get a state for
+ * @event_type: the type of state to look up
+ * @state_key: (allow-none): the key of the state to look up. If
+ * @event_type is %NULL, this parameter is ignored
+ * @content: the content of the state event
+ * @error: a #GError
+ *
+ * Send a state event to the room. These events will be overwritten if
+ * @room_id, @event_type and @state_key all match.
+ *
+ * This request cannot use transaction IDs.
+ *
+ * The required fields in the body of the request (@content) vary
+ * depending on the type of the event.
+ */
+void
+matrix_api_send_room_event(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *room_id,
+ const gchar *event_type,
+ const gchar *state_key,
+ const JsonNode *content,
+ GError **error)
+{
+ g_return_if_fail(MATRIX_IS_API(api));
+
+ MATRIX_API_GET_IFACE(api)
+ ->send_room_event(api,
+ callback, user_data,
+ room_id, event_type, state_key, content,
+ error);
+}
+
+/**
+ * matrix_api_notify_room_typing:
+ * @api: a #MatrixAPI implementation
+ * @callback: (scope async): the function to call when the request is
+ * finished
+ * @user_data: user data to pass to the callback function
+ * @user_id: the user who has started to type
+ * @room_id: the room in which the user is typing
+ * @timeout: the length of time in milliseconds to mark this user as
+ * typing
+ * @typing: whether the user is typing or not. If %FALSE, @timeout can
+ * be omitted (ie. set to 0)
+ * @error: a #GError
+ *
+ * Tell the server the user is typing for the next @timeout
+ * milliseconds. If @typing is %FALSE, it tells the server that the
+ * user stopped typing.
+ */
+void
+matrix_api_notify_room_typing(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *user_id,
+ const gchar *room_id,
+ guint timeout,
+ gboolean typing,
+ GError **error)
+{
+ g_return_if_fail(MATRIX_IS_API(api));
+
+ MATRIX_API_GET_IFACE(api)
+ ->notify_room_typing(api,
+ callback, user_data,
+ user_id, room_id, timeout, typing,
+ error);
+}
+
+/**
+ * matrix_api_sync:
+ * @api: a #MatrixAPI implementation
+ * @callback: (scope async): the function to call when the request is
+ * finished
+ * @user_data: user data to pass to the callback function
+ * @filter_id: (allow-none): a filter ID created by the filter API
+ * (e.g. matrix_api_create_filter())
+ * @filter: (allow-none): a definition on what events to fetch
+ * @since: (allow-none): a point in time to continue a sync from
+ * @full_state: if %TRUE, all state events will be returned, even if
+ * @since is not empty. If %FALSE, and @since is not
+ * empty, only states which have changed since the point
+ * indicated by @since will be returned
+ * @set_presence: controls whether the client is automatically marked
+ * as online by polling this API.
+ * @timeout: the maximum time to poll in milliseconds
+ * @error: a #GError
+ *
+ * Synchronize the client's state with the latest state on the
+ * server. Clients should use this API when they first log in to get
+ * an initial snapshot of the state on the server and then continue to
+ * call this API to get incremental details to the state and to
+ * receive new messages.
+ *
+ * Only one of @filter and @filter_id should be specified, or both of
+ * them should be set to %NULL to receive all events.
+ */
+void
+matrix_api_sync(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *filter_id,
+ const MatrixAPIFilter *filter,
+ const gchar *since,
+ gboolean full_state,
+ gboolean set_presence,
+ gulong timeout,
+ GError **error)
+{
+ g_return_if_fail(MATRIX_IS_API(api));
+
+ MATRIX_API_GET_IFACE(api)
+ ->sync(api,
+ callback, user_data,
+ filter_id, filter, since,
+ full_state, set_presence, timeout,
+ error);
+}
+
+/**
+ * matrix_api_create_filter:
+ * @api: a #MatrixAPI implementation
+ * @callback: (scope async): the function to call when the request is
+ * finished
+ * @user_data: user data to pass to the callback function
+ * @user_id: the ID of the user uploading the filter. An access token
+ * must be present (either specifying one with
+ * matrix_api_set_token() or requested from the server via
+ * matrix_api_register_account() or matrix_api_login().
+ * @filter: the filter to upload
+ * @error: a #GError
+ *
+ * Upload a new filter definition to the homeserver. It will return a
+ * filter ID that may be used in future requests.
+ */
+void
+matrix_api_create_filter(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *user_id,
+ MatrixAPIFilter *filter,
+ GError **error)
+{
+ g_return_if_fail(MATRIX_IS_API(api));
+
+ MATRIX_API_GET_IFACE(api)
+ ->create_filter(api,
+ callback, user_data,
+ user_id, filter,
+ error);
+}
+
+/**
+ * matrix_api_download_filter:
+ * @api: a #MatrixAPI implementation
+ * @callback: (scope async): the function to call when the request is
+ * finished
+ * @user_data: user data to pass to the callback function
+ * @user_id: the user ID to download a filter from
+ * @filter_id: the filter ID to download
+ * @error: a #GError
+ *
+ * Download a filter.
+ */
+void
+matrix_api_download_filter(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *user_id,
+ const gchar *filter_id,
+ GError **error)
+{
+ g_return_if_fail(MATRIX_IS_API(api));
+
+ MATRIX_API_GET_IFACE(api)
+ ->download_filter(api,
+ callback, user_data,
+ user_id, filter_id, error);
+}
+
+/* Search */
+
+/* Server administration */
+
+/**
+ * matrix_api_whois:
+ * @api: a #MatrixAPI implementation
+ * @callback: (scope async): the function to call when the request is
+ * finished
+ * @user_data: user data to pass to the callback function
+ * @user_id: the user ID to look up
+ * @error: a #GError
+ *
+ * Get information about a particular user.
+ */
+void
+matrix_api_whois(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *user_id,
+ GError **error)
+{
+ g_return_if_fail(MATRIX_IS_API(api));
+
+ MATRIX_API_GET_IFACE(api)
+ ->whois(api, callback, user_data, user_id, error);
+}
+
+/* Session management */
+
+/**
+ * matrix_api_login:
+ * @api: a #MatrixAPI implementation
+ * @callback: (scope async): the function to call when the request is
+ * finished
+ * @user_data: user data to pass to the callback function
+ * @type: the login type to use
+ * @content: (allow-none): parameters to pass for the login request
+ * @error: (allow-none): a #GError
+ *
+ * Attempt to login with type @type. Implementations of this method
+ * must set the token property on a successful login.
+ */
+void
+matrix_api_login(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *type,
+ const JsonNode *content,
+ GError **error)
+{
+ g_return_if_fail(MATRIX_IS_API(api));
+
+ MATRIX_API_GET_IFACE(api)
+ ->login(api, callback, user_data, type, content, error);
+}
+
+/**
+ * matrix_api_token_refresh:
+ * @api: a #MatrixAPI implementation
+ * @callback: (scope async): the function to call when the request is
+ * finished
+ * @user_data: user data to pass to the callback function
+ * @refresh_token: the refresh token that was issued by the server
+ * @error: a #GError
+ *
+ * Exchanges a refresh token for a new access token. This is intended
+ * to be used if the access token has expired.
+ */
+void
+matrix_api_token_refresh(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *refresh_token,
+ GError **error)
+{
+ g_return_if_fail(MATRIX_IS_API(api));
+
+ MATRIX_API_GET_IFACE(api)
+ ->token_refresh(api, callback, user_data, refresh_token, error);
+}
+
+/* User data */
+
+/**
+ * matrix_api_get_3pids:
+ * @api: a #MatrixAPI implementation
+ * @callback: (scope async): the function to call when the request is
+ * finished
+ * @user_data: user data to pass to the callback function
+ * @error: a #GError
+ *
+ * Get a list of the third party identifiers that a homeserver has
+ * associated with the user's account.
+ *
+ * This is not the same as the list of third party identifiers bound
+ * to the user's Matrix ID in Identity Servers.
+ *
+ * Identifiers in this list may be used by the homeserver as, for
+ * example, identifiers to accept to reset the user's account
+ * password.
+ */
+void
+matrix_api_get_3pids(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ GError **error)
+{
+ g_return_if_fail(MATRIX_IS_API(api));
+
+ MATRIX_API_GET_IFACE(api)
+ ->get_3pids(api, callback, user_data, error);
+}
+
+/**
+ * matrix_api_add_3pid:
+ * @api: a #MatrixAPI implementation
+ * @callback: (scope async): the function to call when the request is
+ * finished
+ * @user_data: user data to pass to the callback function
+ * @bind_creds: whether the homeserver should also bind this third
+ * party identifier to the account's Matrix ID with the
+ * passed Identity Server.
+ * @threepid_creds: the credentials to associate with the account
+ * @error: a #GError
+ *
+ * Add contact information to the user's account.
+ */
+void
+matrix_api_add_3pid(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ gboolean bind_creds,
+ MatrixAPI3PidCredential *threepid_creds,
+ GError **error)
+{
+ g_return_if_fail(MATRIX_IS_API(api));
+
+ MATRIX_API_GET_IFACE(api)
+ ->add_3pid(api, callback, user_data, bind_creds, threepid_creds, error);
+}
+
+/**
+ * matrix_api_change_password:
+ * @api: a #MatrixAPI implementation
+ * @callback: (scope async): the function to call when the request is
+ * finished
+ * @user_data: user data to pass to the callback function
+ * @new_password: the new password for the account
+ * @error: a #GError
+ *
+ * Change the active user's password.
+ */
+void
+matrix_api_change_password(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *new_password,
+ GError **error)
+{
+ g_return_if_fail(MATRIX_IS_API(api));
+
+ MATRIX_API_GET_IFACE(api)
+ ->change_password(api, callback, user_data, new_password, error);
+}
+
+/**
+ * matrix_api_get_profile:
+ * @api: a #MatrixAPI implementation
+ * @callback: (scope async): the function to call when the request is
+ * finished
+ * @user_data: user data to pass to the callback function
+ * @user_id: the user whose profile to get
+ * @error: a #GError
+ *
+ * Get a user's profile.
+ */
+void
+matrix_api_get_profile(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *user_id,
+ GError **error)
+{
+ g_return_if_fail(MATRIX_IS_API(api));
+
+ MATRIX_API_GET_IFACE(api)
+ ->get_profile(api, callback, user_data, user_id, error);
+}
+
+/**
+ * matrix_api_get_avatar_url:
+ * @api: a #MatrixAPI implementation
+ * @callback: (scope async): the function to call when the request is
+ * finished
+ * @user_data: user data to pass to the callback function
+ * @user_id: the user whose avatar URL to get
+ * @error: a #GError
+ *
+ * Get the URL of the specified user's avatar.
+ */
+void
+matrix_api_get_avatar_url(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *user_id,
+ GError **error)
+{
+ g_return_if_fail(MATRIX_IS_API(api));
+
+ MATRIX_API_GET_IFACE(api)
+ ->get_avatar_url(api, callback, user_data, user_id, error);
+}
+
+/**
+ * matrix_api_set_avatar_url:
+ * @api: a #MatrixAPI implementation
+ * @callback: (scope async): the function to call when the request is
+ * finished
+ * @user_data: user data to pass to the callback function
+ * @user_id: the user whose avatar URL to set
+ * @avatar_url: the avatar URL info
+ * @error: a #GError
+ *
+ * Set the user's avatar URL.
+ */
+void
+matrix_api_set_avatar_url(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *user_id,
+ const gchar *avatar_url,
+ GError **error)
+{
+ g_return_if_fail(MATRIX_IS_API(api));
+
+ MATRIX_API_GET_IFACE(api)
+ ->set_avatar_url(api, callback, user_data, user_id, avatar_url, error);
+}
+
+/**
+ * matrix_api_get_display_name:
+ * @api: a #MatrixAPI implementation
+ * @callback: (scope async): the function to call when the request is
+ * finished
+ * @user_data: user data to pass to the callback function
+ * @user_id: the user whose display name to get
+ * @error: a #GError
+ *
+ * Get the user's display name.
+ */
+void
+matrix_api_get_display_name(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *user_id,
+ GError **error)
+{
+ g_return_if_fail(MATRIX_IS_API(api));
+
+ MATRIX_API_GET_IFACE(api)
+ ->get_display_name(api, callback, user_data, user_id, error);
+}
+
+/**
+ * matrix_api_set_display_name:
+ * @api: a #MatrixAPI implementation
+ * @callback: (scope async): the function to call when the request is
+ * finished
+ * @user_data: user data to pass to the callback function
+ * @user_id: the user whose display name to set
+ * @display_name: the display name info
+ * @error: a #GError
+ *
+ * Set the user's display name.
+ */
+void
+matrix_api_set_display_name(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *user_id,
+ const gchar *display_name,
+ GError **error)
+{
+ g_return_if_fail(MATRIX_IS_API(api));
+
+ MATRIX_API_GET_IFACE(api)
+ ->set_display_name(api,
+ callback, user_data,
+ user_id, display_name, error);
+}
+
+/**
+ * matrix_api_register_account:
+ * @api: a #MatrixAPI implementation
+ * @callback: (scope async): the function to call when the request is
+ * finished
+ * @user_data: user data to pass to the callback function
+ * @bind_email: if %TRUE, the server binds the e-mail used for
+ * authentication to the Matrix ID with the ID server
+ * @username: (allow-none): the local part of the desired Matrix
+ * ID. If omitted, the server will generate a local part
+ * @password: (allow-none): the desired password for the account
+ * @error: a #GError
+ *
+ * Attempt to register with type @login_type. Implementations of this
+ * method must set the token property on a successful login.
+ */
+void
+matrix_api_register_account(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ gboolean bind_email,
+ const gchar *username,
+ const gchar *password,
+ GError **error)
+{
+ g_return_if_fail(MATRIX_IS_API(api));
+
+ MATRIX_API_GET_IFACE(api)
+ ->register_account(api, callback, user_data, bind_email,
+ username, password, error);
+}
+
+/**
+ * matrix_api_set_account_data:
+ * @api: a #MatrixAPI implementation
+ * @callback: (scope async): the function to call when the request is
+ * finished
+ * @user_data: user data to pass to the callback function
+ * @user_id: the user to set account data for. An access token must be
+ * present and be authorized to make requests for this user
+ * ID
+ * @room_id: (allow-none): the room to set account data for. If %NULL,
+ * the account data will be set globally
+ * @type: the event type of the account data to set. Custom types
+ * should be namespaced to avoid clashes.
+ * @content: the content of the account data
+ * @error: a #GError
+ *
+ * Set some account data for the client. This config is only visible
+ * to the user who set the account data. The config will be synced to
+ * clients in the top-level account data.
+ */
+void
+matrix_api_set_account_data(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *user_id,
+ const gchar *room_id,
+ const gchar *type,
+ const JsonNode *content,
+ GError **error)
+{
+ g_return_if_fail(MATRIX_IS_API(api));
+
+ MATRIX_API_GET_IFACE(api)
+ ->set_account_data(api,
+ callback, user_data,
+ user_id, room_id, type, content, error);
+}
+
+/**
+ * matrix_api_get_room_tags:
+ * @api: a #MatrixAPI implementation
+ * @callback: (scope async): the function to call when the request is
+ * finished
+ * @user_data: user data to pass to the callback function
+ * @user_id: the ID of the user to get the tags for. An access token
+ * must be set, and it must be authorised to make requests
+ * for this user ID
+ * @room_id: the room to get tags for
+ * @error: a #GError
+ *
+ * List the tags set by a user on a room.
+ */
+void
+matrix_api_get_room_tags(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *user_id,
+ const gchar *room_id,
+ GError **error)
+{
+ g_return_if_fail(MATRIX_IS_API(api));
+
+ MATRIX_API_GET_IFACE(api)
+ ->get_room_tags(api, callback, user_data, user_id, room_id, error);
+}
+
+/**
+ * matrix_api_delete_room_tag:
+ * @api: a #MatrixAPI implementation
+ * @callback: (scope async): the function to call when the request is
+ * finished
+ * @user_data: user data to pass to the callback function
+ * @user_id: the id of the user to remove a tag for
+ * @room_id: the id of the room to remove the tag from
+ * @tag: the tag to remove
+ * @error: a #GError
+ *
+ * Remove a tag from the room.
+ */
+void
+matrix_api_delete_room_tag(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *user_id,
+ const gchar *room_id,
+ const gchar *tag,
+ GError **error)
+{
+ g_return_if_fail(MATRIX_IS_API(api));
+
+ MATRIX_API_GET_IFACE(api)
+ ->delete_room_tag(api,
+ callback, user_data,
+ user_id, room_id, tag, error);
+}
+
+/**
+ * matrix_api_add_room_tag:
+ * @api: a #MatrixAPI implementation
+ * @callback: (scope async): the function to call when the request is
+ * finished
+ * @user_data: user data to pass to the callback function
+ * @user_id: the ID of the user to add the tag for
+ * @room_id: the ID of the room to add the tag for
+ * @tag: the tag to add
+ * @content: extra data for the tag, e.g. ordering
+ * @error: a #GError
+ *
+ * Add a tag to the room.
+ */
+void
+matrix_api_add_room_tag(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *user_id,
+ const gchar *room_id,
+ const gchar *tag,
+ JsonNode *content,
+ GError **error)
+{
+ g_return_if_fail(MATRIX_IS_API(api));
+
+ MATRIX_API_GET_IFACE(api)
+ ->add_room_tag(api,
+ callback, user_data,
+ user_id, room_id, tag, content, error);
+}
+
+/* VoIP */
+
+/**
+ * matrix_api_get_turn_server:
+ * @api: a #MatrixAPI implementation
+ * @callback: (scope async): the function to call when the request is
+ * finished
+ * @user_data: user data to pass to the callback function
+ * @error: a #GError
+ *
+ * Get credentials for the client to use when initiating calls.
+ */
+void
+matrix_api_get_turn_server(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ GError **error)
+{
+ g_return_if_fail(MATRIX_IS_API(api));
+
+ MATRIX_API_GET_IFACE(api)
+ ->get_turn_server(api, callback, user_data, error);
}
diff --git a/src/matrix-api.h b/src/matrix-api.h
index 33f78c7..d5422ca 100644
--- a/src/matrix-api.h
+++ b/src/matrix-api.h
@@ -50,235 +50,935 @@ typedef void (*MatrixAPICallback)(MatrixAPI *api,
gpointer data,
GError *err);
+typedef enum {
+ MATRIX_API_RESIZE_METHOD_CROP,
+ MATRIX_API_RESIZE_METHOD_SCALE
+} MatrixAPIResizeMethod;
+
+typedef enum {
+ MATRIX_API_PRESENCE_ONLINE,
+ MATRIX_API_PRESENCE_OFFLINE,
+ MATRIX_API_PRESENCE_UNAVAILABLE,
+ MATRIX_API_PRESENCE_FREE_FOR_CHAT
+} MatrixAPIPresence;
+
+typedef enum {
+ MATRIX_API_ROOM_PRESET_NONE,
+ MATRIX_API_ROOM_PRESET_PRIVATE,
+ MATRIX_API_ROOM_PRESET_TRUSTED_PRIVATE,
+ MATRIX_API_ROOM_PRESET_PUBLIC
+} MatrixAPIRoomPreset;
+
+typedef enum {
+ MATRIX_API_ROOM_VISIBILITY_DEFAULT,
+ MATRIX_API_ROOM_VISIBILITY_PUBLIC,
+ MATRIX_API_ROOM_VISIBILITY_PRIVATE
+} MatrixAPIRoomVisibility;
+
+typedef enum {
+ MATRIX_API_EVENT_DIRECTION_FORWARD,
+ MATRIX_API_EVENT_DIRECTION_BACKWARD
+} MatrixAPIEventDirection;
+
+typedef enum {
+ MATRIX_API_EVENT_FORMAT_DEFAULT,
+ MATRIX_API_EVENT_FORMAT_CLIENT,
+ MATRIX_API_EVENT_FORMAT_FEDERATION
+} MatrixAPIEventFormat;
+
+typedef enum {
+ MATRIX_API_RECEIPT_TYPE_READ
+} MatrixAPIReceiptType;
+
+typedef enum {
+ MATRIX_API_PUSHER_KIND_OVERRIDE,
+ MATRIX_API_PUSHER_KIND_SENDER,
+ MATRIX_API_PUSHER_KIND_ROOM,
+ MATRIX_API_PUSHER_KIND_CONTENT,
+ MATRIX_API_PUSHER_KIND_UNDERRIDE
+} MatrixAPIPusherKind;
+
+typedef enum {
+ MATRIX_API_PUSHER_CONDITION_KIND_EVENT_MATCH,
+ MATRIX_API_PUSHER_CONDITION_KIND_PROFILE_TAG,
+ MATRIX_API_PUSHER_CONDITION_KIND_CONTAINS_DISPLAY_NAME,
+ MATRIX_API_PUSHER_CONDITION_KIND_ROOM_MEMBER_COUNT
+} MatrixAPIPusherConditionKind;
+
+typedef struct _MatrixAPIPresenceFilter {
+ guint limit;
+ GList *senders;
+ GList *not_senders;
+ GList *types;
+ GList *not_types;
+} MatrixAPIPresenceFilter;
+
+typedef struct _MatrixAPIEventFilter {
+ GList *rooms;
+ GList *not_rooms;
+ guint limit;
+ GList *senders;
+ GList *not_senders;
+ GList *types;
+ GList *not_types;
+} MatrixAPIEventFilter;
+
+typedef struct _MatrixAPIRoomFilter {
+ MatrixAPIEventFilter *ephemeral;
+ gboolean include_leave;
+ MatrixAPIEventFilter *state;
+ MatrixAPIEventFilter *timeline;
+} MatrixAPIRoomFilter;
+
+typedef struct _MatrixAPIFilter {
+ GList *event_fields;
+ MatrixAPIEventFormat event_format;
+ MatrixAPIPresenceFilter *presence;
+ MatrixAPIRoomFilter *room;
+} MatrixAPIFilter;
+
+typedef struct _MatrixAPI3PidCredential {
+ gchar *client_secret;
+ gchar *id_server;
+ gchar *session_id;
+} MatrixAPI3PidCredential;
+
+typedef struct _MatrixAPIPusher {
+ gchar *app_display_name;
+ gchar *app_id;
+ gboolean append;
+ gchar *device_display_name;
+ gchar *kind;
+ gchar *lang;
+ gchar *profile_tag;
+ gchar *pushkey;
+ JsonNode *data;
+} MatrixAPIPusher;
+
+typedef struct _MatrixAPIStateEvent {
+ gchar *type;
+ gchar *state_key;
+ gchar *content;
+} MatrixAPIStateEvent;
+
struct _MatrixAPIInterface {
/*< private >*/
GTypeInterface g_iface;
/*< public >*/
- void (*register_account)(MatrixAPI *api,
- MatrixAPICallback callback,
- gpointer user_data,
- gchar *login_type,
- GHashTable *parameters);
- void (*login)(MatrixAPI *api,
- MatrixAPICallback callback,
- gpointer user_data,
- gchar *login_type,
- GHashTable *parameters);
- void (*initial_sync)(MatrixAPI *api,
+ /* Properties */
+ const gchar *(*get_token)(MatrixAPI *api);
+ void (*set_token)(MatrixAPI *api, const gchar *token);
+
+ /* Media */
+ void (*media_download)(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *server_name,
+ const gchar *media_id,
+ GError **error);
+ void (*media_thumbnail)(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *server_name,
+ const gchar *media_id,
+ guint width,
+ guint height,
+ MatrixAPIResizeMethod method,
+ GError **error);
+ void (*media_upload)(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
- guint limit);
- void (*event_stream)(MatrixAPI *api,
- MatrixAPICallback callback,
- gpointer user_data,
- gchar *from_token,
- gulong timeout);
+ const gchar *content_type,
+ const GByteArray *content,
+ GError **error);
+
+ /* Presence */
+ void (*get_presence_list)(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *user_id,
+ GError **error);
+ void (*update_presence_list)(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *user_id,
+ GList *drop_ids,
+ GList *invite_ids,
+ GError **error);
+ void (*get_user_presence)(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *user_id,
+ GError **error);
+ void (*set_user_presence)(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *user_id,
+ MatrixAPIPresence presence,
+ const gchar *status_message,
+ GError **error);
+
+ /* Push notifications */
+ void (*modify_pusher)(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ MatrixAPIPusher *pusher,
+ GError **error);
+ void (*get_pushers)(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ GError **error);
+ void (*delete_pusher)(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *scope,
+ MatrixAPIPusherKind kind,
+ const gchar *rule_id,
+ GError **error);
+ void (*get_pusher)(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *scope,
+ MatrixAPIPusherKind kind,
+ const gchar *rule_id,
+ GError **error);
+ void (*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,
+ GError **error);
+ void (*toggle_pusher)(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *scope,
+ MatrixAPIPusherKind kind,
+ const gchar *rule_id,
+ gboolean enabled,
+ GError **error);
+
+ /* Room creation */
void (*create_room)(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
- gchar *alias,
- gboolean is_public,
- GStrv invitees);
- void (*join_room)(MatrixAPI *api,
- MatrixAPICallback callback,
- gpointer user_data,
- gchar *room_id_or_alias);
- void (*send_state_event)(MatrixAPI *api,
- MatrixAPICallback callback,
- gpointer user_data,
- gchar *room_id,
- gchar *event_type,
- JsonNode *content,
- gchar *state_key);
- void (*send_message_event)(MatrixAPI *api,
- MatrixAPICallback callback,
- gpointer user_data,
- gchar *room_id,
- gchar *event_type,
- JsonNode *content);
- void (*send_message)(MatrixAPI *api,
- MatrixAPICallback callback,
- gpointer user_data,
- gchar *room_id,
- gchar *text_content,
- gchar *msg_type);
- void (*send_emote)(MatrixAPI *api,
- MatrixAPICallback callback,
- gpointer user_data,
- gchar *room_id,
- gchar *text_content);
- void (*get_room_name)(MatrixAPI *api,
- MatrixAPICallback callback,
- gpointer user_data,
- gchar *room_id);
- void (*get_room_topic)(MatrixAPI *api,
- MatrixAPICallback callback,
- gpointer user_data,
- gchar *room_id);
- void (*leave_room)(MatrixAPI *api,
- MatrixAPICallback callback,
- gpointer user_data,
- gchar *room_id);
- void (*invite_user)(MatrixAPI *api,
+ MatrixAPIRoomPreset preset,
+ const gchar *room_name,
+ const gchar *room_alias,
+ const gchar *topic,
+ MatrixAPIRoomVisibility visibility,
+ JsonNode *creation_content,
+ GList *initial_state,
+ GList *invitees,
+ GError **error);
+
+ /* Room directory */
+ void (*delete_room_alias)(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *room_alias,
+ GError **error);
+ void (*get_room_id)(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
- gchar *room_id,
- gchar *user_id);
- void (*kick_user)(MatrixAPI *api,
- MatrixAPICallback callback,
- gpointer user_data,
- gchar *room_id,
- gchar *user_id,
- gchar *reason);
- void (*set_membership)(MatrixAPI *api,
- MatrixAPICallback callback,
- gpointer user_data,
- gchar *room_id,
- gchar *user_id,
- gchar *membership,
- gchar *reason);
+ const gchar *room_alias,
+ GError **error);
+ void (*create_room_alias)(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *room_id,
+ const gchar *room_alias,
+ GError **error);
+
+ /* Room discovery */
+ void (*list_public_rooms)(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ GError **error);
+
+ /* Room membership */
+
void (*ban_user)(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
- gchar *room_id,
- gchar *user_id,
- gchar *reason);
+ const gchar *room_id,
+ const gchar *user_id,
+ const gchar *reason,
+ GError **error);
+ void (*forget_room)(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *room_id,
+ GError **error);
+ void (*invite_user_3rdparty)(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *room_id,
+ const gchar *address,
+ const gchar *medium,
+ const gchar *id_server,
+ GError **error);
+ void (*invite_user)(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *room_id,
+ const gchar *user_id,
+ GError **error);
+ void (*join_room)(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *room_id_or_alias,
+ GError **error);
+ void (*leave_room)(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *room_id,
+ GError **error);
+
+ /* Room participation */
+
+ void (*event_stream)(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *from_token,
+ gulong timeout,
+ GError **error);
+ void (*get_event)(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *event_id,
+ GError **error);
+ void (*initial_sync)(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ guint limit,
+ gboolean archived,
+ GError **error);
+ void (*get_event_context)(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *room_id,
+ const gchar *event_id,
+ guint limit,
+ GError **error);
+ void (*initial_sync_room)(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *room_id,
+ GError **error);
+ void (*list_room_members)(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *room_id,
+ GError **error);
+ void (*list_room_messages)(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *room_id,
+ const gchar *from_token,
+ MatrixAPIEventDirection direction,
+ guint limit,
+ GError **error);
+ void (*send_event_receipt)(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *room_id,
+ MatrixAPIReceiptType type,
+ const gchar *event_id,
+ JsonNode *receipt,
+ GError **error);
+ void (*redact_event)(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *room_id,
+ const gchar *event_id,
+ const gchar *txn_id,
+ const gchar *reason,
+ GError **error);
+ void (*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,
+ GError **error);
void (*get_room_state)(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
- gchar *room_id);
- void (*get_text_body)(MatrixAPI *api,
+ const gchar *room_id,
+ const gchar *event_type,
+ const gchar *state_key,
+ GError **error);
+ void (*send_room_event)(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *room_id,
+ const gchar *event_type,
+ const gchar *state_key,
+ const JsonNode *content,
+ GError **error);
+ void (*notify_room_typing)(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *user_id,
+ const gchar *room_id,
+ guint timeout,
+ gboolean typing,
+ GError **error);
+ void (*sync)(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *filter_id,
+ const MatrixAPIFilter *filter,
+ const gchar *since,
+ gboolean full_state,
+ gboolean set_presence,
+ gulong timeout,
+ GError **error);
+ void (*create_filter)(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
- gchar *text,
- gchar *msgtype);
- void (*get_html_body)(MatrixAPI *api,
- MatrixAPICallback callback,
- gpointer user_data,
- gchar *html,
- gchar *msgtype);
- void (*get_emote_body)(MatrixAPI *api,
- MatrixAPICallback callback,
- gpointer user_data,
- gchar *text);
- void (*_send)(MatrixAPI *api,
+ const gchar *user_id,
+ MatrixAPIFilter *filter,
+ GError **error);
+ void (*download_filter)(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *user_id,
+ const gchar *filter_id,
+ GError **error);
+
+ /* Search */
+ void *search_reserved;
+
+ /* Server administration */
+
+ void (*whois)(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
- gchar *method,
- gchar *path,
- gchar *content,
- gchar *query_params,
- gchar *headers);
+ const gchar *user_id,
+ GError **error);
+
+ /* Session management */
+
+ void (*login)(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *type,
+ const JsonNode *content,
+ GError **error);
+ void (*token_refresh)(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *refresh_token,
+ GError **error);
+
+ /* User data */
+
+ void (*get_3pids)(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ GError **error);
+ void (*add_3pid)(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ gboolean bind_creds,
+ MatrixAPI3PidCredential *threepid_creds,
+ GError **error);
+ void (*change_password)(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *new_password,
+ GError **error);
+ void (*get_profile)(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *user_id,
+ GError **error);
+ void (*get_avatar_url)(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *user_id,
+ GError **error);
+ void (*set_avatar_url)(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *user_id,
+ const gchar *avatar_url,
+ GError **error);
+ void (*get_display_name)(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *user_id,
+ GError **error);
+ void (*set_display_name)(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *user_id,
+ const gchar *display_name,
+ GError **error);
+ void (*register_account)(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ gboolean bind_email,
+ const gchar *username,
+ const gchar *password,
+ GError **error);
+ void (*set_account_data)(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *user_id,
+ const gchar *room_id,
+ const gchar *type,
+ const JsonNode *content,
+ GError **error);
+ void (*get_room_tags)(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *user_id,
+ const gchar *room_id,
+ GError **error);
+ void (*delete_room_tag)(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *user_id,
+ const gchar *room_id,
+ const gchar *tag,
+ GError **error);
+ void (*add_room_tag)(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *user_id,
+ const gchar *room_id,
+ const gchar *tag,
+ const JsonNode *content,
+ GError **error);
+
+ /* VoIP */
+
+ void (*get_turn_server)(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ GError **error);
/*< private >*/
- void *padding[20];
+ /* Leave room for endpoint expansion */
+ void *padding[50];
};
GType matrix_api_get_type(void) G_GNUC_CONST;
-void matrix_api_initial_sync(MatrixAPI *api,
+
+/* Property getters and setters */
+
+const gchar *matrix_api_get_token(MatrixAPI *api);
+void matrix_api_set_token(MatrixAPI *api, const gchar *token);
+
+/* API definition */
+
+/* Media */
+void matrix_api_media_download(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *server_name,
+ const gchar *media_id,
+ GError **error);
+void matrix_api_media_thumbnail(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *server_name,
+ const gchar *media_id,
+ guint width,
+ guint height,
+ MatrixAPIResizeMethod method,
+ GError **error);
+void matrix_api_media_upload(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
- guint limit);
-void matrix_api_register_account(MatrixAPI *api,
- MatrixAPICallback callback,
- gpointer user_data,
- gchar *login_type,
- GHashTable *parameters);
-void matrix_api_login(MatrixAPI *api,
- MatrixAPICallback callback,
- gpointer user_data,
- gchar *login_type,
- GHashTable *parameters);
+ const gchar *content_type,
+ const GByteArray *content,
+ GError **error);
+
+/* Presence */
+void matrix_api_get_presence_list(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *user_id,
+ GError **error);
+void matrix_api_update_presence_list(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *user_id,
+ GList *drop_ids,
+ GList *invite_ids,
+ GError **error);
+void matrix_api_get_user_presence(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *user_id,
+ GError **error);
+void matrix_api_set_user_presence(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *user_id,
+ MatrixAPIPresence presence,
+ const gchar *status_message,
+ GError **error);
+
+/* Push notifications */
+void matrix_api_modify_pusher(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ MatrixAPIPusher *pusher,
+ GError **error);
+void matrix_api_get_pushers(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ GError **error);
+void matrix_api_delete_pusher(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *scope,
+ MatrixAPIPusherKind kind,
+ const gchar *rule_id,
+ GError **error);
+void matrix_api_get_pusher(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *scope,
+ MatrixAPIPusherKind kind,
+ const gchar *rule_id,
+ GError **error);
+void matrix_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,
+ GError **error);
+void matrix_api_toggle_pusher(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *scope,
+ MatrixAPIPusherKind kind,
+ const gchar *rule_id,
+ gboolean enabled,
+ GError **error);
+
+/* Room creation */
void matrix_api_create_room(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
- gchar *alias,
- gboolean is_public,
- GStrv invitees);
-void matrix_api_join_room(MatrixAPI *api,
- MatrixAPICallback callback,
- gpointer user_data,
- gchar *room_id_or_alias);
-void matrix_api_event_stream(MatrixAPI *api,
- MatrixAPICallback callback,
- gpointer user_data,
- gchar *from_token,
- gulong timeout);
-void matrix_api_send_state_event(MatrixAPI *api,
- MatrixAPICallback callback,
- gpointer user_data,
- gchar *room_id,
- gchar *event_type,
- JsonNode *content,
- gchar *state_key);
-void matrix_api_send_message_event(MatrixAPI *api,
- MatrixAPICallback callback,
- gpointer user_data,
- gchar *room_id,
- gchar *event_type,
- JsonNode *content);
-void matrix_api_send_message(MatrixAPI *api,
- MatrixAPICallback callback,
- gpointer user_data,
- gchar *room_id,
- gchar *text_content,
- gchar *msg_type);
-void matrix_api_send_emote(MatrixAPI *api,
- MatrixAPICallback callback,
- gpointer user_data,
- gchar *room_id,
- gchar *text_content);
-void matrix_api_get_room_name(MatrixAPI *api,
- MatrixAPICallback callback,
- gpointer user_data,
- gchar *room_id);
-void matrix_api_get_room_topic(MatrixAPI *api,
- MatrixAPICallback callback,
- gpointer user_data,
- gchar *room_id);
-void matrix_api_leave_room(MatrixAPI *api,
- MatrixAPICallback callback,
- gpointer user_data,
- gchar *room_id);
-void matrix_api_invite_user(MatrixAPI *api,
+ MatrixAPIRoomPreset preset,
+ const gchar *room_name,
+ const gchar *room_alias,
+ const gchar *topic,
+ MatrixAPIRoomVisibility visibility,
+ JsonNode *creation_content,
+ GList *initial_state,
+ GList *invitees,
+ GError **error);
+
+/* Room directory */
+void matrix_api_delete_room_alias(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *room_alias,
+ GError **error);
+void matrix_api_get_room_id(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
- gchar *room_id,
- gchar *user_id);
-void matrix_api_kick_user(MatrixAPI *api,
- MatrixAPICallback callback,
- gpointer user_data,
- gchar *room_id,
- gchar *user_id,
- gchar *reason);
-void matrix_api_set_membership(MatrixAPI *api,
- MatrixAPICallback callback,
- gpointer user_data,
- gchar *room_id,
- gchar *user_id,
- gchar *membership,
- gchar *reason);
+ const gchar *room_alias,
+ GError **error);
+void matrix_api_create_room_alias(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *room_id,
+ const gchar *room_alias,
+ GError **error);
+
+/* Room discovery */
+void matrix_api_list_public_rooms(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ GError **error);
+
+/* Room membership */
+
void matrix_api_ban_user(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
- gchar *room_id,
- gchar *user_id,
- gchar *reason);
+ const gchar *room_id,
+ const gchar *user_id,
+ const gchar *reason,
+ GError **error);
+void matrix_api_forget_room(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *room_id,
+ GError **error);
+void matrix_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,
+ GError **error);
+void matrix_api_invite_user(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *room_id,
+ const gchar *user_id,
+ GError **error);
+void matrix_api_join_room(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *room_id_or_alias,
+ GError **error);
+void matrix_api_leave_room(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *room_id,
+ GError **error);
+
+/* Room participation */
+
+void matrix_api_event_stream(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *from_token,
+ gulong timeout,
+ GError **error);
+void matrix_api_get_event(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *event_id,
+ GError **error);
+void matrix_api_initial_sync(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ guint limit,
+ gboolean archived,
+ GError **error);
+void matrix_api_get_event_context(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *room_id,
+ const gchar *event_id,
+ guint limit,
+ GError **error);
+void matrix_api_initial_sync_room(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *room_id,
+ GError **error);
+void matrix_api_list_room_members(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *room_id,
+ GError **error);
+void matrix_api_list_room_messages(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *room_id,
+ const gchar *from_token,
+ MatrixAPIEventDirection direction,
+ guint limit,
+ GError **error);
+void matrix_api_send_event_receipt(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *room_id,
+ MatrixAPIReceiptType type,
+ const gchar *event_id,
+ JsonNode *receipt,
+ GError **error);
+void matrix_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,
+ GError **error);
+void matrix_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,
+ GError **error);
void matrix_api_get_room_state(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
- gchar *room_id);
-void matrix_api_get_text_body(MatrixAPI *api, gchar *text, gchar *msgtype);
-void matrix_api_get_html_body(MatrixAPI *api, gchar *html, gchar *msgtype);
-void matrix_api_get_emote_body(MatrixAPI *api, gchar *text);
-void _send(MatrixAPI *api,
- gchar *method,
- gchar *path,
- gchar *content,
- GHashTable *query_params,
- GHashTable *headers);
+ const gchar *room_id,
+ const gchar *event_type,
+ const gchar *state_key,
+ GError **error);
+void matrix_api_send_room_event(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *room_id,
+ const gchar *event_type,
+ const gchar *state_key,
+ const JsonNode *content,
+ GError **error);
+void matrix_api_notify_room_typing(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *user_id,
+ const gchar *room_id,
+ guint timeout,
+ gboolean typing,
+ GError **error);
+void matrix_api_sync(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *filter_id,
+ const MatrixAPIFilter *filter,
+ const gchar *since,
+ gboolean full_state,
+ gboolean set_presence,
+ gulong timeout,
+ GError **error);
+void matrix_api_create_filter(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *user_id,
+ MatrixAPIFilter *filter,
+ GError **error);
+void matrix_api_download_filter(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *user_id,
+ const gchar *filter_id,
+ GError **error);
+
+/* Search */
+
+/* Add the search function here */
+
+/* Server administration */
+
+void matrix_api_whois(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *user_id,
+ GError **error);
+
+/* Session management */
+
+void matrix_api_login(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *type,
+ const JsonNode *content,
+ GError **error);
+void matrix_api_token_refresh(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *refresh_token,
+ GError **error);
+
+/* User data */
+
+void matrix_api_get_3pids(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ GError **error);
+void matrix_api_add_3pid(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ gboolean bind_creds,
+ MatrixAPI3PidCredential *threepid_creds,
+ GError **error);
+void matrix_api_change_password(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *new_password,
+ GError **error);
+void matrix_api_get_profile(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *user_id,
+ GError **error);
+void matrix_api_get_avatar_url(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *user_id,
+ GError **error);
+void matrix_api_set_avatar_url(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *user_id,
+ const gchar *avatar_url,
+ GError **error);
+void matrix_api_get_display_name(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *user_id,
+ GError **error);
+void matrix_api_set_display_name(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *user_id,
+ const gchar *display_name,
+ GError **error);
+void matrix_api_register_account(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ gboolean bind_email,
+ const gchar *username,
+ const gchar *password,
+ GError **error);
+void matrix_api_set_account_data(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *user_id,
+ const gchar *room_id,
+ const gchar *type,
+ const JsonNode *content,
+ GError **error);
+void matrix_api_get_room_tags(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *user_id,
+ const gchar *room_id,
+ GError **error);
+void matrix_api_delete_room_tag(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *user_id,
+ const gchar *room_id,
+ const gchar *tag,
+ GError **error);
+void matrix_api_add_room_tag(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *user_id,
+ const gchar *room_id,
+ const gchar *tag,
+ JsonNode *content,
+ GError **error);
+
+/* VoIP */
+
+void matrix_api_get_turn_server(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ GError **error);
G_END_DECLS
diff --git a/src/matrix-http-api.c b/src/matrix-http-api.c
index 80d491e..d7bc7bb 100644
--- a/src/matrix-http-api.c
+++ b/src/matrix-http-api.c
@@ -50,7 +50,6 @@
typedef struct _MatrixHTTPAPIPrivate {
SoupSession *soup_session;
- guint txn_id;
SoupURI *uri;
gchar *token;
gboolean validate_certificate;
@@ -82,10 +81,6 @@ static void
matrix_http_api_matrix_api_init(MatrixAPIInterface *iface)
{
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
@@ -97,9 +92,9 @@ matrix_http_api_finalize(GObject *gobject)
static void
matrix_http_api_set_property(GObject *gobject,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
MatrixHTTPAPI *api = MATRIX_HTTP_API(gobject);
MatrixHTTPAPIPrivate *priv = matrix_http_api_get_instance_private(api);
@@ -178,9 +173,9 @@ matrix_http_api_set_property(GObject *gobject,
static void
matrix_http_api_get_property(GObject *gobject,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
MatrixHTTPAPI *api = MATRIX_HTTP_API(gobject);
MatrixHTTPAPIPrivate *priv = matrix_http_api_get_instance_private(api);
@@ -264,7 +259,6 @@ matrix_http_api_init(MatrixHTTPAPI *api)
{
MatrixHTTPAPIPrivate *priv = matrix_http_api_get_instance_private(api);
- priv->txn_id = 0;
priv->uri = NULL;
priv->token = NULL;
priv->validate_certificate = TRUE;
@@ -303,7 +297,7 @@ matrix_http_api_set_validate_certificate(MatrixHTTPAPI *api,
{
MatrixHTTPAPIPrivate *priv = matrix_http_api_get_instance_private(api);
- priv->validate_certificate = validate_certificate;
+ priv->validate_certificate = validate_certificate;
}
/**
@@ -412,7 +406,7 @@ response_callback(SoupSession *session,
}
- /* Call the assigned function, if any */
+ /* Call the assigned function, if any */
if (request->callback) {
request->callback(
MATRIX_API(api),
@@ -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:
* @api: a #MatrixHTTPAPI implementation
@@ -636,153 +440,49 @@ matrix_http_api_get_base_url(MatrixHTTPAPI *api)
return soup_uri_to_string(priv->uri, FALSE);
}
-/**
- * matrix_http_api_register_account:
- * @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,
- gpointer user_data,
- gchar *login_type,
- GHashTable *parameters)
+static void
+matrix_http_api_send(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *method,
+ const gchar *path,
+ const JsonNode *content,
+ GError **error)
{
- matrix_http_api_login_or_register(api,
- callback,
- user_data,
- "register",
- login_type,
- parameters);
-}
+ if (!g_str_is_ascii(method)) {
+ g_warning("Method must be ASCII encoded!");
-/**
- * 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;
}
- escaped_alias = soup_uri_encode(room_id_or_alias, NULL);
- path = g_strdup_printf("join/%s", escaped_alias);
- g_free(escaped_alias);
+ if ((g_ascii_strcasecmp("GET", method) != 0)
+ && (g_ascii_strcasecmp("POST", method) != 0)
+ && (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,
- NULL, NULL);
+}
+
+void
+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);
}
diff --git a/src/matrix-http-api.h b/src/matrix-http-api.h
index e0860e5..15fee58 100644
--- a/src/matrix-http-api.h
+++ b/src/matrix-http-api.h
@@ -52,32 +52,354 @@ void matrix_http_api_set_validate_certificate(MatrixHTTPAPI *api,
gboolean matrix_http_api_get_validate_certificate(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);
-void matrix_http_api_login(MatrixAPI *api,
- MatrixAPICallback callback,
- gpointer user_data,
- gchar *login_type,
- GHashTable *parameters);
-void matrix_http_api_register_account(MatrixAPI *api,
- MatrixAPICallback callback,
- gpointer user_data,
- gchar *login_type,
- GHashTable *parameters);
-void matrix_http_api_initial_sync(MatrixAPI *api,
+
+/* Media */
+void matrix_http_api_media_download(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *server_name,
+ const gchar *media_id);
+void matrix_http_api_media_thumbnail(MatrixAPI *api,
+ MatrixAPICallback callback,
+ gpointer user_data,
+ const gchar *server_name,
+ const gchar *media_id,
+ guint width,
+ guint height,
+ MatrixAPIResizeMethod method);
+void matrix_http_api_media_upload(MatrixAPI *api,
MatrixAPICallback callback,
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,
MatrixAPICallback callback,
gpointer user_data,
- gchar *room_alias,
- gboolean is_public,
- GStrv invitees);
+ MatrixAPIRoomPreset preset,
+ const gchar *room_name,
+ 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,
MatrixAPICallback callback,
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
diff --git a/src/test-client.c b/src/test-client.c
index d87058a..0c7c3f1 100644
--- a/src/test-client.c
+++ b/src/test-client.c
@@ -36,6 +36,10 @@ create_room_finished(MatrixAPI *api,
gpointer data,
GError *err)
{
+ if (err) {
+ g_debug("Error: %s", err->message);
+ }
+
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);
- matrix_http_api_create_room(api,
- create_room_finished, NULL,
- "matrix-glib-sdk-test", TRUE,
- NULL);
+ /* matrix_http_api_create_room(api, */
+ /* create_room_finished, NULL, */
+ /* MATRIX_API_ROOM_PRESET_PUBLIC, */
+ /* "matrix-glib-sdk-test", NULL, */
+ /* "GLib SDK test room", */
+ /* MATRIX_API_ROOM_VISIBILITY_DEFAULT, */
+ /* NULL, NULL, NULL); */
} else {
g_printf("Login unsuccessful!\n");
}
@@ -86,6 +93,8 @@ main(int argc, char *argv[])
GOptionContext *opts;
GError *err = NULL;
gchar *url;
+ JsonBuilder *builder;
+ JsonNode *login_content;
opts = g_option_context_new(NULL);
g_option_context_add_main_entries(opts, entries, NULL);
@@ -111,19 +120,31 @@ main(int argc, char *argv[])
/*
* [ ] register
- * [X] login
- * [X] create_room
+ * [ ] login
+ * [ ] create_room
* [ ] join_room
*/
api = matrix_http_api_new(url, NULL);
- params = matrix_http_api_gen_parameters(
- "user", user,
- "password", password,
- NULL);
+ builder = json_builder_new();
+ json_builder_begin_object(builder);
+ json_builder_set_member_name(builder, "user");
+ 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),
login_finished, loop,
"m.login.password",
- params);
+ login_content,
+ &err);
+
+ if (err) {
+ g_warning("Error: %s", err->message);
+
+ return;
+ }
g_info("Entering main loop");
g_main_loop_run(loop);