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

Add back JOIN/EXIT events for conferences. #795

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 2 additions & 0 deletions toxcore/group.c
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ static int addpeer(Group_Chats *g_c, int groupnumber, const uint8_t *real_pk, co

if (do_gc_callback && g_c->group_namelistchange) {
g_c->group_namelistchange(g_c->m, groupnumber, 0, CHAT_CHANGE_OCCURRED, userdata);
g_c->group_namelistchange(g_c->m, groupnumber, g->numpeers - 1, CHAT_CHANGE_PEER_JOIN, userdata);
}

if (g->peer_on_join) {
Expand Down Expand Up @@ -544,6 +545,7 @@ static int delpeer(Group_Chats *g_c, int groupnumber, int peer_index, void *user

if (g_c->group_namelistchange) {
g_c->group_namelistchange(g_c->m, groupnumber, 0, CHAT_CHANGE_OCCURRED, userdata);
g_c->group_namelistchange(g_c->m, groupnumber, peer_index, CHAT_CHANGE_PEER_EXIT, userdata);
}

if (g->peer_on_leave) {
Expand Down
2 changes: 2 additions & 0 deletions toxcore/group.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ void g_callback_group_title(Group_Chats *g_c, void (*function)(Messenger *m, uin
enum {
CHAT_CHANGE_OCCURRED,
CHAT_CHANGE_PEER_NAME,
CHAT_CHANGE_PEER_JOIN,
CHAT_CHANGE_PEER_EXIT,
};
void g_callback_group_namelistchange(Group_Chats *g_c, void (*function)(Messenger *m, int, int, uint8_t, void *));

Expand Down
18 changes: 18 additions & 0 deletions toxcore/tox.api.h
Original file line number Diff line number Diff line change
Expand Up @@ -2064,6 +2064,10 @@ namespace conference {
* The invitation will remain valid until the inviting friend goes offline
* or exits the conference.
*
* The friend_number can be -1, which means this is a synthesised invite
* event coming from an already joined conference that is being re-joined
* after restart or reconnect.
*
* @param friend_number The friend who invited us.
* @param type The conference type (text only or audio/video).
* @param cookie A piece of data of variable length required to join the
Expand Down Expand Up @@ -2118,6 +2122,20 @@ namespace conference {
* A peer has changed their name.
*/
PEER_NAME_CHANGE,
/**
* A peer has joined the conference.
*
* @deprecated Join/exit events are unreliable due to unstable peer numbers.
* Prefer to listen for $LIST_CHANGED and rebuild the peer list from
* scratch. This enumerator will be removed in v0.3.0.
*/
PEER_JOIN,
/**
* A peer has left the conference.
*
* @deprecated See $PEER_JOIN.
*/
PEER_EXIT,
}

/**
Expand Down
20 changes: 20 additions & 0 deletions toxcore/tox.h
Original file line number Diff line number Diff line change
Expand Up @@ -2333,6 +2333,10 @@ typedef enum TOX_CONFERENCE_TYPE {
* The invitation will remain valid until the inviting friend goes offline
* or exits the conference.
*
* The friend_number can be -1, which means this is a synthesised invite
* event coming from an already joined conference that is being re-joined
* after restart or reconnect.
*
* @param friend_number The friend who invited us.
* @param type The conference type (text only or audio/video).
* @param cookie A piece of data of variable length required to join the
Expand Down Expand Up @@ -2403,6 +2407,22 @@ typedef enum TOX_CONFERENCE_STATE_CHANGE {
*/
TOX_CONFERENCE_STATE_CHANGE_PEER_NAME_CHANGE,

/**
Copy link

@zoff99 zoff99 Feb 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strange naming?

above in group.h it's "chat" old naming:
CHAT_CHANGE_PEER_NAME

in tox.h now its suddenly "conference":
TOX_CONFERENCE_STATE_CHANGE_PEER_NAME_CHANGE

also the enums are renamed and the values shuffled. why? (this is why enums suck, values get assigned in some magical way)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't change the name in this PR and I'm not going to change it now, because this whole event will go away later. The enum values are shuffled because this is an incompatible change anyway, and it's easier to remove the ones at the end than at the beginning (removing the beginning would be another ABI breaking change).

* A peer has joined the conference.
*
* @deprecated Join/exit events are unreliable due to unstable peer numbers.
* Prefer to listen for TOX_CONFERENCE_STATE_CHANGE_LIST_CHANGED and rebuild the peer list from
* scratch. This enumerator will be removed in v0.3.0.
*/
TOX_CONFERENCE_STATE_CHANGE_PEER_JOIN,

/**
* A peer has left the conference.
*
* @deprecated See TOX_CONFERENCE_STATE_CHANGE_PEER_JOIN.
*/
TOX_CONFERENCE_STATE_CHANGE_PEER_EXIT,

} TOX_CONFERENCE_STATE_CHANGE;


Expand Down