mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
removing unnecessary function pointer _isset variables
This commit is contained in:
parent
a8d1f86f8b
commit
0590d8325c
|
@ -449,8 +449,7 @@ void m_set_sends_receipts(Messenger *m, int friendnumber, int yesno)
|
|||
m->friendlist[friendnumber].receives_read_receipts = yesno;
|
||||
}
|
||||
|
||||
/* static void (*friend_request)(uint8_t *, uint8_t *, uint16_t);
|
||||
static uint8_t friend_request_isset = 0; */
|
||||
/* static void (*friend_request)(uint8_t *, uint8_t *, uint16_t); */
|
||||
/* set the function that will be executed when a friend request is received. */
|
||||
void m_callback_friendrequest(Messenger *m, void (*function)(uint8_t *, uint8_t *, uint16_t, void*), void* userdata)
|
||||
{
|
||||
|
@ -461,55 +460,48 @@ void m_callback_friendrequest(Messenger *m, void (*function)(uint8_t *, uint8_t
|
|||
void m_callback_friendmessage(Messenger *m, void (*function)(Messenger *m, int, uint8_t *, uint16_t, void*), void* userdata)
|
||||
{
|
||||
m->friend_message = function;
|
||||
m->friend_message_isset = 1;
|
||||
m->friend_message_userdata = userdata;
|
||||
}
|
||||
|
||||
void m_callback_action(Messenger *m, void (*function)(Messenger *m, int, uint8_t *, uint16_t, void*), void* userdata)
|
||||
{
|
||||
m->friend_action = function;
|
||||
m->friend_action_isset = 1;
|
||||
m->friend_action_userdata = userdata;
|
||||
}
|
||||
|
||||
void m_callback_namechange(Messenger *m, void (*function)(Messenger *m, int, uint8_t *, uint16_t, void*), void* userdata)
|
||||
{
|
||||
m->friend_namechange = function;
|
||||
m->friend_namechange_isset = 1;
|
||||
m->friend_namechange_userdata = userdata;
|
||||
}
|
||||
|
||||
void m_callback_statusmessage(Messenger *m, void (*function)(Messenger *m, int, uint8_t *, uint16_t, void*), void* userdata)
|
||||
{
|
||||
m->friend_statusmessagechange = function;
|
||||
m->friend_statusmessagechange_isset = 1;
|
||||
m->friend_statuschange_userdata = userdata;
|
||||
}
|
||||
|
||||
void m_callback_userstatus(Messenger *m, void (*function)(Messenger *m, int, USERSTATUS, void*), void* userdata)
|
||||
{
|
||||
m->friend_userstatuschange = function;
|
||||
m->friend_userstatuschange_isset = 1;
|
||||
m->friend_userstatuschange_userdata = userdata;
|
||||
}
|
||||
|
||||
void m_callback_read_receipt(Messenger *m, void (*function)(Messenger *m, int, uint32_t, void*), void* userdata)
|
||||
{
|
||||
m->read_receipt = function;
|
||||
m->read_receipt_isset = 1;
|
||||
m->read_receipt_userdata = userdata;
|
||||
}
|
||||
|
||||
void m_callback_connectionstatus(Messenger *m, void (*function)(Messenger *m, int, uint8_t, void*), void* userdata)
|
||||
{
|
||||
m->friend_connectionstatuschange = function;
|
||||
m->friend_connectionstatuschange_isset = 1;
|
||||
m->friend_connectionstatuschange_userdata = userdata;
|
||||
}
|
||||
|
||||
static void check_friend_connectionstatus(Messenger *m, int friendnumber, uint8_t status)
|
||||
{
|
||||
if (!m->friend_connectionstatuschange_isset)
|
||||
if (!m->friend_connectionstatuschange)
|
||||
return;
|
||||
if (status == NOFRIEND)
|
||||
return;
|
||||
|
@ -648,7 +640,7 @@ void doFriends(Messenger *m)
|
|||
case PACKET_ID_NICKNAME: {
|
||||
if (data_length >= MAX_NAME_LENGTH || data_length == 0)
|
||||
break;
|
||||
if(m->friend_namechange_isset)
|
||||
if(m->friend_namechange)
|
||||
m->friend_namechange(m, i, data, data_length, m->friend_namechange_userdata);
|
||||
memcpy(m->friendlist[i].name, data, data_length);
|
||||
m->friendlist[i].name[data_length - 1] = 0; /* make sure the NULL terminator is present. */
|
||||
|
@ -659,7 +651,7 @@ void doFriends(Messenger *m)
|
|||
break;
|
||||
uint8_t *status = calloc(MIN(data_length, MAX_STATUSMESSAGE_LENGTH), 1);
|
||||
memcpy(status, data, MIN(data_length, MAX_STATUSMESSAGE_LENGTH));
|
||||
if (m->friend_statusmessagechange_isset)
|
||||
if (m->friend_statusmessagechange)
|
||||
m->friend_statusmessagechange(m, i, status, MIN(data_length, MAX_STATUSMESSAGE_LENGTH),
|
||||
m->friend_statuschange_userdata);
|
||||
set_friend_statusmessage(m, i, status, MIN(data_length, MAX_STATUSMESSAGE_LENGTH));
|
||||
|
@ -670,7 +662,7 @@ void doFriends(Messenger *m)
|
|||
if (data_length != 1)
|
||||
break;
|
||||
USERSTATUS status = data[0];
|
||||
if (m->friend_userstatuschange_isset)
|
||||
if (m->friend_userstatuschange)
|
||||
m->friend_userstatuschange(m, i, status, m->friend_userstatuschange_userdata);
|
||||
set_friend_userstatus(m, i, status);
|
||||
break;
|
||||
|
@ -683,12 +675,12 @@ void doFriends(Messenger *m)
|
|||
if (m->friendlist[i].receives_read_receipts) {
|
||||
write_cryptpacket_id(m, i, PACKET_ID_RECEIPT, message_id, message_id_length);
|
||||
}
|
||||
if (m->friend_message_isset)
|
||||
if (m->friend_message)
|
||||
(*m->friend_message)(m, i, message, message_length, m->friend_message_userdata);
|
||||
break;
|
||||
}
|
||||
case PACKET_ID_ACTION: {
|
||||
if (m->friend_action_isset)
|
||||
if (m->friend_action)
|
||||
(*m->friend_action)(m, i, data, data_length, m->friend_action_userdata);
|
||||
break;
|
||||
}
|
||||
|
@ -698,7 +690,7 @@ void doFriends(Messenger *m)
|
|||
break;
|
||||
memcpy(&msgid, data, sizeof(msgid));
|
||||
msgid = ntohl(msgid);
|
||||
if (m->read_receipt_isset)
|
||||
if (m->read_receipt)
|
||||
(*m->read_receipt)(m, i, msgid, m->read_receipt_userdata);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -111,28 +111,20 @@ typedef struct Messenger {
|
|||
uint32_t numfriends;
|
||||
|
||||
void (*friend_message)(struct Messenger *m, int, uint8_t *, uint16_t, void*);
|
||||
uint8_t friend_message_isset;
|
||||
void* friend_message_userdata;
|
||||
void (*friend_action)(struct Messenger *m, int, uint8_t *, uint16_t, void*);
|
||||
uint8_t friend_action_isset;
|
||||
void* friend_action_userdata;
|
||||
void (*friend_namechange)(struct Messenger *m, int, uint8_t *, uint16_t, void*);
|
||||
uint8_t friend_namechange_isset;
|
||||
void* friend_namechange_userdata;
|
||||
void (*friend_statusmessagechange)(struct Messenger *m, int, uint8_t *, uint16_t, void*);
|
||||
uint8_t friend_statusmessagechange_isset;
|
||||
void* friend_statusmessagechange_userdata;
|
||||
void (*friend_userstatuschange)(struct Messenger *m, int, USERSTATUS, void*);
|
||||
uint8_t friend_userstatuschange_isset;
|
||||
void* friend_userstatuschange_userdata;
|
||||
void (*read_receipt)(struct Messenger *m, int, uint32_t, void*);
|
||||
uint8_t read_receipt_isset;
|
||||
void* read_receipt_userdata;
|
||||
void (*friend_statuschange)(struct Messenger *m, int, uint8_t, void*);
|
||||
uint8_t friend_statuschange_isset;
|
||||
void* friend_statuschange_userdata;
|
||||
void (*friend_connectionstatuschange)(struct Messenger *m, int, uint8_t, void*);
|
||||
uint8_t friend_connectionstatuschange_isset;
|
||||
void* friend_connectionstatuschange_userdata;
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user