diff options
Diffstat (limited to 'toxcore')
-rw-r--r-- | toxcore/Messenger.c | 2 | ||||
-rw-r--r-- | toxcore/Messenger.h | 2 | ||||
-rw-r--r-- | toxcore/tox.c | 152 | ||||
-rw-r--r-- | toxcore/tox.h | 90 |
4 files changed, 123 insertions, 123 deletions
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index 65f00f30..fe0b7bdf 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c | |||
@@ -1114,7 +1114,7 @@ int del_groupchat(Messenger *m, int groupnumber) | |||
1114 | * return length of name if success | 1114 | * return length of name if success |
1115 | * return -1 if failure | 1115 | * return -1 if failure |
1116 | */ | 1116 | */ |
1117 | int m_group_peername(Messenger *m, int groupnumber, int peernumber, uint8_t *name) | 1117 | int m_group_peername(const Messenger *m, int groupnumber, int peernumber, uint8_t *name) |
1118 | { | 1118 | { |
1119 | if ((unsigned int)groupnumber >= m->numchats) | 1119 | if ((unsigned int)groupnumber >= m->numchats) |
1120 | return -1; | 1120 | return -1; |
diff --git a/toxcore/Messenger.h b/toxcore/Messenger.h index 7bac8bf6..3d85c4e0 100644 --- a/toxcore/Messenger.h +++ b/toxcore/Messenger.h | |||
@@ -570,7 +570,7 @@ int del_groupchat(Messenger *m, int groupnumber); | |||
570 | * return length of name if success | 570 | * return length of name if success |
571 | * return -1 if failure | 571 | * return -1 if failure |
572 | */ | 572 | */ |
573 | int m_group_peername(Messenger *m, int groupnumber, int peernumber, uint8_t *name); | 573 | int m_group_peername(const Messenger *m, int groupnumber, int peernumber, uint8_t *name); |
574 | 574 | ||
575 | /* invite friendnumber to groupnumber | 575 | /* invite friendnumber to groupnumber |
576 | * return 0 on success | 576 | * return 0 on success |
diff --git a/toxcore/tox.c b/toxcore/tox.c index 129f2b07..5afb9185 100644 --- a/toxcore/tox.c +++ b/toxcore/tox.c | |||
@@ -38,9 +38,9 @@ typedef struct Messenger Tox; | |||
38 | * Format: [client_id (32 bytes)][nospam number (4 bytes)][checksum (2 bytes)] | 38 | * Format: [client_id (32 bytes)][nospam number (4 bytes)][checksum (2 bytes)] |
39 | * | 39 | * |
40 | */ | 40 | */ |
41 | void tox_get_address(Tox *tox, uint8_t *address) | 41 | void tox_get_address(const Tox *tox, uint8_t *address) |
42 | { | 42 | { |
43 | Messenger *m = tox; | 43 | const Messenger *m = tox; |
44 | getaddress(m, address); | 44 | getaddress(m, address); |
45 | } | 45 | } |
46 | 46 | ||
@@ -61,7 +61,7 @@ void tox_get_address(Tox *tox, uint8_t *address) | |||
61 | * (the nospam for that friend was set to the new one). | 61 | * (the nospam for that friend was set to the new one). |
62 | * return FAERR_NOMEM if increasing the friend list size fails. | 62 | * return FAERR_NOMEM if increasing the friend list size fails. |
63 | */ | 63 | */ |
64 | int32_t tox_add_friend(Tox *tox, uint8_t *address, uint8_t *data, uint16_t length) | 64 | int32_t tox_add_friend(Tox *tox, const uint8_t *address, const uint8_t *data, uint16_t length) |
65 | { | 65 | { |
66 | Messenger *m = tox; | 66 | Messenger *m = tox; |
67 | return m_addfriend(m, address, data, length); | 67 | return m_addfriend(m, address, data, length); |
@@ -81,9 +81,9 @@ int32_t tox_add_friend_norequest(Tox *tox, const uint8_t *client_id) | |||
81 | /* return the friend number associated to that client id. | 81 | /* return the friend number associated to that client id. |
82 | * return -1 if no such friend. | 82 | * return -1 if no such friend. |
83 | */ | 83 | */ |
84 | int32_t tox_get_friend_number(Tox *tox, uint8_t *client_id) | 84 | int32_t tox_get_friend_number(const Tox *tox, const uint8_t *client_id) |
85 | { | 85 | { |
86 | Messenger *m = tox; | 86 | const Messenger *m = tox; |
87 | return getfriend_id(m, client_id); | 87 | return getfriend_id(m, client_id); |
88 | } | 88 | } |
89 | 89 | ||
@@ -93,9 +93,9 @@ int32_t tox_get_friend_number(Tox *tox, uint8_t *client_id) | |||
93 | * return 0 if success. | 93 | * return 0 if success. |
94 | * return -1 if failure. | 94 | * return -1 if failure. |
95 | */ | 95 | */ |
96 | int tox_get_client_id(Tox *tox, int32_t friendnumber, uint8_t *client_id) | 96 | int tox_get_client_id(const Tox *tox, int32_t friendnumber, uint8_t *client_id) |
97 | { | 97 | { |
98 | Messenger *m = tox; | 98 | const Messenger *m = tox; |
99 | return getclient_id(m, friendnumber, client_id); | 99 | return getclient_id(m, friendnumber, client_id); |
100 | } | 100 | } |
101 | 101 | ||
@@ -112,9 +112,9 @@ int tox_del_friend(Tox *tox, int32_t friendnumber) | |||
112 | * return 0 if friend is not connected to us (Offline). | 112 | * return 0 if friend is not connected to us (Offline). |
113 | * return -1 on failure. | 113 | * return -1 on failure. |
114 | */ | 114 | */ |
115 | int tox_get_friend_connection_status(Tox *tox, int32_t friendnumber) | 115 | int tox_get_friend_connection_status(const Tox *tox, int32_t friendnumber) |
116 | { | 116 | { |
117 | Messenger *m = tox; | 117 | const Messenger *m = tox; |
118 | return m_get_friend_connectionstatus(m, friendnumber); | 118 | return m_get_friend_connectionstatus(m, friendnumber); |
119 | } | 119 | } |
120 | 120 | ||
@@ -123,9 +123,9 @@ int tox_get_friend_connection_status(Tox *tox, int32_t friendnumber) | |||
123 | * return 1 if friend exists. | 123 | * return 1 if friend exists. |
124 | * return 0 if friend doesn't exist. | 124 | * return 0 if friend doesn't exist. |
125 | */ | 125 | */ |
126 | int tox_friend_exists(Tox *tox, int32_t friendnumber) | 126 | int tox_friend_exists(const Tox *tox, int32_t friendnumber) |
127 | { | 127 | { |
128 | Messenger *m = tox; | 128 | const Messenger *m = tox; |
129 | return m_friend_exists(m, friendnumber); | 129 | return m_friend_exists(m, friendnumber); |
130 | } | 130 | } |
131 | 131 | ||
@@ -144,7 +144,7 @@ uint32_t tox_send_message(Tox *tox, int32_t friendnumber, const uint8_t *message | |||
144 | return m_sendmessage(m, friendnumber, message, length); | 144 | return m_sendmessage(m, friendnumber, message, length); |
145 | } | 145 | } |
146 | 146 | ||
147 | uint32_t tox_send_message_withid(Tox *tox, int32_t friendnumber, uint32_t theid, uint8_t *message, uint32_t length) | 147 | uint32_t tox_send_message_withid(Tox *tox, int32_t friendnumber, uint32_t theid, const uint8_t *message, uint32_t length) |
148 | { | 148 | { |
149 | Messenger *m = tox; | 149 | Messenger *m = tox; |
150 | return m_sendmessage_withid(m, friendnumber, theid, message, length); | 150 | return m_sendmessage_withid(m, friendnumber, theid, message, length); |
@@ -160,13 +160,13 @@ uint32_t tox_send_message_withid(Tox *tox, int32_t friendnumber, uint32_t theid, | |||
160 | * m_sendaction_withid will send an action message with the id of your choosing, | 160 | * m_sendaction_withid will send an action message with the id of your choosing, |
161 | * however we can generate an id for you by calling plain m_sendaction. | 161 | * however we can generate an id for you by calling plain m_sendaction. |
162 | */ | 162 | */ |
163 | uint32_t tox_send_action(Tox *tox, int32_t friendnumber, uint8_t *action, uint32_t length) | 163 | uint32_t tox_send_action(Tox *tox, int32_t friendnumber, const uint8_t *action, uint32_t length) |
164 | { | 164 | { |
165 | Messenger *m = tox; | 165 | Messenger *m = tox; |
166 | return m_sendaction(m, friendnumber, action, length); | 166 | return m_sendaction(m, friendnumber, action, length); |
167 | } | 167 | } |
168 | 168 | ||
169 | uint32_t tox_send_action_withid(Tox *tox, int32_t friendnumber, uint32_t theid, uint8_t *action, uint32_t length) | 169 | uint32_t tox_send_action_withid(Tox *tox, int32_t friendnumber, uint32_t theid, const uint8_t *action, uint32_t length) |
170 | { | 170 | { |
171 | Messenger *m = tox; | 171 | Messenger *m = tox; |
172 | return m_sendaction_withid(m, friendnumber, theid, action, length); | 172 | return m_sendaction_withid(m, friendnumber, theid, action, length); |
@@ -180,7 +180,7 @@ uint32_t tox_send_action_withid(Tox *tox, int32_t friendnumber, uint32_t theid, | |||
180 | * return 0 if success. | 180 | * return 0 if success. |
181 | * return -1 if failure. | 181 | * return -1 if failure. |
182 | */ | 182 | */ |
183 | int tox_set_name(Tox *tox, uint8_t *name, uint16_t length) | 183 | int tox_set_name(Tox *tox, const uint8_t *name, uint16_t length) |
184 | { | 184 | { |
185 | Messenger *m = tox; | 185 | Messenger *m = tox; |
186 | return setname(m, name, length); | 186 | return setname(m, name, length); |
@@ -193,9 +193,9 @@ int tox_set_name(Tox *tox, uint8_t *name, uint16_t length) | |||
193 | * return length of the name. | 193 | * return length of the name. |
194 | * return 0 on error. | 194 | * return 0 on error. |
195 | */ | 195 | */ |
196 | uint16_t tox_get_self_name(Tox *tox, uint8_t *name) | 196 | uint16_t tox_get_self_name(const Tox *tox, uint8_t *name) |
197 | { | 197 | { |
198 | Messenger *m = tox; | 198 | const Messenger *m = tox; |
199 | return getself_name(m, name); | 199 | return getself_name(m, name); |
200 | } | 200 | } |
201 | 201 | ||
@@ -205,24 +205,24 @@ uint16_t tox_get_self_name(Tox *tox, uint8_t *name) | |||
205 | * return length of name (with the NULL terminator) if success. | 205 | * return length of name (with the NULL terminator) if success. |
206 | * return -1 if failure. | 206 | * return -1 if failure. |
207 | */ | 207 | */ |
208 | int tox_get_name(Tox *tox, int32_t friendnumber, uint8_t *name) | 208 | int tox_get_name(const Tox *tox, int32_t friendnumber, uint8_t *name) |
209 | { | 209 | { |
210 | Messenger *m = tox; | 210 | const Messenger *m = tox; |
211 | return getname(m, friendnumber, name); | 211 | return getname(m, friendnumber, name); |
212 | } | 212 | } |
213 | 213 | ||
214 | /* returns the length of name on success. | 214 | /* returns the length of name on success. |
215 | * returns -1 on failure. | 215 | * returns -1 on failure. |
216 | */ | 216 | */ |
217 | int tox_get_name_size(Tox *tox, int32_t friendnumber) | 217 | int tox_get_name_size(const Tox *tox, int32_t friendnumber) |
218 | { | 218 | { |
219 | Messenger *m = tox; | 219 | const Messenger *m = tox; |
220 | return m_get_name_size(m, friendnumber); | 220 | return m_get_name_size(m, friendnumber); |
221 | } | 221 | } |
222 | 222 | ||
223 | int tox_get_self_name_size(Tox *tox) | 223 | int tox_get_self_name_size(const Tox *tox) |
224 | { | 224 | { |
225 | Messenger *m = tox; | 225 | const Messenger *m = tox; |
226 | return m_get_self_name_size(m); | 226 | return m_get_self_name_size(m); |
227 | } | 227 | } |
228 | 228 | ||
@@ -231,7 +231,7 @@ int tox_get_self_name_size(Tox *tox) | |||
231 | * | 231 | * |
232 | * return 0 on success, -1 on failure. | 232 | * return 0 on success, -1 on failure. |
233 | */ | 233 | */ |
234 | int tox_set_status_message(Tox *tox, uint8_t *status, uint16_t length) | 234 | int tox_set_status_message(Tox *tox, const uint8_t *status, uint16_t length) |
235 | { | 235 | { |
236 | Messenger *m = tox; | 236 | Messenger *m = tox; |
237 | return m_set_statusmessage(m, status, length); | 237 | return m_set_statusmessage(m, status, length); |
@@ -246,15 +246,15 @@ int tox_set_user_status(Tox *tox, uint8_t status) | |||
246 | /* returns the length of status message on success. | 246 | /* returns the length of status message on success. |
247 | * returns -1 on failure. | 247 | * returns -1 on failure. |
248 | */ | 248 | */ |
249 | int tox_get_status_message_size(Tox *tox, int32_t friendnumber) | 249 | int tox_get_status_message_size(const Tox *tox, int32_t friendnumber) |
250 | { | 250 | { |
251 | Messenger *m = tox; | 251 | const Messenger *m = tox; |
252 | return m_get_statusmessage_size(m, friendnumber); | 252 | return m_get_statusmessage_size(m, friendnumber); |
253 | } | 253 | } |
254 | 254 | ||
255 | int tox_get_self_status_message_size(Tox *tox) | 255 | int tox_get_self_status_message_size(const Tox *tox) |
256 | { | 256 | { |
257 | Messenger *m = tox; | 257 | const Messenger *m = tox; |
258 | return m_get_self_statusmessage_size(m); | 258 | return m_get_self_statusmessage_size(m); |
259 | } | 259 | } |
260 | 260 | ||
@@ -262,15 +262,15 @@ int tox_get_self_status_message_size(Tox *tox) | |||
262 | * Get the size you need to allocate from m_get_statusmessage_size. | 262 | * Get the size you need to allocate from m_get_statusmessage_size. |
263 | * The self variant will copy our own status message. | 263 | * The self variant will copy our own status message. |
264 | */ | 264 | */ |
265 | int tox_get_status_message(Tox *tox, int32_t friendnumber, uint8_t *buf, uint32_t maxlen) | 265 | int tox_get_status_message(const Tox *tox, int32_t friendnumber, uint8_t *buf, uint32_t maxlen) |
266 | { | 266 | { |
267 | Messenger *m = tox; | 267 | const Messenger *m = tox; |
268 | return m_copy_statusmessage(m, friendnumber, buf, maxlen); | 268 | return m_copy_statusmessage(m, friendnumber, buf, maxlen); |
269 | } | 269 | } |
270 | 270 | ||
271 | int tox_get_self_status_message(Tox *tox, uint8_t *buf, uint32_t maxlen) | 271 | int tox_get_self_status_message(const Tox *tox, uint8_t *buf, uint32_t maxlen) |
272 | { | 272 | { |
273 | Messenger *m = tox; | 273 | const Messenger *m = tox; |
274 | return m_copy_self_statusmessage(m, buf, maxlen); | 274 | return m_copy_self_statusmessage(m, buf, maxlen); |
275 | } | 275 | } |
276 | 276 | ||
@@ -279,24 +279,24 @@ int tox_get_self_status_message(Tox *tox, uint8_t *buf, uint32_t maxlen) | |||
279 | * As above, the self variant will return our own USERSTATUS. | 279 | * As above, the self variant will return our own USERSTATUS. |
280 | * If friendnumber is invalid, this shall return USERSTATUS_INVALID. | 280 | * If friendnumber is invalid, this shall return USERSTATUS_INVALID. |
281 | */ | 281 | */ |
282 | uint8_t tox_get_user_status(Tox *tox, int32_t friendnumber) | 282 | uint8_t tox_get_user_status(const Tox *tox, int32_t friendnumber) |
283 | { | 283 | { |
284 | Messenger *m = tox; | 284 | const Messenger *m = tox; |
285 | return m_get_userstatus(m, friendnumber); | 285 | return m_get_userstatus(m, friendnumber); |
286 | } | 286 | } |
287 | 287 | ||
288 | uint8_t tox_get_self_user_status(Tox *tox) | 288 | uint8_t tox_get_self_user_status(const Tox *tox) |
289 | { | 289 | { |
290 | Messenger *m = tox; | 290 | const Messenger *m = tox; |
291 | return m_get_self_userstatus(m); | 291 | return m_get_self_userstatus(m); |
292 | } | 292 | } |
293 | 293 | ||
294 | /* returns timestamp of last time friendnumber was seen online, or 0 if never seen. | 294 | /* returns timestamp of last time friendnumber was seen online, or 0 if never seen. |
295 | * returns -1 on error. | 295 | * returns -1 on error. |
296 | */ | 296 | */ |
297 | uint64_t tox_get_last_online(Tox *tox, int32_t friendnumber) | 297 | uint64_t tox_get_last_online(const Tox *tox, int32_t friendnumber) |
298 | { | 298 | { |
299 | Messenger *m = tox; | 299 | const Messenger *m = tox; |
300 | return m_get_last_online(m, friendnumber); | 300 | return m_get_last_online(m, friendnumber); |
301 | } | 301 | } |
302 | 302 | ||
@@ -317,9 +317,9 @@ int tox_set_user_is_typing(Tox *tox, int32_t friendnumber, uint8_t is_typing) | |||
317 | * returns 0 if friend is not typing. | 317 | * returns 0 if friend is not typing. |
318 | * returns 1 if friend is typing. | 318 | * returns 1 if friend is typing. |
319 | */ | 319 | */ |
320 | uint8_t tox_get_is_typing(Tox *tox, int32_t friendnumber) | 320 | uint8_t tox_get_is_typing(const Tox *tox, int32_t friendnumber) |
321 | { | 321 | { |
322 | Messenger *m = tox; | 322 | const Messenger *m = tox; |
323 | return m_get_istyping(m, friendnumber); | 323 | return m_get_istyping(m, friendnumber); |
324 | } | 324 | } |
325 | 325 | ||
@@ -335,16 +335,16 @@ void tox_set_sends_receipts(Tox *tox, int32_t friendnumber, int yesno) | |||
335 | /* Return the number of friends in the instance m. | 335 | /* Return the number of friends in the instance m. |
336 | * You should use this to determine how much memory to allocate | 336 | * You should use this to determine how much memory to allocate |
337 | * for copy_friendlist. */ | 337 | * for copy_friendlist. */ |
338 | uint32_t tox_count_friendlist(Tox *tox) | 338 | uint32_t tox_count_friendlist(const Tox *tox) |
339 | { | 339 | { |
340 | Messenger *m = tox; | 340 | const Messenger *m = tox; |
341 | return count_friendlist(m); | 341 | return count_friendlist(m); |
342 | } | 342 | } |
343 | 343 | ||
344 | /* Return the number of online friends in the instance m. */ | 344 | /* Return the number of online friends in the instance m. */ |
345 | uint32_t tox_get_num_online_friends(Tox *tox) | 345 | uint32_t tox_get_num_online_friends(const Tox *tox) |
346 | { | 346 | { |
347 | Messenger *m = tox; | 347 | const Messenger *m = tox; |
348 | return get_num_online_friends(m); | 348 | return get_num_online_friends(m); |
349 | } | 349 | } |
350 | 350 | ||
@@ -353,9 +353,9 @@ uint32_t tox_get_num_online_friends(Tox *tox) | |||
353 | * Otherwise, returns the number of elements copied. | 353 | * Otherwise, returns the number of elements copied. |
354 | * If the array was too small, the contents | 354 | * If the array was too small, the contents |
355 | * of out_list will be truncated to list_size. */ | 355 | * of out_list will be truncated to list_size. */ |
356 | uint32_t tox_get_friendlist(Tox *tox, int32_t *out_list, uint32_t list_size) | 356 | uint32_t tox_get_friendlist(const Tox *tox, int32_t *out_list, uint32_t list_size) |
357 | { | 357 | { |
358 | Messenger *m = tox; | 358 | const Messenger *m = tox; |
359 | return copy_friendlist(m, out_list, list_size); | 359 | return copy_friendlist(m, out_list, list_size); |
360 | } | 360 | } |
361 | 361 | ||
@@ -468,9 +468,9 @@ void tox_callback_connection_status(Tox *tox, void (*function)(Messenger *tox, i | |||
468 | 468 | ||
469 | /* Functions to get/set the nospam part of the id. | 469 | /* Functions to get/set the nospam part of the id. |
470 | */ | 470 | */ |
471 | uint32_t tox_get_nospam(Tox *tox) | 471 | uint32_t tox_get_nospam(const Tox *tox) |
472 | { | 472 | { |
473 | Messenger *m = tox; | 473 | const Messenger *m = tox; |
474 | return get_nospam(&(m->fr)); | 474 | return get_nospam(&(m->fr)); |
475 | } | 475 | } |
476 | 476 | ||
@@ -552,9 +552,9 @@ int tox_del_groupchat(Tox *tox, int groupnumber) | |||
552 | * return length of name if success | 552 | * return length of name if success |
553 | * return -1 if failure | 553 | * return -1 if failure |
554 | */ | 554 | */ |
555 | int tox_group_peername(Tox *tox, int groupnumber, int peernumber, uint8_t *name) | 555 | int tox_group_peername(const Tox *tox, int groupnumber, int peernumber, uint8_t *name) |
556 | { | 556 | { |
557 | Messenger *m = tox; | 557 | const Messenger *m = tox; |
558 | return m_group_peername(m, groupnumber, peernumber, name); | 558 | return m_group_peername(m, groupnumber, peernumber, name); |
559 | } | 559 | } |
560 | /* invite friendnumber to groupnumber | 560 | /* invite friendnumber to groupnumber |
@@ -571,7 +571,7 @@ int tox_invite_friend(Tox *tox, int32_t friendnumber, int groupnumber) | |||
571 | * returns group number on success | 571 | * returns group number on success |
572 | * returns -1 on failure. | 572 | * returns -1 on failure. |
573 | */ | 573 | */ |
574 | int tox_join_groupchat(Tox *tox, int32_t friendnumber, uint8_t *friend_group_public_key) | 574 | int tox_join_groupchat(Tox *tox, int32_t friendnumber, const uint8_t *friend_group_public_key) |
575 | { | 575 | { |
576 | Messenger *m = tox; | 576 | Messenger *m = tox; |
577 | return join_groupchat(m, friendnumber, friend_group_public_key); | 577 | return join_groupchat(m, friendnumber, friend_group_public_key); |
@@ -581,7 +581,7 @@ int tox_join_groupchat(Tox *tox, int32_t friendnumber, uint8_t *friend_group_pub | |||
581 | * return 0 on success | 581 | * return 0 on success |
582 | * return -1 on failure | 582 | * return -1 on failure |
583 | */ | 583 | */ |
584 | int tox_group_message_send(Tox *tox, int groupnumber, uint8_t *message, uint32_t length) | 584 | int tox_group_message_send(Tox *tox, int groupnumber, const uint8_t *message, uint32_t length) |
585 | { | 585 | { |
586 | Messenger *m = tox; | 586 | Messenger *m = tox; |
587 | return group_message_send(m, groupnumber, message, length); | 587 | return group_message_send(m, groupnumber, message, length); |
@@ -591,7 +591,7 @@ int tox_group_message_send(Tox *tox, int groupnumber, uint8_t *message, uint32_t | |||
591 | * return 0 on success | 591 | * return 0 on success |
592 | * return -1 on failure | 592 | * return -1 on failure |
593 | */ | 593 | */ |
594 | int tox_group_action_send(Tox *tox, int groupnumber, uint8_t *action, uint32_t length) | 594 | int tox_group_action_send(Tox *tox, int groupnumber, const uint8_t *action, uint32_t length) |
595 | { | 595 | { |
596 | Messenger *m = tox; | 596 | Messenger *m = tox; |
597 | return group_action_send(m, groupnumber, action, length); | 597 | return group_action_send(m, groupnumber, action, length); |
@@ -600,9 +600,9 @@ int tox_group_action_send(Tox *tox, int groupnumber, uint8_t *action, uint32_t l | |||
600 | /* Return the number of peers in the group chat on success. | 600 | /* Return the number of peers in the group chat on success. |
601 | * return -1 on failure | 601 | * return -1 on failure |
602 | */ | 602 | */ |
603 | int tox_group_number_peers(Tox *tox, int groupnumber) | 603 | int tox_group_number_peers(const Tox *tox, int groupnumber) |
604 | { | 604 | { |
605 | Messenger *m = tox; | 605 | const Messenger *m = tox; |
606 | return group_number_peers(m, groupnumber); | 606 | return group_number_peers(m, groupnumber); |
607 | } | 607 | } |
608 | 608 | ||
@@ -616,19 +616,19 @@ int tox_group_number_peers(Tox *tox, int groupnumber) | |||
616 | * | 616 | * |
617 | * return -1 on failure. | 617 | * return -1 on failure. |
618 | */ | 618 | */ |
619 | int tox_group_get_names(Tox *tox, int groupnumber, uint8_t names[][TOX_MAX_NAME_LENGTH], uint16_t lengths[], | 619 | int tox_group_get_names(const Tox *tox, int groupnumber, uint8_t names[][TOX_MAX_NAME_LENGTH], uint16_t lengths[], |
620 | uint16_t length) | 620 | uint16_t length) |
621 | { | 621 | { |
622 | Messenger *m = tox; | 622 | const Messenger *m = tox; |
623 | return group_names(m, groupnumber, names, lengths, length); | 623 | return group_names(m, groupnumber, names, lengths, length); |
624 | } | 624 | } |
625 | 625 | ||
626 | /* Return the number of chats in the instance m. | 626 | /* Return the number of chats in the instance m. |
627 | * You should use this to determine how much memory to allocate | 627 | * You should use this to determine how much memory to allocate |
628 | * for copy_chatlist. */ | 628 | * for copy_chatlist. */ |
629 | uint32_t tox_count_chatlist(Tox *tox) | 629 | uint32_t tox_count_chatlist(const Tox *tox) |
630 | { | 630 | { |
631 | Messenger *m = tox; | 631 | const Messenger *m = tox; |
632 | return count_chatlist(m); | 632 | return count_chatlist(m); |
633 | } | 633 | } |
634 | 634 | ||
@@ -637,9 +637,9 @@ uint32_t tox_count_chatlist(Tox *tox) | |||
637 | * Otherwise, returns the number of elements copied. | 637 | * Otherwise, returns the number of elements copied. |
638 | * If the array was too small, the contents | 638 | * If the array was too small, the contents |
639 | * of out_list will be truncated to list_size. */ | 639 | * of out_list will be truncated to list_size. */ |
640 | uint32_t tox_get_chatlist(Tox *tox, int *out_list, uint32_t list_size) | 640 | uint32_t tox_get_chatlist(const Tox *tox, int *out_list, uint32_t list_size) |
641 | { | 641 | { |
642 | Messenger *m = tox; | 642 | const Messenger *m = tox; |
643 | return copy_chatlist(m, out_list, list_size); | 643 | return copy_chatlist(m, out_list, list_size); |
644 | } | 644 | } |
645 | 645 | ||
@@ -687,7 +687,7 @@ void tox_callback_file_data(Tox *tox, void (*function)(Messenger *tox, int32_t, | |||
687 | * return file number on success | 687 | * return file number on success |
688 | * return -1 on failure | 688 | * return -1 on failure |
689 | */ | 689 | */ |
690 | int tox_new_file_sender(Tox *tox, int32_t friendnumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length) | 690 | int tox_new_file_sender(Tox *tox, int32_t friendnumber, uint64_t filesize, const uint8_t *filename, uint16_t filename_length) |
691 | { | 691 | { |
692 | Messenger *m = tox; | 692 | Messenger *m = tox; |
693 | return new_filesender(m, friendnumber, filesize, filename, filename_length); | 693 | return new_filesender(m, friendnumber, filesize, filename, filename_length); |
@@ -699,7 +699,7 @@ int tox_new_file_sender(Tox *tox, int32_t friendnumber, uint64_t filesize, uint8 | |||
699 | * return -1 on failure | 699 | * return -1 on failure |
700 | */ | 700 | */ |
701 | int tox_file_send_control(Tox *tox, int32_t friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t message_id, | 701 | int tox_file_send_control(Tox *tox, int32_t friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t message_id, |
702 | uint8_t *data, uint16_t length) | 702 | const uint8_t *data, uint16_t length) |
703 | { | 703 | { |
704 | Messenger *m = tox; | 704 | Messenger *m = tox; |
705 | return file_control(m, friendnumber, send_receive, filenumber, message_id, data, length); | 705 | return file_control(m, friendnumber, send_receive, filenumber, message_id, data, length); |
@@ -709,7 +709,7 @@ int tox_file_send_control(Tox *tox, int32_t friendnumber, uint8_t send_receive, | |||
709 | * return 0 on success | 709 | * return 0 on success |
710 | * return -1 on failure | 710 | * return -1 on failure |
711 | */ | 711 | */ |
712 | int tox_file_send_data(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length) | 712 | int tox_file_send_data(Tox *tox, int32_t friendnumber, uint8_t filenumber, const uint8_t *data, uint16_t length) |
713 | { | 713 | { |
714 | Messenger *m = tox; | 714 | Messenger *m = tox; |
715 | return file_data(m, friendnumber, filenumber, data, length); | 715 | return file_data(m, friendnumber, filenumber, data, length); |
@@ -720,7 +720,7 @@ int tox_file_send_data(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint8 | |||
720 | * return size on success | 720 | * return size on success |
721 | * return -1 on failure (currently will never return -1) | 721 | * return -1 on failure (currently will never return -1) |
722 | */ | 722 | */ |
723 | int tox_file_data_size(Tox *tox, int32_t friendnumber) | 723 | int tox_file_data_size(const Tox *tox, int32_t friendnumber) |
724 | { | 724 | { |
725 | return MAX_CRYPTO_DATA_SIZE - 2; | 725 | return MAX_CRYPTO_DATA_SIZE - 2; |
726 | } | 726 | } |
@@ -732,16 +732,16 @@ int tox_file_data_size(Tox *tox, int32_t friendnumber) | |||
732 | * return number of bytes remaining to be sent/received on success | 732 | * return number of bytes remaining to be sent/received on success |
733 | * return 0 on failure | 733 | * return 0 on failure |
734 | */ | 734 | */ |
735 | uint64_t tox_file_data_remaining(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint8_t send_receive) | 735 | uint64_t tox_file_data_remaining(const Tox *tox, int32_t friendnumber, uint8_t filenumber, uint8_t send_receive) |
736 | { | 736 | { |
737 | Messenger *m = tox; | 737 | const Messenger *m = tox; |
738 | return file_dataremaining(m, friendnumber, filenumber, send_receive); | 738 | return file_dataremaining(m, friendnumber, filenumber, send_receive); |
739 | } | 739 | } |
740 | 740 | ||
741 | /***************END OF FILE SENDING FUNCTIONS******************/ | 741 | /***************END OF FILE SENDING FUNCTIONS******************/ |
742 | 742 | ||
743 | /* TODO: expose this properly. */ | 743 | /* TODO: expose this properly. */ |
744 | static int tox_add_tcp_relay(Tox *tox, const char *address, uint8_t ipv6enabled, uint16_t port, uint8_t *public_key) | 744 | static int tox_add_tcp_relay(Tox *tox, const char *address, uint8_t ipv6enabled, uint16_t port, const uint8_t *public_key) |
745 | { | 745 | { |
746 | Messenger *m = tox; | 746 | Messenger *m = tox; |
747 | IP_Port ip_port_v64; | 747 | IP_Port ip_port_v64; |
@@ -766,7 +766,7 @@ static int tox_add_tcp_relay(Tox *tox, const char *address, uint8_t ipv6enabled, | |||
766 | } | 766 | } |
767 | 767 | ||
768 | int tox_bootstrap_from_address(Tox *tox, const char *address, | 768 | int tox_bootstrap_from_address(Tox *tox, const char *address, |
769 | uint8_t ipv6enabled, uint16_t port, uint8_t *public_key) | 769 | uint8_t ipv6enabled, uint16_t port, const uint8_t *public_key) |
770 | { | 770 | { |
771 | Messenger *m = tox; | 771 | Messenger *m = tox; |
772 | tox_add_tcp_relay(tox, address, ipv6enabled, port, public_key); | 772 | tox_add_tcp_relay(tox, address, ipv6enabled, port, public_key); |
@@ -776,9 +776,9 @@ int tox_bootstrap_from_address(Tox *tox, const char *address, | |||
776 | /* return 0 if we are not connected to the DHT. | 776 | /* return 0 if we are not connected to the DHT. |
777 | * return 1 if we are. | 777 | * return 1 if we are. |
778 | */ | 778 | */ |
779 | int tox_isconnected(Tox *tox) | 779 | int tox_isconnected(const Tox *tox) |
780 | { | 780 | { |
781 | Messenger *m = tox; | 781 | const Messenger *m = tox; |
782 | return DHT_isconnected(m->dht); | 782 | return DHT_isconnected(m->dht); |
783 | } | 783 | } |
784 | 784 | ||
@@ -823,21 +823,21 @@ void tox_do(Tox *tox) | |||
823 | /* SAVING AND LOADING FUNCTIONS: */ | 823 | /* SAVING AND LOADING FUNCTIONS: */ |
824 | 824 | ||
825 | /* return size of the messenger data (for saving). */ | 825 | /* return size of the messenger data (for saving). */ |
826 | uint32_t tox_size(Tox *tox) | 826 | uint32_t tox_size(const Tox *tox) |
827 | { | 827 | { |
828 | Messenger *m = tox; | 828 | const Messenger *m = tox; |
829 | return messenger_size(m); | 829 | return messenger_size(m); |
830 | } | 830 | } |
831 | 831 | ||
832 | /* Save the messenger in data (must be allocated memory of size Messenger_size()). */ | 832 | /* Save the messenger in data (must be allocated memory of size Messenger_size()). */ |
833 | void tox_save(Tox *tox, uint8_t *data) | 833 | void tox_save(const Tox *tox, uint8_t *data) |
834 | { | 834 | { |
835 | Messenger *m = tox; | 835 | const Messenger *m = tox; |
836 | messenger_save(m, data); | 836 | messenger_save(m, data); |
837 | } | 837 | } |
838 | 838 | ||
839 | /* Load the messenger from data of size length. */ | 839 | /* Load the messenger from data of size length. */ |
840 | int tox_load(Tox *tox, uint8_t *data, uint32_t length) | 840 | int tox_load(Tox *tox, const uint8_t *data, uint32_t length) |
841 | { | 841 | { |
842 | Messenger *m = tox; | 842 | Messenger *m = tox; |
843 | return messenger_load(m, data, length); | 843 | return messenger_load(m, data, length); |
diff --git a/toxcore/tox.h b/toxcore/tox.h index 65088ebb..fdff44d1 100644 --- a/toxcore/tox.h +++ b/toxcore/tox.h | |||
@@ -82,7 +82,7 @@ typedef struct Tox Tox; | |||
82 | /* return TOX_FRIEND_ADDRESS_SIZE byte address to give to others. | 82 | /* return TOX_FRIEND_ADDRESS_SIZE byte address to give to others. |
83 | * format: [client_id (32 bytes)][nospam number (4 bytes)][checksum (2 bytes)] | 83 | * format: [client_id (32 bytes)][nospam number (4 bytes)][checksum (2 bytes)] |
84 | */ | 84 | */ |
85 | void tox_get_address(Tox *tox, uint8_t *address); | 85 | void tox_get_address(const Tox *tox, uint8_t *address); |
86 | 86 | ||
87 | /* Add a friend. | 87 | /* Add a friend. |
88 | * Set the data that will be sent along with friend request. | 88 | * Set the data that will be sent along with friend request. |
@@ -100,7 +100,7 @@ void tox_get_address(Tox *tox, uint8_t *address); | |||
100 | * (the nospam for that friend was set to the new one). | 100 | * (the nospam for that friend was set to the new one). |
101 | * return TOX_FAERR_NOMEM if increasing the friend list size fails. | 101 | * return TOX_FAERR_NOMEM if increasing the friend list size fails. |
102 | */ | 102 | */ |
103 | int32_t tox_add_friend(Tox *tox, uint8_t *address, uint8_t *data, uint16_t length); | 103 | int32_t tox_add_friend(Tox *tox, const uint8_t *address, const uint8_t *data, uint16_t length); |
104 | 104 | ||
105 | 105 | ||
106 | /* Add a friend without sending a friendrequest. | 106 | /* Add a friend without sending a friendrequest. |
@@ -111,14 +111,14 @@ int32_t tox_add_friend_norequest(Tox *tox, const uint8_t *client_id); | |||
111 | 111 | ||
112 | /* return the friend number associated to that client id. | 112 | /* return the friend number associated to that client id. |
113 | return -1 if no such friend */ | 113 | return -1 if no such friend */ |
114 | int32_t tox_get_friend_number(Tox *tox, uint8_t *client_id); | 114 | int32_t tox_get_friend_number(const Tox *tox, const uint8_t *client_id); |
115 | 115 | ||
116 | /* Copies the public key associated to that friend id into client_id buffer. | 116 | /* Copies the public key associated to that friend id into client_id buffer. |
117 | * Make sure that client_id is of size CLIENT_ID_SIZE. | 117 | * Make sure that client_id is of size CLIENT_ID_SIZE. |
118 | * return 0 if success. | 118 | * return 0 if success. |
119 | * return -1 if failure. | 119 | * return -1 if failure. |
120 | */ | 120 | */ |
121 | int tox_get_client_id(Tox *tox, int32_t friendnumber, uint8_t *client_id); | 121 | int tox_get_client_id(const Tox *tox, int32_t friendnumber, uint8_t *client_id); |
122 | 122 | ||
123 | /* Remove a friend. | 123 | /* Remove a friend. |
124 | * | 124 | * |
@@ -133,14 +133,14 @@ int tox_del_friend(Tox *tox, int32_t friendnumber); | |||
133 | * return 0 if friend is not connected to us (Offline). | 133 | * return 0 if friend is not connected to us (Offline). |
134 | * return -1 on failure. | 134 | * return -1 on failure. |
135 | */ | 135 | */ |
136 | int tox_get_friend_connection_status(Tox *tox, int32_t friendnumber); | 136 | int tox_get_friend_connection_status(const Tox *tox, int32_t friendnumber); |
137 | 137 | ||
138 | /* Checks if there exists a friend with given friendnumber. | 138 | /* Checks if there exists a friend with given friendnumber. |
139 | * | 139 | * |
140 | * return 1 if friend exists. | 140 | * return 1 if friend exists. |
141 | * return 0 if friend doesn't exist. | 141 | * return 0 if friend doesn't exist. |
142 | */ | 142 | */ |
143 | int tox_friend_exists(Tox *tox, int32_t friendnumber); | 143 | int tox_friend_exists(const Tox *tox, int32_t friendnumber); |
144 | 144 | ||
145 | /* Send a text chat message to an online friend. | 145 | /* Send a text chat message to an online friend. |
146 | * | 146 | * |
@@ -157,7 +157,7 @@ int tox_friend_exists(Tox *tox, int32_t friendnumber); | |||
157 | * however we can generate an id for you by calling plain m_sendmessage. | 157 | * however we can generate an id for you by calling plain m_sendmessage. |
158 | */ | 158 | */ |
159 | uint32_t tox_send_message(Tox *tox, int32_t friendnumber, const uint8_t *message, uint32_t length); | 159 | uint32_t tox_send_message(Tox *tox, int32_t friendnumber, const uint8_t *message, uint32_t length); |
160 | uint32_t tox_send_message_withid(Tox *tox, int32_t friendnumber, uint32_t theid, uint8_t *message, uint32_t length); | 160 | uint32_t tox_send_message_withid(Tox *tox, int32_t friendnumber, uint32_t theid, const uint8_t *message, uint32_t length); |
161 | 161 | ||
162 | /* Send an action to an online friend. | 162 | /* Send an action to an online friend. |
163 | * | 163 | * |
@@ -173,8 +173,8 @@ uint32_t tox_send_message_withid(Tox *tox, int32_t friendnumber, uint32_t theid, | |||
173 | * m_sendaction_withid will send an action message with the id of your choosing, | 173 | * m_sendaction_withid will send an action message with the id of your choosing, |
174 | * however we can generate an id for you by calling plain m_sendaction. | 174 | * however we can generate an id for you by calling plain m_sendaction. |
175 | */ | 175 | */ |
176 | uint32_t tox_send_action(Tox *tox, int32_t friendnumber, uint8_t *action, uint32_t length); | 176 | uint32_t tox_send_action(Tox *tox, int32_t friendnumber, const uint8_t *action, uint32_t length); |
177 | uint32_t tox_send_action_withid(Tox *tox, int32_t friendnumber, uint32_t theid, uint8_t *action, uint32_t length); | 177 | uint32_t tox_send_action_withid(Tox *tox, int32_t friendnumber, uint32_t theid, const uint8_t *action, uint32_t length); |
178 | 178 | ||
179 | /* Set our nickname. | 179 | /* Set our nickname. |
180 | * name must be a string of maximum MAX_NAME_LENGTH length. | 180 | * name must be a string of maximum MAX_NAME_LENGTH length. |
@@ -184,7 +184,7 @@ uint32_t tox_send_action_withid(Tox *tox, int32_t friendnumber, uint32_t theid, | |||
184 | * return 0 if success. | 184 | * return 0 if success. |
185 | * return -1 if failure. | 185 | * return -1 if failure. |
186 | */ | 186 | */ |
187 | int tox_set_name(Tox *tox, uint8_t *name, uint16_t length); | 187 | int tox_set_name(Tox *tox, const uint8_t *name, uint16_t length); |
188 | 188 | ||
189 | /* | 189 | /* |
190 | * Get your nickname. | 190 | * Get your nickname. |
@@ -194,7 +194,7 @@ int tox_set_name(Tox *tox, uint8_t *name, uint16_t length); | |||
194 | * return length of name. | 194 | * return length of name. |
195 | * return 0 on error. | 195 | * return 0 on error. |
196 | */ | 196 | */ |
197 | uint16_t tox_get_self_name(Tox *tox, uint8_t *name); | 197 | uint16_t tox_get_self_name(const Tox *tox, uint8_t *name); |
198 | 198 | ||
199 | /* Get name of friendnumber and put it in name. | 199 | /* Get name of friendnumber and put it in name. |
200 | * name needs to be a valid memory location with a size of at least MAX_NAME_LENGTH (128) bytes. | 200 | * name needs to be a valid memory location with a size of at least MAX_NAME_LENGTH (128) bytes. |
@@ -202,13 +202,13 @@ uint16_t tox_get_self_name(Tox *tox, uint8_t *name); | |||
202 | * return length of name if success. | 202 | * return length of name if success. |
203 | * return -1 if failure. | 203 | * return -1 if failure. |
204 | */ | 204 | */ |
205 | int tox_get_name(Tox *tox, int32_t friendnumber, uint8_t *name); | 205 | int tox_get_name(const Tox *tox, int32_t friendnumber, uint8_t *name); |
206 | 206 | ||
207 | /* returns the length of name on success. | 207 | /* returns the length of name on success. |
208 | * returns -1 on failure. | 208 | * returns -1 on failure. |
209 | */ | 209 | */ |
210 | int tox_get_name_size(Tox *tox, int32_t friendnumber); | 210 | int tox_get_name_size(const Tox *tox, int32_t friendnumber); |
211 | int tox_get_self_name_size(Tox *tox); | 211 | int tox_get_self_name_size(const Tox *tox); |
212 | 212 | ||
213 | /* Set our user status. | 213 | /* Set our user status. |
214 | * | 214 | * |
@@ -218,14 +218,14 @@ int tox_get_self_name_size(Tox *tox); | |||
218 | * returns 0 on success. | 218 | * returns 0 on success. |
219 | * returns -1 on failure. | 219 | * returns -1 on failure. |
220 | */ | 220 | */ |
221 | int tox_set_status_message(Tox *tox, uint8_t *status, uint16_t length); | 221 | int tox_set_status_message(Tox *tox, const uint8_t *status, uint16_t length); |
222 | int tox_set_user_status(Tox *tox, uint8_t userstatus); | 222 | int tox_set_user_status(Tox *tox, uint8_t userstatus); |
223 | 223 | ||
224 | /* returns the length of status message on success. | 224 | /* returns the length of status message on success. |
225 | * returns -1 on failure. | 225 | * returns -1 on failure. |
226 | */ | 226 | */ |
227 | int tox_get_status_message_size(Tox *tox, int32_t friendnumber); | 227 | int tox_get_status_message_size(const Tox *tox, int32_t friendnumber); |
228 | int tox_get_self_status_message_size(Tox *tox); | 228 | int tox_get_self_status_message_size(const Tox *tox); |
229 | 229 | ||
230 | /* Copy friendnumber's status message into buf, truncating if size is over maxlen. | 230 | /* Copy friendnumber's status message into buf, truncating if size is over maxlen. |
231 | * Get the size you need to allocate from m_get_statusmessage_size. | 231 | * Get the size you need to allocate from m_get_statusmessage_size. |
@@ -234,22 +234,22 @@ int tox_get_self_status_message_size(Tox *tox); | |||
234 | * returns the length of the copied data on success | 234 | * returns the length of the copied data on success |
235 | * retruns -1 on failure. | 235 | * retruns -1 on failure. |
236 | */ | 236 | */ |
237 | int tox_get_status_message(Tox *tox, int32_t friendnumber, uint8_t *buf, uint32_t maxlen); | 237 | int tox_get_status_message(const Tox *tox, int32_t friendnumber, uint8_t *buf, uint32_t maxlen); |
238 | int tox_get_self_status_message(Tox *tox, uint8_t *buf, uint32_t maxlen); | 238 | int tox_get_self_status_message(const Tox *tox, uint8_t *buf, uint32_t maxlen); |
239 | 239 | ||
240 | /* return one of TOX_USERSTATUS values. | 240 | /* return one of TOX_USERSTATUS values. |
241 | * Values unknown to your application should be represented as TOX_USERSTATUS_NONE. | 241 | * Values unknown to your application should be represented as TOX_USERSTATUS_NONE. |
242 | * As above, the self variant will return our own TOX_USERSTATUS. | 242 | * As above, the self variant will return our own TOX_USERSTATUS. |
243 | * If friendnumber is invalid, this shall return TOX_USERSTATUS_INVALID. | 243 | * If friendnumber is invalid, this shall return TOX_USERSTATUS_INVALID. |
244 | */ | 244 | */ |
245 | uint8_t tox_get_user_status(Tox *tox, int32_t friendnumber); | 245 | uint8_t tox_get_user_status(const Tox *tox, int32_t friendnumber); |
246 | uint8_t tox_get_self_user_status(Tox *tox); | 246 | uint8_t tox_get_self_user_status(const Tox *tox); |
247 | 247 | ||
248 | 248 | ||
249 | /* returns timestamp of last time friendnumber was seen online, or 0 if never seen. | 249 | /* returns timestamp of last time friendnumber was seen online, or 0 if never seen. |
250 | * returns -1 on error. | 250 | * returns -1 on error. |
251 | */ | 251 | */ |
252 | uint64_t tox_get_last_online(Tox *tox, int32_t friendnumber); | 252 | uint64_t tox_get_last_online(const Tox *tox, int32_t friendnumber); |
253 | 253 | ||
254 | /* Set our typing status for a friend. | 254 | /* Set our typing status for a friend. |
255 | * You are responsible for turning it on or off. | 255 | * You are responsible for turning it on or off. |
@@ -264,7 +264,7 @@ int tox_set_user_is_typing(Tox *tox, int32_t friendnumber, uint8_t is_typing); | |||
264 | * returns 0 if friend is not typing. | 264 | * returns 0 if friend is not typing. |
265 | * returns 1 if friend is typing. | 265 | * returns 1 if friend is typing. |
266 | */ | 266 | */ |
267 | uint8_t tox_get_is_typing(Tox *tox, int32_t friendnumber); | 267 | uint8_t tox_get_is_typing(const Tox *tox, int32_t friendnumber); |
268 | 268 | ||
269 | /* Sets whether we send read receipts for friendnumber. | 269 | /* Sets whether we send read receipts for friendnumber. |
270 | * This function is not lazy, and it will fail if yesno is not (0 or 1). | 270 | * This function is not lazy, and it will fail if yesno is not (0 or 1). |
@@ -274,17 +274,17 @@ void tox_set_sends_receipts(Tox *tox, int32_t friendnumber, int yesno); | |||
274 | /* Return the number of friends in the instance m. | 274 | /* Return the number of friends in the instance m. |
275 | * You should use this to determine how much memory to allocate | 275 | * You should use this to determine how much memory to allocate |
276 | * for copy_friendlist. */ | 276 | * for copy_friendlist. */ |
277 | uint32_t tox_count_friendlist(Tox *tox); | 277 | uint32_t tox_count_friendlist(const Tox *tox); |
278 | 278 | ||
279 | /* Return the number of online friends in the instance m. */ | 279 | /* Return the number of online friends in the instance m. */ |
280 | uint32_t tox_get_num_online_friends(Tox *tox); | 280 | uint32_t tox_get_num_online_friends(const Tox *tox); |
281 | 281 | ||
282 | /* Copy a list of valid friend IDs into the array out_list. | 282 | /* Copy a list of valid friend IDs into the array out_list. |
283 | * If out_list is NULL, returns 0. | 283 | * If out_list is NULL, returns 0. |
284 | * Otherwise, returns the number of elements copied. | 284 | * Otherwise, returns the number of elements copied. |
285 | * If the array was too small, the contents | 285 | * If the array was too small, the contents |
286 | * of out_list will be truncated to list_size. */ | 286 | * of out_list will be truncated to list_size. */ |
287 | uint32_t tox_get_friendlist(Tox *tox, int32_t *out_list, uint32_t list_size); | 287 | uint32_t tox_get_friendlist(const Tox *tox, int32_t *out_list, uint32_t list_size); |
288 | 288 | ||
289 | /* Set the function that will be executed when a friend request is received. | 289 | /* Set the function that will be executed when a friend request is received. |
290 | * Function format is function(Tox *tox, uint8_t * public_key, uint8_t * data, uint16_t length, void *userdata) | 290 | * Function format is function(Tox *tox, uint8_t * public_key, uint8_t * data, uint16_t length, void *userdata) |
@@ -357,7 +357,7 @@ void tox_callback_connection_status(Tox *tox, void (*function)(Tox *tox, int32_t | |||
357 | 357 | ||
358 | /* Functions to get/set the nospam part of the id. | 358 | /* Functions to get/set the nospam part of the id. |
359 | */ | 359 | */ |
360 | uint32_t tox_get_nospam(Tox *tox); | 360 | uint32_t tox_get_nospam(const Tox *tox); |
361 | void tox_set_nospam(Tox *tox, uint32_t nospam); | 361 | void tox_set_nospam(Tox *tox, uint32_t nospam); |
362 | 362 | ||
363 | 363 | ||
@@ -417,7 +417,7 @@ int tox_del_groupchat(Tox *tox, int groupnumber); | |||
417 | * return length of name if success | 417 | * return length of name if success |
418 | * return -1 if failure | 418 | * return -1 if failure |
419 | */ | 419 | */ |
420 | int tox_group_peername(Tox *tox, int groupnumber, int peernumber, uint8_t *name); | 420 | int tox_group_peername(const Tox *tox, int groupnumber, int peernumber, uint8_t *name); |
421 | 421 | ||
422 | /* invite friendnumber to groupnumber | 422 | /* invite friendnumber to groupnumber |
423 | * return 0 on success | 423 | * return 0 on success |
@@ -430,24 +430,24 @@ int tox_invite_friend(Tox *tox, int32_t friendnumber, int groupnumber); | |||
430 | * returns group number on success | 430 | * returns group number on success |
431 | * returns -1 on failure. | 431 | * returns -1 on failure. |
432 | */ | 432 | */ |
433 | int tox_join_groupchat(Tox *tox, int32_t friendnumber, uint8_t *friend_group_public_key); | 433 | int tox_join_groupchat(Tox *tox, int32_t friendnumber, const uint8_t *friend_group_public_key); |
434 | 434 | ||
435 | /* send a group message | 435 | /* send a group message |
436 | * return 0 on success | 436 | * return 0 on success |
437 | * return -1 on failure | 437 | * return -1 on failure |
438 | */ | 438 | */ |
439 | int tox_group_message_send(Tox *tox, int groupnumber, uint8_t *message, uint32_t length); | 439 | int tox_group_message_send(Tox *tox, int groupnumber, const uint8_t *message, uint32_t length); |
440 | 440 | ||
441 | /* send a group action | 441 | /* send a group action |
442 | * return 0 on success | 442 | * return 0 on success |
443 | * return -1 on failure | 443 | * return -1 on failure |
444 | */ | 444 | */ |
445 | int tox_group_action_send(Tox *tox, int groupnumber, uint8_t *action, uint32_t length); | 445 | int tox_group_action_send(Tox *tox, int groupnumber, const uint8_t *action, uint32_t length); |
446 | 446 | ||
447 | /* Return the number of peers in the group chat on success. | 447 | /* Return the number of peers in the group chat on success. |
448 | * return -1 on failure | 448 | * return -1 on failure |
449 | */ | 449 | */ |
450 | int tox_group_number_peers(Tox *tox, int groupnumber); | 450 | int tox_group_number_peers(const Tox *tox, int groupnumber); |
451 | 451 | ||
452 | /* List all the peers in the group chat. | 452 | /* List all the peers in the group chat. |
453 | * | 453 | * |
@@ -459,20 +459,20 @@ int tox_group_number_peers(Tox *tox, int groupnumber); | |||
459 | * | 459 | * |
460 | * return -1 on failure. | 460 | * return -1 on failure. |
461 | */ | 461 | */ |
462 | int tox_group_get_names(Tox *tox, int groupnumber, uint8_t names[][TOX_MAX_NAME_LENGTH], uint16_t lengths[], | 462 | int tox_group_get_names(const Tox *tox, int groupnumber, uint8_t names[][TOX_MAX_NAME_LENGTH], uint16_t lengths[], |
463 | uint16_t length); | 463 | uint16_t length); |
464 | 464 | ||
465 | /* Return the number of chats in the instance m. | 465 | /* Return the number of chats in the instance m. |
466 | * You should use this to determine how much memory to allocate | 466 | * You should use this to determine how much memory to allocate |
467 | * for copy_chatlist. */ | 467 | * for copy_chatlist. */ |
468 | uint32_t tox_count_chatlist(Tox *tox); | 468 | uint32_t tox_count_chatlist(const Tox *tox); |
469 | 469 | ||
470 | /* Copy a list of valid chat IDs into the array out_list. | 470 | /* Copy a list of valid chat IDs into the array out_list. |
471 | * If out_list is NULL, returns 0. | 471 | * If out_list is NULL, returns 0. |
472 | * Otherwise, returns the number of elements copied. | 472 | * Otherwise, returns the number of elements copied. |
473 | * If the array was too small, the contents | 473 | * If the array was too small, the contents |
474 | * of out_list will be truncated to list_size. */ | 474 | * of out_list will be truncated to list_size. */ |
475 | uint32_t tox_get_chatlist(Tox *tox, int *out_list, uint32_t list_size); | 475 | uint32_t tox_get_chatlist(const Tox *tox, int *out_list, uint32_t list_size); |
476 | 476 | ||
477 | 477 | ||
478 | /****************FILE SENDING FUNCTIONS*****************/ | 478 | /****************FILE SENDING FUNCTIONS*****************/ |
@@ -551,7 +551,7 @@ void tox_callback_file_data(Tox *tox, void (*function)(Tox *m, int32_t, uint8_t, | |||
551 | * return file number on success | 551 | * return file number on success |
552 | * return -1 on failure | 552 | * return -1 on failure |
553 | */ | 553 | */ |
554 | int tox_new_file_sender(Tox *tox, int32_t friendnumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length); | 554 | int tox_new_file_sender(Tox *tox, int32_t friendnumber, uint64_t filesize, const uint8_t *filename, uint16_t filename_length); |
555 | 555 | ||
556 | /* Send a file control request. | 556 | /* Send a file control request. |
557 | * | 557 | * |
@@ -562,21 +562,21 @@ int tox_new_file_sender(Tox *tox, int32_t friendnumber, uint64_t filesize, uint8 | |||
562 | * return -1 on failure | 562 | * return -1 on failure |
563 | */ | 563 | */ |
564 | int tox_file_send_control(Tox *tox, int32_t friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t message_id, | 564 | int tox_file_send_control(Tox *tox, int32_t friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t message_id, |
565 | uint8_t *data, uint16_t length); | 565 | const uint8_t *data, uint16_t length); |
566 | 566 | ||
567 | /* Send file data. | 567 | /* Send file data. |
568 | * | 568 | * |
569 | * return 0 on success | 569 | * return 0 on success |
570 | * return -1 on failure | 570 | * return -1 on failure |
571 | */ | 571 | */ |
572 | int tox_file_send_data(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length); | 572 | int tox_file_send_data(Tox *tox, int32_t friendnumber, uint8_t filenumber, const uint8_t *data, uint16_t length); |
573 | 573 | ||
574 | /* Returns the recommended/maximum size of the filedata you send with tox_file_send_data() | 574 | /* Returns the recommended/maximum size of the filedata you send with tox_file_send_data() |
575 | * | 575 | * |
576 | * return size on success | 576 | * return size on success |
577 | * return -1 on failure (currently will never return -1) | 577 | * return -1 on failure (currently will never return -1) |
578 | */ | 578 | */ |
579 | int tox_file_data_size(Tox *tox, int32_t friendnumber); | 579 | int tox_file_data_size(const Tox *tox, int32_t friendnumber); |
580 | 580 | ||
581 | /* Give the number of bytes left to be sent/received. | 581 | /* Give the number of bytes left to be sent/received. |
582 | * | 582 | * |
@@ -585,7 +585,7 @@ int tox_file_data_size(Tox *tox, int32_t friendnumber); | |||
585 | * return number of bytes remaining to be sent/received on success | 585 | * return number of bytes remaining to be sent/received on success |
586 | * return 0 on failure | 586 | * return 0 on failure |
587 | */ | 587 | */ |
588 | uint64_t tox_file_data_remaining(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint8_t send_receive); | 588 | uint64_t tox_file_data_remaining(const Tox *tox, int32_t friendnumber, uint8_t filenumber, uint8_t send_receive); |
589 | 589 | ||
590 | /***************END OF FILE SENDING FUNCTIONS******************/ | 590 | /***************END OF FILE SENDING FUNCTIONS******************/ |
591 | 591 | ||
@@ -606,12 +606,12 @@ uint64_t tox_file_data_remaining(Tox *tox, int32_t friendnumber, uint8_t filenum | |||
606 | * returns 0 otherwise | 606 | * returns 0 otherwise |
607 | */ | 607 | */ |
608 | int tox_bootstrap_from_address(Tox *tox, const char *address, uint8_t ipv6enabled, | 608 | int tox_bootstrap_from_address(Tox *tox, const char *address, uint8_t ipv6enabled, |
609 | uint16_t port, uint8_t *public_key); | 609 | uint16_t port, const uint8_t *public_key); |
610 | 610 | ||
611 | /* return 0 if we are not connected to the DHT. | 611 | /* return 0 if we are not connected to the DHT. |
612 | * return 1 if we are. | 612 | * return 1 if we are. |
613 | */ | 613 | */ |
614 | int tox_isconnected(Tox *tox); | 614 | int tox_isconnected(const Tox *tox); |
615 | 615 | ||
616 | /* | 616 | /* |
617 | * Run this function at startup. | 617 | * Run this function at startup. |
@@ -645,17 +645,17 @@ void tox_do(Tox *tox); | |||
645 | /* SAVING AND LOADING FUNCTIONS: */ | 645 | /* SAVING AND LOADING FUNCTIONS: */ |
646 | 646 | ||
647 | /* return size of messenger data (for saving). */ | 647 | /* return size of messenger data (for saving). */ |
648 | uint32_t tox_size(Tox *tox); | 648 | uint32_t tox_size(const Tox *tox); |
649 | 649 | ||
650 | /* Save the messenger in data (must be allocated memory of size Messenger_size()). */ | 650 | /* Save the messenger in data (must be allocated memory of size Messenger_size()). */ |
651 | void tox_save(Tox *tox, uint8_t *data); | 651 | void tox_save(const Tox *tox, uint8_t *data); |
652 | 652 | ||
653 | /* Load the messenger from data of size length. | 653 | /* Load the messenger from data of size length. |
654 | * | 654 | * |
655 | * returns 0 on success | 655 | * returns 0 on success |
656 | * returns -1 on failure | 656 | * returns -1 on failure |
657 | */ | 657 | */ |
658 | int tox_load(Tox *tox, uint8_t *data, uint32_t length); | 658 | int tox_load(Tox *tox, const uint8_t *data, uint32_t length); |
659 | 659 | ||
660 | #ifdef __cplusplus | 660 | #ifdef __cplusplus |
661 | } | 661 | } |