mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
fix(groups): fix assert on group invite accept
This commit is contained in:
parent
df62463e27
commit
0f5ad725d7
|
@ -1096,7 +1096,8 @@ bool Core::parsePeerQueryError(Tox_Err_Conference_Peer_Query error) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GroupId Core::getGroupPersistentId(uint32_t groupNumber) {
|
GroupId Core::getGroupPersistentId(uint32_t groupNumber) const
|
||||||
|
{
|
||||||
QMutexLocker ml{&coreLoopLock};
|
QMutexLocker ml{&coreLoopLock};
|
||||||
|
|
||||||
size_t conferenceIdSize = TOX_CONFERENCE_UID_SIZE;
|
size_t conferenceIdSize = TOX_CONFERENCE_UID_SIZE;
|
||||||
|
@ -1273,7 +1274,7 @@ bool Core::parseConferenceJoinError(Tox_Err_Conference_Join error) const
|
||||||
*
|
*
|
||||||
* @return Conference number on success, UINT32_MAX on failure.
|
* @return Conference number on success, UINT32_MAX on failure.
|
||||||
*/
|
*/
|
||||||
uint32_t Core::joinGroupchat(const GroupInvite& inviteInfo) const
|
uint32_t Core::joinGroupchat(const GroupInvite& inviteInfo)
|
||||||
{
|
{
|
||||||
QMutexLocker ml{&coreLoopLock};
|
QMutexLocker ml{&coreLoopLock};
|
||||||
|
|
||||||
|
@ -1282,25 +1283,30 @@ uint32_t Core::joinGroupchat(const GroupInvite& inviteInfo) const
|
||||||
const QByteArray invite = inviteInfo.getInvite();
|
const QByteArray invite = inviteInfo.getInvite();
|
||||||
const uint8_t* const cookie = reinterpret_cast<const uint8_t*>(invite.data());
|
const uint8_t* const cookie = reinterpret_cast<const uint8_t*>(invite.data());
|
||||||
const size_t cookieLength = invite.length();
|
const size_t cookieLength = invite.length();
|
||||||
|
uint32_t groupNum{std::numeric_limits<uint32_t>::max()};
|
||||||
switch (confType) {
|
switch (confType) {
|
||||||
case TOX_CONFERENCE_TYPE_TEXT: {
|
case TOX_CONFERENCE_TYPE_TEXT: {
|
||||||
qDebug() << QString("Trying to join text groupchat invite sent by friend %1").arg(friendId);
|
qDebug() << QString("Trying to join text groupchat invite sent by friend %1").arg(friendId);
|
||||||
Tox_Err_Conference_Join error;
|
Tox_Err_Conference_Join error;
|
||||||
uint32_t groupId = tox_conference_join(tox.get(), friendId, cookie, cookieLength, &error);
|
groupNum = tox_conference_join(tox.get(), friendId, cookie, cookieLength, &error);
|
||||||
return parseConferenceJoinError(error) ? groupId : std::numeric_limits<uint32_t>::max();
|
if (!parseConferenceJoinError(error)) {
|
||||||
|
groupNum = std::numeric_limits<uint32_t>::max();
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case TOX_CONFERENCE_TYPE_AV: {
|
case TOX_CONFERENCE_TYPE_AV: {
|
||||||
qDebug() << QString("Trying to join AV groupchat invite sent by friend %1").arg(friendId);
|
qDebug() << QString("Trying to join AV groupchat invite sent by friend %1").arg(friendId);
|
||||||
return toxav_join_av_groupchat(tox.get(), friendId, cookie, cookieLength,
|
groupNum = toxav_join_av_groupchat(tox.get(), friendId, cookie, cookieLength,
|
||||||
CoreAV::groupCallCallback, const_cast<Core*>(this));
|
CoreAV::groupCallCallback, const_cast<Core*>(this));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
qWarning() << "joinGroupchat: Unknown groupchat type " << confType;
|
qWarning() << "joinGroupchat: Unknown groupchat type " << confType;
|
||||||
}
|
}
|
||||||
|
if (groupNum != std::numeric_limits<uint32_t>::max()) {
|
||||||
return std::numeric_limits<uint32_t>::max();
|
emit groupJoined(groupNum, getGroupPersistentId(groupNum));
|
||||||
|
}
|
||||||
|
return groupNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::groupInviteFriend(uint32_t friendId, int groupId)
|
void Core::groupInviteFriend(uint32_t friendId, int groupId)
|
||||||
|
|
|
@ -81,7 +81,7 @@ public:
|
||||||
static QStringList splitMessage(const QString& message, int maxLen);
|
static QStringList splitMessage(const QString& message, int maxLen);
|
||||||
QString getPeerName(const ToxPk& id) const;
|
QString getPeerName(const ToxPk& id) const;
|
||||||
QVector<uint32_t> getFriendList() const;
|
QVector<uint32_t> getFriendList() const;
|
||||||
GroupId getGroupPersistentId(uint32_t groupNumber);
|
GroupId getGroupPersistentId(uint32_t groupNumber) const;
|
||||||
uint32_t getGroupNumberPeers(int groupId) const;
|
uint32_t getGroupNumberPeers(int groupId) const;
|
||||||
QString getGroupPeerName(int groupId, int peerId) const;
|
QString getGroupPeerName(int groupId, int peerId) const;
|
||||||
ToxPk getGroupPeerPk(int groupId, int peerId) const;
|
ToxPk getGroupPeerPk(int groupId, int peerId) const;
|
||||||
|
@ -92,7 +92,7 @@ public:
|
||||||
|
|
||||||
bool isFriendOnline(uint32_t friendId) const;
|
bool isFriendOnline(uint32_t friendId) const;
|
||||||
bool hasFriendWithPublicKey(const ToxPk& publicKey) const;
|
bool hasFriendWithPublicKey(const ToxPk& publicKey) const;
|
||||||
uint32_t joinGroupchat(const GroupInvite& inviteInfo) const;
|
uint32_t joinGroupchat(const GroupInvite& inviteInfo);
|
||||||
void quitGroupChat(int groupId) const;
|
void quitGroupChat(int groupId) const;
|
||||||
|
|
||||||
QString getUsername() const;
|
QString getUsername() const;
|
||||||
|
@ -181,6 +181,7 @@ signals:
|
||||||
void groupTitleChanged(int groupnumber, const QString& author, const QString& title);
|
void groupTitleChanged(int groupnumber, const QString& author, const QString& title);
|
||||||
void groupPeerAudioPlaying(int groupnumber, ToxPk peerPk);
|
void groupPeerAudioPlaying(int groupnumber, ToxPk peerPk);
|
||||||
void groupSentFailed(int groupId);
|
void groupSentFailed(int groupId);
|
||||||
|
void groupJoined(int groupnumber, GroupId groupId);
|
||||||
void actionSentResult(uint32_t friendId, const QString& action, int success);
|
void actionSentResult(uint32_t friendId, const QString& action, int success);
|
||||||
|
|
||||||
void receiptRecieved(int friedId, ReceiptNum receipt);
|
void receiptRecieved(int friedId, ReceiptNum receipt);
|
||||||
|
|
|
@ -214,6 +214,7 @@ void Nexus::showMainGUI()
|
||||||
connect(core, &Core::groupTitleChanged, widget, &Widget::onGroupTitleChanged);
|
connect(core, &Core::groupTitleChanged, widget, &Widget::onGroupTitleChanged);
|
||||||
connect(core, &Core::groupPeerAudioPlaying, widget, &Widget::onGroupPeerAudioPlaying);
|
connect(core, &Core::groupPeerAudioPlaying, widget, &Widget::onGroupPeerAudioPlaying);
|
||||||
connect(core, &Core::emptyGroupCreated, widget, &Widget::onEmptyGroupCreated);
|
connect(core, &Core::emptyGroupCreated, widget, &Widget::onEmptyGroupCreated);
|
||||||
|
connect(core, &Core::groupJoined, widget, &Widget::onGroupJoined);
|
||||||
connect(core, &Core::friendTypingChanged, widget, &Widget::onFriendTypingChanged);
|
connect(core, &Core::friendTypingChanged, widget, &Widget::onFriendTypingChanged);
|
||||||
connect(core, &Core::groupSentFailed, widget, &Widget::onGroupSendFailed);
|
connect(core, &Core::groupSentFailed, widget, &Widget::onGroupSendFailed);
|
||||||
connect(core, &Core::usernameSet, widget, &Widget::refreshPeerListsLocal);
|
connect(core, &Core::usernameSet, widget, &Widget::refreshPeerListsLocal);
|
||||||
|
|
|
@ -1901,6 +1901,11 @@ void Widget::onEmptyGroupCreated(int groupId, const GroupId& groupPersistentId,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Widget::onGroupJoined(int groupId, const GroupId& groupPersistentId)
|
||||||
|
{
|
||||||
|
createGroup(groupId, groupPersistentId);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Used to reset the blinking icon.
|
* @brief Used to reset the blinking icon.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -170,7 +170,8 @@ public slots:
|
||||||
void onFriendMessageReceived(int friendId, const QString& message, bool isAction);
|
void onFriendMessageReceived(int friendId, const QString& message, bool isAction);
|
||||||
void onFriendRequestReceived(const ToxPk& friendPk, const QString& message);
|
void onFriendRequestReceived(const ToxPk& friendPk, const QString& message);
|
||||||
void updateFriendActivity(const Friend* frnd);
|
void updateFriendActivity(const Friend* frnd);
|
||||||
void onEmptyGroupCreated(int groupId, const GroupId& groupPersistentId, const QString& title);
|
void onEmptyGroupCreated(int groupNum, const GroupId& groupId, const QString& title);
|
||||||
|
void onGroupJoined(int groupNum, const GroupId& groupId);
|
||||||
void onGroupInviteReceived(const GroupInvite& inviteInfo);
|
void onGroupInviteReceived(const GroupInvite& inviteInfo);
|
||||||
void onGroupInviteAccepted(const GroupInvite& inviteInfo);
|
void onGroupInviteAccepted(const GroupInvite& inviteInfo);
|
||||||
void onGroupMessageReceived(int groupnumber, int peernumber, const QString& message, bool isAction);
|
void onGroupMessageReceived(int groupnumber, int peernumber, const QString& message, bool isAction);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user