mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Revert "Add correction message type"
This reverts commite16d3894c5
and commitc5976e37ea
.
This commit is contained in:
parent
83779a21ea
commit
99bfb9a4f2
|
@ -489,8 +489,7 @@ int m_friend_exists(const Messenger *m, int32_t friendnumber)
|
|||
int m_send_message_generic(Messenger *m, int32_t friendnumber, uint8_t type, const uint8_t *message, uint32_t length,
|
||||
uint32_t *message_id)
|
||||
{
|
||||
/* MESSAGE_LAST itself is incorrect value */
|
||||
if (type >= MESSAGE_LAST) {
|
||||
if (type > MESSAGE_ACTION) {
|
||||
return -5;
|
||||
}
|
||||
|
||||
|
@ -2216,8 +2215,7 @@ static int m_handle_packet(void *object, int i, const uint8_t *temp, uint16_t le
|
|||
}
|
||||
|
||||
case PACKET_ID_MESSAGE: // fall-through
|
||||
case PACKET_ID_ACTION:
|
||||
case PACKET_ID_CORRECTION: {
|
||||
case PACKET_ID_ACTION: {
|
||||
if (data_length == 0) {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -46,9 +46,7 @@
|
|||
|
||||
enum {
|
||||
MESSAGE_NORMAL,
|
||||
MESSAGE_ACTION,
|
||||
MESSAGE_CORRECTION,
|
||||
MESSAGE_LAST
|
||||
MESSAGE_ACTION
|
||||
};
|
||||
|
||||
/* NOTE: Packet ids below 24 must never be used. */
|
||||
|
@ -60,7 +58,6 @@ enum {
|
|||
#define PACKET_ID_TYPING 51
|
||||
#define PACKET_ID_MESSAGE 64
|
||||
#define PACKET_ID_ACTION (PACKET_ID_MESSAGE + MESSAGE_ACTION) /* 65 */
|
||||
#define PACKET_ID_CORRECTION (PACKET_ID_MESSAGE + MESSAGE_CORRECTION) /* 66 */
|
||||
#define PACKET_ID_MSI 69
|
||||
#define PACKET_ID_FILE_SENDREQUEST 80
|
||||
#define PACKET_ID_FILE_CONTROL 81
|
||||
|
|
|
@ -1956,21 +1956,6 @@ int group_action_send(const Group_Chats *g_c, int groupnumber, const uint8_t *ac
|
|||
return ret;
|
||||
}
|
||||
|
||||
/* send a group correction message
|
||||
* return 0 on success
|
||||
* see: send_message_group() for error codes.
|
||||
*/
|
||||
int group_correction_send(const Group_Chats *g_c, int groupnumber, const uint8_t *action, uint16_t length)
|
||||
{
|
||||
int ret = send_message_group(g_c, groupnumber, PACKET_ID_CORRECTION, action, length);
|
||||
|
||||
if (ret > 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* High level function to send custom lossy packets.
|
||||
*
|
||||
* return -1 on failure.
|
||||
|
@ -2098,9 +2083,7 @@ static void handle_message_packet_group(Group_Chats *g_c, int groupnumber, const
|
|||
}
|
||||
break;
|
||||
|
||||
case PACKET_ID_MESSAGE:
|
||||
case PACKET_ID_ACTION:
|
||||
case PACKET_ID_CORRECTION: {
|
||||
case PACKET_ID_MESSAGE: {
|
||||
if (msg_data_len == 0) {
|
||||
return;
|
||||
}
|
||||
|
@ -2111,9 +2094,24 @@ static void handle_message_packet_group(Group_Chats *g_c, int groupnumber, const
|
|||
|
||||
// TODO(irungentoo):
|
||||
if (g_c->message_callback) {
|
||||
uint8_t chat_message_id = message_id - PACKET_ID_MESSAGE;
|
||||
g_c->message_callback(g_c->m, groupnumber, index, chat_message_id,
|
||||
newmsg, msg_data_len, userdata);
|
||||
g_c->message_callback(g_c->m, groupnumber, index, 0, newmsg, msg_data_len, userdata);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case PACKET_ID_ACTION: {
|
||||
if (msg_data_len == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
VLA(uint8_t, newmsg, msg_data_len + 1);
|
||||
memcpy(newmsg, msg_data, msg_data_len);
|
||||
newmsg[msg_data_len] = 0;
|
||||
|
||||
// TODO(irungentoo):
|
||||
if (g_c->message_callback) {
|
||||
g_c->message_callback(g_c->m, groupnumber, index, 1, newmsg, msg_data_len, userdata);
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
|
@ -238,12 +238,6 @@ int group_message_send(const Group_Chats *g_c, int groupnumber, const uint8_t *m
|
|||
*/
|
||||
int group_action_send(const Group_Chats *g_c, int groupnumber, const uint8_t *action, uint16_t length);
|
||||
|
||||
/* send a group correction message
|
||||
* return 0 on success
|
||||
* see: send_message_group() for error codes.
|
||||
*/
|
||||
int group_correction_send(const Group_Chats *g_c, int groupnumber, const uint8_t *action, uint16_t length);
|
||||
|
||||
/* set the group's title, limited to MAX_NAME_LENGTH
|
||||
* return 0 on success
|
||||
* return -1 if groupnumber is invalid.
|
||||
|
|
|
@ -338,11 +338,6 @@ enum class MESSAGE_TYPE {
|
|||
* on IRC.
|
||||
*/
|
||||
ACTION,
|
||||
/**
|
||||
* Correction of the last message. With empty message body can be used to mark
|
||||
* last message as deleted.
|
||||
*/
|
||||
CORRECTION,
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1300,10 +1300,8 @@ bool tox_conference_send_message(Tox *tox, uint32_t conference_number, TOX_MESSA
|
|||
|
||||
if (type == TOX_MESSAGE_TYPE_NORMAL) {
|
||||
ret = group_message_send((Group_Chats *)m->conferences_object, conference_number, message, length);
|
||||
} else if (type == TOX_MESSAGE_TYPE_ACTION) {
|
||||
} else {
|
||||
ret = group_action_send((Group_Chats *)m->conferences_object, conference_number, message, length);
|
||||
} else if (type == TOX_MESSAGE_TYPE_CORRECTION) {
|
||||
ret = group_correction_send((Group_Chats *)m->conferences_object, conference_number, message, length);
|
||||
}
|
||||
|
||||
switch (ret) {
|
||||
|
|
|
@ -371,12 +371,6 @@ typedef enum TOX_MESSAGE_TYPE {
|
|||
*/
|
||||
TOX_MESSAGE_TYPE_ACTION,
|
||||
|
||||
/**
|
||||
* Correction of the last message. With empty message body can be used to mark
|
||||
* last message as deleted.
|
||||
*/
|
||||
TOX_MESSAGE_TYPE_CORRECTION,
|
||||
|
||||
} TOX_MESSAGE_TYPE;
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user