MatrixClient

MatrixClient — Base interface for client communication with a Matrix.org homeserver

Functions

Types and Values

Description

Functions

matrix_client_login_with_password ()

void
matrix_client_login_with_password (MatrixClient *self,
                                   const gchar *username,
                                   const gchar *password,
                                   GError **error);

Authenticate with the Matrix.org server with a username and password.

Parameters

self

the MatrixClient instance

 

username

 .

the username to login with

.

[in]

password

 .

the password to use

.

[in]

error

location to store the error occuring, or NULL to ignore.

[error-domains MatrixError]

matrix_client_register_with_password ()

void
matrix_client_register_with_password (MatrixClient *self,
                                      const gchar *username,
                                      const gchar *password,
                                      GError **error);

Register username with the homeserver as a normal user.

Upon success, the user is registered and authenticated.

Implementations must emit the login-finished signal when a response arrives.

This method registers a normal user account. If you want to register a different kind of user, use matrix_api_register_account().

Parameters

self

the MatrixClient instance

 

username

 .

the username to register. If omitted, the server will generate one

.

[in][allow-none]

password

 .

the password to use with the registration

.

[in]

error

location to store the error occuring, or NULL to ignore.

[error-domains MatrixError]

matrix_client_logout ()

void
matrix_client_logout (MatrixClient *self,
                      GError **error);

Logout from the homeserver. As Matrix.org doesn’t have such a concept, this cancels all ongoing requests and clears the authentication data (e.g. tokens).

Parameters

self

the MatrixClient instance

 

error

location to store the error occuring, or NULL to ignore.

[error-domains MatrixError]

matrix_client_begin_polling ()

void
matrix_client_begin_polling (MatrixClient *self,
                             GError **error);

Begin polling the event stream.

Parameters

self

the MatrixClient instance

 

error

location to store the error occuring, or NULL to ignore.

[error-domains MatrixError]

matrix_client_stop_polling ()

void
matrix_client_stop_polling (MatrixClient *self,
                            gboolean cancel_ongoing,
                            GError **error);

Stop polling the event stream. If param cancel_ongoing is

1
true

, ongoing requests will be cancelled, too.

Parameters

self

the MatrixClient instance

 

cancel_ongoing

 .

if

1
true

, ongoing requests will be cancelled, too

.

[in]

error

location to store the error occuring, or NULL to ignore.

[error-domains MatrixError]

matrix_client_emit_login_finished ()

void
matrix_client_emit_login_finished (MatrixClient *self,
                                   gboolean success);

Convenience function to emits the login-finished signal.

Parameters

self

the MatrixClient instance

 

success

 .

set to

1
true

if login was successful

.

[in]

matrix_client_incoming_event ()

void
matrix_client_incoming_event (MatrixClient *self,
                              const gchar *room_id,
                              JsonNode *raw_event,
                              MatrixEventBase *matrix_event);

Emits the “event” signal.

Parameters

self

the MatrixClient instance

 

room_id

 .

the room this event is associated with

.

[in][allow-none]

raw_event

 .

the raw event

.

[in]

matrix_event

 .

the event as a Matrix.Event

.

[in][allow-none]

matrix_client_connect_event ()

void
matrix_client_connect_event (MatrixClient *self,
                             GType event_gtype,
                             MatrixClientEventCallback event_callback,
                             void *event_callback_target,
                             GDestroyNotify event_callback_target_destroy_notify);

Connect a handler for events. If param event_gtype is Matrix.Event, all events will be sent to the callback function, otherwise only events that match the specified event type.

If event_gtype is not derived from Matrix.Event, param callback won’t get connected.

Parameters

self

the MatrixClient instance

 

event_gtype

 .

the GType of a Matrix.Event derivative

.

[in]

event_callback

 .

the allback function to connect

.

[in]

event_callback_target

user data to pass to event_callback .

[allow-none][closure]

event_callback_target_destroy_notify

function to call when event_callback_target is no longer needed.

[allow-none]

matrix_client_get_user_profile ()

MatrixProfile *
matrix_client_get_user_profile (MatrixClient *self,
                                const gchar *user_id,
                                const gchar *room_id,
                                GError **error);

Get the profile of a user specified by param user_id. If param room_id is not null, return the room-specific profile. If the user's profile is not cached yet, Matrix.Error.UNAVAILABLE is thrown.

Parameters

self

the MatrixClient instance

 

user_id

 

 

room_id

 

 

error

location to store the error occuring, or NULL to ignore.

[error-domains MatrixError]

matrix_client_get_user_presence ()

MatrixPresence
matrix_client_get_user_presence (MatrixClient *self,
                                 const gchar *user_id,
                                 const gchar *room_id,
                                 GError **error);

Get the presence state of a user specified by param user_id. If param room_id is null, return the room specific presence state. If the user's presence state is not cached yet, Matrix.Error.UNAVAILABLE is thrown.

Parameters

self

the MatrixClient instance

 

user_id

 

 

room_id

 

 

error

location to store the error occuring, or NULL to ignore.

[error-domains MatrixError]

matrix_client_get_room_by_id ()

MatrixRoom *
matrix_client_get_room_by_id (MatrixClient *self,
                              const gchar *room_id,
                              GError **error);

Get a room object by the room ID specified in param room_id. If room data is not cached yet, Matrix.Error.UNAVAILABLE is thrown.

Parameters

self

the MatrixClient instance

 

room_id

 .

the ID of a room

.

[in]

error

location to store the error occuring, or NULL to ignore.

[error-domains MatrixError]

Returns

a Matrix.Room object


MatrixClientEventCallback ()

void
(*MatrixClientEventCallback) (MatrixClient *client,
                              const gchar *room_id,
                              JsonNode *raw_event,
                              MatrixEventBase *matrix_event,
                              void *user_data);

Callback function delegate for the event signal.

Parameters

room_id

 .

the room the event associated with

.

[in][allow-none]

raw_event

 .

the event as a raw JSON object

.

[in]

matrix_event

 .

the event as a Matrix.Event object

.

[in][allow-none]

client

 

 

user_data

data to pass to the delegate function.

[closure]

Types and Values

MatrixClient

typedef struct _MatrixClient MatrixClient;

Base interface for client communication with a Matrix.org homeserver


struct MatrixClientIface

struct MatrixClientIface {
	GTypeInterface parent_iface;
	void (*login_with_password) (MatrixClient* self, const gchar* username, const gchar* password, GError** error);
	void (*register_with_password) (MatrixClient* self, const gchar* username, const gchar* password, GError** error);
	void (*logout) (MatrixClient* self, GError** error);
	void (*begin_polling) (MatrixClient* self, GError** error);
	void (*stop_polling) (MatrixClient* self, gboolean cancel_ongoing, GError** error);
	MatrixProfile* (*get_user_profile) (MatrixClient* self, const gchar* user_id, const gchar* room_id, GError** error);
	MatrixPresence (*get_user_presence) (MatrixClient* self, const gchar* user_id, const gchar* room_id, GError** error);
	MatrixRoom* (*get_room_by_id) (MatrixClient* self, const gchar* room_id, GError** error);
	void (*login_finished) (MatrixClient* self, gboolean success);
	void (*event) (MatrixClient* self, const gchar* room_id, JsonNode* raw_event, MatrixEventBase* matrix_event);
};

Interface for creating MatrixClient implementations.

Members

GTypeInterface parent_iface;

the parent interface structure

 

login_with_password ()

virtual method called by matrix_client_login_with_password()

 

register_with_password ()

virtual method called by matrix_client_register_with_password()

 

logout ()

virtual method called by matrix_client_logout()

 

begin_polling ()

virtual method called by matrix_client_begin_polling()

 

stop_polling ()

virtual method called by matrix_client_stop_polling()

 

get_user_profile ()

virtual method called by matrix_client_get_user_profile()

 

get_user_presence ()

virtual method called by matrix_client_get_user_presence()

 

get_room_by_id ()

virtual method called by matrix_client_get_room_by_id()

 

login_finished ()

   

event ()