CallLogs: filter and synchronization

This commit is contained in:
Julien Wadel 2024-03-20 09:17:33 +01:00
parent 08363816b6
commit b6f09509f4
10 changed files with 32 additions and 37 deletions

View file

@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## 5.2.3 - Undefined
### Fixed
- Call logs : incoming filter will not display missed calls.
- Call logs synchronization.
## 5.2.2 - 2024-03-11

View file

@ -129,15 +129,6 @@ CoreManager *CoreManager::getInstance (){
return mInstance;
}
HistoryModel* CoreManager::getHistoryModel(){
if(!mHistoryModel){
mHistoryModel = new HistoryModel(this);
emit historyModelCreated(mHistoryModel);
}
return mHistoryModel;
}
RecorderManager* CoreManager::getRecorderManager(){
if(!mRecorderManager){
mRecorderManager = new RecorderManager(this);

View file

@ -74,7 +74,6 @@ public:
return mHandlers;
}
HistoryModel* getHistoryModel();
RecorderManager* getRecorderManager();
// ---------------------------------------------------------------------------
@ -184,7 +183,6 @@ signals:
void coreManagerInitialized ();
void chatRoomModelCreated (const QSharedPointer<ChatRoomModel> &chatRoomModel);
void historyModelCreated (HistoryModel *historyModel);
void recorderManagerCreated(RecorderManager *recorderModel);
void logsUploaded (const QString &url);

View file

@ -44,6 +44,7 @@ QString reorder(const QString& address){
void CallHistoryListModel::reload() {
beginResetModel();
mList.clear();
mCalls.clear();
endResetModel();
auto account = CoreManager::getInstance()->getCore()->getDefaultAccount();
auto callLogs = account ? account->getCallLogs() : CoreManager::getInstance()->getCore()->getCallLogs();
@ -76,12 +77,13 @@ void CallHistoryListModel::add(const std::list<std::shared_ptr<linphone::CallLog
connect(call.get(), &CallHistoryModel::selectedChanged, this, &CallHistoryListModel::onSelectedChanged);
connect(call.get(), &CallHistoryModel::hasBeenRemoved, this, &CallHistoryListModel::onHasBeenRemoved);
connect(call.get(), &CallHistoryModel::lastCallDateChanged, this, &CallHistoryListModel::lastCallDateChanged);
connect(call.get(), &CallHistoryModel::lastCallStatusChanged, this, &CallHistoryListModel::lastCallStatusChanged);
toAdd << call;
}else{
mCalls[keyName]->update(callLog);
}
}
qDebug() << "Adding call : " << callLogs.size() << " => " << toAdd.size();
ProxyListModel::add(toAdd);
}

View file

@ -48,6 +48,7 @@ signals:
void countChanged();
void selectedChanged(CallHistoryModel * model);
void lastCallDateChanged();
void lastCallStatusChanged();
private:
QHash<QString, QSharedPointer<CallHistoryModel>> mCalls;
};

View file

@ -40,6 +40,7 @@ CallHistoryProxyModel::CallHistoryProxyModel (QObject *parent) : QSortFilterProx
sort(0);
connect(CoreManager::getInstance()->getAccountSettingsModel(), &AccountSettingsModel::defaultAccountChanged, model, &CallHistoryListModel::reload);
connect(model, &CallHistoryListModel::lastCallDateChanged, this, &CallHistoryProxyModel::invalidate);
connect(model, &CallHistoryListModel::lastCallStatusChanged, this, &CallHistoryProxyModel::invalidateFilter);
App *app = App::getInstance();
connect(app->getMainWindow(), &QWindow::activeChanged, this, [this]() {
handleIsActiveChanged(App::getInstance()->getMainWindow());
@ -51,7 +52,7 @@ CallHistoryProxyModel::CallHistoryProxyModel (QObject *parent) : QSortFilterProx
void CallHistoryProxyModel::setFilterFlags(int filterFlags){
if( mFilterFlags != filterFlags){
mFilterFlags = filterFlags;
invalidate();
invalidateFilter();
emit filterFlagsChanged();
}
}
@ -59,7 +60,7 @@ void CallHistoryProxyModel::setFilterFlags(int filterFlags){
void CallHistoryProxyModel::setFilterText(const QString& text){
if( mFilterText != text){
mFilterText = text;
invalidate();
invalidateFilter();
emit filterTextChanged();
}
}
@ -75,7 +76,8 @@ bool CallHistoryProxyModel::filterAcceptsRow (int sourceRow, const QModelIndex &
auto timeline = sourceModel()->data(index).value<CallHistoryModel*>();
if( mFilterFlags > 0) {
show = ( ((mFilterFlags & CallTimelineFilter::Incoming) == CallTimelineFilter::Incoming) && !timeline->mLastCallIsOutgoing)
show = ( ((mFilterFlags & CallTimelineFilter::Incoming) == CallTimelineFilter::Incoming)
&& (!timeline->mLastCallIsOutgoing && timeline->mLastCallStatus != LinphoneEnums::CallStatusMissed))
|| ( ((mFilterFlags & CallTimelineFilter::Outgoing) == CallTimelineFilter::Outgoing) && timeline->mLastCallIsOutgoing)
|| ( ((mFilterFlags & CallTimelineFilter::Missed) == CallTimelineFilter::Missed) && timeline->mLastCallStatus == LinphoneEnums::CallStatusMissed)
;
@ -115,4 +117,4 @@ void CallHistoryProxyModel::handleIsActiveChanged (QWindow *window) {
if (window->isActive() && getParentWindow(this) == window) {
CoreManager::getInstance()->resetMissedCallsCount();
}
}
}

View file

@ -149,13 +149,12 @@ bool HistoryProxyModel::lessThan (const QModelIndex &left, const QModelIndex &ri
void HistoryProxyModel::reload () {
mMaxDisplayedEntries = EntriesChunkSize;
//auto model = CoreManager::getInstance()->getHistoryModel();
//model->reload();
static_cast<HistoryModelFilter *>(sourceModel())->setSourceModel(new HistoryModel(mCallHistoryModel));
invalidate();
}
void HistoryProxyModel::resetMessageCount(){
static_cast<HistoryModel*>(static_cast<HistoryModelFilter *>(sourceModel())->sourceModel())->resetMessageCount();
auto model = static_cast<HistoryModel*>(static_cast<HistoryModelFilter *>(sourceModel())->sourceModel());
if(model) model->resetMessageCount();
/*
auto model = CoreManager::getInstance()->getHistoryModel();
if( model){
@ -176,9 +175,7 @@ static inline QWindow *getParentWindow (QObject *object) {
}
void HistoryProxyModel::handleIsActiveChanged (QWindow *window) {
auto model = CoreManager::getInstance()->getHistoryModel();
if (model && window->isActive() && getParentWindow(this) == window) {
model->focused();
model->resetMessageCount();
if (window->isActive() && getParentWindow(this) == window) {
resetMessageCount();
}
}

View file

@ -84,8 +84,9 @@ QString SipAddressesModel::DisplayNames::get(){
void SipAddressesModel::DisplayNames::updateFromCall(const std::shared_ptr<const linphone::Address>& address){
auto displayName = address->getDisplayName();
if(!displayName.empty())
if(!displayName.empty()){
mFromCallLogs = Utils::coreStringToAppString(displayName);
}
}
void SipAddressesModel::DisplayNames::updateFromChatMessage(const std::shared_ptr<const linphone::Address>& address){
@ -100,7 +101,6 @@ SipAddressesModel::SipAddressesModel (QObject *parent) : QAbstractListModel(pare
mCoreHandlers = coreManager->getHandlers();
QObject::connect(coreManager, &CoreManager::chatRoomModelCreated, this, &SipAddressesModel::handleChatRoomModelCreated);
QObject::connect(coreManager, &CoreManager::historyModelCreated, this, &SipAddressesModel::handleHistoryModelCreated);
//Use blocking in order to apply updates before any use
ContactsListModel *contacts = CoreManager::getInstance()->getContactsListModel();
QObject::connect(contacts, &ContactsListModel::contactAdded, this, &SipAddressesModel::handleContactAdded, Qt::DirectConnection);
@ -327,9 +327,6 @@ void SipAddressesModel::handleChatRoomModelCreated (const QSharedPointer<ChatRoo
QObject::connect(ptr, &ChatRoomModel::messageSent, this, &SipAddressesModel::handleMessageSent);
}
void SipAddressesModel::handleHistoryModelCreated (HistoryModel *historyModel) {
}
void SipAddressesModel::handleContactAdded (QSharedPointer<ContactModel> contact) {
for (const auto &sipAddress : contact->getVcardModel()->getLinphoneSipAddresses()) {
addOrUpdateSipAddress(Utils::coreStringToAppString(sipAddress->asStringUriOnly()), sipAddress, contact);
@ -520,13 +517,14 @@ void SipAddressesModel::addOrUpdateSipAddress (SipAddressEntry &sipAddressEntry,
void SipAddressesModel::addOrUpdateSipAddress (SipAddressEntry &sipAddressEntry, const shared_ptr<linphone::Call> &call) {
const shared_ptr<linphone::CallLog> callLog = call->getCallLog();
auto lPeerAddress = callLog->getRemoteAddress();
QString localAddress(Utils::cleanSipAddress(Utils::coreStringToAppString(callLog->getLocalAddress()->asStringUriOnly())));
QString peerAddress(Utils::cleanSipAddress(Utils::coreStringToAppString(lPeerAddress->asStringUriOnly())));
ConferenceEntry &conferenceEntry = sipAddressEntry.localAddressToConferenceEntry[
localAddress
];
qInfo() << QStringLiteral("Update (`%1`, `%2`) from chat call.").arg(sipAddressEntry.sipAddress, localAddress);
qInfo() << QStringLiteral("Update (`%1`, `%2`, `%3`) from chat call.").arg(sipAddressEntry.sipAddress, localAddress, Utils::coreStringToAppString(lPeerAddress->asString()));
conferenceEntry.timestamp = callLog->getStatus() == linphone::Call::Status::Success
? QDateTime::fromMSecsSinceEpoch((callLog->getStartDate() + callLog->getDuration()) * 1000)
@ -698,4 +696,4 @@ void SipAddressesModel::updateObservers (const QString &sipAddress, const Presen
observer->setPresenceStatus(presenceStatus);
observer->setPresenceTimestamp(presenceTimestamp);
}
}
}

View file

@ -116,7 +116,6 @@ private:
// ---------------------------------------------------------------------------
void handleChatRoomModelCreated (const QSharedPointer<ChatRoomModel> &chatRoomModel);
void handleHistoryModelCreated (HistoryModel *historyModel) ;
void handleContactAdded (QSharedPointer<ContactModel> contact);
void handleContactRemoved (QSharedPointer<ContactModel> contact);

View file

@ -122,15 +122,17 @@ ColumnLayout{
| (outgoingFilter.checked ? CallHistoryProxyModel.Outgoing : 0)
| (missedFilter.checked ? CallHistoryProxyModel.Missed : 0)
}
onCountChanged: if(count == 0) mainItem.entrySelected(null)
delegate: Loader{
width: view.contentWidth
asynchronous: index > 20
active: true
sourceComponent: CallTimelineItem{
callHistoryModel: $modelData
property CallHistoryModel historyModel: $modelData// use loader property to avoid desync variables into Component.
width: view.contentWidth
asynchronous: index > 20
active: historyModel
sourceComponent: CallTimelineItem{
callHistoryModel: historyModel
modelIndex: index
Connections{
target: $modelData
target: historyModel
onSelectedChanged:{
if(selected) {
view.currentIndex = index;