hide conference joined/left events if not in a chat group #LINQT-2146
This commit is contained in:
parent
735c473b3c
commit
29691485bf
5 changed files with 36 additions and 22 deletions
|
|
@ -209,7 +209,7 @@ void ChatCore::setSelf(QSharedPointer<ChatCore> me) {
|
||||||
const std::shared_ptr<const linphone::EventLog> &eventLog) {
|
const std::shared_ptr<const linphone::EventLog> &eventLog) {
|
||||||
if (mChatModel->getMonitor() != chatRoom) return;
|
if (mChatModel->getMonitor() != chatRoom) return;
|
||||||
lDebug() << "EVENT LOG RECEIVED IN CHATROOM" << mChatModel->getTitle();
|
lDebug() << "EVENT LOG RECEIVED IN CHATROOM" << mChatModel->getTitle();
|
||||||
auto event = EventLogCore::create(eventLog);
|
auto event = EventLogCore::create(eventLog, chatRoom);
|
||||||
if (event->isHandled()) {
|
if (event->isHandled()) {
|
||||||
mChatModelConnection->invokeToCore([this, event]() { emit eventsInserted({event}); });
|
mChatModelConnection->invokeToCore([this, event]() { emit eventsInserted({event}); });
|
||||||
}
|
}
|
||||||
|
|
@ -224,7 +224,7 @@ void ChatCore::setSelf(QSharedPointer<ChatCore> me) {
|
||||||
lDebug() << "CHAT MESSAGE RECEIVED IN CHATROOM" << mChatModel->getTitle();
|
lDebug() << "CHAT MESSAGE RECEIVED IN CHATROOM" << mChatModel->getTitle();
|
||||||
QList<QSharedPointer<EventLogCore>> list;
|
QList<QSharedPointer<EventLogCore>> list;
|
||||||
for (auto &e : eventsLog) {
|
for (auto &e : eventsLog) {
|
||||||
auto event = EventLogCore::create(e);
|
auto event = EventLogCore::create(e, chatRoom);
|
||||||
list.push_back(event);
|
list.push_back(event);
|
||||||
}
|
}
|
||||||
mChatModelConnection->invokeToCore([this, list]() {
|
mChatModelConnection->invokeToCore([this, list]() {
|
||||||
|
|
@ -287,7 +287,7 @@ void ChatCore::setSelf(QSharedPointer<ChatCore> me) {
|
||||||
mChatModelConnection->makeConnectToModel(
|
mChatModelConnection->makeConnectToModel(
|
||||||
&ChatModel::chatMessageSending, [this](const std::shared_ptr<linphone::ChatRoom> &chatRoom,
|
&ChatModel::chatMessageSending, [this](const std::shared_ptr<linphone::ChatRoom> &chatRoom,
|
||||||
const std::shared_ptr<const linphone::EventLog> &eventLog) {
|
const std::shared_ptr<const linphone::EventLog> &eventLog) {
|
||||||
auto event = EventLogCore::create(eventLog);
|
auto event = EventLogCore::create(eventLog, chatRoom);
|
||||||
mChatModelConnection->invokeToCore([this, event]() { emit eventsInserted({event}); });
|
mChatModelConnection->invokeToCore([this, event]() { emit eventsInserted({event}); });
|
||||||
});
|
});
|
||||||
mChatModelConnection->makeConnectToCore(
|
mChatModelConnection->makeConnectToCore(
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,7 @@ void ChatList::setSelf(QSharedPointer<ChatList> me) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto chatCore = ChatCore::create(room);
|
auto chatCore = ChatCore::create(room);
|
||||||
addChatInList(chatCore);
|
mModelConnection->invokeToCore([this, chatCore] { addChatInList(chatCore); });
|
||||||
};
|
};
|
||||||
mModelConnection->makeConnectToModel(&CoreModel::messageReceived,
|
mModelConnection->makeConnectToModel(&CoreModel::messageReceived,
|
||||||
[this, addChatToList](const std::shared_ptr<linphone::Core> &core,
|
[this, addChatToList](const std::shared_ptr<linphone::Core> &core,
|
||||||
|
|
@ -183,9 +183,10 @@ void ChatList::setSelf(QSharedPointer<ChatList> me) {
|
||||||
lInfo() << "ChatRoom created, add it to the list" << chatRoom.get();
|
lInfo() << "ChatRoom created, add it to the list" << chatRoom.get();
|
||||||
auto chatCore = ChatCore::create(chatRoom);
|
auto chatCore = ChatCore::create(chatRoom);
|
||||||
if (chatCore) {
|
if (chatCore) {
|
||||||
|
mModelConnection->invokeToCore([this, chatCore] {
|
||||||
bool added = addChatInList(chatCore);
|
bool added = addChatInList(chatCore);
|
||||||
if (added)
|
if (added) emit chatCreated(new ChatGui(chatCore));
|
||||||
mModelConnection->invokeToCore([this, chatCore] { emit chatCreated(new ChatGui(chatCore)); });
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -26,14 +26,16 @@
|
||||||
|
|
||||||
DEFINE_ABSTRACT_OBJECT(EventLogCore)
|
DEFINE_ABSTRACT_OBJECT(EventLogCore)
|
||||||
|
|
||||||
QSharedPointer<EventLogCore> EventLogCore::create(const std::shared_ptr<const linphone::EventLog> &eventLog) {
|
QSharedPointer<EventLogCore> EventLogCore::create(const std::shared_ptr<const linphone::EventLog> &eventLog,
|
||||||
auto sharedPointer = QSharedPointer<EventLogCore>(new EventLogCore(eventLog), &QObject::deleteLater);
|
const std::shared_ptr<linphone::ChatRoom> &chatRoom) {
|
||||||
|
auto sharedPointer = QSharedPointer<EventLogCore>(new EventLogCore(eventLog, chatRoom), &QObject::deleteLater);
|
||||||
sharedPointer->setSelf(sharedPointer);
|
sharedPointer->setSelf(sharedPointer);
|
||||||
sharedPointer->moveToThread(App::getInstance()->thread());
|
sharedPointer->moveToThread(App::getInstance()->thread());
|
||||||
return sharedPointer;
|
return sharedPointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
EventLogCore::EventLogCore(const std::shared_ptr<const linphone::EventLog> &eventLog) {
|
EventLogCore::EventLogCore(const std::shared_ptr<const linphone::EventLog> &eventLog,
|
||||||
|
const std::shared_ptr<linphone::ChatRoom> &chatRoom) {
|
||||||
mustBeInLinphoneThread(getClassName());
|
mustBeInLinphoneThread(getClassName());
|
||||||
App::getInstance()->mEngine->setObjectOwnership(this, QQmlEngine::CppOwnership);
|
App::getInstance()->mEngine->setObjectOwnership(this, QQmlEngine::CppOwnership);
|
||||||
mEventLogType = LinphoneEnums::fromLinphone(eventLog->getType());
|
mEventLogType = LinphoneEnums::fromLinphone(eventLog->getType());
|
||||||
|
|
@ -52,7 +54,7 @@ EventLogCore::EventLogCore(const std::shared_ptr<const linphone::EventLog> &even
|
||||||
QString type = QString::fromLatin1(
|
QString type = QString::fromLatin1(
|
||||||
QMetaEnum::fromType<LinphoneEnums::EventLogType>().valueToKey(static_cast<int>(mEventLogType)));
|
QMetaEnum::fromType<LinphoneEnums::EventLogType>().valueToKey(static_cast<int>(mEventLogType)));
|
||||||
mEventId = type + QString::number(static_cast<qint64>(eventLog->getCreationTime()));
|
mEventId = type + QString::number(static_cast<qint64>(eventLog->getCreationTime()));
|
||||||
computeEvent(eventLog);
|
computeEvent(eventLog, chatRoom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -94,7 +96,8 @@ std::shared_ptr<EventLogModel> EventLogCore::getModel() const {
|
||||||
|
|
||||||
// Events (other than ChatMessage and CallLog which are handled in their respective Core)
|
// Events (other than ChatMessage and CallLog which are handled in their respective Core)
|
||||||
|
|
||||||
void EventLogCore::computeEvent(const std::shared_ptr<const linphone::EventLog> &eventLog) {
|
void EventLogCore::computeEvent(const std::shared_ptr<const linphone::EventLog> &eventLog,
|
||||||
|
const std::shared_ptr<linphone::ChatRoom> &chatRoom) {
|
||||||
mustBeInLinphoneThread(getClassName());
|
mustBeInLinphoneThread(getClassName());
|
||||||
mHandled = true;
|
mHandled = true;
|
||||||
mImportant = false;
|
mImportant = false;
|
||||||
|
|
@ -104,9 +107,15 @@ void EventLogCore::computeEvent(const std::shared_ptr<const linphone::EventLog>
|
||||||
|
|
||||||
switch (eventLog->getType()) {
|
switch (eventLog->getType()) {
|
||||||
case linphone::EventLog::Type::ConferenceCreated:
|
case linphone::EventLog::Type::ConferenceCreated:
|
||||||
|
if (chatRoom->hasCapability((int)linphone::ChatRoom::Capabilities::OneToOne) &&
|
||||||
|
!chatRoom->hasCapability((int)linphone::ChatRoom::Capabilities::Conference))
|
||||||
|
mHandled = false;
|
||||||
mEventDetails = tr("conference_created_event");
|
mEventDetails = tr("conference_created_event");
|
||||||
break;
|
break;
|
||||||
case linphone::EventLog::Type::ConferenceTerminated:
|
case linphone::EventLog::Type::ConferenceTerminated:
|
||||||
|
if (chatRoom->hasCapability((int)linphone::ChatRoom::Capabilities::OneToOne) &&
|
||||||
|
!chatRoom->hasCapability((int)linphone::ChatRoom::Capabilities::Conference))
|
||||||
|
mHandled = false;
|
||||||
mEventDetails = tr("conference_created_terminated");
|
mEventDetails = tr("conference_created_terminated");
|
||||||
mImportant = true;
|
mImportant = true;
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -51,8 +51,10 @@ class EventLogCore : public QObject, public AbstractObject {
|
||||||
Q_PROPERTY(QDateTime timestamp READ getTimestamp CONSTANT)
|
Q_PROPERTY(QDateTime timestamp READ getTimestamp CONSTANT)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static QSharedPointer<EventLogCore> create(const std::shared_ptr<const linphone::EventLog> &eventLog);
|
static QSharedPointer<EventLogCore> create(const std::shared_ptr<const linphone::EventLog> &eventLog,
|
||||||
EventLogCore(const std::shared_ptr<const linphone::EventLog> &eventLog);
|
const std::shared_ptr<linphone::ChatRoom> &chatRoom);
|
||||||
|
EventLogCore(const std::shared_ptr<const linphone::EventLog> &eventLog,
|
||||||
|
const std::shared_ptr<linphone::ChatRoom> &chatRoom);
|
||||||
~EventLogCore();
|
~EventLogCore();
|
||||||
void setSelf(QSharedPointer<EventLogCore> me);
|
void setSelf(QSharedPointer<EventLogCore> me);
|
||||||
QString getEventLogId();
|
QString getEventLogId();
|
||||||
|
|
@ -87,7 +89,8 @@ private:
|
||||||
ChatMessageCore *getChatMessageCorePointer();
|
ChatMessageCore *getChatMessageCorePointer();
|
||||||
CallHistoryCore *getCallHistoryCorePointer();
|
CallHistoryCore *getCallHistoryCorePointer();
|
||||||
std::shared_ptr<EventLogModel> mEventLogModel;
|
std::shared_ptr<EventLogModel> mEventLogModel;
|
||||||
void computeEvent(const std::shared_ptr<const linphone::EventLog> &eventLog);
|
void computeEvent(const std::shared_ptr<const linphone::EventLog> &eventLog,
|
||||||
|
const std::shared_ptr<linphone::ChatRoom> &chatRoom);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // EventLogCore_H_
|
#endif // EventLogCore_H_
|
||||||
|
|
|
||||||
|
|
@ -138,7 +138,7 @@ void EventLogList::displayMore() {
|
||||||
auto linphoneLogs = chatModel->getHistoryRange(totalItemsCount, newCount);
|
auto linphoneLogs = chatModel->getHistoryRange(totalItemsCount, newCount);
|
||||||
QList<QSharedPointer<EventLogCore>> *events = new QList<QSharedPointer<EventLogCore>>();
|
QList<QSharedPointer<EventLogCore>> *events = new QList<QSharedPointer<EventLogCore>>();
|
||||||
for (auto it : linphoneLogs) {
|
for (auto it : linphoneLogs) {
|
||||||
auto model = EventLogCore::create(it);
|
auto model = EventLogCore::create(it, chatModel->getMonitor());
|
||||||
events->push_back(model);
|
events->push_back(model);
|
||||||
}
|
}
|
||||||
mCoreModelConnection->invokeToCore([this, events] {
|
mCoreModelConnection->invokeToCore([this, events] {
|
||||||
|
|
@ -176,16 +176,17 @@ void EventLogList::loadMessagesUpTo(std::shared_ptr<linphone::EventLog> event) {
|
||||||
auto beforeEvents = chatModel->getHistoryRangeNear(mItemsToLoadBeforeSearchResult, 0, event, filters);
|
auto beforeEvents = chatModel->getHistoryRangeNear(mItemsToLoadBeforeSearchResult, 0, event, filters);
|
||||||
auto linphoneLogs = chatModel->getHistoryRangeBetween(event, linOldest, filters);
|
auto linphoneLogs = chatModel->getHistoryRangeBetween(event, linOldest, filters);
|
||||||
QList<QSharedPointer<EventLogCore>> *events = new QList<QSharedPointer<EventLogCore>>();
|
QList<QSharedPointer<EventLogCore>> *events = new QList<QSharedPointer<EventLogCore>>();
|
||||||
for (auto it : beforeEvents) {
|
const auto &linChatRoom = chatModel->getMonitor();
|
||||||
auto model = EventLogCore::create(it);
|
for (const auto &it : beforeEvents) {
|
||||||
|
auto model = EventLogCore::create(it, linChatRoom);
|
||||||
events->push_back(model);
|
events->push_back(model);
|
||||||
}
|
}
|
||||||
for (auto it : linphoneLogs) {
|
for (const auto &it : linphoneLogs) {
|
||||||
auto model = EventLogCore::create(it);
|
auto model = EventLogCore::create(it, linChatRoom);
|
||||||
events->push_back(model);
|
events->push_back(model);
|
||||||
}
|
}
|
||||||
mCoreModelConnection->invokeToCore([this, events, event] {
|
mCoreModelConnection->invokeToCore([this, events, event] {
|
||||||
for (auto &e : *events) {
|
for (const auto &e : *events) {
|
||||||
connectItem(e);
|
connectItem(e);
|
||||||
add(e);
|
add(e);
|
||||||
}
|
}
|
||||||
|
|
@ -286,7 +287,7 @@ void EventLogList::setSelf(QSharedPointer<EventLogList> me) {
|
||||||
auto linphoneLogs = chatModel->getHistoryRange(0, mDisplayItemsStep);
|
auto linphoneLogs = chatModel->getHistoryRange(0, mDisplayItemsStep);
|
||||||
QList<QSharedPointer<EventLogCore>> *events = new QList<QSharedPointer<EventLogCore>>();
|
QList<QSharedPointer<EventLogCore>> *events = new QList<QSharedPointer<EventLogCore>>();
|
||||||
for (auto it : linphoneLogs) {
|
for (auto it : linphoneLogs) {
|
||||||
auto model = EventLogCore::create(it);
|
auto model = EventLogCore::create(it, chatModel->getMonitor());
|
||||||
events->push_back(model);
|
events->push_back(model);
|
||||||
}
|
}
|
||||||
mCoreModelConnection->invokeToCore([this, events] {
|
mCoreModelConnection->invokeToCore([this, events] {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue