check if safe connection is being destroyed before trying lock
Add apply button and success/error toast for managing chatroom participants debug logs
This commit is contained in:
parent
d9b879fac7
commit
8df5fb833c
6 changed files with 48 additions and 9 deletions
|
|
@ -231,10 +231,8 @@ void ChatCore::setSelf(const QSharedPointer<ChatCore> &me) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mChatModel->getMonitor() != chatRoom) return;
|
if (mChatModel->getMonitor() != chatRoom) return;
|
||||||
lDebug() << log().arg("CHAT MESSAGE RECEIVED IN CHATROOM") << this << mChatModel->getTitle();
|
|
||||||
lInfo() << log().arg("Chat message received in chatroom") << this << mChatModel->getTitle();
|
lInfo() << log().arg("Chat message received in chatroom") << this << mChatModel->getTitle();
|
||||||
lInfo() << log().arg("Safe Connection =") << mChatModelConnection.get();
|
lInfo() << log().arg("Connection =") << mChatModelConnection.get();
|
||||||
lInfo() << log().arg("this =") << this;
|
|
||||||
QList<QSharedPointer<EventLogCore>> list;
|
QList<QSharedPointer<EventLogCore>> list;
|
||||||
for (auto &e : eventsLog) {
|
for (auto &e : eventsLog) {
|
||||||
if (!e) {
|
if (!e) {
|
||||||
|
|
@ -391,6 +389,15 @@ void ChatCore::setSelf(const QSharedPointer<ChatCore> &me) {
|
||||||
setMeAdmin(meAdmin);
|
setMeAdmin(meAdmin);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
mChatModelConnection->makeConnectToModel(
|
||||||
|
&ChatModel::participantAddressesChanged,
|
||||||
|
[this](const std::shared_ptr<linphone::ChatRoom> &chatRoom, bool success) {
|
||||||
|
if (!success) {
|
||||||
|
auto participants = buildParticipants(chatRoom);
|
||||||
|
mChatModelConnection->invokeToCore([this, participants] { setParticipants(participants); });
|
||||||
|
}
|
||||||
|
mChatModelConnection->invokeToCore([this, success] { emit participantAddressesChanged(success); });
|
||||||
|
});
|
||||||
mChatModelConnection->makeConnectToCore(&ChatCore::lRemoveParticipantAtIndex, [this](int index) {
|
mChatModelConnection->makeConnectToCore(&ChatCore::lRemoveParticipantAtIndex, [this](int index) {
|
||||||
mChatModelConnection->invokeToModel([this, index]() { mChatModel->removeParticipantAtIndex(index); });
|
mChatModelConnection->invokeToModel([this, index]() { mChatModel->removeParticipantAtIndex(index); });
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -175,6 +175,7 @@ signals:
|
||||||
void fileListChanged();
|
void fileListChanged();
|
||||||
void isSecuredChanged();
|
void isSecuredChanged();
|
||||||
void conferenceJoined();
|
void conferenceJoined();
|
||||||
|
void participantAddressesChanged(bool success);
|
||||||
|
|
||||||
void lDeleteMessage(ChatMessageGui *message);
|
void lDeleteMessage(ChatMessageGui *message);
|
||||||
void lDelete();
|
void lDelete();
|
||||||
|
|
|
||||||
|
|
@ -237,17 +237,23 @@ void ChatModel::toggleParticipantAdminStatusAtIndex(int index) const {
|
||||||
mMonitor->setParticipantAdminStatus(participant, !participant->isAdmin());
|
mMonitor->setParticipantAdminStatus(participant, !participant->isAdmin());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatModel::setParticipantAddresses(const QStringList &addresses) const {
|
void ChatModel::setParticipantAddresses(const QStringList &addresses) {
|
||||||
QSet<QString> s{addresses.cbegin(), addresses.cend()};
|
QSet<QString> s{addresses.cbegin(), addresses.cend()};
|
||||||
|
bool soFarSoGood = true;
|
||||||
for (auto p : mMonitor->getParticipants()) {
|
for (auto p : mMonitor->getParticipants()) {
|
||||||
auto address = Utils::coreStringToAppString(p->getAddress()->asStringUriOnly());
|
auto address = Utils::coreStringToAppString(p->getAddress()->asStringUriOnly());
|
||||||
if (s.contains(address)) s.remove(address);
|
if (s.contains(address)) s.remove(address);
|
||||||
else mMonitor->removeParticipant(p);
|
else {
|
||||||
|
mMonitor->removeParticipants({p});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (const auto &a : s) {
|
for (const auto &a : s) {
|
||||||
auto address = linphone::Factory::get()->createAddress(Utils::appStringToCoreString(a));
|
auto address = linphone::Factory::get()->createAddress(Utils::appStringToCoreString(a));
|
||||||
if (address) mMonitor->addParticipant(address);
|
if (address) {
|
||||||
|
soFarSoGood &= mMonitor->addParticipants({address});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
emit participantAddressesChanged(mMonitor, soFarSoGood);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------//
|
//---------------------------------------------------------------//
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ public:
|
||||||
void setEphemeralLifetime(int time);
|
void setEphemeralLifetime(int time);
|
||||||
void setSubject(QString subject) const;
|
void setSubject(QString subject) const;
|
||||||
void removeParticipantAtIndex(int index) const;
|
void removeParticipantAtIndex(int index) const;
|
||||||
void setParticipantAddresses(const QStringList &addresses) const;
|
void setParticipantAddresses(const QStringList &addresses);
|
||||||
void toggleParticipantAdminStatusAtIndex(int index) const;
|
void toggleParticipantAdminStatusAtIndex(int index) const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
@ -94,6 +94,7 @@ signals:
|
||||||
void mutedChanged(bool muted);
|
void mutedChanged(bool muted);
|
||||||
void ephemeralEnableChanged(bool enable);
|
void ephemeralEnableChanged(bool enable);
|
||||||
void ephemeralLifetimeChanged(int time);
|
void ephemeralLifetimeChanged(int time);
|
||||||
|
void participantAddressesChanged(const std::shared_ptr<linphone::ChatRoom> &chatRoom, bool success);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DECLARE_ABSTRACT_OBJECT
|
DECLARE_ABSTRACT_OBJECT
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ template <class A, class B>
|
||||||
class SafeConnection : public QObject {
|
class SafeConnection : public QObject {
|
||||||
// Use create functions.
|
// Use create functions.
|
||||||
protected:
|
protected:
|
||||||
SafeConnection(const QSharedPointer<A> &a, std::shared_ptr<B> b)
|
SafeConnection(QSharedPointer<A> a, std::shared_ptr<B> b)
|
||||||
: mCore(a), mModel(b), mCoreObject(a.get()), mModelObject(b.get()) {
|
: mCore(a), mModel(b), mCoreObject(a.get()), mModelObject(b.get()) {
|
||||||
}
|
}
|
||||||
SafeConnection(QSharedPointer<A> a, QSharedPointer<B> b)
|
SafeConnection(QSharedPointer<A> a, QSharedPointer<B> b)
|
||||||
|
|
@ -150,6 +150,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
bool tryLock() {
|
bool tryLock() {
|
||||||
|
if (!this) return false;
|
||||||
mLocker.lock();
|
mLocker.lock();
|
||||||
auto coreLocked = mCore.lock();
|
auto coreLocked = mCore.lock();
|
||||||
auto modelLocked = mModel.lock();
|
auto modelLocked = mModel.lock();
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,22 @@ Rectangle {
|
||||||
height: participantAddColumn.implicitHeight
|
height: participantAddColumn.implicitHeight
|
||||||
signal done()
|
signal done()
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
enabled: chatGui !== null
|
||||||
|
target: chatGui.core
|
||||||
|
function onParticipantAddressesChanged(success) {
|
||||||
|
if (!success) UtilsCpp.showInformationPopup(qsTr("info_popup_error_title"),
|
||||||
|
//: Error while setting participants !
|
||||||
|
qsTr("info_popup_manage_participant_error_message"), false)
|
||||||
|
else {
|
||||||
|
mainItem.done()
|
||||||
|
UtilsCpp.showInformationPopup(qsTr("info_popup_success_title"),
|
||||||
|
//: Participants updated
|
||||||
|
qsTr("info_popup_manage_participant_updated_message"), true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
id: participantAddColumn
|
id: participantAddColumn
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
@ -36,7 +52,6 @@ Rectangle {
|
||||||
style: ButtonStyle.noBackground
|
style: ButtonStyle.noBackground
|
||||||
icon.source: AppIcons.leftArrow
|
icon.source: AppIcons.leftArrow
|
||||||
onClicked: {
|
onClicked: {
|
||||||
mainItem.chatGui.core.lSetParticipantsAddresses(manageParticipantsLayout.selectedParticipants)
|
|
||||||
mainItem.done()
|
mainItem.done()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -47,6 +62,14 @@ Rectangle {
|
||||||
font: Typography.h4
|
font: Typography.h4
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
}
|
}
|
||||||
|
MediumButton {
|
||||||
|
id: manageParticipantsApplyButton
|
||||||
|
//: Apply
|
||||||
|
text: qsTr("apply_button_text")
|
||||||
|
onClicked: {
|
||||||
|
mainItem.chatGui.core.lSetParticipantsAddresses(manageParticipantsLayout.selectedParticipants)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
AddParticipantsForm {
|
AddParticipantsForm {
|
||||||
id: manageParticipantsLayout
|
id: manageParticipantsLayout
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue