mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Make Typing change callback stateless
Moved a few #defines to the top of the header for better readability
This commit is contained in:
parent
83d4857f08
commit
0e18966a27
|
@ -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) {
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
|
|
Loading…
Reference in New Issue
Block a user