aboutsummaryrefslogtreecommitdiffstats
path: root/matrix-connection.h
blob: b7d8e21657439cac4c212c0b4c616e6c0681556c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/**
 * matrix-connection.h: handle the connection to a matrix homeserver
 *
 * When matrix_connection_start_login is called, we first get an access
 * token by calling /login. We then repeatedly poll the /sync API endpoint.
 * Each time /sync returns, the returned events are dispatched to the
 * relevant rooms, and another /sync request is started.
 *
 *
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
 */

#ifndef MATRIX_CONNECTION_H
#define MATRIX_CONNECTION_H

#include <glib.h>

struct _PurpleConnection;
struct _MatrixE2EData;

typedef struct _MatrixConnectionData {
    struct _PurpleConnection *pc;
    gchar *homeserver;      /* URL of the homeserver. Always ends in '/' */
    gchar *user_id;         /* our full user id ("@user:server") */
    gchar *access_token;    /* access token corresponding to our user */

    /* the active sync request */
    struct _MatrixApiRequestData *active_sync;
    /* All the end-2-end encryption magic */
    struct _MatrixE2EData *e2e;
} MatrixConnectionData;


/**
 * Allocate a new MatrixConnectionData for the given PurpleConnection
 */
void matrix_connection_new(struct _PurpleConnection *pc);

/**
 * Start the login process on a matrix connection. When this completes, it
 * will start the /sync loop
 */
void matrix_connection_start_login(struct _PurpleConnection *pc);

/**
 * free the resources associated with a PurpleConnection
 */
void matrix_connection_free(struct _PurpleConnection *pc);

/**
 * abort the active /sync for this account, in preparation for disconnecting
 */
void matrix_connection_cancel_sync(struct _PurpleConnection *pc);


/**
 * start the process for joining a room
 */
void matrix_connection_join_room(struct _PurpleConnection *pc,
        const gchar *room, GHashTable *components);


/**
 * start the process for rejecting an invite to a chat
 */
void matrix_connection_reject_invite(struct _PurpleConnection *pc,
        const gchar *room_id);

#endif