Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
fix(core): Adapt qtox to new conferences state change callback.
Browse files Browse the repository at this point in the history
  • Loading branch information
iphydf authored and sudden6 committed Feb 24, 2018
1 parent e73dc10 commit 1111949
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
20 changes: 18 additions & 2 deletions src/core/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ void Core::onConnectionStatusChanged(Tox*, uint32_t friendId, TOX_CONNECTION sta
}
}

void Core::onGroupInvite(Tox*, uint32_t friendId, TOX_CONFERENCE_TYPE type, const uint8_t* cookie,
void Core::onGroupInvite(Tox* tox, uint32_t friendId, TOX_CONFERENCE_TYPE type, const uint8_t* cookie,
size_t length, void* vCore)
{
Core* core = static_cast<Core*>(vCore);
Expand All @@ -513,11 +513,22 @@ void Core::onGroupInvite(Tox*, uint32_t friendId, TOX_CONFERENCE_TYPE type, cons
switch (type) {
case TOX_CONFERENCE_TYPE_TEXT:
qDebug() << QString("Text group invite by %1").arg(friendId);
if (friendId == UINT32_MAX) {
// Rejoining existing (persistent) conference after disconnect and reconnect.
tox_conference_join(tox, friendId, cookie, length, nullptr);
return;
}
emit core->groupInviteReceived(inviteInfo);
break;

case TOX_CONFERENCE_TYPE_AV:
qDebug() << QString("AV group invite by %1").arg(friendId);
if (friendId == UINT32_MAX) {
// Rejoining existing (persistent) AV conference after disconnect and reconnect.
toxav_join_av_groupchat(tox, friendId, cookie, length,
CoreAV::groupCallCallback, core);
return;
}
emit core->groupInviteReceived(inviteInfo);
break;

Expand All @@ -539,7 +550,12 @@ void Core::onGroupNamelistChange(Tox*, uint32_t groupId, uint32_t peerId,
TOX_CONFERENCE_STATE_CHANGE change, void* core)
{
CoreAV* coreAv = static_cast<Core*>(core)->getAv();
if (change == TOX_CONFERENCE_STATE_CHANGE_PEER_EXIT && coreAv->isGroupAvEnabled(groupId)) {
#if TOX_VERSION_IS_API_COMPATIBLE(0, 2, 0)
const auto changed = change == TOX_CONFERENCE_STATE_CHANGE_LIST_CHANGED;
#else
const auto changed = change == TOX_CONFERENCE_STATE_CHANGE_PEER_EXIT;
#endif
if (changed && coreAv->isGroupAvEnabled(groupId)) {
CoreAV::invalidateGroupCallPeerSource(groupId, peerId);
}

Expand Down
13 changes: 5 additions & 8 deletions src/widget/widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1748,18 +1748,15 @@ void Widget::onGroupNamelistChanged(int groupnumber, int peernumber, uint8_t Cha
}

TOX_CONFERENCE_STATE_CHANGE change = static_cast<TOX_CONFERENCE_STATE_CHANGE>(Change);
#if TOX_VERSION_IS_API_COMPATIBLE(0, 2, 0)
if (change == TOX_CONFERENCE_STATE_CHANGE_LIST_CHANGED) {
g->regeneratePeerList();
#else
if (change == TOX_CONFERENCE_STATE_CHANGE_PEER_JOIN) {
// g->addPeer(peernumber,name);
g->regeneratePeerList();
// g->getChatForm()->addSystemInfoMessage(tr("%1 has joined the chat").arg(name), "white",
// QDateTime::currentDateTime());
// we can't display these messages until toxcore fixes peernumbers
// https://github.com/irungentoo/toxcore/issues/1128
} else if (change == TOX_CONFERENCE_STATE_CHANGE_PEER_EXIT) {
// g->removePeer(peernumber);
g->regeneratePeerList();
// g->getChatForm()->addSystemInfoMessage(tr("%1 has left the chat").arg(name), "white",
// QDateTime::currentDateTime());
#endif
} else if (change == TOX_CONFERENCE_STATE_CHANGE_PEER_NAME_CHANGE) // core overwrites old name
// before telling us it
// changed...
Expand Down

0 comments on commit 1111949

Please sign in to comment.