Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Add correction message type" #748

Merged
merged 1 commit into from
Feb 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions toxcore/Messenger.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}
Expand Down
5 changes: 1 addition & 4 deletions toxcore/Messenger.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@

enum {
MESSAGE_NORMAL,
MESSAGE_ACTION,
MESSAGE_CORRECTION,
MESSAGE_LAST
MESSAGE_ACTION
};

/* NOTE: Packet ids below 24 must never be used. */
Expand All @@ -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
Expand Down
40 changes: 19 additions & 21 deletions toxcore/group.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -2098,9 +2083,24 @@ 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;
}

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, 0, newmsg, msg_data_len, userdata);
}

break;
}

case PACKET_ID_ACTION: {
if (msg_data_len == 0) {
return;
}
Expand All @@ -2111,9 +2111,7 @@ 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, 1, newmsg, msg_data_len, userdata);
}

break;
Expand Down
6 changes: 0 additions & 6 deletions toxcore/group.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 0 additions & 5 deletions toxcore/tox.api.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}


Expand Down
4 changes: 1 addition & 3 deletions toxcore/tox.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 0 additions & 6 deletions toxcore/tox.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;


Expand Down