-
Notifications
You must be signed in to change notification settings - Fork 47
/
matrix-roommembers.h
152 lines (120 loc) · 4.24 KB
/
matrix-roommembers.h
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/*
* matrix-roommembers.h
*
*
* Copyright (c) Openmarket UK Ltd 2015
*
* 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_ROOMMEMBERS_H_
#define MATRIX_ROOMMEMBERS_H_
#include <glib.h>
/* the potential states of a user's membership of a room */
#define MATRIX_ROOM_MEMBERSHIP_NONE 0
#define MATRIX_ROOM_MEMBERSHIP_JOIN 1
#define MATRIX_ROOM_MEMBERSHIP_INVITE 2
#define MATRIX_ROOM_MEMBERSHIP_LEAVE 3
/* ****************************************************************************
*
* Handling of individual members
*/
typedef struct _MatrixRoomMember MatrixRoomMember;
/**
* Get the user_id for the given member
*
* @returns a string, which should *not* be freed
*/
const gchar *matrix_roommember_get_user_id(const MatrixRoomMember *member);
/**
* Get the displayname for the given member
*
* @returns a string, which should *not* be freed
*/
const gchar *matrix_roommember_get_displayname(const MatrixRoomMember *member);
/**
* Get the opaque data associated with the given member
*/
gpointer matrix_roommember_get_opaque_data(const MatrixRoomMember *member);
typedef void (*DestroyMemberNotify)(MatrixRoomMember *member);
/**
* Set the opaque data associated with the given member
*
* @param on_delete: a callback which will be called when the RoomMember is
* deleted (usually when its parent MatrixRoomMemberTable is deleted). It is
* passed a pointer to the MatrixRoomMember.
*/
void matrix_roommember_set_opaque_data(MatrixRoomMember *member,
gpointer data, DestroyMemberNotify on_delete);
/* ****************************************************************************
*
* Member table
*/
typedef struct _MatrixRoomMemberTable MatrixRoomMemberTable;
struct _JsonObject;
/**
* Allocate a new MatrixRoomMemberTable
*/
MatrixRoomMemberTable *matrix_roommembers_new_table();
/**
* Free a MatrixRoomMemberTable
*/
void matrix_roommembers_free_table(MatrixRoomMemberTable *table);
/**
* Handle the update of a room member.
*
* For efficiency, we do not immediately notify purple of the changes. Instead,
* you should call matrix_roommembers_get_(new,renamed,left)_members once
* the whole state table has been handled.
*/
void matrix_roommembers_update_member(MatrixRoomMemberTable *table,
const gchar *member_user_id, struct _JsonObject *new_state);
/**
* Look up a room member given the userid
*
* @returns MatrixRoomMember *, or NULL if unknown
*/
MatrixRoomMember *matrix_roommembers_lookup_member(MatrixRoomMemberTable *table,
const gchar *member_user_id);
/**
* Get a list of the members who have joined this room.
*
* Returns a list of MatrixRoomMember *s. Free the list, but not the pointers.
*/
GList *matrix_roommembers_get_active_members(
MatrixRoomMemberTable *member_table, gboolean include_invited);
/**
* Get a list of the new members since the last time this function was called.
*
* @returns a list of MatrixRoomMember *s. Free the list when you are done with
* it.
*/
GSList *matrix_roommembers_get_new_members(MatrixRoomMemberTable *table);
/**
* Get a list of the members who have been renamed since the last time this
* function was called.
*
* @returns a list of MatrixRoomMember *s. Free the list when you are done with
* it.
*/
GSList *matrix_roommembers_get_renamed_members(MatrixRoomMemberTable *table);
/**
* Get a list of the members who have left the channel since the last time this
* function was called.
*
* @returns a list of MatrixRoomMember *s. Free the list when you are done with
* it.
*/
GSList *matrix_roommembers_get_left_members(MatrixRoomMemberTable *table);
#endif /* MATRIX_ROOMMEMBERS_H_ */