MatrixClient

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

Functions

Types and Values

Object Hierarchy


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

true

, ongoing requests will be cancelled, too.

Parameters

self

the MatrixClient instance

 

cancel_ongoing

 .

if

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

true

if login was successful

.

[in]

matrix_client_incoming_event ()

void
matrix_client_incoming_event (MatrixClient *self,
                              const gchar *room_id,
                              JsonNode *raw_event,
                              MatrixEvent *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]

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 MatrixEvent, param callback won’t get connected.

Parameters

callback

the allback function to connect

 

self

the MatrixClient instance

 

event_gtype

 .

the GType of a MatrixEvent derivative

.

[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]

event_callback

 

 

MatrixClientEventCallback ()

void
(*MatrixClientEventCallback) (MatrixClient *client,
                              const gchar *room_id,
                              JsonNode *raw_event,
                              MatrixEvent *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]

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);
	void (*login_finished) (MatrixClient* self, gboolean success);
	void (*event) (MatrixClient* self, const gchar* room_id, JsonNode* raw_event, MatrixEvent* 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()

 

login_finished ()

   

event ()