Start working on the GObject generator for event types

This commit is contained in:
Gergely Polonkai 2016-03-04 17:15:42 +01:00 committed by Gergely Polonkai
parent e93a7675c0
commit 0d024b6885
33 changed files with 1372 additions and 0 deletions

2
.gitignore vendored
View File

@ -58,3 +58,5 @@ Makefile.in
/src/matrix-room-member-event.c
/src/matrix-state-event.c
/src/matrix-room-message-event.c
/src/object-generator

44
schemas/m.call.answer Normal file
View File

@ -0,0 +1,44 @@
{
"type": "object",
"description": "This event is sent by the callee when they wish to answer the call.",
"allOf": [{
"$ref": "core-event-schema/room_event.yaml"
}],
"properties": {
"content": {
"type": "object",
"properties": {
"call_id": {
"type": "string",
"description": "The ID of the call this event relates to."
},
"answer": {
"type": "object",
"title": "Answer",
"description": "The session description object",
"properties": {
"type": {
"type": "string",
"enum": ["answer"],
"description": "The type of session description."
},
"sdp": {
"type": "string",
"description": "The SDP text of the session description."
}
},
"required": ["type", "sdp"]
},
"version": {
"type": "number",
"description": ""
}
},
"required": ["call_id", "answer", "version"]
},
"type": {
"type": "string",
"enum": ["m.call.answer"]
}
}
}

50
schemas/m.call.candidates Normal file
View File

@ -0,0 +1,50 @@
{
"type": "object",
"description": "This event is sent by callers after sending an invite and by the callee after answering. Its purpose is to give the other party additional ICE candidates to try using to communicate.",
"allOf": [{
"$ref": "core-event-schema/room_event.yaml"
}],
"properties": {
"content": {
"type": "object",
"properties": {
"call_id": {
"type": "string",
"description": "The ID of the call this event relates to."
},
"candidates": {
"type": "array",
"description": "Array of objects describing the candidates.",
"items": {
"type": "object",
"title": "Candidate",
"properties": {
"sdpMid": {
"type": "string",
"description": "The SDP media type this candidate is intended for."
},
"sdpMLineIndex": {
"type": "number",
"description": "The index of the SDP 'm' line this candidate is intended for."
},
"candidate": {
"type": "string",
"description": "The SDP 'a' line of the candidate."
}
},
"required": ["candidate", "sdpMLineIndex", "sdpMid"]
}
},
"version": {
"type": "integer",
"description": "The version of the VoIP specification this messages adheres to. This specification is version 0."
}
},
"required": ["call_id", "candidates", "version"]
},
"type": {
"type": "string",
"enum": ["m.call.candidates"]
}
}
}

27
schemas/m.call.hangup Normal file
View File

@ -0,0 +1,27 @@
{
"type": "object",
"description": "Sent by either party to signal their termination of the call. This can be sent either once the call has has been established or before to abort the call.",
"allOf": [{
"$ref": "core-event-schema/room_event.yaml"
}],
"properties": {
"content": {
"type": "object",
"properties": {
"call_id": {
"type": "string",
"description": "The ID of the call this event relates to."
},
"version": {
"type": "integer",
"description": "The version of the VoIP specification this message adheres to. This specification is version 0."
}
},
"required": ["call_id", "version"]
},
"type": {
"type": "string",
"enum": ["m.call.hangup"]
}
}
}

48
schemas/m.call.invite Normal file
View File

@ -0,0 +1,48 @@
{
"type": "object",
"description": "This event is sent by the caller when they wish to establish a call.",
"allOf": [{
"$ref": "core-event-schema/room_event.yaml"
}],
"properties": {
"content": {
"type": "object",
"properties": {
"call_id": {
"type": "string",
"description": "A unique identifer for the call."
},
"offer": {
"type": "object",
"title": "Offer",
"description": "The session description object",
"properties": {
"type": {
"type": "string",
"enum": ["offer"],
"description": "The type of session description."
},
"sdp": {
"type": "string",
"description": "The SDP text of the session description."
}
},
"required": ["type", "sdp"]
},
"version": {
"type": "integer",
"description": "The version of the VoIP specification this message adheres to. This specification is version 0."
},
"lifetime": {
"type": "integer",
"description": "The time in milliseconds that the invite is valid for. Once the invite age exceeds this value, clients should discard it. They should also no longer show the call as awaiting an answer in the UI."
}
},
"required": ["call_id", "offer", "version", "lifetime"]
},
"type": {
"type": "string",
"enum": ["m.call.invite"]
}
}
}

42
schemas/m.presence Normal file
View File

@ -0,0 +1,42 @@
{
"type": "object",
"title": "Presence Event",
"description": "Informs the client of a user's presence state change.",
"properties": {
"content": {
"type": "object",
"properties": {
"avatar_url": {
"type": "string",
"description": "The current avatar URL for this user, if any."
},
"displayname": {
"type": "string",
"description": "The current display name for this user, if any."
},
"last_active_ago": {
"type": "number",
"description": "The last time since this used performed some action, in milliseconds."
},
"presence": {
"type": "string",
"description": "The presence state for this user.",
"enum": ["online", "offline", "unavailable", "free_for_chat", "hidden"]
},
"user_id": {
"type": "string",
"description": "The user's ID."
}
},
"required": ["presence", "user_id"]
},
"type": {
"type": "string",
"enum": ["m.presence"]
},
"event_id": {
"type": "string"
}
},
"required": ["event_id", "type", "content"]
}

48
schemas/m.receipt Normal file
View File

@ -0,0 +1,48 @@
{
"type": "object",
"title": "Receipt Event",
"description": "Informs the client of new receipts.",
"properties": {
"content": {
"type": "object",
"patternProperties": {
"^\\$": {
"type": "object",
"x-pattern": "$EVENT_ID",
"title": "Receipts",
"description": "The mapping of event ID to a collection of receipts for this event ID. The event ID is the ID of the event being acknowledged and *not* an ID for the receipt itself.",
"properties": {
"m.read": {
"type": "object",
"title": "Users",
"description": "A collection of users who have sent ``m.read`` receipts for this event.",
"patternProperties": {
"^@": {
"type": "object",
"title": "Receipt",
"description": "The mapping of user ID to receipt. The user ID is the entity who sent this receipt.",
"x-pattern": "$USER_ID",
"properties": {
"ts": {
"type": "number",
"description": "The timestamp the receipt was sent at."
}
}
}
}
}
}
}
},
"additionalProperties": false
},
"type": {
"type": "string",
"enum": ["m.receipt"]
},
"room_id": {
"type": "string"
}
},
"required": ["room_id", "type", "content"]
}

31
schemas/m.room.aliases Normal file
View File

@ -0,0 +1,31 @@
{
"type": "object",
"title": "Informs the room about what room aliases it has been given.",
"description": "This event is sent by a homeserver directly to inform of changes to the list of aliases it knows about for that room. The ``state_key`` for this event is set to the homeserver which owns the room alias. The entire set of known aliases for the room is the union of all the ``m.room.aliases`` events, one for each homeserver. Clients **should** check the validity of any room alias given in this list before presenting it to the user as trusted fact. The lists given by this event should be considered simply as advice on which aliases might exist, for which the client can perform the lookup to confirm whether it receives the correct room ID.",
"allOf": [{
"$ref": "core-event-schema/state_event.yaml"
}],
"properties": {
"content": {
"type": "object",
"properties": {
"aliases": {
"type": "array",
"description": "A list of room aliases.",
"items": {
"type": "string"
}
}
},
"required": ["aliases"]
},
"state_key": {
"type": "string",
"description": "The homeserver domain which owns these room aliases."
},
"type": {
"type": "string",
"enum": ["m.room.aliases"]
}
}
}

64
schemas/m.room.avatar Normal file
View File

@ -0,0 +1,64 @@
{
"title": "RoomAvatar",
"description": "A picture that is associated with the room. This can be displayed alongside the room information.",
"type": "object",
"allOf": [{
"$ref": "core-event-schema/state_event.yaml"
}],
"properties": {
"content": {
"type": "object",
"properties": {
"url": {
"type": "string",
"description": "The URL to the image."
},
"thumbnail_url": {
"type": "string",
"description": "The URL to the thumbnail of the image."
},
"thumbnail_info": {
"type": "object",
"title": "ImageInfo",
"description": "Metadata about the image referred to in ``thumbnail_url``.",
"allOf": [{
"$ref": "core-event-schema/msgtype_infos/image_info.yaml"
}]
},
"info": {
"type": "object",
"title": "ImageInfo",
"description": "Metadata about the image referred to in ``url``.",
"properties": {
"size": {
"type": "integer",
"description": "Size of the image in bytes."
},
"w": {
"type": "integer",
"description": "The width of the image in pixels."
},
"h": {
"type": "integer",
"description": "The height of the image in pixels."
},
"mimetype": {
"type": "string",
"description": "The mimetype of the image, e.g. ``image/jpeg``."
}
}
}
},
"required": ["url"]
},
"state_key": {
"type": "string",
"description": "A zero-length string.",
"pattern": "^$"
},
"type": {
"type": "string",
"enum": ["m.room.avatar"]
}
}
}

View File

@ -0,0 +1,28 @@
{
"type": "object",
"title": "Informs the room as to which alias is the canonical one.",
"description": "This event is used to inform the room about which alias should be considered the canonical one. This could be for display purposes or as suggestion to users which alias to use to advertise the room.",
"allOf": [{
"$ref": "core-event-schema/state_event.yaml"
}],
"properties": {
"content": {
"type": "object",
"properties": {
"alias": {
"type": "string",
"description": "The canonical alias."
}
}
},
"state_key": {
"type": "string",
"description": "A zero-length string.",
"pattern": "^$"
},
"type": {
"type": "string",
"enum": ["m.room.canonical_alias"]
}
}
}

33
schemas/m.room.create Normal file
View File

@ -0,0 +1,33 @@
{
"type": "object",
"title": "The first event in the room.",
"description": "This is the first event in a room and cannot be changed. It acts as the root of all other events.",
"allOf": [{
"$ref": "core-event-schema/state_event.yaml"
}],
"properties": {
"content": {
"type": "object",
"properties": {
"creator": {
"type": "string",
"description": "The ``user_id`` of the room creator. This is set by the homeserver."
},
"m.federate": {
"type": "boolean",
"description": "Whether users on other servers can join this room. Defaults to ``true`` if key does not exist."
}
},
"required": ["creator"]
},
"state_key": {
"type": "string",
"description": "A zero-length string.",
"pattern": "^$"
},
"type": {
"type": "string",
"enum": ["m.room.create"]
}
}
}

View File

@ -0,0 +1,30 @@
{
"type": "object",
"title": "Controls whether guest users are allowed to join rooms.",
"description": "This event controls whether guest users are allowed to join rooms. If this event is absent, servers should act as if it is present and has the guest_access value \"forbidden\".",
"allOf": [{
"$ref": "core-event-schema/state_event.yaml"
}],
"properties": {
"content": {
"type": "object",
"properties": {
"guest_access": {
"type": "string",
"description": "Whether guests can join the room.",
"enum": ["can_join", "forbidden"]
}
},
"required": ["guest_access"]
},
"state_key": {
"type": "string",
"description": "A zero-length string.",
"pattern": "^$"
},
"type": {
"type": "string",
"enum": ["m.room.guest_access"]
}
}
}

View File

@ -0,0 +1,30 @@
{
"type": "object",
"title": "Controls visibility of history.",
"description": "This event controls whether a user can see the events that happened in a room from before they joined.",
"allOf": [{
"$ref": "core-event-schema/state_event.yaml"
}],
"properties": {
"content": {
"type": "object",
"properties": {
"history_visibility": {
"type": "string",
"description": "Who can see the room history.",
"enum": ["invited","joined","shared","world_readable"]
}
},
"required": ["history_visibility"]
},
"state_key": {
"type": "string",
"description": "A zero-length string.",
"pattern": "^$"
},
"type": {
"type": "string",
"enum": ["m.room.history_visibility"]
}
}
}

30
schemas/m.room.join_rules Normal file
View File

@ -0,0 +1,30 @@
{
"type": "object",
"title": "Describes how users are allowed to join the room.",
"description": "A room may be ``public`` meaning anyone can join the room without any prior action. Alternatively, it can be ``invite`` meaning that a user who wishes to join the room must first receive an invite to the room from someone already inside of the room. Currently, ``knock`` and ``private`` are reserved keywords which are not implemented.",
"allOf": [{
"$ref": "core-event-schema/state_event.yaml"
}],
"properties": {
"content": {
"type": "object",
"properties": {
"join_rule": {
"type": "string",
"description": "The type of rules used for users wishing to join this room.",
"enum": ["public","knock","invite","private"]
}
},
"required": ["join_rule"]
},
"state_key": {
"type": "string",
"description": "A zero-length string.",
"pattern": "^$"
},
"type": {
"type": "string",
"enum": ["m.room.join_rules"]
}
}
}

96
schemas/m.room.member Normal file
View File

@ -0,0 +1,96 @@
{
"type": "object",
"title": "The current membership state of a user in the room.",
"description": "Adjusts the membership state for a user in a room. It is preferable to use the membership APIs (``/rooms/<room id>/invite`` etc) when performing membership actions rather than adjusting the state directly as there are a restricted set of valid transformations. For example, user A cannot force user B to join a room, and trying to force this state change directly will fail. \n\nThe following membership states are specified:\n\n- ``invite`` - 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.\n\n- ``join`` - The user has joined the room (possibly after accepting an invite), and may participate in it.\n\n- ``leave`` - The user was once joined to the room, but has since left (possibly by choice, or possibly by being kicked).\n\n- ``ban`` - 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 ``ban``).\n\n- ``knock`` - This is a reserved word, which currently has no meaning.\n\nThe ``third_party_invite`` property will be set if this invite is an ``invite`` event and is the successor of an ``m.room.third_party_invite`` event, and absent otherwise.\n\nThis event may also include an ``invite_room_state`` key **outside the** ``content`` **key**. If present, this contains an array of ``StrippedState`` Events. These events provide information on a few select state events such as the room name.",
"allOf": [{
"$ref": "core-event-schema/state_event.yaml"
}],
"properties": {
"content": {
"type": "object",
"title": "EventContent",
"properties": {
"membership": {
"type": "string",
"description": "The membership state of the user.",
"enum": ["invite","join","knock","leave","ban"]
},
"avatar_url": {
"type": "string",
"description": "The avatar URL for this user, if any. This is added by the homeserver."
},
"displayname": {
"type": ["string", "null"],
"description": "The display name for this user, if any. This is added by the homeserver."
},
"third_party_invite": {
"type": "object",
"title": "Invite",
"properties": {
"display_name": {
"type": "string",
"description": "A name which can be displayed to represent the user instead of their third party identifier"
},
"signed": {
"type": "object",
"title": "signed",
"description": "A block of content which has been signed, which servers can use to verify the event. Clients should ignore this.",
"properties": {
"mxid": {
"type": "string",
"description": "The invited matrix user ID. Must be equal to the user_id property of the event."
},
"token": {
"type": "string",
"description": "The token property of the containing third_party_invite object."
},
"signatures": {
"type": "object",
"description": "A single signature from the verifying server, in the format specified by the Signing Events section of the server-server API.",
"title": "Signatures"
}
},
"required": ["mxid", "signatures", "token"]
}
},
"required": ["display_name", "signed"]
}
},
"required": ["membership"]
},
"state_key": {
"type": "string",
"description": "The ``user_id`` this membership event relates to."
},
"type": {
"type": "string",
"enum": ["m.room.member"]
},
"invite_room_state": {
"type": "array",
"description": "A subset of the state of the room at the time of the invite, if ``membership`` is ``invite``",
"items": {
"type": "object",
"title": "StrippedState",
"description": "A stripped down state event, with only the ``type``, ``state_key`` and ``content`` keys.",
"required": ["type", "state_key", "content"],
"properties": {
"type": {
"type": "string",
"description": "The ``type`` for the event.",
"enum": ["m.room.join_rules", "m.room.canonical_alias", "m.room.avatar", "m.room.name"]
},
"state_key": {
"type": "string",
"description": "The ``state_key`` for the event."
},
"content": {
"title": "EventContent",
"type": "object",
"description": "The ``content`` for the event."
}
}
}
}
}
}

28
schemas/m.room.message Normal file
View File

@ -0,0 +1,28 @@
{
"type": "object",
"title": "Message",
"description": "This event is used when sending messages in a room. Messages are not limited to be text. The ``msgtype`` key outlines the type of message, e.g. text, audio, image, video, etc. The ``body`` key is text and MUST be used with every kind of ``msgtype`` as a fallback mechanism for when a client cannot render a message. This allows clients to display *something* even if it is just plain text.",
"allOf": [{
"$ref": "core-event-schema/room_event.yaml"
}],
"properties": {
"content": {
"type": "object",
"properties": {
"msgtype": {
"type": "string",
"description": "The type of message, e.g. ``m.image``, ``m.text``"
},
"body": {
"type": "string",
"description": "The textual representation of this message."
}
},
"required": ["msgtype", "body"]
},
"type": {
"type": "string",
"enum": ["m.room.message"]
}
}
}

View File

@ -0,0 +1,51 @@
{
"type": "object",
"title": "AudioMessage",
"description": "This message represents a single audio clip.",
"allOf": [{
"$ref": "core-event-schema/room_event.yaml"
}],
"properties": {
"content": {
"type": "object",
"properties": {
"msgtype": {
"type": "string",
"enum": ["m.audio"]
},
"body": {
"type": "string",
"description": "A description of the audio e.g. 'Bee Gees - Stayin' Alive', or some kind of content description for accessibility e.g. 'audio attachment'."
},
"url": {
"type": "string",
"description": "The URL to the audio clip."
},
"info": {
"type": "object",
"title": "AudioInfo",
"description": "Metadata for the audio clip referred to in ``url``.",
"properties": {
"mimetype": {
"type": "string",
"description": "The mimetype of the audio e.g. ``audio/aac``."
},
"size": {
"type": "integer",
"description": "The size of the audio clip in bytes."
},
"duration": {
"type": "integer",
"description": "The duration of the audio in milliseconds."
}
}
}
},
"required": ["msgtype", "body", "url"]
},
"type": {
"type": "string",
"enum": ["m.room.message"]
}
}
}

View File

@ -0,0 +1,28 @@
{
"type": "object",
"title": "EmoteMessage",
"description": "This message is similar to ``m.text`` except that the sender is 'performing' the action contained in the ``body`` key, similar to ``/me`` in IRC. This message should be prefixed by the name of the sender. This message could also be represented in a different colour to distinguish it from regular ``m.text`` messages.",
"allOf": [{
"$ref": "core-event-schema/room_event.yaml"
}],
"properties": {
"content": {
"type": "object",
"properties": {
"msgtype": {
"type": "string",
"enum": ["m.emote"]
},
"body": {
"type": "string",
"description": "The emote action to perform."
}
},
"required": ["msgtype", "body"]
},
"type": {
"type": "string",
"enum": ["m.room.message"]
}
}
}

View File

@ -0,0 +1,63 @@
{
"type": "object",
"title": "FileMessage",
"description": "This message represents a generic file.",
"allOf": [{
"$ref": "core-event-schema/room_event.yaml"
}],
"properties": {
"content": {
"type": "object",
"properties": {
"msgtype": {
"type": "string",
"enum": ["m.file"]
},
"filename": {
"type": "string",
"description": "The original filename of the uploaded file."
},
"body": {
"type": "string",
"description": "A human-readable description of the file. This is recommended to be the filename of the original upload."
},
"url": {
"type": "string",
"description": "The URL to the file."
},
"info": {
"type": "object",
"title": "FileInfo",
"description": "Information about the file referred to in ``url``.",
"properties": {
"size": {
"type": "integer",
"description": "The size of the file in bytes."
},
"mimetype": {
"type": "string",
"description": "The mimetype of the file e.g. ``application/msword``."
}
}
},
"thumbnail_url": {
"type": "string",
"description": "The URL to the thumbnail of the file."
},
"thumbnail_info": {
"type": "object",
"title": "ImageInfo",
"description": "Metadata about the image referred to in ``thumbnail_url``.",
"allOf": [{
"$ref": "core-event-schema/msgtype_infos/image_info.yaml"
}]
}
},
"required": ["msgtype", "body", "url", "filename"]
},
"type": {
"type": "string",
"enum": ["m.room.message"]
}
}
}

View File

@ -0,0 +1,67 @@
{
"type": "object",
"title": "ImageMessage",
"description": "This message represents a single image and an optional thumbnail.",
"allOf": [{
"$ref": "core-event-schema/room_event.yaml"
}],
"properties": {
"content": {
"type": "object",
"properties": {
"msgtype": {
"type": "string",
"enum": ["m.image"]
},
"body": {
"type": "string",
"description": "A textual representation of the image. This could be the alt text of the image, the filename of the image, or some kind of content description for accessibility e.g. 'image attachment'."
},
"url": {
"type": "string",
"description": "The URL to the image."
},
"thumbnail_url": {
"type": "string",
"description": "The URL to the thumbnail of the image."
},
"thumbnail_info": {
"type": "object",
"title": "ImageInfo",
"description": "Metadata about the image referred to in ``thumbnail_url``.",
"allOf": [{
"$ref": "core-event-schema/msgtype_infos/image_info.yaml"
}]
},
"info": {
"type": "object",
"title": "ImageInfo",
"description": "Metadata about the image referred to in ``url``.",
"properties": {
"size": {
"type": "integer",
"description": "Size of the image in bytes."
},
"w": {
"type": "integer",
"description": "The width of the image in pixels."
},
"h": {
"type": "integer",
"description": "The height of the image in pixels."
},
"mimetype": {
"type": "string",
"description": "The mimetype of the image, e.g. ``image/jpeg``."
}
}
}
},
"required": ["msgtype", "body", "url"]
},
"type": {
"type": "string",
"enum": ["m.room.message"]
}
}
}

View File

@ -0,0 +1,43 @@
{
"type": "object",
"title": "LocationMessage",
"description": "This message represents a real-world location.",
"allOf": [{
"$ref": "core-event-schema/room_event.yaml"
}],
"properties": {
"content": {
"type": "object",
"properties": {
"msgtype": {
"type": "string",
"enum": ["m.location"]
},
"body": {
"type": "string",
"description": "A description of the location e.g. 'Big Ben, London, UK', or some kind of content description for accessibility e.g. 'location attachment'."
},
"geo_uri": {
"type": "string",
"description": "A geo URI representing this location."
},
"thumbnail_url": {
"type": "string",
"description": "The URL to a thumbnail of the location being represented."
},
"thumbnail_info": {
"type": "object",
"title": "ImageInfo",
"allOf": [{
"$ref": "core-event-schema/msgtype_infos/image_info.yaml"
}]
}
},
"required": ["msgtype", "body", "geo_uri"]
},
"type": {
"type": "string",
"enum": ["m.room.message"]
}
}
}

View File

@ -0,0 +1,28 @@
{
"type": "object",
"title": "NoticeMessage",
"description": "A m.notice message should be considered similar to a plain m.text message except that clients should visually distinguish it in some way. It is intended to be used by automated clients, such as bots, bridges, and other entities, rather than humans. Additionally, such automated agents which watch a room for messages and respond to them ought to ignore m.notice messages. This helps to prevent infinite-loop situations where two automated clients continuously exchange messages, as each responds to the other.",
"allOf": [{
"$ref": "core-event-schema/room_event.yaml"
}],
"properties": {
"content": {
"type": "object",
"properties": {
"msgtype": {
"type": "string",
"enum": ["m.notice"]
},
"body": {
"type": "string",
"description": "The notice text to send."
}
},
"required": ["msgtype", "body"]
},
"type": {
"type": "string",
"enum": ["m.room.message"]
}
}
}

View File

@ -0,0 +1,28 @@
{
"type": "object",
"title": "TextMessage",
"description": "This message is the most basic message and is used to represent text.",
"allOf": [{
"$ref": "core-event-schema/room_event.yaml"
}],
"properties": {
"content": {
"type": "object",
"properties": {
"msgtype": {
"type": "string",
"enum": ["m.text"]
},
"body": {
"type": "string",
"description": "The body of the message."
}
},
"required": ["msgtype", "body"]
},
"type": {
"type": "string",
"enum": ["m.room.message"]
}
}
}

View File

@ -0,0 +1,70 @@
{
"type": "object",
"title": "VideoMessage",
"description": "This message represents a single video clip.",
"allOf": [{
"$ref": "core-event-schema/room_event.yaml"
}],
"properties": {
"content": {
"type": "object",
"properties": {
"msgtype": {
"type": "string",
"enum": ["m.video"]
},
"body": {
"type": "string",
"description": "A description of the video e.g. 'Gangnam style', or some kind of content description for accessibility e.g. 'video attachment'."
},
"url": {
"type": "string",
"description": "The URL to the video clip."
},
"info": {
"type": "object",
"title": "VideoInfo",
"description": "Metadata about the video clip referred to in ``url``.",
"properties": {
"mimetype": {
"type": "string",
"description": "The mimetype of the video e.g. ``video/mp4``."
},
"size": {
"type": "integer",
"description": "The size of the video in bytes."
},
"duration": {
"type": "integer",
"description": "The duration of the video in milliseconds."
},
"w": {
"type": "integer",
"description": "The width of the video in pixels."
},
"h": {
"type": "integer",
"description": "The height of the video in pixels."
},
"thumbnail_url": {
"type": "string",
"description": "The URL to a thumbnail of the video clip."
},
"thumbnail_info": {
"type": "object",
"title": "ImageInfo",
"allOf": [{
"$ref": "core-event-schema/msgtype_infos/image_info.yaml"
}]
}
}
}
},
"required": ["msgtype", "body", "url"]
},
"type": {
"type": "string",
"enum": ["m.room.message"]
}
}
}

View File

@ -0,0 +1,29 @@
{
"type": "object",
"title": "MessageFeedback",
"description": "**NB: Usage of this event is discouraged in favour of the** `receipts module`_. **Most clients will not recognise this event.** Feedback events are events sent to acknowledge a message in some way. There are two supported acknowledgements: ``delivered`` (sent when the event has been received) and ``read`` (sent when the event has been observed by the end-user). The ``target_event_id`` should reference the ``m.room.message`` event being acknowledged.",
"allOf": [{
"$ref": "core-event-schema/room_event.yaml"
}],
"properties": {
"content": {
"type": "object",
"properties": {
"type": {
"type": "string",
"description": "The type of feedback.",
"enum": ["delivered", "read"]
},
"target_event_id": {
"type": "string",
"description": "The event that this feedback is related to."
}
},
"required": ["type", "target_event_id"]
},
"type": {
"type": "string",
"enum": ["m.room.message.feedback"]
}
}
}

29
schemas/m.room.name Normal file
View File

@ -0,0 +1,29 @@
{
"title": "RoomName",
"description": "A room has an opaque room ID which is not human-friendly to read. A room alias is human-friendly, but not all rooms have room aliases. The room name is a human-friendly string designed to be displayed to the end-user. The room name is not unique, as multiple rooms can have the same room name set. The room name can also be set when creating a room using ``/createRoom`` with the ``name`` key.",
"type": "object",
"allOf": [{
"$ref": "core-event-schema/state_event.yaml"
}],
"properties": {
"content": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "The name of the room. This MUST NOT exceed 255 bytes."
}
},
"required": ["name"]
},
"state_key": {
"type": "string",
"description": "A zero-length string.",
"pattern": "^$"
},
"type": {
"type": "string",
"enum": ["m.room.name"]
}
}
}

View File

@ -0,0 +1,66 @@
{
"type": "object",
"title": "Defines the power levels (privileges) of users in the room.",
"description": "This event specifies the minimum level a user must have in order to perform a certain action. It also specifies the levels of each user in the room. If a ``user_id`` is in the ``users`` list, then that ``user_id`` has the associated power level. Otherwise they have the default level ``users_default``. If ``users_default`` is not supplied, it is assumed to be 0. The level required to send a certain event is governed by ``events``, ``state_default`` and ``events_default``. If an event type is specified in ``events``, then the user must have at least the level specified in order to send that event. If the event type is not supplied, it defaults to ``events_default`` for Message Events and ``state_default`` for State Events.",
"allOf": [{
"$ref": "core-event-schema/state_event.yaml"
}],
"properties": {
"content": {
"type": "object",
"properties": {
"ban": {
"type": "number",
"description": "The level required to ban a user."
},
"events_default": {
"type": "number",
"description": "The default level required to send message events. Can be overridden by the ``events`` key."
},
"kick": {
"type": "number",
"description": "The level required to kick a user."
},
"redact": {
"type": "number",
"description": "The level required to redact an event."
},
"state_default": {
"type": "number",
"description": "The default level required to send state events. Can be overridden by the ``events`` key."
},
"users_default": {
"type": "number",
"description": "The default power level for every user in the room, unless their ``user_id`` is mentioned in the ``users`` key."
},
"events": {
"type": "object",
"title": "Event power levels",
"description": "The level required to send specific event types. This is a mapping from event type to power level required.",
"additionalProperties": {
"type": "number"
}
},
"users": {
"type": "object",
"title": "User power levels",
"description": "The power levels for specific users. This is a mapping from ``user_id`` to power level for that user.",
"additionalProperties": {
"type": "number"
}
}
},
"required": ["ban","events","events_default","kick","redact",
"state_default","users"]
},
"state_key": {
"type": "string",
"description": "A zero-length string.",
"pattern": "^$"
},
"type": {
"type": "string",
"enum": ["m.room.power_levels"]
}
}
}

28
schemas/m.room.redaction Normal file
View File

@ -0,0 +1,28 @@
{
"type": "object",
"title": "Redaction",
"description": "Events can be redacted by either room or server admins. Redacting an event means that all keys not required by the protocol are stripped off, allowing admins to remove offensive or illegal content that may have been attached to any event. This cannot be undone, allowing server owners to physically delete the offending data. There is also a concept of a moderator hiding a message event, which can be undone, but cannot be applied to state events. The event that has been redacted is specified in the ``redacts`` event level key.",
"allOf": [{
"$ref": "core-event-schema/room_event.yaml"
}],
"properties": {
"content": {
"type": "object",
"properties": {
"reason": {
"type": "string",
"description": "The reason for the redaction, if any."
}
}
},
"redacts": {
"type": "string",
"description": "The event ID that was redacted."
},
"type": {
"type": "string",
"enum": ["m.room.redaction"]
}
},
"required": ["redacts"]
}

View File

@ -0,0 +1,56 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"title": "An invitation to a room issued to a third party identifier, rather than a matrix user ID.",
"description": "Acts as an ``m.room.member`` invite event, where there isn't a target user_id to invite. This event contains a token and a public key whose private key must be used to sign the token. Any user who can present that signature may use this invitation to join the target room.",
"allOf": [{
"$ref": "core-event-schema/state_event.yaml"
}],
"properties": {
"content": {
"type": "object",
"properties": {
"display_name": {
"type": "string",
"description": "A user-readable string which represents the user who has been invited. This should not contain the user's third party ID, as otherwise when the invite is accepted it would leak the association between the matrix ID and the third party ID."
},
"key_validity_url": {
"type": "string",
"description": "A URL which can be fetched, with querystring public_key=public_key, to validate whether the key has been revoked. The URL must return a JSON object containing a boolean property named 'valid'."
},
"public_key": {
"type": "string",
"description": "A base64-encoded ed25519 key with which token must be signed (though a signature from any entry in public_keys is also sufficient). This exists for backwards compatibility."
},
"public_keys": {
"type": "array",
"description": "Keys with which the token may be signed.",
"items": {
"type": "object",
"title": "PublicKeys",
"properties": {
"public_key": {
"type": "string",
"description": "A base-64 encoded ed25519 key with which token may be signed."
},
"key_validity_url": {
"type": "string",
"description": "An optional URL which can be fetched, with querystring public_key=public_key, to validate whether the key has been revoked. The URL must return a JSON object containing a boolean property named 'valid'. If this URL is absent, the key must be considered valid indefinitely."
}
},
"required": ["public_key"]
}
}
},
"required": ["display_name", "key_validity_url", "public_key"]
},
"state_key": {
"type": "string",
"description": "The token, of which a signature must be produced in order to join the room."
},
"type": {
"type": "string",
"enum": ["m.room.third_party_invite"]
}
}
}

29
schemas/m.room.topic Normal file
View File

@ -0,0 +1,29 @@
{
"type": "object",
"title": "Topic",
"description": "A topic is a short message detailing what is currently being discussed in the room. It can also be used as a way to display extra information about the room, which may not be suitable for the room name. The room topic can also be set when creating a room using ``/createRoom`` with the ``topic`` key.",
"allOf": [{
"$ref": "core-event-schema/state_event.yaml"
}],
"properties": {
"content": {
"type": "object",
"properties": {
"topic": {
"type": "string",
"description": "The topic text."
}
},
"required": ["topic"]
},
"state_key": {
"type": "string",
"description": "A zero-length string.",
"pattern": "^$"
},
"type": {
"type": "string",
"enum": ["m.room.topic"]
}
}
}

25
schemas/m.tag Normal file
View File

@ -0,0 +1,25 @@
{
"type": "object",
"title": "Tag Event",
"description": "Informs the client of tags on a room.",
"properties": {
"type": {
"type": "string",
"enum": ["m.tag"]
},
"content": {
"type": "object",
"properties": {
"tags": {
"type": "object",
"description": "The tags on the room and their contents.",
"additionalProperties": {
"title": "Tag",
"type": "object"
}
}
}
}
},
"required": ["type", "content"]
}

28
schemas/m.typing Normal file
View File

@ -0,0 +1,28 @@
{
"type": "object",
"title": "Typing Event",
"description": "Informs the client of the list of users currently typing.",
"properties": {
"content": {
"type": "object",
"properties": {
"user_ids": {
"type": "array",
"items": {
"type": "string"
},
"description": "The list of user IDs typing in this room, if any."
}
},
"required": ["user_ids"]
},
"type": {
"type": "string",
"enum": ["m.typing"]
},
"room_id": {
"type": "string"
}
},
"required": ["type", "room_id", "content"]
}

73
src/object-generator.vala Normal file
View File

@ -0,0 +1,73 @@
/*
* 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.
*
* This one specific file is licensed under the GNU 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/>.
*/
int main (string[] args)
{
try {
var directory = File.new_for_path("../schemas");
var enumerator = directory.enumerate_children(
FileAttribute.STANDARD_NAME, 0);
FileInfo file_info;
while ((file_info = enumerator.next_file()) != null) {
var filename = file_info.get_name();
if (filename.has_prefix("m.")) {
File schema_file = directory.resolve_relative_path(filename);
var parser = new Json.Parser();
string? description = null;
stdout.printf("Processing %s…\n", filename);
parser.load_from_stream(schema_file.read());
var root = parser.get_root().get_object();
var event_type = root.get_member("type").get_string();
stdout.printf("Type: %s\n", event_type);
if (event_type == "object") {
if (filename.index_of_char('#') == -1) {
Json.Node? node;
if ((node = root.get_member("description")) != null) {
description = node.get_string();
}
} else {
stdout.printf("Event-subtype, will implement later\n");
}
} else {
stdout.printf("Wont process non-objects!\n");
}
stdout.printf("\n");
}
}
} catch (Error e) {
stderr.printf("Error: %s\n", e.message);
return 1;
}
return 0;
}