diff --git a/auto_tests/tox_test.c b/auto_tests/tox_test.c index 2146bdcf..6bd619c3 100644 --- a/auto_tests/tox_test.c +++ b/auto_tests/tox_test.c @@ -583,7 +583,7 @@ START_TEST(test_few_clients) ck_assert_msg(memcmp(temp_status_m, "Installing Gentoo", sizeof("Installing Gentoo")) == 0, "status message not correct"); - tox_callback_friend_typing(tox2, &print_typingchange, &to_compare); + tox_callback_friend_typing(tox2, &print_typingchange); tox_self_set_typing(tox3, 0, 1, 0); while (1) { diff --git a/other/apidsl/tox.in.h b/other/apidsl/tox.in.h index 0aca1716..c0695d54 100644 --- a/other/apidsl/tox.in.h +++ b/other/apidsl/tox.in.h @@ -1333,7 +1333,7 @@ namespace friend { /** * This event is triggered when a friend starts or stops typing. */ - event typing { + event typing const { /** * @param friend_number The friend number of the friend who started or stopped * typing. diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index d7fa8e64..2eb6cfd8 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c @@ -793,10 +793,9 @@ void m_callback_userstatus(Messenger *m, void (*function)(Messenger *m, uint32_t m->friend_userstatuschange_userdata = userdata; } -void m_callback_typingchange(Messenger *m, void(*function)(Messenger *m, uint32_t, _Bool, void *), void *userdata) +void m_callback_typingchange(Messenger *m, void(*function)(Messenger *m, uint32_t, _Bool, void *)) { m->friend_typingchange = function; - m->friend_typingchange_userdata = userdata; } void m_callback_read_receipt(Messenger *m, void (*function)(Messenger *m, uint32_t, uint32_t, void *), void *userdata) @@ -1987,8 +1986,9 @@ static int handle_packet(void *object, int i, uint8_t *temp, uint16_t len, void set_friend_typing(m, i, typing); - if (m->friend_typingchange) - m->friend_typingchange(m, i, typing, m->friend_typingchange_userdata); + if (m->friend_typingchange) { + m->friend_typingchange(m, i, typing, userdata); + } break; } diff --git a/toxcore/Messenger.h b/toxcore/Messenger.h index 9dae8446..113df796 100644 --- a/toxcore/Messenger.h +++ b/toxcore/Messenger.h @@ -32,6 +32,10 @@ #define MAX_NAME_LENGTH 128 /* TODO: this must depend on other variable. */ #define MAX_STATUSMESSAGE_LENGTH 1007 +/* Used for TCP relays in Messenger struct (may need to be % 2 == 0)*/ +#define NUM_SAVED_TCP_RELAYS 8 +/* This cannot be bigger than 256 */ +#define MAX_CONCURRENT_FILE_PIPES 256 #define FRIEND_ADDRESS_SIZE (crypto_box_PUBLICKEYBYTES + sizeof(uint32_t) + sizeof(uint16_t)) @@ -152,9 +156,6 @@ enum { FILE_PAUSE_BOTH }; -/* This cannot be bigger than 256 */ -#define MAX_CONCURRENT_FILE_PIPES 256 - enum { FILECONTROL_ACCEPT, FILECONTROL_PAUSE, @@ -207,7 +208,6 @@ typedef struct { struct Receipts *receipts_end; } Friend; - struct Messenger { Networking_Core *net; @@ -233,7 +233,6 @@ struct Messenger { Friend *friendlist; uint32_t numfriends; -#define NUM_SAVED_TCP_RELAYS 8 uint8_t has_added_relays; // If the first connection has occurred in do_messenger Node_format loaded_relays[NUM_SAVED_TCP_RELAYS]; // Relays loaded from config @@ -244,7 +243,6 @@ struct Messenger { void (*friend_userstatuschange)(struct Messenger *m, uint32_t, unsigned int, void *); void *friend_userstatuschange_userdata; void (*friend_typingchange)(struct Messenger *m, uint32_t, _Bool, void *); - void *friend_typingchange_userdata; void (*read_receipt)(struct Messenger *m, uint32_t, uint32_t, void *); void *read_receipt_userdata; void (*friend_connectionstatuschange)(struct Messenger *m, uint32_t, unsigned int, void *); @@ -501,7 +499,7 @@ void m_callback_userstatus(Messenger *m, void (*function)(Messenger *m, uint32_t /* Set the callback for typing changes. * Function(uint32_t friendnumber, uint8_t is_typing) */ -void m_callback_typingchange(Messenger *m, void(*function)(Messenger *m, uint32_t, _Bool, void *), void *userdata); +void m_callback_typingchange(Messenger *m, void(*function)(Messenger *m, uint32_t, _Bool, void *)); /* Set the callback for read receipts. * Function(uint32_t friendnumber, uint32_t receipt) @@ -527,6 +525,7 @@ void m_callback_read_receipt(Messenger *m, void (*function)(Messenger *m, uint32 */ void m_callback_connectionstatus(Messenger *m, void (*function)(Messenger *m, uint32_t, unsigned int, void *), void *userdata); + /* Same as previous but for internal A/V core usage only */ void m_callback_connectionstatus_internal_av(Messenger *m, void (*function)(Messenger *m, uint32_t, uint8_t, void *), void *userdata); diff --git a/toxcore/tox.c b/toxcore/tox.c index 51307fc1..6b36c115 100644 --- a/toxcore/tox.c +++ b/toxcore/tox.c @@ -823,10 +823,10 @@ bool tox_friend_get_typing(const Tox *tox, uint32_t friend_number, TOX_ERR_FRIEN return !!ret; } -void tox_callback_friend_typing(Tox *tox, tox_friend_typing_cb *function, void *user_data) +void tox_callback_friend_typing(Tox *tox, tox_friend_typing_cb *function) { Messenger *m = tox; - m_callback_typingchange(m, function, user_data); + m_callback_typingchange(m, function); } bool tox_self_set_typing(Tox *tox, uint32_t friend_number, bool is_typing, TOX_ERR_SET_TYPING *error) diff --git a/toxcore/tox.h b/toxcore/tox.h index 1bb98a76..c2b14eec 100644 --- a/toxcore/tox.h +++ b/toxcore/tox.h @@ -1413,7 +1413,7 @@ typedef void tox_friend_typing_cb(Tox *tox, uint32_t friend_number, bool is_typi * * This event is triggered when a friend starts or stops typing. */ -void tox_callback_friend_typing(Tox *tox, tox_friend_typing_cb *callback, void *user_data); +void tox_callback_friend_typing(Tox *tox, tox_friend_typing_cb *callback); /*******************************************************************************