diff options
author | irungentoo <irungentoo@gmail.com> | 2013-09-12 20:29:30 -0400 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2013-09-12 20:29:30 -0400 |
commit | f8b979a92a8c316c49bed28e158a468a2f74346c (patch) | |
tree | dd139feb11dde83d1f16cc7be9f92c3d8e680dd1 /toxcore | |
parent | 41b162eb189d3631abba4c65ced3570c776e45a5 (diff) |
Put group chat functions in the public API.
Group chats are not complete, they seem to work very well though.
This means that the functions will change.
Diffstat (limited to 'toxcore')
-rw-r--r-- | toxcore/tox.c | 75 | ||||
-rw-r--r-- | toxcore/tox.h | 53 |
2 files changed, 128 insertions, 0 deletions
diff --git a/toxcore/tox.c b/toxcore/tox.c index 54bbd9f0..417f1af3 100644 --- a/toxcore/tox.c +++ b/toxcore/tox.c | |||
@@ -366,6 +366,81 @@ void tox_callback_connectionstatus(void *tox, void (*function)(Messenger *tox, i | |||
366 | m_callback_connectionstatus(m, function, userdata); | 366 | m_callback_connectionstatus(m, function, userdata); |
367 | } | 367 | } |
368 | 368 | ||
369 | /**********GROUP CHAT FUNCTIONS: WARNING WILL BREAK A LOT************/ | ||
370 | |||
371 | /* Set the callback for group invites. | ||
372 | * | ||
373 | * Function(Tox *tox, int friendnumber, uint8_t *group_public_key, void *userdata) | ||
374 | */ | ||
375 | void tox_callback_group_invite(void *tox, void (*function)(Messenger *tox, int, uint8_t *, void *), void *userdata) | ||
376 | { | ||
377 | Messenger *m = tox; | ||
378 | m_callback_group_invite(m, function, userdata); | ||
379 | } | ||
380 | /* Set the callback for group messages. | ||
381 | * | ||
382 | * Function(Tox *tox, int groupnumber, uint8_t * message, uint16_t length, void *userdata) | ||
383 | */ | ||
384 | void tox_callback_group_message(void *tox, void (*function)(Messenger *tox, int, uint8_t *, uint16_t, void *), | ||
385 | void *userdata) | ||
386 | { | ||
387 | Messenger *m = tox; | ||
388 | m_callback_group_message(m, function, userdata); | ||
389 | } | ||
390 | /* Creates a new groupchat and puts it in the chats array. | ||
391 | * | ||
392 | * return group number on success. | ||
393 | * return -1 on failure. | ||
394 | */ | ||
395 | int tox_add_groupchat(void *tox) | ||
396 | { | ||
397 | Messenger *m = tox; | ||
398 | return add_groupchat(m); | ||
399 | } | ||
400 | /* Delete a groupchat from the chats array. | ||
401 | * | ||
402 | * return 0 on success. | ||
403 | * return -1 if failure. | ||
404 | */ | ||
405 | int tox_del_groupchat(void *tox, int groupnumber) | ||
406 | { | ||
407 | Messenger *m = tox; | ||
408 | return del_groupchat(m, groupnumber); | ||
409 | } | ||
410 | /* invite friendnumber to groupnumber | ||
411 | * return 0 on success | ||
412 | * return -1 on failure | ||
413 | */ | ||
414 | int tox_invite_friend(void *tox, int friendnumber, int groupnumber) | ||
415 | { | ||
416 | Messenger *m = tox; | ||
417 | return invite_friend(m, friendnumber, groupnumber); | ||
418 | } | ||
419 | /* Join a group (you need to have been invited first.) | ||
420 | * | ||
421 | * returns group number on success | ||
422 | * returns -1 on failure. | ||
423 | */ | ||
424 | int tox_join_groupchat(void *tox, int friendnumber, uint8_t *friend_group_public_key) | ||
425 | { | ||
426 | Messenger *m = tox; | ||
427 | return join_groupchat(m, friendnumber, friend_group_public_key); | ||
428 | } | ||
429 | |||
430 | /* send a group message | ||
431 | * return 0 on success | ||
432 | * return -1 on failure | ||
433 | */ | ||
434 | int tox_group_message_send(void *tox, int groupnumber, uint8_t *message, uint32_t length) | ||
435 | { | ||
436 | Messenger *m = tox; | ||
437 | return group_message_send(m, groupnumber, message, length); | ||
438 | } | ||
439 | |||
440 | |||
441 | |||
442 | /******************END OF GROUP CHAT FUNCTIONS************************/ | ||
443 | |||
369 | /* Use this function to bootstrap the client. | 444 | /* Use this function to bootstrap the client. |
370 | * Sends a get nodes request to the given node with ip port and public_key. | 445 | * Sends a get nodes request to the given node with ip port and public_key. |
371 | */ | 446 | */ |
diff --git a/toxcore/tox.h b/toxcore/tox.h index 811e798b..6d5db49f 100644 --- a/toxcore/tox.h +++ b/toxcore/tox.h | |||
@@ -289,6 +289,59 @@ void tox_callback_read_receipt(Tox *tox, void (*function)(Tox *tox, int, uint32_ | |||
289 | */ | 289 | */ |
290 | void tox_callback_connectionstatus(Tox *tox, void (*function)(Tox *tox, int, uint8_t, void *), void *userdata); | 290 | void tox_callback_connectionstatus(Tox *tox, void (*function)(Tox *tox, int, uint8_t, void *), void *userdata); |
291 | 291 | ||
292 | /**********GROUP CHAT FUNCTIONS: WARNING WILL BREAK A LOT************/ | ||
293 | |||
294 | /* Set the callback for group invites. | ||
295 | * | ||
296 | * Function(Tox *tox, int friendnumber, uint8_t *group_public_key, void *userdata) | ||
297 | */ | ||
298 | void tox_callback_group_invite(Tox *tox, void (*function)(Tox *tox, int, uint8_t *, void *), void *userdata); | ||
299 | |||
300 | /* Set the callback for group messages. | ||
301 | * | ||
302 | * Function(Tox *tox, int groupnumber, uint8_t * message, uint16_t length, void *userdata) | ||
303 | */ | ||
304 | void tox_callback_group_message(Tox *tox, void (*function)(Tox *tox, int, uint8_t *, uint16_t, void *), | ||
305 | void *userdata); | ||
306 | |||
307 | /* Creates a new groupchat and puts it in the chats array. | ||
308 | * | ||
309 | * return group number on success. | ||
310 | * return -1 on failure. | ||
311 | */ | ||
312 | int tox_add_groupchat(Tox *tox); | ||
313 | |||
314 | /* Delete a groupchat from the chats array. | ||
315 | * | ||
316 | * return 0 on success. | ||
317 | * return -1 if failure. | ||
318 | */ | ||
319 | int tox_del_groupchat(Tox *tox, int groupnumber); | ||
320 | |||
321 | /* invite friendnumber to groupnumber | ||
322 | * return 0 on success | ||
323 | * return -1 on failure | ||
324 | */ | ||
325 | int tox_invite_friend(Tox *tox, int friendnumber, int groupnumber); | ||
326 | |||
327 | /* Join a group (you need to have been invited first.) | ||
328 | * | ||
329 | * returns group number on success | ||
330 | * returns -1 on failure. | ||
331 | */ | ||
332 | int tox_join_groupchat(Tox *tox, int friendnumber, uint8_t *friend_group_public_key); | ||
333 | |||
334 | |||
335 | /* send a group message | ||
336 | * return 0 on success | ||
337 | * return -1 on failure | ||
338 | */ | ||
339 | int tox_group_message_send(Tox *tox, int groupnumber, uint8_t *message, uint32_t length); | ||
340 | |||
341 | |||
342 | |||
343 | /******************END OF GROUP CHAT FUNCTIONS************************/ | ||
344 | |||
292 | /* Use this function to bootstrap the client. | 345 | /* Use this function to bootstrap the client. |
293 | * Sends a get nodes request to the given node with ip port and public_key. | 346 | * Sends a get nodes request to the given node with ip port and public_key. |
294 | */ | 347 | */ |