aboutsummaryrefslogtreecommitdiffstats
path: root/matrix-api.h
blob: d81c02799cc487d911bc0fecb2612284f6c51dcf (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
/**
 * Interface to the matrix client/server API
 *
 * 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_API_H
#define MATRIX_API_H

/* libpurple */
#include "util.h"

#include "libmatrix.h"

struct _JsonNode;

/**
 * This is the signature used for functions that act as the callback
 * to the matrix api methods
 *
 * @param account       The MatrixAccount passed into the api method
 * @param user_data     The user data that your code passed into the api
 *                      method.
 * @param http_response -1 on error, otherwise this is the HTTP response code.
 * @param http_response_msg NULL on error, otherwise this is the message from
 *                      the HTTP response line.
 * @param body_start    NULL on error, or if there was no body in the response;
 *                      otherwise a pointer to the start of the body in the
 *                      response
 * @param json_root     NULL on error, or if there was no body in the response;
 *                      otherwise the root of the JSON tree in the response
 * @param error_message If something went wrong then this will contain
 *                      a descriptive error message, and ret_text will be
 *                      NULL and ret_len will be 0.
 */
typedef void (*MatrixApiCallback)(MatrixAccount *account,
                                  gpointer user_data,
                                  int http_response_code,
                                  const gchar *http_response_msg,
                                  const gchar *body_start,
                                  struct _JsonNode *json_root,
                                  const gchar *error_message);


/**
 * call the /initialsync API
 *
 * @param account    The MatrixAccount for which to make the request
 * @param callback   Function to be called when the request completes
 * @param user_data  Opaque data to be passed to the callback
 */
PurpleUtilFetchUrlData *matrix_initialsync(MatrixAccount *account,
                                           MatrixApiCallback callback,
                                           gpointer user_data);

#endif