Merge branch 'release/6.1'

This commit is contained in:
gaelle 2025-12-04 14:34:47 +01:00
commit d4c1387c43
154 changed files with 109344 additions and 4206 deletions

View file

@ -31,7 +31,6 @@
.deploy_linux: &deploy_linux | .deploy_linux: &deploy_linux |
rsync -rlv --ignore-existing build/OUTPUT/Packages/*.AppImage $DEPLOY_SERVER:$UPLOAD_ROOT_PATH/$LINUX_PLATFORM/$APP_FOLDER rsync -rlv --ignore-existing build/OUTPUT/Packages/*.AppImage $DEPLOY_SERVER:$UPLOAD_ROOT_PATH/$LINUX_PLATFORM/$APP_FOLDER
|-
if [[ $MAKE_RELEASE_FILE_URL != "" ]]; then if [[ $MAKE_RELEASE_FILE_URL != "" ]]; then
rsync -rlv build/OUTPUT/Packages/RELEASE $DEPLOY_SERVER:$UPLOAD_ROOT_PATH/$LINUX_PLATFORM rsync -rlv build/OUTPUT/Packages/RELEASE $DEPLOY_SERVER:$UPLOAD_ROOT_PATH/$LINUX_PLATFORM
rsync -rlv build/OUTPUT/Packages/RELEASE $MAIN_DEPLOY_SERVER:$UPLOAD_ROOT_PATH/$LINUX_PLATFORM rsync -rlv build/OUTPUT/Packages/RELEASE $MAIN_DEPLOY_SERVER:$UPLOAD_ROOT_PATH/$LINUX_PLATFORM

View file

@ -26,7 +26,7 @@
.macosx-desktop: .macosx-desktop:
stage: build stage: build
tags: [ "macos-min-xcode12.2-flat" ] tags: [ "macmini-m1-xcode15" ]
rules: rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event" && $DOCKER_UPDATE == null && $SKIP_MACOSX == null - if: $CI_PIPELINE_SOURCE == "merge_request_event" && $DOCKER_UPDATE == null && $SKIP_MACOSX == null
- if: $CI_PIPELINE_SOURCE == "schedule" && $DOCKER_UPDATE == null && $SKIP_MACOSX == null - if: $CI_PIPELINE_SOURCE == "schedule" && $DOCKER_UPDATE == null && $SKIP_MACOSX == null
@ -93,7 +93,7 @@ macosx-ninja-novideo:
# WAIT for QT6 for arm64 # WAIT for QT6 for arm64
macosx-ninja-package: macosx-ninja-package:
stage: package stage: package
tags: [ "macos-min-xcode12.2-flat" ] tags: [ "macmini-m1-xcode15" ]
needs: [] needs: []
rules: rules:
- !reference [.rules-merge-request-manual, rules] - !reference [.rules-merge-request-manual, rules]
@ -117,7 +117,7 @@ macosx-ninja-package:
macosx-codesigning: macosx-codesigning:
stage: signing stage: signing
tags: [ "macos-min-xcode12.2-flat" ] tags: [ "macmini-m1-xcode15" ]
needs: needs:
- macosx-ninja-package - macosx-ninja-package
rules: rules:
@ -142,7 +142,7 @@ macosx-codesigning:
macosx-deploy: macosx-deploy:
stage: deploy stage: deploy
tags: [ "macos-min-xcode12.2-flat" ] tags: [ "macmini-m1-xcode15" ]
needs: needs:
- macosx-codesigning - macosx-codesigning
only: only:
@ -160,7 +160,7 @@ macosx-deploy:
macosx-makefile-plugins-deploy: macosx-makefile-plugins-deploy:
stage: deploy stage: deploy
tags: [ "macos-min-xcode12.2-flat" ] tags: [ "macmini-m1-xcode15" ]
needs: needs:
- macosx-makefile - macosx-makefile
only: only:

View file

@ -31,3 +31,9 @@ Group changes to describe their impact on the project, as follows:
- Default screen (between contacts, call history, conversations & meetings list) will change depending on where you were when the app was paused or killed, and you will return to that last visited screen on the next startup. - Default screen (between contacts, call history, conversations & meetings list) will change depending on where you were when the app was paused or killed, and you will return to that last visited screen on the next startup.
- Minimum supported Qt version is now 6.5.3 - Minimum supported Qt version is now 6.5.3
- Some settings have changed name and/or section in linphonerc file. - Some settings have changed name and/or section in linphonerc file.
## [6.1.0] - XXXX-XX-XX
### Changed
- Minimum supported Qt version is now 6.10.0

View file

@ -60,7 +60,6 @@ project(linphoneqt)
include(GNUInstallDirs) include(GNUInstallDirs)
include(CheckCXXCompilerFlag) include(CheckCXXCompilerFlag)
include(Linphone/application_info.cmake)
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD 17)
if(LINPHONEAPP_INSTALL_PREFIX) if(LINPHONEAPP_INSTALL_PREFIX)
@ -72,8 +71,11 @@ endif()
set(CMAKE_INSTALL_PREFIX "${APPLICATION_OUTPUT_DIR}") set(CMAKE_INSTALL_PREFIX "${APPLICATION_OUTPUT_DIR}")
set(LINPHONEAPP_APPLICATION_NAME "Linphone6" CACHE STRING "Application name" ) set(LINPHONEAPP_APPLICATION_NAME "Linphone" CACHE STRING "Application name" )
set(LINPHONEAPP_EXECUTABLE_NAME "linphone6" CACHE STRING "Executable name" ) set(LINPHONEAPP_EXECUTABLE_NAME "linphone" CACHE STRING "Executable name" )
# Include application_info.cmake here as the LINPHONEAPP_APPLICATION_NAME variable must be known as it is set to the APPLICATION_NAME variable.
include(Linphone/application_info.cmake)
if( APPLE ) if( APPLE )
set(LINPHONEAPP_MACOS_ARCHS "arm64" CACHE STRING "MacOS architectures to build: comma-separated list of values in [arm64, x86_64]") set(LINPHONEAPP_MACOS_ARCHS "arm64" CACHE STRING "MacOS architectures to build: comma-separated list of values in [arm64, x86_64]")

View file

@ -98,15 +98,11 @@ endif()
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake" "${CMAKE_CURRENT_BINARY_DIR}/config.h") configure_file("${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake" "${CMAKE_CURRENT_BINARY_DIR}/config.h")
if(${Qt6_VERSION} VERSION_LESS "6.3.0") if(${Qt6_VERSION} VERSION_LESS "6.10.0")
set(CMAKE_AUTOMOC ON) message( FATAL_ERROR "Linphone requires Qt 6.10.0 or newer. Exiting CMake." )
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
else()
qt6_standard_project_setup()
endif() endif()
qt6_standard_project_setup()
################################################################ ################################################################
@ -127,7 +123,7 @@ add_subdirectory(core)
set(LANGUAGES_DIRECTORY "data/languages") set(LANGUAGES_DIRECTORY "data/languages")
set(I18N_FILENAME i18n.qrc) set(I18N_FILENAME i18n.qrc)
set(LANGUAGES en fr_FR de) set(LANGUAGES en fr de)
# Add languages support. # Add languages support.
add_subdirectory("${LANGUAGES_DIRECTORY}" "data/languages") add_subdirectory("${LANGUAGES_DIRECTORY}" "data/languages")
@ -174,6 +170,12 @@ qt6_add_qml_module(Linphone
RESOURCES data/fonts.qrc RESOURCES data/fonts.qrc
) )
if (WIN32)
if(MSVC AND (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo"))
install(FILES "$<TARGET_PDB_FILE:${TARGET_NAME}>" DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
endif()
qt6_add_resources(Linphone "resources" PREFIX "/" FILES ${_LINPHONEAPP_RC_FILES}) qt6_add_resources(Linphone "resources" PREFIX "/" FILES ${_LINPHONEAPP_RC_FILES})
set_property(TARGET Linphone PROPERTY POSITION_INDEPENDENT_CODE ON) #Need by Qt set_property(TARGET Linphone PROPERTY POSITION_INDEPENDENT_CODE ON) #Need by Qt
@ -199,6 +201,7 @@ set_target_properties(${TARGET_NAME} PROPERTIES
if(MSVC) if(MSVC)
set_target_properties(${TARGET_NAME} PROPERTIES PDB_NAME "${EXECUTABLE_NAME}_app") set_target_properties(${TARGET_NAME} PROPERTIES PDB_NAME "${EXECUTABLE_NAME}_app")
endif() endif()
set_target_properties(${TARGET_NAME} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON)
if(WIN32) if(WIN32)
if(ENABLE_SCREENSHARING) if(ENABLE_SCREENSHARING)

View file

@ -267,9 +267,7 @@ void App::setAutoStart(bool enabled) {
void App::setAutoStart(bool enabled) { void App::setAutoStart(bool enabled) {
QSettings settings(AutoStartSettingsFilePath, QSettings::NativeFormat); QSettings settings(AutoStartSettingsFilePath, QSettings::NativeFormat);
QString parameters; if (enabled) settings.setValue(EXECUTABLE_NAME, QDir::toNativeSeparators(applicationFilePath()));
if (!mSettings->getExitOnClose()) parameters = " --minimized";
if (enabled) settings.setValue(EXECUTABLE_NAME, QDir::toNativeSeparators(applicationFilePath()) + parameters);
else settings.remove(EXECUTABLE_NAME); else settings.remove(EXECUTABLE_NAME);
mAutoStart = enabled; mAutoStart = enabled;
@ -287,9 +285,11 @@ App::App(int &argc, char *argv[])
: SingleApplication(argc, argv, true, Mode::User | Mode::ExcludeAppPath | Mode::ExcludeAppVersion) { : SingleApplication(argc, argv, true, Mode::User | Mode::ExcludeAppPath | Mode::ExcludeAppVersion) {
// Do not use APPLICATION_NAME here. // Do not use APPLICATION_NAME here.
// The EXECUTABLE_NAME will be used in qt standard paths. It's our goal. // The EXECUTABLE_NAME will be used in qt standard paths. It's our goal.
QDir::setCurrent(QCoreApplication::applicationDirPath());// Set working directory as the executable to allow relative paths. QDir::setCurrent(
QCoreApplication::applicationDirPath()); // Set working directory as the executable to allow relative paths.
QThread::currentThread()->setPriority(QThread::HighPriority); QThread::currentThread()->setPriority(QThread::HighPriority);
qDebug() << "app thread is" << QThread::currentThread(); qDebug() << "app thread is" << QThread::currentThread();
lDebug() << "Starting app with Qt version" << qVersion();
QCoreApplication::setApplicationName(EXECUTABLE_NAME); QCoreApplication::setApplicationName(EXECUTABLE_NAME);
QApplication::setOrganizationDomain(EXECUTABLE_NAME); QApplication::setOrganizationDomain(EXECUTABLE_NAME);
QCoreApplication::setApplicationVersion(APPLICATION_SEMVER); QCoreApplication::setApplicationVersion(APPLICATION_SEMVER);
@ -337,7 +337,7 @@ void App::setSelf(QSharedPointer<App>(me)) {
auto callCore = CallCore::create(call); auto callCore = CallCore::create(call);
mCoreModelConnection->invokeToCore([this, callCore] { mCoreModelConnection->invokeToCore([this, callCore] {
auto callGui = new CallGui(callCore); auto callGui = new CallGui(callCore);
auto win = getCallsWindow(QVariant::fromValue(callGui)); auto win = getOrCreateCallsWindow(QVariant::fromValue(callGui));
Utils::smartShowWindow(win); Utils::smartShowWindow(win);
auto mainwin = getMainWindow(); auto mainwin = getMainWindow();
QMetaObject::invokeMethod(mainwin, "callCreated"); QMetaObject::invokeMethod(mainwin, "callCreated");
@ -407,8 +407,12 @@ void App::setSelf(QSharedPointer<App>(me)) {
mustBeInMainThread(log().arg(Q_FUNC_INFO)); mustBeInMainThread(log().arg(Q_FUNC_INFO));
// There is an account added by a remote provisioning, force switching to main page // There is an account added by a remote provisioning, force switching to main page
// because the account may not be connected already // because the account may not be connected already
// if (accountConnected)
if (mPossiblyLookForAddedAccount) {
QMetaObject::invokeMethod(mMainWindow, "openMainPage", Qt::DirectConnection, QMetaObject::invokeMethod(mMainWindow, "openMainPage", Qt::DirectConnection,
Q_ARG(QVariant, accountConnected)); Q_ARG(QVariant, accountConnected));
}
mPossiblyLookForAddedAccount = false;
}); });
} }
}); });
@ -431,6 +435,43 @@ void App::setSelf(QSharedPointer<App>(me)) {
}); });
}); });
// Check update
mCoreModelConnection->makeConnectToModel(
&CoreModel::versionUpdateCheckResultReceived,
[this](const std::shared_ptr<linphone::Core> &core, linphone::VersionUpdateCheckResult result,
const std::string &version, const std::string &url, bool checkRequestedByUser) {
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
mCoreModelConnection->invokeToCore([this, result, version, url, checkRequestedByUser] {
switch (result) {
case linphone::VersionUpdateCheckResult::Error:
Utils::showInformationPopup(tr("info_popup_error_title"),
//: An error occured while trying to check update. Please
//: try again later or contact support team.
tr("info_popup_error_checking_update"), false);
break;
case linphone::VersionUpdateCheckResult::NewVersionAvailable: {
QString downloadLink =
QStringLiteral("<a href='%1'><font color='DefaultStyle.main2_600'>%2</a>")
.arg(url)
//: Download it !
.arg(tr("info_popup_new_version_download_label"));
Utils::showInformationPopup(
//: New version available !
tr("info_popup_new_version_available_title"),
//: A new version of Linphone (%1) is available. %2
tr("info_popup_new_version_available_message").arg(version).arg(downloadLink));
break;
}
case linphone::VersionUpdateCheckResult::UpToDate:
if (checkRequestedByUser)
//: Up to date
Utils::showInformationPopup(tr("info_popup_version_up_to_date_title"),
//: Your version is up to date
tr("info_popup_version_up_to_date_message"));
}
});
});
//--------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------
mCliModelConnection = SafeConnection<App, CliModel>::create(me, CliModel::getInstance()); mCliModelConnection = SafeConnection<App, CliModel>::create(me, CliModel::getInstance());
mCliModelConnection->makeConnectToCore(&App::receivedMessage, [this](int, const QByteArray &byteArray) { mCliModelConnection->makeConnectToCore(&App::receivedMessage, [this](int, const QByteArray &byteArray) {
@ -647,8 +688,8 @@ void App::initCore() {
} else lInfo() << log().arg("Stay minimized"); } else lInfo() << log().arg("Stay minimized");
firstOpen = false; firstOpen = false;
lInfo() << log().arg("Checking remote provisioning"); lInfo() << log().arg("Checking remote provisioning");
if (CoreModel::getInstance()->mConfigStatus == linphone::ConfiguringState::Failed && if (mIsRestarting) {
mIsRestarting) { if (CoreModel::getInstance()->mConfigStatus == linphone::ConfiguringState::Failed) {
QMetaObject::invokeMethod(thread(), [this]() { QMetaObject::invokeMethod(thread(), [this]() {
auto message = CoreModel::getInstance()->mConfigMessage; auto message = CoreModel::getInstance()->mConfigMessage;
//: not reachable //: not reachable
@ -660,7 +701,11 @@ void App::initCore() {
//: Remote provisioning failed : %1 //: Remote provisioning failed : %1
tr("info_popup_configuration_failed_message").arg(message), false); tr("info_popup_configuration_failed_message").arg(message), false);
}); });
} else {
mPossiblyLookForAddedAccount = true;
} }
}
checkForUpdate();
mIsRestarting = false; mIsRestarting = false;
//--------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------
@ -1025,7 +1070,38 @@ bool App::notify(QObject *receiver, QEvent *event) {
return done; return done;
} }
QQuickWindow *App::getCallsWindow(QVariant callGui) { void App::handleAppActivity() {
auto handle = [this](QSharedPointer<AccountCore> accountCore) {
if (!accountCore) return;
auto accountPresence = accountCore->getPresence();
if ((mMainWindow && mMainWindow->isActive() || (mCallsWindow && mCallsWindow->isActive())) &&
accountPresence == LinphoneEnums::Presence::Away)
accountCore->lSetPresence(LinphoneEnums::Presence::Online);
if (((!mMainWindow || !mMainWindow->isActive()) && (!mCallsWindow || !mCallsWindow->isActive())) &&
accountPresence == LinphoneEnums::Presence::Online)
accountCore->lSetPresence(LinphoneEnums::Presence::Away);
};
if (mAccountList) {
for (auto &account : mAccountList->getSharedList<AccountCore>())
handle(account);
} else {
connect(
this, &App::accountsChanged, this,
[this, &handle] {
if (mAccountList) {
for (auto &account : mAccountList->getSharedList<AccountCore>())
handle(account);
}
},
Qt::SingleShotConnection);
}
}
QQuickWindow *App::getCallsWindow() {
return mCallsWindow;
}
QQuickWindow *App::getOrCreateCallsWindow(QVariant callGui) {
mustBeInMainThread(getClassName()); mustBeInMainThread(getClassName());
if (!mCallsWindow) { if (!mCallsWindow) {
const QUrl callUrl("qrc:/qt/qml/Linphone/view/Page/Window/Call/CallsWindow.qml"); const QUrl callUrl("qrc:/qt/qml/Linphone/view/Page/Window/Call/CallsWindow.qml");
@ -1060,6 +1136,7 @@ QQuickWindow *App::getCallsWindow(QVariant callGui) {
} }
// window->setParent(mMainWindow); // window->setParent(mMainWindow);
mCallsWindow = window; mCallsWindow = window;
connect(mCallsWindow, &QQuickWindow::activeChanged, this, &App::handleAppActivity);
} }
if (!callGui.isNull() && callGui.isValid()) mCallsWindow->setProperty("call", callGui); if (!callGui.isNull() && callGui.isValid()) mCallsWindow->setProperty("call", callGui);
return mCallsWindow; return mCallsWindow;
@ -1082,8 +1159,11 @@ QQuickWindow *App::getMainWindow() const {
} }
void App::setMainWindow(QQuickWindow *data) { void App::setMainWindow(QQuickWindow *data) {
if (mMainWindow) disconnect(mMainWindow, &QQuickWindow::activeChanged, this, nullptr);
if (mMainWindow != data) { if (mMainWindow != data) {
mMainWindow = data; mMainWindow = data;
connect(mMainWindow, &QQuickWindow::activeChanged, this, &App::handleAppActivity);
handleAppActivity();
emit mainWindowChanged(); emit mainWindowChanged();
} }
} }
@ -1358,6 +1438,12 @@ void App::setSysTrayIcon() {
menu->addSeparator(); menu->addSeparator();
} }
menu->addAction(markAllReadAction); menu->addAction(markAllReadAction);
//: Check for update
if (mSettings->isCheckForUpdateAvailable()) {
QAction *checkForUpdateAction = new QAction(tr("check_for_update"), root);
root->connect(checkForUpdateAction, &QAction::triggered, this, [this] { checkForUpdate(true); });
menu->addAction(checkForUpdateAction);
}
menu->addAction(quitAction); menu->addAction(quitAction);
if (!mSystemTrayIcon) { if (!mSystemTrayIcon) {
systemTrayIcon->setContextMenu(menu); // This is a Qt bug. We cannot call setContextMenu more than once. So systemTrayIcon->setContextMenu(menu); // This is a Qt bug. We cannot call setContextMenu more than once. So
@ -1437,6 +1523,21 @@ QString App::getSdkVersion() {
#endif #endif
} }
QString App::getQtVersion() const {
return qVersion();
}
void App::checkForUpdate(bool requestedByUser) {
mustBeInMainThread(log().arg(Q_FUNC_INFO));
if (CoreModel::getInstance() && mCoreModelConnection) {
mCoreModelConnection->invokeToModel([this, requestedByUser] {
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
CoreModel::getInstance()->checkForUpdate(Utils::appStringToCoreString(applicationVersion()),
requestedByUser);
});
}
}
ChatGui *App::getCurrentChat() const { ChatGui *App::getCurrentChat() const {
return mCurrentChat; return mCurrentChat;
} }

View file

@ -46,6 +46,7 @@ class App : public SingleApplication, public AbstractObject {
Q_PROPERTY(AccountList *accounts READ getAccounts NOTIFY accountsChanged) Q_PROPERTY(AccountList *accounts READ getAccounts NOTIFY accountsChanged)
Q_PROPERTY(CallList *calls READ getCalls NOTIFY callsChanged) Q_PROPERTY(CallList *calls READ getCalls NOTIFY callsChanged)
Q_PROPERTY(QString shortApplicationVersion READ getShortApplicationVersion CONSTANT) Q_PROPERTY(QString shortApplicationVersion READ getShortApplicationVersion CONSTANT)
Q_PROPERTY(QString qtVersion READ getQtVersion CONSTANT)
Q_PROPERTY(QString gitBranchName READ getGitBranchName CONSTANT) Q_PROPERTY(QString gitBranchName READ getGitBranchName CONSTANT)
Q_PROPERTY(QString sdkVersion READ getSdkVersion CONSTANT) Q_PROPERTY(QString sdkVersion READ getSdkVersion CONSTANT)
Q_PROPERTY(ChatGui *currentChat READ getCurrentChat WRITE setCurrentChat NOTIFY currentChatChanged) Q_PROPERTY(ChatGui *currentChat READ getCurrentChat WRITE setCurrentChat NOTIFY currentChatChanged)
@ -138,7 +139,9 @@ public:
bool getCoreStarted() const; bool getCoreStarted() const;
void setCoreStarted(bool started); void setCoreStarted(bool started);
QQuickWindow *getCallsWindow(QVariant callGui = QVariant()); QQuickWindow *getCallsWindow();
Q_INVOKABLE void handleAppActivity();
QQuickWindow *getOrCreateCallsWindow(QVariant callGui = QVariant());
void setCallsWindowProperty(const char *id, QVariant property); void setCallsWindowProperty(const char *id, QVariant property);
void closeCallsWindow(); void closeCallsWindow();
@ -164,7 +167,9 @@ public:
QString getShortApplicationVersion(); QString getShortApplicationVersion();
QString getGitBranchName(); QString getGitBranchName();
QString getSdkVersion(); QString getSdkVersion();
QString getQtVersion() const;
Q_INVOKABLE void checkForUpdate(bool requestedByUser = false);
ChatGui *getCurrentChat() const; ChatGui *getCurrentChat() const;
void setCurrentChat(ChatGui *chat); void setCurrentChat(ChatGui *chat);
@ -221,6 +226,7 @@ private:
bool mAutoStart = false; bool mAutoStart = false;
bool mCoreStarted = false; bool mCoreStarted = false;
bool mIsRestarting = false; bool mIsRestarting = false;
bool mPossiblyLookForAddedAccount = false;
QLocale mLocale = QLocale::system(); QLocale mLocale = QLocale::system();
DefaultTranslatorCore *mTranslatorCore = nullptr; DefaultTranslatorCore *mTranslatorCore = nullptr;
DefaultTranslatorCore *mDefaultTranslatorCore = nullptr; DefaultTranslatorCore *mDefaultTranslatorCore = nullptr;

View file

@ -73,10 +73,10 @@ void CarddavCore::remove() {
void CarddavCore::setSelf(QSharedPointer<CarddavCore> me) { void CarddavCore::setSelf(QSharedPointer<CarddavCore> me) {
mCarddavModelConnection = SafeConnection<CarddavCore, CarddavModel>::create(me, mCarddavModel); mCarddavModelConnection = SafeConnection<CarddavCore, CarddavModel>::create(me, mCarddavModel);
mCarddavModelConnection->makeConnectToModel(&CarddavModel::saved, [this](bool success) { mCarddavModelConnection->makeConnectToModel(&CarddavModel::saved, [this](bool success, QString message) {
mCarddavModelConnection->invokeToCore([this, success]() { mCarddavModelConnection->invokeToCore([this, success, message]() {
if (success) emit App::getInstance()->getSettings()->cardDAVAddressBookSynchronized(); if (success) emit App::getInstance() -> getSettings()->cardDAVAddressBookSynchronized();
emit saved(success); emit saved(success, message);
}); });
}); });
} }

View file

@ -50,7 +50,7 @@ public:
DECLARE_CORE_MEMBER(bool, storeNewFriendsInIt, StoreNewFriendsInIt) DECLARE_CORE_MEMBER(bool, storeNewFriendsInIt, StoreNewFriendsInIt)
signals: signals:
void saved(bool success); void saved(bool success, QString message);
private: private:
std::shared_ptr<CarddavModel> mCarddavModel; std::shared_ptr<CarddavModel> mCarddavModel;

View file

@ -107,9 +107,11 @@ CallCore::CallCore(const std::shared_ptr<linphone::Call> &call) : QObject(nullpt
mCallModel->setSelf(mCallModel); mCallModel->setSelf(mCallModel);
mDuration = call->getDuration(); mDuration = call->getDuration();
mIsStarted = mDuration > 0; mIsStarted = mDuration > 0;
auto videoDirection = call->getParams()->getVideoDirection(); auto callParams = call->getParams();
auto videoDirection = callParams->getVideoDirection();
mLocalVideoEnabled = mLocalVideoEnabled =
videoDirection == linphone::MediaDirection::SendOnly || videoDirection == linphone::MediaDirection::SendRecv; videoDirection == linphone::MediaDirection::SendOnly || videoDirection == linphone::MediaDirection::SendRecv;
mCameraEnabled = callParams->cameraEnabled();
auto remoteParams = call->getRemoteParams(); auto remoteParams = call->getRemoteParams();
videoDirection = remoteParams ? remoteParams->getVideoDirection() : linphone::MediaDirection::Inactive; videoDirection = remoteParams ? remoteParams->getVideoDirection() : linphone::MediaDirection::Inactive;
mRemoteVideoEnabled = mRemoteVideoEnabled =
@ -133,7 +135,7 @@ CallCore::CallCore(const std::shared_ptr<linphone::Call> &call) : QObject(nullpt
mTransferState = LinphoneEnums::fromLinphone(call->getTransferState()); mTransferState = LinphoneEnums::fromLinphone(call->getTransferState());
mLocalToken = Utils::coreStringToAppString(mCallModel->getLocalAtuhenticationToken()); mLocalToken = Utils::coreStringToAppString(mCallModel->getLocalAtuhenticationToken());
mRemoteTokens = mCallModel->getRemoteAtuhenticationTokens(); mRemoteTokens = mCallModel->getRemoteAtuhenticationTokens();
mEncryption = LinphoneEnums::fromLinphone(call->getParams()->getMediaEncryption()); mEncryption = LinphoneEnums::fromLinphone(callParams->getMediaEncryption());
auto tokenVerified = call->getAuthenticationTokenVerified(); auto tokenVerified = call->getAuthenticationTokenVerified();
mIsMismatch = call->getZrtpCacheMismatchFlag(); mIsMismatch = call->getZrtpCacheMismatchFlag();
mIsSecured = (mEncryption == LinphoneEnums::MediaEncryption::Zrtp && tokenVerified) || mIsSecured = (mEncryption == LinphoneEnums::MediaEncryption::Zrtp && tokenVerified) ||
@ -160,7 +162,7 @@ CallCore::CallCore(const std::shared_ptr<linphone::Call> &call) : QObject(nullpt
mPaused = mState == LinphoneEnums::CallState::Pausing || mState == LinphoneEnums::CallState::Paused || mPaused = mState == LinphoneEnums::CallState::Pausing || mState == LinphoneEnums::CallState::Paused ||
mState == LinphoneEnums::CallState::PausedByRemote; mState == LinphoneEnums::CallState::PausedByRemote;
mRecording = call->getParams() && call->getParams()->isRecording(); mRecording = callParams && callParams->isRecording();
mRemoteRecording = call->getRemoteParams() && call->getRemoteParams()->isRecording(); mRemoteRecording = call->getRemoteParams() && call->getRemoteParams()->isRecording();
auto settingsModel = SettingsModel::getInstance(); auto settingsModel = SettingsModel::getInstance();
mMicrophoneVolume = call->getRecordVolume(); mMicrophoneVolume = call->getRecordVolume();
@ -193,8 +195,8 @@ void CallCore::setSelf(QSharedPointer<CallCore> me) {
mCallModelConnection->makeConnectToModel(&CallModel::speakerMutedChanged, [this](bool isMuted) { mCallModelConnection->makeConnectToModel(&CallModel::speakerMutedChanged, [this](bool isMuted) {
mCallModelConnection->invokeToCore([this, isMuted]() { setSpeakerMuted(isMuted); }); mCallModelConnection->invokeToCore([this, isMuted]() { setSpeakerMuted(isMuted); });
}); });
mCallModelConnection->makeConnectToCore(&CallCore::lSetLocalVideoEnabled, [this](bool enabled) { mCallModelConnection->makeConnectToCore(&CallCore::lSetCameraEnabled, [this](bool enabled) {
mCallModelConnection->invokeToModel([this, enabled]() { mCallModel->setLocalVideoEnabled(enabled); }); mCallModelConnection->invokeToModel([this, enabled]() { mCallModel->setCameraEnabled(enabled); });
}); });
mCallModelConnection->makeConnectToCore(&CallCore::lStartRecording, [this]() { mCallModelConnection->makeConnectToCore(&CallCore::lStartRecording, [this]() {
mCallModelConnection->invokeToModel([this]() { mCallModel->startRecording(); }); mCallModelConnection->invokeToModel([this]() { mCallModel->startRecording(); });
@ -204,15 +206,15 @@ void CallCore::setSelf(QSharedPointer<CallCore> me) {
}); });
mCallModelConnection->makeConnectToModel( mCallModelConnection->makeConnectToModel(
&CallModel::recordingChanged, [this](const std::shared_ptr<linphone::Call> &call, bool recording) { &CallModel::recordingChanged, [this](const std::shared_ptr<linphone::Call> &call, bool recording) {
mCallModelConnection->invokeToCore([this, recording]() { auto recordFile = QString::fromStdString(mCallModel->getRecordFile());
mCallModelConnection->invokeToCore([this, recording, recordFile]() {
setRecording(recording); setRecording(recording);
if (recording == false) { if (recording == false) {
//: "Enregistrement terminé" //: "Enregistrement terminé"
Utils::showInformationPopup(tr("call_record_end_message"), Utils::showInformationPopup(tr("call_record_end_message"),
//: "L'appel a été enregistré dans le fichier : %1" //: "L'appel a été enregistré dans le fichier : %1"
tr("call_record_saved_in_file_message") tr("call_record_saved_in_file_message").arg(recordFile), true,
.arg(QString::fromStdString(mCallModel->getRecordFile())), App::getInstance()->getOrCreateCallsWindow());
true, App::getInstance()->getCallsWindow());
} }
}); });
}); });
@ -244,6 +246,9 @@ void CallCore::setSelf(QSharedPointer<CallCore> me) {
mCallModelConnection->makeConnectToModel(&CallModel::localVideoEnabledChanged, [this](bool enabled) { mCallModelConnection->makeConnectToModel(&CallModel::localVideoEnabledChanged, [this](bool enabled) {
mCallModelConnection->invokeToCore([this, enabled]() { setLocalVideoEnabled(enabled); }); mCallModelConnection->invokeToCore([this, enabled]() { setLocalVideoEnabled(enabled); });
}); });
mCallModelConnection->makeConnectToModel(&CallModel::cameraEnabledChanged, [this](bool enabled) {
mCallModelConnection->invokeToCore([this, enabled]() { setCameraEnabled(enabled); });
});
mCallModelConnection->makeConnectToModel(&CallModel::durationChanged, [this](int duration) { mCallModelConnection->makeConnectToModel(&CallModel::durationChanged, [this](int duration) {
mCallModelConnection->invokeToCore([this, duration]() { setDuration(duration); }); mCallModelConnection->invokeToCore([this, duration]() { setDuration(duration); });
}); });
@ -344,6 +349,8 @@ void CallCore::setSelf(QSharedPointer<CallCore> me) {
}); });
mCallModelConnection->makeConnectToModel(&CallModel::conferenceChanged, [this]() { mCallModelConnection->makeConnectToModel(&CallModel::conferenceChanged, [this]() {
auto conference = mCallModel->getMonitor()->getConference(); auto conference = mCallModel->getMonitor()->getConference();
// Force enable video if in conference to handle screen sharing
if (conference && !mCallModel->videoEnabled()) mCallModel->enableVideo(true);
QSharedPointer<ConferenceCore> core = conference ? ConferenceCore::create(conference) : nullptr; QSharedPointer<ConferenceCore> core = conference ? ConferenceCore::create(conference) : nullptr;
mCallModelConnection->invokeToCore([this, core]() { setConference(core); }); mCallModelConnection->invokeToCore([this, core]() { setConference(core); });
}); });
@ -558,6 +565,18 @@ void CallCore::setLocalVideoEnabled(bool enabled) {
} }
} }
bool CallCore::getCameraEnabled() const {
return mCameraEnabled;
}
void CallCore::setCameraEnabled(bool enabled) {
if (mCameraEnabled != enabled) {
mCameraEnabled = enabled;
lDebug() << "CameraEnabled: " << mCameraEnabled;
emit cameraEnabledChanged();
}
}
bool CallCore::getPaused() const { bool CallCore::getPaused() const {
return mPaused; return mPaused;
} }

View file

@ -117,8 +117,8 @@ public:
Q_PROPERTY(QStringList remoteTokens WRITE setRemoteTokens MEMBER mRemoteTokens NOTIFY remoteTokensChanged) Q_PROPERTY(QStringList remoteTokens WRITE setRemoteTokens MEMBER mRemoteTokens NOTIFY remoteTokensChanged)
Q_PROPERTY( Q_PROPERTY(
bool remoteVideoEnabled READ getRemoteVideoEnabled WRITE setRemoteVideoEnabled NOTIFY remoteVideoEnabledChanged) bool remoteVideoEnabled READ getRemoteVideoEnabled WRITE setRemoteVideoEnabled NOTIFY remoteVideoEnabledChanged)
Q_PROPERTY( Q_PROPERTY(bool localVideoEnabled READ getLocalVideoEnabled NOTIFY localVideoEnabledChanged)
bool localVideoEnabled READ getLocalVideoEnabled WRITE lSetLocalVideoEnabled NOTIFY localVideoEnabledChanged) Q_PROPERTY(bool cameraEnabled READ getCameraEnabled WRITE lSetCameraEnabled NOTIFY cameraEnabledChanged)
Q_PROPERTY(bool recording READ getRecording WRITE setRecording NOTIFY recordingChanged) Q_PROPERTY(bool recording READ getRecording WRITE setRecording NOTIFY recordingChanged)
Q_PROPERTY(bool remoteRecording READ getRemoteRecording WRITE setRemoteRecording NOTIFY remoteRecordingChanged) Q_PROPERTY(bool remoteRecording READ getRemoteRecording WRITE setRemoteRecording NOTIFY remoteRecordingChanged)
Q_PROPERTY(bool recordable READ getRecordable WRITE setRecordable NOTIFY recordableChanged) Q_PROPERTY(bool recordable READ getRecordable WRITE setRecordable NOTIFY recordableChanged)
@ -201,6 +201,9 @@ public:
bool getLocalVideoEnabled() const; bool getLocalVideoEnabled() const;
void setLocalVideoEnabled(bool enabled); void setLocalVideoEnabled(bool enabled);
bool getCameraEnabled() const;
void setCameraEnabled(bool enabled);
bool getRecording() const; bool getRecording() const;
void setRecording(bool recording); void setRecording(bool recording);
@ -255,6 +258,7 @@ signals:
void remoteTokensChanged(); void remoteTokensChanged();
void remoteVideoEnabledChanged(bool remoteVideoEnabled); void remoteVideoEnabledChanged(bool remoteVideoEnabled);
void localVideoEnabledChanged(); void localVideoEnabledChanged();
void cameraEnabledChanged();
void recordingChanged(); void recordingChanged();
void remoteRecordingChanged(); void remoteRecordingChanged();
void recordableChanged(); void recordableChanged();
@ -275,7 +279,7 @@ signals:
void lTerminateAllCalls(); // Hangup all calls void lTerminateAllCalls(); // Hangup all calls
void lSetSpeakerMuted(bool muted); void lSetSpeakerMuted(bool muted);
void lSetMicrophoneMuted(bool isMuted); void lSetMicrophoneMuted(bool isMuted);
void lSetLocalVideoEnabled(bool enabled); void lSetCameraEnabled(bool enabled);
void lSetVideoEnabled(bool enabled); void lSetVideoEnabled(bool enabled);
void lSetPaused(bool paused); void lSetPaused(bool paused);
void lTransferCall(QString address); void lTransferCall(QString address);
@ -331,6 +335,7 @@ private:
bool mSpeakerMuted = false; bool mSpeakerMuted = false;
bool mMicrophoneMuted = false; bool mMicrophoneMuted = false;
bool mLocalVideoEnabled = false; bool mLocalVideoEnabled = false;
bool mCameraEnabled = false;
bool mVideoEnabled = false; bool mVideoEnabled = false;
bool mPaused = false; bool mPaused = false;
bool mRemoteVideoEnabled = false; bool mRemoteVideoEnabled = false;

View file

@ -33,7 +33,7 @@ class CoreModel;
class CallList : public ListProxy, public AbstractObject { class CallList : public ListProxy, public AbstractObject {
Q_OBJECT Q_OBJECT
Q_PROPERTY(CallGui* currentCall READ getCurrentCall WRITE setCurrentCall NOTIFY currentCallChanged) Q_PROPERTY(CallGui *currentCall READ getCurrentCall WRITE setCurrentCall NOTIFY currentCallChanged)
public: public:
static QSharedPointer<CallList> create(); static QSharedPointer<CallList> create();
// Create a CallCore and make connections to List. // Create a CallCore and make connections to List.

View file

@ -118,6 +118,7 @@ ChatCore::ChatCore(const std::shared_ptr<linphone::ChatRoom> &chatRoom) : QObjec
ChatCore::~ChatCore() { ChatCore::~ChatCore() {
lDebug() << "[ChatCore] delete" << this; lDebug() << "[ChatCore] delete" << this;
mustBeInMainThread("~" + getClassName()); mustBeInMainThread("~" + getClassName());
if (mChatModelConnection) mChatModelConnection->disconnect();
emit mChatModel->removeListener(); emit mChatModel->removeListener();
} }
@ -162,14 +163,13 @@ void ChatCore::setSelf(QSharedPointer<ChatCore> me) {
mChatModelConnection->makeConnectToCore(&ChatCore::lDelete, [this]() { mChatModelConnection->makeConnectToCore(&ChatCore::lDelete, [this]() {
mChatModelConnection->invokeToModel([this]() { mChatModel->deleteChatRoom(); }); mChatModelConnection->invokeToModel([this]() { mChatModel->deleteChatRoom(); });
}); });
mChatModelConnection->makeConnectToModel(
&ChatModel::deleted, [this]() { mChatModelConnection->invokeToCore([this]() { emit deleted(); }); });
mChatModelConnection->makeConnectToModel( mChatModelConnection->makeConnectToModel(
&ChatModel::stateChanged, &ChatModel::stateChanged,
[this](const std::shared_ptr<linphone::ChatRoom> &chatRoom, linphone::ChatRoom::State newState) { [this](const std::shared_ptr<linphone::ChatRoom> &chatRoom, linphone::ChatRoom::State newState) {
auto state = LinphoneEnums::fromLinphone(newState); auto state = LinphoneEnums::fromLinphone(newState);
bool isReadOnly = chatRoom->isReadOnly(); bool isReadOnly = chatRoom->isReadOnly();
if (newState == linphone::ChatRoom::State::Deleted) emit deleted();
mChatModelConnection->invokeToCore([this, state, isReadOnly]() { mChatModelConnection->invokeToCore([this, state, isReadOnly]() {
setChatRoomState(state); setChatRoomState(state);
setIsReadOnly(isReadOnly); setIsReadOnly(isReadOnly);
@ -207,8 +207,8 @@ void ChatCore::setSelf(QSharedPointer<ChatCore> me) {
&ChatModel::newEvent, [this](const std::shared_ptr<linphone::ChatRoom> &chatRoom, &ChatModel::newEvent, [this](const std::shared_ptr<linphone::ChatRoom> &chatRoom,
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;
qDebug() << "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}); });
} }
@ -220,10 +220,10 @@ void ChatCore::setSelf(QSharedPointer<ChatCore> me) {
&ChatModel::chatMessagesReceived, [this](const std::shared_ptr<linphone::ChatRoom> &chatRoom, &ChatModel::chatMessagesReceived, [this](const std::shared_ptr<linphone::ChatRoom> &chatRoom,
const std::list<std::shared_ptr<linphone::EventLog>> &eventsLog) { const std::list<std::shared_ptr<linphone::EventLog>> &eventsLog) {
if (mChatModel->getMonitor() != chatRoom) return; if (mChatModel->getMonitor() != chatRoom) return;
qDebug() << "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]() {
@ -234,13 +234,14 @@ void ChatCore::setSelf(QSharedPointer<ChatCore> me) {
}); });
mChatModelConnection->makeConnectToCore(&ChatCore::lMarkAsRead, [this]() { mChatModelConnection->makeConnectToCore(&ChatCore::lMarkAsRead, [this]() {
auto mainWindow = Utils::getMainWindow(); auto lastActiveWindow = Utils::getLastActiveWindow();
if (mainWindow->isActive()) mChatModelConnection->invokeToModel([this]() { mChatModel->markAsRead(); }); if (lastActiveWindow && lastActiveWindow->isActive())
mChatModelConnection->invokeToModel([this]() { mChatModel->markAsRead(); });
else { else {
connect(mainWindow, &QQuickWindow::activeChanged, this, [this, mainWindow] { connect(lastActiveWindow, &QQuickWindow::activeChanged, this, [this, lastActiveWindow] {
if (mainWindow->isActive()) { if (lastActiveWindow->isActive()) {
disconnect(mainWindow, &QQuickWindow::activeChanged, this, nullptr); disconnect(lastActiveWindow, &QQuickWindow::activeChanged, this, nullptr);
mChatModelConnection->invokeToModel([this, mainWindow] { mChatModel->markAsRead(); }); mChatModelConnection->invokeToModel([this, lastActiveWindow] { mChatModel->markAsRead(); });
} }
}); });
} }
@ -285,7 +286,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(
@ -362,11 +363,15 @@ void ChatCore::setSelf(QSharedPointer<ChatCore> me) {
auto participants = buildParticipants(chatRoom); auto participants = buildParticipants(chatRoom);
mChatModelConnection->invokeToCore([this, participants]() { setParticipants(participants); }); mChatModelConnection->invokeToCore([this, participants]() { setParticipants(participants); });
}); });
mChatModelConnection->makeConnectToModel( mChatModelConnection->makeConnectToModel(&ChatModel::participantAdminStatusChanged,
&ChatModel::participantAdminStatusChanged, [this](const std::shared_ptr<linphone::ChatRoom> &chatRoom, [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 participants = buildParticipants(chatRoom); auto participants = buildParticipants(chatRoom);
mChatModelConnection->invokeToCore([this, participants]() { setParticipants(participants); }); bool meAdmin = chatRoom->getMe()->isAdmin();
mChatModelConnection->invokeToCore([this, participants, meAdmin]() {
setParticipants(participants);
setMeAdmin(meAdmin);
});
}); });
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); });
@ -491,7 +496,7 @@ ChatMessageGui *ChatCore::getLastMessage() const {
void ChatCore::setLastMessage(QSharedPointer<ChatMessageCore> lastMessage) { void ChatCore::setLastMessage(QSharedPointer<ChatMessageCore> lastMessage) {
if (mLastMessage != lastMessage) { if (mLastMessage != lastMessage) {
disconnect(mLastMessage.get()); if (mLastMessage) disconnect(mLastMessage.get(), &ChatMessageCore::messageStateChanged, this, nullptr);
mLastMessage = lastMessage; mLastMessage = lastMessage;
connect(mLastMessage.get(), &ChatMessageCore::messageStateChanged, this, &ChatCore::lastMessageChanged); connect(mLastMessage.get(), &ChatMessageCore::messageStateChanged, this, &ChatCore::lastMessageChanged);
emit lastMessageChanged(); emit lastMessageChanged();
@ -544,10 +549,6 @@ std::shared_ptr<ChatModel> ChatCore::getModel() const {
return mChatModel; return mChatModel;
} }
QSharedPointer<SafeConnection<ChatCore, ChatModel>> ChatCore::getChatModelConnection() const {
return mChatModelConnection;
}
bool ChatCore::isMuted() const { bool ChatCore::isMuted() const {
return mIsMuted; return mIsMuted;
} }

View file

@ -64,7 +64,6 @@ public:
Q_PROPERTY( Q_PROPERTY(
int ephemeralLifetime READ getEphemeralLifetime WRITE lSetEphemeralLifetime NOTIFY ephemeralLifetimeChanged) int ephemeralLifetime READ getEphemeralLifetime WRITE lSetEphemeralLifetime NOTIFY ephemeralLifetimeChanged)
Q_PROPERTY(bool muted READ isMuted WRITE lSetMuted NOTIFY mutedChanged) Q_PROPERTY(bool muted READ isMuted WRITE lSetMuted NOTIFY mutedChanged)
Q_PROPERTY(bool conferenceJoined MEMBER mConferenceJoined NOTIFY conferenceJoined)
Q_PROPERTY(bool meAdmin READ getMeAdmin WRITE setMeAdmin NOTIFY meAdminChanged) Q_PROPERTY(bool meAdmin READ getMeAdmin WRITE setMeAdmin NOTIFY meAdminChanged)
Q_PROPERTY(QVariantList participants READ getParticipantsGui NOTIFY participantsChanged) Q_PROPERTY(QVariantList participants READ getParticipantsGui NOTIFY participantsChanged)
Q_PROPERTY(QStringList participantsAddresses READ getParticipantsAddresses WRITE lSetParticipantsAddresses NOTIFY Q_PROPERTY(QStringList participantsAddresses READ getParticipantsAddresses WRITE lSetParticipantsAddresses NOTIFY
@ -142,7 +141,6 @@ public:
void setComposingAddress(QString composingAddress); void setComposingAddress(QString composingAddress);
std::shared_ptr<ChatModel> getModel() const; std::shared_ptr<ChatModel> getModel() const;
QSharedPointer<SafeConnection<ChatCore, ChatModel>> getChatModelConnection() const;
void setParticipants(QList<QSharedPointer<ParticipantCore>> participants); void setParticipants(QList<QSharedPointer<ParticipantCore>> participants);
QList<QSharedPointer<ParticipantCore>> buildParticipants(const std::shared_ptr<linphone::ChatRoom> &chatRoom) const; QList<QSharedPointer<ParticipantCore>> buildParticipants(const std::shared_ptr<linphone::ChatRoom> &chatRoom) const;

View file

@ -54,13 +54,15 @@ ChatList::~ChatList() {
} }
void ChatList::connectItem(QSharedPointer<ChatCore> chat) { void ChatList::connectItem(QSharedPointer<ChatCore> chat) {
connect(chat.get(), &ChatCore::deleted, this, [this, chat] { connect(
disconnect(chat.get()); chat.get(), &ChatCore::deleted, this,
[this, chat] {
disconnect(chat.get(), &ChatCore::unreadMessagesCountChanged, this, nullptr);
disconnect(chat.get(), &ChatCore::lastUpdatedTimeChanged, this, nullptr);
disconnect(chat.get(), &ChatCore::lastMessageChanged, this, nullptr);
remove(chat); remove(chat);
// We cannot use countChanged here because it is called before mList },
// really has removed the item, then emit specific signal Qt::SingleShotConnection);
emit chatRemoved(chat ? new ChatGui(chat) : nullptr);
});
auto dataChange = [this, chat] { auto dataChange = [this, chat] {
int i = -1; int i = -1;
get(chat.get(), &i); get(chat.get(), &i);
@ -94,7 +96,6 @@ void ChatList::setSelf(QSharedPointer<ChatList> me) {
mModelConnection->invokeToModel([this]() { mModelConnection->invokeToModel([this]() {
mustBeInLinphoneThread(getClassName()); mustBeInLinphoneThread(getClassName());
beginResetModel(); beginResetModel();
mList.clear();
// Avoid copy to lambdas // Avoid copy to lambdas
QList<QSharedPointer<ChatCore>> *chats = new QList<QSharedPointer<ChatCore>>(); QList<QSharedPointer<ChatCore>> *chats = new QList<QSharedPointer<ChatCore>>();
auto currentAccount = CoreModel::getInstance()->getCore()->getDefaultAccount(); auto currentAccount = CoreModel::getInstance()->getCore()->getDefaultAccount();
@ -118,6 +119,7 @@ void ChatList::setSelf(QSharedPointer<ChatList> me) {
disconnect(chat.get(), &ChatCore::lastMessageChanged, this, nullptr); disconnect(chat.get(), &ChatCore::lastMessageChanged, this, nullptr);
} }
} }
mList.clear();
for (auto &chat : *chats) { for (auto &chat : *chats) {
connectItem(chat); connectItem(chat);
} }
@ -143,18 +145,7 @@ void ChatList::setSelf(QSharedPointer<ChatList> me) {
return; return;
} }
auto chatCore = ChatCore::create(room); auto chatCore = ChatCore::create(room);
mModelConnection->invokeToCore([this, chatCore] { mModelConnection->invokeToCore([this, chatCore] { addChatInList(chatCore); });
auto chatList = getSharedList<ChatCore>();
auto it = std::find_if(chatList.begin(), chatList.end(), [chatCore](const QSharedPointer<ChatCore> item) {
return item && chatCore && item->getModel() && chatCore->getModel() &&
item->getModel()->getMonitor() == chatCore->getModel()->getMonitor();
});
if (it == chatList.end()) {
connectItem(chatCore);
add(chatCore);
emit chatAdded();
}
});
}; };
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,
@ -195,17 +186,19 @@ int ChatList::findChatIndex(ChatGui *chatGui) {
return it == chatList.end() ? -1 : std::distance(chatList.begin(), it); return it == chatList.end() ? -1 : std::distance(chatList.begin(), it);
} }
void ChatList::addChatInList(QSharedPointer<ChatCore> chatCore) { bool ChatList::addChatInList(QSharedPointer<ChatCore> chatCore) {
mustBeInMainThread(log().arg(Q_FUNC_INFO));
auto chatList = getSharedList<ChatCore>(); auto chatList = getSharedList<ChatCore>();
auto it = std::find_if(chatList.begin(), chatList.end(), [chatCore](const QSharedPointer<ChatCore> item) { auto it = std::find_if(chatList.begin(), chatList.end(), [chatCore](const QSharedPointer<ChatCore> item) {
return item && chatCore && item->getModel() && chatCore->getModel() && return item && chatCore && item->getIdentifier() == chatCore->getIdentifier();
item->getModel()->getMonitor() == chatCore->getModel()->getMonitor();
}); });
if (it == chatList.end()) { if (it == chatList.end()) {
connectItem(chatCore); connectItem(chatCore);
add(chatCore); add(chatCore);
emit chatAdded(); emit chatAdded();
return true;
} }
return false;
} }
QVariant ChatList::data(const QModelIndex &index, int role) const { QVariant ChatList::data(const QModelIndex &index, int role) const {

View file

@ -42,13 +42,12 @@ public:
void connectItem(QSharedPointer<ChatCore> chat); void connectItem(QSharedPointer<ChatCore> chat);
int findChatIndex(ChatGui *chat); int findChatIndex(ChatGui *chat);
void addChatInList(QSharedPointer<ChatCore> chatCore); bool addChatInList(QSharedPointer<ChatCore> chatCore);
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
signals: signals:
void lUpdate(); void lUpdate();
void filterChanged(QString filter); void filterChanged(QString filter);
void chatRemoved(ChatGui *chat);
void chatAdded(); void chatAdded();
void chatUpdated(); void chatUpdated();

View file

@ -25,7 +25,7 @@
DEFINE_ABSTRACT_OBJECT(ChatProxy) DEFINE_ABSTRACT_OBJECT(ChatProxy)
ChatProxy::ChatProxy(QObject *parent) : LimitProxy(parent) { ChatProxy::ChatProxy(QObject *parent) {
mList = ChatList::create(); mList = ChatList::create();
setSourceModel(mList.get()); setSourceModel(mList.get());
setDynamicSortFilter(true); setDynamicSortFilter(true);
@ -35,53 +35,47 @@ ChatProxy::~ChatProxy() {
} }
void ChatProxy::setSourceModel(QAbstractItemModel *model) { void ChatProxy::setSourceModel(QAbstractItemModel *model) {
auto oldChatList = getListModel<ChatList>(); auto oldChatList = dynamic_cast<ChatList *>(sourceModel());
if (oldChatList) { if (oldChatList) {
disconnect(oldChatList); disconnect(this, &ChatProxy::filterTextChanged, oldChatList, nullptr);
disconnect(oldChatList, &ChatList::chatAdded, this, nullptr);
disconnect(oldChatList, &ChatList::dataChanged, this, nullptr);
} }
auto newChatList = dynamic_cast<ChatList *>(model); auto newChatList = dynamic_cast<ChatList *>(model);
if (newChatList) { if (newChatList) {
connect(this, &ChatProxy::filterTextChanged, newChatList, connect(this, &ChatProxy::filterTextChanged, newChatList,
[this, newChatList] { emit newChatList->filterChanged(getFilterText()); }); [this, newChatList] { emit newChatList->filterChanged(getFilterText()); });
connect(newChatList, &ChatList::chatRemoved, this, &ChatProxy::chatRemoved);
connect(newChatList, &ChatList::chatAdded, this, [this] { invalidate(); }); connect(newChatList, &ChatList::chatAdded, this, [this] { invalidate(); });
connect(newChatList, &ChatList::dataChanged, this, [this] { invalidate(); }); connect(newChatList, &ChatList::dataChanged, this, [this] { invalidate(); });
} }
auto firstList = new SortFilterList(model, Qt::AscendingOrder); QSortFilterProxyModel::setSourceModel(newChatList);
firstList->setDynamicSortFilter(true);
setSourceModels(firstList);
sort(0); sort(0);
} }
int ChatProxy::findChatIndex(ChatGui *chatGui) { int ChatProxy::findChatIndex(ChatGui *chatGui) {
auto chatList = getListModel<ChatList>(); auto chatList = dynamic_cast<ChatList *>(sourceModel());
if (chatList) { if (chatList) {
auto listIndex = chatList->findChatIndex(chatGui); auto listIndex = chatList->findChatIndex(chatGui);
if (listIndex != -1) { if (listIndex != -1) {
listIndex = listIndex = mapFromSource(chatList->index(listIndex, 0)).row();
dynamic_cast<SortFilterList *>(sourceModel())->mapFromSource(chatList->index(listIndex, 0)).row();
if (mMaxDisplayItems <= listIndex) setMaxDisplayItems(listIndex + mDisplayItemsStep);
return listIndex; return listIndex;
} }
} }
return -1; return -1;
} }
void ChatProxy::addChatInList(ChatGui *chatGui) { bool ChatProxy::addChatInList(ChatGui *chatGui) {
auto chatList = getListModel<ChatList>(); auto chatList = dynamic_cast<ChatList *>(sourceModel());
if (chatList && chatGui) { if (chatList && chatGui) {
chatList->addChatInList(chatGui->mCore); return chatList->addChatInList(chatGui->mCore);
} }
return false;
} }
bool ChatProxy::SortFilterList::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const { bool ChatProxy::lessThan(const QModelIndex &sourceLeft, const QModelIndex &sourceRight) const {
return true;
}
bool ChatProxy::SortFilterList::lessThan(const QModelIndex &sourceLeft, const QModelIndex &sourceRight) const {
if (!mFilterText.isEmpty()) return false; if (!mFilterText.isEmpty()) return false;
auto l = getItemAtSource<ChatList, ChatCore>(sourceLeft.row()); auto l = getItemAtSource<ChatList, ChatCore>(sourceLeft.row());
auto r = getItemAtSource<ChatList, ChatCore>(sourceRight.row()); auto r = getItemAtSource<ChatList, ChatCore>(sourceRight.row());
if (l && r) return l->getLastUpdatedTime() >= r->getLastUpdatedTime(); if (l && r) return l->getLastUpdatedTime() > r->getLastUpdatedTime();
return false; return false;
} }

View file

@ -21,29 +21,26 @@
#ifndef CHAT_PROXY_H_ #ifndef CHAT_PROXY_H_
#define CHAT_PROXY_H_ #define CHAT_PROXY_H_
#include "../proxy/LimitProxy.hpp" #include "../proxy/SortFilterProxy.hpp"
#include "core/chat/ChatGui.hpp" #include "core/chat/ChatGui.hpp"
#include "core/chat/ChatList.hpp" #include "core/chat/ChatList.hpp"
#include "tool/AbstractObject.hpp" #include "tool/AbstractObject.hpp"
// ============================================================================= // =============================================================================
class ChatProxy : public LimitProxy, public AbstractObject { class ChatProxy : public SortFilterProxy, public AbstractObject {
Q_OBJECT Q_OBJECT
public: public:
DECLARE_SORTFILTER_CLASS()
ChatProxy(QObject *parent = Q_NULLPTR); ChatProxy(QObject *parent = Q_NULLPTR);
~ChatProxy(); ~ChatProxy();
void setSourceModel(QAbstractItemModel *sourceModel) override; void setSourceModel(QAbstractItemModel *sourceModel) override;
Q_INVOKABLE int findChatIndex(ChatGui *chatGui); bool lessThan(const QModelIndex &sourceLeft, const QModelIndex &sourceRight) const override;
Q_INVOKABLE void addChatInList(ChatGui *chatGui);
signals: Q_INVOKABLE int findChatIndex(ChatGui *chatGui);
void chatRemoved(ChatGui *chat); Q_INVOKABLE bool addChatInList(ChatGui *chatGui);
protected: protected:
QSharedPointer<ChatList> mList; QSharedPointer<ChatList> mList;

View file

@ -112,6 +112,7 @@ ChatMessageCore::ChatMessageCore(const std::shared_ptr<linphone::ChatMessage> &c
// lDebug() << "[ChatMessageCore] new" << this; // lDebug() << "[ChatMessageCore] new" << this;
mustBeInLinphoneThread(getClassName()); mustBeInLinphoneThread(getClassName());
App::getInstance()->mEngine->setObjectOwnership(this, QQmlEngine::CppOwnership); App::getInstance()->mEngine->setObjectOwnership(this, QQmlEngine::CppOwnership);
if (chatmessage) {
mChatMessageModel = Utils::makeQObject_ptr<ChatMessageModel>(chatmessage); mChatMessageModel = Utils::makeQObject_ptr<ChatMessageModel>(chatmessage);
mChatMessageModel->setSelf(mChatMessageModel); mChatMessageModel->setSelf(mChatMessageModel);
mText = ToolModel::getMessageFromContent(chatmessage->getContents()); mText = ToolModel::getMessageFromContent(chatmessage->getContents());
@ -127,13 +128,13 @@ ChatMessageCore::ChatMessageCore(const std::shared_ptr<linphone::ChatMessage> &c
mFromAddress = Utils::coreStringToAppString(fromAddress->asStringUriOnly()); mFromAddress = Utils::coreStringToAppString(fromAddress->asStringUriOnly());
mFromName = ToolModel::getDisplayName(chatmessage->getFromAddress()); mFromName = ToolModel::getDisplayName(chatmessage->getFromAddress());
mToName = ToolModel::getDisplayName(chatmessage->getToAddress()); mToName = ToolModel::getDisplayName(chatmessage->getToAddress());
auto chatroom = chatmessage->getChatRoom(); auto chatroom = chatmessage->getChatRoom();
mIsFromChatGroup = chatroom->hasCapability((int)linphone::ChatRoom::Capabilities::Conference) && mIsFromChatGroup = chatroom->hasCapability((int)linphone::ChatRoom::Capabilities::Conference) &&
!chatroom->hasCapability((int)linphone::ChatRoom::Capabilities::OneToOne); !chatroom->hasCapability((int)linphone::ChatRoom::Capabilities::OneToOne);
mIsRead = chatmessage->isRead(); mIsRead = chatmessage->isRead();
mMessageState = LinphoneEnums::fromLinphone(chatmessage->getState()); mMessageState = LinphoneEnums::fromLinphone(chatmessage->getState());
mIsEphemeral = chatmessage->isEphemeral(); mIsEphemeral = chatmessage->isEphemeral();
if (mIsEphemeral) { if (mIsEphemeral) {
auto now = QDateTime::currentDateTime(); auto now = QDateTime::currentDateTime();
mEphemeralDuration = chatmessage->getEphemeralExpireTime() == 0 mEphemeralDuration = chatmessage->getEphemeralExpireTime() == 0
@ -144,7 +145,8 @@ ChatMessageCore::ChatMessageCore(const std::shared_ptr<linphone::ChatMessage> &c
for (auto content : chatmessage->getContents()) { for (auto content : chatmessage->getContents()) {
auto contentCore = ChatMessageContentCore::create(content, mChatMessageModel); auto contentCore = ChatMessageContentCore::create(content, mChatMessageModel);
mChatMessageContentList.push_back(contentCore); mChatMessageContentList.push_back(contentCore);
if ((content->isFile() || content->isFileTransfer()) && !content->isVoiceRecording()) mHasFileContent = true; if ((content->isFile() || content->isFileTransfer()) && !content->isVoiceRecording())
mHasFileContent = true;
if (content->isIcalendar()) mIsCalendarInvite = true; if (content->isIcalendar()) mIsCalendarInvite = true;
if (content->isVoiceRecording()) { if (content->isVoiceRecording()) {
mIsVoiceRecording = true; mIsVoiceRecording = true;
@ -194,6 +196,7 @@ ChatMessageCore::ChatMessageCore(const std::shared_ptr<linphone::ChatMessage> &c
} }
} }
mImdnStatusList = computeDeliveryStatus(chatmessage); mImdnStatusList = computeDeliveryStatus(chatmessage);
}
} }
ChatMessageCore::~ChatMessageCore() { ChatMessageCore::~ChatMessageCore() {

View file

@ -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;

View file

@ -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_

View file

@ -64,7 +64,6 @@ void EventLogList::disconnectItem(const QSharedPointer<EventLogCore> &item) {
if (message) { if (message) {
disconnect(message.get(), &ChatMessageCore::isReadChanged, this, nullptr); disconnect(message.get(), &ChatMessageCore::isReadChanged, this, nullptr);
disconnect(message.get(), &ChatMessageCore::deleted, this, nullptr); disconnect(message.get(), &ChatMessageCore::deleted, this, nullptr);
disconnect(message.get(), &ChatMessageCore::ephemeralDurationChanged, this, nullptr);
} }
} }
@ -82,7 +81,6 @@ void EventLogList::connectItem(const QSharedPointer<EventLogCore> &item) {
} }
void EventLogList::setChatCore(QSharedPointer<ChatCore> core) { void EventLogList::setChatCore(QSharedPointer<ChatCore> core) {
auto updateChatCore = [this](QSharedPointer<ChatCore> core) {
if (mChatCore != core) { if (mChatCore != core) {
if (mChatCore) { if (mChatCore) {
disconnect(mChatCore.get(), &ChatCore::eventsInserted, this, nullptr); disconnect(mChatCore.get(), &ChatCore::eventsInserted, this, nullptr);
@ -91,37 +89,27 @@ void EventLogList::setChatCore(QSharedPointer<ChatCore> core) {
mChatCore = core; mChatCore = core;
if (mChatCore) { if (mChatCore) {
connect(mChatCore.get(), &ChatCore::eventListCleared, this, [this] { resetData(); }); connect(mChatCore.get(), &ChatCore::eventListCleared, this, [this] { resetData(); });
connect(mChatCore.get(), &ChatCore::eventsInserted, this, connect(mChatCore.get(), &ChatCore::eventsInserted, this, [this](QList<QSharedPointer<EventLogCore>> list) {
[this](QList<QSharedPointer<EventLogCore>> list) {
auto eventsList = getSharedList<EventLogCore>(); auto eventsList = getSharedList<EventLogCore>();
for (auto &event : list) { for (auto &event : list) {
auto it = std::find_if( auto it = std::find_if(eventsList.begin(), eventsList.end(),
eventsList.begin(), eventsList.end(),
[event](const QSharedPointer<EventLogCore> item) { return item == event; }); [event](const QSharedPointer<EventLogCore> item) { return item == event; });
if (it == eventsList.end()) { if (it == eventsList.end()) {
connectItem(event); connectItem(event);
add(event); prepend(event);
int index; int index;
get(event.get(), &index); get(event.get(), &index);
emit eventInserted(index, new EventLogGui(event)); if (event->getChatMessageCore() && !event->getChatMessageCore()->isRemoteMessage()) {
emit eventInsertedByUser(index);
}
} }
} }
}); });
} }
lUpdate(); lUpdate();
// setIsUpdating(false);
emit chatGuiChanged(); emit chatGuiChanged();
} }
};
if (mIsUpdating) {
connect(this, &EventLogList::isUpdatingChanged, this, [this, core, updateChatCore] {
if (!mIsUpdating) {
updateChatCore(core);
disconnect(this, &EventLogList::isUpdatingChanged, this, nullptr);
}
});
} else {
updateChatCore(core);
}
} }
void EventLogList::setChatGui(ChatGui *chat) { void EventLogList::setChatGui(ChatGui *chat) {
@ -136,6 +124,13 @@ void EventLogList::setDisplayItemsStep(int displayItemsStep) {
} }
} }
void EventLogList::markIndexAsRead(int index) {
if (index < mList.count()) {
auto eventLog = mList[index].objectCast<EventLogCore>();
if (eventLog && eventLog->getChatMessageCore()) eventLog->getChatMessageCore()->lMarkAsRead();
}
}
void EventLogList::displayMore() { void EventLogList::displayMore() {
auto loadMoreItems = [this] { auto loadMoreItems = [this] {
if (!mChatCore) return; if (!mChatCore) return;
@ -152,14 +147,17 @@ 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); if (it->getChatMessage() || model->isHandled()) events->push_front(model);
} }
mCoreModelConnection->invokeToCore([this, events] { mCoreModelConnection->invokeToCore([this, events] {
int currentCount = mList.count(); int currentCount = mList.count();
for (auto it = events->end() - 1; it >= events->begin(); --it) { if (!events->isEmpty()) {
connectItem(*it); for (int i = events->size() - 1; i >= 0; --i) {
prepend(*it); const auto &ev = events->at(i);
connectItem(ev);
}
add(*events);
} }
}); });
}); });
@ -177,8 +175,10 @@ void EventLogList::displayMore() {
void EventLogList::loadMessagesUpTo(std::shared_ptr<linphone::EventLog> event) { void EventLogList::loadMessagesUpTo(std::shared_ptr<linphone::EventLog> event) {
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
auto oldestEventLoaded = getAt<EventLogCore>(0); auto oldestEventLoaded = mList.count() > 0 ? getAt<EventLogCore>(mList.count() - 1) : nullptr;
auto linOldest = std::const_pointer_cast<linphone::EventLog>(oldestEventLoaded->getModel()->getEventLog()); auto linOldest = oldestEventLoaded
? std::const_pointer_cast<linphone::EventLog>(oldestEventLoaded->getModel()->getEventLog())
: nullptr;
auto chatModel = mChatCore->getModel(); auto chatModel = mChatCore->getModel();
assert(chatModel); assert(chatModel);
if (!chatModel) return; if (!chatModel) return;
@ -187,47 +187,55 @@ 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) {
events->push_back(model); auto model = EventLogCore::create(it, linChatRoom);
if (it->getChatMessage() || model->isHandled()) events->push_front(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); if (it->getChatMessage() || model->isHandled()) events->push_front(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(*events);
emit messagesLoadedUpTo(event); emit messagesLoadedUpTo(event);
}); });
} }
int EventLogList::findFirstUnreadIndex() { int EventLogList::findFirstUnreadIndex() {
auto eventList = getSharedList<EventLogCore>(); auto eventList = getSharedList<EventLogCore>();
auto it = std::find_if(eventList.begin(), eventList.end(), [](const QSharedPointer<EventLogCore> item) { auto it = std::find_if(eventList.rbegin(), eventList.rend(), [](const QSharedPointer<EventLogCore> item) {
return item->getChatMessageCore() && !item->getChatMessageCore()->isRead(); auto chatmessage = item->getChatMessageCore();
return chatmessage && !chatmessage->isRead();
}); });
return it == eventList.end() ? -1 : std::distance(eventList.begin(), it); return it == eventList.rend() ? -1 : std::distance(it, eventList.rend()) - 1;
} }
void EventLogList::findChatMessageWithFilter(QString filter, void EventLogList::findChatMessageWithFilter(QString filter, int startIndex, bool forward, bool isFirstResearch) {
QSharedPointer<EventLogCore> startEvent,
bool forward,
bool isFirstResearch) {
if (mChatCore) { if (mChatCore) {
if (isFirstResearch) mLastFoundResult.reset(); if (isFirstResearch) mLastFoundResult.reset();
auto chatModel = mChatCore->getModel(); auto chatModel = mChatCore->getModel();
auto startEvent =
startIndex >= 0 && startIndex < mList.count() ? mList[startIndex].objectCast<EventLogCore>() : nullptr;
lInfo() << log().arg("searching event starting from index") << startIndex << "| event :"
<< (startEvent && startEvent->getChatMessageCore() ? startEvent->getChatMessageCore()->getText()
: "null")
<< "| filter :" << filter;
auto startEventModel = startEvent ? startEvent->getModel() : nullptr; auto startEventModel = startEvent ? startEvent->getModel() : nullptr;
mCoreModelConnection->invokeToModel([this, chatModel, startEventModel, filter, forward, isFirstResearch] { mCoreModelConnection->invokeToModel([this, chatModel, startEventModel, filter, forward, isFirstResearch] {
auto linStartEvent = startEventModel ? startEventModel->getEventLog() : nullptr; auto linStartEvent = startEventModel ? startEventModel->getEventLog() : nullptr;
auto eventLog = chatModel->searchMessageByText(filter, linStartEvent, forward); auto eventLog = chatModel->searchMessageByText(filter, linStartEvent, forward);
if (!eventLog) if (!eventLog) {
// event not found, search in the entire history // event not found, search in the entire history
lInfo() << log().arg("not found, search in entire history");
auto eventLog = chatModel->searchMessageByText(filter, nullptr, forward); auto eventLog = chatModel->searchMessageByText(filter, nullptr, forward);
}
int index = -1; int index = -1;
if (eventLog) { if (eventLog) {
lInfo() << log().arg("event with filter found") << eventLog.get();
auto eventList = getSharedList<EventLogCore>(); auto eventList = getSharedList<EventLogCore>();
auto it = std::find_if(eventList.begin(), eventList.end(), auto it = std::find_if(eventList.begin(), eventList.end(),
[eventLog](const QSharedPointer<EventLogCore> item) { [eventLog](const QSharedPointer<EventLogCore> item) {
@ -255,6 +263,7 @@ void EventLogList::findChatMessageWithFilter(QString filter,
loadMessagesUpTo(eventLog); loadMessagesUpTo(eventLog);
} }
} else { } else {
lInfo() << log().arg("event not found at all in history");
mCoreModelConnection->invokeToCore([this, index] { emit messageWithFilterFound(index); }); mCoreModelConnection->invokeToCore([this, index] { emit messageWithFilterFound(index); });
} }
}); });
@ -277,6 +286,9 @@ void EventLogList::setSelf(QSharedPointer<EventLogList> me) {
} }
setIsUpdating(true); setIsUpdating(true);
beginResetModel(); beginResetModel();
for (auto &event : getSharedList<EventLogCore>()) {
disconnectItem(event);
}
mList.clear(); mList.clear();
if (!mChatCore) { if (!mChatCore) {
endResetModel(); endResetModel();
@ -294,17 +306,10 @@ 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); if (it->getChatMessage() || model->isHandled()) events->push_front(model);
} }
mCoreModelConnection->invokeToCore([this, events] { mCoreModelConnection->invokeToCore([this, events] {
for (auto &event : getSharedList<EventLogCore>()) {
auto message = event->getChatMessageCore();
if (message) {
disconnect(message.get(), &ChatMessageCore::ephemeralDurationChanged, this, nullptr);
disconnect(message.get(), &ChatMessageCore::deleted, this, nullptr);
}
}
for (auto &event : *events) { for (auto &event : *events) {
connectItem(event); connectItem(event);
mList.append(event); mList.append(event);

View file

@ -54,13 +54,12 @@ public:
int findFirstUnreadIndex(); int findFirstUnreadIndex();
void markIndexAsRead(int index);
void displayMore(); void displayMore();
void setDisplayItemsStep(int displayItemsStep); void setDisplayItemsStep(int displayItemsStep);
void findChatMessageWithFilter(QString filter, void findChatMessageWithFilter(QString filter, int startIndex, bool forward = true, bool isFirstResearch = true);
QSharedPointer<EventLogCore> startEvent,
bool forward = true,
bool isFirstResearch = true);
void setSelf(QSharedPointer<EventLogList> me); void setSelf(QSharedPointer<EventLogList> me);
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
@ -69,7 +68,7 @@ public:
signals: signals:
void lUpdate(); void lUpdate();
void filterChanged(QString filter); void filterChanged(QString filter);
void eventInserted(int index, EventLogGui *message); void eventInsertedByUser(int index);
void messageWithFilterFound(int index); void messageWithFilterFound(int index);
void listAboutToBeReset(); void listAboutToBeReset();
void chatGuiChanged(); void chatGuiChanged();
@ -79,7 +78,6 @@ signals:
private: private:
QString mFilter; QString mFilter;
QSharedPointer<ChatCore> mChatCore; QSharedPointer<ChatCore> mChatCore;
QSharedPointer<SafeConnection<ChatCore, ChatModel>> mChatModelConnection;
QSharedPointer<SafeConnection<EventLogList, CoreModel>> mCoreModelConnection; QSharedPointer<SafeConnection<EventLogList, CoreModel>> mCoreModelConnection;
int mDisplayItemsStep = 0; int mDisplayItemsStep = 0;
int mItemsToLoadBeforeSearchResult = 3; int mItemsToLoadBeforeSearchResult = 3;

View file

@ -26,7 +26,7 @@
DEFINE_ABSTRACT_OBJECT(EventLogProxy) DEFINE_ABSTRACT_OBJECT(EventLogProxy)
EventLogProxy::EventLogProxy(QObject *parent) : LimitProxy(parent) { EventLogProxy::EventLogProxy(QObject *parent) : QSortFilterProxyModel(parent) {
mList = EventLogList::create(); mList = EventLogList::create();
setSourceModel(mList.get()); setSourceModel(mList.get());
} }
@ -35,54 +35,41 @@ EventLogProxy::~EventLogProxy() {
} }
void EventLogProxy::setSourceModel(QAbstractItemModel *model) { void EventLogProxy::setSourceModel(QAbstractItemModel *model) {
auto oldEventLogList = getListModel<EventLogList>(); auto oldEventLogList = dynamic_cast<EventLogList *>(sourceModel());
if (oldEventLogList) { if (oldEventLogList) {
disconnect(oldEventLogList); disconnect(oldEventLogList, &EventLogList::displayItemsStepChanged, this, nullptr);
disconnect(oldEventLogList, &EventLogList::messageWithFilterFound, this, nullptr);
disconnect(oldEventLogList, &EventLogList::eventInsertedByUser, this, nullptr);
} }
auto newEventLogList = dynamic_cast<EventLogList *>(model); auto newEventLogList = dynamic_cast<EventLogList *>(model);
if (newEventLogList) { if (newEventLogList) {
connect(newEventLogList, &EventLogList::listAboutToBeReset, this, &EventLogProxy::listAboutToBeReset);
connect(newEventLogList, &EventLogList::chatGuiChanged, this, &EventLogProxy::chatGuiChanged);
connect(this, &EventLogProxy::displayItemsStepChanged, newEventLogList, connect(this, &EventLogProxy::displayItemsStepChanged, newEventLogList,
[this, newEventLogList] { newEventLogList->setDisplayItemsStep(mDisplayItemsStep); }); [this, newEventLogList] { newEventLogList->setDisplayItemsStep(mDisplayItemsStep); });
connect(newEventLogList, &EventLogList::eventInserted, this,
[this, newEventLogList](int index, EventLogGui *event) {
invalidate();
int proxyIndex = -1;
if (index != -1) {
proxyIndex = dynamic_cast<SortFilterList *>(sourceModel())
->mapFromSource(newEventLogList->index(index, 0))
.row();
}
loadUntil(proxyIndex);
emit eventInserted(proxyIndex, event);
});
connect(newEventLogList, &EventLogList::messageWithFilterFound, this, [this, newEventLogList](int i) { connect(newEventLogList, &EventLogList::messageWithFilterFound, this, [this, newEventLogList](int i) {
connect(this, &EventLogProxy::layoutChanged, newEventLogList, [this, i, newEventLogList] { auto model = dynamic_cast<EventLogList *>(sourceModel());
disconnect(this, &EventLogProxy::layoutChanged, newEventLogList, nullptr); int proxyIndex = mapFromSource(newEventLogList->index(i, 0)).row();
auto model = getListModel<EventLogList>();
int proxyIndex =
dynamic_cast<SortFilterList *>(sourceModel())->mapFromSource(newEventLogList->index(i, 0)).row();
if (i != -1) { if (i != -1) {
loadUntil(proxyIndex); loadUntil(proxyIndex);
} }
emit indexWithFilterFound(proxyIndex); emit indexWithFilterFound(proxyIndex);
}); });
invalidate(); connect(newEventLogList, &EventLogList::eventInsertedByUser, this, [this, newEventLogList](int i) {
int proxyIndex = mapFromSource(newEventLogList->index(i, 0)).row();
emit eventInsertedByUser(proxyIndex);
}); });
} }
setSourceModels(new SortFilterList(model, Qt::DescendingOrder)); QSortFilterProxyModel::setSourceModel(model);
sort(0, Qt::DescendingOrder);
} }
ChatGui *EventLogProxy::getChatGui() { ChatGui *EventLogProxy::getChatGui() {
auto model = getListModel<EventLogList>(); auto model = dynamic_cast<EventLogList *>(sourceModel());
if (!mChatGui && model) mChatGui = model->getChat(); if (!mChatGui && model) mChatGui = model->getChat();
return mChatGui; return mChatGui;
} }
void EventLogProxy::setChatGui(ChatGui *chat) { void EventLogProxy::setChatGui(ChatGui *chat) {
getListModel<EventLogList>()->setChatGui(chat); auto model = dynamic_cast<EventLogList *>(sourceModel());
if (model) model->setChatGui(chat);
} }
EventLogGui *EventLogProxy::getEventAtIndex(int i) { EventLogGui *EventLogProxy::getEventAtIndex(int i) {
@ -90,29 +77,86 @@ EventLogGui *EventLogProxy::getEventAtIndex(int i) {
return eventCore == nullptr ? nullptr : new EventLogGui(eventCore); return eventCore == nullptr ? nullptr : new EventLogGui(eventCore);
} }
int EventLogProxy::getCount() const {
return rowCount();
}
int EventLogProxy::getInitialDisplayItems() const {
return mInitialDisplayItems;
}
void EventLogProxy::setInitialDisplayItems(int initialItems) {
if (mInitialDisplayItems != initialItems) {
mInitialDisplayItems = initialItems;
if (getMaxDisplayItems() <= mInitialDisplayItems) setMaxDisplayItems(initialItems);
if (getDisplayItemsStep() <= 0) setDisplayItemsStep(initialItems);
emit initialDisplayItemsChanged();
}
}
int EventLogProxy::getDisplayCount(int listCount, int maxCount) {
return maxCount >= 0 ? qMin(listCount, maxCount) : listCount;
}
int EventLogProxy::getDisplayCount(int listCount) const {
return getDisplayCount(listCount, mMaxDisplayItems);
}
QSharedPointer<EventLogCore> EventLogProxy::getEventCoreAtIndex(int i) { QSharedPointer<EventLogCore> EventLogProxy::getEventCoreAtIndex(int i) {
return getItemAt<SortFilterList, EventLogList, EventLogCore>(i); auto model = dynamic_cast<EventLogList *>(sourceModel());
if (model) {
return model->getAt<EventLogCore>(mapToSource(index(i, 0)).row());
}
return nullptr;
} }
void EventLogProxy::displayMore() { void EventLogProxy::displayMore() {
auto model = getListModel<EventLogList>(); auto model = dynamic_cast<EventLogList *>(sourceModel());
if (model) { if (model) {
model->displayMore(); model->displayMore();
} }
} }
int EventLogProxy::getMaxDisplayItems() const {
return mMaxDisplayItems;
}
void EventLogProxy::setMaxDisplayItems(int maxItems) {
if (mMaxDisplayItems != maxItems) {
auto model = sourceModel();
int modelCount = model ? model->rowCount() : 0;
int oldCount = getDisplayCount(modelCount);
mMaxDisplayItems = maxItems;
if (getInitialDisplayItems() > mMaxDisplayItems) setInitialDisplayItems(maxItems);
if (getDisplayItemsStep() <= 0) setDisplayItemsStep(maxItems);
emit maxDisplayItemsChanged();
if (model && getDisplayCount(modelCount) != oldCount) {
invalidate();
}
}
}
int EventLogProxy::getDisplayItemsStep() const {
return mDisplayItemsStep;
}
void EventLogProxy::setDisplayItemsStep(int step) {
if (step > 0 && mDisplayItemsStep != step) {
mDisplayItemsStep = step;
emit displayItemsStepChanged();
}
}
void EventLogProxy::loadUntil(int index) { void EventLogProxy::loadUntil(int index) {
auto confInfoList = getListModel<EventLogList>();
if (mMaxDisplayItems < index) setMaxDisplayItems(index + mDisplayItemsStep); if (mMaxDisplayItems < index) setMaxDisplayItems(index + mDisplayItemsStep);
} }
int EventLogProxy::findFirstUnreadIndex() { int EventLogProxy::findFirstUnreadIndex() {
auto eventLogList = getListModel<EventLogList>(); auto eventLogList = dynamic_cast<EventLogList *>(sourceModel());
if (eventLogList) { if (eventLogList) {
auto listIndex = eventLogList->findFirstUnreadIndex(); auto listIndex = eventLogList->findFirstUnreadIndex();
if (listIndex != -1) { if (listIndex != -1) {
listIndex = listIndex = mapFromSource(eventLogList->index(listIndex, 0)).row();
dynamic_cast<SortFilterList *>(sourceModel())->mapFromSource(eventLogList->index(listIndex, 0)).row();
if (mMaxDisplayItems <= listIndex) setMaxDisplayItems(listIndex + mDisplayItemsStep); if (mMaxDisplayItems <= listIndex) setMaxDisplayItems(listIndex + mDisplayItemsStep);
return listIndex; return listIndex;
} else { } else {
@ -122,32 +166,43 @@ int EventLogProxy::findFirstUnreadIndex() {
return 0; return 0;
} }
QString EventLogProxy::getFilterText() const {
return mFilterText;
}
void EventLogProxy::setFilterText(const QString &filter) {
if (mFilterText != filter) {
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
beginFilterChange();
mFilterText = filter;
endFilterChange();
#else
mFilterText = filter;
invalidateFilter();
#endif
emit filterTextChanged();
}
}
QSharedPointer<EventLogCore> EventLogProxy::getAt(int atIndex) const {
auto model = dynamic_cast<EventLogList *>(sourceModel());
if (model) {
return model->getAt<EventLogCore>(mapToSource(index(atIndex, 0)).row());
}
return nullptr;
}
void EventLogProxy::markIndexAsRead(int proxyIndex) { void EventLogProxy::markIndexAsRead(int proxyIndex) {
auto event = getItemAt<SortFilterList, EventLogList, EventLogCore>(proxyIndex); auto event = getAt(proxyIndex);
if (event && event->getChatMessageCore()) event->getChatMessageCore()->lMarkAsRead(); if (event && event->getChatMessageCore()) event->getChatMessageCore()->lMarkAsRead();
} }
void EventLogProxy::findIndexCorrespondingToFilter(int startIndex, bool forward, bool isFirstResearch) { void EventLogProxy::findIndexCorrespondingToFilter(int startIndex, bool forward, bool isFirstResearch) {
auto filter = getFilterText(); auto filter = getFilterText();
if (filter.isEmpty()) return; if (filter.isEmpty()) return;
auto eventLogList = getListModel<EventLogList>(); auto eventLogList = dynamic_cast<EventLogList *>(sourceModel());
if (eventLogList) { if (eventLogList) {
auto startEvent = mLastSearchStart; auto listIndex = mapToSource(index(startIndex, 0)).row();
if (!startEvent) { eventLogList->findChatMessageWithFilter(filter, listIndex, forward, isFirstResearch);
startEvent = getItemAt<SortFilterList, EventLogList, EventLogCore>(startIndex);
}
eventLogList->findChatMessageWithFilter(filter, startEvent, forward, isFirstResearch);
} }
} }
bool EventLogProxy::SortFilterList::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const {
auto l = getItemAtSource<EventLogList, EventLogCore>(sourceRow);
return l != nullptr;
}
bool EventLogProxy::SortFilterList::lessThan(const QModelIndex &sourceLeft, const QModelIndex &sourceRight) const {
auto l = getItemAtSource<EventLogList, EventLogCore>(sourceLeft.row());
auto r = getItemAtSource<EventLogList, EventLogCore>(sourceRight.row());
if (l && r) return l->getTimestamp() <= r->getTimestamp();
return true;
}

View file

@ -22,19 +22,26 @@
#define EVENT_LIST_PROXY_H_ #define EVENT_LIST_PROXY_H_
#include "EventLogList.hpp" #include "EventLogList.hpp"
#include "core/proxy/LimitProxy.hpp" // #include "core/proxy/LimitProxy.hpp"
#include "tool/AbstractObject.hpp" #include "tool/AbstractObject.hpp"
#include <QSortFilterProxyModel>
// ============================================================================= // =============================================================================
class ChatGui; class ChatGui;
class EventLogProxy : public LimitProxy, public AbstractObject { class EventLogProxy : public QSortFilterProxyModel, public AbstractObject {
Q_OBJECT Q_OBJECT
Q_PROPERTY(int count READ getCount NOTIFY countChanged)
Q_PROPERTY(ChatGui *chatGui READ getChatGui WRITE setChatGui NOTIFY chatGuiChanged) Q_PROPERTY(ChatGui *chatGui READ getChatGui WRITE setChatGui NOTIFY chatGuiChanged)
Q_PROPERTY(int initialDisplayItems READ getInitialDisplayItems WRITE setInitialDisplayItems NOTIFY
initialDisplayItemsChanged)
Q_PROPERTY(int maxDisplayItems READ getMaxDisplayItems WRITE setMaxDisplayItems NOTIFY maxDisplayItemsChanged)
Q_PROPERTY(int displayItemsStep READ getDisplayItemsStep WRITE setDisplayItemsStep NOTIFY displayItemsStepChanged)
Q_PROPERTY(QString filterText READ getFilterText WRITE setFilterText NOTIFY filterTextChanged)
public: public:
DECLARE_SORTFILTER_CLASS() // DECLARE_SORTFILTER_CLASS()
EventLogProxy(QObject *parent = Q_NULLPTR); EventLogProxy(QObject *parent = Q_NULLPTR);
~EventLogProxy(); ~EventLogProxy();
@ -43,8 +50,27 @@ public:
void setChatGui(ChatGui *chat); void setChatGui(ChatGui *chat);
void setSourceModel(QAbstractItemModel *sourceModel) override; void setSourceModel(QAbstractItemModel *sourceModel) override;
virtual int getCount() const;
static int getDisplayCount(int listCount, int maxCount);
int getDisplayCount(int listCount) const;
int getInitialDisplayItems() const;
void setInitialDisplayItems(int initialItems);
Q_INVOKABLE void displayMore() override; int getMaxDisplayItems() const;
void setMaxDisplayItems(int maxItems);
int getDisplayItemsStep() const;
void setDisplayItemsStep(int step);
QString getFilterText() const;
void setFilterText(const QString &filter);
// bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
// bool lessThan(const QModelIndex &sourceLeft, const QModelIndex &sourceRight) const override;
QSharedPointer<EventLogCore> getAt(int atIndex) const;
Q_INVOKABLE void displayMore();
Q_INVOKABLE void loadUntil(int index); Q_INVOKABLE void loadUntil(int index);
Q_INVOKABLE EventLogGui *getEventAtIndex(int i); Q_INVOKABLE EventLogGui *getEventAtIndex(int i);
QSharedPointer<EventLogCore> getEventCoreAtIndex(int i); QSharedPointer<EventLogCore> getEventCoreAtIndex(int i);
@ -53,15 +79,23 @@ public:
Q_INVOKABLE void findIndexCorrespondingToFilter(int startIndex, bool forward = true, bool isFirstResearch = true); Q_INVOKABLE void findIndexCorrespondingToFilter(int startIndex, bool forward = true, bool isFirstResearch = true);
signals: signals:
void eventInserted(int index, EventLogGui *message); void eventInsertedByUser(int index);
void indexWithFilterFound(int index); void indexWithFilterFound(int index);
void listAboutToBeReset();
void chatGuiChanged(); void chatGuiChanged();
void countChanged();
void initialDisplayItemsChanged();
void maxDisplayItemsChanged();
void displayItemsStepChanged();
void filterTextChanged();
protected: protected:
QSharedPointer<EventLogList> mList; QSharedPointer<EventLogList> mList;
QSharedPointer<EventLogCore> mLastSearchStart; QSharedPointer<EventLogCore> mLastSearchStart;
ChatGui *mChatGui = nullptr; ChatGui *mChatGui = nullptr;
int mInitialDisplayItems = -1;
int mMaxDisplayItems = -1;
int mDisplayItemsStep = 5;
QString mFilterText;
DECLARE_ABSTRACT_OBJECT DECLARE_ABSTRACT_OBJECT
}; };

View file

@ -46,7 +46,7 @@ ChatMessageContentCore::ChatMessageContentCore(const std::shared_ptr<linphone::C
mName = QFileInfo(fileName).baseName(); mName = QFileInfo(fileName).baseName();
} }
} }
mFilePath = Utils::coreStringToAppString(content->getFilePath()); mFilePath = QDir::fromNativeSeparators(Utils::coreStringToAppString(content->getFilePath()));
mIsFile = content->isFile(); mIsFile = content->isFile();
mIsFileEncrypted = content->isFileEncrypted(); mIsFileEncrypted = content->isFileEncrypted();
mIsFileTransfer = content->isFileTransfer(); mIsFileTransfer = content->isFileTransfer();
@ -67,8 +67,8 @@ ChatMessageContentCore::ChatMessageContentCore(const std::shared_ptr<linphone::C
mRichFormatText = ToolModel::encodeTextToQmlRichFormat(mUtf8Text, {}, chatRoom); mRichFormatText = ToolModel::encodeTextToQmlRichFormat(mUtf8Text, {}, chatRoom);
mWasDownloaded = !mFilePath.isEmpty() && QFileInfo(mFilePath).isFile(); mWasDownloaded = !mFilePath.isEmpty() && QFileInfo(mFilePath).isFile();
mThumbnail = mFilePath.isEmpty() mThumbnail = mFilePath.isEmpty()
? QString() ? QUrl()
: QStringLiteral("image://%1/%2").arg(ThumbnailProvider::ProviderId).arg(mFilePath); : QUrl(QString("image://%1/%2").arg(ThumbnailProvider::ProviderId).arg(mFilePath));
mChatMessageContentModel = Utils::makeQObject_ptr<ChatMessageContentModel>(content, chatMessageModel); mChatMessageContentModel = Utils::makeQObject_ptr<ChatMessageContentModel>(content, chatMessageModel);
} }
} }
@ -92,11 +92,22 @@ void ChatMessageContentCore::setSelf(QSharedPointer<ChatMessageContentCore> me)
}); });
mChatMessageContentModelConnection->makeConnectToModel( mChatMessageContentModelConnection->makeConnectToModel(
&ChatMessageContentModel::thumbnailChanged, [this, updateThumbnailType](QString thumbnail) { &ChatMessageContentModel::thumbnailChanged, [this, updateThumbnailType](QString thumbnail) {
mChatMessageContentModelConnection->invokeToCore([this, thumbnail] { setThumbnail(thumbnail); }); mChatMessageContentModelConnection->invokeToCore([this, thumbnail] { setThumbnail(QUrl(thumbnail)); });
}); });
mChatMessageContentModelConnection->makeConnectToCore(&ChatMessageContentCore::lDownloadFile, [this]() { mChatMessageContentModelConnection->makeConnectToCore(&ChatMessageContentCore::lDownloadFile, [this]() {
mChatMessageContentModelConnection->invokeToModel([this] { mChatMessageContentModel->downloadFile(mName); }); mChatMessageContentModelConnection->invokeToModel([this] {
QString *error = new QString();
bool downloaded = mChatMessageContentModel->downloadFile(mName, error);
if (!downloaded) {
mChatMessageContentModelConnection->invokeToCore([this, error] {
//: Error downloading file %1
if (error->isEmpty()) *error = tr("download_file_default_error").arg(mName);
Utils::showInformationPopup(tr("info_popup_error_titile"), *error, false);
delete error;
});
} else delete error;
});
}); });
mChatMessageContentModelConnection->makeConnectToModel( mChatMessageContentModelConnection->makeConnectToModel(
&ChatMessageContentModel::wasDownloadedChanged, &ChatMessageContentModel::wasDownloadedChanged,
@ -239,11 +250,11 @@ bool ChatMessageContentCore::wasDownloaded() const {
return mWasDownloaded; return mWasDownloaded;
} }
QString ChatMessageContentCore::getThumbnail() const { QUrl ChatMessageContentCore::getThumbnail() const {
return mThumbnail; return mThumbnail;
} }
void ChatMessageContentCore::setThumbnail(const QString &data) { void ChatMessageContentCore::setThumbnail(const QUrl &data) {
if (mThumbnail != data) { if (mThumbnail != data) {
mThumbnail = data; mThumbnail = data;
emit thumbnailChanged(); emit thumbnailChanged();

View file

@ -36,7 +36,7 @@ class ChatMessageContentCore : public QObject, public AbstractObject {
Q_PROPERTY(QString name READ getName CONSTANT) Q_PROPERTY(QString name READ getName CONSTANT)
Q_PROPERTY(quint64 fileOffset READ getFileOffset WRITE setFileOffset NOTIFY fileOffsetChanged) Q_PROPERTY(quint64 fileOffset READ getFileOffset WRITE setFileOffset NOTIFY fileOffsetChanged)
Q_PROPERTY(QString thumbnail READ getThumbnail WRITE setThumbnail NOTIFY thumbnailChanged) Q_PROPERTY(QUrl thumbnail READ getThumbnail WRITE setThumbnail NOTIFY thumbnailChanged)
Q_PROPERTY(bool wasDownloaded READ wasDownloaded WRITE setWasDownloaded NOTIFY wasDownloadedChanged) Q_PROPERTY(bool wasDownloaded READ wasDownloaded WRITE setWasDownloaded NOTIFY wasDownloadedChanged)
Q_PROPERTY(QString filePath READ getFilePath WRITE setFilePath NOTIFY filePathChanged) Q_PROPERTY(QString filePath READ getFilePath WRITE setFilePath NOTIFY filePathChanged)
Q_PROPERTY(QString utf8Text READ getUtf8Text CONSTANT) Q_PROPERTY(QString utf8Text READ getUtf8Text CONSTANT)
@ -84,8 +84,8 @@ public:
int getFileDuration() const; int getFileDuration() const;
ConferenceInfoGui *getConferenceInfoGui() const; ConferenceInfoGui *getConferenceInfoGui() const;
void setThumbnail(const QString &data); void setThumbnail(const QUrl &data);
QString getThumbnail() const; QUrl getThumbnail() const;
bool wasDownloaded() const; bool wasDownloaded() const;
void setWasDownloaded(bool downloaded); void setWasDownloaded(bool downloaded);
@ -121,7 +121,7 @@ private:
bool mIsText; bool mIsText;
bool mIsVoiceRecording; bool mIsVoiceRecording;
int mFileDuration; int mFileDuration;
QString mThumbnail; QUrl mThumbnail;
QString mUtf8Text; QString mUtf8Text;
QString mRichFormatText; QString mRichFormatText;
QString mFilePath; QString mFilePath;

View file

@ -197,7 +197,8 @@ void ChatMessageContentList::setSelf(QSharedPointer<ChatMessageContentList> me)
mModelConnection->makeConnectToCore(&ChatMessageContentList::lUpdate, [this]() { mModelConnection->makeConnectToCore(&ChatMessageContentList::lUpdate, [this]() {
for (auto &content : getSharedList<ChatMessageContentCore>()) { for (auto &content : getSharedList<ChatMessageContentCore>()) {
if (content) disconnect(content.get()); if (content) disconnect(content.get(), &ChatMessageContentCore::wasDownloadedChanged, this, nullptr);
if (content) disconnect(content.get(), &ChatMessageContentCore::thumbnailChanged, this, nullptr);
} }
if (!mChatMessageCore) return; if (!mChatMessageCore) return;
auto contents = mChatMessageCore->getChatMessageContentList(); auto contents = mChatMessageCore->getChatMessageContentList();

View file

@ -47,6 +47,7 @@ ConferenceCore::ConferenceCore(const std::shared_ptr<linphone::Conference> &conf
mIsLocalScreenSharing = mConferenceModel->isLocalScreenSharing(); mIsLocalScreenSharing = mConferenceModel->isLocalScreenSharing();
mIsScreenSharingEnabled = mConferenceModel->isScreenSharingEnabled(); mIsScreenSharingEnabled = mConferenceModel->isScreenSharingEnabled();
mIsRecording = conference->isRecording(); mIsRecording = conference->isRecording();
if (conference->getCurrentParams()) mIsChatEnabled = conference->getCurrentParams()->chatEnabled();
auto me = conference->getMe(); auto me = conference->getMe();
auto confAddress = conference->getConferenceAddress(); auto confAddress = conference->getConferenceAddress();
if (confAddress) { if (confAddress) {
@ -205,6 +206,10 @@ void ConferenceCore::setIsScreenSharingEnabled(bool state) {
} }
} }
bool ConferenceCore::isChatEnabled() const {
return mIsChatEnabled;
}
std::shared_ptr<ConferenceModel> ConferenceCore::getModel() const { std::shared_ptr<ConferenceModel> ConferenceCore::getModel() const {
return mConferenceModel; return mConferenceModel;
} }

View file

@ -37,6 +37,7 @@ class ConferenceCore : public QObject, public AbstractObject {
Q_OBJECT Q_OBJECT
public: public:
Q_PROPERTY(QDateTime startDate READ getStartDate CONSTANT) Q_PROPERTY(QDateTime startDate READ getStartDate CONSTANT)
Q_PROPERTY(bool isChatEnabled READ isChatEnabled CONSTANT)
// Q_PROPERTY(ParticipantDeviceList *participantDevices READ getParticipantDeviceList CONSTANT) // Q_PROPERTY(ParticipantDeviceList *participantDevices READ getParticipantDeviceList CONSTANT)
// Q_PROPERTY(ParticipantModel* localParticipant READ getLocalParticipant NOTIFY localParticipantChanged) // Q_PROPERTY(ParticipantModel* localParticipant READ getLocalParticipant NOTIFY localParticipantChanged)
Q_PROPERTY(bool isReady MEMBER mIsReady WRITE setIsReady NOTIFY isReadyChanged) Q_PROPERTY(bool isReady MEMBER mIsReady WRITE setIsReady NOTIFY isReadyChanged)
@ -81,6 +82,8 @@ public:
void setIsLocalScreenSharing(bool state); void setIsLocalScreenSharing(bool state);
void setIsScreenSharingEnabled(bool state); void setIsScreenSharingEnabled(bool state);
bool isChatEnabled() const;
std::shared_ptr<ConferenceModel> getModel() const; std::shared_ptr<ConferenceModel> getModel() const;
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -108,6 +111,7 @@ private:
bool mIsRecording = false; bool mIsRecording = false;
bool mIsLocalScreenSharing = false; bool mIsLocalScreenSharing = false;
bool mIsScreenSharingEnabled = false; bool mIsScreenSharingEnabled = false;
bool mIsChatEnabled = false;
QString mSubject; QString mSubject;
QString mConfUri; QString mConfUri;
QDateTime mStartDate = QDateTime::currentDateTime(); QDateTime mStartDate = QDateTime::currentDateTime();

View file

@ -195,8 +195,9 @@ void ConferenceInfoCore::setSelf(QSharedPointer<ConferenceInfoCore> me) {
QString uri; QString uri;
if (state == linphone::ConferenceScheduler::State::Ready) { if (state == linphone::ConferenceScheduler::State::Ready) {
uri = mConferenceInfoModel->getConferenceScheduler()->getUri(); uri = mConferenceInfoModel->getConferenceScheduler()->getUri();
emit CoreModel::getInstance()->conferenceInfoReceived( emit CoreModel::getInstance() -> conferenceInfoReceived(
CoreModel::getInstance()->getCore(), mConferenceInfoModel->getConferenceInfo()); CoreModel::getInstance()->getCore(),
mConferenceInfoModel->getConferenceInfo());
} }
mConfInfoModelConnection->invokeToCore([this, state = LinphoneEnums::fromLinphone(state), mConfInfoModelConnection->invokeToCore([this, state = LinphoneEnums::fromLinphone(state),
infoState = LinphoneEnums::fromLinphone(confInfoState), infoState = LinphoneEnums::fromLinphone(confInfoState),

View file

@ -235,13 +235,17 @@ int ConferenceInfoList::getCurrentDateIndex() {
return it == confInfoList.end() ? -1 : std::distance(confInfoList.begin(), it); return it == confInfoList.end() ? -1 : std::distance(confInfoList.begin(), it);
} }
QSharedPointer<ConferenceInfoCore> ConferenceInfoList::getCurrentDateConfInfo() { QSharedPointer<ConferenceInfoCore> ConferenceInfoList::getCurrentDateConfInfo(bool enableCancelledConference) {
auto today = QDate::currentDate(); auto today = QDate::currentDate();
auto confInfoList = getSharedList<ConferenceInfoCore>(); auto confInfoList = getSharedList<ConferenceInfoCore>();
QList<QSharedPointer<ConferenceInfoCore>>::iterator it; QList<QSharedPointer<ConferenceInfoCore>>::iterator it;
if (mHaveCurrentDate) { if (mHaveCurrentDate) {
it = std::find_if(confInfoList.begin(), confInfoList.end(), it = std::find_if(confInfoList.begin(), confInfoList.end(),
[today](const QSharedPointer<ConferenceInfoCore> &item) { [today, enableCancelledConference](const QSharedPointer<ConferenceInfoCore> &item) {
if (!item) return false;
if (!enableCancelledConference &&
item->getConferenceInfoState() == LinphoneEnums::ConferenceInfoState::Cancelled)
return false;
return item && item->getDateTimeUtc().date() == today; return item && item->getDateTimeUtc().date() == today;
}); });
} else it = std::find(confInfoList.begin(), confInfoList.end(), nullptr); } else it = std::find(confInfoList.begin(), confInfoList.end(), nullptr);

View file

@ -48,7 +48,7 @@ public:
void updateHaveCurrentDate(); void updateHaveCurrentDate();
int getCurrentDateIndex(); int getCurrentDateIndex();
QSharedPointer<ConferenceInfoCore> getCurrentDateConfInfo(); QSharedPointer<ConferenceInfoCore> getCurrentDateConfInfo(bool enableCancelledConference = false);
QSharedPointer<ConferenceInfoCore> build(const std::shared_ptr<linphone::ConferenceInfo> &conferenceInfo); QSharedPointer<ConferenceInfoCore> build(const std::shared_ptr<linphone::ConferenceInfo> &conferenceInfo);
void connectItem(QSharedPointer<ConferenceInfoCore> confInfoCore); void connectItem(QSharedPointer<ConferenceInfoCore> confInfoCore);

View file

@ -105,7 +105,7 @@ void ConferenceInfoProxy::clear() {
mList->clearData(); mList->clearData();
} }
ConferenceInfoGui *ConferenceInfoProxy::getCurrentDateConfInfo() { ConferenceInfoGui *ConferenceInfoProxy::getCurrentDateConfInfo(bool enableCancelledConference) {
if (mList) { if (mList) {
auto confInfo = mList->getCurrentDateConfInfo(); auto confInfo = mList->getCurrentDateConfInfo();
return confInfo ? new ConferenceInfoGui(confInfo) : nullptr; return confInfo ? new ConferenceInfoGui(confInfo) : nullptr;
@ -150,7 +150,7 @@ bool ConferenceInfoProxy::SortFilterList::lessThan(const QModelIndex &sourceLeft
auto nowDate = QDate::currentDate(); auto nowDate = QDate::currentDate();
if (!l || !r) { // sort on date if (!l || !r) { // sort on date
auto rdate = r ? r->getDateTimeUtc().date() : QDate::currentDate(); auto rdate = r ? r->getDateTimeUtc().date() : QDate::currentDate();
return !l ? nowDate <= r->getDateTimeUtc().date() : l->getDateTimeUtc().date() < nowDate; return !l ? nowDate < r->getDateTimeUtc().date() : l->getDateTimeUtc().date() < nowDate;
} else { } else {
return l->getDateTimeUtc() < r->getDateTimeUtc(); return l->getDateTimeUtc() < r->getDateTimeUtc();
} }

View file

@ -47,7 +47,7 @@ public:
bool getAccountConnected() const; bool getAccountConnected() const;
Q_INVOKABLE void clear(); Q_INVOKABLE void clear();
Q_INVOKABLE ConferenceInfoGui *getCurrentDateConfInfo(); Q_INVOKABLE ConferenceInfoGui *getCurrentDateConfInfo(bool enableCancelledConference = false);
Q_INVOKABLE int loadUntil(ConferenceInfoGui *confInfo); Q_INVOKABLE int loadUntil(ConferenceInfoGui *confInfo);
int loadUntil(QSharedPointer<ConferenceInfoCore> data); int loadUntil(QSharedPointer<ConferenceInfoCore> data);
signals: signals:

View file

@ -130,7 +130,7 @@ Notifier::~Notifier() {
bool Notifier::createNotification(Notifier::NotificationType type, QVariantMap data) { bool Notifier::createNotification(Notifier::NotificationType type, QVariantMap data) {
mMutex->lock(); mMutex->lock();
// Q_ASSERT(mInstancesNumber <= MaxNotificationsNumber); // Q_ASSERT(mInstancesNumber <= MaxNotificationsNumber);
if (mInstancesNumber == MaxNotificationsNumber) { // Check existing instances. if (mInstancesNumber >= MaxNotificationsNumber) { // Check existing instances.
qWarning() << QStringLiteral("Unable to create another notification."); qWarning() << QStringLiteral("Unable to create another notification.");
mMutex->unlock(); mMutex->unlock();
return false; return false;
@ -288,9 +288,6 @@ void Notifier::notifyReceivedCall(const shared_ptr<linphone::Call> &call) {
auto voicemailAddress = linphone::Factory::get()->createAddress( auto voicemailAddress = linphone::Factory::get()->createAddress(
Utils::appStringToCoreString(accountModel->getVoicemailAddress())); Utils::appStringToCoreString(accountModel->getVoicemailAddress()));
if (voicemailAddress) call->transferTo(voicemailAddress); if (voicemailAddress) call->transferTo(voicemailAddress);
} else {
lInfo() << log().arg("Declining call.");
call->decline(linphone::Reason::Busy);
} }
return; return;
} }
@ -335,7 +332,8 @@ void Notifier::notifyReceivedMessages(const std::shared_ptr<linphone::ChatRoom>
if (receiverAccount) { if (receiverAccount) {
auto senderAccount = ToolModel::findAccount(message->getFromAddress()); auto senderAccount = ToolModel::findAccount(message->getFromAddress());
auto currentAccount = CoreModel::getInstance()->getCore()->getDefaultAccount(); auto currentAccount = CoreModel::getInstance()->getCore()->getDefaultAccount();
if (senderAccount && senderAccount->getContactAddress()->weakEqual(currentAccount->getContactAddress())) { if (senderAccount && senderAccount->getContactAddress() && currentAccount->getContactAddress() &&
senderAccount->getContactAddress()->weakEqual(currentAccount->getContactAddress())) {
qDebug() << "sender is current account, return"; qDebug() << "sender is current account, return";
return; return;
} }
@ -369,6 +367,7 @@ void Notifier::notifyReceivedMessages(const std::shared_ptr<linphone::ChatRoom>
}; };
if (messages.size() == 1) { // Display only sender on mono message. if (messages.size() == 1) { // Display only sender on mono message.
if (message->isRead()) return;
getMessage(message); getMessage(message);
if (txt.isEmpty()) { // Do not notify message without content if (txt.isEmpty()) { // Do not notify message without content
qDebug() << "empty notif, return"; qDebug() << "empty notif, return";

View file

@ -48,7 +48,7 @@ ParticipantInfoList::~ParticipantInfoList() {
void ParticipantInfoList::setChatCore(const QSharedPointer<ChatCore> &chatCore) { void ParticipantInfoList::setChatCore(const QSharedPointer<ChatCore> &chatCore) {
mustBeInMainThread(log().arg(Q_FUNC_INFO)); mustBeInMainThread(log().arg(Q_FUNC_INFO));
if (mChatCore) disconnect(mChatCore.get()); if (mChatCore) disconnect(mChatCore.get(), &ChatCore::participantsChanged, this, nullptr);
mChatCore = chatCore; mChatCore = chatCore;
lDebug() << "[ParticipantInfoList] : set Chat " << mChatCore.get(); lDebug() << "[ParticipantInfoList] : set Chat " << mChatCore.get();
clearData(); clearData();

View file

@ -109,7 +109,7 @@ void ParticipantProxy::setShowMe(const bool &show) {
if (list->mShowMe != show) { if (list->mShowMe != show) {
list->mShowMe = show; list->mShowMe = show;
emit showMeChanged(); emit showMeChanged();
invalidateFilter(); invalidate();
} }
} }

View file

@ -68,8 +68,8 @@ void LimitProxy::setSourceModels(SortFilterProxy *firstList) {
/* /*
void LimitProxy::setSourceModels(SortFilterProxy *firstList, QAbstractItemModel *secondList) { void LimitProxy::setSourceModels(SortFilterProxy *firstList, QAbstractItemModel *secondList) {
connect(secondList, &QAbstractItemModel::rowsInserted, this, &LimitProxy::invalidateFilter); connect(secondList, &QAbstractItemModel::rowsInserted, this, &LimitProxy::invalidate);
connect(secondList, &QAbstractItemModel::rowsRemoved, this, &LimitProxy::invalidateFilter); connect(secondList, &QAbstractItemModel::rowsRemoved, this, &LimitProxy::invalidate);
connect(firstList, &SortFilterProxy::filterTextChanged, this, &LimitProxy::filterTextChanged); connect(firstList, &SortFilterProxy::filterTextChanged, this, &LimitProxy::filterTextChanged);
setSourceModel(firstList); setSourceModel(firstList);
}*/ }*/
@ -127,7 +127,7 @@ void LimitProxy::setMaxDisplayItems(int maxItems) {
emit maxDisplayItemsChanged(); emit maxDisplayItemsChanged();
if (model && getDisplayCount(modelCount) != oldCount) { if (model && getDisplayCount(modelCount) != oldCount) {
invalidateFilter(); invalidate();
} }
} }
} }
@ -186,6 +186,6 @@ void LimitProxy::onAdded() {
void LimitProxy::onRemoved() { void LimitProxy::onRemoved() {
int count = sourceModel()->rowCount(); int count = sourceModel()->rowCount();
if (mMaxDisplayItems > 0 && mMaxDisplayItems <= count) { if (mMaxDisplayItems > 0 && mMaxDisplayItems <= count) {
invalidateFilter(); invalidate();
} }
} }

View file

@ -26,6 +26,9 @@ SortFilterProxy::SortFilterProxy(QAbstractItemModel *list) : QSortFilterProxyMod
setSourceModel(list); setSourceModel(list);
} }
SortFilterProxy::SortFilterProxy() {
}
SortFilterProxy::SortFilterProxy(QAbstractItemModel *list, Qt::SortOrder order) : SortFilterProxy(list) { SortFilterProxy::SortFilterProxy(QAbstractItemModel *list, Qt::SortOrder order) : SortFilterProxy(list) {
sort(0, order); sort(0, order);
} }
@ -63,9 +66,15 @@ int SortFilterProxy::getFilterType() const {
void SortFilterProxy::setFilterType(int filterType) { void SortFilterProxy::setFilterType(int filterType) {
if (getFilterType() != filterType) { if (getFilterType() != filterType) {
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
beginFilterChange();
mFilterType = filterType; mFilterType = filterType;
endFilterChange();
#else
mFilterType = filterType;
invalidateFilter();
#endif
emit filterTypeChanged(filterType); emit filterTypeChanged(filterType);
invalidate();
} }
} }
@ -75,13 +84,13 @@ QString SortFilterProxy::getFilterText() const {
void SortFilterProxy::setFilterText(const QString &filter) { void SortFilterProxy::setFilterText(const QString &filter) {
if (mFilterText != filter) { if (mFilterText != filter) {
#if QT_VERSION < QT_VERSION_CHECK(6, 10, 0) #if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
beginFilterChange();
mFilterText = filter; mFilterText = filter;
QSortFilterProxyModel::invalidateFilter(); endFilterChange();
#else #else
QSortFilterProxyModel::beginFilterChange();
mFilterText = filter; mFilterText = filter;
QSortFilterProxyModel::endFilterChange(); invalidateFilter();
#endif #endif
emit filterTextChanged(); emit filterTextChanged();
} }
@ -96,11 +105,10 @@ void SortFilterProxy::remove(int index, int count) {
} }
void SortFilterProxy::invalidateFilter() { void SortFilterProxy::invalidateFilter() {
// TODO for a better filter management by encapsulating filter change between begin/end #if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
#if QT_VERSION < QT_VERSION_CHECK(6, 10, 0)
QSortFilterProxyModel::invalidateFilter();
#else
QSortFilterProxyModel::beginFilterChange(); QSortFilterProxyModel::beginFilterChange();
QSortFilterProxyModel::endFilterChange(); QSortFilterProxyModel::endFilterChange();
#else
invalidateFilter();
#endif #endif
} }

View file

@ -41,6 +41,7 @@ public:
Q_PROPERTY(int filterType READ getFilterType WRITE setFilterType NOTIFY filterTypeChanged) Q_PROPERTY(int filterType READ getFilterType WRITE setFilterType NOTIFY filterTypeChanged)
Q_PROPERTY(QString filterText READ getFilterText WRITE setFilterText NOTIFY filterTextChanged) Q_PROPERTY(QString filterText READ getFilterText WRITE setFilterText NOTIFY filterTextChanged)
SortFilterProxy();
SortFilterProxy(QAbstractItemModel *parent); SortFilterProxy(QAbstractItemModel *parent);
SortFilterProxy(QAbstractItemModel *parent, Qt::SortOrder order); SortFilterProxy(QAbstractItemModel *parent, Qt::SortOrder order);
virtual ~SortFilterProxy(); virtual ~SortFilterProxy();

View file

@ -94,18 +94,29 @@ void MagicSearchList::setSelf(QSharedPointer<MagicSearchList> me) {
[this](const std::list<std::shared_ptr<linphone::SearchResult>> &results) { [this](const std::list<std::shared_ptr<linphone::SearchResult>> &results) {
auto *contacts = new QList<QSharedPointer<FriendCore>>(); auto *contacts = new QList<QSharedPointer<FriendCore>>();
auto ldapContacts = ToolModel::getLdapFriendList(); auto ldapContacts = ToolModel::getLdapFriendList();
auto core = CoreModel::getInstance()->getCore();
auto userAddress = core->getDefaultAccount() && core->getDefaultAccount()->getParams()
? core->getDefaultAccount()->getParams()->getIdentityAddress()
: nullptr;
for (auto it : results) { for (auto it : results) {
QSharedPointer<FriendCore> contact; QSharedPointer<FriendCore> contact;
auto linphoneFriend = it->getFriend(); auto linphoneFriend = it->getFriend();
bool isStored = false; bool isStored = false;
if (linphoneFriend) { if (linphoneFriend) {
if (!mShowMe && userAddress && userAddress->weakEqual(linphoneFriend->getAddress())) {
lWarning() << log().arg("do not show my own address in this contact list");
continue;
}
isStored = isStored =
(ldapContacts->findFriendByAddress(linphoneFriend->getAddress()) != linphoneFriend); (ldapContacts->findFriendByAddress(linphoneFriend->getAddress()) != linphoneFriend);
contact = FriendCore::create(linphoneFriend, isStored, it->getSourceFlags()); contact = FriendCore::create(linphoneFriend, isStored, it->getSourceFlags());
contacts->append(contact); contacts->append(contact);
} else if (auto address = it->getAddress()) { } else if (auto address = it->getAddress()) {
auto linphoneFriend = CoreModel::getInstance()->getCore()->createFriend(); if (!mShowMe && userAddress && userAddress->weakEqual(address)) {
lWarning() << log().arg("do not show my own address in this contact list");
continue;
}
auto linphoneFriend = core->createFriend();
linphoneFriend->setAddress(address); linphoneFriend->setAddress(address);
contact = FriendCore::create(linphoneFriend, isStored, it->getSourceFlags()); contact = FriendCore::create(linphoneFriend, isStored, it->getSourceFlags());
auto displayName = Utils::coreStringToAppString(address->getDisplayName()); auto displayName = Utils::coreStringToAppString(address->getDisplayName());
@ -125,7 +136,7 @@ void MagicSearchList::setSelf(QSharedPointer<MagicSearchList> me) {
contacts->append(contact); contacts->append(contact);
} else if (!it->getPhoneNumber().empty()) { } else if (!it->getPhoneNumber().empty()) {
auto phoneNumber = it->getPhoneNumber(); auto phoneNumber = it->getPhoneNumber();
linphoneFriend = CoreModel::getInstance()->getCore()->createFriend(); linphoneFriend = core->createFriend();
linphoneFriend->addPhoneNumber(phoneNumber); linphoneFriend->addPhoneNumber(phoneNumber);
contact = FriendCore::create(linphoneFriend, isStored, it->getSourceFlags()); contact = FriendCore::create(linphoneFriend, isStored, it->getSourceFlags());
contact->setGivenName(Utils::coreStringToAppString(it->getPhoneNumber())); contact->setGivenName(Utils::coreStringToAppString(it->getPhoneNumber()));
@ -202,6 +213,17 @@ void MagicSearchList::setMaxResults(int maxResults) {
} }
} }
bool MagicSearchList::getShowMe() const {
return mShowMe;
}
void MagicSearchList::setShowMe(bool showMe) {
if (mShowMe != showMe) {
mShowMe = showMe;
emit showMeChanged(mShowMe);
}
}
LinphoneEnums::MagicSearchAggregation MagicSearchList::getAggregationFlag() const { LinphoneEnums::MagicSearchAggregation MagicSearchList::getAggregationFlag() const {
return mAggregationFlag; return mAggregationFlag;
} }

View file

@ -41,7 +41,7 @@ public:
~MagicSearchList(); ~MagicSearchList();
void setSelf(QSharedPointer<MagicSearchList> me); void setSelf(QSharedPointer<MagicSearchList> me);
void connectContact(FriendCore* data); void connectContact(FriendCore *data);
void setSearch(const QString &search); void setSearch(const QString &search);
void setResults(const QList<QSharedPointer<FriendCore>> &contacts); void setResults(const QList<QSharedPointer<FriendCore>> &contacts);
void add(QSharedPointer<FriendCore> contact); void add(QSharedPointer<FriendCore> contact);
@ -55,6 +55,9 @@ public:
int getMaxResults() const; int getMaxResults() const;
void setMaxResults(int maxResults); void setMaxResults(int maxResults);
bool getShowMe() const;
void setShowMe(bool showMe);
virtual QHash<int, QByteArray> roleNames() const override; virtual QHash<int, QByteArray> roleNames() const override;
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
@ -68,6 +71,7 @@ signals:
void sourceFlagsChanged(int sourceFlags); void sourceFlagsChanged(int sourceFlags);
void aggregationFlagChanged(LinphoneEnums::MagicSearchAggregation flag); void aggregationFlagChanged(LinphoneEnums::MagicSearchAggregation flag);
void maxResultsChanged(int maxResults); void maxResultsChanged(int maxResults);
void showMeChanged(bool showMe);
void friendCreated(int index, FriendGui *data); void friendCreated(int index, FriendGui *data);
void friendStarredChanged(); void friendStarredChanged();
@ -81,6 +85,7 @@ private:
LinphoneEnums::MagicSearchAggregation mAggregationFlag; LinphoneEnums::MagicSearchAggregation mAggregationFlag;
QString mSearchFilter; QString mSearchFilter;
int mMaxResults = -1; int mMaxResults = -1;
bool mShowMe = false;
std::shared_ptr<MagicSearchModel> mMagicSearch; std::shared_ptr<MagicSearchModel> mMagicSearch;
QSharedPointer<SafeConnection<MagicSearchList, MagicSearchModel>> mModelConnection; QSharedPointer<SafeConnection<MagicSearchList, MagicSearchModel>> mModelConnection;

View file

@ -148,6 +148,14 @@ void MagicSearchProxy::setMaxResults(int flags) {
mList->setMaxResults(flags); mList->setMaxResults(flags);
} }
bool MagicSearchProxy::getShowMe() const {
return mList->getShowMe();
}
void MagicSearchProxy::setShowMe(bool showMe) {
mList->setShowMe(showMe);
}
MagicSearchProxy *MagicSearchProxy::getParentProxy() const { MagicSearchProxy *MagicSearchProxy::getParentProxy() const {
return mParentProxy; return mParentProxy;
} }

View file

@ -34,6 +34,7 @@ class MagicSearchProxy : public LimitProxy {
Q_PROPERTY(int sourceFlags READ getSourceFlags WRITE setSourceFlags NOTIFY sourceFlagsChanged) Q_PROPERTY(int sourceFlags READ getSourceFlags WRITE setSourceFlags NOTIFY sourceFlagsChanged)
Q_PROPERTY(int maxResults READ getMaxResults WRITE setMaxResults NOTIFY maxResultsChanged) Q_PROPERTY(int maxResults READ getMaxResults WRITE setMaxResults NOTIFY maxResultsChanged)
Q_PROPERTY(bool showMe READ getShowMe WRITE setShowMe NOTIFY showMeChanged)
Q_PROPERTY(LinphoneEnums::MagicSearchAggregation aggregationFlag READ getAggregationFlag WRITE setAggregationFlag Q_PROPERTY(LinphoneEnums::MagicSearchAggregation aggregationFlag READ getAggregationFlag WRITE setAggregationFlag
NOTIFY aggregationFlagChanged) NOTIFY aggregationFlagChanged)
@ -60,6 +61,9 @@ public:
int getMaxResults() const; int getMaxResults() const;
void setMaxResults(int maxResults); void setMaxResults(int maxResults);
bool getShowMe() const;
void setShowMe(bool showMe);
MagicSearchProxy *getParentProxy() const; MagicSearchProxy *getParentProxy() const;
void setList(QSharedPointer<MagicSearchList> list); void setList(QSharedPointer<MagicSearchList> list);
Q_INVOKABLE void setParentProxy(MagicSearchProxy *proxy); Q_INVOKABLE void setParentProxy(MagicSearchProxy *proxy);
@ -77,6 +81,7 @@ signals:
void sourceFlagsChanged(int sourceFlags); void sourceFlagsChanged(int sourceFlags);
void aggregationFlagChanged(LinphoneEnums::MagicSearchAggregation aggregationFlag); void aggregationFlagChanged(LinphoneEnums::MagicSearchAggregation aggregationFlag);
void maxResultsChanged(int maxResults); void maxResultsChanged(int maxResults);
void showMeChanged(bool showMe);
void forceUpdate(); void forceUpdate();
void localFriendCreated(int index); void localFriendCreated(int index);
void parentProxyChanged(); void parentProxyChanged();

View file

@ -107,6 +107,9 @@ SettingsCore::SettingsCore(QObject *parent) : QObject(parent) {
mEmojiFont = settingsModel->getEmojiFont(); mEmojiFont = settingsModel->getEmojiFont();
mTextMessageFont = settingsModel->getTextMessageFont(); mTextMessageFont = settingsModel->getTextMessageFont();
// Check for update
mIsCheckForUpdateAvailable = settingsModel->isCheckForUpdateAvailable();
// Ui // Ui
INIT_CORE_MEMBER(DisableChatFeature, settingsModel) INIT_CORE_MEMBER(DisableChatFeature, settingsModel)
INIT_CORE_MEMBER(DisableMeetingsFeature, settingsModel) INIT_CORE_MEMBER(DisableMeetingsFeature, settingsModel)
@ -234,6 +237,13 @@ void SettingsCore::setSelf(QSharedPointer<SettingsCore> me) {
mustBeInLinphoneThread(getClassName()); mustBeInLinphoneThread(getClassName());
mSettingsModelConnection = SafeConnection<SettingsCore, SettingsModel>::create(me, SettingsModel::getInstance()); mSettingsModelConnection = SafeConnection<SettingsCore, SettingsModel>::create(me, SettingsModel::getInstance());
mSettingsModelConnection->makeConnectToModel(&SettingsModel::captureGraphRunningChanged, [this](bool running) {
mSettingsModelConnection->invokeToCore([this, running] {
mCaptureGraphRunning = running;
emit captureGraphRunningChanged(running);
});
});
// VFS // VFS
mSettingsModelConnection->makeConnectToModel(&SettingsModel::vfsEnabledChanged, [this](const bool enabled) { mSettingsModelConnection->makeConnectToModel(&SettingsModel::vfsEnabledChanged, [this](const bool enabled) {
mSettingsModelConnection->invokeToCore([this, enabled]() { setVfsEnabled(enabled); }); mSettingsModelConnection->invokeToCore([this, enabled]() { setVfsEnabled(enabled); });
@ -1028,7 +1038,8 @@ QString SettingsCore::getConfigLocale() const {
QString SettingsCore::getDownloadFolder() const { QString SettingsCore::getDownloadFolder() const {
auto path = mDownloadFolder; auto path = mDownloadFolder;
if (mDownloadFolder.isEmpty()) path = Paths::getDownloadDirPath(); if (mDownloadFolder.isEmpty()) path = Paths::getDownloadDirPath();
return QDir::cleanPath(path) + QDir::separator(); QString cleanPath = QDir::cleanPath(path);
return cleanPath;
} }
void SettingsCore::writeIntoModel(std::shared_ptr<SettingsModel> model) const { void SettingsCore::writeIntoModel(std::shared_ptr<SettingsModel> model) const {
@ -1143,6 +1154,9 @@ void SettingsCore::writeFromModel(const std::shared_ptr<SettingsModel> &model) {
mLogsFolder = model->getLogsFolder(); mLogsFolder = model->getLogsFolder();
mLogsEmail = model->getLogsEmail(); mLogsEmail = model->getLogsEmail();
// Check update
mIsCheckForUpdateAvailable = model->isCheckForUpdateAvailable();
// UI // UI
mDisableChatFeature = model->getDisableChatFeature(); mDisableChatFeature = model->getDisableChatFeature();
mDisableMeetingsFeature = model->getDisableMeetingsFeature(); mDisableMeetingsFeature = model->getDisableMeetingsFeature();
@ -1171,6 +1185,10 @@ void SettingsCore::writeFromModel(const std::shared_ptr<SettingsModel> &model) {
mDownloadFolder = model->getDownloadFolder(); mDownloadFolder = model->getDownloadFolder();
} }
bool SettingsCore::isCheckForUpdateAvailable() const {
return mIsCheckForUpdateAvailable;
}
void SettingsCore::save() { void SettingsCore::save() {
mustBeInMainThread(getClassName() + Q_FUNC_INFO); mustBeInMainThread(getClassName() + Q_FUNC_INFO);
SettingsCore *thisCopy = new SettingsCore(*this); SettingsCore *thisCopy = new SettingsCore(*this);

View file

@ -218,6 +218,7 @@ public:
bool getCardDAVMinCharForResearch() const; bool getCardDAVMinCharForResearch() const;
void setCardDAVMinCharForResearch(int min); void setCardDAVMinCharForResearch(int min);
bool isCheckForUpdateAvailable() const;
Q_INVOKABLE void save(); Q_INVOKABLE void save();
Q_INVOKABLE void undo(); Q_INVOKABLE void undo();
@ -401,6 +402,9 @@ private:
// CardDAV // CardDAV
int mCardDAVMinCharForResearch = 0; int mCardDAVMinCharForResearch = 0;
// Check update
bool mIsCheckForUpdateAvailable = false;
DECLARE_ABSTRACT_OBJECT DECLARE_ABSTRACT_OBJECT
}; };
#endif #endif

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -19,6 +19,7 @@
*/ */
#include "AccountManager.hpp" #include "AccountManager.hpp"
#include "tool/accessibility/AccessibilityHelper.hpp"
#include <QDebug> #include <QDebug>
#include <QDesktopServices> #include <QDesktopServices>
@ -66,7 +67,7 @@ bool AccountManager::login(QString username,
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
auto core = CoreModel::getInstance()->getCore(); auto core = CoreModel::getInstance()->getCore();
auto factory = linphone::Factory::get(); auto factory = linphone::Factory::get();
QString assistantFile = (!QString::compare(domain, "sip.linphone.org") || domain.isEmpty()) QString assistantFile = (!QString::compare(domain, "sip.linphone.org", Qt::CaseInsensitive) || domain.isEmpty())
? "use-app-sip-account.rc" ? "use-app-sip-account.rc"
: "use-other-sip-account.rc"; : "use-other-sip-account.rc";
auto account = createAccount(assistantFile); auto account = createAccount(assistantFile);
@ -81,8 +82,13 @@ bool AccountManager::login(QString username,
auto otherAccounts = core->getAccountList(); auto otherAccounts = core->getAccountList();
for (auto otherAccount : otherAccounts) { for (auto otherAccount : otherAccounts) {
auto otherParams = otherAccount->getParams(); auto otherParams = otherAccount->getParams();
if (otherParams->getIdentityAddress()->getUsername() == Utils::appStringToCoreString(username) && if (domain.isEmpty()) {
otherParams->getDomain() == Utils::appStringToCoreString(domain)) { lDebug() << "domain is empty, setting \"sip.linphone.org\" by default";
domain = "sip.linphone.org";
}
if (!QString::compare(Utils::coreStringToAppString(otherParams->getIdentityAddress()->getUsername()), username,
Qt::CaseInsensitive) &&
!QString::compare(Utils::coreStringToAppString(otherParams->getDomain()), domain, Qt::CaseInsensitive)) {
//: "The account is already connected" //: "The account is already connected"
*errorMessage = tr("assistant_account_login_already_connected_error"); *errorMessage = tr("assistant_account_login_already_connected_error");
return false; return false;
@ -153,6 +159,7 @@ bool AccountManager::login(QString username,
errorMessage = tr("assistant_account_login_forbidden_error"); errorMessage = tr("assistant_account_login_forbidden_error");
//: "Error during connection, please verify your parameters" //: "Error during connection, please verify your parameters"
else errorMessage = tr("assistant_account_login_error"); else errorMessage = tr("assistant_account_login_error");
AccessibilityHelper::announceMessage(errorMessage);
mAccountModel->removeAccount(); mAccountModel->removeAccount();
} else if (state == linphone::RegistrationState::Ok) { } else if (state == linphone::RegistrationState::Ok) {
core->setDefaultAccount(account); core->setDefaultAccount(account);

View file

@ -125,7 +125,7 @@ void AccountModel::setPictureUri(QString uri) {
// Hack because Account doesn't provide callbacks on updated data // Hack because Account doesn't provide callbacks on updated data
// emit pictureUriChanged(uri); // emit pictureUriChanged(uri);
auto core = CoreModel::getInstance()->getCore(); auto core = CoreModel::getInstance()->getCore();
emit CoreModel::getInstance()->defaultAccountChanged(core, core->getDefaultAccount()); emit CoreModel::getInstance() -> defaultAccountChanged(core, core->getDefaultAccount());
} }
void AccountModel::onDefaultAccountChanged() { void AccountModel::onDefaultAccountChanged() {
@ -182,7 +182,7 @@ void AccountModel::setDisplayName(QString displayName) {
// Hack because Account doesn't provide callbacks on updated data // Hack because Account doesn't provide callbacks on updated data
// emit displayNameChanged(displayName); // emit displayNameChanged(displayName);
auto core = CoreModel::getInstance()->getCore(); auto core = CoreModel::getInstance()->getCore();
emit CoreModel::getInstance()->defaultAccountChanged(core, core->getDefaultAccount()); emit CoreModel::getInstance() -> defaultAccountChanged(core, core->getDefaultAccount());
} }
void AccountModel::setDialPlan(int index) { void AccountModel::setDialPlan(int index) {
@ -274,7 +274,7 @@ void AccountModel::setTransport(linphone::TransportType value, bool save) {
QString AccountModel::getRegistrarUri() const { QString AccountModel::getRegistrarUri() const {
if (mMonitor->getParams()->getServerAddress()) if (mMonitor->getParams()->getServerAddress())
return Utils::coreStringToAppString(mMonitor->getParams()->getServerAddress()->asString()); return Utils::coreStringToAppString(mMonitor->getParams()->getServerAddress()->asStringUriOnly());
else return ""; else return "";
} }
@ -292,13 +292,12 @@ void AccountModel::setRegistrarUri(QString value) {
emit setValueFailed(tr("set_server_address_failed_error_message").arg(value)); emit setValueFailed(tr("set_server_address_failed_error_message").arg(value));
qWarning() << "Unable to set ServerAddress, failed creating address from" << value; qWarning() << "Unable to set ServerAddress, failed creating address from" << value;
} }
emit registrarUriChanged(Utils::coreStringToAppString(address->asString()));
} }
QString AccountModel::getOutboundProxyUri() const { QString AccountModel::getOutboundProxyUri() const {
auto routeAddresses = mMonitor->getParams()->getRoutesAddresses(); auto routeAddresses = mMonitor->getParams()->getRoutesAddresses();
auto outbound = auto outbound =
routeAddresses.empty() ? QString() : Utils::coreStringToAppString(routeAddresses.front()->asString()); routeAddresses.empty() ? QString() : Utils::coreStringToAppString(routeAddresses.front()->asStringUriOnly());
return outbound; return outbound;
} }
@ -308,11 +307,11 @@ void AccountModel::setOutboundProxyUri(QString value) {
//: Unable to set outbound proxy uri, failed creating address from %1 //: Unable to set outbound proxy uri, failed creating address from %1
emit setValueFailed(tr("set_outbound_proxy_uri_failed_error_message").arg(value)); emit setValueFailed(tr("set_outbound_proxy_uri_failed_error_message").arg(value));
return; return;
} } else {
auto params = mMonitor->getParams()->clone(); auto params = mMonitor->getParams()->clone();
params->setRoutesAddresses({linOutboundProxyAddress}); params->setRoutesAddresses({linOutboundProxyAddress});
emit outboundProxyUriChanged(value); emit outboundProxyUriChanged(value);
}
} }
bool AccountModel::getOutboundProxyEnabled() const { bool AccountModel::getOutboundProxyEnabled() const {
@ -400,7 +399,7 @@ void AccountModel::setExpire(int value) {
QString AccountModel::getConferenceFactoryAddress() const { QString AccountModel::getConferenceFactoryAddress() const {
auto confAddress = mMonitor->getParams()->getConferenceFactoryAddress(); auto confAddress = mMonitor->getParams()->getConferenceFactoryAddress();
return confAddress ? Utils::coreStringToAppString(confAddress->asString()) : QString(); return confAddress ? Utils::coreStringToAppString(confAddress->asStringUriOnly()) : QString();
} }
void AccountModel::setConferenceFactoryAddress(QString value) { void AccountModel::setConferenceFactoryAddress(QString value) {
@ -422,7 +421,7 @@ void AccountModel::setConferenceFactoryAddress(QString value) {
QString AccountModel::getAudioVideoConferenceFactoryAddress() const { QString AccountModel::getAudioVideoConferenceFactoryAddress() const {
auto confAddress = mMonitor->getParams()->getAudioVideoConferenceFactoryAddress(); auto confAddress = mMonitor->getParams()->getAudioVideoConferenceFactoryAddress();
return confAddress ? Utils::coreStringToAppString(confAddress->asString()) : QString(); return confAddress ? Utils::coreStringToAppString(confAddress->asStringUriOnly()) : QString();
} }
void AccountModel::setAudioVideoConferenceFactoryAddress(QString value) { void AccountModel::setAudioVideoConferenceFactoryAddress(QString value) {
@ -491,7 +490,7 @@ void AccountModel::setVoicemailAddress(QString value) {
QString AccountModel::getVoicemailAddress() const { QString AccountModel::getVoicemailAddress() const {
auto addr = mMonitor->getParams()->getVoicemailAddress(); auto addr = mMonitor->getParams()->getVoicemailAddress();
return addr ? Utils::coreStringToAppString(addr->asString()) : ""; return addr ? Utils::coreStringToAppString(addr->asStringUriOnly()) : "";
} }
// UserData (see hpp for explanations) // UserData (see hpp for explanations)
@ -585,7 +584,7 @@ void AccountModel::setPresence(LinphoneEnums::Presence presence,
} }
setNotificationsAllowed( setNotificationsAllowed(
presence != LinphoneEnums::Presence::DoNotDisturb && presence != LinphoneEnums::Presence::Offline && presence != LinphoneEnums::Presence::DoNotDisturb &&
(presence != LinphoneEnums::Presence::Away || (presence != LinphoneEnums::Presence::Away ||
core->getConfig()->getBool(accountSection, "allow_notifications_in_presence_away", true)) && core->getConfig()->getBool(accountSection, "allow_notifications_in_presence_away", true)) &&
(presence != LinphoneEnums::Presence::Busy || (presence != LinphoneEnums::Presence::Busy ||

View file

@ -97,15 +97,16 @@ void CarddavModel::remove() {
void CarddavModel::onSyncStatusChanged(const std::shared_ptr<linphone::FriendList> &friendList, void CarddavModel::onSyncStatusChanged(const std::shared_ptr<linphone::FriendList> &friendList,
linphone::FriendList::SyncStatus status, linphone::FriendList::SyncStatus status,
const std::string &message) { const std::string &message) {
lInfo() << log().arg("carddav sync status changed :") << message;
if (status == linphone::FriendList::SyncStatus::Successful) { if (status == linphone::FriendList::SyncStatus::Successful) {
lInfo() << log().arg("Successfully synchronized:") << mCarddavFriendList->getUri(); lInfo() << log().arg("Successfully synchronized:") << mCarddavFriendList->getUri();
setMonitor(nullptr); setMonitor(nullptr);
SettingsModel::setCardDAVListForNewFriends(mStoreNewFriendsInIt ? friendList->getDisplayName() : ""); SettingsModel::setCardDAVListForNewFriends(mStoreNewFriendsInIt ? friendList->getDisplayName() : "");
emit saved(true); emit saved(true, Utils::coreStringToAppString(message));
} }
if (status == linphone::FriendList::SyncStatus::Failure) { if (status == linphone::FriendList::SyncStatus::Failure) {
lWarning() << log().arg("Synchronization failure:") << mCarddavFriendList->getUri(); lWarning() << log().arg("Synchronization failure:") << mCarddavFriendList->getUri();
setMonitor(nullptr); setMonitor(nullptr);
emit saved(false); emit saved(false, Utils::coreStringToAppString(message));
} }
} }

View file

@ -36,12 +36,17 @@ public:
CarddavModel(const std::shared_ptr<linphone::FriendList> &carddavFriendList, QObject *parent = nullptr); CarddavModel(const std::shared_ptr<linphone::FriendList> &carddavFriendList, QObject *parent = nullptr);
~CarddavModel(); ~CarddavModel();
void save(std::string displayName, std::string uri, std::string username, std::string password, std::string realm, bool storeNewFriendsInIt); void save(std::string displayName,
std::string uri,
std::string username,
std::string password,
std::string realm,
bool storeNewFriendsInIt);
void remove(); void remove();
bool storeNewFriendsInIt(); bool storeNewFriendsInIt();
signals: signals:
void saved(bool success); void saved(bool success, QString message);
void removed(); void removed();
private: private:

View file

@ -69,6 +69,7 @@ void CallModel::accept(bool withVideo) {
activateLocalVideo(params, withVideo); activateLocalVideo(params, withVideo);
mMonitor->acceptWithParams(params); mMonitor->acceptWithParams(params);
emit localVideoEnabledChanged(withVideo); emit localVideoEnabledChanged(withVideo);
emit cameraEnabledChanged(params->cameraEnabled());
} }
void CallModel::decline() { void CallModel::decline() {
@ -104,7 +105,9 @@ void CallModel::transferTo(const std::shared_ptr<linphone::Address> &address) {
void CallModel::transferToAnother(const std::shared_ptr<linphone::Call> &call) { void CallModel::transferToAnother(const std::shared_ptr<linphone::Call> &call) {
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
if (mMonitor->transferToAnother(call) == -1) if (!call) return;
// Transfer paused call to current call
if (call->transferToAnother(mMonitor) == -1)
lWarning() << log() lWarning() << log()
.arg(QStringLiteral("Unable to transfer: `%1`.")) .arg(QStringLiteral("Unable to transfer: `%1`."))
.arg(Utils::coreStringToAppString(call->getRemoteAddress()->asStringUriOnly())); .arg(Utils::coreStringToAppString(call->getRemoteAddress()->asStringUriOnly()));
@ -128,13 +131,25 @@ void CallModel::setSpeakerMuted(bool isMuted) {
emit speakerMutedChanged(isMuted); emit speakerMutedChanged(isMuted);
} }
void CallModel::enableVideo(bool enable) {
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
auto params = CoreModel::getInstance()->getCore()->createCallParams(mMonitor);
params->enableVideo(enable);
mMonitor->update(params);
}
bool CallModel::videoEnabled() const {
return mMonitor->getParams()->videoEnabled();
}
void CallModel::activateLocalVideo(std::shared_ptr<linphone::CallParams> &params, bool enable) { void CallModel::activateLocalVideo(std::shared_ptr<linphone::CallParams> &params, bool enable) {
lInfo() << sLog() lInfo() << sLog()
.arg("Updating call with video enabled and media direction set to %1") .arg("Updating call with video enabled and media direction set to %1")
.arg((int)params->getVideoDirection()); .arg((int)params->getVideoDirection());
params->enableVideo(SettingsModel::getInstance()->getVideoEnabled()); params->enableVideo(SettingsModel::getInstance()->getVideoEnabled());
auto videoDirection = enable ? linphone::MediaDirection::SendRecv : linphone::MediaDirection::RecvOnly; auto videoDirection = params->getVideoDirection();
params->setVideoDirection(videoDirection); params->setVideoDirection(enable || params->screenSharingEnabled() ? linphone::MediaDirection::SendRecv
: linphone::MediaDirection::RecvOnly);
} }
void CallModel::setLocalVideoEnabled(bool enabled) { void CallModel::setLocalVideoEnabled(bool enabled) {
@ -144,6 +159,15 @@ void CallModel::setLocalVideoEnabled(bool enabled) {
mMonitor->update(params); mMonitor->update(params);
} }
void CallModel::setCameraEnabled(bool enabled) {
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
auto params = CoreModel::getInstance()->getCore()->createCallParams(mMonitor);
activateLocalVideo(params, enabled);
lInfo() << log().arg("Enable camera :") << enabled;
params->enableCamera(enabled);
mMonitor->update(params);
}
void CallModel::startRecording() { void CallModel::startRecording() {
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
mMonitor->startRecording(); mMonitor->startRecording();
@ -431,8 +455,11 @@ void CallModel::onStateChanged(const std::shared_ptr<linphone::Call> &call,
setConference(call->getConference()); setConference(call->getConference());
mDurationTimer.start(); mDurationTimer.start();
// After UpdatedByRemote, video direction could be changed. // After UpdatedByRemote, video direction could be changed.
auto videoDirection = call->getParams()->getVideoDirection(); auto params = call->getParams();
auto videoDirection = params->getVideoDirection();
auto remoteVideoDirection = call->getRemoteParams()->getVideoDirection(); auto remoteVideoDirection = call->getRemoteParams()->getVideoDirection();
lInfo() << log().arg("Camera enabled changed") << params->cameraEnabled();
emit cameraEnabledChanged(params->cameraEnabled());
emit localVideoEnabledChanged(videoDirection == linphone::MediaDirection::SendOnly || emit localVideoEnabledChanged(videoDirection == linphone::MediaDirection::SendOnly ||
videoDirection == linphone::MediaDirection::SendRecv); videoDirection == linphone::MediaDirection::SendRecv);
emit remoteVideoEnabledChanged(remoteVideoDirection == linphone::MediaDirection::SendOnly || emit remoteVideoEnabledChanged(remoteVideoDirection == linphone::MediaDirection::SendOnly ||
@ -491,6 +518,7 @@ void CallModel::onVideoDisplayErrorOccurred(const std::shared_ptr<linphone::Call
void CallModel::onAudioDeviceChanged(const std::shared_ptr<linphone::Call> &call, void CallModel::onAudioDeviceChanged(const std::shared_ptr<linphone::Call> &call,
const std::shared_ptr<linphone::AudioDevice> &audioDevice) { const std::shared_ptr<linphone::AudioDevice> &audioDevice) {
lInfo() << log().arg("audio device changed");
emit audioDeviceChanged(call, audioDevice); emit audioDeviceChanged(call, audioDevice);
} }

View file

@ -45,6 +45,7 @@ public:
void setMicrophoneMuted(bool isMuted); void setMicrophoneMuted(bool isMuted);
void setSpeakerMuted(bool isMuted); void setSpeakerMuted(bool isMuted);
void setLocalVideoEnabled(bool enabled); void setLocalVideoEnabled(bool enabled);
void setCameraEnabled(bool enabled);
void startRecording(); void startRecording();
void stopRecording(); void stopRecording();
void setRecordFile(const std::string &path); void setRecordFile(const std::string &path);
@ -82,7 +83,8 @@ public:
LinphoneEnums::VideoSourceScreenSharingType getVideoSourceType() const; LinphoneEnums::VideoSourceScreenSharingType getVideoSourceType() const;
int getScreenSharingIndex() const; int getScreenSharingIndex() const;
void setVideoSourceDescriptorModel(std::shared_ptr<VideoSourceDescriptorModel> model = nullptr); void setVideoSourceDescriptorModel(std::shared_ptr<VideoSourceDescriptorModel> model = nullptr);
void enableVideo(bool enable);
bool videoEnabled() const;
static void activateLocalVideo(std::shared_ptr<linphone::CallParams> &params, bool enable); static void activateLocalVideo(std::shared_ptr<linphone::CallParams> &params, bool enable);
void sendDtmf(const QString &dtmf); void sendDtmf(const QString &dtmf);
@ -97,6 +99,7 @@ signals:
void microphoneVolumeChanged(float); void microphoneVolumeChanged(float);
void pausedChanged(bool paused); void pausedChanged(bool paused);
void remoteVideoEnabledChanged(bool remoteVideoEnabled); void remoteVideoEnabledChanged(bool remoteVideoEnabled);
void cameraEnabledChanged(bool enalbed);
void localVideoEnabledChanged(bool enabled); void localVideoEnabledChanged(bool enabled);
void recordingChanged(const std::shared_ptr<linphone::Call> &call, bool recording); void recordingChanged(const std::shared_ptr<linphone::Call> &call, bool recording);
void speakerVolumeGainChanged(float volume); void speakerVolumeGainChanged(float volume);

View file

@ -44,7 +44,7 @@ ChatModel::ChatModel(const std::shared_ptr<linphone::ChatRoom> &chatroom, QObjec
ChatModel::~ChatModel() { ChatModel::~ChatModel() {
mustBeInLinphoneThread("~" + getClassName()); mustBeInLinphoneThread("~" + getClassName());
disconnect(CoreModel::getInstance().get(), &CoreModel::messageReadInChatRoom, this, nullptr); disconnect(CoreModel::getInstance().get(), &CoreModel::chatRoomRead, this, nullptr);
} }
QDateTime ChatModel::getLastUpdateTime() { QDateTime ChatModel::getLastUpdateTime() {
@ -173,7 +173,6 @@ void ChatModel::leave() {
void ChatModel::deleteChatRoom() { void ChatModel::deleteChatRoom() {
CoreModel::getInstance()->getCore()->deleteChatRoom(mMonitor); CoreModel::getInstance()->getCore()->deleteChatRoom(mMonitor);
emit deleted();
} }
std::shared_ptr<linphone::ChatMessage> std::shared_ptr<linphone::ChatMessage>

View file

@ -92,7 +92,7 @@ bool ChatMessageModel::isRead() const {
void ChatMessageModel::markAsRead() { void ChatMessageModel::markAsRead() {
mMonitor->markAsRead(); mMonitor->markAsRead();
emit messageRead(); emit messageRead();
emit CoreModel::getInstance()->messageReadInChatRoom(mMonitor->getChatRoom()); emit CoreModel::getInstance() -> messageReadInChatRoom(mMonitor->getChatRoom());
} }
void ChatMessageModel::deleteMessageFromChatRoom(bool deletedByUser) { void ChatMessageModel::deleteMessageFromChatRoom(bool deletedByUser) {

View file

@ -74,8 +74,12 @@ void ChatMessageContentModel::removeDownloadedFile(QString filePath) {
} }
} }
void ChatMessageContentModel::downloadFile(const QString &name) { bool ChatMessageContentModel::downloadFile(const QString &name, QString *error) {
if (!mChatMessageModel) return; if (!mChatMessageModel) {
//: Internal error : message object does not exist anymore !
if (error) *error = tr("download_error_object_doesnt_exist");
return false;
}
switch (mChatMessageModel->getState()) { switch (mChatMessageModel->getState()) {
case linphone::ChatMessage::State::Delivered: case linphone::ChatMessage::State::Delivered:
case linphone::ChatMessage::State::DeliveredToUser: case linphone::ChatMessage::State::DeliveredToUser:
@ -83,10 +87,13 @@ void ChatMessageContentModel::downloadFile(const QString &name) {
case linphone::ChatMessage::State::FileTransferDone: case linphone::ChatMessage::State::FileTransferDone:
break; break;
case linphone::ChatMessage::State::FileTransferInProgress: case linphone::ChatMessage::State::FileTransferInProgress:
return; return true;
default: default:
lWarning() << QStringLiteral("Wrong message state when requesting downloading, state=.") auto state = LinphoneEnums::fromLinphone(mChatMessageModel->getState());
<< LinphoneEnums::fromLinphone(mChatMessageModel->getState()); lWarning() << QStringLiteral("Wrong message state when requesting downloading, state=") << state;
//: Error while trying to download content : %1
if (error) *error = tr("download_file_server_error").arg(LinphoneEnums::toString(state));
return false;
} }
bool soFarSoGood; bool soFarSoGood;
const QString safeFilePath = Utils::getSafeFilePath( const QString safeFilePath = Utils::getSafeFilePath(
@ -94,21 +101,32 @@ void ChatMessageContentModel::downloadFile(const QString &name) {
if (!soFarSoGood) { if (!soFarSoGood) {
lWarning() << QStringLiteral("Unable to create safe file path for: %1.").arg(name); lWarning() << QStringLiteral("Unable to create safe file path for: %1.").arg(name);
return; //: Unable to create safe file path for: %1
if (error) *error = tr("download_file_error_no_safe_file_path").arg(name);
return false;
} }
mContent->setFilePath(Utils::appStringToCoreString(safeFilePath)); mContent->setFilePath(Utils::appStringToCoreString(safeFilePath));
if (!mContent->isFileTransfer()) { if (!mContent->isFileTransfer()) {
lWarning() << QStringLiteral("file transfer is not available"); lWarning() << QStringLiteral("file transfer is not available");
Utils::showInformationPopup(
//: Error
tr("popup_error_title"),
//: This file was already downloaded and is no more on the server. Your peer have to resend it if you want //: This file was already downloaded and is no more on the server. Your peer have to resend it if you want
//: to get it //: to get it
tr("popup_download_error_message"), false); if (error) *error = tr("download_file_error_file_transfer_unavailable");
return false;
} else if (mContent->getName().empty()) {
lWarning() << QStringLiteral("content name is null, can't download it !");
//: Content name is null, can't download it !
if (error) *error = tr("download_file_error_null_name");
return false;
} else { } else {
if (!mChatMessageModel->getMonitor()->downloadContent(mContent)) lDebug() << log().arg("download file : %1").arg(name);
auto downloaded = mChatMessageModel->getMonitor()->downloadContent(mContent);
if (!downloaded) {
lWarning() << QStringLiteral("Unable to download file of entry %1.").arg(name); lWarning() << QStringLiteral("Unable to download file of entry %1.").arg(name);
//: Unable to download file of entry %1
if (error) *error = tr("download_file_error_unable_to_download").arg(name);
}
return downloaded;
} }
} }

View file

@ -40,17 +40,21 @@ public:
std::shared_ptr<ChatMessageModel> chatMessageModel); std::shared_ptr<ChatMessageModel> chatMessageModel);
~ChatMessageContentModel(); ~ChatMessageContentModel();
QString getThumbnail() const;
void setThumbnail(const QString &data); void setThumbnail(const QString &data);
void setWasDownloaded(bool wasDownloaded); void setWasDownloaded(bool wasDownloaded);
void createThumbnail(); void createThumbnail();
void removeDownloadedFile(QString filePath); void removeDownloadedFile(QString filePath);
void downloadFile(const QString &name); /**
* Returns true if download succeed, false otherwise
*/
bool downloadFile(const QString &name, QString *error = nullptr);
void cancelDownloadFile(); void cancelDownloadFile();
void openFile(const QString &name, bool wasDownloaded, bool showDirectory = false); void openFile(const QString &name, bool wasDownloaded, bool showDirectory = false);
/**
* Returns true if file saved successfully, false otherwise
*/
bool saveAs(const QString &path); bool saveAs(const QString &path);
const std::shared_ptr<linphone::Content> &getContent() const; const std::shared_ptr<linphone::Content> &getContent() const;

View file

@ -236,8 +236,8 @@ void ConferenceModel::onParticipantDeviceMediaCapabilityChanged(
void ConferenceModel::onParticipantDeviceMediaAvailabilityChanged( void ConferenceModel::onParticipantDeviceMediaAvailabilityChanged(
const std::shared_ptr<linphone::Conference> &conference, const std::shared_ptr<linphone::Conference> &conference,
const std::shared_ptr<const linphone::ParticipantDevice> &participantDevice) { const std::shared_ptr<const linphone::ParticipantDevice> &participantDevice) {
lInfo() << "onParticipantDeviceMediaAvailabilityChanged: " lInfo() << "onParticipantDeviceMediaAvailabilityChanged: video stream available ="
<< (int)participantDevice->getStreamAvailability(linphone::StreamType::Video) << participantDevice->getStreamAvailability(linphone::StreamType::Video)
<< ". Device: " << participantDevice->getAddress()->asString().c_str(); << ". Device: " << participantDevice->getAddress()->asString().c_str();
emit participantDeviceMediaAvailabilityChanged(participantDevice); emit participantDeviceMediaAvailabilityChanged(participantDevice);
} }

View file

@ -114,6 +114,10 @@ void CoreModel::start() {
if (mCore->getLogCollectionUploadServerUrl().empty()) if (mCore->getLogCollectionUploadServerUrl().empty())
mCore->setLogCollectionUploadServerUrl(Constants::DefaultUploadLogsServer); mCore->setLogCollectionUploadServerUrl(Constants::DefaultUploadLogsServer);
/// These 2 API should not be used as they manage internal gains insterad of those of the soundcard.
// Use playback/capture gain from capture graph and call only
mCore->setMicGainDb(0.0);
mCore->setPlaybackGainDb(0.0);
mIterateTimer = new QTimer(this); mIterateTimer = new QTimer(this);
mIterateTimer->setInterval(20); mIterateTimer->setInterval(20);
connect(mIterateTimer, &QTimer::timeout, [this]() { mCore->iterate(); }); connect(mIterateTimer, &QTimer::timeout, [this]() { mCore->iterate(); });
@ -200,7 +204,7 @@ void CoreModel::setPathAfterStart() {
QString rootCaPath = Utils::coreStringToAppString(mCore->getRootCa()); QString rootCaPath = Utils::coreStringToAppString(mCore->getRootCa());
QString relativeRootCa = Paths::getAppRootCaFilePath(); QString relativeRootCa = Paths::getAppRootCaFilePath();
lDebug() << "[CoreModel] Getting rootCa paths: " << rootCaPath << " VS " << relativeRootCa; lDebug() << "[CoreModel] Getting rootCa paths: " << rootCaPath << " VS " << relativeRootCa;
if (!Paths::filePathExists(rootCaPath) || Paths::isSameRelativeFile(rootCaPath, relativeRootCa) ) { if (!Paths::filePathExists(rootCaPath) || Paths::isSameRelativeFile(rootCaPath, relativeRootCa)) {
lInfo() << "[CoreModel] Reset rootCa path to: " << relativeRootCa; lInfo() << "[CoreModel] Reset rootCa path to: " << relativeRootCa;
mCore->setRootCa(Utils::appStringToCoreString(relativeRootCa)); mCore->setRootCa(Utils::appStringToCoreString(relativeRootCa));
} }
@ -219,7 +223,10 @@ QString CoreModel::getFetchConfig(QString filePath, bool *error) {
if (!filePath.isEmpty()) filePath = "file://" + filePath; if (!filePath.isEmpty()) filePath = "file://" + filePath;
} }
if (filePath.isEmpty()) { if (filePath.isEmpty()) {
qWarning() << "Remote provisionning cannot be retrieved. Command have been cleaned"; qWarning() << "Remote provisioning cannot be retrieved. Command have been cleaned";
Utils::showInformationPopup(tr("info_popup_error_title"),
//: "Remote provisioning cannot be retrieved"
tr("fetching_config_failed_error_message"), false);
*error = true; *error = true;
} }
} }
@ -368,6 +375,23 @@ void CoreModel::searchInMagicSearch(QString filter,
mMagicSearch->search(filter, sourceFlags, aggregation, maxResults); mMagicSearch->search(filter, sourceFlags, aggregation, maxResults);
} }
void CoreModel::checkForUpdate(const std::string &applicationVersion, bool requestedByUser) {
mCheckVersionRequestedByUser = requestedByUser;
auto settingsModel = SettingsModel::getInstance();
if (settingsModel->isCheckForUpdateEnabled()) {
if (settingsModel->getVersionCheckUrl().isEmpty())
settingsModel->setVersionCheckUrl(Constants::VersionCheckReleaseUrl);
lInfo() << log().arg("Checking for update for version") << applicationVersion;
getCore()->checkForUpdate(applicationVersion);
} else {
lWarning() << log().arg("Check for update settings is not set");
}
}
bool CoreModel::isCheckVersionRequestedByUser() const {
return mCheckVersionRequestedByUser;
}
//--------------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------------
void CoreModel::onAccountAdded(const std::shared_ptr<linphone::Core> &core, void CoreModel::onAccountAdded(const std::shared_ptr<linphone::Core> &core,
@ -525,6 +549,7 @@ void CoreModel::onLogCollectionUploadProgressIndication(const std::shared_ptr<li
void CoreModel::onMessageReceived(const std::shared_ptr<linphone::Core> &core, void CoreModel::onMessageReceived(const std::shared_ptr<linphone::Core> &core,
const std::shared_ptr<linphone::ChatRoom> &room, const std::shared_ptr<linphone::ChatRoom> &room,
const std::shared_ptr<linphone::ChatMessage> &message) { const std::shared_ptr<linphone::ChatMessage> &message) {
if (SettingsModel::getInstance()->getDisableChatFeature()) return;
if (message->isOutgoing()) return; if (message->isOutgoing()) return;
emit unreadNotificationsChanged(); emit unreadNotificationsChanged();
std::list<std::shared_ptr<linphone::ChatMessage>> messages; std::list<std::shared_ptr<linphone::ChatMessage>> messages;
@ -537,6 +562,7 @@ void CoreModel::onMessageReceived(const std::shared_ptr<linphone::Core> &core,
void CoreModel::onMessagesReceived(const std::shared_ptr<linphone::Core> &core, void CoreModel::onMessagesReceived(const std::shared_ptr<linphone::Core> &core,
const std::shared_ptr<linphone::ChatRoom> &room, const std::shared_ptr<linphone::ChatRoom> &room,
const std::list<std::shared_ptr<linphone::ChatMessage>> &messages) { const std::list<std::shared_ptr<linphone::ChatMessage>> &messages) {
if (SettingsModel::getInstance()->getDisableChatFeature()) return;
std::list<std::shared_ptr<linphone::ChatMessage>> finalMessages; std::list<std::shared_ptr<linphone::ChatMessage>> finalMessages;
for (auto &message : messages) { for (auto &message : messages) {
if (message->isOutgoing()) continue; if (message->isOutgoing()) continue;
@ -554,6 +580,7 @@ void CoreModel::onNewMessageReaction(const std::shared_ptr<linphone::Core> &core
const std::shared_ptr<linphone::ChatRoom> &chatRoom, const std::shared_ptr<linphone::ChatRoom> &chatRoom,
const std::shared_ptr<linphone::ChatMessage> &message, const std::shared_ptr<linphone::ChatMessage> &message,
const std::shared_ptr<const linphone::ChatMessageReaction> &reaction) { const std::shared_ptr<const linphone::ChatMessageReaction> &reaction) {
if (SettingsModel::getInstance()->getDisableChatFeature()) return;
emit newMessageReaction(core, chatRoom, message, reaction); emit newMessageReaction(core, chatRoom, message, reaction);
} }
void CoreModel::onNotifyPresenceReceivedForUriOrTel( void CoreModel::onNotifyPresenceReceivedForUriOrTel(
@ -574,6 +601,7 @@ void CoreModel::onReactionRemoved(const std::shared_ptr<linphone::Core> &core,
const std::shared_ptr<linphone::ChatRoom> &chatRoom, const std::shared_ptr<linphone::ChatRoom> &chatRoom,
const std::shared_ptr<linphone::ChatMessage> &message, const std::shared_ptr<linphone::ChatMessage> &message,
const std::shared_ptr<const linphone::Address> &address) { const std::shared_ptr<const linphone::Address> &address) {
if (SettingsModel::getInstance()->getDisableChatFeature()) return;
emit reactionRemoved(core, chatRoom, message, address); emit reactionRemoved(core, chatRoom, message, address);
} }
void CoreModel::onTransferStateChanged(const std::shared_ptr<linphone::Core> &core, void CoreModel::onTransferStateChanged(const std::shared_ptr<linphone::Core> &core,
@ -585,7 +613,7 @@ void CoreModel::onVersionUpdateCheckResultReceived(const std::shared_ptr<linphon
linphone::VersionUpdateCheckResult result, linphone::VersionUpdateCheckResult result,
const std::string &version, const std::string &version,
const std::string &url) { const std::string &url) {
emit versionUpdateCheckResultReceived(core, result, version, url); emit versionUpdateCheckResultReceived(core, result, version, url, mCheckVersionRequestedByUser);
} }
void CoreModel::onFriendListRemoved(const std::shared_ptr<linphone::Core> &core, void CoreModel::onFriendListRemoved(const std::shared_ptr<linphone::Core> &core,
@ -611,3 +639,12 @@ void CoreModel::onFriendListRemoved(const std::shared_ptr<linphone::Core> &core,
} }
*/ */
} }
void CoreModel::onAudioDevicesListUpdated(const std::shared_ptr<linphone::Core> &core) {
emit audioDevicesListUpdated(core);
}
void CoreModel::onAudioDeviceChanged(const std::shared_ptr<linphone::Core> &core,
const std::shared_ptr<linphone::AudioDevice> &device) {
emit audioDeviceChanged(core, device);
}

View file

@ -71,6 +71,9 @@ public:
LinphoneEnums::MagicSearchAggregation aggregation, LinphoneEnums::MagicSearchAggregation aggregation,
int maxResults); int maxResults);
void checkForUpdate(const std::string &applicationVersion, bool requestedByUser = false);
bool isCheckVersionRequestedByUser() const;
bool mEnd = false; bool mEnd = false;
linphone::ConfiguringState mConfigStatus; linphone::ConfiguringState mConfigStatus;
QString mConfigMessage; QString mConfigMessage;
@ -97,6 +100,7 @@ private:
QMap<QString, OIDCModel *> mOpenIdConnections; QMap<QString, OIDCModel *> mOpenIdConnections;
std::shared_ptr<MagicSearchModel> mMagicSearch; std::shared_ptr<MagicSearchModel> mMagicSearch;
bool mStarted = false; bool mStarted = false;
bool mCheckVersionRequestedByUser = false;
void setPathBeforeCreation(); void setPathBeforeCreation();
void setPathsAfterCreation(); void setPathsAfterCreation();
@ -202,6 +206,9 @@ private:
const std::string &url) override; const std::string &url) override;
virtual void onFriendListRemoved(const std::shared_ptr<linphone::Core> &core, virtual void onFriendListRemoved(const std::shared_ptr<linphone::Core> &core,
const std::shared_ptr<linphone::FriendList> &friendList) override; const std::shared_ptr<linphone::FriendList> &friendList) override;
virtual void onAudioDevicesListUpdated(const std::shared_ptr<linphone::Core> &core) override;
virtual void onAudioDeviceChanged(const std::shared_ptr<linphone::Core> &core,
const std::shared_ptr<linphone::AudioDevice> &device) override;
signals: signals:
void accountAdded(const std::shared_ptr<linphone::Core> &core, const std::shared_ptr<linphone::Account> &account); void accountAdded(const std::shared_ptr<linphone::Core> &core, const std::shared_ptr<linphone::Account> &account);
@ -281,9 +288,13 @@ signals:
void versionUpdateCheckResultReceived(const std::shared_ptr<linphone::Core> &core, void versionUpdateCheckResultReceived(const std::shared_ptr<linphone::Core> &core,
linphone::VersionUpdateCheckResult result, linphone::VersionUpdateCheckResult result,
const std::string &version, const std::string &version,
const std::string &url); const std::string &url,
bool checkRequestedByUser);
void friendListRemoved(const std::shared_ptr<linphone::Core> &core, void friendListRemoved(const std::shared_ptr<linphone::Core> &core,
const std::shared_ptr<linphone::FriendList> &friendList); const std::shared_ptr<linphone::FriendList> &friendList);
void audioDevicesListUpdated(const std::shared_ptr<linphone::Core> &core);
void audioDeviceChanged(const std::shared_ptr<linphone::Core> &core,
const std::shared_ptr<linphone::AudioDevice> &device);
}; };
#endif #endif

View file

@ -155,5 +155,5 @@ void MagicSearchModel::updateFriendListWithFriend(const std::shared_ptr<linphone
} }
qInfo() << log().arg("Adding Friend:") << linphoneFriend.get(); qInfo() << log().arg("Adding Friend:") << linphoneFriend.get();
if (friendList) friendList->addFriend(linphoneFriend); if (friendList) friendList->addFriend(linphoneFriend);
emit CoreModel::getInstance()->friendCreated(linphoneFriend); emit CoreModel::getInstance() -> friendCreated(linphoneFriend);
} }

View file

@ -81,6 +81,20 @@ SettingsModel::SettingsModel() {
QObject::connect(CoreModel::getInstance().get(), &CoreModel::lastCallEnded, this, [this]() { QObject::connect(CoreModel::getInstance().get(), &CoreModel::lastCallEnded, this, [this]() {
if (mCaptureGraphListenerCount > 0) createCaptureGraph(); // Repair the capture graph if (mCaptureGraphListenerCount > 0) createCaptureGraph(); // Repair the capture graph
}); });
QObject::connect(CoreModel::getInstance().get(), &CoreModel::audioDevicesListUpdated, this,
[this](const std::shared_ptr<linphone::Core> &core) {
lInfo() << log().arg("audio device list updated");
updateCallSettings();
});
QObject::connect(
CoreModel::getInstance().get(), &CoreModel::audioDeviceChanged, this,
[this](const std::shared_ptr<linphone::Core> &core, const std::shared_ptr<linphone::AudioDevice> &device) {
lInfo() << log().arg("audio device changed");
if (device) lInfo() << "device :" << device->getDeviceName();
// emit playbackDeviceChanged(getPlaybackDevice());
// emit captureDeviceChanged(getCaptureDevice());
// emit ringerDeviceChanged(getRingerDevice());
});
} }
SettingsModel::~SettingsModel() { SettingsModel::~SettingsModel() {
@ -173,8 +187,10 @@ void SettingsModel::stopCaptureGraph() {
// Force a call on the 'detect' method of all audio filters, updating new or removed devices // Force a call on the 'detect' method of all audio filters, updating new or removed devices
void SettingsModel::accessCallSettings() { void SettingsModel::accessCallSettings() {
// Audio
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
startCaptureGraph();
// Audio
CoreModel::getInstance()->getCore()->reloadSoundDevices(); CoreModel::getInstance()->getCore()->reloadSoundDevices();
emit captureDevicesChanged(getCaptureDevices()); emit captureDevicesChanged(getCaptureDevices());
emit playbackDevicesChanged(getPlaybackDevices()); emit playbackDevicesChanged(getPlaybackDevices());
@ -185,12 +201,28 @@ void SettingsModel::accessCallSettings() {
emit playbackGainChanged(getPlaybackGain()); emit playbackGainChanged(getPlaybackGain());
emit captureGainChanged(getCaptureGain()); emit captureGainChanged(getCaptureGain());
startCaptureGraph();
// Video // Video
CoreModel::getInstance()->getCore()->reloadVideoDevices(); CoreModel::getInstance()->getCore()->reloadVideoDevices();
emit videoDevicesChanged(getVideoDevices()); emit videoDevicesChanged(getVideoDevices());
} }
void SettingsModel::updateCallSettings() {
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
// Audio
emit captureDevicesChanged(getCaptureDevices());
emit playbackDevicesChanged(getPlaybackDevices());
emit playbackDeviceChanged(getPlaybackDevice());
emit ringerDevicesChanged(getRingerDevices());
emit ringerDeviceChanged(getRingerDevice());
emit captureDeviceChanged(getCaptureDevice());
emit playbackGainChanged(getPlaybackGain());
emit captureGainChanged(getCaptureGain());
// Video
emit videoDevicesChanged(getVideoDevices());
}
void SettingsModel::closeCallSettings() { void SettingsModel::closeCallSettings() {
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
stopCaptureGraph(); stopCaptureGraph();
@ -205,13 +237,12 @@ bool SettingsModel::getCaptureGraphRunning() {
float SettingsModel::getMicVolume() { float SettingsModel::getMicVolume() {
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
float v = 0.0; float v = 0.0;
if (mSimpleCaptureGraph && mSimpleCaptureGraph->isRunning()) { if (mSimpleCaptureGraph && mSimpleCaptureGraph->isRunning()) {
v = mSimpleCaptureGraph->getCaptureVolume(); v = mSimpleCaptureGraph->getCaptureVolume();
} else { } else {
auto call = CoreModel::getInstance()->getCore()->getCurrentCall(); auto call = CoreModel::getInstance()->getCore()->getCurrentCall();
if (call) { if (call) {
v = MediastreamerUtils::computeVu(call->getRecordVolume()); v = call->getRecordVolume();
} }
} }
@ -221,33 +252,49 @@ float SettingsModel::getMicVolume() {
float SettingsModel::getPlaybackGain() const { float SettingsModel::getPlaybackGain() const {
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
float dbGain = CoreModel::getInstance()->getCore()->getPlaybackGainDb(); if (mSimpleCaptureGraph && mSimpleCaptureGraph->isRunning()) {
return MediastreamerUtils::dbToLinear(dbGain); return mSimpleCaptureGraph->getPlaybackGain();
} else {
auto call = CoreModel::getInstance()->getCore()->getCurrentCall();
if (call) return call->getSpeakerVolumeGain();
else return 0.0;
}
} }
void SettingsModel::setPlaybackGain(float gain) { void SettingsModel::setPlaybackGain(float gain) {
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
float oldGain = getPlaybackGain(); float oldGain = getPlaybackGain();
CoreModel::getInstance()->getCore()->setPlaybackGainDb(MediastreamerUtils::linearToDb(gain));
if (mSimpleCaptureGraph && mSimpleCaptureGraph->isRunning()) { if (mSimpleCaptureGraph && mSimpleCaptureGraph->isRunning()) {
mSimpleCaptureGraph->setPlaybackGain(gain); mSimpleCaptureGraph->setPlaybackGain(gain);
} }
auto currentCall = CoreModel::getInstance()->getCore()->getCurrentCall();
if (currentCall) {
currentCall->setSpeakerVolumeGain(gain);
}
if ((int)(oldGain * 1000) != (int)(gain * 1000)) emit playbackGainChanged(gain); if ((int)(oldGain * 1000) != (int)(gain * 1000)) emit playbackGainChanged(gain);
} }
float SettingsModel::getCaptureGain() const { float SettingsModel::getCaptureGain() const {
mustBeInLinphoneThread(getClassName()); mustBeInLinphoneThread(getClassName());
float dbGain = CoreModel::getInstance()->getCore()->getMicGainDb(); if (mSimpleCaptureGraph && mSimpleCaptureGraph->isRunning()) {
return MediastreamerUtils::dbToLinear(dbGain); return mSimpleCaptureGraph->getCaptureGain();
} else {
auto call = CoreModel::getInstance()->getCore()->getCurrentCall();
if (call) return call->getMicrophoneVolumeGain();
else return 0.0;
}
} }
void SettingsModel::setCaptureGain(float gain) { void SettingsModel::setCaptureGain(float gain) {
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
float oldGain = getCaptureGain(); float oldGain = getCaptureGain();
CoreModel::getInstance()->getCore()->setMicGainDb(MediastreamerUtils::linearToDb(gain));
if (mSimpleCaptureGraph && mSimpleCaptureGraph->isRunning()) { if (mSimpleCaptureGraph && mSimpleCaptureGraph->isRunning()) {
mSimpleCaptureGraph->setCaptureGain(gain); mSimpleCaptureGraph->setCaptureGain(gain);
} }
auto currentCall = CoreModel::getInstance()->getCore()->getCurrentCall();
if (currentCall) {
currentCall->setMicrophoneVolumeGain(gain);
}
if ((int)(oldGain * 1000) != (int)(gain * 1000)) emit captureGainChanged(gain); if ((int)(oldGain * 1000) != (int)(gain * 1000)) emit captureGainChanged(gain);
} }
@ -396,8 +443,7 @@ void SettingsModel::setPlaybackDevice(const QVariantMap &device) {
QVariantMap SettingsModel::getRingerDevice() const { QVariantMap SettingsModel::getRingerDevice() const {
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
for (const auto &device : CoreModel::getInstance()->getCore()->getExtendedAudioDevices()) { for (const auto &device : CoreModel::getInstance()->getCore()->getExtendedAudioDevices()) {
if (device->getUseForRinging()) if (device->getUseForRinging()) return ToolModel::createVariant(device);
return ToolModel::createVariant(device);
} }
return ToolModel::createVariant(nullptr); return ToolModel::createVariant(nullptr);
} }
@ -408,8 +454,7 @@ void SettingsModel::setRingerDevice(QVariantMap device) {
auto id = Utils::appStringToCoreString(device["id"].toString()); auto id = Utils::appStringToCoreString(device["id"].toString());
if (ldevice->getId() == id) { if (ldevice->getId() == id) {
ldevice->setUseForRinging(true); ldevice->setUseForRinging(true);
}else } else ldevice->setUseForRinging(false);
ldevice->setUseForRinging(false);
} }
emit ringerDeviceChanged(device); emit ringerDeviceChanged(device);
} }
@ -863,6 +908,40 @@ bool SettingsModel::getDisableMeetingsFeature() const {
return !!mConfig->getInt(UiSection, "disable_meetings_feature", 0); return !!mConfig->getInt(UiSection, "disable_meetings_feature", 0);
} }
bool SettingsModel::isCheckForUpdateAvailable() const {
#ifdef ENABLE_UPDATE_CHECK
return true;
#else
return false;
#endif
}
bool SettingsModel::isCheckForUpdateEnabled() const {
return !!mConfig->getInt(UiSection, "check_for_update_enabled", isCheckForUpdateAvailable());
}
void SettingsModel::setCheckForUpdateEnabled(bool enable) {
mConfig->setInt(UiSection, "check_for_update_enabled", enable);
emit checkForUpdateEnabledChanged();
}
QString SettingsModel::getVersionCheckUrl() {
auto url = mConfig->getString("misc", "version_check_url_root", "");
if (url == "") {
url = Constants::VersionCheckReleaseUrl;
if (url != "") mConfig->setString("misc", "version_check_url_root", url);
}
return Utils::coreStringToAppString(url);
}
void SettingsModel::setVersionCheckUrl(const QString &url) {
if (url != getVersionCheckUrl()) {
// Do not trim the url before because we want to update GUI from potential auto fix.
mConfig->setString("misc", "version_check_url_root", Utils::appStringToCoreString(url.trimmed()));
emit versionCheckUrlChanged();
}
}
void SettingsModel::setChatNotificationSoundPath(const QString &path) { void SettingsModel::setChatNotificationSoundPath(const QString &path) {
QString cleanedPath = QDir::cleanPath(path); QString cleanedPath = QDir::cleanPath(path);
mConfig->setString(UiSection, "chat_sound_notification_file", Utils::appStringToCoreString(cleanedPath)); mConfig->setString(UiSection, "chat_sound_notification_file", Utils::appStringToCoreString(cleanedPath));

View file

@ -22,6 +22,7 @@
#define SETTINGS_MODEL_H_ #define SETTINGS_MODEL_H_
#include "MediastreamerUtils.hpp" #include "MediastreamerUtils.hpp"
#include "tool/LinphoneEnums.hpp"
#include <QFont> #include <QFont>
#include <QObject> #include <QObject>
#include <QVariantMap> #include <QVariantMap>
@ -69,6 +70,7 @@ public:
bool getIsInCall() const; bool getIsInCall() const;
void accessCallSettings(); void accessCallSettings();
void updateCallSettings();
void closeCallSettings(); void closeCallSettings();
void startCaptureGraph(); void startCaptureGraph();
@ -186,6 +188,13 @@ public:
void setDisableMeetingsFeature(bool value); void setDisableMeetingsFeature(bool value);
bool getDisableMeetingsFeature() const; bool getDisableMeetingsFeature() const;
bool isCheckForUpdateAvailable() const;
bool isCheckForUpdateEnabled() const;
void setCheckForUpdateEnabled(bool enable);
QString getVersionCheckUrl();
void setVersionCheckUrl(const QString &url);
void setVersionCheckType(const LinphoneEnums::VersionCheckType &type);
// UI // UI
DECLARE_GETSET(bool, disableChatFeature, DisableChatFeature) DECLARE_GETSET(bool, disableChatFeature, DisableChatFeature)
DECLARE_GETSET(bool, disableBroadcastFeature, DisableBroadcastFeature) DECLARE_GETSET(bool, disableBroadcastFeature, DisableBroadcastFeature)
@ -269,6 +278,9 @@ signals:
void disableMeetingsFeatureChanged(bool value); void disableMeetingsFeatureChanged(bool value);
void checkForUpdateEnabledChanged();
void versionCheckUrlChanged();
// Messages. -------------------------------------------------------------------- // Messages. --------------------------------------------------------------------
void autoDownloadReceivedFilesChanged(bool enabled); void autoDownloadReceivedFilesChanged(bool enabled);

View file

@ -320,7 +320,10 @@ bool ToolModel::createCall(const QString &sipAddress,
SettingsModel::getInstance()->setCallToneIndicationsEnabled(true); SettingsModel::getInstance()->setCallToneIndicationsEnabled(true);
} }
std::shared_ptr<linphone::CallParams> params = core->createCallParams(nullptr); std::shared_ptr<linphone::CallParams> params = core->createCallParams(nullptr);
CallModel::activateLocalVideo(params, localVideoEnabled); params->enableVideo(localVideoEnabled);
params->enableCamera(localVideoEnabled);
auto videoDirection = localVideoEnabled ? linphone::MediaDirection::SendRecv : linphone::MediaDirection::RecvOnly;
params->setVideoDirection(videoDirection);
bool micEnabled = options.contains("microEnabled") ? options["microEnabled"].toBool() : true; bool micEnabled = options.contains("microEnabled") ? options["microEnabled"].toBool() : true;
params->enableMic(micEnabled); params->enableMic(micEnabled);
@ -627,6 +630,8 @@ ToolModel::getChatRoomParams(std::shared_ptr<linphone::Call> call, std::shared_p
//: Dummy subject //: Dummy subject
params->setSubject("Dummy subject"); params->setSubject("Dummy subject");
params->setAccount(account); params->setAccount(account);
params->enableAudio(false);
params->enableVideo(false);
auto chatParams = params->getChatParams(); auto chatParams = params->getChatParams();
if (!chatParams) { if (!chatParams) {
@ -758,6 +763,7 @@ ToolModel::createGroupChatRoom(QString subject, std::list<std::shared_ptr<linpho
auto accountParams = account->getParams(); auto accountParams = account->getParams();
auto chatRoom = core->createChatRoom(params, participantsAddresses); auto chatRoom = core->createChatRoom(params, participantsAddresses);
if (!chatRoom) lWarning() << ("[ToolModel] Failed to create group chat");
return chatRoom; return chatRoom;
} }

View file

@ -66,8 +66,8 @@ public:
static constexpr int DefaultExpires = 600; static constexpr int DefaultExpires = 600;
static constexpr int DefaultPublishExpires = 120; static constexpr int DefaultPublishExpires = 120;
static constexpr char DownloadUrl[] = "https://www.linphone.org/technical-corner/linphone"; static constexpr char DownloadUrl[] = "https://www.linphone.org/technical-corner/linphone";
static constexpr char VersionCheckReleaseUrl[] = "https://linphone.org/releases"; static constexpr char VersionCheckReleaseUrl[] = "https://download.linphone.org/releases";
static constexpr char VersionCheckNightlyUrl[] = "https://linphone.org/snapshots"; static constexpr char VersionCheckNightlyUrl[] = "https://download.linphone.org/snapshots";
static constexpr char PasswordRecoveryUrl[] = "https://subscribe.linphone.org/recovery/email"; static constexpr char PasswordRecoveryUrl[] = "https://subscribe.linphone.org/recovery/email";
static constexpr char CguUrl[] = "https://www.linphone.org/en/terms-of-use/"; static constexpr char CguUrl[] = "https://www.linphone.org/en/terms-of-use/";
static constexpr char PrivatePolicyUrl[] = "https://www.linphone.org/en/privacy-policy/"; static constexpr char PrivatePolicyUrl[] = "https://www.linphone.org/en/privacy-policy/";
@ -129,7 +129,7 @@ public:
static constexpr char LinphoneDomain[] = "sip.linphone.org"; // Use for checking if config are a Linphone static constexpr char LinphoneDomain[] = "sip.linphone.org"; // Use for checking if config are a Linphone
static constexpr char WindowIconPath[] = ":/data/image/logo.svg"; static constexpr char WindowIconPath[] = ":/data/image/logo.svg";
static constexpr char ApplicationMinimalQtVersion[] = "6.6.5"; static constexpr char ApplicationMinimalQtVersion[] = "6.10.0";
static constexpr char DefaultConferenceURI[] = static constexpr char DefaultConferenceURI[] =
"sip:conference-factory@sip.linphone.org"; // Default for a Linphone account "sip:conference-factory@sip.linphone.org"; // Default for a Linphone account
static constexpr char DefaultVideoConferenceURI[] = static constexpr char DefaultVideoConferenceURI[] =

View file

@ -120,6 +120,9 @@ LinphoneEnums::ChatMessageState LinphoneEnums::fromLinphone(const linphone::Chat
QString LinphoneEnums::toString(const LinphoneEnums::ChatMessageState &data) { QString LinphoneEnums::toString(const LinphoneEnums::ChatMessageState &data) {
switch (data) { switch (data) {
case LinphoneEnums::ChatMessageState::StateIdle:
//: "idle"
return QObject::tr("message_state_idle");
case LinphoneEnums::ChatMessageState::StateInProgress: case LinphoneEnums::ChatMessageState::StateInProgress:
//: "delivery in progress" //: "delivery in progress"
return QObject::tr("message_state_in_progress"); return QObject::tr("message_state_in_progress");

View file

@ -399,6 +399,9 @@ LinphoneEnums::VideoSourceScreenSharingType fromLinphone(const linphone::VideoSo
enum class PlaybackState { PlayingState = 0, PausedState = 1, StoppedState = 2, ErrorState = 3 }; enum class PlaybackState { PlayingState = 0, PausedState = 1, StoppedState = 2, ErrorState = 3 };
Q_ENUM_NS(PlaybackState); Q_ENUM_NS(PlaybackState);
enum class VersionCheckType { Release = 0, Nightly = 1, Custom = 2 };
Q_ENUM_NS(VersionCheckType)
} // namespace LinphoneEnums } // namespace LinphoneEnums
/* /*
Q_DECLARE_METATYPE(LinphoneEnums::CallState) Q_DECLARE_METATYPE(LinphoneEnums::CallState)

View file

@ -209,22 +209,22 @@ void Utils::createGroupCall(QString subject, const std::list<QString> &participa
// Comment on annule ? Si on ferme la fenêtre ça va finir l'appel en cours // Comment on annule ? Si on ferme la fenêtre ça va finir l'appel en cours
void Utils::setupConference(ConferenceInfoGui *confGui) { void Utils::setupConference(ConferenceInfoGui *confGui) {
if (!confGui) return; if (!confGui) return;
auto window = App::getInstance()->getCallsWindow(QVariant()); auto window = App::getInstance()->getOrCreateCallsWindow(QVariant());
window->setProperty("conferenceInfo", QVariant::fromValue(confGui)); window->setProperty("conferenceInfo", QVariant::fromValue(confGui));
window->show(); window->show();
} }
void Utils::openCallsWindow(CallGui *call) { void Utils::openCallsWindow(CallGui *call) {
if (call) { if (call) {
auto window = App::getInstance()->getCallsWindow(QVariant::fromValue(call)); auto window = App::getInstance()->getOrCreateCallsWindow(QVariant::fromValue(call));
window->show(); window->show();
window->raise(); window->raise();
} }
} }
QQuickWindow *Utils::getCallsWindow(CallGui *callGui) { QQuickWindow *Utils::getOrCreateCallsWindow(CallGui *callGui) {
auto app = App::getInstance(); auto app = App::getInstance();
auto window = app->getCallsWindow(QVariant::fromValue(callGui)); auto window = app->getOrCreateCallsWindow(QVariant::fromValue(callGui));
return window; return window;
} }
@ -269,11 +269,14 @@ VariantObject *Utils::haveAccount() {
void Utils::smartShowWindow(QQuickWindow *window) { void Utils::smartShowWindow(QQuickWindow *window) {
if (!window) return; if (!window) return;
if (window->visibility() == QWindow::Maximized) // Avoid to change visibility mode // if (window->visibility() == QWindow::Maximized) // Avoid to change visibility mode
window->showMaximized(); // window->showMaximized();
else window->show(); lInfo() << "[Utils] : show window" << window;
window->show();
App::getInstance()->setLastActiveWindow(window); App::getInstance()->setLastActiveWindow(window);
lInfo() << "[Utils] : raise window" << window;
window->raise(); // Raise ensure to get focus on Mac window->raise(); // Raise ensure to get focus on Mac
lInfo() << "[Utils] : request activate";
window->requestActivate(); window->requestActivate();
} }
@ -1432,9 +1435,9 @@ QDateTime Utils::addYears(QDateTime date, int years) {
return date; return date;
} }
int Utils::timeOffset(QDateTime start, QDateTime end) { int Utils::timeOffset(QTime start, QTime end) {
int offset = start.secsTo(end); int offset = start.secsTo(end);
return std::min(offset, INT_MAX); return std::max(std::min(offset, INT_MAX), INT_MIN);
} }
int Utils::daysOffset(QDateTime start, QDateTime end) { int Utils::daysOffset(QDateTime start, QDateTime end) {
@ -1601,7 +1604,7 @@ VariantObject *Utils::getCurrentCallChat(CallGui *call) {
showInformationPopup(tr("information_popup_error_title"), showInformationPopup(tr("information_popup_error_title"),
//: Failed to create 1-1 conversation with %1 ! //: Failed to create 1-1 conversation with %1 !
tr("information_popup_chatroom_creation_error_message"), false, tr("information_popup_chatroom_creation_error_message"), false,
getCallsWindow()); getOrCreateCallsWindow());
}); });
return QVariant(); return QVariant();
} }
@ -1635,7 +1638,7 @@ VariantObject *Utils::getChatForAddress(QString address) {
data->mConnection->invokeToCore([] { data->mConnection->invokeToCore([] {
showInformationPopup(tr("information_popup_error_title"), showInformationPopup(tr("information_popup_error_title"),
tr("information_popup_chatroom_creation_error_message"), false, tr("information_popup_chatroom_creation_error_message"), false,
getCallsWindow()); getOrCreateCallsWindow());
}); });
return QVariant(); return QVariant();
} }

View file

@ -84,7 +84,7 @@ public:
const QString &description, const QString &description,
bool isSuccess = true, bool isSuccess = true,
QQuickWindow *window = nullptr); QQuickWindow *window = nullptr);
Q_INVOKABLE static QQuickWindow *getCallsWindow(CallGui *callGui = nullptr); Q_INVOKABLE static QQuickWindow *getOrCreateCallsWindow(CallGui *callGui = nullptr);
Q_INVOKABLE static void closeCallsWindow(); Q_INVOKABLE static void closeCallsWindow();
Q_INVOKABLE static VariantObject *haveAccount(); Q_INVOKABLE static VariantObject *haveAccount();
Q_INVOKABLE static void smartShowWindow(QQuickWindow *window); Q_INVOKABLE static void smartShowWindow(QQuickWindow *window);
@ -126,7 +126,7 @@ public:
Q_INVOKABLE static int secsTo(const QString &start, const QString &end); Q_INVOKABLE static int secsTo(const QString &start, const QString &end);
Q_INVOKABLE static QDateTime addSecs(QDateTime date, int secs); Q_INVOKABLE static QDateTime addSecs(QDateTime date, int secs);
Q_INVOKABLE static QDateTime addYears(QDateTime date, int years); Q_INVOKABLE static QDateTime addYears(QDateTime date, int years);
Q_INVOKABLE static int timeOffset(QDateTime start, QDateTime end); Q_INVOKABLE static int timeOffset(QTime start, QTime end);
Q_INVOKABLE static int daysOffset(QDateTime start, QDateTime end); Q_INVOKABLE static int daysOffset(QDateTime start, QDateTime end);
Q_INVOKABLE static VariantObject *interpretUrl(QString uri); Q_INVOKABLE static VariantObject *interpretUrl(QString uri);
Q_INVOKABLE static bool isValidURL(const QString &url); Q_INVOKABLE static bool isValidURL(const QString &url);

View file

@ -54,6 +54,7 @@ list(APPEND _LINPHONEAPP_QML_FILES
view/Control/Display/TemporaryText.qml view/Control/Display/TemporaryText.qml
view/Control/Display/Text.qml view/Control/Display/Text.qml
view/Control/Display/ToolTip.qml view/Control/Display/ToolTip.qml
view/Control/Display/UnreadNotification.qml
view/Control/Display/Call/CallListView.qml view/Control/Display/Call/CallListView.qml
view/Control/Display/Call/CallHistoryListView.qml view/Control/Display/Call/CallHistoryListView.qml
view/Control/Display/Call/CallStatistics.qml view/Control/Display/Call/CallStatistics.qml

View file

@ -52,9 +52,9 @@ Control.Button {
property real keyboardFocusedBorderWidth: Utils.getSizeWithScreenRatio(3) property real keyboardFocusedBorderWidth: Utils.getSizeWithScreenRatio(3)
// Image properties // Image properties
property var contentImageColor: style?.image? style.image.normal : DefaultStyle.main2_600 property var contentImageColor: style?.image? style.image.normal : DefaultStyle.main2_600
property var hoveredImageColor: style?.image? style.image.pressed : Qt.darker(contentImageColor, 1.05) property var hoveredImageColor: style && style.image && style.image.hovered ? style.image.hovered : Qt.darker(contentImageColor, 1.05)
property var checkedImageColor: style?.image? style.image.checked : Qt.darker(contentImageColor, 1.1) property var checkedImageColor: style && style.image && style.image.checked ? style.image.checked : Qt.darker(contentImageColor, 1.1)
property var pressedImageColor: style?.image? style.image.pressed : Qt.darker(contentImageColor, 1.1) property var pressedImageColor: style && style.image && style.image.pressed ? style.image.pressed : Qt.darker(contentImageColor, 1.1)
icon.source: style?.iconSource || "" icon.source: style?.iconSource || ""
property color colorizationColor: checkable && checked property color colorizationColor: checkable && checked
? checkedImageColor ? checkedImageColor
@ -139,6 +139,12 @@ Control.Button {
underline: mainItem.underline underline: mainItem.underline
bold: (mainItem.style === ButtonStyle.noBackground || mainItem.style === ButtonStyle.noBackgroundRed) && (mainItem.hovered || mainItem.pressed) bold: (mainItem.style === ButtonStyle.noBackground || mainItem.style === ButtonStyle.noBackgroundRed) && (mainItem.hovered || mainItem.pressed)
} }
ToolTip {
parent: mainItem
text: mainItem.text
visible: mainItem.hovered && (buttonText.implicitWidth > buttonText.width)
delay: 500
}
TextMetrics { TextMetrics {
id: textMetrics id: textMetrics
text: mainItem.text text: mainItem.text
@ -147,7 +153,6 @@ Control.Button {
} }
component ButtonImage: EffectImage { component ButtonImage: EffectImage {
asynchronous: mainItem.asynchronous
imageSource: mainItem.icon.source imageSource: mainItem.icon.source
imageWidth: mainItem.icon.width imageWidth: mainItem.icon.width
imageHeight: mainItem.icon.height imageHeight: mainItem.icon.height

View file

@ -14,14 +14,14 @@ ComboBox {
property alias contentText: contentText property alias contentText: contentText
contentItem: Text { contentItem: Text {
id: contentText id: contentText
text: UtilsCpp.formatDate(calendar.selectedDate, false, true, "ddd d, MMMM") text: calendar.selectedDate ? UtilsCpp.formatDate(calendar.selectedDate, false, true, "ddd d, MMMM") : ""
anchors.fill: parent anchors.fill: parent
anchors.leftMargin: Utils.getSizeWithScreenRatio(15) anchors.leftMargin: Utils.getSizeWithScreenRatio(15)
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
font { font {
pixelSize: Utils.getSizeWithScreenRatio(14) pixelSize: Utils.getSizeWithScreenRatio(14)
weight: Math.min(Utils.getSizeWithScreenRatio(700), 1000) weight: Font.Bold
} }
} }
popup: Control.Popup { popup: Control.Popup {

View file

@ -223,7 +223,7 @@ Control.ComboBox {
font { font {
family: DefaultStyle.defaultFont family: DefaultStyle.defaultFont
pixelSize: Utils.getSizeWithScreenRatio(15) pixelSize: Utils.getSizeWithScreenRatio(15)
weight: Math.min(Utils.getSizeWithScreenRatio(400), 1000) weight: Font.Normal
} }
} }
} }

View file

@ -3,6 +3,7 @@ import QtQuick.Effects
import QtQuick.Layouts import QtQuick.Layouts
import Linphone import Linphone
import "qrc:/qt/qml/Linphone/view/Control/Tool/Helper/utils.js" as Utils import "qrc:/qt/qml/Linphone/view/Control/Tool/Helper/utils.js" as Utils
import 'qrc:/qt/qml/Linphone/view/Style/buttonStyle.js' as ButtonStyle
MouseArea { MouseArea {
id: mainItem id: mainItem
@ -11,6 +12,8 @@ MouseArea {
property string subTitle property string subTitle
property real iconSize: Utils.getSizeWithScreenRatio(32) property real iconSize: Utils.getSizeWithScreenRatio(32)
property bool shadowEnabled: containsMouse || activeFocus property bool shadowEnabled: containsMouse || activeFocus
property bool arrowImageVisible: false
property alias image: image
hoverEnabled: true hoverEnabled: true
width: content.implicitWidth width: content.implicitWidth
height: content.implicitHeight height: content.implicitHeight
@ -27,6 +30,7 @@ MouseArea {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.fill:parent anchors.fill:parent
EffectImage { EffectImage {
id: image
Layout.preferredWidth: mainItem.iconSize Layout.preferredWidth: mainItem.iconSize
Layout.preferredHeight: mainItem.iconSize Layout.preferredHeight: mainItem.iconSize
width: mainItem.iconSize width: mainItem.iconSize
@ -36,10 +40,12 @@ MouseArea {
} }
ColumnLayout { ColumnLayout {
width: implicitWidth width: implicitWidth
Layout.preferredWidth: width
height: implicitHeight height: implicitHeight
Layout.leftMargin: Utils.getSizeWithScreenRatio(16) Layout.leftMargin: Utils.getSizeWithScreenRatio(16)
Text { Text {
Layout.fillWidth: true Layout.fillWidth: true
maximumLineCount: 1
text: mainItem.title text: mainItem.title
color: DefaultStyle.main2_600 color: DefaultStyle.main2_600
font: Typography.p2 font: Typography.p2
@ -49,6 +55,7 @@ MouseArea {
Text { Text {
Layout.alignment: Qt.AlignTop Layout.alignment: Qt.AlignTop
verticalAlignment: Text.AlignTop verticalAlignment: Text.AlignTop
maximumLineCount: 2
Layout.fillWidth: true Layout.fillWidth: true
text: mainItem.subTitle text: mainItem.subTitle
color: DefaultStyle.main2_500_main color: DefaultStyle.main2_500_main
@ -56,6 +63,13 @@ MouseArea {
font: Typography.p1 font: Typography.p1
} }
} }
Item{Layout.fillWidth: true}
EffectImage {
id: arrowImage
visible: mainItem.arrowImageVisible
imageSource: AppIcons.rightArrow
colorizationColor: DefaultStyle.main2_600
}
} }
MultiEffect { MultiEffect {
enabled: mainItem.shadowEnabled enabled: mainItem.shadowEnabled

View file

@ -23,7 +23,7 @@ Button {
: mainItem.hovered || mainItem.hasNavigationFocus : mainItem.hovered || mainItem.hasNavigationFocus
? mainItem.hoveredColor ? mainItem.hoveredColor
: mainItem.color : mainItem.color
border.color: mainItem.hovered ? mainItem.focusedBorderColor : mainItem.borderColor border.color: mainItem.borderColor
} }
contentItem: EffectImage { contentItem: EffectImage {

View file

@ -15,9 +15,10 @@ Button {
shadowEnabled: mainItem.activeFocus || hovered shadowEnabled: mainItem.activeFocus || hovered
style: ButtonStyle.hoveredBackground style: ButtonStyle.hoveredBackground
property bool inverseLayout: false property bool inverseLayout: false
spacing: Utils.getSizeWithScreenRatio(5)
contentItem: RowLayout { contentItem: RowLayout {
spacing: Utils.getSizeWithScreenRatio(5) spacing: mainItem.spacing
layoutDirection: mainItem.inverseLayout ? Qt.RightToLeft: Qt.LeftToRight layoutDirection: mainItem.inverseLayout ? Qt.RightToLeft: Qt.LeftToRight
EffectImage { EffectImage {
imageSource: mainItem.icon.source imageSource: mainItem.icon.source

View file

@ -55,6 +55,7 @@ Button {
} }
function _getPreviousItem(content, index) { function _getPreviousItem(content, index) {
if (!content.visible) return null
if (content.visibleChildren.length == 0 || !hasFocusableChild(content)) if (content.visibleChildren.length == 0 || !hasFocusableChild(content))
return null; return null;
--index; --index;

View file

@ -79,6 +79,9 @@ Item {
anchors.bottomMargin: Utils.getSizeWithScreenRatio(15)// Spacing anchors.bottomMargin: Utils.getSizeWithScreenRatio(15)// Spacing
qmlName: 'S_'+index qmlName: 'S_'+index
visible: parent.visible visible: parent.visible
videoEnabled: (index === 0 && mainItem.call.core.cameraEnabled)
|| (!previewEnabled && call && call.core.remoteVideoEnabled)
|| (!previewEnabled && participantDevice && participantDevice.core.videoEnabled)
participantDevice: $modelData participantDevice: $modelData
displayAll: false displayAll: false
displayPresence: false displayPresence: false

View file

@ -113,7 +113,7 @@ ColumnLayout {
style: ButtonStyle.grey style: ButtonStyle.grey
onClicked: { onClicked: {
if (mainItem.conferenceInfo) { if (mainItem.conferenceInfo) {
var callsWindow = UtilsCpp.getCallsWindow() var callsWindow = UtilsCpp.getOrCreateCallsWindow()
callsWindow.setupConference(mainItem.conferenceInfo) callsWindow.setupConference(mainItem.conferenceInfo)
UtilsCpp.smartShowWindow(callsWindow) UtilsCpp.smartShowWindow(callsWindow)
} }

View file

@ -113,8 +113,7 @@ Item {
anchors.bottom: mainItem.bottom anchors.bottom: mainItem.bottom
anchors.rightMargin: Utils.getSizeWithScreenRatio(20) anchors.rightMargin: Utils.getSizeWithScreenRatio(20)
anchors.bottomMargin: Utils.getSizeWithScreenRatio(10) anchors.bottomMargin: Utils.getSizeWithScreenRatio(10)
videoEnabled: preview.visible && mainItem.call && mainItem.call.core.localVideoEnabled onVideoEnabledChanged: console.log("Preview : " +videoEnabled + " / " +visible +" / " +mainItem.call)
onVideoEnabledChanged: console.log("P : " +videoEnabled + " / " +visible +" / " +mainItem.call)
property var accountObj: UtilsCpp.findLocalAccountByAddress(mainItem.localAddress) property var accountObj: UtilsCpp.findLocalAccountByAddress(mainItem.localAddress)
account: accountObj && accountObj.value || null account: accountObj && accountObj.value || null
call: mainItem.call call: mainItem.call

View file

@ -14,6 +14,7 @@ FocusScope {
property color searchBarBorderColor: "transparent" property color searchBarBorderColor: "transparent"
property alias searchBar: searchBar property alias searchBar: searchBar
property string startGroupButtonText property string startGroupButtonText
property bool startGroupButtonVisible: true
property NumericPadPopup numPadPopup property NumericPadPopup numPadPopup
signal groupCreationRequested() signal groupCreationRequested()
signal contactClicked(FriendGui contact) signal contactClicked(FriendGui contact)
@ -52,6 +53,7 @@ FocusScope {
spacing: Utils.getSizeWithScreenRatio(32) spacing: Utils.getSizeWithScreenRatio(32)
Button { Button {
id: groupCreationButton id: groupCreationButton
visible: mainItem.startGroupButtonVisible
Layout.preferredWidth: Utils.getSizeWithScreenRatio(320) Layout.preferredWidth: Utils.getSizeWithScreenRatio(320)
Layout.preferredHeight: Utils.getSizeWithScreenRatio(44) Layout.preferredHeight: Utils.getSizeWithScreenRatio(44)
padding: 0 padding: 0

View file

@ -9,6 +9,7 @@ FocusScope{
id: mainItem id: mainItem
property alias contentItem: contentItem.data property alias contentItem: contentItem.data
property string label: "" property string label: ""
property string labelIndication
property string tooltip: "" property string tooltip: ""
property bool mandatory: false property bool mandatory: false
@ -73,6 +74,12 @@ FocusScope{
text: mainItem.tooltip text: mainItem.tooltip
} }
} }
Text {
visible: mainItem.labelIndication !== undefined
font.pixelSize: Utils.getSizeWithScreenRatio(12)
font.weight: Utils.getSizeWithScreenRatio(300)
text: mainItem.labelIndication
}
} }
Item { Item {

Some files were not shown because too many files have changed in this diff Show more