diff options
-rw-r--r-- | toxcore/Messenger.c | 6 | ||||
-rw-r--r-- | toxcore/Messenger.h | 5 | ||||
-rw-r--r-- | toxcore/group.c | 40 | ||||
-rw-r--r-- | toxcore/group.h | 6 | ||||
-rw-r--r-- | toxcore/tox.api.h | 5 | ||||
-rw-r--r-- | toxcore/tox.c | 4 | ||||
-rw-r--r-- | toxcore/tox.h | 6 |
7 files changed, 23 insertions, 49 deletions
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index c665a1f8..73fab888 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c | |||
@@ -489,8 +489,7 @@ int m_friend_exists(const Messenger *m, int32_t friendnumber) | |||
489 | int m_send_message_generic(Messenger *m, int32_t friendnumber, uint8_t type, const uint8_t *message, uint32_t length, | 489 | int m_send_message_generic(Messenger *m, int32_t friendnumber, uint8_t type, const uint8_t *message, uint32_t length, |
490 | uint32_t *message_id) | 490 | uint32_t *message_id) |
491 | { | 491 | { |
492 | /* MESSAGE_LAST itself is incorrect value */ | 492 | if (type > MESSAGE_ACTION) { |
493 | if (type >= MESSAGE_LAST) { | ||
494 | return -5; | 493 | return -5; |
495 | } | 494 | } |
496 | 495 | ||
@@ -2216,8 +2215,7 @@ static int m_handle_packet(void *object, int i, const uint8_t *temp, uint16_t le | |||
2216 | } | 2215 | } |
2217 | 2216 | ||
2218 | case PACKET_ID_MESSAGE: // fall-through | 2217 | case PACKET_ID_MESSAGE: // fall-through |
2219 | case PACKET_ID_ACTION: | 2218 | case PACKET_ID_ACTION: { |
2220 | case PACKET_ID_CORRECTION: { | ||
2221 | if (data_length == 0) { | 2219 | if (data_length == 0) { |
2222 | break; | 2220 | break; |
2223 | } | 2221 | } |
diff --git a/toxcore/Messenger.h b/toxcore/Messenger.h index 26977036..6bf1bce8 100644 --- a/toxcore/Messenger.h +++ b/toxcore/Messenger.h | |||
@@ -46,9 +46,7 @@ | |||
46 | 46 | ||
47 | enum { | 47 | enum { |
48 | MESSAGE_NORMAL, | 48 | MESSAGE_NORMAL, |
49 | MESSAGE_ACTION, | 49 | MESSAGE_ACTION |
50 | MESSAGE_CORRECTION, | ||
51 | MESSAGE_LAST | ||
52 | }; | 50 | }; |
53 | 51 | ||
54 | /* NOTE: Packet ids below 24 must never be used. */ | 52 | /* NOTE: Packet ids below 24 must never be used. */ |
@@ -60,7 +58,6 @@ enum { | |||
60 | #define PACKET_ID_TYPING 51 | 58 | #define PACKET_ID_TYPING 51 |
61 | #define PACKET_ID_MESSAGE 64 | 59 | #define PACKET_ID_MESSAGE 64 |
62 | #define PACKET_ID_ACTION (PACKET_ID_MESSAGE + MESSAGE_ACTION) /* 65 */ | 60 | #define PACKET_ID_ACTION (PACKET_ID_MESSAGE + MESSAGE_ACTION) /* 65 */ |
63 | #define PACKET_ID_CORRECTION (PACKET_ID_MESSAGE + MESSAGE_CORRECTION) /* 66 */ | ||
64 | #define PACKET_ID_MSI 69 | 61 | #define PACKET_ID_MSI 69 |
65 | #define PACKET_ID_FILE_SENDREQUEST 80 | 62 | #define PACKET_ID_FILE_SENDREQUEST 80 |
66 | #define PACKET_ID_FILE_CONTROL 81 | 63 | #define PACKET_ID_FILE_CONTROL 81 |
diff --git a/toxcore/group.c b/toxcore/group.c index c929d995..3f14e8ce 100644 --- a/toxcore/group.c +++ b/toxcore/group.c | |||
@@ -1956,21 +1956,6 @@ int group_action_send(const Group_Chats *g_c, int groupnumber, const uint8_t *ac | |||
1956 | return ret; | 1956 | return ret; |
1957 | } | 1957 | } |
1958 | 1958 | ||
1959 | /* send a group correction message | ||
1960 | * return 0 on success | ||
1961 | * see: send_message_group() for error codes. | ||
1962 | */ | ||
1963 | int group_correction_send(const Group_Chats *g_c, int groupnumber, const uint8_t *action, uint16_t length) | ||
1964 | { | ||
1965 | int ret = send_message_group(g_c, groupnumber, PACKET_ID_CORRECTION, action, length); | ||
1966 | |||
1967 | if (ret > 0) { | ||
1968 | return 0; | ||
1969 | } | ||
1970 | |||
1971 | return ret; | ||
1972 | } | ||
1973 | |||
1974 | /* High level function to send custom lossy packets. | 1959 | /* High level function to send custom lossy packets. |
1975 | * | 1960 | * |
1976 | * return -1 on failure. | 1961 | * return -1 on failure. |
@@ -2098,9 +2083,24 @@ static void handle_message_packet_group(Group_Chats *g_c, int groupnumber, const | |||
2098 | } | 2083 | } |
2099 | break; | 2084 | break; |
2100 | 2085 | ||
2101 | case PACKET_ID_MESSAGE: | 2086 | case PACKET_ID_MESSAGE: { |
2102 | case PACKET_ID_ACTION: | 2087 | if (msg_data_len == 0) { |
2103 | case PACKET_ID_CORRECTION: { | 2088 | return; |
2089 | } | ||
2090 | |||
2091 | VLA(uint8_t, newmsg, msg_data_len + 1); | ||
2092 | memcpy(newmsg, msg_data, msg_data_len); | ||
2093 | newmsg[msg_data_len] = 0; | ||
2094 | |||
2095 | // TODO(irungentoo): | ||
2096 | if (g_c->message_callback) { | ||
2097 | g_c->message_callback(g_c->m, groupnumber, index, 0, newmsg, msg_data_len, userdata); | ||
2098 | } | ||
2099 | |||
2100 | break; | ||
2101 | } | ||
2102 | |||
2103 | case PACKET_ID_ACTION: { | ||
2104 | if (msg_data_len == 0) { | 2104 | if (msg_data_len == 0) { |
2105 | return; | 2105 | return; |
2106 | } | 2106 | } |
@@ -2111,9 +2111,7 @@ static void handle_message_packet_group(Group_Chats *g_c, int groupnumber, const | |||
2111 | 2111 | ||
2112 | // TODO(irungentoo): | 2112 | // TODO(irungentoo): |
2113 | if (g_c->message_callback) { | 2113 | if (g_c->message_callback) { |
2114 | uint8_t chat_message_id = message_id - PACKET_ID_MESSAGE; | 2114 | g_c->message_callback(g_c->m, groupnumber, index, 1, newmsg, msg_data_len, userdata); |
2115 | g_c->message_callback(g_c->m, groupnumber, index, chat_message_id, | ||
2116 | newmsg, msg_data_len, userdata); | ||
2117 | } | 2115 | } |
2118 | 2116 | ||
2119 | break; | 2117 | break; |
diff --git a/toxcore/group.h b/toxcore/group.h index 6c0baebf..2e014da3 100644 --- a/toxcore/group.h +++ b/toxcore/group.h | |||
@@ -238,12 +238,6 @@ int group_message_send(const Group_Chats *g_c, int groupnumber, const uint8_t *m | |||
238 | */ | 238 | */ |
239 | int group_action_send(const Group_Chats *g_c, int groupnumber, const uint8_t *action, uint16_t length); | 239 | int group_action_send(const Group_Chats *g_c, int groupnumber, const uint8_t *action, uint16_t length); |
240 | 240 | ||
241 | /* send a group correction message | ||
242 | * return 0 on success | ||
243 | * see: send_message_group() for error codes. | ||
244 | */ | ||
245 | int group_correction_send(const Group_Chats *g_c, int groupnumber, const uint8_t *action, uint16_t length); | ||
246 | |||
247 | /* set the group's title, limited to MAX_NAME_LENGTH | 241 | /* set the group's title, limited to MAX_NAME_LENGTH |
248 | * return 0 on success | 242 | * return 0 on success |
249 | * return -1 if groupnumber is invalid. | 243 | * return -1 if groupnumber is invalid. |
diff --git a/toxcore/tox.api.h b/toxcore/tox.api.h index 7f3d8d4c..63959207 100644 --- a/toxcore/tox.api.h +++ b/toxcore/tox.api.h | |||
@@ -338,11 +338,6 @@ enum class MESSAGE_TYPE { | |||
338 | * on IRC. | 338 | * on IRC. |
339 | */ | 339 | */ |
340 | ACTION, | 340 | ACTION, |
341 | /** | ||
342 | * Correction of the last message. With empty message body can be used to mark | ||
343 | * last message as deleted. | ||
344 | */ | ||
345 | CORRECTION, | ||
346 | } | 341 | } |
347 | 342 | ||
348 | 343 | ||
diff --git a/toxcore/tox.c b/toxcore/tox.c index 7dd4a7b5..c3bcb652 100644 --- a/toxcore/tox.c +++ b/toxcore/tox.c | |||
@@ -1300,10 +1300,8 @@ bool tox_conference_send_message(Tox *tox, uint32_t conference_number, TOX_MESSA | |||
1300 | 1300 | ||
1301 | if (type == TOX_MESSAGE_TYPE_NORMAL) { | 1301 | if (type == TOX_MESSAGE_TYPE_NORMAL) { |
1302 | ret = group_message_send((Group_Chats *)m->conferences_object, conference_number, message, length); | 1302 | ret = group_message_send((Group_Chats *)m->conferences_object, conference_number, message, length); |
1303 | } else if (type == TOX_MESSAGE_TYPE_ACTION) { | 1303 | } else { |
1304 | ret = group_action_send((Group_Chats *)m->conferences_object, conference_number, message, length); | 1304 | ret = group_action_send((Group_Chats *)m->conferences_object, conference_number, message, length); |
1305 | } else if (type == TOX_MESSAGE_TYPE_CORRECTION) { | ||
1306 | ret = group_correction_send((Group_Chats *)m->conferences_object, conference_number, message, length); | ||
1307 | } | 1305 | } |
1308 | 1306 | ||
1309 | switch (ret) { | 1307 | switch (ret) { |
diff --git a/toxcore/tox.h b/toxcore/tox.h index f4f3d066..567ce7e5 100644 --- a/toxcore/tox.h +++ b/toxcore/tox.h | |||
@@ -371,12 +371,6 @@ typedef enum TOX_MESSAGE_TYPE { | |||
371 | */ | 371 | */ |
372 | TOX_MESSAGE_TYPE_ACTION, | 372 | TOX_MESSAGE_TYPE_ACTION, |
373 | 373 | ||
374 | /** | ||
375 | * Correction of the last message. With empty message body can be used to mark | ||
376 | * last message as deleted. | ||
377 | */ | ||
378 | TOX_MESSAGE_TYPE_CORRECTION, | ||
379 | |||
380 | } TOX_MESSAGE_TYPE; | 374 | } TOX_MESSAGE_TYPE; |
381 | 375 | ||
382 | 376 | ||