Port MatrixAPI to C

This commit is contained in:
Gergely Polonkai 2017-11-24 08:06:14 +01:00
parent 508bf5d12e
commit b495cdc66a
7 changed files with 3205 additions and 1407 deletions

1
.gitignore vendored
View File

@ -47,7 +47,6 @@ Makefile.in
/src/vala-temp /src/vala-temp
/src/vala-stamp /src/vala-stamp
/src/matrix-glib.h /src/matrix-glib.h
/src/matrix-api.c
/src/matrix-client.c /src/matrix-client.c
/src/matrix-http-api.c /src/matrix-http-api.c
/src/matrix-http-client.c /src/matrix-http-client.c

View File

@ -17,7 +17,6 @@ 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 = \
namespace-info.vala \ namespace-info.vala \
matrix-api.vala \
matrix-client.vala \ matrix-client.vala \
matrix-http-api.vala \ matrix-http-api.vala \
matrix-http-client.vala \ matrix-http-client.vala \
@ -76,6 +75,7 @@ bin_PROGRAMS = test-api-client test-client
INST_H_SRC_FILES = \ INST_H_SRC_FILES = \
matrix-types.h \ matrix-types.h \
matrix-compacts.h \ matrix-compacts.h \
matrix-api.h \
matrix-event-base.h \ matrix-event-base.h \
matrix-event-call-base.h \ matrix-event-call-base.h \
matrix-event-call-answer.h \ matrix-event-call-answer.h \
@ -133,6 +133,7 @@ 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-event-types.c \ matrix-event-types.c \
matrix-version.c \ matrix-version.c \
matrix-api.c \
matrix-types.c \ matrix-types.c \
matrix-compacts.c \ matrix-compacts.c \
matrix-event-base.c \ matrix-event-base.c \

2074
src/matrix-api.c Normal file

File diff suppressed because it is too large Load Diff

896
src/matrix-api.h Normal file
View File

@ -0,0 +1,896 @@
/*
* 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_GLIB_SDK_API_H__
# define __MATRIX_GLIB_SDK_API_H__
# include <glib-object.h>
# include <json-glib/json-glib.h>
# include "matrix-compacts.h"
# include "matrix-event-state-base.h"
G_BEGIN_DECLS
# ifdef __MATRIX_GLIB_SDK_COMPILATION
# define MATRIX_DEPRECATED_FOR(f)
# else
# define MATRIX_DEPRECATED_FOR(f) G_DEPRECATED_FOR(f)
# endif
# define MATRIX_TYPE_API matrix_api_get_type()
G_DECLARE_INTERFACE(MatrixAPI, matrix_api, MATRIX, API, GObject)
typedef void (*MatrixAPICallback)(MatrixAPI *api,
const gchar *content_type,
JsonNode *json_content,
GByteArray *raw_content,
GError *err,
gpointer user_data);
struct _MatrixAPIInterface {
GTypeInterface parent_iface;
void (*abort_pending)(MatrixAPI *api);
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 (*deactivate_account)(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
const gchar *session,
const gchar *login_type,
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);
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);
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,
MatrixEventState **initial_state,
int n_initial_state,
gchar **invitees,
int n_invitees,
Matrix3PidCredential **invite_3pids,
int n_invite_3pids,
GError **error);
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);
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_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_state_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,
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);
void (*join_room_id_or_alias)(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
const gchar *room_id_or_alias,
GError **error);
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 (*kick_user)(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
const gchar *room_id,
const gchar *user_id,
const gchar *reason,
GError **error);
void (*leave_room)(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
const gchar *room_id,
GError **error);
void (*unban_user)(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
const gchar *room_id,
const gchar *user_id,
GError **error);
void (*login)(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
const gchar *login_type,
JsonNode *content,
GError **error);
void (*logout)(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void (*token_refresh)(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
const gchar *refresh_token,
GError **error);
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,
gchar **drop_ids,
int n_drop_ids,
gchar **invite_ids,
int n_invite_ids,
GError **error);
void (*get_presence)(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
const gchar *user_id,
GError **error);
void (*set_presence)(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
const gchar *user_id,
MatrixPresence presence,
const gchar *status_message,
GError **error);
void (*list_public_rooms)(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void (*get_pushers)(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void (*update_pusher)(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
MatrixPusher *pusher,
GError **error);
void (*get_pushrules)(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void (*delete_pushrule)(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
const gchar *scope,
MatrixPusherKind kind,
const gchar *rule_id,
GError **error);
void (*get_pushrule)(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
const gchar *scope,
MatrixPusherKind kind,
const gchar *rule_id,
GError **error);
void (*add_pushrule)(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
const gchar *scope,
MatrixPusherKind kind,
const gchar *rule_id,
const gchar *before,
const gchar *after,
gchar **actions,
int n_actions,
MatrixPusherConditionKind *conditions,
int n_conditions,
GError **error);
void (*toggle_pushrule)(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
const gchar *scope,
MatrixPusherKind kind,
const gchar *rule_id,
gboolean enabled,
GError **error);
void (*search)(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
const gchar *next_batch,
MatrixSearchCategories *search_categories,
GError **error);
void (*get_turn_server)(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
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);
const gchar *(*get_token)(MatrixAPI *api);
void (*set_token)(MatrixAPI *api, const gchar *token);
const gchar *(*get_refresh_token)(MatrixAPI *api);
void (*set_refresh_token)(MatrixAPI *api, const gchar *value);
const gchar *(*get_user_id)(MatrixAPI *api);
const gchar *(*get_homeserver)(MatrixAPI *api);
};
void matrix_api_abort_pending(MatrixAPI *api);
void matrix_api_get_3pids(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_add_3pid(MatrixAPI *api,
gboolean bind_creds,
Matrix3PidCredential *threepid_creds,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_deactivate_account(MatrixAPI *api,
const gchar *session,
const gchar *login_type,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_change_password(MatrixAPI *api,
const gchar *new_password,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_get_profile(MatrixAPI *api,
const gchar *user_id,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_get_avatar_url(MatrixAPI *api,
const gchar *user_id,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_set_avatar_url(MatrixAPI *api,
const gchar *user_id,
const gchar *avatar_url,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_get_display_name(MatrixAPI *api,
const gchar *user_id,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_set_display_name(MatrixAPI *api,
const gchar *user_id,
const gchar *display_name,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_register_account(MatrixAPI *api,
MatrixAccountKind account_kind,
gboolean bind_email,
const gchar *username,
const gchar *password,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_set_account_data(MatrixAPI *api,
const gchar *user_id,
const gchar *room_id,
const gchar *event_type,
JsonNode *content,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_get_room_tags(MatrixAPI *api,
const gchar *user_id,
const gchar *room_id,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_delete_room_tag(MatrixAPI *api,
const gchar *user_id,
const gchar *room_id,
const gchar *tag,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_add_room_tag(MatrixAPI *api,
const gchar *user_id,
const gchar *room_id,
const gchar *tag,
JsonNode *content,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_whois(MatrixAPI *api,
const gchar *user_id,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_versions(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_create_room(MatrixAPI *api,
MatrixRoomPreset preset,
const gchar *room_name,
const gchar *room_alias,
const gchar *topic,
MatrixRoomVisibility visibility,
JsonNode *creation_content,
MatrixEventState **initial_state,
int n_initial_state,
gchar **invitees,
int n_invitees,
Matrix3PidCredential **invite_3pids,
int n_invite_3pids,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_delete_room_alias(MatrixAPI *api,
const gchar *room_alias,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_get_room_id(MatrixAPI *api,
const gchar *room_alias,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_create_room_alias(MatrixAPI *api,
const gchar *room_id,
const gchar *room_alias,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_event_stream(MatrixAPI *api,
const gchar *from_token,
gulong timeout,
MatrixAPICallback callback,
gpointer user_data,
GError **error)
MATRIX_DEPRECATED_FOR(matrix_api_sync);
void matrix_api_get_event(MatrixAPI *api,
const gchar *event_id,
MatrixAPICallback callback,
gpointer user_data,
GError **error)
MATRIX_DEPRECATED_FOR(matrix_api_sync);
void matrix_api_initial_sync(MatrixAPI *api,
guint limit,
gboolean archived,
MatrixAPICallback callback,
gpointer user_data,
GError **error)
MATRIX_DEPRECATED_FOR(matrix_api_sync);
void matrix_api_get_event_context(MatrixAPI *api,
const gchar *room_id,
const gchar *event_id,
guint limit,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_initial_sync_room(MatrixAPI *api,
const gchar *room_id,
MatrixAPICallback callback,
gpointer user_data,
GError **error)
MATRIX_DEPRECATED_FOR(matrix_api_sync);
void matrix_api_list_room_members(MatrixAPI *api,
const gchar *room_id,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_list_room_messages(MatrixAPI *api,
const gchar *room_id,
const gchar *from_token,
MatrixEventDirection direction,
guint limit,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_send_event_receipt(MatrixAPI *api,
const gchar *room_id,
MatrixReceiptType receipt_type,
const gchar *event_id,
JsonNode *receipt,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_redact_event(MatrixAPI *api,
const gchar *room_id,
const gchar *event_id,
const gchar *txn_id,
const gchar *reason,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_send_event(MatrixAPI *api,
const gchar *room_id,
const gchar *event_type,
const gchar *txn_id,
JsonNode *content,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_get_room_state(MatrixAPI *api,
const gchar *room_id,
const gchar *event_type,
const gchar *state_key,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_send_state_event(MatrixAPI *api,
const gchar *room_id,
const gchar *event_type,
const gchar *state_key,
JsonNode *content,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_notify_room_typing(MatrixAPI *api,
const gchar *user_id,
const gchar *room_id,
guint timeout,
gboolean typing,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_sync(MatrixAPI *api,
const gchar *filter_id,
MatrixFilter *filter,
const gchar *since,
gboolean full_state,
gboolean set_presence,
gulong timeout,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_create_filter(MatrixAPI *api,
const gchar *user_id,
MatrixFilter *filter,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_download_filter(MatrixAPI *api,
const gchar *user_id,
const gchar *filter_id,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_join_room_id_or_alias(MatrixAPI *api,
const gchar *room_id_or_alias,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_ban_user(MatrixAPI *api,
const gchar *room_id,
const gchar *user_id,
const gchar *reason,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_forget_room(MatrixAPI *api,
const gchar *room_id,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_invite_user_3rdparty(MatrixAPI *api,
const gchar *room_id,
Matrix3PidCredential *credential,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_invite_user(MatrixAPI *api,
const gchar *room_id,
const gchar *user_id,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_join_room(MatrixAPI *api,
const gchar *room_id,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_kick_user(MatrixAPI *api,
const gchar *room_id,
const gchar *user_id,
const gchar *reason,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_leave_room(MatrixAPI *api,
const gchar *room_id,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_unban_user(MatrixAPI *api,
const gchar *room_id,
const gchar *user_id,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_login(MatrixAPI *api,
const gchar *login_type,
JsonNode *content,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_logout(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_token_refresh(MatrixAPI *api,
const gchar *refresh_token,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_get_presence_list(MatrixAPI *api,
const gchar *user_id,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_update_presence_list(MatrixAPI *api,
const gchar *user_id,
gchar **drop_ids,
int n_drop_ids,
gchar **invite_ids,
int n_invite_ids,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_get_presence(MatrixAPI *api,
const gchar *user_id,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_set_presence(MatrixAPI *api,
const gchar *user_id,
MatrixPresence presence,
const gchar *status_message,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_list_public_rooms(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_get_pushers(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_update_pusher(MatrixAPI *api,
MatrixPusher *pusher,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_get_pushrules(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_delete_pushrule(MatrixAPI *api,
const gchar *scope,
MatrixPusherKind kind,
const gchar *rule_id,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_get_pushrule(MatrixAPI *api,
const gchar *scope,
MatrixPusherKind kind,
const gchar *rule_id,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_add_pushrule(MatrixAPI *api,
const gchar *scope,
MatrixPusherKind kind,
const gchar *rule_id,
const gchar *before,
const gchar *after,
gchar **actions,
int n_actions,
MatrixPusherConditionKind *conditions,
int n_conditions,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_toggle_pushrule(MatrixAPI *api,
const gchar *scope,
MatrixPusherKind kind,
const gchar *rule_id,
gboolean enabled,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_search(MatrixAPI *api,
const gchar *next_batch,
MatrixSearchCategories *search_categories,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_get_turn_server(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_media_download(MatrixAPI *api,
const gchar *server_name,
const gchar *media_id,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_media_thumbnail(MatrixAPI *api,
const gchar *server_name,
const gchar *media_id,
guint width,
guint height,
MatrixResizeMethod method,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void matrix_api_media_upload(MatrixAPI *api,
const gchar *content_type,
GByteArray *content,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
const gchar *matrix_api_get_token(MatrixAPI *api);
void matrix_api_set_token(MatrixAPI *api, const gchar *token);
const gchar *matrix_api_get_refresh_token(MatrixAPI *api);
void matrix_api_set_refresh_token(MatrixAPI *api, const gchar *refresh_token);
const gchar *matrix_api_get_user_id(MatrixAPI *api);
const gchar *matrix_api_get_homeserver(MatrixAPI *api);
G_END_DECLS
#endif /* __MATRIX_GLIB_SDK_API_H__ */

File diff suppressed because it is too large Load Diff

View File

@ -46,7 +46,7 @@ initial_sync_finished(MatrixAPI *api,
{ {
g_printf("initialSync finished\n"); g_printf("initialSync finished\n");
matrix_api_event_stream(api, NULL, NULL, NULL, 0, NULL); matrix_api_event_stream(api, NULL, 0, NULL, NULL, NULL);
} }
static void static void
@ -90,9 +90,9 @@ get_presence_finished(MatrixAPI *api,
soup_uri_get_host(avatar_uri), soup_uri_get_host(avatar_uri),
soup_uri_get_path(avatar_uri)); soup_uri_get_path(avatar_uri));
matrix_api_media_download(api, matrix_api_media_download(api,
NULL, NULL,
soup_uri_get_host(avatar_uri), soup_uri_get_host(avatar_uri),
soup_uri_get_path(avatar_uri) + 1, soup_uri_get_path(avatar_uri) + 1,
NULL, NULL,
NULL); NULL);
soup_uri_free(avatar_uri); soup_uri_free(avatar_uri);
} }
@ -132,20 +132,25 @@ login_finished(MatrixAPI *api,
g_printf("Logged in as %s\n", user_id); g_printf("Logged in as %s\n", user_id);
matrix_api_initial_sync(api, matrix_api_initial_sync(api,
initial_sync_finished, 10, TRUE,
data, 10, TRUE, initial_sync_finished, data,
NULL); NULL);
matrix_api_create_room (api, matrix_api_create_room (api,
create_room_finished, NULL,
MATRIX_ROOM_PRESET_PUBLIC, MATRIX_ROOM_PRESET_PUBLIC,
"GLib SDK test room", "matrix-glib-sdk-test", "GLib SDK test room", "matrix-glib-sdk-test",
"GLib SDK test room", "GLib SDK test room",
MATRIX_ROOM_VISIBILITY_DEFAULT, MATRIX_ROOM_VISIBILITY_DEFAULT,
NULL, NULL, 0, NULL, 0, NULL, 0, NULL); NULL, NULL, 0, NULL, 0, NULL, 0,
matrix_api_get_presence_list(api, NULL, NULL, user_id, NULL); create_room_finished, NULL,
NULL);
matrix_api_get_presence_list(api,
user_id,
NULL, NULL,
NULL);
matrix_api_get_presence(api, matrix_api_get_presence(api,
get_presence_finished, NULL, user_id,
user_id, NULL); get_presence_finished, NULL,
NULL);
} else { } else {
g_printf("Login unsuccessful!\n"); g_printf("Login unsuccessful!\n");
@ -197,9 +202,9 @@ main(int argc, char *argv[])
g_debug("Logging in"); g_debug("Logging in");
matrix_api_login(api, matrix_api_login(api,
login_finished, loop,
"m.login.password", "m.login.password",
login_content, login_content,
login_finished, loop,
&err); &err);
if (err) { if (err) {

View File

@ -486,6 +486,224 @@ namespace Matrix {
public Profile(); public Profile();
} }
[CCode (cheader_filename = "matrix-api.h", type_cname = "MatrixAPIInterface")]
public interface API : GLib.Object {
public abstract string? token { get; set; default = null; }
public abstract string? refresh_token { get; set; default = null; }
public abstract string? user_id { get; default = null; }
public abstract string? homeserver { get; default = null; }
public delegate void
Callback(Matrix.API api,
string content_type,
Json.Node? json_content,
GLib.ByteArray? raw_content,
Matrix.Error? err);
public abstract void abort_pending();
/* User data */
public abstract void get_3pids([CCode (scope = "async")]owned Matrix.API.Callback? @callback)
throws Matrix.Error;
public abstract void add_3pid([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, bool bind_creds, Matrix.3PidCredential threepid_creds)
throws Matrix.Error;
public abstract void deactivate_account([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, string? session, string? login_type)
throws Matrix.Error;
public abstract void change_password([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, string new_password)
throws Matrix.Error;
public abstract void get_profile([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, string user_id)
throws Matrix.Error;
public abstract void get_avatar_url([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, string user_id)
throws Matrix.Error;
public abstract void set_avatar_url([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, string user_id, string avatar_url)
throws Matrix.Error;
public abstract void get_display_name([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, string user_id)
throws Matrix.Error;
public abstract void set_display_name([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, string user_id, string display_name)
throws Matrix.Error;
public abstract void register_account([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, Matrix.AccountKind account_kind, bool bind_email, string? username, string password)
throws Matrix.Error;
public abstract void set_account_data([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, string user_id, string? room_id, string event_type, owned Json.Node content)
throws Matrix.Error;
public abstract void get_room_tags([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, string user_id, string room_id)
throws Matrix.Error;
public abstract void delete_room_tag([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, string user_id, string room_id, string tag)
throws Matrix.Error;
public abstract void add_room_tag([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, string user_id, string room_id, string tag, owned Json.Node? content)
throws Matrix.Error;
public abstract void whois([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, string user_id)
throws Matrix.Error;
public abstract void versions([CCode (scope = "async")] owned Matrix.API.Callback? @callback)
throws Matrix.Error;
public abstract void create_room([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, Matrix.RoomPreset preset, string? room_name, string? room_alias, string? topic, Matrix.RoomVisibility visibility, Json.Node? creation_content, Matrix.Event.State[] initial_state, string[] invitees, Matrix.3PidCredential[] invite_3pids)
throws Matrix.Error;
public abstract void delete_room_alias([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, string room_alias)
throws Matrix.Error;
public abstract void get_room_id([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, string room_alias)
throws Matrix.Error;
public abstract void create_room_alias([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, string room_id, string room_alias)
throws Matrix.Error;
[Version (deprecated = true, deprecated_since = "v0", replacement = "sync")]
public abstract void event_stream([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, string? from_token, ulong timeout)
throws Matrix.Error;
[Version (deprecated = true, deprecated_since = "v0", replacement = "sync")]
public abstract void get_event([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, string event_id)
throws Matrix.Error;
[Version (deprecated = true, deprecated_since = "v0", replacement = "sync")]
public abstract void initial_sync([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, uint limit, bool archived)
throws Matrix.Error;
public abstract void get_event_context([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? callback, string room_id, string event_id, uint limit)
throws Matrix.Error;
[Version (deprecated = true, deprecated_since = "v0", replacement = "sync")]
public abstract void initial_sync_room([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, string room_id)
throws Matrix.Error;
public abstract void list_room_members([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, string room_id)
throws Matrix.Error;
public abstract void list_room_messages([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, string room_id, string from_token, Matrix.EventDirection direction, uint limit)
throws Matrix.Error;
public abstract void send_event_receipt([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, string room_id, Matrix.ReceiptType receipt_type, string event_id, Json.Node receipt)
throws Matrix.Error;
public abstract void redact_event([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, string room_id, string event_id, string txn_id, string? reason)
throws Matrix.Error;
public abstract void send_event([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, string room_id, string event_type, string txn_id, owned Json.Node content)
throws Matrix.Error;
public abstract void get_room_state([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, string room_id, string? event_type, string? state_key)
throws Matrix.Error;
public abstract void send_state_event([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, string room_id, string event_type, string? state_key, owned Json.Node content)
throws Matrix.Error;
public abstract void notify_room_typing([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, string user_id, string room_id, uint timeout, bool typing)
throws Matrix.Error;
public abstract void sync([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, string? filter_id, Matrix.Filter? filter, string? since, bool full_state, bool set_presence, ulong timeout)
throws Matrix.Error;
public abstract void create_filter([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, string user_id, Matrix.Filter filter)
throws Matrix.Error;
public abstract void download_filter([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, string user_id, string filter_id)
throws Matrix.Error;
public abstract void join_room_id_or_alias([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, string room_id_or_alias)
throws Matrix.Error;
public abstract void ban_user([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, string room_id, string user_id, string? reason)
throws Matrix.Error;
public abstract void forget_room([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, string room_id)
throws Matrix.Error;
public abstract void invite_user_3rdparty([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, string room_id, Matrix.3PidCredential credential)
throws Matrix.Error;
public abstract void invite_user([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, string room_id, string user_id)
throws Matrix.Error;
public abstract void join_room([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, string room_id)
throws Matrix.Error;
public abstract void kick_user([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, string room_id, string user_id, string? reason)
throws Matrix.Error;
public abstract void leave_room([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, string room_id)
throws Matrix.Error;
public abstract void unban_user([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, string room_id, string user_id)
throws Matrix.Error;
public abstract void login([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, string login_type, Json.Node? content)
throws Matrix.Error;
public abstract void logout([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback)
throws Matrix.Error;
public abstract void token_refresh([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, string? refresh_token)
throws Matrix.Error;
public abstract void get_presence_list([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, string user_id)
throws Matrix.Error;
public abstract void update_presence_list([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, string user_id, string[] drop_ids, string[] invite_ids)
throws Matrix.Error;
public abstract void get_presence([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, string user_id)
throws Matrix.Error;
public abstract void set_presence([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, string user_id, Matrix.Presence presence, string? status_message)
throws Matrix.Error;
public abstract void list_public_rooms([CCode (scope = "async")] owned Matrix.API.Callback? @callback)
throws Matrix.Error;
public abstract void get_pushers([CCode (scope = "async")] owned Matrix.API.Callback? @callback)
throws Matrix.Error;
public abstract void update_pusher([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, Matrix.Pusher pusher)
throws Matrix.Error;
public abstract void get_pushrules([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback)
throws Matrix.Error;
public abstract void delete_pushrule([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, string scope, Matrix.PusherKind kind, string rule_id)
throws Matrix.Error;
public abstract void get_pushrule([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, string scope, Matrix.PusherKind kind, string rule_id)
throws Matrix.Error;
public abstract void add_pushrule([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, string scope, Matrix.PusherKind kind, string rule_id, string? before, string? after, string[] actions, Matrix.PusherConditionKind[] conditions)
throws Matrix.Error;
public abstract void toggle_pushrule([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, string scope, Matrix.PusherKind kind, string rule_id, bool enabled)
throws Matrix.Error;
public abstract void search([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, string? next_batch, SearchCategories search_categories)
throws Matrix.Error;
public abstract void get_turn_server([CCode (scope = "async")] owned Matrix.API.Callback? @callback)
throws Matrix.Error;
public abstract void media_download([CCode (delegate_target_pos = 1.5, scope = "async", destroy_notify_pos = -1)] owned Matrix.API.Callback? @callback, string server_name, string media_id)
throws Matrix.Error;
public abstract void media_thumbnail([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, string server_name, string media_id, uint width, uint height, Matrix.ResizeMethod method)
throws Matrix.Error;
public abstract void media_upload([CCode (delegate_target_pos = 1.5, scope = "async")] owned Matrix.API.Callback? @callback, string? content_type, owned GLib.ByteArray content)
throws Matrix.Error;
}
/** /**
* The major version number of the Matrix.org GLib SDK. * The major version number of the Matrix.org GLib SDK.
*/ */