diff --git a/Linphone/core/account/AccountCore.cpp b/Linphone/core/account/AccountCore.cpp index 34f6752ff..8544cb5ce 100644 --- a/Linphone/core/account/AccountCore.cpp +++ b/Linphone/core/account/AccountCore.cpp @@ -109,6 +109,36 @@ AccountCore::~AccountCore() { emit mAccountModel->removeListener(); } +AccountCore::AccountCore(const AccountCore &accountCore) { + mContactAddress = accountCore.mContactAddress; + mIdentityAddress = accountCore.mIdentityAddress; + mPictureUri = accountCore.mPictureUri; + mDisplayName = accountCore.mDisplayName; + mDialPlans = accountCore.mDialPlans; + mDialPlan = accountCore.mDialPlan; + mRegisterEnabled = accountCore.mRegisterEnabled; + mIsDefaultAccount = accountCore.mIsDefaultAccount; + mRegistrationState = accountCore.mRegistrationState; + mUnreadNotifications = accountCore.mUnreadNotifications; + mUnreadCallNotifications = accountCore.mUnreadCallNotifications; + mUnreadMessageNotifications = accountCore.mUnreadMessageNotifications; + mDevices = accountCore.mDevices; + mNotificationsAllowed = accountCore.mNotificationsAllowed; + mMwiServerAddress = accountCore.mMwiServerAddress; + mTransport = accountCore.mTransport; + mTransports = accountCore.mTransports; + mServerAddress = accountCore.mServerAddress; + mOutboundProxyEnabled = accountCore.mOutboundProxyEnabled; + mStunServer = accountCore.mStunServer; + mIceEnabled = accountCore.mIceEnabled; + mAvpfEnabled = accountCore.mAvpfEnabled; + mBundleModeEnabled = accountCore.mBundleModeEnabled; + mExpire = accountCore.mExpire; + mConferenceFactoryAddress = accountCore.mConferenceFactoryAddress; + mAudioVideoConferenceFactoryAddress = accountCore.mAudioVideoConferenceFactoryAddress; + mLimeServerUrl = accountCore.mLimeServerUrl; +} + void AccountCore::setSelf(QSharedPointer me) { mAccountModelConnection = QSharedPointer>( new SafeConnection(me, mAccountModel)); @@ -228,54 +258,33 @@ void AccountCore::setSelf(QSharedPointer me) { mAccountModelConnection->makeConnectToCore(&AccountCore::lSetNotificationsAllowed, [this](bool value) { mAccountModelConnection->invokeToModel([this, value]() { mAccountModel->setNotificationsAllowed(value); }); }); - mAccountModelConnection->makeConnectToCore(&AccountCore::lSetMwiServerAddress, [this](QString value) { - mAccountModelConnection->invokeToModel([this, value]() { mAccountModel->setMwiServerAddress(value); }); - }); - mAccountModelConnection->makeConnectToCore(&AccountCore::lSetTransport, [this](QString value) { - LinphoneEnums::TransportType transport; - LinphoneEnums::fromString(value, &transport); - mAccountModelConnection->invokeToModel( - [this, value, transport]() { mAccountModel->setTransport(LinphoneEnums::toLinphone(transport)); }); - }); - mAccountModelConnection->makeConnectToCore(&AccountCore::lSetServerAddress, [this](QString value) { - mAccountModelConnection->invokeToModel([this, value]() { mAccountModel->setServerAddress(value); }); - }); - mAccountModelConnection->makeConnectToCore(&AccountCore::lSetOutboundProxyEnabled, [this](bool value) { - mAccountModelConnection->invokeToModel([this, value]() { mAccountModel->setOutboundProxyEnabled(value); }); - }); - mAccountModelConnection->makeConnectToCore(&AccountCore::lSetStunServer, [this](QString value) { - mAccountModelConnection->invokeToModel([this, value]() { mAccountModel->setStunServer(value); }); - }); - mAccountModelConnection->makeConnectToCore(&AccountCore::lSetIceEnabled, [this](bool value) { - mAccountModelConnection->invokeToModel([this, value]() { mAccountModel->setIceEnabled(value); }); - }); - mAccountModelConnection->makeConnectToCore(&AccountCore::lSetAvpfEnabled, [this](bool value) { - mAccountModelConnection->invokeToModel([this, value]() { mAccountModel->setAvpfEnabled(value); }); - }); - mAccountModelConnection->makeConnectToCore(&AccountCore::lSetBundleModeEnabled, [this](bool value) { - mAccountModelConnection->invokeToModel([this, value]() { mAccountModel->setBundleModeEnabled(value); }); - }); - mAccountModelConnection->makeConnectToCore(&AccountCore::lSetExpire, [this](int value) { - mAccountModelConnection->invokeToModel([this, value]() { mAccountModel->setExpire(value); }); - }); - mAccountModelConnection->makeConnectToCore(&AccountCore::lSetConferenceFactoryAddress, [this](QString value) { - mAccountModelConnection->invokeToModel([this, value]() { mAccountModel->setConferenceFactoryAddress(value); }); - }); - mAccountModelConnection->makeConnectToCore(&AccountCore::lSetAudioVideoConferenceFactoryAddress, - [this](QString value) { - mAccountModelConnection->invokeToModel([this, value]() { - mAccountModel->setAudioVideoConferenceFactoryAddress(value); - }); - }); - mAccountModelConnection->makeConnectToCore(&AccountCore::lSetLimeServerUrl, [this](QString value) { - mAccountModelConnection->invokeToModel([this, value]() { mAccountModel->setLimeServerUrl(value); }); - }); DEFINE_CORE_GET_CONNECT(mAccountModelConnection, AccountCore, AccountModel, mAccountModel, int, voicemailCount, VoicemailCount) DEFINE_CORE_GET_CONNECT(mAccountModelConnection, AccountCore, AccountModel, mAccountModel, int, showMwi, ShowMwi) - DEFINE_CORE_GETSET_CONNECT(mAccountModelConnection, AccountCore, AccountModel, mAccountModel, QString, - voicemailAddress, VoicemailAddress) + // DEFINE_CORE_GETSET_CONNECT(mAccountModelConnection, AccountCore, AccountModel, mAccountModel, QString, + // voicemailAddress, VoicemailAddress) + mAccountModelConnection->makeConnectToModel(&AccountModel::voicemailAddressChanged, [this](QString value) { + mAccountModelConnection->invokeToCore([this, value]() { setVoicemailAddress(value); }); + }); +} + +void AccountCore::reset(const AccountCore &accountCore) { + setUnreadNotifications(accountCore.mUnreadNotifications); + setUnreadCallNotifications(accountCore.mUnreadCallNotifications); + setUnreadMessageNotifications(accountCore.mUnreadMessageNotifications); + setMwiServerAddress(accountCore.mMwiServerAddress); + setTransport(accountCore.mTransport); + setServerAddress(accountCore.mServerAddress); + setOutboundProxyEnabled(accountCore.mOutboundProxyEnabled); + setStunServer(accountCore.mStunServer); + setIceEnabled(accountCore.mIceEnabled); + setAvpfEnabled(accountCore.mAvpfEnabled); + setBundleModeEnabled(accountCore.mBundleModeEnabled); + setExpire(accountCore.mExpire); + setConferenceFactoryAddress(accountCore.mConferenceFactoryAddress); + setAudioVideoConferenceFactoryAddress(accountCore.mAudioVideoConferenceFactoryAddress); + setLimeServerUrl(accountCore.mLimeServerUrl); } const std::shared_ptr &AccountCore::getModel() const { @@ -487,6 +496,125 @@ QString AccountCore::getLimeServerUrl() { return mLimeServerUrl; } +QString AccountCore::getVoicemailAddress() { + return mVoicemailAddress; +} + +void AccountCore::setMwiServerAddress(QString value) { + if (mMwiServerAddress != value) { + mMwiServerAddress = value; + emit mwiServerAddressChanged(); + setIsSaved(false); + } +} + +void AccountCore::setTransport(QString value) { + if (mTransport != value) { + mTransport = value; + emit transportChanged(); + setIsSaved(false); + } +} + +void AccountCore::setServerAddress(QString value) { + if (mServerAddress != value) { + mServerAddress = value; + emit serverAddressChanged(); + setIsSaved(false); + } +} + +void AccountCore::setOutboundProxyEnabled(bool value) { + if (mOutboundProxyEnabled != value) { + mOutboundProxyEnabled = value; + emit outboundProxyEnabledChanged(); + setIsSaved(false); + } +} + +void AccountCore::setStunServer(QString value) { + if (mStunServer != value) { + mStunServer = value; + emit stunServerChanged(); + setIsSaved(false); + } +} + +void AccountCore::setIceEnabled(bool value) { + if (mIceEnabled != value) { + mIceEnabled = value; + emit iceEnabledChanged(); + setIsSaved(false); + } +} + +void AccountCore::setAvpfEnabled(bool value) { + if (mAvpfEnabled != value) { + mAvpfEnabled = value; + emit avpfEnabledChanged(); + setIsSaved(false); + } +} + +void AccountCore::setBundleModeEnabled(bool value) { + if (mBundleModeEnabled != value) { + mBundleModeEnabled = value; + emit bundleModeEnabledChanged(); + setIsSaved(false); + } +} + +void AccountCore::setExpire(int value) { + if (mExpire != value) { + mExpire = value; + emit expireChanged(); + setIsSaved(false); + } +} + +void AccountCore::setConferenceFactoryAddress(QString value) { + if (mConferenceFactoryAddress != value) { + mConferenceFactoryAddress = value; + emit conferenceFactoryAddressChanged(); + setIsSaved(false); + } +} + +void AccountCore::setAudioVideoConferenceFactoryAddress(QString value) { + if (mAudioVideoConferenceFactoryAddress != value) { + mAudioVideoConferenceFactoryAddress = value; + emit audioVideoConferenceFactoryAddressChanged(); + setIsSaved(false); + } +} + +void AccountCore::setLimeServerUrl(QString value) { + if (mLimeServerUrl != value) { + mLimeServerUrl = value; + emit limeServerUrlChanged(); + setIsSaved(false); + } +} + +void AccountCore::setVoicemailAddress(QString value) { + if (mVoicemailAddress != value) { + mVoicemailAddress = value; + emit voicemailAddressChanged(); + setIsSaved(false); + } +} + +bool AccountCore::isSaved() const { + return mIsSaved; +} + +void AccountCore::setIsSaved(bool saved) { + if (mIsSaved != saved) { + mIsSaved = saved; + emit isSavedChanged(); + } +} + void AccountCore::onNotificationsAllowedChanged(bool value) { if (value != mNotificationsAllowed) { mNotificationsAllowed = value; @@ -576,3 +704,69 @@ void AccountCore::onLimeServerUrlChanged(QString value) { emit limeServerUrlChanged(); } } + +void AccountCore::writeIntoModel(std::shared_ptr model) const { + mustBeInLinphoneThread(getClassName() + Q_FUNC_INFO); + model->setMwiServerAddress(mMwiServerAddress); + LinphoneEnums::TransportType transport; + LinphoneEnums::fromString(mTransport, &transport); + model->setTransport(LinphoneEnums::toLinphone(transport)); + model->setServerAddress(mServerAddress); + model->setOutboundProxyEnabled(mOutboundProxyEnabled); + model->setStunServer(mStunServer); + model->setIceEnabled(mIceEnabled); + model->setAvpfEnabled(mAvpfEnabled); + model->setBundleModeEnabled(mBundleModeEnabled); + model->setExpire(mExpire); + model->setConferenceFactoryAddress(mConferenceFactoryAddress); + model->setAudioVideoConferenceFactoryAddress(mAudioVideoConferenceFactoryAddress); + model->setLimeServerUrl(mLimeServerUrl); + model->setVoicemailAddress(mVoicemailAddress); +} + +void AccountCore::writeFromModel(const std::shared_ptr &model) { + mustBeInLinphoneThread(getClassName() + Q_FUNC_INFO); + + mUnreadCallNotifications = model->getMissedCallsCount(); + mUnreadMessageNotifications = model->getUnreadMessagesCount(); + mMwiServerAddress = model->getMwiServerAddress(); + mTransport = LinphoneEnums::toString(LinphoneEnums::fromLinphone(model->getTransport())); + mServerAddress = model->getServerAddress(); + mOutboundProxyEnabled = model->getOutboundProxyEnabled(); + mStunServer = model->getStunServer(); + mIceEnabled = model->getIceEnabled(); + mAvpfEnabled = model->getAvpfEnabled(); + mBundleModeEnabled = model->getBundleModeEnabled(); + mExpire = model->getExpire(); + mConferenceFactoryAddress = model->getConferenceFactoryAddress(); + mAudioVideoConferenceFactoryAddress = model->getAudioVideoConferenceFactoryAddress(); + mLimeServerUrl = model->getLimeServerUrl(); + mVoicemailAddress = model->getVoicemailAddress(); +} + +void AccountCore::save() { + mustBeInMainThread(getClassName() + Q_FUNC_INFO); + if (mAccountModel) { + AccountCore *thisCopy = new AccountCore(*this); + mAccountModelConnection->invokeToModel([this, thisCopy] { + mustBeInLinphoneThread(getClassName() + Q_FUNC_INFO); + thisCopy->writeIntoModel(mAccountModel); + thisCopy->deleteLater(); + mAccountModelConnection->invokeToCore([this]() { setIsSaved(true); }); + }); + } +} + +void AccountCore::undo() { + if (mAccountModel) { + mAccountModelConnection->invokeToModel([this] { + AccountCore *account = new AccountCore(*this); + account->writeFromModel(mAccountModel); + account->moveToThread(App::getInstance()->thread()); + mAccountModelConnection->invokeToCore([this, account]() { + this->reset(*account); + account->deleteLater(); + }); + }); + } +} \ No newline at end of file diff --git a/Linphone/core/account/AccountCore.hpp b/Linphone/core/account/AccountCore.hpp index 670e85bef..1f0b6c1c9 100644 --- a/Linphone/core/account/AccountCore.hpp +++ b/Linphone/core/account/AccountCore.hpp @@ -55,31 +55,35 @@ public: Q_PROPERTY(bool notificationsAllowed READ getNotificationsAllowed WRITE lSetNotificationsAllowed NOTIFY notificationsAllowedChanged) Q_PROPERTY( - QString mwiServerAddress READ getMwiServerAddress WRITE lSetMwiServerAddress NOTIFY mwiServerAddressChanged) + QString mwiServerAddress READ getMwiServerAddress WRITE setMwiServerAddress NOTIFY mwiServerAddressChanged) Q_PROPERTY(QStringList transports READ getTransports CONSTANT) - Q_PROPERTY(QString transport READ getTransport WRITE lSetTransport NOTIFY transportChanged) - Q_PROPERTY(QString serverAddress READ getServerAddress WRITE lSetServerAddress NOTIFY serverAddressChanged) - Q_PROPERTY(bool outboundProxyEnabled READ getOutboundProxyEnabled WRITE lSetOutboundProxyEnabled NOTIFY + Q_PROPERTY(QString transport READ getTransport WRITE setTransport NOTIFY transportChanged) + Q_PROPERTY(QString serverAddress READ getServerAddress WRITE setServerAddress NOTIFY serverAddressChanged) + Q_PROPERTY(bool outboundProxyEnabled READ getOutboundProxyEnabled WRITE setOutboundProxyEnabled NOTIFY outboundProxyEnabledChanged) - Q_PROPERTY(QString stunServer READ getStunServer WRITE lSetStunServer NOTIFY stunServerChanged) - Q_PROPERTY(bool iceEnabled READ getIceEnabled WRITE lSetIceEnabled NOTIFY iceEnabledChanged) - Q_PROPERTY(bool avpfEnabled READ getAvpfEnabled WRITE lSetAvpfEnabled NOTIFY avpfEnabledChanged) + Q_PROPERTY(QString stunServer READ getStunServer WRITE setStunServer NOTIFY stunServerChanged) + Q_PROPERTY(bool iceEnabled READ getIceEnabled WRITE setIceEnabled NOTIFY iceEnabledChanged) + Q_PROPERTY(bool avpfEnabled READ getAvpfEnabled WRITE setAvpfEnabled NOTIFY avpfEnabledChanged) Q_PROPERTY( - bool bundleModeEnabled READ getBundleModeEnabled WRITE lSetBundleModeEnabled NOTIFY bundleModeEnabledChanged) - Q_PROPERTY(int expire READ getExpire WRITE lSetExpire NOTIFY expireChanged) - Q_PROPERTY(QString conferenceFactoryAddress READ getConferenceFactoryAddress WRITE lSetConferenceFactoryAddress + bool bundleModeEnabled READ getBundleModeEnabled WRITE setBundleModeEnabled NOTIFY bundleModeEnabledChanged) + Q_PROPERTY(int expire READ getExpire WRITE setExpire NOTIFY expireChanged) + Q_PROPERTY(QString conferenceFactoryAddress READ getConferenceFactoryAddress WRITE setConferenceFactoryAddress NOTIFY conferenceFactoryAddressChanged) Q_PROPERTY(QString audioVideoConferenceFactoryAddress READ getAudioVideoConferenceFactoryAddress WRITE - lSetAudioVideoConferenceFactoryAddress NOTIFY audioVideoConferenceFactoryAddressChanged) - Q_PROPERTY(QString limeServerUrl READ getLimeServerUrl WRITE lSetLimeServerUrl NOTIFY limeServerUrlChanged) + setAudioVideoConferenceFactoryAddress NOTIFY audioVideoConferenceFactoryAddressChanged) + Q_PROPERTY(QString limeServerUrl READ getLimeServerUrl WRITE setLimeServerUrl NOTIFY limeServerUrlChanged) + Q_PROPERTY(bool isSaved READ isSaved WRITE setIsSaved NOTIFY isSavedChanged) + Q_PROPERTY( + QString voicemailAddress READ getVoicemailAddress WRITE setVoicemailAddress NOTIFY voicemailAddressChanged) DECLARE_CORE_GET(int, voicemailCount, VoicemailCount) - DECLARE_CORE_GETSET_MEMBER(QString, voicemailAddress, VoicemailAddress) static QSharedPointer create(const std::shared_ptr &account); // Should be call from model Thread. Will be automatically in App thread after initialization AccountCore(const std::shared_ptr &account); ~AccountCore(); + AccountCore(const AccountCore &accountCore); void setSelf(QSharedPointer me); + void reset(const AccountCore &accountCore); const std::shared_ptr &getModel() const; @@ -127,6 +131,24 @@ public: QString getConferenceFactoryAddress(); QString getAudioVideoConferenceFactoryAddress(); QString getLimeServerUrl(); + QString getVoicemailAddress(); + + void setMwiServerAddress(QString value); + void setTransport(QString value); + void setServerAddress(QString value); + void setOutboundProxyEnabled(bool value); + void setStunServer(QString value); + void setIceEnabled(bool value); + void setAvpfEnabled(bool value); + void setBundleModeEnabled(bool value); + void setExpire(int value); + void setConferenceFactoryAddress(QString value); + void setAudioVideoConferenceFactoryAddress(QString value); + void setLimeServerUrl(QString value); + void setVoicemailAddress(QString value); + + bool isSaved() const; + void setIsSaved(bool saved); void onNotificationsAllowedChanged(bool value); void onMwiServerAddressChanged(QString value); @@ -144,6 +166,9 @@ public: DECLARE_CORE_GET(bool, showMwi, ShowMwi) + Q_INVOKABLE void save(); + Q_INVOKABLE void undo(); + signals: void pictureUriChanged(); void registrationStateChanged(const QString &message); @@ -170,7 +195,8 @@ signals: void audioVideoConferenceFactoryAddressChanged(); void limeServerUrlChanged(); void removed(); - // void voicemailAddressChanged(); + void isSavedChanged(); + void voicemailAddressChanged(); // Account requests void lSetPictureUri(QString pictureUri); @@ -181,18 +207,10 @@ signals: void lSetDialPlan(QVariantMap internationalPrefix); void lSetRegisterEnabled(bool enabled); void lSetNotificationsAllowed(bool value); - void lSetMwiServerAddress(QString value); - void lSetTransport(QString value); - void lSetServerAddress(QString value); - void lSetOutboundProxyEnabled(bool value); - void lSetStunServer(QString value); - void lSetIceEnabled(bool value); - void lSetAvpfEnabled(bool value); - void lSetBundleModeEnabled(bool value); - void lSetExpire(int value); - void lSetConferenceFactoryAddress(QString value); - void lSetAudioVideoConferenceFactoryAddress(QString value); - void lSetLimeServerUrl(QString value); + +protected: + void writeIntoModel(std::shared_ptr model) const; + void writeFromModel(const std::shared_ptr &model); private: QString mContactAddress; @@ -222,7 +240,9 @@ private: QString mConferenceFactoryAddress; QString mAudioVideoConferenceFactoryAddress; QString mLimeServerUrl; + QString mVoicemailAddress; + bool mIsSaved = true; std::shared_ptr mAccountModel; QSharedPointer> mAccountModelConnection; QSharedPointer> mCoreModelConnection; diff --git a/Linphone/core/address-books/ldap/LdapCore.cpp b/Linphone/core/address-books/ldap/LdapCore.cpp index b0f7dc10c..33a1201cd 100644 --- a/Linphone/core/address-books/ldap/LdapCore.cpp +++ b/Linphone/core/address-books/ldap/LdapCore.cpp @@ -35,7 +35,6 @@ LdapCore::LdapCore(const std::shared_ptr &ldap mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); mLdapModel = Utils::makeQObject_ptr(ldap); - INIT_CORE_MEMBER(Enabled, mLdapModel) INIT_CORE_MEMBER(ServerUrl, mLdapModel) INIT_CORE_MEMBER(BindDn, mLdapModel) INIT_CORE_MEMBER(Password, mLdapModel) @@ -58,13 +57,6 @@ LdapCore::~LdapCore() { mustBeInMainThread(log().arg(Q_FUNC_INFO)); } -void LdapCore::save() { - mLdapModelConnection->invokeToModel([this]() { - mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); - mLdapModel->save(); - }); -} - void LdapCore::remove() { mLdapModelConnection->invokeToModel([this]() { mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); @@ -80,7 +72,6 @@ void LdapCore::setSelf(QSharedPointer me) { mLdapModelConnection = QSharedPointer>( new SafeConnection(me, mLdapModel), &QObject::deleteLater); - DEFINE_CORE_GETSET_CONNECT(mLdapModelConnection, LdapCore, LdapModel, mLdapModel, bool, enabled, Enabled) DEFINE_CORE_GETSET_CONNECT(mLdapModelConnection, LdapCore, LdapModel, mLdapModel, QString, serverUrl, ServerUrl) DEFINE_CORE_GETSET_CONNECT(mLdapModelConnection, LdapCore, LdapModel, mLdapModel, QString, bindDn, BindDn) DEFINE_CORE_GETSET_CONNECT(mLdapModelConnection, LdapCore, LdapModel, mLdapModel, QString, password, Password) @@ -110,3 +101,51 @@ void LdapCore::setSelf(QSharedPointer me) { mLdapModelConnection->invokeToCore([this]() { emit App::getInstance()->getSettings()->ldapConfigChanged(); }); }); } + +bool LdapCore::isEnabled() const { + return mEnabled; +} + +void LdapCore::setEnabled(bool enabled) { + if (mEnabled != enabled) { + mEnabled = enabled; + emit enabledChanged(); + setSaved(false); + } +} + +bool LdapCore::isSaved() const { + return mIsSaved; +} + +void LdapCore::setSaved(bool saved) { + if (mIsSaved != saved) { + mIsSaved = saved; + emit savedChanged(); + } +} + +void LdapCore::writeIntoModel(std::shared_ptr model) const { + mustBeInLinphoneThread(getClassName() + Q_FUNC_INFO); + model->setEnabled(mEnabled); +} + +void LdapCore::writeFromModel(const std::shared_ptr &model) { + mustBeInLinphoneThread(getClassName() + Q_FUNC_INFO); + setEnabled(model->getEnabled()); +} + +void LdapCore::save() { + mLdapModelConnection->invokeToModel([this]() { + mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); + mLdapModel->save(); + writeIntoModel(mLdapModel); + mLdapModelConnection->invokeToCore([this] { setSaved(true); }); + }); +} + +void LdapCore::undo() { + if (mLdapModel) { + mLdapModelConnection->invokeToModel([this] { writeFromModel(mLdapModel); }); + } +} \ No newline at end of file diff --git a/Linphone/core/address-books/ldap/LdapCore.hpp b/Linphone/core/address-books/ldap/LdapCore.hpp index 499d9da48..120c15a41 100644 --- a/Linphone/core/address-books/ldap/LdapCore.hpp +++ b/Linphone/core/address-books/ldap/LdapCore.hpp @@ -40,9 +40,12 @@ public: Q_INVOKABLE void remove(); Q_INVOKABLE void save(); + Q_INVOKABLE void undo(); Q_INVOKABLE bool isValid(); - DECLARE_CORE_GETSET_MEMBER(bool, enabled, Enabled) + Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged) + Q_PROPERTY(bool saved READ isSaved WRITE setSaved NOTIFY savedChanged) + DECLARE_CORE_GETSET_MEMBER(QString, serverUrl, ServerUrl) DECLARE_CORE_GETSET_MEMBER(QString, bindDn, BindDn) DECLARE_CORE_GETSET_MEMBER(QString, password, Password) @@ -62,7 +65,24 @@ public: DECLARE_CORE_GETSET_MEMBER(QString, sipDomain, SipDomain) DECLARE_CORE_GETSET_MEMBER(bool, debug, Debug) +public: + bool isEnabled() const; + void setEnabled(bool enabled); + + bool isSaved() const; + void setSaved(bool saved); + +signals: + void enabledChanged(); + void savedChanged(); + +protected: + void writeIntoModel(std::shared_ptr model) const; + void writeFromModel(const std::shared_ptr &model); + private: + bool mEnabled = false; + bool mIsSaved = false; std::shared_ptr mLdapModel; QSharedPointer> mLdapModelConnection; diff --git a/Linphone/core/setting/SettingsCore.cpp b/Linphone/core/setting/SettingsCore.cpp index a79f9821f..547302974 100644 --- a/Linphone/core/setting/SettingsCore.cpp +++ b/Linphone/core/setting/SettingsCore.cpp @@ -57,6 +57,7 @@ SettingsCore::SettingsCore(QObject *parent) : QObject(parent) { mRingerDevices = settingsModel->getRingerDevices(); mCaptureDevice = settingsModel->getCaptureDevice(); mPlaybackDevice = settingsModel->getPlaybackDevice(); + mRingerDevice = settingsModel->getRingerDevice(); mConferenceLayouts = LinphoneEnums::conferenceLayoutsToVariant(); mConferenceLayout = @@ -111,6 +112,74 @@ SettingsCore::SettingsCore(QObject *parent) : QObject(parent) { INIT_CORE_MEMBER(DownloadFolder, settingsModel) } +SettingsCore::SettingsCore(const SettingsCore &settingsCore) { + // Security + mVfsEnabled = settingsCore.mVfsEnabled; + mMediaEncryptions = settingsCore.mMediaEncryptions; + mMediaEncryption = settingsCore.mMediaEncryption; + mMediaEncryptionMandatory = settingsCore.mMediaEncryptionMandatory; + + // Call + mVideoEnabled = settingsCore.mVfsEnabled; + mEchoCancellationEnabled = settingsCore.mEchoCancellationEnabled; + mAutomaticallyRecordCallsEnabled = settingsCore.mAutomaticallyRecordCallsEnabled; + + // Audio + mCaptureDevices = settingsCore.mCaptureDevices; + mPlaybackDevices = settingsCore.mPlaybackDevices; + mRingerDevices = settingsCore.mRingerDevices; + mCaptureDevice = settingsCore.mCaptureDevice; + mPlaybackDevice = settingsCore.mPlaybackDevice; + mRingerDevice = settingsCore.mRingerDevice; + + mConferenceLayouts = settingsCore.mConferenceLayouts; + mConferenceLayout = settingsCore.mConferenceLayout; + + // Video + mVideoDevice = settingsCore.mVideoDevice; + mVideoDevices = settingsCore.mVideoDevices; + + mCaptureGain = settingsCore.mCaptureGain; + mPlaybackGain = settingsCore.mPlaybackGain; + + mEchoCancellationCalibration = settingsCore.mEchoCancellationCalibration; + + // Logs + mLogsEnabled = settingsCore.mLogsEnabled; + mFullLogsEnabled = settingsCore.mFullLogsEnabled; + mLogsFolder = settingsCore.mLogsFolder; + mLogsEmail = settingsCore.mLogsEmail; + + // DND + mDndEnabled = settingsCore.mDndEnabled; + + // UI + mDisableChatFeature = settingsCore.mDisableChatFeature; + mDisableMeetingsFeature = settingsCore.mDisableMeetingsFeature; + mDisableBroadcastFeature = settingsCore.mDisableBroadcastFeature; + mHideSettings = settingsCore.mHideSettings; + mHideAccountSettings = settingsCore.mHideAccountSettings; + mHideFps = settingsCore.mHideFps; + mDisableCallRecordings = settingsCore.mDisableCallRecordings; + mAssistantHideCreateAccount = settingsCore.mAssistantHideCreateAccount; + mAssistantHideCreateAccount = settingsCore.mAssistantHideCreateAccount; + mAssistantDisableQrCode = settingsCore.mAssistantDisableQrCode; + + mAssistantHideThirdPartyAccount = settingsCore.mAssistantHideThirdPartyAccount; + mOnlyDisplaySipUriUsername = settingsCore.mOnlyDisplaySipUriUsername; + mDarkModeAllowed = settingsCore.mDarkModeAllowed; + mMaxAccount = settingsCore.mMaxAccount; + mAssistantGoDirectlyToThirdPartySipAccountLogin = settingsCore.mAssistantGoDirectlyToThirdPartySipAccountLogin; + mAssistantThirdPartySipAccountDomain = settingsCore.mAssistantThirdPartySipAccountDomain; + mAssistantThirdPartySipAccountTransport = settingsCore.mAssistantThirdPartySipAccountTransport; + mAutoStart = settingsCore.mAutoStart; + mExitOnClose = settingsCore.mExitOnClose; + mSyncLdapContacts = settingsCore.mSyncLdapContacts; + mIpv6Enabled = settingsCore.mIpv6Enabled; + mConfigLocale = settingsCore.mConfigLocale; + mDownloadFolder = settingsCore.mDownloadFolder; +} + SettingsCore::~SettingsCore() { } @@ -120,116 +189,46 @@ void SettingsCore::setSelf(QSharedPointer me) { new SafeConnection(me, SettingsModel::getInstance()), &QObject::deleteLater); // VFS - mSettingsModelConnection->makeConnectToCore(&SettingsCore::setVfsEnabled, [this](const bool enabled) { - mSettingsModelConnection->invokeToModel( - [this, enabled]() { SettingsModel::getInstance()->setVfsEnabled(enabled); }); - }); - mSettingsModelConnection->makeConnectToModel(&SettingsModel::vfsEnabledChanged, [this](const bool enabled) { - mSettingsModelConnection->invokeToCore([this, enabled]() { - mVfsEnabled = enabled; - emit vfsEnabledChanged(); - }); + mSettingsModelConnection->invokeToCore([this, enabled]() { setVfsEnabled(enabled); }); }); // Video Calls - mSettingsModelConnection->makeConnectToCore(&SettingsCore::setVideoEnabled, [this](const bool enabled) { - mSettingsModelConnection->invokeToModel( - [this, enabled]() { SettingsModel::getInstance()->setVideoEnabled(enabled); }); - }); - mSettingsModelConnection->makeConnectToModel(&SettingsModel::videoEnabledChanged, [this](const bool enabled) { - mSettingsModelConnection->invokeToCore([this, enabled]() { - mVideoEnabled = enabled; - emit videoEnabledChanged(); - }); + mSettingsModelConnection->invokeToCore([this, enabled]() { setVideoEnabled(enabled); }); }); // Echo cancelling - mSettingsModelConnection->makeConnectToCore(&SettingsCore::setEchoCancellationEnabled, [this](const bool enabled) { - mSettingsModelConnection->invokeToModel( - [this, enabled]() { SettingsModel::getInstance()->setEchoCancellationEnabled(enabled); }); - }); - - mSettingsModelConnection->makeConnectToModel(&SettingsModel::echoCancellationEnabledChanged, - [this](const bool enabled) { - mSettingsModelConnection->invokeToCore([this, enabled]() { - mEchoCancellationEnabled = enabled; - emit echoCancellationEnabledChanged(); - }); - }); + mSettingsModelConnection->makeConnectToModel( + &SettingsModel::echoCancellationEnabledChanged, [this](const bool enabled) { + mSettingsModelConnection->invokeToCore([this, enabled]() { setEchoCancellationEnabled(enabled); }); + }); // Auto recording - mSettingsModelConnection->makeConnectToCore( - &SettingsCore::setAutomaticallyRecordCallsEnabled, [this](const bool enabled) { - mSettingsModelConnection->invokeToModel( - [this, enabled]() { SettingsModel::getInstance()->setAutomaticallyRecordCallsEnabled(enabled); }); + mSettingsModelConnection->makeConnectToModel( + &SettingsModel::automaticallyRecordCallsEnabledChanged, [this](const bool enabled) { + mSettingsModelConnection->invokeToCore([this, enabled]() { setAutomaticallyRecordCallsEnabled(enabled); }); }); - mSettingsModelConnection->makeConnectToModel(&SettingsModel::automaticallyRecordCallsEnabledChanged, - [this](const bool enabled) { - mSettingsModelConnection->invokeToCore([this, enabled]() { - mAutomaticallyRecordCallsEnabled = enabled; - emit automaticallyRecordCallsEnabledChanged(); - }); - }); // Audio device(s) - mSettingsModelConnection->makeConnectToCore(&SettingsCore::lSetCaptureDevice, [this](QVariantMap device) { - mSettingsModelConnection->invokeToModel( - [this, device]() { SettingsModel::getInstance()->setCaptureDevice(device); }); - }); mSettingsModelConnection->makeConnectToModel(&SettingsModel::captureDeviceChanged, [this](QVariantMap device) { - mSettingsModelConnection->invokeToCore([this, device]() { - mCaptureDevice = device; - emit captureDeviceChanged(device); - }); - }); - - mSettingsModelConnection->makeConnectToCore(&SettingsCore::lSetPlaybackDevice, [this](QVariantMap device) { - mSettingsModelConnection->invokeToModel( - [this, device]() { SettingsModel::getInstance()->setPlaybackDevice(device); }); + mSettingsModelConnection->invokeToCore([this, device]() { setCaptureDevice(device); }); }); mSettingsModelConnection->makeConnectToModel(&SettingsModel::playbackDeviceChanged, [this](QVariantMap device) { - mSettingsModelConnection->invokeToCore([this, device]() { - mPlaybackDevice = device; - emit playbackDeviceChanged(device); - }); - }); - mSettingsModelConnection->makeConnectToCore(&SettingsCore::lSetRingerDevice, [this](QVariantMap device) { - mSettingsModelConnection->invokeToModel( - [this, device]() { SettingsModel::getInstance()->setRingerDevice(device); }); + mSettingsModelConnection->invokeToCore([this, device]() { setPlaybackDevice(device); }); }); mSettingsModelConnection->makeConnectToModel(&SettingsModel::ringerDeviceChanged, [this](QVariantMap device) { - mSettingsModelConnection->invokeToCore([this, device]() { - mRingerDevice = device; - emit ringerDeviceChanged(device); - }); - }); - - mSettingsModelConnection->makeConnectToCore(&SettingsCore::lSetPlaybackGain, [this](const float value) { - mSettingsModelConnection->invokeToModel( - [this, value]() { SettingsModel::getInstance()->setPlaybackGain(value); }); + mSettingsModelConnection->invokeToCore([this, device]() { setRingerDevice(device); }); }); mSettingsModelConnection->makeConnectToModel(&SettingsModel::playbackGainChanged, [this](const float value) { - mSettingsModelConnection->invokeToCore([this, value]() { - mPlaybackGain = value; - emit playbackGainChanged(value); - }); - }); - - mSettingsModelConnection->makeConnectToCore(&SettingsCore::lSetCaptureGain, [this](const float value) { - mSettingsModelConnection->invokeToModel( - [this, value]() { SettingsModel::getInstance()->setCaptureGain(value); }); + mSettingsModelConnection->invokeToCore([this, value]() { setPlaybackGain(value); }); }); mSettingsModelConnection->makeConnectToModel(&SettingsModel::captureGainChanged, [this](const float value) { - mSettingsModelConnection->invokeToCore([this, value]() { - mCaptureGain = value; - emit captureGainChanged(value); - }); + mSettingsModelConnection->invokeToCore([this, value]() { setCaptureGain(value); }); }); mSettingsModelConnection->makeConnectToModel(&SettingsModel::micVolumeChanged, [this](const float value) { @@ -237,108 +236,50 @@ void SettingsCore::setSelf(QSharedPointer me) { }); mSettingsModelConnection->makeConnectToModel(&SettingsModel::captureDevicesChanged, [this](QVariantList devices) { - mSettingsModelConnection->invokeToCore([this, devices]() { - mCaptureDevices = devices; - emit captureDevicesChanged(devices); - }); + mSettingsModelConnection->invokeToCore([this, devices]() { setCaptureDevices(devices); }); }); mSettingsModelConnection->makeConnectToModel(&SettingsModel::playbackDevicesChanged, [this](QVariantList devices) { - mSettingsModelConnection->invokeToCore([this, devices]() { - mPlaybackDevices = devices; - emit playbackDevicesChanged(devices); - }); + mSettingsModelConnection->invokeToCore([this, devices]() { setPlaybackDevices(devices); }); }); mSettingsModelConnection->makeConnectToModel(&SettingsModel::ringerDevicesChanged, [this](QVariantList devices) { - mSettingsModelConnection->invokeToCore([this, devices]() { - mRingerDevices = devices; - emit ringerDevicesChanged(devices); - }); + mSettingsModelConnection->invokeToCore([this, devices]() { setRingerDevices(devices); }); }); // Video device(s) - mSettingsModelConnection->makeConnectToCore(&SettingsCore::lSetVideoDevice, [this](const QString id) { - mSettingsModelConnection->invokeToModel([this, id]() { SettingsModel::getInstance()->setVideoDevice(id); }); - }); - mSettingsModelConnection->makeConnectToModel(&SettingsModel::videoDeviceChanged, [this](const QString device) { - mSettingsModelConnection->invokeToCore([this, device]() { - mVideoDevice = device; - emit videoDeviceChanged(); - }); + mSettingsModelConnection->invokeToCore([this, device]() { setVideoDevice(device); }); }); - mSettingsModelConnection->makeConnectToCore(&SettingsCore::lSetConferenceLayout, [this](QVariantMap layout) { - auto linLayout = LinphoneEnums::toLinphone(LinphoneEnums::ConferenceLayout(layout["id"].toInt())); - mSettingsModelConnection->invokeToModel( - [this, linLayout]() { SettingsModel::getInstance()->setDefaultConferenceLayout(linLayout); }); - }); mSettingsModelConnection->makeConnectToModel(&SettingsModel::conferenceLayoutChanged, [this]() { auto layout = LinphoneEnums::fromLinphone(SettingsModel::getInstance()->getDefaultConferenceLayout()); - mSettingsModelConnection->invokeToCore([this, layout]() { - mConferenceLayout = LinphoneEnums::toVariant(layout); - emit conferenceLayoutChanged(); - }); + mSettingsModelConnection->invokeToCore( + [this, layout]() { setConferenceLayout(LinphoneEnums::toVariant(layout)); }); }); - mSettingsModelConnection->makeConnectToCore( - &SettingsCore::lSetMediaEncryption, [this](const QVariantMap &encryption) { - auto linEncryption = LinphoneEnums::toLinphone(LinphoneEnums::MediaEncryption(encryption["id"].toInt())); - mSettingsModelConnection->invokeToModel( - [this, linEncryption]() { SettingsModel::getInstance()->setDefaultMediaEncryption(linEncryption); }); - }); mSettingsModelConnection->makeConnectToModel(&SettingsModel::mediaEncryptionChanged, [this]() { auto encryption = LinphoneEnums::toVariant( LinphoneEnums::fromLinphone(SettingsModel::getInstance()->getDefaultMediaEncryption())); - mSettingsModelConnection->invokeToCore([this, encryption]() { - mMediaEncryption = encryption; - emit mediaEncryptionChanged(); - }); + mSettingsModelConnection->invokeToCore([this, encryption]() { setMediaEncryption(encryption); }); }); - mSettingsModelConnection->makeConnectToCore(&SettingsCore::lSetMediaEncryptionMandatory, [this](bool mandatory) { - mSettingsModelConnection->invokeToModel( - [this, mandatory]() { SettingsModel::getInstance()->setMediaEncryptionMandatory(mandatory); }); - }); mSettingsModelConnection->makeConnectToModel(&SettingsModel::mediaEncryptionMandatoryChanged, [this]() { auto mandatory = SettingsModel::getInstance()->getMediaEncryptionMandatory(); - mSettingsModelConnection->invokeToCore([this, mandatory]() { - mMediaEncryptionMandatory = mandatory; - emit mediaEncryptionMandatoryChanged(mandatory); - }); + mSettingsModelConnection->invokeToCore([this, mandatory]() { setMediaEncryptionMandatory(mandatory); }); }); - mSettingsModelConnection->makeConnectToModel(&SettingsModel::videoDevicesChanged, - [this](const QStringList devices) { - mSettingsModelConnection->invokeToCore([this, devices]() { - mVideoDevices = devices; - emit videoDevicesChanged(); - }); - }); + mSettingsModelConnection->makeConnectToModel( + &SettingsModel::videoDevicesChanged, [this](const QStringList devices) { + mSettingsModelConnection->invokeToCore([this, devices]() { setVideoDevices(devices); }); + }); // Logs - mSettingsModelConnection->makeConnectToCore(&SettingsCore::setLogsEnabled, [this](const bool status) { - mSettingsModelConnection->invokeToModel( - [this, status]() { SettingsModel::getInstance()->setLogsEnabled(status); }); - }); - mSettingsModelConnection->makeConnectToModel(&SettingsModel::logsEnabledChanged, [this](const bool status) { - mSettingsModelConnection->invokeToCore([this, status]() { - mLogsEnabled = status; - emit logsEnabledChanged(); - }); - }); - - mSettingsModelConnection->makeConnectToCore(&SettingsCore::setFullLogsEnabled, [this](const bool status) { - mSettingsModelConnection->invokeToModel( - [this, status]() { SettingsModel::getInstance()->setFullLogsEnabled(status); }); + mSettingsModelConnection->invokeToCore([this, status]() { setLogsEnabled(status); }); }); mSettingsModelConnection->makeConnectToModel(&SettingsModel::fullLogsEnabledChanged, [this](const bool status) { - mSettingsModelConnection->invokeToCore([this, status]() { - mFullLogsEnabled = status; - emit fullLogsEnabledChanged(); - }); + mSettingsModelConnection->invokeToCore([this, status]() { setFullLogsEnabled(status); }); }); // DND @@ -346,10 +287,7 @@ void SettingsCore::setSelf(QSharedPointer me) { mSettingsModelConnection->invokeToModel([this, value]() { SettingsModel::getInstance()->enableDnd(value); }); }); mSettingsModelConnection->makeConnectToModel(&SettingsModel::dndChanged, [this](const bool value) { - mSettingsModelConnection->invokeToCore([this, value]() { - mDndEnabled = value; - emit dndChanged(); - }); + mSettingsModelConnection->invokeToCore([this, value]() { setDndEnabled(value); }); }); auto settingsModel = SettingsModel::getInstance(); @@ -417,6 +355,72 @@ void SettingsCore::setSelf(QSharedPointer me) { }); } +void SettingsCore::reset(const SettingsCore &settingsCore) { + // Security + setVfsEnabled(settingsCore.mVfsEnabled); + + // Call + setVideoEnabled(settingsCore.mVfsEnabled); + setEchoCancellationEnabled(settingsCore.mEchoCancellationEnabled); + setAutomaticallyRecordCallsEnabled(settingsCore.mAutomaticallyRecordCallsEnabled); + + // Audio + setCaptureDevices(settingsCore.mCaptureDevices); + setPlaybackDevices(settingsCore.mPlaybackDevices); + setRingerDevices(settingsCore.mRingerDevices); + setCaptureDevice(settingsCore.mCaptureDevice); + setPlaybackDevice(settingsCore.mPlaybackDevice); + + setConferenceLayouts(settingsCore.mConferenceLayouts); + setConferenceLayout(settingsCore.mConferenceLayout); + + setMediaEncryptions(settingsCore.mMediaEncryptions); + setMediaEncryption(settingsCore.mMediaEncryption); + + setMediaEncryptionMandatory(settingsCore.mMediaEncryptionMandatory); + + setCaptureGain(settingsCore.mCaptureGain); + setPlaybackGain(settingsCore.mPlaybackGain); + + // Video + setVideoDevice(settingsCore.mVideoDevice); + setVideoDevices(settingsCore.mVideoDevices); + + // Logs + setLogsEnabled(settingsCore.mLogsEnabled); + setFullLogsEnabled(settingsCore.mFullLogsEnabled); + setLogsFolder(settingsCore.mLogsFolder); + + // DND + setDndEnabled(settingsCore.mDndEnabled); + + // UI + setDisableChatFeature(settingsCore.mDisableChatFeature); + setDisableMeetingsFeature(settingsCore.mDisableMeetingsFeature); + setDisableBroadcastFeature(settingsCore.mDisableBroadcastFeature); + setHideSettings(settingsCore.mHideSettings); + setHideAccountSettings(settingsCore.mHideAccountSettings); + setHideFps(settingsCore.mHideFps); + setDisableCallRecordings(settingsCore.mDisableCallRecordings); + setAssistantHideCreateAccount(settingsCore.mAssistantHideCreateAccount); + setAssistantHideCreateAccount(settingsCore.mAssistantHideCreateAccount); + setAssistantDisableQrCode(settingsCore.mAssistantDisableQrCode); + + setAssistantHideThirdPartyAccount(settingsCore.mAssistantHideThirdPartyAccount); + setOnlyDisplaySipUriUsername(settingsCore.mOnlyDisplaySipUriUsername); + setDarkModeAllowed(settingsCore.mDarkModeAllowed); + setMaxAccount(settingsCore.mMaxAccount); + setAssistantGoDirectlyToThirdPartySipAccountLogin(settingsCore.mAssistantGoDirectlyToThirdPartySipAccountLogin); + setAssistantThirdPartySipAccountDomain(settingsCore.mAssistantThirdPartySipAccountDomain); + setAssistantThirdPartySipAccountTransport(settingsCore.mAssistantThirdPartySipAccountTransport); + setAutoStart(settingsCore.mAutoStart); + setExitOnClose(settingsCore.mExitOnClose); + setSyncLdapContacts(settingsCore.mSyncLdapContacts); + setIpv6Enabled(settingsCore.mIpv6Enabled); + setConfigLocale(settingsCore.mConfigLocale); + setDownloadFolder(settingsCore.mDownloadFolder); +} + QString SettingsCore::getConfigPath(const QCommandLineParser &parser) { QString filePath = parser.isSet("config") ? parser.value("config") : ""; QString configPath; @@ -429,30 +433,122 @@ QString SettingsCore::getConfigPath(const QCommandLineParser &parser) { return configPath; } +void SettingsCore::setVfsEnabled(bool enabled) { + if (mVfsEnabled != enabled) { + mVfsEnabled = enabled; + emit vfsEnabledChanged(); + setIsSaved(false); + } +} + +void SettingsCore::setVideoEnabled(bool enabled) { + if (mVideoEnabled != enabled) { + mVideoEnabled = enabled; + emit videoEnabledChanged(); + setIsSaved(false); + } +} + +void SettingsCore::setEchoCancellationEnabled(bool enabled) { + if (mEchoCancellationEnabled != enabled) { + mEchoCancellationEnabled = enabled; + emit echoCancellationEnabledChanged(); + setIsSaved(false); + } +} + +void SettingsCore::setAutomaticallyRecordCallsEnabled(bool enabled) { + if (mAutomaticallyRecordCallsEnabled != enabled) { + mAutomaticallyRecordCallsEnabled = enabled; + emit automaticallyRecordCallsEnabledChanged(); + setIsSaved(false); + } +} + QVariantList SettingsCore::getCaptureDevices() const { return mCaptureDevices; } +void SettingsCore::setCaptureDevices(QVariantList devices) { + mCaptureDevices = devices; + emit captureDevicesChanged(devices); +} + QVariantList SettingsCore::getPlaybackDevices() const { return mPlaybackDevices; } +void SettingsCore::setPlaybackDevices(QVariantList devices) { + mPlaybackDevices = devices; + emit captureDevicesChanged(devices); +} + QVariantList SettingsCore::getRingerDevices() const { return mRingerDevices; } +void SettingsCore::setRingerDevices(QVariantList devices) { + mRingerDevices = devices; + emit captureDevicesChanged(devices); +} + QVariantList SettingsCore::getConferenceLayouts() const { return mConferenceLayouts; } +void SettingsCore::setConferenceLayouts(QVariantList layouts) { + mConferenceLayouts = layouts; + emit conferenceLayoutsChanged(layouts); +} + QVariantList SettingsCore::getMediaEncryptions() const { return mMediaEncryptions; } +void SettingsCore::setMediaEncryptions(QVariantList encryptions) { + mMediaEncryptions = encryptions; + emit mediaEncryptionsChanged(encryptions); +} + bool SettingsCore::isMediaEncryptionMandatory() const { return mMediaEncryptionMandatory; } +void SettingsCore::setMediaEncryptionMandatory(bool mandatory) { + if (mMediaEncryptionMandatory != mandatory) { + mMediaEncryptionMandatory = mandatory; + emit mediaEncryptionMandatoryChanged(mandatory); + setIsSaved(false); + } +} + +bool SettingsCore::isSaved() const { + return mIsSaved; +} + +void SettingsCore::setIsSaved(bool saved) { + if (mIsSaved != saved) { + mIsSaved = saved; + emit isSavedChanged(); + } +} + +void SettingsCore::setVideoDevice(QString device) { + if (mVideoDevice != device) { + mVideoDevice = device; + emit videoDeviceChanged(); + setIsSaved(false); + } +} + +void SettingsCore::setVideoDevices(QStringList devices) { + if (mVideoDevices != devices) { + mVideoDevices = devices; + emit videoDevicesChanged(); + setIsSaved(false); + } +} + int SettingsCore::getVideoDeviceIndex() const { return mVideoDevices.indexOf(mVideoDevice); } @@ -469,30 +565,86 @@ float SettingsCore::getCaptureGain() const { return mCaptureGain; } +void SettingsCore::setCaptureGain(float gain) { + if (mCaptureGain != gain) { + mCaptureGain = gain; + emit captureGainChanged(gain); + setIsSaved(false); + } +} + QVariantMap SettingsCore::getConferenceLayout() const { return mConferenceLayout; } +void SettingsCore::setConferenceLayout(QVariantMap layout) { + if (mConferenceLayout["id"] != layout["id"]) { + mConferenceLayout = layout; + emit conferenceLayoutChanged(); + setIsSaved(false); + } +} + QVariantMap SettingsCore::getMediaEncryption() const { return mMediaEncryption; } +void SettingsCore::setMediaEncryption(QVariantMap encryption) { + if (mMediaEncryption != encryption) { + mMediaEncryption = encryption; + emit mediaEncryptionChanged(); + setIsSaved(false); + } +} + float SettingsCore::getPlaybackGain() const { return mPlaybackGain; } +void SettingsCore::setPlaybackGain(float gain) { + if (mPlaybackGain != gain) { + mPlaybackGain = gain; + emit playbackGainChanged(gain); + setIsSaved(false); + } +} + QVariantMap SettingsCore::getCaptureDevice() const { return mCaptureDevice; } +void SettingsCore::setCaptureDevice(QVariantMap device) { + if (mCaptureDevice["id"] != device["id"]) { + mCaptureDevice = device; + emit captureDeviceChanged(device); + setIsSaved(false); + } +} + QVariantMap SettingsCore::getPlaybackDevice() const { return mPlaybackDevice; } +void SettingsCore::setPlaybackDevice(QVariantMap device) { + if (mPlaybackDevice["id"] != device["id"]) { + mPlaybackDevice = device; + emit playbackDeviceChanged(device); + setIsSaved(false); + } +} + QVariantMap SettingsCore::getRingerDevice() const { return mRingerDevice; } +void SettingsCore::setRingerDevice(QVariantMap device) { + if (mRingerDevice["id"] != device["id"]) { + mRingerDevice = device; + emit ringerDeviceChanged(mRingerDevice); + setIsSaved(false); + } +} + int SettingsCore::getEchoCancellationCalibration() const { return mEchoCancellationCalibration; } @@ -557,10 +709,26 @@ bool SettingsCore::getLogsEnabled() const { return mLogsEnabled; } +void SettingsCore::setLogsEnabled(bool enabled) { + if (mLogsEnabled != enabled) { + mLogsEnabled = enabled; + emit logsEnabledChanged(); + setIsSaved(false); + } +} + bool SettingsCore::getFullLogsEnabled() const { return mFullLogsEnabled; } +void SettingsCore::setFullLogsEnabled(bool enabled) { + if (mFullLogsEnabled != enabled) { + mFullLogsEnabled = enabled; + emit fullLogsEnabledChanged(); + setIsSaved(false); + } +} + void SettingsCore::cleanLogs() const { mSettingsModelConnection->invokeToModel([this]() { SettingsModel::getInstance()->cleanLogs(); }); } @@ -577,10 +745,25 @@ QString SettingsCore::getLogsFolder() const { return mLogsFolder; } +void SettingsCore::setLogsFolder(QString folder) { + if (mLogsFolder != folder) { + mLogsFolder = folder; + emit logsFolderChanged(folder); + setIsSaved(false); + } +} + bool SettingsCore::dndEnabled() const { return mDndEnabled; } +void SettingsCore::setDndEnabled(bool enabled) { + if (mDndEnabled != enabled) { + mDndEnabled = enabled; + emit dndChanged(); + } +} + bool SettingsCore::getAutoStart() const { return mAutoStart; } @@ -602,3 +785,155 @@ QString SettingsCore::getDownloadFolder() const { if (mDownloadFolder.isEmpty()) path = Paths::getDownloadDirPath(); return QDir::cleanPath(path) + QDir::separator(); } + +void SettingsCore::writeIntoModel(std::shared_ptr model) const { + mustBeInLinphoneThread(getClassName() + Q_FUNC_INFO); + // Security + model->setVfsEnabled(mVfsEnabled); + + // Call + model->setVideoEnabled(mVfsEnabled); + model->setEchoCancellationEnabled(mEchoCancellationEnabled); + model->setAutomaticallyRecordCallsEnabled(mAutomaticallyRecordCallsEnabled); + + // Audio + model->setRingerDevice(mRingerDevice); + model->setCaptureDevice(mCaptureDevice); + model->setPlaybackDevice(mPlaybackDevice); + + model->setDefaultConferenceLayout( + LinphoneEnums::toLinphone(LinphoneEnums::ConferenceLayout(mConferenceLayout["id"].toInt()))); + + model->setDefaultMediaEncryption( + LinphoneEnums::toLinphone(LinphoneEnums::MediaEncryption(mMediaEncryption["id"].toInt()))); + + model->setMediaEncryptionMandatory(mMediaEncryptionMandatory); + + model->setCaptureGain(mCaptureGain); + model->setPlaybackGain(mPlaybackGain); + + // Video + model->setVideoDevice(mVideoDevice); + + // Logs + model->setLogsEnabled(mLogsEnabled); + model->setFullLogsEnabled(mFullLogsEnabled); + + // UI + model->setDisableChatFeature(mDisableChatFeature); + model->setDisableMeetingsFeature(mDisableMeetingsFeature); + model->setDisableBroadcastFeature(mDisableBroadcastFeature); + model->setHideSettings(mHideSettings); + model->setHideAccountSettings(mHideAccountSettings); + model->setHideFps(mHideFps); + model->setDisableCallRecordings(mDisableCallRecordings); + model->setAssistantHideCreateAccount(mAssistantHideCreateAccount); + model->setAssistantHideCreateAccount(mAssistantHideCreateAccount); + model->setAssistantDisableQrCode(mAssistantDisableQrCode); + + model->setAssistantHideThirdPartyAccount(mAssistantHideThirdPartyAccount); + model->setOnlyDisplaySipUriUsername(mOnlyDisplaySipUriUsername); + model->setDarkModeAllowed(mDarkModeAllowed); + model->setMaxAccount(mMaxAccount); + model->setAssistantGoDirectlyToThirdPartySipAccountLogin(mAssistantGoDirectlyToThirdPartySipAccountLogin); + model->setAssistantThirdPartySipAccountDomain(mAssistantThirdPartySipAccountDomain); + model->setAssistantThirdPartySipAccountTransport(mAssistantThirdPartySipAccountTransport); + model->setAutoStart(mAutoStart); + model->setExitOnClose(mExitOnClose); + model->setSyncLdapContacts(mSyncLdapContacts); + model->setIpv6Enabled(mIpv6Enabled); + model->setConfigLocale(mConfigLocale); + model->setDownloadFolder(mDownloadFolder); +} + +void SettingsCore::writeFromModel(const std::shared_ptr &model) { + mustBeInLinphoneThread(getClassName() + Q_FUNC_INFO); + + // Security + mVfsEnabled = model->getVfsEnabled(); + + // Call + mVideoEnabled = model->getVideoEnabled(); + mEchoCancellationEnabled = model->getEchoCancellationEnabled(); + mAutomaticallyRecordCallsEnabled = model->getAutomaticallyRecordCallsEnabled(); + + // Audio + mCaptureDevices = model->getCaptureDevices(); + mPlaybackDevices = model->getPlaybackDevices(); + mRingerDevices = model->getRingerDevices(); + mRingerDevice = model->getRingerDevice(); + mCaptureDevice = model->getCaptureDevice(); + mPlaybackDevice = model->getPlaybackDevice(); + + mConferenceLayout = LinphoneEnums::toVariant(LinphoneEnums::fromLinphone(model->getDefaultConferenceLayout())); + + mMediaEncryption = LinphoneEnums::toVariant(LinphoneEnums::fromLinphone(model->getDefaultMediaEncryption())); + + mMediaEncryptionMandatory = model->getMediaEncryptionMandatory(); + + mCaptureGain = model->getCaptureGain(); + mPlaybackGain = model->getPlaybackGain(); + + // Video + mVideoDevice = model->getVideoDevice(); + mVideoDevices = model->getVideoDevices(); + + // Logs + mLogsEnabled = model->getLogsEnabled(); + mFullLogsEnabled = model->getFullLogsEnabled(); + mLogsFolder = model->getLogsFolder(); + mLogsEmail = model->getLogsEmail(); + + // UI + mDisableChatFeature = model->getDisableChatFeature(); + mDisableMeetingsFeature = model->getDisableMeetingsFeature(); + mDisableBroadcastFeature = model->getDisableBroadcastFeature(); + mHideSettings = model->getHideSettings(); + mHideAccountSettings = model->getHideAccountSettings(); + mHideFps = model->getHideFps(); + mDisableCallRecordings = model->getDisableCallRecordings(); + mAssistantHideCreateAccount = model->getAssistantHideCreateAccount(); + mAssistantHideCreateAccount = model->getAssistantHideCreateAccount(); + mAssistantDisableQrCode = model->getAssistantDisableQrCode(); + + mAssistantHideThirdPartyAccount = model->getAssistantHideThirdPartyAccount(); + mOnlyDisplaySipUriUsername = model->getOnlyDisplaySipUriUsername(); + mDarkModeAllowed = model->getDarkModeAllowed(); + mMaxAccount = model->getMaxAccount(); + mAssistantGoDirectlyToThirdPartySipAccountLogin = model->getAssistantGoDirectlyToThirdPartySipAccountLogin(); + mAssistantThirdPartySipAccountDomain = model->getAssistantThirdPartySipAccountDomain(); + mAssistantThirdPartySipAccountTransport = model->getAssistantThirdPartySipAccountTransport(); + mAutoStart = model->getAutoStart(); + mExitOnClose = model->getExitOnClose(); + mSyncLdapContacts = model->getSyncLdapContacts(); + mIpv6Enabled = model->getIpv6Enabled(); + mConfigLocale = model->getConfigLocale(); + mDownloadFolder = model->getDownloadFolder(); +} + +void SettingsCore::save() { + mustBeInMainThread(getClassName() + Q_FUNC_INFO); + SettingsCore *thisCopy = new SettingsCore(*this); + if (SettingsModel::getInstance()) { + mSettingsModelConnection->invokeToModel([this, thisCopy] { + mustBeInLinphoneThread(getClassName() + Q_FUNC_INFO); + thisCopy->writeIntoModel(SettingsModel::getInstance()); + thisCopy->deleteLater(); + mSettingsModelConnection->invokeToCore([this]() { setIsSaved(true); }); + }); + } +} + +void SettingsCore::undo() { + if (SettingsModel::getInstance()) { + mSettingsModelConnection->invokeToModel([this] { + SettingsCore *settings = new SettingsCore(*this); + settings->writeFromModel(SettingsModel::getInstance()); + settings->moveToThread(App::getInstance()->thread()); + mSettingsModelConnection->invokeToCore([this, settings]() { + this->reset(*settings); + settings->deleteLater(); + }); + }); + } +} \ No newline at end of file diff --git a/Linphone/core/setting/SettingsCore.hpp b/Linphone/core/setting/SettingsCore.hpp index cbc03cdb5..fb262aebf 100644 --- a/Linphone/core/setting/SettingsCore.hpp +++ b/Linphone/core/setting/SettingsCore.hpp @@ -53,22 +53,22 @@ public: Q_PROPERTY(QVariantList conferenceLayouts READ getConferenceLayouts NOTIFY conferenceLayoutsChanged) Q_PROPERTY(QVariantList mediaEncryptions READ getMediaEncryptions NOTIFY mediaEncryptionsChanged) - Q_PROPERTY(float playbackGain READ getPlaybackGain WRITE lSetPlaybackGain NOTIFY playbackGainChanged) - Q_PROPERTY(float captureGain READ getCaptureGain WRITE lSetCaptureGain NOTIFY captureGainChanged) + Q_PROPERTY(float playbackGain READ getPlaybackGain WRITE setPlaybackGain NOTIFY playbackGainChanged) + Q_PROPERTY(float captureGain READ getCaptureGain WRITE setCaptureGain NOTIFY captureGainChanged) - Q_PROPERTY(QVariantMap captureDevice READ getCaptureDevice WRITE lSetCaptureDevice NOTIFY captureDeviceChanged) - Q_PROPERTY(QVariantMap playbackDevice READ getPlaybackDevice WRITE lSetPlaybackDevice NOTIFY playbackDeviceChanged) - Q_PROPERTY(QVariantMap ringerDevice READ getRingerDevice WRITE lSetRingerDevice NOTIFY ringerDeviceChanged) + Q_PROPERTY(QVariantMap captureDevice READ getCaptureDevice WRITE setCaptureDevice NOTIFY captureDeviceChanged) + Q_PROPERTY(QVariantMap playbackDevice READ getPlaybackDevice WRITE setPlaybackDevice NOTIFY playbackDeviceChanged) + Q_PROPERTY(QVariantMap ringerDevice READ getRingerDevice WRITE setRingerDevice NOTIFY ringerDeviceChanged) Q_PROPERTY( - QVariantMap conferenceLayout READ getConferenceLayout WRITE lSetConferenceLayout NOTIFY conferenceLayoutChanged) + QVariantMap conferenceLayout READ getConferenceLayout WRITE setConferenceLayout NOTIFY conferenceLayoutChanged) Q_PROPERTY( - QVariantMap mediaEncryption READ getMediaEncryption WRITE lSetMediaEncryption NOTIFY mediaEncryptionChanged) - Q_PROPERTY(bool mediaEncryptionMandatory READ isMediaEncryptionMandatory WRITE lSetMediaEncryptionMandatory NOTIFY + QVariantMap mediaEncryption READ getMediaEncryption WRITE setMediaEncryption NOTIFY mediaEncryptionChanged) + Q_PROPERTY(bool mediaEncryptionMandatory READ isMediaEncryptionMandatory WRITE setMediaEncryptionMandatory NOTIFY mediaEncryptionMandatoryChanged) Q_PROPERTY(QStringList videoDevices READ getVideoDevices NOTIFY videoDevicesChanged) - Q_PROPERTY(QString videoDevice READ getVideoDevice WRITE lSetVideoDevice NOTIFY videoDeviceChanged) + Q_PROPERTY(QString videoDevice READ getVideoDevice WRITE setVideoDevice NOTIFY videoDeviceChanged) Q_PROPERTY(int videoDeviceIndex READ getVideoDeviceIndex NOTIFY videoDeviceChanged) Q_PROPERTY(float micVolume MEMBER _dummy_int NOTIFY micVolumeChanged) @@ -78,12 +78,15 @@ public: Q_PROPERTY(QString logsEmail READ getLogsEmail) Q_PROPERTY(QString logsFolder READ getLogsFolder) Q_PROPERTY(bool dnd READ dndEnabled WRITE lEnableDnd NOTIFY dndChanged) + Q_PROPERTY(bool isSaved READ isSaved WRITE setIsSaved NOTIFY isSavedChanged) static QSharedPointer create(); SettingsCore(QObject *parent = Q_NULLPTR); + SettingsCore(const SettingsCore &settingsCore); virtual ~SettingsCore(); void setSelf(QSharedPointer me); + void reset(const SettingsCore &settingsCore); QString getConfigPath(const QCommandLineParser &parser = QCommandLineParser()); @@ -101,42 +104,64 @@ public: bool getVfsEnabled() { return mVfsEnabled; } + void setVfsEnabled(bool enabled); // Call. -------------------------------------------------------------------- bool getVideoEnabled() { return mVideoEnabled; } + void setVideoEnabled(bool enabled); + bool getEchoCancellationEnabled() { return mEchoCancellationEnabled; } + void setEchoCancellationEnabled(bool enabled); + bool getAutomaticallyRecordCallsEnabled() { return mAutomaticallyRecordCallsEnabled; } + void setAutomaticallyRecordCallsEnabled(bool enabled); float getPlaybackGain() const; + void setPlaybackGain(float gain); float getCaptureGain() const; - - QVariantMap getMediaEncryption() const; - bool isMediaEncryptionMandatory() const; + void setCaptureGain(float gain); QVariantList getCaptureDevices() const; + void setCaptureDevices(QVariantList devices); QVariantList getPlaybackDevices() const; + void setPlaybackDevices(QVariantList devices); QVariantList getRingerDevices() const; + void setRingerDevices(QVariantList devices); QVariantList getConferenceLayouts() const; + void setConferenceLayouts(QVariantList layouts); QVariantList getMediaEncryptions() const; + void setMediaEncryptions(QVariantList encryptions); QVariantMap getCaptureDevice() const; + void setCaptureDevice(QVariantMap device); QVariantMap getPlaybackDevice() const; + void setPlaybackDevice(QVariantMap device); QVariantMap getRingerDevice() const; + void setRingerDevice(QVariantMap device); QVariantMap getConferenceLayout() const; + void setConferenceLayout(QVariantMap layout); + QVariantMap getMediaEncryption() const; + void setMediaEncryption(QVariantMap encryption); + bool isMediaEncryptionMandatory() const; + void setMediaEncryptionMandatory(bool mandatory); + bool isSaved() const; + void setIsSaved(bool saved); QString getVideoDevice() const { return mVideoDevice; } + void setVideoDevice(QString device); int getVideoDeviceIndex() const; QStringList getVideoDevices() const; + void setVideoDevices(QStringList devices); bool getCaptureGraphRunning(); @@ -148,14 +173,22 @@ public: Q_INVOKABLE void updateMicVolume() const; bool getLogsEnabled() const; + void setLogsEnabled(bool enabled); + bool getFullLogsEnabled() const; + void setFullLogsEnabled(bool enabled); Q_INVOKABLE void cleanLogs() const; Q_INVOKABLE void sendLogs() const; QString getLogsEmail() const; QString getLogsFolder() const; + void setLogsFolder(QString folder); bool dndEnabled() const; + void setDndEnabled(bool enabled); + + Q_INVOKABLE void save(); + Q_INVOKABLE void undo(); DECLARE_CORE_GETSET_MEMBER(bool, disableChatFeature, DisableChatFeature) DECLARE_CORE_GETSET_MEMBER(bool, disableMeetingsFeature, DisableMeetingsFeature) @@ -187,17 +220,13 @@ public: signals: // Security - void setVfsEnabled(const bool enabled); void vfsEnabledChanged(); // Call - void setVideoEnabled(const bool enabled); void videoEnabledChanged(); - void setEchoCancellationEnabled(const bool enabled); void echoCancellationEnabledChanged(); - void setAutomaticallyRecordCallsEnabled(const bool enabled); void automaticallyRecordCallsEnabledChanged(); void captureGraphRunningChanged(bool running); @@ -211,42 +240,30 @@ signals: void conferenceLayoutsChanged(const QVariantList &layouts); void mediaEncryptionsChanged(const QVariantList &encryptions); - void lSetCaptureDevice(const QVariantMap &device); void captureDeviceChanged(const QVariantMap &device); - void lSetConferenceLayout(QVariantMap confLayout); void conferenceLayoutChanged(); - void lSetMediaEncryption(const QVariantMap &id); void mediaEncryptionChanged(); - void lSetMediaEncryptionMandatory(bool mandatory); void mediaEncryptionMandatoryChanged(bool mandatory); - void lSetPlaybackDevice(const QVariantMap &device); + void isSavedChanged(); + void playbackDeviceChanged(const QVariantMap &device); - void lSetRingerDevice(const QVariantMap &device); void ringerDeviceChanged(const QVariantMap &device); - void lSetVideoDevice(const QString &device); void videoDeviceChanged(); void videoDevicesChanged(); - void lSetCaptureGain(float gain); - void lSetPlaybackGain(float gain); - void echoCancellationCalibrationChanged(); void micVolumeChanged(float volume); void logsEnabledChanged(); void fullLogsEnabledChanged(); - void setLogsEnabled(bool status); - void setFullLogsEnabled(bool status); - void logsUploadTerminated(bool status, QString url); - void logsEmailChanged(const QString &email); void logsFolderChanged(const QString &folder); void firstLaunchChanged(bool firstLaunch); @@ -255,10 +272,15 @@ signals: void lastActiveTabIndexChanged(); void dndChanged(); - void lEnableDnd(bool value); void ldapConfigChanged(); + void lEnableDnd(bool value); + +protected: + void writeIntoModel(std::shared_ptr model) const; + void writeFromModel(const std::shared_ptr &model); + private: // Dummy properties (for properties that use values from core received through signals) int _dummy_int = 0; @@ -278,12 +300,13 @@ private: QVariantList mCaptureDevices; QVariantList mPlaybackDevices; QVariantList mRingerDevices; - QVariantList mConferenceLayouts; QVariantMap mCaptureDevice; QVariantMap mPlaybackDevice; QVariantMap mRingerDevice; - QVariantMap mConferenceLayout; + QVariantList mConferenceLayouts; + QVariantMap mConferenceLayout; + // Video QStringList mVideoDevices; QString mVideoDevice; @@ -302,6 +325,7 @@ private: // DND bool mDndEnabled; + bool mIsSaved = true; QSettings mAppSettings; QSharedPointer> mSettingsModelConnection; diff --git a/Linphone/model/account/AccountModel.cpp b/Linphone/model/account/AccountModel.cpp index bd9cafc9b..3fea2f8f0 100644 --- a/Linphone/model/account/AccountModel.cpp +++ b/Linphone/model/account/AccountModel.cpp @@ -186,6 +186,11 @@ void AccountModel::setNotificationsAllowed(bool value) { emit notificationsAllowedChanged(value); } +QString AccountModel::getMwiServerAddress() const { + mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); + return Utils::coreStringToAppString(mMonitor->getParams()->getMwiServerAddress()->asString()); +} + void AccountModel::setMwiServerAddress(QString value) { mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); auto params = mMonitor->getParams()->clone(); @@ -199,6 +204,10 @@ void AccountModel::setMwiServerAddress(QString value) { } else qWarning() << "Unable to set MWI address, failed creating address from" << value; } +linphone::TransportType AccountModel::getTransport() const { + return mMonitor->getParams()->getTransport(); +} + void AccountModel::setTransport(linphone::TransportType value) { mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); auto params = mMonitor->getParams()->clone(); @@ -207,6 +216,10 @@ void AccountModel::setTransport(linphone::TransportType value) { emit transportChanged(value); } +QString AccountModel::getServerAddress() const { + return Utils::coreStringToAppString(mMonitor->getParams()->getServerAddress()->asString()); +} + void AccountModel::setServerAddress(QString value) { mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); auto params = mMonitor->getParams()->clone(); @@ -218,6 +231,10 @@ void AccountModel::setServerAddress(QString value) { } else qWarning() << "Unable to set ServerAddress, failed creating address from" << value; } +bool AccountModel::getOutboundProxyEnabled() const { + return mMonitor->getParams()->outboundProxyEnabled(); +} + void AccountModel::setOutboundProxyEnabled(bool value) { mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); auto params = mMonitor->getParams()->clone(); @@ -226,6 +243,12 @@ void AccountModel::setOutboundProxyEnabled(bool value) { emit outboundProxyEnabledChanged(value); } +QString AccountModel::getStunServer() const { + auto policy = mMonitor->getParams()->getNatPolicy(); + if (policy) return Utils::coreStringToAppString(policy->getStunServer()); + else return QString(); +} + void AccountModel::setStunServer(QString value) { mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); auto params = mMonitor->getParams()->clone(); @@ -238,6 +261,12 @@ void AccountModel::setStunServer(QString value) { emit stunServerChanged(value); } +bool AccountModel::getIceEnabled() const { + mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); + auto policy = mMonitor->getParams()->getNatPolicy(); + return policy && policy->iceEnabled(); +} + void AccountModel::setIceEnabled(bool value) { mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); auto params = mMonitor->getParams()->clone(); @@ -249,6 +278,10 @@ void AccountModel::setIceEnabled(bool value) { emit iceEnabledChanged(value); } +bool AccountModel::getAvpfEnabled() const { + return mMonitor->getParams()->getAvpfMode() == linphone::AVPFMode::Enabled; +} + void AccountModel::setAvpfEnabled(bool value) { mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); auto params = mMonitor->getParams()->clone(); @@ -257,6 +290,10 @@ void AccountModel::setAvpfEnabled(bool value) { emit avpfEnabledChanged(value); } +bool AccountModel::getBundleModeEnabled() const { + return mMonitor->getParams()->rtpBundleEnabled(); +} + void AccountModel::setBundleModeEnabled(bool value) { mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); auto params = mMonitor->getParams()->clone(); @@ -265,6 +302,10 @@ void AccountModel::setBundleModeEnabled(bool value) { emit bundleModeEnabledChanged(value); } +int AccountModel::getExpire() const { + return mMonitor->getParams()->getExpires(); +} + void AccountModel::setExpire(int value) { mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); auto params = mMonitor->getParams()->clone(); @@ -273,6 +314,11 @@ void AccountModel::setExpire(int value) { emit expireChanged(value); } +QString AccountModel::getConferenceFactoryAddress() const { + auto confAddress = mMonitor->getParams()->getConferenceFactoryAddress(); + return confAddress ? Utils::coreStringToAppString(confAddress->asString()) : QString(); +} + void AccountModel::setConferenceFactoryAddress(QString value) { mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); auto params = mMonitor->getParams()->clone(); @@ -286,6 +332,11 @@ void AccountModel::setConferenceFactoryAddress(QString value) { } else qWarning() << "Unable to set ConferenceFactoryAddress address, failed creating address from" << value; } +QString AccountModel::getAudioVideoConferenceFactoryAddress() const { + auto confAddress = mMonitor->getParams()->getAudioVideoConferenceFactoryAddress(); + return confAddress ? Utils::coreStringToAppString(confAddress->asString()) : QString(); +} + void AccountModel::setAudioVideoConferenceFactoryAddress(QString value) { mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); auto params = mMonitor->getParams()->clone(); @@ -300,6 +351,10 @@ void AccountModel::setAudioVideoConferenceFactoryAddress(QString value) { qWarning() << "Unable to set AudioVideoConferenceFactoryAddress address, failed creating address from" << value; } +QString AccountModel::getLimeServerUrl() const { + return Utils::coreStringToAppString(mMonitor->getParams()->getLimeServerUrl()); +} + void AccountModel::setLimeServerUrl(QString value) { mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); auto params = mMonitor->getParams()->clone(); @@ -339,6 +394,10 @@ void AccountModel::setVoicemailAddress(QString value) { } else qWarning() << "Unable to set VoicemailAddress, failed creating address from" << value; } +QString AccountModel::getVoicemailAddress() const { + return Utils::coreStringToAppString(mMonitor->getParams()->getVoicemailAddress()->asString()); +} + // UserData (see hpp for explanations) static QMap, std::shared_ptr> userDataMap; diff --git a/Linphone/model/account/AccountModel.hpp b/Linphone/model/account/AccountModel.hpp index ca78b4f22..11e5a467e 100644 --- a/Linphone/model/account/AccountModel.hpp +++ b/Linphone/model/account/AccountModel.hpp @@ -53,15 +53,27 @@ public: void setRegisterEnabled(bool enabled); bool getNotificationsAllowed(); void setNotificationsAllowed(bool value); + QString getMwiServerAddress() const; void setMwiServerAddress(QString value); + linphone::TransportType getTransport() const; void setTransport(linphone::TransportType value); + QString getServerAddress() const; void setServerAddress(QString value); + bool getOutboundProxyEnabled() const; void setOutboundProxyEnabled(bool value); + QString getStunServer() const; void setStunServer(QString value); + bool getIceEnabled() const; void setIceEnabled(bool value); + bool getAvpfEnabled() const; void setAvpfEnabled(bool value); + bool getBundleModeEnabled() const; void setBundleModeEnabled(bool value); + int getExpire() const; void setExpire(int value); + QString getConferenceFactoryAddress() const; + QString getAudioVideoConferenceFactoryAddress() const; + QString getLimeServerUrl() const; void setConferenceFactoryAddress(QString value); void setAudioVideoConferenceFactoryAddress(QString value); void setLimeServerUrl(QString value); @@ -69,6 +81,7 @@ public: int getVoicemailCount(); bool getShowMwi(); void setVoicemailAddress(QString value); + QString getVoicemailAddress() const; signals: void registrationStateChanged(const std::shared_ptr &account, diff --git a/Linphone/view/Control/Button/Settings/ComboSetting.qml b/Linphone/view/Control/Button/Settings/ComboSetting.qml index a5ae8b184..093196224 100644 --- a/Linphone/view/Control/Button/Settings/ComboSetting.qml +++ b/Linphone/view/Control/Button/Settings/ComboSetting.qml @@ -25,6 +25,4 @@ ComboBox { value: mainItem.currentValue when: false } -} - - +} \ No newline at end of file diff --git a/Linphone/view/Control/Display/Settings/SettingsMenuItem.qml b/Linphone/view/Control/Display/Settings/SettingsMenuItem.qml index 7c18d759b..d9a9cb1dc 100644 --- a/Linphone/view/Control/Display/Settings/SettingsMenuItem.qml +++ b/Linphone/view/Control/Display/Settings/SettingsMenuItem.qml @@ -64,5 +64,4 @@ Item { font: Typography.h4 } - } diff --git a/Linphone/view/Control/Form/Settings/MultimediaSettings.qml b/Linphone/view/Control/Form/Settings/MultimediaSettings.qml index af24c7a8e..6168fc85b 100644 --- a/Linphone/view/Control/Form/Settings/MultimediaSettings.qml +++ b/Linphone/view/Control/Form/Settings/MultimediaSettings.qml @@ -95,7 +95,7 @@ ColumnLayout { value: mainItem.call ? mainItem.call.core.speakerVolumeGain : SettingsCpp.playbackGain onMoved: { if (mainItem.call) mainItem.call.core.lSetSpeakerVolumeGain(value) - SettingsCpp.lSetPlaybackGain(value) + SettingsCpp.playbackGain = value } } } @@ -135,7 +135,7 @@ ColumnLayout { value: mainItem.call ? mainItem.call.core.microphoneVolumeGain : SettingsCpp.captureGain onMoved: { if (mainItem.call) mainItem.call.core.lSetMicrophoneVolumeGain(value) - SettingsCpp.lSetCaptureGain(value) + SettingsCpp.captureGain = value } } Timer { diff --git a/Linphone/view/Control/Popup/Dialog/Dialog.qml b/Linphone/view/Control/Popup/Dialog/Dialog.qml index b669a3678..31cc5fe62 100644 --- a/Linphone/view/Control/Popup/Dialog/Dialog.qml +++ b/Linphone/view/Control/Popup/Dialog/Dialog.qml @@ -114,14 +114,15 @@ Popup { id:firstButtonId visible: mainItem.buttons.length === 2 text: mainItem.firstButtonText + textSize: 15 * DefaultStyle.dp leftPadding: 20 * DefaultStyle.dp rightPadding: 20 * DefaultStyle.dp topPadding: 11 * DefaultStyle.dp bottomPadding: 11 * DefaultStyle.dp inversedColors: !mainItem.firstButtonAccept - focus: !firstButtonAccept + focus: !mainItem.firstButtonAccept onClicked: { - if(firstButtonAccept) + if(mainItem.firstButtonAccept) mainItem.accepted() else mainItem.rejected() @@ -134,13 +135,14 @@ Popup { id: secondButtonId visible: mainItem.buttons.length === 2 text: mainItem.secondButtonText + textSize: 15 * DefaultStyle.dp leftPadding: 20 * DefaultStyle.dp rightPadding: 20 * DefaultStyle.dp topPadding: 11 * DefaultStyle.dp bottomPadding: 11 * DefaultStyle.dp - focus: !secondButtonAccept + focus: !mainItem.secondButtonAccept onClicked: { - if(secondButtonAccept) + if(mainItem.secondButtonAccept) mainItem.accepted() else mainItem.rejected() diff --git a/Linphone/view/Page/Form/Settings/AbstractSettingsMenu.qml b/Linphone/view/Page/Form/Settings/AbstractSettingsMenu.qml index 85501f7e0..447d1f6c5 100644 --- a/Linphone/view/Page/Form/Settings/AbstractSettingsMenu.qml +++ b/Linphone/view/Page/Form/Settings/AbstractSettingsMenu.qml @@ -14,6 +14,7 @@ AbstractMainPage { property var titleText signal goBack() + signal goBackRequested() function layoutUrl(name) { return layoutsPath+"/"+name+".qml" @@ -41,7 +42,7 @@ AbstractMainPage { height: 24 * DefaultStyle.dp focus: true onClicked: { - mainItem.goBack() + mainItem.goBackRequested() } background: Item { anchors.fill: parent diff --git a/Linphone/view/Page/Form/Settings/AccountSettingsPage.qml b/Linphone/view/Page/Form/Settings/AccountSettingsPage.qml index 155f41758..f7f595135 100644 --- a/Linphone/view/Page/Form/Settings/AccountSettingsPage.qml +++ b/Linphone/view/Page/Form/Settings/AccountSettingsPage.qml @@ -7,6 +7,7 @@ import UtilsCpp import SettingsCpp AbstractSettingsMenu { + id: mainItem layoutsPath: "qrc:/qt/qml/Linphone/view/Page/Layout/Settings" titleText: qsTr("Mon compte") property AccountGui account @@ -19,4 +20,18 @@ AbstractSettingsMenu { target: account.core onRemoved: accountRemoved() } + onGoBackRequested: if (!account.core.isSaved) { + UtilsCpp.getMainWindow().showConfirmationLambdaPopup(qsTr("Modifications non enregistrées"), + qsTr("Vous avez des modifications non enregistrées. Si vous quittez cette page, vos changements seront perdus. Voulez-vous enregistrer vos modifications avant de continuer ?"), + "", + function (confirmed) { + if (confirmed) { + account.core.save() + } else { + account.core.undo() + } + mainItem.goBack() + }, qsTr("Ne pas enregistrer"), qsTr("Enregistrer") + ) + } else {mainItem.goBack()} } diff --git a/Linphone/view/Page/Form/Settings/SettingsPage.qml b/Linphone/view/Page/Form/Settings/SettingsPage.qml index 46b5cd83e..4f3327fdf 100644 --- a/Linphone/view/Page/Form/Settings/SettingsPage.qml +++ b/Linphone/view/Page/Form/Settings/SettingsPage.qml @@ -3,8 +3,10 @@ import QtQuick.Effects import QtQuick.Layouts import QtQuick.Controls.Basic as Control import SettingsCpp +import UtilsCpp AbstractSettingsMenu { + id: mainItem layoutsPath: "qrc:/qt/qml/Linphone/view/Page/Layout/Settings" titleText: qsTr("Paramètres") families: [ @@ -16,4 +18,19 @@ AbstractSettingsMenu { {title: qsTr("Réseau"), layout: "NetworkSettingsLayout"}, {title: qsTr("Paramètres avancés"), layout: "AdvancedSettingsLayout"} ] + + onGoBackRequested: if (!SettingsCpp.isSaved) { + UtilsCpp.getMainWindow().showConfirmationLambdaPopup(qsTr("Modifications non enregistrées"), + qsTr("Vous avez des modifications non enregistrées. Si vous quittez cette page, vos changements seront perdus. Voulez-vous enregistrer vos modifications avant de continuer ?"), + "", + function (confirmed) { + if (confirmed) { + SettingsCpp.save() + } else { + SettingsCpp.undo() + } + mainItem.goBack() + }, qsTr("Ne pas enregistrer"), qsTr("Enregistrer") + ) + } else {mainItem.goBack()} } diff --git a/Linphone/view/Page/Layout/Settings/AbstractSettingsLayout.qml b/Linphone/view/Page/Layout/Settings/AbstractSettingsLayout.qml index 1b8179590..b65d3f8cf 100644 --- a/Linphone/view/Page/Layout/Settings/AbstractSettingsLayout.qml +++ b/Linphone/view/Page/Layout/Settings/AbstractSettingsLayout.qml @@ -18,6 +18,9 @@ Rectangle { property int contentHeight: contentRepeater.count > 0 ? contentRepeater.itemAt(0).height * contentRepeater.count : 0 property int minimumWidthForSwitchintToRowLayout: 981 * DefaultStyle.dp property var useVerticalLayout + property bool saveButtonVisible: true + signal save() + signal undo() function setResponsivityFlags() { var newValue = width < minimumWidthForSwitchintToRowLayout * DefaultStyle.dp if (useVerticalLayout != newValue) { @@ -89,6 +92,20 @@ Rectangle { sourceComponent: mainItem.topbarOptionalComponent Layout.rightMargin: 34 * DefaultStyle.dp } + Button { + id: saveButton + text: qsTr("Enregistrer") + Layout.rightMargin: 6 * DefaultStyle.dp + visible: mainItem.saveButtonVisible + textSize: 15 * DefaultStyle.dp + leftPadding: 16 * DefaultStyle.dp + rightPadding: 16 * DefaultStyle.dp + topPadding: 10 * DefaultStyle.dp + bottomPadding: 10 * DefaultStyle.dp + onClicked: { + mainItem.save() + } + } } Repeater { id: contentRepeater diff --git a/Linphone/view/Page/Layout/Settings/AccountSettingsGeneralLayout.qml b/Linphone/view/Page/Layout/Settings/AccountSettingsGeneralLayout.qml index bf26994b2..a46aaa995 100644 --- a/Linphone/view/Page/Layout/Settings/AccountSettingsGeneralLayout.qml +++ b/Linphone/view/Page/Layout/Settings/AccountSettingsGeneralLayout.qml @@ -9,6 +9,7 @@ import UtilsCpp AbstractSettingsLayout { id: mainItem + saveButtonVisible: false width: parent?.width contentModel: [ diff --git a/Linphone/view/Page/Layout/Settings/AccountSettingsParametersLayout.qml b/Linphone/view/Page/Layout/Settings/AccountSettingsParametersLayout.qml index 6cb1df2c8..353d2885a 100644 --- a/Linphone/view/Page/Layout/Settings/AccountSettingsParametersLayout.qml +++ b/Linphone/view/Page/Layout/Settings/AccountSettingsParametersLayout.qml @@ -17,12 +17,25 @@ AbstractSettingsLayout { contentComponent: generalParametersComponent }, { - title: qsTr("Paramètres avancés"), + title: qsTr("Paramètres de compte"), subTitle: "", contentComponent: advancedParametersComponent } ] + property alias account: mainItem.model + + onSave: { + account.core.save() + } + onUndo: account.core.undo() + Connections { + target: account.core + function onIsSavedChanged() { + if (account.core.isSaved) UtilsCpp.showInformationPopup(qsTr("Succès"), qsTr("Les changements ont été sauvegardés"), true, mainWindow) + } + } + // General parameters ///////////////////// @@ -37,7 +50,7 @@ AbstractSettingsLayout { propertyOwner: account.core title: qsTr("URI du serveur de messagerie vocale") Layout.fillWidth: true - isValid: function(text) { return text.length == 0 || !text.endsWith(".") } // work around sdk crash when adress ends with . + isValid: function(text) { return text.length == 0 || !text.endsWith(".") } // work around sdk crash when adress ends with . toValidate: true } DecoratedTextField { diff --git a/Linphone/view/Page/Layout/Settings/AdvancedSettingsLayout.qml b/Linphone/view/Page/Layout/Settings/AdvancedSettingsLayout.qml index 335a2d47a..24ebbbd92 100644 --- a/Linphone/view/Page/Layout/Settings/AdvancedSettingsLayout.qml +++ b/Linphone/view/Page/Layout/Settings/AdvancedSettingsLayout.qml @@ -43,6 +43,11 @@ AbstractSettingsLayout { } ] + onSave: { + SettingsCpp.save() + } + onUndo: SettingsCpp.undo() + // System ///////// diff --git a/Linphone/view/Page/Layout/Settings/CallSettingsLayout.qml b/Linphone/view/Page/Layout/Settings/CallSettingsLayout.qml index 628b17d74..afea464b0 100644 --- a/Linphone/view/Page/Layout/Settings/CallSettingsLayout.qml +++ b/Linphone/view/Page/Layout/Settings/CallSettingsLayout.qml @@ -4,6 +4,7 @@ import QtQuick.Layouts import QtQuick.Controls.Basic as Control import Linphone import SettingsCpp 1.0 +import UtilsCpp AbstractSettingsLayout { id: mainItem @@ -23,6 +24,11 @@ AbstractSettingsLayout { } ] + onSave: { + SettingsCpp.save() + } + onUndo: SettingsCpp.undo() + // Generic call parameters ////////////////////////// diff --git a/Linphone/view/Page/Layout/Settings/CarddavSettingsLayout.qml b/Linphone/view/Page/Layout/Settings/CarddavSettingsLayout.qml index b713cb8ff..450b867bb 100644 --- a/Linphone/view/Page/Layout/Settings/CarddavSettingsLayout.qml +++ b/Linphone/view/Page/Layout/Settings/CarddavSettingsLayout.qml @@ -20,6 +20,22 @@ AbstractSettingsLayout { topbarOptionalComponent: topBar property alias carddavGui: mainItem.model property bool isNew: false + onSave: { + if (carddavGui.core.isValid()) { + carddavGui.core.save() + } else { + UtilsCpp.showInformationPopup(qsTr("Erreur"), qsTr("Vérifiez que toutes les informations ont été saisies."), false, mainWindow) + } + } + Connections { + target: carddavGui.core + function onSaved(success) { + if (success) + UtilsCpp.showInformationPopup(qsTr("Succès"), qsTr("Le carnet d'adresse CardDAV est synchronisé."), true, mainWindow) + else + UtilsCpp.showInformationPopup(qsTr("Erreur"), qsTr("Erreur de synchronisation!"), false, mainWindow) + } + } Component { id: topBar RowLayout { @@ -45,25 +61,6 @@ AbstractSettingsLayout { ) } } - Button { - text: qsTr("Enregistrer") - onClicked: { - if (carddavGui.core.isValid()) { - carddavGui.core.save() - } else { - UtilsCpp.showInformationPopup(qsTr("Erreur"), qsTr("Vérifiez que toutes les informations ont été saisies."), false, mainWindow) - } - } - Connections { - target: carddavGui.core - function onSaved(success) { - if (success) - UtilsCpp.showInformationPopup(qsTr("Succès"), qsTr("Le carnet d'adresse CardDAV est synchronisé."), true, mainWindow) - else - UtilsCpp.showInformationPopup(qsTr("Erreur"), qsTr("Erreur de synchronisation!"), false, mainWindow) - } - } - } } } diff --git a/Linphone/view/Page/Layout/Settings/ContactsSettingsLayout.qml b/Linphone/view/Page/Layout/Settings/ContactsSettingsLayout.qml index 8c0c2fb8f..4fd4ed8a4 100644 --- a/Linphone/view/Page/Layout/Settings/ContactsSettingsLayout.qml +++ b/Linphone/view/Page/Layout/Settings/ContactsSettingsLayout.qml @@ -45,6 +45,12 @@ AbstractSettingsLayout { titleProperty: "serverUrl" supportsEnableDisable: true showAddButton: true + + Connections { + target: mainItem + function onSave() { save()} + function onUndo() { undo()} + } } } @@ -68,6 +74,12 @@ AbstractSettingsLayout { owner: mainItem titleProperty: "displayName" supportsEnableDisable: false + + Connections { + target: mainItem + function onSave() { save()} + function onUndo() { undo()} + } } } } diff --git a/Linphone/view/Page/Layout/Settings/ContactsSettingsProviderLayout.qml b/Linphone/view/Page/Layout/Settings/ContactsSettingsProviderLayout.qml index ab8f25467..973005907 100644 --- a/Linphone/view/Page/Layout/Settings/ContactsSettingsProviderLayout.qml +++ b/Linphone/view/Page/Layout/Settings/ContactsSettingsProviderLayout.qml @@ -3,6 +3,7 @@ import QtQuick import QtQuick.Layouts import QtQuick.Controls.Basic as Control import SettingsCpp 1.0 +import UtilsCpp import Linphone RowLayout { @@ -20,6 +21,9 @@ RowLayout { property bool supportsEnableDisable property bool showAddButton + signal save() + signal undo() + spacing: 5 * DefaultStyle.dp ColumnLayout { Layout.fillWidth: true @@ -64,7 +68,6 @@ RowLayout { visible: supportsEnableDisable onToggled: { binding.when = true - modelData.core.save() } } Binding { @@ -74,6 +77,22 @@ RowLayout { value: switchButton.checked when: false } + Connections { + target: mainItem + function onSave() { + modelData.core.save() + } + function onUndo() { + modelData.core.undo() + } + } + Connections { + target: modelData.core + function onSavedChanged() { + if (modelData.core.saved) UtilsCpp.showInformationPopup(qsTr("Succès"), qsTr("Les changements ont été sauvegardés"), true, mainWindow) + } + } + } onVisibleChanged: { if (visible) diff --git a/Linphone/view/Page/Layout/Settings/LdapSettingsLayout.qml b/Linphone/view/Page/Layout/Settings/LdapSettingsLayout.qml index e1cfd3d89..939623615 100644 --- a/Linphone/view/Page/Layout/Settings/LdapSettingsLayout.qml +++ b/Linphone/view/Page/Layout/Settings/LdapSettingsLayout.qml @@ -21,6 +21,15 @@ AbstractSettingsLayout { topbarOptionalComponent: topBar property alias ldapGui: mainItem.model property bool isNew: false + + onSave: { + if (ldapGui.core.isValid()) { + ldapGui.core.save() + UtilsCpp.showInformationPopup(qsTr("Succès"), qsTr("L'annuaire LDAP a été sauvegardé"), true, mainWindow) + } else { + UtilsCpp.showInformationPopup(qsTr("Erreur"), qsTr("Une erreur s'est produite, la configuration LDAP n'a pas été sauvegardée !"), false, mainWindow) + } + } Component { id: topBar @@ -47,22 +56,6 @@ AbstractSettingsLayout { ) } } - Button { - leftPadding: 16 * DefaultStyle.dp - rightPadding: 16 * DefaultStyle.dp - topPadding: 10 * DefaultStyle.dp - bottomPadding: 10 * DefaultStyle.dp - textSize: 15 * DefaultStyle.dp - text: qsTr("Enregistrer") - onClicked: { - if (ldapGui.core.isValid()) { - ldapGui.core.save() - UtilsCpp.showInformationPopup(qsTr("Succès"), qsTr("L'annuaire LDAP a été sauvegardé"), true, mainWindow) - } else { - UtilsCpp.showInformationPopup(qsTr("Erreur"), qsTr("Une erreur s'est produite, la configuration LDAP n'a pas été sauvegardée !"), false, mainWindow) - } - } - } } } diff --git a/Linphone/view/Page/Layout/Settings/MeetingsSettingsLayout.qml b/Linphone/view/Page/Layout/Settings/MeetingsSettingsLayout.qml index 98b6f1634..7efa302b9 100644 --- a/Linphone/view/Page/Layout/Settings/MeetingsSettingsLayout.qml +++ b/Linphone/view/Page/Layout/Settings/MeetingsSettingsLayout.qml @@ -3,6 +3,7 @@ import QtQuick import QtQuick.Layouts import QtQuick.Controls.Basic as Control import SettingsCpp 1.0 +import UtilsCpp import Linphone AbstractSettingsLayout { @@ -17,6 +18,11 @@ AbstractSettingsLayout { } ] + onSave: { + SettingsCpp.save() + } + onUndo: SettingsCpp.undo() + Component { id: confDisplayParametersComponent ColumnLayout { diff --git a/Linphone/view/Page/Layout/Settings/NetworkSettingsLayout.qml b/Linphone/view/Page/Layout/Settings/NetworkSettingsLayout.qml index 253c7b64d..b61ec2721 100644 --- a/Linphone/view/Page/Layout/Settings/NetworkSettingsLayout.qml +++ b/Linphone/view/Page/Layout/Settings/NetworkSettingsLayout.qml @@ -4,6 +4,7 @@ import QtQuick.Layouts import QtQuick.Controls.Basic as Control import SettingsCpp 1.0 import Linphone +import UtilsCpp AbstractSettingsLayout { width: parent?.width @@ -14,6 +15,11 @@ AbstractSettingsLayout { contentComponent: content } ] + onSave: { + SettingsCpp.save() + } + onUndo: SettingsCpp.undo() + Component { id: content ColumnLayout { diff --git a/Linphone/view/Page/Layout/Settings/SecuritySettingsLayout.qml b/Linphone/view/Page/Layout/Settings/SecuritySettingsLayout.qml index 4232fd856..4150c36c4 100644 --- a/Linphone/view/Page/Layout/Settings/SecuritySettingsLayout.qml +++ b/Linphone/view/Page/Layout/Settings/SecuritySettingsLayout.qml @@ -4,6 +4,7 @@ import QtQuick.Layouts import QtQuick.Controls.Basic as Control import SettingsCpp 1.0 import Linphone +import UtilsCpp AbstractSettingsLayout { width: parent?.width @@ -14,6 +15,11 @@ AbstractSettingsLayout { contentComponent: content } ] + onSave: { + SettingsCpp.save() + } + onUndo: SettingsCpp.undo() + Component { id: content ColumnLayout { diff --git a/Linphone/view/Page/Window/AbstractWindow.qml b/Linphone/view/Page/Window/AbstractWindow.qml index abfacc9b1..cccf63d1d 100644 --- a/Linphone/view/Page/Window/AbstractWindow.qml +++ b/Linphone/view/Page/Window/AbstractWindow.qml @@ -218,17 +218,16 @@ ApplicationWindow { function showConfirmationPopup(requestDialog){ console.log("Showing confirmation popup") var popup = confirmPopupComp.createObject(popupLayout, {"requestDialog": requestDialog}) - popup.index = popupLayout.popupList.length - popupLayout.popupList.push(popup) popup.open() popup.closePopup.connect(removeFromPopupLayout) } - function showConfirmationLambdaPopup(title,text, details,callback){ + function showConfirmationLambdaPopup(title,text, details,callback, firstButtonText, secondButtonText){ console.log("Showing confirmation lambda popup") var popup = confirmPopupComp.createObject(popupLayout, {"title": title, "text": text, "details":details,"callback":callback}) - popup.index = popupLayout.popupList.length - popupLayout.popupList.push(popup) + if (firstButtonText != undefined) popup.firstButtonText = firstButtonText + if (secondButtonText != undefined) popup.secondButtonText = secondButtonText + popup.titleColor = DefaultStyle.main1_500_main popup.open() popup.closePopup.connect(removeFromPopupLayout) } diff --git a/Linphone/view/Page/Window/Main/MainWindow.qml b/Linphone/view/Page/Window/Main/MainWindow.qml index 83af903e1..c066330a2 100644 --- a/Linphone/view/Page/Window/Main/MainWindow.qml +++ b/Linphone/view/Page/Window/Main/MainWindow.qml @@ -88,6 +88,9 @@ AbstractWindow { function onAssistantGoDirectlyToThirdPartySipAccountLoginChanged() { initStackViewItem() } + function onIsSavedChanged() { + if (SettingsCpp.isSaved) UtilsCpp.showInformationPopup(qsTr("Succès"), qsTr("Les changements ont été sauvegardés"), true, mainWindow) + } } Loader {