Merge commit 'aae086cc650e42eec1eea8db28cd01fa868d7f90'
This commit is contained in:
25
external/toxcore/c-toxcore/toxav/msi.c
vendored
25
external/toxcore/c-toxcore/toxav/msi.c
vendored
@ -27,14 +27,12 @@ typedef enum MSIHeaderID {
|
||||
ID_CAPABILITIES,
|
||||
} MSIHeaderID;
|
||||
|
||||
|
||||
typedef enum MSIRequest {
|
||||
REQU_INIT,
|
||||
REQU_PUSH,
|
||||
REQU_POP,
|
||||
} MSIRequest;
|
||||
|
||||
|
||||
typedef struct MSIHeaderRequest {
|
||||
MSIRequest value;
|
||||
bool exists;
|
||||
@ -50,14 +48,12 @@ typedef struct MSIHeaderCapabilities {
|
||||
bool exists;
|
||||
} MSIHeaderCapabilities;
|
||||
|
||||
|
||||
typedef struct MSIMessage {
|
||||
MSIHeaderRequest request;
|
||||
MSIHeaderError error;
|
||||
MSIHeaderCapabilities capabilities;
|
||||
} MSIMessage;
|
||||
|
||||
|
||||
static void msg_init(MSIMessage *dest, MSIRequest request);
|
||||
static int msg_parse_in(const Logger *log, MSIMessage *dest, const uint8_t *data, uint16_t length);
|
||||
static uint8_t *msg_parse_header_out(MSIHeaderID id, uint8_t *dest, const uint8_t *value, uint8_t value_len,
|
||||
@ -68,12 +64,11 @@ static bool invoke_callback(MSICall *call, MSICallbackID cb);
|
||||
static MSICall *get_call(MSISession *session, uint32_t friend_number);
|
||||
static MSICall *new_call(MSISession *session, uint32_t friend_number);
|
||||
static void kill_call(MSICall *call);
|
||||
static void on_peer_status(Messenger *m, uint32_t friend_number, uint8_t status, void *data);
|
||||
static void on_peer_status(Messenger *m, uint32_t friend_number, bool is_online, void *user_data);
|
||||
static void handle_init(MSICall *call, const MSIMessage *msg);
|
||||
static void handle_push(MSICall *call, const MSIMessage *msg);
|
||||
static void handle_pop(MSICall *call, const MSIMessage *msg);
|
||||
static void handle_msi_packet(Messenger *m, uint32_t friend_number, const uint8_t *data, uint16_t length, void *object);
|
||||
|
||||
static void handle_msi_packet(Messenger *m, uint32_t friend_number, const uint8_t *data, uint16_t length, void *user_data);
|
||||
|
||||
/*
|
||||
* Public functions
|
||||
@ -318,7 +313,6 @@ int msi_change_capabilities(MSICall *call, uint8_t capabilities)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Private functions
|
||||
*/
|
||||
@ -357,7 +351,6 @@ static bool check_enum_high(const Logger *log, const uint8_t *bytes, uint8_t enu
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static int msg_parse_in(const Logger *log, MSIMessage *dest, const uint8_t *data, uint16_t length)
|
||||
{
|
||||
/* Parse raw data received from socket into MSIMessage struct */
|
||||
@ -449,7 +442,7 @@ static int send_message(const Messenger *m, uint32_t friend_number, const MSIMes
|
||||
/* Parse and send message */
|
||||
assert(m != nullptr);
|
||||
|
||||
uint8_t parsed [MSI_MAXMSG_SIZE];
|
||||
uint8_t parsed[MSI_MAXMSG_SIZE];
|
||||
|
||||
uint8_t *it = parsed;
|
||||
uint16_t size = 0;
|
||||
@ -587,7 +580,7 @@ static MSICall *new_call(MSISession *session, uint32_t friend_number)
|
||||
session->calls_tail = friend_number;
|
||||
session->calls_head = friend_number;
|
||||
} else if (session->calls_tail < friend_number) { /* Appending */
|
||||
MSICall **tmp = (MSICall **)realloc(session->calls, (friend_number + 1) * sizeof(MSICall *));
|
||||
MSICall **tmp = (MSICall **)realloc(session->calls, (friend_number + 1) * sizeof(MSICall *));
|
||||
|
||||
if (tmp == nullptr) {
|
||||
free(rc);
|
||||
@ -655,11 +648,11 @@ CLEAR_CONTAINER:
|
||||
free(call);
|
||||
session->calls = nullptr;
|
||||
}
|
||||
static void on_peer_status(Messenger *m, uint32_t friend_number, uint8_t status, void *data)
|
||||
static void on_peer_status(Messenger *m, uint32_t friend_number, bool is_online, void *user_data)
|
||||
{
|
||||
MSISession *session = (MSISession *)data;
|
||||
MSISession *session = (MSISession *)user_data;
|
||||
|
||||
if (status != 0) {
|
||||
if (is_online) {
|
||||
// Friend is online.
|
||||
return;
|
||||
}
|
||||
@ -850,9 +843,9 @@ static void handle_pop(MSICall *call, const MSIMessage *msg)
|
||||
|
||||
kill_call(call);
|
||||
}
|
||||
static void handle_msi_packet(Messenger *m, uint32_t friend_number, const uint8_t *data, uint16_t length, void *object)
|
||||
static void handle_msi_packet(Messenger *m, uint32_t friend_number, const uint8_t *data, uint16_t length, void *user_data)
|
||||
{
|
||||
MSISession *session = (MSISession *)object;
|
||||
MSISession *session = (MSISession *)user_data;
|
||||
|
||||
LOGGER_DEBUG(m->log, "Got msi message");
|
||||
|
||||
|
Reference in New Issue
Block a user