Rework MatrixAPI in Vala

This commit is contained in:
Gergely Polonkai 2016-02-18 17:29:21 +01:00
parent 2eb4828cdb
commit d5833c4cee
10 changed files with 1438 additions and 3667 deletions

3
.gitignore vendored
View File

@ -60,4 +60,5 @@ Makefile.in
/src/Matrix-0.0.vapi /src/Matrix-0.0.vapi
/src/vala-temp /src/vala-temp
/src/vala-stamp /src/vala-stamp
/src/matrix-glib.h /src/matrix-glib.h
/src/matrix-api.c

View File

@ -16,6 +16,7 @@ lib_LTLIBRARIES = libmatrix-glib-0.0.la
# Vala source files # Vala source files
libmatrix_glib_0_0_la_VALA_SOURCES = \ libmatrix_glib_0_0_la_VALA_SOURCES = \
matrix-api.vala \
$(NULL) $(NULL)
AM_CPPFLAGS += \ AM_CPPFLAGS += \
@ -38,6 +39,7 @@ AM_VALAFLAGS += \
-C \ -C \
--use-header \ --use-header \
--gir=Matrix-$(MATRIX_GLIB_API_VERSION).gir \ --gir=Matrix-$(MATRIX_GLIB_API_VERSION).gir \
$(top_srcdir)/src/c-api.vapi \
$(NULL) $(NULL)
vala-stamp: $(libmatrix_glib_0_0_la_VALA_SOURCES) vala-stamp: $(libmatrix_glib_0_0_la_VALA_SOURCES)
@ -69,7 +71,6 @@ bin_PROGRAMS = test-api-client
INST_H_SRC_FILES = \ INST_H_SRC_FILES = \
matrix-types.h \ matrix-types.h \
matrix-api.h \
matrix-http-api.h \ matrix-http-api.h \
matrix-client.h \ matrix-client.h \
matrix-http-client.h \ matrix-http-client.h \
@ -82,7 +83,6 @@ INST_H_BUILT_FILES = \
matrix_enum_headers = \ matrix_enum_headers = \
matrix-types.h \ matrix-types.h \
matrix-api.h \
$(NULL) $(NULL)
libmatrix_glib_0_0_la_SOURCES = \ libmatrix_glib_0_0_la_SOURCES = \
@ -91,7 +91,6 @@ libmatrix_glib_0_0_la_SOURCES = \
$(libmatrix_glib_0_0_la_VALA_SOURCES:.vala=.c) \ $(libmatrix_glib_0_0_la_VALA_SOURCES:.vala=.c) \
matrix-version.c \ matrix-version.c \
matrix-types.c \ matrix-types.c \
matrix-api.c \
matrix-http-api.c \ matrix-http-api.c \
matrix-enumtypes.c \ matrix-enumtypes.c \
utils.c \ utils.c \

121
src/c-api.vapi Normal file
View File

@ -0,0 +1,121 @@
/*
* 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/>.
*/
[CCode (cprefix = "Matrix", gir_namespace = "Matrix", gir_version = "0.0", lower_case_cprefix = "matrix_")]
namespace Matrix {
[CCode (cheader_filename = "matrix-enumtypes.h", cprefix = "MATRIX_ERROR_")]
public errordomain Error {
NONE,
COMMUNICATION_ERROR,
INCOMPLETE,
BAD_REQUEST,
BAD_RESPONSE,
INVALID_ROOM_ID,
UNKNOWN_VALUE,
INVALID_TYPE,
UNSUPPORTED,
INVALID_FORMAT,
M_MISSING_TOKEN,
M_FORBIDDEN,
M_UNKNOWN,
M_UNKNOWN_TOKEN,
M_NOT_JSON,
M_UNRECOGNIZED,
UNSPECIFIED,
UNKNOWN_ERROR;
public static GLib.Quark quark ();
}
[CCode (cheader_filename = "matrix-enumtypes.h", cprefix = "MATRIX_RESIZE_METHOD_")]
public enum ResizeMethod {
DEFAULT,
CROP,
SCALE;
}
[CCode (cheader_filename = "matrix-enumtypes.h", cprefix = "MATRIX_PRESENCE_")]
public enum Presence {
UNKNOWN,
ONLINE,
OFFLINE,
UNAVAILABLE,
FREE_FOR_CHAT;
}
[CCode (cheader_filename = "matrix-enumtypes.h", cprefix = "MATRIX_PUSHER_KIND_")]
public enum PusherKind {
OVERRIDE,
SENDER,
ROOM,
CONTENT,
UNDERRIDE;
}
[CCode (cheader_filename = "matrix-enumtypes.h", cprefix = "MATRIX_PUSHER_CONDITION_KIND_")]
public enum PusherConditionKind {
EVENT_MATCH,
PROFILE_TAG,
CONTAINS_DISPLAY_NAME,
ROOM_MEMBER_COUNT;
}
[CCode (cheader_filename = "matrix-enumtypes.h", cprefix = "MATRIX_ROOM_PRESET_")]
public enum RoomPreset {
NONE,
PRIVATE,
TRUSTED_PRIVATE,
PUBLIC;
}
[CCode (cheader_filename = "matrix-enumtypes.h", cprefix = "MATRIX_ROOM_VISIBILITY_")]
public enum RoomVisibility {
DEFAULT,
PUBLIC,
PRIVATE;
}
[CCode (cheader_filename = "matrix-enumtypes.h", cprefix = "MATRIX_EVENT_DIRECTION_")]
public enum EventDirection {
FORWARD,
BACKWARD;
}
[CCode (cheader_filename = "matrix-enumtypes.h", cprefix = "MATRIX_RECEIPT_TYPE_")]
public enum ReceiptType {
READ;
}
[CCode (cheader_filename = "matrix-enumtypes.h", cprefix = "MATRIX_ACCOUNT_KIND_")]
public enum AccountKind {
DEFAULT,
USER,
GUEST;
}
[CCode (cheader_filename = "matrix-types.h")]
public class Pusher {}
[CCode (cheader_filename = "matrix-types.h")]
public class StateEvent {}
[CCode (cheader_filename = "matrix-types.h")]
public class @3PidCredential {}
[CCode (cheader_filename = "matrix-types.h")]
public class Filter {}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,908 +0,0 @@
/*
* 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/>.
*/
#ifndef __MATRIX_API_IFACE_H__
#define __MATRIX_API_IFACE_H__
#include <glib-object.h>
#include <json-glib/json-glib.h>
#include "matrix-types.h"
G_BEGIN_DECLS
#define MATRIX_TYPE_API (matrix_api_get_type())
#define MATRIX_API(o) (G_TYPE_CHECK_INSTANCE_CAST((o), MATRIX_TYPE_API, MatrixAPI))
#define MATRIX_IS_API(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), MATRIX_TYPE_API))
#define MATRIX_API_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE((o), MATRIX_TYPE_API, MatrixAPIInterface))
typedef struct _MatrixAPIInterface MatrixAPIInterface;
typedef struct _MatrixAPI MatrixAPI;
typedef void (*MatrixAPICallback)(MatrixAPI *api,
const gchar *content_type,
JsonNode *json_content,
GByteArray *raw_content,
gpointer user_data,
GError *err);
#define MATRIX_API_CALLBACK(f) ((MatrixAPICallback) (f)
#define MATRIX_API_CALLBACK_PROTO(name) static void \
name (MatrixAPI *api, \
const gchar *content_type, \
JsonNode *json_content, \
GByteArray *raw_content, \
gpointer user_data, \
GError *error)
struct _MatrixAPIInterface {
/*< private >*/
GTypeInterface g_iface;
/*< public >*/
/* Properties */
void (*set_token)(MatrixAPI *api, const gchar *token);
const gchar *(*get_token)(MatrixAPI *api);
void (*set_refresh_token)(MatrixAPI *api, const gchar *refresh_token);
const gchar *(*get_refresh_token)(MatrixAPI *api);
const gchar *(*get_user_id)(MatrixAPI *api);
const gchar *(*get_homeserver)(MatrixAPI *api);
/*< private >*/
void *properties_reserved[10];
/*< public >*/
/* 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,
MatrixResizeMethod method,
GError **error);
void (*media_upload)(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
const gchar *content_type,
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,
MatrixPresence presence,
const gchar *status_message,
GError **error);
/* Push notifications */
void (*update_pusher)(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
MatrixPusher *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,
MatrixPusherKind kind,
const gchar *rule_id,
GError **error);
void (*get_pusher)(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
const gchar *scope,
MatrixPusherKind kind,
const gchar *rule_id,
GError **error);
void (*add_pusher)(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
const gchar *scope,
MatrixPusherKind 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,
MatrixPusherKind kind,
const gchar *rule_id,
gboolean enabled,
GError **error);
/* Room creation */
void (*create_room)(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
MatrixRoomPreset preset,
const gchar *room_name,
const gchar *room_alias,
const gchar *topic,
MatrixRoomVisibility visibility,
JsonNode *creation_content,
GList *initial_state,
GList *invitees,
GList *invite_3pids,
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,
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,
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,
Matrix3PidCredential *credential,
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,
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,
MatrixEventDirection direction,
guint limit,
GError **error);
void (*send_event_receipt)(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
const gchar *room_id,
MatrixReceiptType receipt_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,
JsonNode *content,
GError **error);
void (*get_room_state)(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
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,
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 MatrixFilter *filter,
const gchar *since,
gboolean full_state,
gboolean set_presence,
gulong timeout,
GError **error);
void (*create_filter)(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
const gchar *user_id,
MatrixFilter *filter,
GError **error);
void (*download_filter)(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
const gchar *user_id,
const gchar *filter_id,
GError **error);
/*< private >*/
/* Search */
void *search_reserved;
/*< public >*/
/* Server administration */
void (*whois)(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
const gchar *user_id,
GError **error);
void (*versions)(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
/* Session management */
void (*login)(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
const gchar *login_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,
Matrix3PidCredential *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,
MatrixAccountKind account_kind,
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 *event_type,
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,
JsonNode *content,
GError **error);
/* VoIP */
void (*get_turn_server)(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
/* Non-spec methods */
void (*abort_pending)(MatrixAPI *api);
/*< private >*/
/* Leave room for endpoint expansion */
void *padding[50];
};
GType matrix_api_get_type(void) G_GNUC_CONST;
/* Property getters and setters */
void matrix_api_set_token(MatrixAPI *api, const gchar *token);
const gchar *matrix_api_get_token(MatrixAPI *api);
void matrix_api_set_refresh_token(MatrixAPI *api, const gchar *refresh_token);
const gchar *matrix_api_get_refresh_token(MatrixAPI *api);
const gchar *matrix_api_get_user_id(MatrixAPI *api);
const gchar *matrix_api_get_homeserver(MatrixAPI *api);
/* 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,
MatrixResizeMethod method,
GError **error);
void matrix_api_media_upload(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
const gchar *content_type,
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,
MatrixPresence presence,
const gchar *status_message,
GError **error);
/* Push notifications */
void matrix_api_update_pusher(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
MatrixPusher *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,
MatrixPusherKind kind,
const gchar *rule_id,
GError **error);
void matrix_api_get_pusher(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
const gchar *scope,
MatrixPusherKind kind,
const gchar *rule_id,
GError **error);
void matrix_api_add_pusher(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
const gchar *scope,
MatrixPusherKind 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,
MatrixPusherKind kind,
const gchar *rule_id,
gboolean enabled,
GError **error);
/* Room creation */
void matrix_api_create_room(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
MatrixRoomPreset preset,
const gchar *room_name,
const gchar *room_alias,
const gchar *topic,
MatrixRoomVisibility visibility,
JsonNode *creation_content,
GList *initial_state,
GList *invitees,
GList *invite_3pids,
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,
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,
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,
Matrix3PidCredential *credential,
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,
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,
MatrixEventDirection direction,
guint limit,
GError **error);
void matrix_api_send_event_receipt(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
const gchar *room_id,
MatrixReceiptType receipt_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,
JsonNode *content,
GError **error);
void matrix_api_get_room_state(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
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,
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 MatrixFilter *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,
MatrixFilter *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);
void matrix_api_versions(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
/* Session management */
void matrix_api_login(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
const gchar *login_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,
Matrix3PidCredential *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,
MatrixAccountKind account_kind,
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 *event_type,
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);
/* Non-spec methods */
void matrix_api_abort_pending(MatrixAPI *api);
G_END_DECLS
#endif /* __MATRIX_API_IFACE_H__ */

1294
src/matrix-api.vala Normal file

File diff suppressed because it is too large Load Diff

View File

@ -90,7 +90,7 @@ typedef struct {
static GParamSpec *obj_properties[N_PROPERTIES] = {NULL,}; static GParamSpec *obj_properties[N_PROPERTIES] = {NULL,};
static void matrix_http_api_matrix_api_init(MatrixAPIInterface *iface); static void matrix_http_api_matrix_api_init(MatrixAPIIface *iface);
static void i_set_token(MatrixAPI *api, const gchar *token); static void i_set_token(MatrixAPI *api, const gchar *token);
static const gchar *i_get_token(MatrixAPI *api); static const gchar *i_get_token(MatrixAPI *api);
static void i_set_refresh_token(MatrixAPI *api, const gchar *refresh_token); static void i_set_refresh_token(MatrixAPI *api, const gchar *refresh_token);
@ -844,7 +844,7 @@ i_login(MatrixAPI *api,
MatrixAPICallback callback, MatrixAPICallback callback,
gpointer user_data, gpointer user_data,
const gchar *login_type, const gchar *login_type,
const JsonNode *content, JsonNode *content,
GError **error) GError **error)
{ {
JsonNode *body; JsonNode *body;
@ -2175,7 +2175,7 @@ i_sync(MatrixAPI *api,
MatrixAPICallback callback, MatrixAPICallback callback,
gpointer user_data, gpointer user_data,
const gchar *filter_id, const gchar *filter_id,
const MatrixFilter *filter, MatrixFilter *filter,
const gchar *since, const gchar *since,
gboolean full_state, gboolean full_state,
gboolean set_presence, gboolean set_presence,
@ -2756,7 +2756,7 @@ i_abort_pending(MatrixAPI *api)
} }
static void static void
matrix_http_api_matrix_api_init(MatrixAPIInterface *iface) matrix_http_api_matrix_api_init(MatrixAPIIface *iface)
{ {
iface->set_token = i_set_token; iface->set_token = i_set_token;
iface->get_token = i_get_token; iface->get_token = i_get_token;

View File

@ -21,7 +21,7 @@
#include <glib-object.h> #include <glib-object.h>
#include "matrix-api.h" #include "matrix-glib.h"
G_BEGIN_DECLS G_BEGIN_DECLS

View File

@ -58,8 +58,8 @@ cb_login(MatrixAPI *api,
const gchar *content_type, const gchar *content_type,
JsonNode *json_content, JsonNode *json_content,
GByteArray *raw_content, GByteArray *raw_content,
gpointer user_data, GError *error,
GError *error) gpointer user_data)
{ {
matrix_client_login_finished(MATRIX_CLIENT(api), (error == NULL)); matrix_client_login_finished(MATRIX_CLIENT(api), (error == NULL));
} }
@ -97,8 +97,8 @@ cb_register_account(MatrixAPI *api,
const gchar *content_type, const gchar *content_type,
JsonNode *json_content, JsonNode *json_content,
GByteArray *raw_content, GByteArray *raw_content,
gpointer user_data, GError *error,
GError *error) gpointer user_data)
{ {
matrix_client_login_finished(MATRIX_CLIENT(api), (error == NULL)); matrix_client_login_finished(MATRIX_CLIENT(api), (error == NULL));
} }
@ -137,8 +137,8 @@ cb_event_stream(MatrixAPI *api,
const gchar *content_type, const gchar *content_type,
JsonNode *json_content, JsonNode *json_content,
GByteArray *raw_content, GByteArray *raw_content,
gpointer user_data, GError *error,
GError *error) gpointer user_data)
{ {
MatrixHTTPClientPrivate *priv = matrix_http_client_get_instance_private( MatrixHTTPClientPrivate *priv = matrix_http_client_get_instance_private(
MATRIX_HTTP_CLIENT(api)); MATRIX_HTTP_CLIENT(api));

View File

@ -41,8 +41,8 @@ initial_sync_finished(MatrixAPI *api,
const gchar *content_type, const gchar *content_type,
JsonNode *json_content, JsonNode *json_content,
GByteArray *raw_content, GByteArray *raw_content,
gpointer user_data, GError *err,
GError *err) gpointer user_data)
{ {
g_printf("initialSync finished\n"); g_printf("initialSync finished\n");
@ -54,8 +54,8 @@ create_room_finished(MatrixAPI *api,
const gchar *content_type, const gchar *content_type,
JsonNode *json_content, JsonNode *json_content,
GByteArray *raw_content, GByteArray *raw_content,
gpointer data, GError *err,
GError *err) gpointer data)
{ {
if (err) { if (err) {
g_debug("Error: %s", err->message); g_debug("Error: %s", err->message);
@ -72,8 +72,8 @@ get_user_presence_finished(MatrixAPI *api,
const gchar *content_type, const gchar *content_type,
JsonNode *json_content, JsonNode *json_content,
GByteArray *raw_content, GByteArray *raw_content,
gpointer data, GError *err,
GError *err) gpointer data)
{ {
JsonObject *root_obj; JsonObject *root_obj;
const gchar *avatar_url; const gchar *avatar_url;
@ -102,8 +102,8 @@ login_finished(MatrixAPI *api,
const gchar *content_type, const gchar *content_type,
JsonNode *json_content, JsonNode *json_content,
GByteArray *raw_content, GByteArray *raw_content,
gpointer data, GError *err,
GError *err) gpointer data)
{ {
JsonPath *path = json_path_new(); JsonPath *path = json_path_new();
JsonNode *result; JsonNode *result;