mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Added actions to group chats.
This commit is contained in:
parent
da723e93f1
commit
d6685d1c9a
@ -893,6 +893,17 @@ void g_callback_group_message(Group_Chats *g_c, void (*function)(Messenger *m, i
|
|||||||
g_c->message_callback_userdata = userdata;
|
g_c->message_callback_userdata = userdata;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Set the callback for group actions.
|
||||||
|
*
|
||||||
|
* Function(Group_Chats *g_c, int groupnumber, int friendgroupnumber, uint8_t * message, uint16_t length, void *userdata)
|
||||||
|
*/
|
||||||
|
void g_callback_group_action(Group_Chats *g_c, void (*function)(Messenger *m, int, int, const uint8_t *, uint16_t,
|
||||||
|
void *), void *userdata)
|
||||||
|
{
|
||||||
|
g_c->action_callback = function;
|
||||||
|
g_c->action_callback_userdata = userdata;
|
||||||
|
}
|
||||||
|
|
||||||
/* Set callback function for peer name list changes.
|
/* Set callback function for peer name list changes.
|
||||||
*
|
*
|
||||||
* It gets called every time the name list changes(new peer/name, deleted peer)
|
* 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
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* send a group action
|
||||||
|
* return 0 on success
|
||||||
|
* return -1 on failure
|
||||||
|
*/
|
||||||
|
int group_action_send(const Group_Chats *g_c, int groupnumber, const uint8_t *action, uint16_t length)
|
||||||
|
{
|
||||||
|
if (send_message_group(g_c, groupnumber, PACKET_ID_ACTION, action, length)) {
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void handle_message_packet_group(Group_Chats *g_c, int groupnumber, const uint8_t *data, uint16_t length,
|
static void handle_message_packet_group(Group_Chats *g_c, int groupnumber, const uint8_t *data, uint16_t length,
|
||||||
int close_index)
|
int close_index)
|
||||||
{
|
{
|
||||||
@ -1485,6 +1509,21 @@ static void handle_message_packet_group(Group_Chats *g_c, int groupnumber, const
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case PACKET_ID_ACTION: {
|
||||||
|
if (msg_data_len == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
uint8_t newmsg[msg_data_len + 1];
|
||||||
|
memcpy(newmsg, msg_data, msg_data_len);
|
||||||
|
newmsg[msg_data_len] = 0;
|
||||||
|
|
||||||
|
//TODO
|
||||||
|
if (g_c->action_callback)
|
||||||
|
g_c->action_callback(g_c->m, groupnumber, index, newmsg, msg_data_len, g_c->action_callback_userdata);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -98,6 +98,8 @@ typedef struct {
|
|||||||
void *invite_callback_userdata;
|
void *invite_callback_userdata;
|
||||||
void (*message_callback)(Messenger *m, int, int, const uint8_t *, uint16_t, void *);
|
void (*message_callback)(Messenger *m, int, int, const uint8_t *, uint16_t, void *);
|
||||||
void *message_callback_userdata;
|
void *message_callback_userdata;
|
||||||
|
void (*action_callback)(Messenger *m, int, int, const uint8_t *, uint16_t, void *);
|
||||||
|
void *action_callback_userdata;
|
||||||
void (*peer_namelistchange)(Messenger *m, int, int, uint8_t, void *);
|
void (*peer_namelistchange)(Messenger *m, int, int, uint8_t, void *);
|
||||||
void *group_namelistchange_userdata;
|
void *group_namelistchange_userdata;
|
||||||
} Group_Chats;
|
} Group_Chats;
|
||||||
|
@ -581,7 +581,7 @@ void tox_callback_group_action(Tox *tox, void (*function)(Messenger *tox, int, i
|
|||||||
void *userdata)
|
void *userdata)
|
||||||
{
|
{
|
||||||
Messenger *m = tox;
|
Messenger *m = tox;
|
||||||
//m_callback_group_action(m, function, userdata);
|
g_callback_group_action(m->group_chat_object, function, userdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set callback function for peer name list changes.
|
/* Set callback function for peer name list changes.
|
||||||
@ -668,8 +668,7 @@ int tox_group_message_send(Tox *tox, int groupnumber, const uint8_t *message, ui
|
|||||||
int tox_group_action_send(Tox *tox, int groupnumber, const uint8_t *action, uint16_t length)
|
int tox_group_action_send(Tox *tox, int groupnumber, const uint8_t *action, uint16_t length)
|
||||||
{
|
{
|
||||||
Messenger *m = tox;
|
Messenger *m = tox;
|
||||||
//return group_action_send(m, groupnumber, action, length);
|
return group_action_send(m->group_chat_object, groupnumber, action, length);
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if the current peernumber corresponds to ours.
|
/* Check if the current peernumber corresponds to ours.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user