summaryrefslogtreecommitdiff
path: root/toxcore/group.c
diff options
context:
space:
mode:
Diffstat (limited to 'toxcore/group.c')
-rw-r--r--toxcore/group.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/toxcore/group.c b/toxcore/group.c
index 24f0b72e..0b77e013 100644
--- a/toxcore/group.c
+++ b/toxcore/group.c
@@ -893,6 +893,17 @@ void g_callback_group_message(Group_Chats *g_c, void (*function)(Messenger *m, i
893 g_c->message_callback_userdata = userdata; 893 g_c->message_callback_userdata = userdata;
894} 894}
895 895
896/* Set the callback for group actions.
897 *
898 * Function(Group_Chats *g_c, int groupnumber, int friendgroupnumber, uint8_t * message, uint16_t length, void *userdata)
899 */
900void g_callback_group_action(Group_Chats *g_c, void (*function)(Messenger *m, int, int, const uint8_t *, uint16_t,
901 void *), void *userdata)
902{
903 g_c->action_callback = function;
904 g_c->action_callback_userdata = userdata;
905}
906
896/* Set callback function for peer name list changes. 907/* Set callback function for peer name list changes.
897 * 908 *
898 * It gets called every time the name list changes(new peer/name, deleted peer) 909 * It gets called every time the name list changes(new peer/name, deleted peer)
@@ -1390,6 +1401,19 @@ int group_message_send(const Group_Chats *g_c, int groupnumber, const uint8_t *m
1390 } 1401 }
1391} 1402}
1392 1403
1404/* send a group action
1405 * return 0 on success
1406 * return -1 on failure
1407 */
1408int group_action_send(const Group_Chats *g_c, int groupnumber, const uint8_t *action, uint16_t length)
1409{
1410 if (send_message_group(g_c, groupnumber, PACKET_ID_ACTION, action, length)) {
1411 return 0;
1412 } else {
1413 return -1;
1414 }
1415}
1416
1393static void handle_message_packet_group(Group_Chats *g_c, int groupnumber, const uint8_t *data, uint16_t length, 1417static void handle_message_packet_group(Group_Chats *g_c, int groupnumber, const uint8_t *data, uint16_t length,
1394 int close_index) 1418 int close_index)
1395{ 1419{
@@ -1485,6 +1509,21 @@ static void handle_message_packet_group(Group_Chats *g_c, int groupnumber, const
1485 break; 1509 break;
1486 } 1510 }
1487 1511
1512 case PACKET_ID_ACTION: {
1513 if (msg_data_len == 0)
1514 return;
1515
1516 uint8_t newmsg[msg_data_len + 1];
1517 memcpy(newmsg, msg_data, msg_data_len);
1518 newmsg[msg_data_len] = 0;
1519
1520 //TODO
1521 if (g_c->action_callback)
1522 g_c->action_callback(g_c->m, groupnumber, index, newmsg, msg_data_len, g_c->action_callback_userdata);
1523
1524 break;
1525 }
1526
1488 default: 1527 default:
1489 return; 1528 return;
1490 } 1529 }