2016-03-04 07:58:56 +00:00
|
|
|
|
/*
|
|
|
|
|
* This file is part of matrix-glib-sdk
|
|
|
|
|
*
|
|
|
|
|
* matrix-glib-sdk is free software: you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
* License as published by the Free Software Foundation, either
|
|
|
|
|
* version 3 of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* matrix-glib-sdk is distributed in the hope that it will be
|
|
|
|
|
* useful, but WITHOUT ANY WARRANTY; without even the implied
|
|
|
|
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
* See the GNU Lesser General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
* License along with matrix-glib-sdk. If not, see
|
|
|
|
|
* <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
namespace Matrix {
|
2016-02-19 13:32:20 +00:00
|
|
|
|
public errordomain Error {
|
2016-03-18 09:55:22 +00:00
|
|
|
|
/**
|
|
|
|
|
* no error. You should never see this.
|
|
|
|
|
*/
|
|
|
|
|
NONE,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* there was a problem in communication (e.g. connection
|
|
|
|
|
* error)
|
|
|
|
|
*/
|
|
|
|
|
COMMUNICATION_ERROR,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* the passed/generated data is incomplete
|
|
|
|
|
*/
|
|
|
|
|
INCOMPLETE,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* the request is invalid
|
|
|
|
|
*/
|
|
|
|
|
BAD_REQUEST,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* malformed response, or the response is not a JSON object
|
|
|
|
|
*/
|
|
|
|
|
BAD_RESPONSE,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* the provided string doesn’t contain a valid room ID
|
|
|
|
|
*/
|
|
|
|
|
INVALID_ROOM_ID,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* the response from the Matrix.org server contains a value
|
|
|
|
|
* unknown to this library. These should be reported to the
|
|
|
|
|
* Matrix GLib SDK developers
|
|
|
|
|
*/
|
|
|
|
|
UNKNOWN_VALUE,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* the provided type is invalid
|
|
|
|
|
*/
|
|
|
|
|
INVALID_TYPE,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* the operation is unsupported
|
|
|
|
|
*/
|
|
|
|
|
UNSUPPORTED,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* the format of the JSON node is invalid (e.g. it is an array
|
|
|
|
|
* instead of an object)
|
|
|
|
|
*/
|
|
|
|
|
INVALID_FORMAT,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* the requested data is not cached yet. Clients getting this
|
|
|
|
|
* message may go online by some means to get the data
|
|
|
|
|
*/
|
|
|
|
|
UNAVAILABLE,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* the requested data (e.g. member of a room) can not be found
|
|
|
|
|
*/
|
|
|
|
|
NOT_FOUND,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* the data to create (e.g. when adding a new member to a Room
|
|
|
|
|
* object) already exists
|
|
|
|
|
*/
|
|
|
|
|
ALREADY_EXISTS,
|
2016-02-19 13:32:20 +00:00
|
|
|
|
|
|
|
|
|
/* Add Matrix-defined error codes under here, prefixing them with
|
|
|
|
|
* `MATRIX_ERROR_`, i.e. `M_FORBIDDEN` =>
|
|
|
|
|
* `MATRIX_ERROR_M_FORBIDDEN` */
|
2016-03-18 09:55:22 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* authorization token is missing from the request
|
|
|
|
|
*/
|
|
|
|
|
M_MISSING_TOKEN = 500,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* access was forbidden (e.g. due to a missing/invalid token,
|
|
|
|
|
* or using a bad password during login)
|
|
|
|
|
*/
|
|
|
|
|
M_FORBIDDEN,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* an error unknown to the Matrix homeserver
|
|
|
|
|
*/
|
|
|
|
|
M_UNKNOWN,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* the token provided is not known for the homeserver
|
|
|
|
|
*/
|
|
|
|
|
M_UNKNOWN_TOKEN,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* illegal request, the content is not valid JSON
|
|
|
|
|
*/
|
|
|
|
|
M_NOT_JSON,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* the homeserver didn't understand the request
|
|
|
|
|
*/
|
|
|
|
|
M_UNRECOGNIZED,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* the request is unauthorized
|
|
|
|
|
*/
|
|
|
|
|
M_UNAUTHORIZED,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* the JSON data is not in the required format
|
|
|
|
|
*/
|
|
|
|
|
M_BAD_JSON,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* the specified username is in use
|
|
|
|
|
*/
|
|
|
|
|
M_USER_IN_USE,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* the specified room is in use
|
|
|
|
|
*/
|
|
|
|
|
M_ROOM_IN_USE,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* invalid pagination parameters
|
|
|
|
|
*/
|
|
|
|
|
M_BAD_PAGINATION,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* invalid state event
|
|
|
|
|
*/
|
|
|
|
|
M_BAD_STATE,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* the requested resource is not found
|
|
|
|
|
*/
|
|
|
|
|
M_NOT_FOUND,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* guest access was requested, but ( it is forbidden
|
|
|
|
|
*/
|
|
|
|
|
M_GUEST_ACCESS_FORBIDDEN,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* the request was rate limited
|
|
|
|
|
*/
|
|
|
|
|
M_LIMIT_EXCEEDED,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* a captcha is needed to continue
|
|
|
|
|
*/
|
|
|
|
|
M_CAPTCHA_NEEDED,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* the provided captcha is invalid
|
|
|
|
|
*/
|
|
|
|
|
M_CAPTCHA_INVALID,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* a parameter is missing from the request
|
|
|
|
|
*/
|
|
|
|
|
M_MISSING_PARAM,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* the request data is too large
|
|
|
|
|
*/
|
|
|
|
|
M_TOO_LARGE,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* the desired user ID is in an exclusive namespace claimed by
|
|
|
|
|
* an application server
|
|
|
|
|
*/
|
|
|
|
|
M_EXCLUSIVE,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 3rd party authentication failed
|
|
|
|
|
*/
|
|
|
|
|
M_THREEPID_AUTH_FAILED,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* the provided 3rd party ID is already in use
|
|
|
|
|
*/
|
|
|
|
|
M_THREEPID_IN_USE,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* the given username is invalid
|
|
|
|
|
*/
|
|
|
|
|
M_INVALID_USERNAME,
|
|
|
|
|
|
|
|
|
|
/* Allow for a lot of Matrix.org defined codes. Do not define
|
|
|
|
|
* Matrix-specific error codes after this! */
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* no error code was sent by the homeserver. If you see this
|
|
|
|
|
* error, that usually indicates a homeserver bug
|
|
|
|
|
*/
|
|
|
|
|
UNSPECIFIED = 16383,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* an error unknown to this library
|
|
|
|
|
*/
|
|
|
|
|
UNKNOWN_ERROR;
|
2016-02-19 13:32:20 +00:00
|
|
|
|
|
|
|
|
|
public static GLib.Quark
|
|
|
|
|
quark ()
|
|
|
|
|
{
|
|
|
|
|
return Quark.from_string("matrix-error-quark");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-03 11:45:57 +00:00
|
|
|
|
/**
|
|
|
|
|
* User account types.
|
|
|
|
|
*/
|
|
|
|
|
public enum AccountKind {
|
2016-03-18 09:55:22 +00:00
|
|
|
|
/**
|
|
|
|
|
* use the server default (usually
|
|
|
|
|
* {@link Matrix.AccountKind.USER})
|
|
|
|
|
*/
|
|
|
|
|
DEFAULT,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* normal user
|
|
|
|
|
*/
|
|
|
|
|
USER,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* guest user
|
|
|
|
|
*/
|
|
|
|
|
GUEST;
|
2016-03-03 11:45:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-03 11:49:01 +00:00
|
|
|
|
/**
|
|
|
|
|
* Direction of events when requesting an event context.
|
|
|
|
|
*/
|
|
|
|
|
public enum EventDirection {
|
2016-03-18 09:55:22 +00:00
|
|
|
|
/**
|
|
|
|
|
* list events after the specified one
|
|
|
|
|
*/
|
|
|
|
|
FORWARD,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* list events before the specified one
|
|
|
|
|
*/
|
|
|
|
|
BACKWARD;
|
2016-03-03 11:49:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-03 11:34:30 +00:00
|
|
|
|
/**
|
|
|
|
|
* Event format received when synchronizing.
|
|
|
|
|
*/
|
|
|
|
|
public enum EventFormat {
|
2016-03-18 09:55:22 +00:00
|
|
|
|
/**
|
|
|
|
|
* event format will be omitted from the filter, so the server
|
|
|
|
|
* will use its default (usually
|
|
|
|
|
* {@link Matrix.EventFormat.FEDERATION})
|
|
|
|
|
*/
|
|
|
|
|
DEFAULT,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* return the events in a format suitable for clients
|
|
|
|
|
*/
|
|
|
|
|
CLIENT,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* return the raw event as receieved over federation
|
|
|
|
|
*/
|
|
|
|
|
FEDERATION;
|
2016-03-03 11:34:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-03 12:07:54 +00:00
|
|
|
|
/**
|
|
|
|
|
* Presence values for matrix_api_set_user_presence() and other
|
|
|
|
|
* presence related queries.
|
|
|
|
|
*/
|
|
|
|
|
public enum Presence {
|
2016-03-18 09:55:22 +00:00
|
|
|
|
/**
|
|
|
|
|
* user's presence is unknown
|
|
|
|
|
*/
|
|
|
|
|
UNKNOWN,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* user is online
|
|
|
|
|
*/
|
|
|
|
|
ONLINE,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* user is offline
|
|
|
|
|
*/
|
|
|
|
|
OFFLINE,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* user is unavailable (i.e. busy)
|
|
|
|
|
*/
|
|
|
|
|
UNAVAILABLE,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* user is free for chat
|
|
|
|
|
*/
|
|
|
|
|
FREE_FOR_CHAT;
|
2016-03-03 12:07:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-03 12:12:56 +00:00
|
|
|
|
/**
|
|
|
|
|
* Condition types for pushers.
|
|
|
|
|
*/
|
|
|
|
|
public enum PusherConditionKind {
|
2016-03-18 09:55:22 +00:00
|
|
|
|
/**
|
|
|
|
|
* glob pattern match on a field of the event. Requires a
|
|
|
|
|
* {{{key}}} and a {{{pattern}}} parameter
|
|
|
|
|
*/
|
|
|
|
|
EVENT_MATCH,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* matches the profile tag of the device that the notification
|
|
|
|
|
* would be delivered to. Requires a {{{profile_tag}}}
|
|
|
|
|
* parameter
|
|
|
|
|
*/
|
|
|
|
|
PROFILE_TAG,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* matches unencrypted messages where the content's body
|
|
|
|
|
* contains the owner's display name in that room.
|
|
|
|
|
*/
|
|
|
|
|
CONTAINS_DISPLAY_NAME,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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 {{{==}}}
|
|
|
|
|
*/
|
|
|
|
|
ROOM_MEMBER_COUNT;
|
2016-03-03 12:12:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-03 13:22:00 +00:00
|
|
|
|
/**
|
|
|
|
|
* Pusher types.
|
|
|
|
|
*/
|
|
|
|
|
public enum PusherKind {
|
2016-03-18 09:55:22 +00:00
|
|
|
|
/**
|
|
|
|
|
* highest priority rules
|
|
|
|
|
*/
|
|
|
|
|
OVERRIDE,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* for (unencrypted) messages that match certain patterns
|
|
|
|
|
*/
|
|
|
|
|
SENDER,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* for all messages for a given room. The rule ID of a room
|
|
|
|
|
* rule is always the ID of the room that it affects
|
|
|
|
|
*/
|
|
|
|
|
ROOM,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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
|
|
|
|
|
*/
|
|
|
|
|
CONTENT,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* lowest priority rules
|
|
|
|
|
*/
|
|
|
|
|
UNDERRIDE;
|
2016-03-03 13:22:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-03 13:23:25 +00:00
|
|
|
|
/**
|
|
|
|
|
* Receipt types of acknowledgment.
|
|
|
|
|
*/
|
|
|
|
|
public enum ReceiptType {
|
2016-03-18 09:55:22 +00:00
|
|
|
|
/**
|
|
|
|
|
* indicate that the message has been read
|
|
|
|
|
*/
|
|
|
|
|
READ;
|
2016-03-03 13:23:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-03 11:37:02 +00:00
|
|
|
|
/**
|
|
|
|
|
* Resizing methods for matrix_api_media_thumbnail().
|
|
|
|
|
*/
|
|
|
|
|
public enum ResizeMethod {
|
2016-03-18 09:55:22 +00:00
|
|
|
|
/**
|
|
|
|
|
* use the server default value
|
|
|
|
|
*/
|
|
|
|
|
DEFAULT,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* crop thumbnail to the requested size
|
|
|
|
|
*/
|
|
|
|
|
CROP,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* scale thumbnail to the requested size
|
|
|
|
|
*/
|
|
|
|
|
SCALE;
|
2016-03-03 11:37:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-03 09:42:52 +00:00
|
|
|
|
/**
|
|
|
|
|
* Room membership types.
|
|
|
|
|
*/
|
|
|
|
|
public enum RoomMembership {
|
2016-03-18 09:55:22 +00:00
|
|
|
|
/**
|
|
|
|
|
* the membership sent by the server is unknown to this SDK
|
|
|
|
|
*/
|
|
|
|
|
UNKNOWN,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* the user has been invited to join a room, but has not yet
|
|
|
|
|
* joined it. They may not participate in the room until they
|
|
|
|
|
* join
|
|
|
|
|
*/
|
|
|
|
|
INVITE,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* the user has joined the room (possibly after accepting an
|
|
|
|
|
* invite), and may participate in it
|
|
|
|
|
*/
|
|
|
|
|
JOIN,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* the user was once joined to the room, but has since left
|
|
|
|
|
* (possibly by choice, or possibly by being kicked)
|
|
|
|
|
*/
|
|
|
|
|
LEAVE,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* the user has been banned from the room, and is no longer
|
|
|
|
|
* allowed to join it until they are un-banned from the room
|
|
|
|
|
* (by having their membership state set to a value other than
|
|
|
|
|
* {@link Matrix.RoomMembership.BAN})
|
|
|
|
|
*/
|
|
|
|
|
BAN,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* this is a reserved word, which currently has no meaning
|
|
|
|
|
*/
|
|
|
|
|
KNOCK;
|
2016-02-03 09:42:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-03 13:26:15 +00:00
|
|
|
|
/**
|
|
|
|
|
* Preset values for matrix_api_create_room() calls.
|
|
|
|
|
*/
|
|
|
|
|
public enum RoomPreset {
|
2016-03-18 09:55:22 +00:00
|
|
|
|
/**
|
|
|
|
|
* no preset
|
|
|
|
|
*/
|
|
|
|
|
NONE,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* preset for private rooms
|
|
|
|
|
*/
|
|
|
|
|
PRIVATE,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* same as private rooms, but all users get the same power
|
|
|
|
|
* level as the room creator
|
|
|
|
|
*/
|
|
|
|
|
TRUSTED_PRIVATE,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* preset for public rooms
|
|
|
|
|
*/
|
|
|
|
|
PUBLIC;
|
2016-03-03 13:26:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-03 13:28:22 +00:00
|
|
|
|
/**
|
|
|
|
|
* Visibility values for room creation. Not to be confused with
|
|
|
|
|
* join rules.
|
|
|
|
|
*/
|
|
|
|
|
public enum RoomVisibility {
|
2016-03-18 09:55:22 +00:00
|
|
|
|
/**
|
|
|
|
|
* use a server-assigned value (usually
|
|
|
|
|
* {@link Matrix.RoomVisibility.PRIVATE})
|
|
|
|
|
*/
|
|
|
|
|
DEFAULT,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* make the room visible in the public room list
|
|
|
|
|
*/
|
|
|
|
|
PUBLIC,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* hide the room from the public room list
|
|
|
|
|
*/
|
|
|
|
|
PRIVATE;
|
2016-03-03 13:28:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-07 18:17:32 +00:00
|
|
|
|
/**
|
|
|
|
|
* Room join rules.
|
|
|
|
|
*/
|
|
|
|
|
public enum JoinRules {
|
2016-03-18 09:55:22 +00:00
|
|
|
|
/**
|
|
|
|
|
* a value unknown to this library
|
|
|
|
|
*/
|
|
|
|
|
UNKNOWN,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* anyone can join
|
|
|
|
|
*/
|
|
|
|
|
PUBLIC,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* users may join upon invite
|
|
|
|
|
*/
|
|
|
|
|
INVITE,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* reserved word, not usable yet
|
|
|
|
|
*/
|
|
|
|
|
PRIVATE,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* reserved word, not usable yet
|
|
|
|
|
*/
|
|
|
|
|
KNOCK;
|
2016-03-07 18:17:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-18 09:55:22 +00:00
|
|
|
|
/**
|
|
|
|
|
* Search ordering.
|
|
|
|
|
*/
|
2016-02-29 13:45:14 +00:00
|
|
|
|
public enum SearchOrder {
|
2016-03-18 09:55:22 +00:00
|
|
|
|
/**
|
|
|
|
|
* order messages as they arrived
|
|
|
|
|
*/
|
2016-02-29 13:45:14 +00:00
|
|
|
|
RECENT,
|
2016-03-18 09:55:22 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* order messages by relevance
|
|
|
|
|
*/
|
|
|
|
|
RANK;
|
2016-02-29 13:45:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-18 09:55:22 +00:00
|
|
|
|
/**
|
|
|
|
|
* Search keys.
|
|
|
|
|
*/
|
2016-02-29 13:45:14 +00:00
|
|
|
|
public enum SearchKey {
|
2016-03-18 09:55:22 +00:00
|
|
|
|
/**
|
|
|
|
|
* search in the body of a message
|
|
|
|
|
*/
|
2016-02-29 13:45:14 +00:00
|
|
|
|
CONTENT_BODY,
|
2016-03-18 09:55:22 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* search in the name of rooms
|
|
|
|
|
*/
|
2016-02-29 13:45:14 +00:00
|
|
|
|
CONTENT_NAME,
|
2016-03-18 09:55:22 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* search in the topic of rooms
|
|
|
|
|
*/
|
|
|
|
|
CONTENT_TOPIC;
|
2016-02-29 13:45:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-18 09:55:22 +00:00
|
|
|
|
/**
|
|
|
|
|
* Search grouping
|
|
|
|
|
*
|
|
|
|
|
* The client can request that the results are returned along with
|
|
|
|
|
* grouping information, e.g. grouped by room_id. In this case the
|
|
|
|
|
* response will contain a group entry for each distinct value of
|
|
|
|
|
* room_id. Each group entry contains at least a list of the
|
|
|
|
|
* event_ids that are in that group, as well as potentially other
|
|
|
|
|
* metadata about the group.
|
|
|
|
|
*/
|
2016-02-29 13:45:14 +00:00
|
|
|
|
public enum SearchGroupBy {
|
2016-03-18 09:55:22 +00:00
|
|
|
|
/**
|
|
|
|
|
* no grouping
|
|
|
|
|
*/
|
|
|
|
|
NONE,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* group by room ID
|
|
|
|
|
*/
|
2016-02-29 13:45:14 +00:00
|
|
|
|
ROOM_ID,
|
2016-03-18 09:55:22 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* group by sender
|
|
|
|
|
*/
|
2016-03-17 16:02:08 +00:00
|
|
|
|
SENDER;
|
2016-02-29 13:45:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-18 09:55:22 +00:00
|
|
|
|
/**
|
|
|
|
|
* Room history visibility
|
|
|
|
|
*/
|
2016-03-07 15:24:45 +00:00
|
|
|
|
public enum HistoryVisibility {
|
2016-03-18 09:55:22 +00:00
|
|
|
|
/**
|
|
|
|
|
* represents a value unknown to this library
|
|
|
|
|
*/
|
|
|
|
|
UNKNOWN,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* only room members can see the room history, and only what
|
|
|
|
|
* happened after they got an invitation
|
|
|
|
|
*/
|
|
|
|
|
INVITED,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* only room members can see the room history, and only what
|
|
|
|
|
* happened after they joined
|
|
|
|
|
*/
|
|
|
|
|
JOINED,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* only room members can see the room history, but they see
|
|
|
|
|
* all of it
|
|
|
|
|
*/
|
|
|
|
|
SHARED,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* anyone can see the room history
|
|
|
|
|
*/
|
|
|
|
|
WORLD_READABLE;
|
2016-03-07 15:24:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-18 09:55:22 +00:00
|
|
|
|
/**
|
|
|
|
|
* Room guest access
|
|
|
|
|
*/
|
2016-03-08 18:17:57 +00:00
|
|
|
|
public enum GuestAccess {
|
2016-03-18 09:55:22 +00:00
|
|
|
|
/**
|
|
|
|
|
* represents a value unknown to this library
|
|
|
|
|
*/
|
|
|
|
|
UNKNOWN,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* guest users are allowed to access the room
|
|
|
|
|
*/
|
|
|
|
|
CAN_JOIN,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* guest users are not allowed to access the room
|
|
|
|
|
*/
|
|
|
|
|
FORBIDDEN;
|
2016-03-08 18:17:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-18 09:55:22 +00:00
|
|
|
|
/**
|
|
|
|
|
* Call offer types
|
|
|
|
|
*/
|
2016-03-09 08:26:53 +00:00
|
|
|
|
public enum CallOfferType {
|
2016-03-18 09:55:22 +00:00
|
|
|
|
/**
|
|
|
|
|
* represents a value unknown to this library
|
|
|
|
|
*/
|
|
|
|
|
UNKNOWN,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* call offer
|
|
|
|
|
*/
|
|
|
|
|
OFFER;
|
2016-03-09 08:26:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-18 09:55:22 +00:00
|
|
|
|
/**
|
|
|
|
|
* Call answer types
|
|
|
|
|
*/
|
2016-03-09 09:31:26 +00:00
|
|
|
|
public enum CallAnswerType {
|
2016-03-18 09:55:22 +00:00
|
|
|
|
/**
|
|
|
|
|
* represents a value unknown to this library
|
|
|
|
|
*/
|
|
|
|
|
UNKNOWN,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* call answer
|
|
|
|
|
*/
|
|
|
|
|
ANSWER;
|
2016-03-09 09:31:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-10 16:56:19 +00:00
|
|
|
|
/**
|
|
|
|
|
* Information about the file referred to in a URL.
|
|
|
|
|
*/
|
|
|
|
|
public struct FileInfo {
|
|
|
|
|
int? size;
|
|
|
|
|
string? mimetype;
|
|
|
|
|
|
|
|
|
|
public void
|
|
|
|
|
set_from_json(Json.Node json_data)
|
|
|
|
|
{
|
|
|
|
|
size = null;
|
|
|
|
|
mimetype = null;
|
|
|
|
|
|
|
|
|
|
var root = json_data.get_object();
|
|
|
|
|
Json.Node? node;
|
|
|
|
|
|
|
|
|
|
if ((node = root.get_member("size")) != null) {
|
|
|
|
|
size = (int)node.get_int();
|
|
|
|
|
} else if (Config.DEBUG) {
|
|
|
|
|
warning("size is missing from a FileInfo");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((node = root.get_member("mimetype")) != null) {
|
|
|
|
|
mimetype = node.get_string();
|
|
|
|
|
} else if (Config.DEBUG) {
|
|
|
|
|
warning("mimetype is missing from a FileInfo");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Json.Node
|
|
|
|
|
get_json_node()
|
|
|
|
|
throws Matrix.Error
|
|
|
|
|
{
|
|
|
|
|
if ((size == null)
|
|
|
|
|
|| (mimetype == null)) {
|
|
|
|
|
throw new Matrix.Error.INCOMPLETE(
|
|
|
|
|
"Won't generate a FileInfo without all fields set.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var node = new Json.Node(Json.NodeType.OBJECT);
|
|
|
|
|
var obj = new Json.Object();
|
|
|
|
|
node.set_object(obj);
|
|
|
|
|
|
|
|
|
|
obj.set_int_member("size", size);
|
|
|
|
|
obj.set_string_member("mimetype", mimetype);
|
|
|
|
|
|
|
|
|
|
return node;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-08 16:02:29 +00:00
|
|
|
|
public struct ImageInfo {
|
|
|
|
|
int? size;
|
|
|
|
|
int? height;
|
|
|
|
|
int? width;
|
|
|
|
|
string? mimetype;
|
|
|
|
|
|
2016-03-10 16:46:16 +00:00
|
|
|
|
public void
|
|
|
|
|
set_from_json(Json.Node json_data)
|
|
|
|
|
{
|
|
|
|
|
size = null;
|
|
|
|
|
mimetype = null;
|
|
|
|
|
height = null;
|
|
|
|
|
width = null;
|
|
|
|
|
|
|
|
|
|
var root = json_data.get_object();
|
|
|
|
|
Json.Node? node;
|
|
|
|
|
|
|
|
|
|
if ((node = root.get_member("w")) != null) {
|
|
|
|
|
width = (int)node.get_int();
|
|
|
|
|
} else if (Config.DEBUG) {
|
|
|
|
|
warning("w is missing from an ImageInfo");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((node = root.get_member("h")) != null) {
|
|
|
|
|
height = (int)node.get_int();
|
|
|
|
|
} else if (Config.DEBUG) {
|
|
|
|
|
warning("h is missing from an ImageInfo");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((node = root.get_member("size")) != null) {
|
|
|
|
|
size = (int)node.get_int();
|
|
|
|
|
} else if (Config.DEBUG) {
|
|
|
|
|
warning("size is missing from an ImageInfo");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((node = root.get_member("mimetype")) != null) {
|
|
|
|
|
mimetype = node.get_string();
|
|
|
|
|
} else if (Config.DEBUG) {
|
|
|
|
|
warning("mimetype is missing from an ImageInfo");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-08 16:02:29 +00:00
|
|
|
|
public Json.Node
|
|
|
|
|
get_json_node()
|
|
|
|
|
throws Matrix.Error
|
|
|
|
|
{
|
|
|
|
|
if ((size == null)
|
|
|
|
|
|| (height == null)
|
|
|
|
|
|| (width == null)
|
|
|
|
|
|| (mimetype == null)) {
|
|
|
|
|
throw new Matrix.Error.INCOMPLETE(
|
|
|
|
|
"Won't generate an ImageInfo without all fields set.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var node = new Json.Node(Json.NodeType.OBJECT);
|
|
|
|
|
var obj = new Json.Object();
|
|
|
|
|
node.set_object(obj);
|
|
|
|
|
|
|
|
|
|
obj.set_int_member("size", size);
|
|
|
|
|
obj.set_int_member("h", height);
|
|
|
|
|
obj.set_int_member("w", width);
|
|
|
|
|
obj.set_string_member("mimetype", mimetype);
|
|
|
|
|
|
|
|
|
|
return node;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-10 18:25:09 +00:00
|
|
|
|
public struct AudioInfo {
|
|
|
|
|
int? size;
|
|
|
|
|
string? mimetype;
|
|
|
|
|
int? duration;
|
|
|
|
|
|
|
|
|
|
public void
|
|
|
|
|
set_from_json(Json.Node json_data)
|
|
|
|
|
{
|
|
|
|
|
size = null;
|
|
|
|
|
mimetype = null;
|
|
|
|
|
duration = null;
|
|
|
|
|
|
|
|
|
|
var root = json_data.get_object();
|
|
|
|
|
Json.Node? node;
|
|
|
|
|
|
|
|
|
|
if ((node = root.get_member("size")) != null) {
|
|
|
|
|
size = (int)node.get_int();
|
|
|
|
|
} else if (Config.DEBUG) {
|
|
|
|
|
warning("size is missing from an ImageInfo");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((node = root.get_member("mimetype")) != null) {
|
|
|
|
|
mimetype = node.get_string();
|
|
|
|
|
} else if (Config.DEBUG) {
|
|
|
|
|
warning("mimetype is missing from an ImageInfo");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((node = root.get_member("duration")) != null) {
|
|
|
|
|
duration = (int)node.get_int();
|
|
|
|
|
} else if (Config.DEBUG) {
|
|
|
|
|
warning("duration is missing from an ImageInfo");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Json.Node
|
|
|
|
|
get_json_node()
|
|
|
|
|
throws Matrix.Error
|
|
|
|
|
{
|
|
|
|
|
if ((size == null)
|
|
|
|
|
|| (mimetype == null)
|
|
|
|
|
|| (duration == null)) {
|
|
|
|
|
throw new Matrix.Error.INCOMPLETE(
|
|
|
|
|
"Won't generate an ImageInfo without all fields set.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var node = new Json.Node(Json.NodeType.OBJECT);
|
|
|
|
|
var obj = new Json.Object();
|
|
|
|
|
node.set_object(obj);
|
|
|
|
|
|
|
|
|
|
obj.set_int_member("size", size);
|
|
|
|
|
obj.set_string_member("mimetype", mimetype);
|
|
|
|
|
obj.set_int_member("duration", duration);
|
|
|
|
|
|
|
|
|
|
return node;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-10 18:46:01 +00:00
|
|
|
|
public struct VideoInfo {
|
|
|
|
|
int? size;
|
|
|
|
|
string? mimetype;
|
|
|
|
|
int? duration;
|
|
|
|
|
int? width;
|
|
|
|
|
int? height;
|
|
|
|
|
string? thumbnail_url;
|
|
|
|
|
ImageInfo? thumbnail_info;
|
|
|
|
|
|
|
|
|
|
public void
|
|
|
|
|
set_from_json(Json.Node json_data)
|
|
|
|
|
{
|
|
|
|
|
size = null;
|
|
|
|
|
mimetype = null;
|
|
|
|
|
duration = null;
|
|
|
|
|
|
|
|
|
|
var root = json_data.get_object();
|
|
|
|
|
Json.Node? node;
|
|
|
|
|
|
|
|
|
|
if ((node = root.get_member("size")) != null) {
|
|
|
|
|
size = (int)node.get_int();
|
|
|
|
|
} else if (Config.DEBUG) {
|
|
|
|
|
warning("size is missing from an VideoInfo");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((node = root.get_member("mimetype")) != null) {
|
|
|
|
|
mimetype = node.get_string();
|
|
|
|
|
} else if (Config.DEBUG) {
|
|
|
|
|
warning("mimetype is missing from an VideoInfo");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((node = root.get_member("duration")) != null) {
|
|
|
|
|
duration = (int)node.get_int();
|
|
|
|
|
} else if (Config.DEBUG) {
|
|
|
|
|
warning("duration is missing from an VideoInfo");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((node = root.get_member("w")) != null) {
|
|
|
|
|
width = (int)node.get_int();
|
|
|
|
|
} else if (Config.DEBUG) {
|
|
|
|
|
warning("w is missing from a VideoInfo");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((node = root.get_member("h")) != null) {
|
|
|
|
|
height = (int)node.get_int();
|
|
|
|
|
} else if (Config.DEBUG) {
|
|
|
|
|
warning("h is missing from a VideoInfo");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((node = root.get_member("thumbnail_url")) != null) {
|
|
|
|
|
thumbnail_url = node.get_string();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((node = root.get_member("thumbnail_info")) != null) {
|
|
|
|
|
thumbnail_info = ImageInfo();
|
|
|
|
|
thumbnail_info.set_from_json(node);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Json.Node
|
|
|
|
|
get_json_node()
|
|
|
|
|
throws Matrix.Error
|
|
|
|
|
{
|
|
|
|
|
if ((size == null)
|
|
|
|
|
|| (mimetype == null)
|
|
|
|
|
|| (duration == null)
|
|
|
|
|
|| (width == null)
|
|
|
|
|
|| (height == null)
|
|
|
|
|
|| (thumbnail_url == null)
|
|
|
|
|
|| (thumbnail_info == null)) {
|
|
|
|
|
throw new Matrix.Error.INCOMPLETE(
|
|
|
|
|
"Won't generate an ImageInfo without all fields set.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var node = new Json.Node(Json.NodeType.OBJECT);
|
|
|
|
|
var obj = new Json.Object();
|
|
|
|
|
node.set_object(obj);
|
|
|
|
|
|
|
|
|
|
obj.set_int_member("size", size);
|
|
|
|
|
obj.set_string_member("mimetype", mimetype);
|
|
|
|
|
obj.set_int_member("duration", duration);
|
|
|
|
|
obj.set_int_member("w", width);
|
|
|
|
|
obj.set_int_member("h", height);
|
|
|
|
|
obj.set_string_member("thumbnail_url", thumbnail_url);
|
|
|
|
|
obj.set_member("thumbnail_info", thumbnail_info.get_json_node());
|
|
|
|
|
|
|
|
|
|
return node;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-03 13:06:33 +00:00
|
|
|
|
private int?
|
|
|
|
|
_g_enum_nick_to_value(Type enum_type, string nick)
|
|
|
|
|
{
|
|
|
|
|
EnumClass enum_class = (EnumClass)enum_type.class_ref();
|
|
|
|
|
unowned EnumValue? enum_val = enum_class.get_value_by_nick(nick);
|
|
|
|
|
|
|
|
|
|
if (enum_val != null) {
|
|
|
|
|
return enum_val.value;
|
|
|
|
|
} else {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string?
|
2016-03-04 07:58:56 +00:00
|
|
|
|
_g_enum_value_to_nick(Type enum_type,
|
|
|
|
|
int value,
|
|
|
|
|
bool convert_dashes = true)
|
|
|
|
|
{
|
|
|
|
|
EnumClass enum_class = (EnumClass)enum_type.class_ref();
|
|
|
|
|
unowned EnumValue? enum_val = enum_class.get_value(value);
|
|
|
|
|
|
|
|
|
|
if (enum_val != null) {
|
|
|
|
|
var nick = enum_val.value_nick;
|
|
|
|
|
|
|
|
|
|
if (convert_dashes) {
|
|
|
|
|
return nick.replace("-", "_");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nick;
|
|
|
|
|
} else {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|