mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-05-07 05:23:06 +00:00
Optimisations on display chat room and on startup.
Minor update to LDAP API.
This commit is contained in:
parent
3ba5c4ec0b
commit
7f77c7bb59
7 changed files with 46 additions and 19 deletions
|
|
@ -233,15 +233,7 @@ ChatRoomModel::ChatRoomModel (std::shared_ptr<linphone::ChatRoom> chatRoom, QObj
|
|||
connect(contact, &ContactModel::contactUpdated, this, &ChatRoomModel::fullPeerAddressChanged);
|
||||
}
|
||||
}
|
||||
// Get Max updatetime from chat room and last call event
|
||||
auto callHistory = CallsListModel::getCallHistory(getParticipantAddress(), Utils::coreStringToAppString(mChatRoom->getLocalAddress()->asStringUriOnly()));
|
||||
if(callHistory.size() > 0){
|
||||
auto callDate = callHistory.front()->getStartDate();
|
||||
if( callHistory.front()->getStatus() == linphone::Call::Status::Success )
|
||||
callDate += callHistory.front()->getDuration();
|
||||
setLastUpdateTime(QDateTime::fromMSecsSinceEpoch(max(mChatRoom->getLastUpdateTime(), callDate )*1000));
|
||||
}else
|
||||
setLastUpdateTime(QDateTime::fromMSecsSinceEpoch(mChatRoom->getLastUpdateTime()*1000));
|
||||
|
||||
}else
|
||||
mParticipantListModel = nullptr;
|
||||
|
||||
|
|
@ -941,11 +933,11 @@ void ChatRoomModel::initEntries(){
|
|||
QList<std::shared_ptr<ChatEvent> > entries;
|
||||
QList<EntrySorterHelper> prepareEntries;
|
||||
// Get chat messages
|
||||
for (auto &message : mChatRoom->getHistory(mLastEntriesStep)) {
|
||||
for (auto &message : mChatRoom->getHistory(mFirstLastEntriesStep)) {
|
||||
prepareEntries << EntrySorterHelper(message->getTime() ,MessageEntry, message);
|
||||
}
|
||||
// Get events
|
||||
for(auto &eventLog : mChatRoom->getHistoryEvents(mLastEntriesStep))
|
||||
for(auto &eventLog : mChatRoom->getHistoryEvents(mFirstLastEntriesStep))
|
||||
prepareEntries << EntrySorterHelper(eventLog->getCreationTime() , NoticeEntry, eventLog);
|
||||
// Get calls.
|
||||
bool secureChatEnabled = CoreManager::getInstance()->getSettingsModel()->getSecureChatEnabled();
|
||||
|
|
@ -956,11 +948,11 @@ void ChatRoomModel::initEntries(){
|
|||
auto callHistory = CallsListModel::getCallHistory(getParticipantAddress(), Utils::coreStringToAppString(mChatRoom->getLocalAddress()->asStringUriOnly()));
|
||||
// callhistory is sorted from newest to oldest
|
||||
int count = 0;
|
||||
for (auto callLog = callHistory.begin() ; count < mLastEntriesStep && callLog != callHistory.end() ; ++callLog, ++count ){
|
||||
for (auto callLog = callHistory.begin() ; count < mFirstLastEntriesStep && callLog != callHistory.end() ; ++callLog, ++count ){
|
||||
prepareEntries << EntrySorterHelper((*callLog)->getStartDate(), CallEntry, *callLog);
|
||||
}
|
||||
}
|
||||
EntrySorterHelper::getLimitedSelection(&entries, prepareEntries, mLastEntriesStep, this);
|
||||
EntrySorterHelper::getLimitedSelection(&entries, prepareEntries, mFirstLastEntriesStep, this);
|
||||
qDebug() << "Internal Entries : Built";
|
||||
mIsInitialized = true;
|
||||
if(entries.size() >0){
|
||||
|
|
|
|||
|
|
@ -243,6 +243,7 @@ public:
|
|||
|
||||
bool mDeleteChatRoom = false; // Use as workaround because of core->deleteChatRoom() that call destructor without takking account of count ref : call it in ChatRoomModel destructor
|
||||
int mLastEntriesStep = 50; // Retrieve a part of the history to avoid too much processing
|
||||
int mFirstLastEntriesStep = 10; // Retrieve a part of the history to avoid too much processing at the init
|
||||
bool mMarkAsReadEnabled = true;
|
||||
bool mEntriesLoading = false;
|
||||
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ void LdapModel::save(){
|
|||
|
||||
void LdapModel::unsave(){
|
||||
if(mLdap)
|
||||
mLdap->removeFromConfigFile();
|
||||
CoreManager::getInstance()->getCore()->removeLdap(mLdap);
|
||||
}
|
||||
QVariantMap LdapModel::getConfig(){
|
||||
//return mConfig;
|
||||
|
|
|
|||
|
|
@ -272,12 +272,15 @@ void TimelineListModel::updateTimelines () {
|
|||
}else
|
||||
++itTimeline;
|
||||
}
|
||||
// Add new
|
||||
// Add new.
|
||||
// Call logs optimization : store all the list and check on it for each chat room instead of loading call logs on each chat room. See TimelineModel()
|
||||
std::list<std::shared_ptr<linphone::CallLog>> callLogs = coreManager->getCore()->getCallLogs();
|
||||
//
|
||||
for(auto dbChatRoom : allChatRooms){
|
||||
auto haveTimeline = getTimeline(dbChatRoom, false);
|
||||
if(!haveTimeline && dbChatRoom){// Create a new Timeline if needed
|
||||
|
||||
std::shared_ptr<TimelineModel> model = TimelineModel::create(dbChatRoom);
|
||||
std::shared_ptr<TimelineModel> model = TimelineModel::create(dbChatRoom, callLogs);
|
||||
if( model){
|
||||
connect(model.get(), SIGNAL(selectedChanged(bool)), this, SLOT(onSelectedHasChanged(bool)));
|
||||
connect(model->getChatRoomModel(), &ChatRoomModel::allEntriesRemoved, this, &TimelineListModel::removeChatRoomModel);
|
||||
|
|
|
|||
|
|
@ -28,18 +28,49 @@
|
|||
#include "TimelineModel.hpp"
|
||||
#include "TimelineListModel.hpp"
|
||||
|
||||
#include "../calls/CallsListModel.hpp"
|
||||
|
||||
#include <QDebug>
|
||||
#include <qqmlapplicationengine.h>
|
||||
#include <QTimer>
|
||||
|
||||
|
||||
// =============================================================================
|
||||
std::shared_ptr<TimelineModel> TimelineModel::create(std::shared_ptr<linphone::ChatRoom> chatRoom, QObject *parent){
|
||||
std::shared_ptr<TimelineModel> TimelineModel::create(std::shared_ptr<linphone::ChatRoom> chatRoom, const std::list<std::shared_ptr<linphone::CallLog>>& callLogs, QObject *parent){
|
||||
if(!CoreManager::getInstance()->getTimelineListModel() || !CoreManager::getInstance()->getTimelineListModel()->getTimeline(chatRoom, false)) {
|
||||
std::shared_ptr<TimelineModel> model = std::make_shared<TimelineModel>(chatRoom, parent);
|
||||
if(model && model->getChatRoomModel()){
|
||||
model->mSelf = model;
|
||||
chatRoom->addListener(model);
|
||||
// Get Max updatetime from chat room and last call event
|
||||
auto timelineChatRoom = model->getChatRoomModel();
|
||||
std::shared_ptr<linphone::CallLog> lastCall = nullptr;
|
||||
QString peerAddress = timelineChatRoom->getParticipantAddress();
|
||||
std::shared_ptr<const linphone::Address> lLocalAddress = chatRoom->getLocalAddress();
|
||||
QString localAddress = Utils::coreStringToAppString(lLocalAddress->asStringUriOnly());
|
||||
|
||||
if(callLogs.size() == 0) {
|
||||
auto callHistory = CallsListModel::getCallHistory(peerAddress, localAddress);
|
||||
if(callHistory.size() > 0)
|
||||
lastCall = callHistory.front();
|
||||
}else{// Find the last call in list
|
||||
std::shared_ptr<linphone::Address> lPeerAddress = Utils::interpretUrl(peerAddress);
|
||||
if( lPeerAddress && lLocalAddress){
|
||||
auto itCallLog = std::find_if(callLogs.begin(), callLogs.end(), [lPeerAddress, lLocalAddress](std::shared_ptr<linphone::CallLog> c){
|
||||
return c->getLocalAddress()->weakEqual(lLocalAddress) && c->getRemoteAddress()->weakEqual(lPeerAddress);
|
||||
});
|
||||
if( itCallLog != callLogs.end())
|
||||
lastCall = *itCallLog;
|
||||
}
|
||||
}
|
||||
|
||||
if(lastCall){
|
||||
auto callDate = lastCall->getStartDate();
|
||||
if( lastCall->getStatus() == linphone::Call::Status::Success )
|
||||
callDate += lastCall->getDuration();
|
||||
timelineChatRoom->setLastUpdateTime(QDateTime::fromMSecsSinceEpoch(std::max(chatRoom->getLastUpdateTime(), callDate )*1000));
|
||||
}else
|
||||
timelineChatRoom->setLastUpdateTime(QDateTime::fromMSecsSinceEpoch(chatRoom->getLastUpdateTime()*1000));
|
||||
return model;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class TimelineModel : public QObject, public linphone::ChatRoomListener {
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static std::shared_ptr<TimelineModel> create(std::shared_ptr<linphone::ChatRoom> chatRoom, QObject *parent = Q_NULLPTR);
|
||||
static std::shared_ptr<TimelineModel> create(std::shared_ptr<linphone::ChatRoom> chatRoom, const std::list<std::shared_ptr<linphone::CallLog>>& callLogs = std::list<std::shared_ptr<linphone::CallLog>>(), QObject *parent = Q_NULLPTR);
|
||||
TimelineModel (std::shared_ptr<linphone::ChatRoom> chatRoom, QObject *parent = Q_NULLPTR);
|
||||
virtual ~TimelineModel();
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 2b0c68e4234dd35dd99fdea96eed71f4a394008f
|
||||
Subproject commit b2a3ebaffde438fb23c7b7d91327a35fa3a0f23d
|
||||
Loading…
Add table
Reference in a new issue