1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

fix(core): Adapt qtox to new conferences state change callback.

This commit is contained in:
iphydf 2018-02-09 14:18:32 +03:00 committed by sudden6
parent e73dc10c7f
commit 1111949f45
No known key found for this signature in database
GPG Key ID: 279509B499E032B9
2 changed files with 23 additions and 10 deletions

View File

@ -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) size_t length, void* vCore)
{ {
Core* core = static_cast<Core*>(vCore); Core* core = static_cast<Core*>(vCore);
@ -513,11 +513,22 @@ void Core::onGroupInvite(Tox*, uint32_t friendId, TOX_CONFERENCE_TYPE type, cons
switch (type) { switch (type) {
case TOX_CONFERENCE_TYPE_TEXT: case TOX_CONFERENCE_TYPE_TEXT:
qDebug() << QString("Text group invite by %1").arg(friendId); 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); emit core->groupInviteReceived(inviteInfo);
break; break;
case TOX_CONFERENCE_TYPE_AV: case TOX_CONFERENCE_TYPE_AV:
qDebug() << QString("AV group invite by %1").arg(friendId); 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); emit core->groupInviteReceived(inviteInfo);
break; break;
@ -539,7 +550,12 @@ void Core::onGroupNamelistChange(Tox*, uint32_t groupId, uint32_t peerId,
TOX_CONFERENCE_STATE_CHANGE change, void* core) TOX_CONFERENCE_STATE_CHANGE change, void* core)
{ {
CoreAV* coreAv = static_cast<Core*>(core)->getAv(); 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); CoreAV::invalidateGroupCallPeerSource(groupId, peerId);
} }

View File

@ -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); 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) { if (change == TOX_CONFERENCE_STATE_CHANGE_PEER_JOIN) {
// g->addPeer(peernumber,name);
g->regeneratePeerList(); 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) { } else if (change == TOX_CONFERENCE_STATE_CHANGE_PEER_EXIT) {
// g->removePeer(peernumber);
g->regeneratePeerList(); g->regeneratePeerList();
// g->getChatForm()->addSystemInfoMessage(tr("%1 has left the chat").arg(name), "white", #endif
// QDateTime::currentDateTime());
} else if (change == TOX_CONFERENCE_STATE_CHANGE_PEER_NAME_CHANGE) // core overwrites old name } else if (change == TOX_CONFERENCE_STATE_CHANGE_PEER_NAME_CHANGE) // core overwrites old name
// before telling us it // before telling us it
// changed... // changed...