mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Make Message received receipts stateless
This commit is contained in:
parent
3f0c101771
commit
a6f2e9539b
|
@ -1435,7 +1435,7 @@ namespace friend {
|
||||||
* This event is triggered when the friend receives the message sent with
|
* This event is triggered when the friend receives the message sent with
|
||||||
* ${send.message} with the corresponding message ID.
|
* ${send.message} with the corresponding message ID.
|
||||||
*/
|
*/
|
||||||
event read_receipt {
|
event read_receipt const {
|
||||||
/**
|
/**
|
||||||
* @param friend_number The friend number of the friend who received the message.
|
* @param friend_number The friend number of the friend who received the message.
|
||||||
* @param message_id The message ID as returned from ${send.message}
|
* @param message_id The message ID as returned from ${send.message}
|
||||||
|
|
|
@ -344,7 +344,7 @@ static int friend_received_packet(const Messenger *m, int32_t friendnumber, uint
|
||||||
m->friendlist[friendnumber].friendcon_id), number);
|
m->friendlist[friendnumber].friendcon_id), number);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int do_receipts(Messenger *m, int32_t friendnumber)
|
static int do_receipts(Messenger *m, int32_t friendnumber, void *userdata)
|
||||||
{
|
{
|
||||||
if (friend_not_valid(m, friendnumber))
|
if (friend_not_valid(m, friendnumber))
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -357,8 +357,9 @@ static int do_receipts(Messenger *m, int32_t friendnumber)
|
||||||
if (friend_received_packet(m, friendnumber, receipts->packet_num) == -1)
|
if (friend_received_packet(m, friendnumber, receipts->packet_num) == -1)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (m->read_receipt)
|
if (m->read_receipt) {
|
||||||
(*m->read_receipt)(m, friendnumber, receipts->msg_id, m->read_receipt_userdata);
|
(*m->read_receipt)(m, friendnumber, receipts->msg_id, userdata);
|
||||||
|
}
|
||||||
|
|
||||||
free(receipts);
|
free(receipts);
|
||||||
m->friendlist[friendnumber].receipts_start = temp_r;
|
m->friendlist[friendnumber].receipts_start = temp_r;
|
||||||
|
@ -796,10 +797,9 @@ void m_callback_typingchange(Messenger *m, void(*function)(Messenger *m, uint32_
|
||||||
m->friend_typingchange = function;
|
m->friend_typingchange = function;
|
||||||
}
|
}
|
||||||
|
|
||||||
void m_callback_read_receipt(Messenger *m, void (*function)(Messenger *m, uint32_t, uint32_t, void *), void *userdata)
|
void m_callback_read_receipt(Messenger *m, void (*function)(Messenger *m, uint32_t, uint32_t, void *))
|
||||||
{
|
{
|
||||||
m->read_receipt = function;
|
m->read_receipt = function;
|
||||||
m->read_receipt_userdata = userdata;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void m_callback_connectionstatus(Messenger *m, void (*function)(Messenger *m, uint32_t, unsigned int, void *),
|
void m_callback_connectionstatus(Messenger *m, void (*function)(Messenger *m, uint32_t, unsigned int, void *),
|
||||||
|
@ -2168,7 +2168,7 @@ static int handle_packet(void *object, int i, uint8_t *temp, uint16_t len, void
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_friends(Messenger *m)
|
static void do_friends(Messenger *m, void *userdata)
|
||||||
{
|
{
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
uint64_t temp_time = unix_time();
|
uint64_t temp_time = unix_time();
|
||||||
|
@ -2217,7 +2217,7 @@ void do_friends(Messenger *m)
|
||||||
}
|
}
|
||||||
|
|
||||||
check_friend_tcp_udp(m, i);
|
check_friend_tcp_udp(m, i);
|
||||||
do_receipts(m, i);
|
do_receipts(m, i, userdata);
|
||||||
do_reqchunk_filecb(m, i);
|
do_reqchunk_filecb(m, i);
|
||||||
|
|
||||||
m->friendlist[i].last_seen_time = (uint64_t) time(NULL);
|
m->friendlist[i].last_seen_time = (uint64_t) time(NULL);
|
||||||
|
@ -2311,7 +2311,7 @@ void do_messenger(Messenger *m, void *userdata)
|
||||||
do_net_crypto(m->net_crypto, userdata);
|
do_net_crypto(m->net_crypto, userdata);
|
||||||
do_onion_client(m->onion_c);
|
do_onion_client(m->onion_c);
|
||||||
do_friend_connections(m->fr_c);
|
do_friend_connections(m->fr_c);
|
||||||
do_friends(m);
|
do_friends(m, userdata);
|
||||||
connection_status_cb(m, userdata);
|
connection_status_cb(m, userdata);
|
||||||
|
|
||||||
#ifdef TOX_LOGGER
|
#ifdef TOX_LOGGER
|
||||||
|
|
|
@ -242,7 +242,6 @@ struct Messenger {
|
||||||
void (*friend_userstatuschange)(struct Messenger *m, uint32_t, unsigned int, void *);
|
void (*friend_userstatuschange)(struct Messenger *m, uint32_t, unsigned int, void *);
|
||||||
void (*friend_typingchange)(struct Messenger *m, uint32_t, _Bool, void *);
|
void (*friend_typingchange)(struct Messenger *m, uint32_t, _Bool, void *);
|
||||||
void (*read_receipt)(struct Messenger *m, uint32_t, uint32_t, void *);
|
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 *);
|
void (*friend_connectionstatuschange)(struct Messenger *m, uint32_t, unsigned int, void *);
|
||||||
void *friend_connectionstatuschange_userdata;
|
void *friend_connectionstatuschange_userdata;
|
||||||
void (*friend_connectionstatuschange_internal)(struct Messenger *m, uint32_t, uint8_t, void *);
|
void (*friend_connectionstatuschange_internal)(struct Messenger *m, uint32_t, uint8_t, void *);
|
||||||
|
@ -507,7 +506,7 @@ void m_callback_typingchange(Messenger *m, void(*function)(Messenger *m, uint32_
|
||||||
* Since core doesn't track ids for you, receipt may not correspond to any message.
|
* Since core doesn't track ids for you, receipt may not correspond to any message.
|
||||||
* In that case, you should discard it.
|
* In that case, you should discard it.
|
||||||
*/
|
*/
|
||||||
void m_callback_read_receipt(Messenger *m, void (*function)(Messenger *m, uint32_t, uint32_t, void *), void *userdata);
|
void m_callback_read_receipt(Messenger *m, void (*function)(Messenger *m, uint32_t, uint32_t, void *));
|
||||||
|
|
||||||
/* Set the callback for connection status changes.
|
/* Set the callback for connection status changes.
|
||||||
* function(uint32_t friendnumber, uint8_t status)
|
* function(uint32_t friendnumber, uint8_t status)
|
||||||
|
|
|
@ -890,10 +890,10 @@ uint32_t tox_friend_send_message(Tox *tox, uint32_t friend_number, TOX_MESSAGE_T
|
||||||
return message_id;
|
return message_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tox_callback_friend_read_receipt(Tox *tox, tox_friend_read_receipt_cb *function, void *user_data)
|
void tox_callback_friend_read_receipt(Tox *tox, tox_friend_read_receipt_cb *function)
|
||||||
{
|
{
|
||||||
Messenger *m = tox;
|
Messenger *m = tox;
|
||||||
m_callback_read_receipt(m, function, user_data);
|
m_callback_read_receipt(m, function);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tox_callback_friend_request(Tox *tox, tox_friend_request_cb *function, void *user_data)
|
void tox_callback_friend_request(Tox *tox, tox_friend_request_cb *function, void *user_data)
|
||||||
|
|
|
@ -1531,7 +1531,7 @@ typedef void tox_friend_read_receipt_cb(Tox *tox, uint32_t friend_number, uint32
|
||||||
* This event is triggered when the friend receives the message sent with
|
* This event is triggered when the friend receives the message sent with
|
||||||
* tox_friend_send_message with the corresponding message ID.
|
* tox_friend_send_message with the corresponding message ID.
|
||||||
*/
|
*/
|
||||||
void tox_callback_friend_read_receipt(Tox *tox, tox_friend_read_receipt_cb *callback, void *user_data);
|
void tox_callback_friend_read_receipt(Tox *tox, tox_friend_read_receipt_cb *callback);
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
|
|
Loading…
Reference in New Issue
Block a user