aboutsummaryrefslogtreecommitdiffstats
path: root/matrix-connection.h
blob: a79c5cfda8d8fe92d6c38e33c9999d708c151d9c (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
/**
 * 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;

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;
} 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);


#endif