summaryrefslogtreecommitdiff
path: root/toxcore/tox_old.c
diff options
context:
space:
mode:
Diffstat (limited to 'toxcore/tox_old.c')
-rw-r--r--toxcore/tox_old.c237
1 files changed, 237 insertions, 0 deletions
diff --git a/toxcore/tox_old.c b/toxcore/tox_old.c
new file mode 100644
index 00000000..2a422575
--- /dev/null
+++ b/toxcore/tox_old.c
@@ -0,0 +1,237 @@
1/**********GROUP CHAT FUNCTIONS: WARNING Group chats will be rewritten so this might change ************/
2
3/* Set the callback for group invites.
4 *
5 * Function(Tox *tox, int32_t friendnumber, uint8_t type, uint8_t *data, uint16_t length, void *userdata)
6 *
7 * data of length is what needs to be passed to join_groupchat().
8 */
9void tox_callback_group_invite(Tox *tox, void (*function)(Messenger *tox, int32_t, uint8_t, const uint8_t *, uint16_t,
10 void *), void *userdata)
11{
12 Messenger *m = tox;
13 g_callback_group_invite(m->group_chat_object, function, userdata);
14}
15
16/* Set the callback for group messages.
17 *
18 * Function(Tox *tox, int groupnumber, int peernumber, uint8_t * message, uint16_t length, void *userdata)
19 */
20void tox_callback_group_message(Tox *tox, void (*function)(Messenger *tox, int, int, const uint8_t *, uint16_t, void *),
21 void *userdata)
22{
23 Messenger *m = tox;
24 g_callback_group_message(m->group_chat_object, function, userdata);
25}
26
27/* Set the callback for group actions.
28 *
29 * Function(Tox *tox, int groupnumber, int peernumber, uint8_t * action, uint16_t length, void *userdata)
30 */
31void tox_callback_group_action(Tox *tox, void (*function)(Messenger *tox, int, int, const uint8_t *, uint16_t, void *),
32 void *userdata)
33{
34 Messenger *m = tox;
35 g_callback_group_action(m->group_chat_object, function, userdata);
36}
37
38/* Set callback function for title changes.
39 *
40 * Function(Tox *tox, int groupnumber, int peernumber, uint8_t * title, uint8_t length, void *userdata)
41 * if peernumber == -1, then author is unknown (e.g. initial joining the group)
42 */
43void tox_callback_group_title(Tox *tox, void (*function)(Messenger *tox, int, int, const uint8_t *, uint8_t,
44 void *), void *userdata)
45{
46 Messenger *m = tox;
47 g_callback_group_title(m->group_chat_object, function, userdata);
48}
49
50/* Set callback function for peer name list changes.
51 *
52 * It gets called every time the name list changes(new peer/name, deleted peer)
53 * Function(Tox *tox, int groupnumber, void *userdata)
54 */
55void tox_callback_group_namelist_change(Tox *tox, void (*function)(Tox *tox, int, int, uint8_t, void *), void *userdata)
56{
57 Messenger *m = tox;
58 g_callback_group_namelistchange(m->group_chat_object, function, userdata);
59}
60
61/* Creates a new groupchat and puts it in the chats array.
62 *
63 * return group number on success.
64 * return -1 on failure.
65 */
66int tox_add_groupchat(Tox *tox)
67{
68 Messenger *m = tox;
69 return add_groupchat(m->group_chat_object, GROUPCHAT_TYPE_TEXT);
70}
71
72/* Delete a groupchat from the chats array.
73 *
74 * return 0 on success.
75 * return -1 if failure.
76 */
77int tox_del_groupchat(Tox *tox, int groupnumber)
78{
79 Messenger *m = tox;
80 return del_groupchat(m->group_chat_object, groupnumber);
81}
82
83/* Copy the name of peernumber who is in groupnumber to name.
84 * name must be at least MAX_NICK_BYTES long.
85 *
86 * return length of name if success
87 * return -1 if failure
88 */
89int tox_group_peername(const Tox *tox, int groupnumber, int peernumber, uint8_t *name)
90{
91 const Messenger *m = tox;
92 return group_peername(m->group_chat_object, groupnumber, peernumber, name);
93}
94
95/* Copy the public key of peernumber who is in groupnumber to public_key.
96 * public_key must be crypto_box_PUBLICKEYBYTES long.
97 *
98 * returns 0 on success
99 * returns -1 on failure
100 */
101int tox_group_peer_pubkey(const Tox *tox, int groupnumber, int peernumber, uint8_t *public_key)
102{
103 const Messenger *m = tox;
104 return group_peer_pubkey(m->group_chat_object, groupnumber, peernumber, public_key);
105}
106
107/* invite friendnumber to groupnumber
108 * return 0 on success
109 * return -1 on failure
110 */
111int tox_invite_friend(Tox *tox, int32_t friendnumber, int groupnumber)
112{
113 Messenger *m = tox;
114 return invite_friend(m->group_chat_object, friendnumber, groupnumber);
115}
116
117/* Join a group (you need to have been invited first.) using data of length obtained
118 * in the group invite callback.
119 *
120 * returns group number on success
121 * returns -1 on failure.
122 */
123int tox_join_groupchat(Tox *tox, int32_t friendnumber, const uint8_t *data, uint16_t length)
124{
125 Messenger *m = tox;
126 return join_groupchat(m->group_chat_object, friendnumber, GROUPCHAT_TYPE_TEXT, data, length);
127}
128
129/* send a group message
130 * return 0 on success
131 * return -1 on failure
132 */
133int tox_group_message_send(Tox *tox, int groupnumber, const uint8_t *message, uint16_t length)
134{
135 Messenger *m = tox;
136 return group_message_send(m->group_chat_object, groupnumber, message, length);
137}
138
139/* send a group action
140 * return 0 on success
141 * return -1 on failure
142 */
143int tox_group_action_send(Tox *tox, int groupnumber, const uint8_t *action, uint16_t length)
144{
145 Messenger *m = tox;
146 return group_action_send(m->group_chat_object, groupnumber, action, length);
147}
148
149/* set the group's title, limited to MAX_NAME_LENGTH
150 * return 0 on success
151 * return -1 on failure
152 */
153int tox_group_set_title(Tox *tox, int groupnumber, const uint8_t *title, uint8_t length)
154{
155 Messenger *m = tox;
156 return group_title_send(m->group_chat_object, groupnumber, title, length);
157}
158
159/* Get group title from groupnumber and put it in title.
160 * title needs to be a valid memory location with a max_length size of at least MAX_NAME_LENGTH (128) bytes.
161 *
162 * return length of copied title if success.
163 * return -1 if failure.
164 */
165int tox_group_get_title(Tox *tox, int groupnumber, uint8_t *title, uint32_t max_length)
166{
167 Messenger *m = tox;
168 return group_title_get(m->group_chat_object, groupnumber, title, max_length);
169}
170
171/* Check if the current peernumber corresponds to ours.
172 *
173 * return 1 if the peernumber corresponds to ours.
174 * return 0 on failure.
175 */
176unsigned int tox_group_peernumber_is_ours(const Tox *tox, int groupnumber, int peernumber)
177{
178 const Messenger *m = tox;
179 return group_peernumber_is_ours(m->group_chat_object, groupnumber, peernumber);
180}
181
182/* Return the number of peers in the group chat on success.
183 * return -1 on failure
184 */
185int tox_group_number_peers(const Tox *tox, int groupnumber)
186{
187 const Messenger *m = tox;
188 return group_number_peers(m->group_chat_object, groupnumber);
189}
190
191/* List all the peers in the group chat.
192 *
193 * Copies the names of the peers to the name[length][MAX_NICK_BYTES] array.
194 *
195 * Copies the lengths of the names to lengths[length]
196 *
197 * returns the number of peers on success.
198 *
199 * return -1 on failure.
200 */
201int tox_group_get_names(const Tox *tox, int groupnumber, uint8_t names[][TOX_MAX_NAME_LENGTH], uint16_t lengths[],
202 uint16_t length)
203{
204 const Messenger *m = tox;
205 return group_names(m->group_chat_object, groupnumber, names, lengths, length);
206}
207
208/* Return the number of chats in the instance m.
209 * You should use this to determine how much memory to allocate
210 * for copy_chatlist. */
211uint32_t tox_count_chatlist(const Tox *tox)
212{
213 const Messenger *m = tox;
214 return count_chatlist(m->group_chat_object);
215}
216
217/* Copy a list of valid chat IDs into the array out_list.
218 * If out_list is NULL, returns 0.
219 * Otherwise, returns the number of elements copied.
220 * If the array was too small, the contents
221 * of out_list will be truncated to list_size. */
222uint32_t tox_get_chatlist(const Tox *tox, int32_t *out_list, uint32_t list_size)
223{
224 const Messenger *m = tox;
225 return copy_chatlist(m->group_chat_object, out_list, list_size);
226}
227
228/* return the type of groupchat (TOX_GROUPCHAT_TYPE_) that groupnumber is.
229 *
230 * return -1 on failure.
231 * return type on success.
232 */
233int tox_group_get_type(const Tox *tox, int groupnumber)
234{
235 const Messenger *m = tox;
236 return group_get_type(m->group_chat_object, groupnumber);
237}