mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Document functions, and fix bug.
This commit is contained in:
parent
9f6262f3dd
commit
c0828667e7
|
@ -205,7 +205,10 @@ uint32_t m_sendmessage(int friendnumber, uint8_t *message, uint32_t length)
|
||||||
{
|
{
|
||||||
if (friendnumber < 0 || friendnumber >= numfriends)
|
if (friendnumber < 0 || friendnumber >= numfriends)
|
||||||
return 0;
|
return 0;
|
||||||
return m_sendmessage_withid(friendnumber, friendlist[friendnumber].message_id++, message, length);
|
uint32_t msgid = ++friendlist[friendnumber].message_id;
|
||||||
|
if (msgid == 0)
|
||||||
|
msgid = 1; /* otherwise, false error */
|
||||||
|
return m_sendmessage_withid(friendnumber, msgid, message, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t m_sendmessage_withid(int friendnumber, uint32_t theid, uint8_t *message, uint32_t length)
|
uint32_t m_sendmessage_withid(int friendnumber, uint32_t theid, uint8_t *message, uint32_t length)
|
||||||
|
@ -391,6 +394,16 @@ static void set_friend_userstatus_kind(int friendnumber, USERSTATUS_KIND k)
|
||||||
friendlist[friendnumber].userstatus_kind = k;
|
friendlist[friendnumber].userstatus_kind = k;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Sets whether we send read receipts for friendnumber. */
|
||||||
|
void m_set_sends_receipts(int friendnumber, int yesno)
|
||||||
|
{
|
||||||
|
if (yesno < 0 || yesno > 1)
|
||||||
|
return;
|
||||||
|
if (friendnumber >= numfriends || friendnumber < 0)
|
||||||
|
return;
|
||||||
|
friendlist[friendnumber].receives_read_receipts = yesno;
|
||||||
|
}
|
||||||
|
|
||||||
/* static void (*friend_request)(uint8_t *, uint8_t *, uint16_t);
|
/* static void (*friend_request)(uint8_t *, uint8_t *, uint16_t);
|
||||||
static uint8_t friend_request_isset = 0; */
|
static uint8_t friend_request_isset = 0; */
|
||||||
/* set the function that will be executed when a friend request is received. */
|
/* set the function that will be executed when a friend request is received. */
|
||||||
|
|
|
@ -171,6 +171,10 @@ int m_copy_self_userstatus(uint8_t *buf, uint32_t maxlen);
|
||||||
USERSTATUS_KIND m_get_userstatus_kind(int friendnumber);
|
USERSTATUS_KIND m_get_userstatus_kind(int friendnumber);
|
||||||
USERSTATUS_KIND m_get_self_userstatus_kind(void);
|
USERSTATUS_KIND m_get_self_userstatus_kind(void);
|
||||||
|
|
||||||
|
/* Sets whether we send read receipts for friendnumber.
|
||||||
|
* This function is not lazy, and it will fail if yesno is not (0 or 1).*/
|
||||||
|
void m_set_sends_receipts(int friendnumber, int yesno);
|
||||||
|
|
||||||
/* set the function that will be executed when a friend request is received.
|
/* set the function that will be executed when a friend request is received.
|
||||||
function format is function(uint8_t * public_key, uint8_t * data, uint16_t length) */
|
function format is function(uint8_t * public_key, uint8_t * data, uint16_t length) */
|
||||||
void m_callback_friendrequest(void (*function)(uint8_t *, uint8_t *, uint16_t));
|
void m_callback_friendrequest(void (*function)(uint8_t *, uint8_t *, uint16_t));
|
||||||
|
@ -189,6 +193,13 @@ void m_callback_namechange(void (*function)(int, uint8_t *, uint16_t));
|
||||||
you are not responsible for freeing newstatus */
|
you are not responsible for freeing newstatus */
|
||||||
void m_callback_userstatus(void (*function)(int, USERSTATUS_KIND, uint8_t *, uint16_t));
|
void m_callback_userstatus(void (*function)(int, USERSTATUS_KIND, uint8_t *, uint16_t));
|
||||||
|
|
||||||
|
/* set the callback for read receipts
|
||||||
|
function(int friendnumber, uint32_t receipt)
|
||||||
|
if you are keeping a record of returns from m_sendmessage,
|
||||||
|
receipt might be one of those values, and that means the message
|
||||||
|
has been received on the other side. since core doesn't
|
||||||
|
track ids for you, receipt may not correspond to any message
|
||||||
|
in that case, you should discard it. */
|
||||||
void m_callback_read_receipt(void (*function)(int, uint32_t));
|
void m_callback_read_receipt(void (*function)(int, uint32_t));
|
||||||
|
|
||||||
/* run this at startup
|
/* run this at startup
|
||||||
|
|
Loading…
Reference in New Issue
Block a user