From 9f9b624abd8486df6a128724f164fa0b66bd0d14 Mon Sep 17 00:00:00 2001 From: Julien Wadel Date: Mon, 24 Jul 2023 11:30:54 +0200 Subject: [PATCH] Display secure icon on contacts if it has the capability. Deactivate video if no codecs are selected. Link to licence in about. Fix loosing ICE configuration. Fix click shortcut on the first item on smartsearch bar. Add separated and editable prefix phone number in assistant. --- linphone-app/application_info.cmake | 1 + .../assistant/create-app-sip-account.rc | 4 +- .../assets/assistant/use-app-sip-account.rc | 4 +- .../assets/assistant/use-other-sip-account.rc | 2 +- linphone-app/src/app/App.cpp | 7 ++ .../app/proxyModel/ProxyAbstractObject.hpp | 1 + .../components/assistant/AssistantModel.cpp | 49 +++++++++-- .../components/assistant/AssistantModel.hpp | 40 ++++++--- .../components/codecs/AbstractCodecsModel.cpp | 3 + .../src/components/settings/SettingsModel.cpp | 14 ++++ .../src/components/settings/SettingsModel.hpp | 8 +- .../TelephoneNumbersModel.cpp | 19 ++++- .../TelephoneNumbersModel.hpp | 8 +- linphone-app/src/config.h.cmake | 1 + .../ui/modules/Common/Form/ComboBox.js | 5 +- .../ui/modules/Linphone/Calls/Calls.js | 2 +- .../Dialog/MultimediaParametersDialog.qml | 2 +- .../ui/modules/Linphone/Menus/IncallMenu.qml | 2 +- .../NotificationReceivedCall.qml | 2 +- .../SmartSearchBar/SmartSearchBar.qml | 2 +- .../Linphone/View/SipAddressesView.qml | 4 + linphone-app/ui/scripts/Utils/utils.js | 2 +- .../App/Calls/Dialogs/CallSipAddress.qml | 2 +- linphone-app/ui/views/App/Calls/Incall.js | 2 +- linphone-app/ui/views/App/Calls/Incall.qml | 2 +- .../ui/views/App/Calls/IncomingCall.qml | 2 +- .../ui/views/App/Calls/WaitingRoom.qml | 8 +- .../ActivateAppSipAccountWithPhoneNumber.qml | 4 +- .../CreateAppSipAccountWithPhoneNumber.qml | 84 ++++++++++++------- .../App/Main/Assistant/UseAppSipAccount.qml | 25 ++++-- .../UseAppSipAccountWithPhoneNumber.qml | 44 +++++++--- .../ui/views/App/Main/ContactEdit.qml | 2 +- linphone-app/ui/views/App/Main/Contacts.qml | 4 +- .../ui/views/App/Main/Conversation.qml | 2 +- .../ui/views/App/Main/Dialogs/About.qml | 5 ++ .../ui/views/App/Main/HistoryView.qml | 2 +- 36 files changed, 264 insertions(+), 106 deletions(-) diff --git a/linphone-app/application_info.cmake b/linphone-app/application_info.cmake index 9281a0838..5e76c1caa 100644 --- a/linphone-app/application_info.cmake +++ b/linphone-app/application_info.cmake @@ -4,6 +4,7 @@ set(APPLICATION_NAME Linphone) set(APPLICATION_URL "https://www.linphone.org") set(APPLICATION_VENDOR "Belledonne Communications") set(APPLICATION_LICENCE "GNU General Public License V3") +set(APPLICATION_LICENCE_URL "https://www.gnu.org/licenses/gpl-3.0.html") set(APPLICATION_START_LICENCE "2010") set(EXECUTABLE_NAME linphone) diff --git a/linphone-app/assets/assistant/create-app-sip-account.rc b/linphone-app/assets/assistant/create-app-sip-account.rc index 89951bed1..a23f4995a 100644 --- a/linphone-app/assets/assistant/create-app-sip-account.rc +++ b/linphone-app/assets/assistant/create-app-sip-account.rc @@ -15,7 +15,7 @@ sip:?@sip.linphone.org <sip:sip.linphone.org;transport=tls> 1 - nat_policy_default_values + default_nat_policy_values sip.linphone.org message-expires=2419200 sip:conference-factory@sip.linphone.org @@ -24,7 +24,7 @@ 1 https://lime.linphone.org/lime-server/lime-server.php -
+
stun.linphone.org stun,ice
diff --git a/linphone-app/assets/assistant/use-app-sip-account.rc b/linphone-app/assets/assistant/use-app-sip-account.rc index 1d0249ff0..4e6917299 100644 --- a/linphone-app/assets/assistant/use-app-sip-account.rc +++ b/linphone-app/assets/assistant/use-app-sip-account.rc @@ -15,7 +15,7 @@ sip:?@sip.linphone.org <sip:sip.linphone.org;transport=tls> 1 - nat_policy_default_values + default_nat_policy_values sip.linphone.org message-expires=2419200 sip:conference-factory@sip.linphone.org @@ -24,7 +24,7 @@ 1 https://lime.linphone.org/lime-server/lime-server.php
-
+
stun.linphone.org stun,ice
diff --git a/linphone-app/assets/assistant/use-other-sip-account.rc b/linphone-app/assets/assistant/use-other-sip-account.rc index 228726c84..c5413129e 100644 --- a/linphone-app/assets/assistant/use-other-sip-account.rc +++ b/linphone-app/assets/assistant/use-other-sip-account.rc @@ -22,7 +22,7 @@
-
+
diff --git a/linphone-app/src/app/App.cpp b/linphone-app/src/app/App.cpp index 360079208..2e98ba348 100644 --- a/linphone-app/src/app/App.cpp +++ b/linphone-app/src/app/App.cpp @@ -456,6 +456,13 @@ void App::initContentApp () { #else mEngine->rootContext()->setContextProperty("applicationLicence", ""); #endif +#ifdef APPLICATION_LICENCE_URL + mEngine->rootContext()->setContextProperty("applicationLicenceUrl", APPLICATION_LICENCE_URL); +#else + mEngine->rootContext()->setContextProperty("applicationLicenceUrl", ""); +#endif + + #ifdef COPYRIGHT_RANGE_DATE mEngine->rootContext()->setContextProperty("copyrightRangeDate", COPYRIGHT_RANGE_DATE); #else diff --git a/linphone-app/src/app/proxyModel/ProxyAbstractObject.hpp b/linphone-app/src/app/proxyModel/ProxyAbstractObject.hpp index b2affa0c3..e2136a64c 100644 --- a/linphone-app/src/app/proxyModel/ProxyAbstractObject.hpp +++ b/linphone-app/src/app/proxyModel/ProxyAbstractObject.hpp @@ -29,6 +29,7 @@ class ProxyAbstractObject : public QAbstractListModel{ Q_OBJECT public: Q_PROPERTY(int count READ getCount NOTIFY countChanged) + Q_PROPERTY(int length READ getCount NOTIFY countChanged) ProxyAbstractObject(QObject * parent = nullptr) : QAbstractListModel(parent){ connect(this, &ProxyAbstractObject::rowsInserted, this, &ProxyAbstractObject::countChanged); diff --git a/linphone-app/src/components/assistant/AssistantModel.cpp b/linphone-app/src/components/assistant/AssistantModel.cpp index e99efce3a..810c53ef3 100644 --- a/linphone-app/src/components/assistant/AssistantModel.cpp +++ b/linphone-app/src/components/assistant/AssistantModel.cpp @@ -53,11 +53,17 @@ public: private: void createAccount (const shared_ptr &creator) { - shared_ptr proxyConfig = creator->createProxyConfig(); - auto account = CoreManager::getInstance()->getCore()->getAccountByIdkey(proxyConfig->getIdkey()); + auto account = creator->createAccountInCore(); if(account){ + AccountSettingsModel *accountSettingsModel = CoreManager::getInstance()->getAccountSettingsModel(); CoreManager::getInstance()->addingAccount(account->getParams()); - CoreManager::getInstance()->getAccountSettingsModel()->setDefaultAccount(account); + auto accountParams = account->getParams()->clone(); + auto natPolicy = accountParams->getNatPolicy(); + if(natPolicy) + accountParams->setNatPolicy(natPolicy->clone());// Be sure to have a 'ref' entry on a nat_policy. When using default values, the 'ref' entry is lost where it should be pointing to default. We get one by cloning the policy. + if (accountSettingsModel->addOrUpdateAccount(account, accountParams)) { + accountSettingsModel->setDefaultAccount(account); + } } } @@ -133,7 +139,7 @@ private: QVariantMap description = doc.toVariant().toMap(); creator->setToken(description.value("token").toString().toStdString()); // it will automatically use the account creation token. - if (!mAssistant->mCountryCode.isEmpty()) { + if (mAssistant->mUsePhoneNumber) { emit mAssistant->createStatusChanged("Recovering account"); creator->recoverAccount(); }else{ @@ -144,7 +150,6 @@ private: QTimer::singleShot(2000, [creator](){ creator->requestAccountCreationTokenUsingRequestToken(); }); - } void onActivateAccount ( @@ -269,7 +274,8 @@ void AssistantModel::login () { setIsProcessing(true); if(mAccountCreator->getUsername().empty()) mAccountCreator->setUsername(mAccountCreator->getPhoneNumber()); - if (!mCountryCode.isEmpty()) {// Recovering account from phone + if (mUsePhoneNumber) { + emit createStatusChanged("Requesting validation url"); mAccountCreator->requestAccountCreationRequestToken(); return; } @@ -555,12 +561,29 @@ QString AssistantModel::getCountryCode () const { void AssistantModel::setCountryCode (const QString &countryCode) { mCountryCode = countryCode; + mAccountCreator->setPhoneNumber(Utils::appStringToCoreString(mPhoneNumber), Utils::appStringToCoreString(mCountryCode)); emit countryCodeChanged(countryCode); + emit computedPhoneNumberChanged(); } // ----------------------------------------------------------------------------- +bool AssistantModel::getUsePhoneNumber() const{ + return mUsePhoneNumber; +} + +void AssistantModel::setUsePhoneNumber(bool use) { + if(mUsePhoneNumber != use){ + mUsePhoneNumber = use; + emit usePhoneNumberChanged(); + } +} + QString AssistantModel::getPhoneNumber () const { + return mPhoneNumber; +} + +QString AssistantModel::getComputedPhoneNumber () const{ return Utils::coreStringToAppString(mAccountCreator->getPhoneNumber()); } @@ -588,8 +611,20 @@ void AssistantModel::setPhoneNumber (const QString &phoneNumber) { default: break; } - + mPhoneNumber = phoneNumber; emit phoneNumberChanged(phoneNumber, error); + emit computedPhoneNumberChanged(); +} + +QString AssistantModel::getPhoneCountryCode() const { + return mPhoneCountryCode; +} + +void AssistantModel::setPhoneCountryCode(const QString &code) { + if( mPhoneCountryCode != code) { + mPhoneCountryCode = code; + emit phoneCountryCodeChanged(); + } } // ----------------------------------------------------------------------------- diff --git a/linphone-app/src/components/assistant/AssistantModel.hpp b/linphone-app/src/components/assistant/AssistantModel.hpp index c3831330f..a1647ac19 100644 --- a/linphone-app/src/components/assistant/AssistantModel.hpp +++ b/linphone-app/src/components/assistant/AssistantModel.hpp @@ -32,18 +32,23 @@ class OAuth2Model; class AssistantModel : public QObject { class Handlers; - Q_OBJECT; + Q_OBJECT + + Q_PROPERTY(QString email READ getEmail WRITE setEmail NOTIFY emailChanged) + Q_PROPERTY(QString password READ getPassword WRITE setPassword NOTIFY passwordChanged) + Q_PROPERTY(QString countryCode READ getCountryCode WRITE setCountryCode NOTIFY countryCodeChanged) + Q_PROPERTY(QString phoneNumber READ getPhoneNumber WRITE setPhoneNumber NOTIFY phoneNumberChanged) + Q_PROPERTY(QString phoneCountryCode READ getPhoneCountryCode WRITE setPhoneCountryCode NOTIFY phoneCountryCodeChanged) + Q_PROPERTY(QString computedPhoneNumber READ getComputedPhoneNumber NOTIFY computedPhoneNumberChanged) + + Q_PROPERTY(QString username READ getUsername WRITE setUsername NOTIFY usernameChanged) + Q_PROPERTY(QString displayName READ getDisplayName WRITE setDisplayName NOTIFY displayNameChanged) + Q_PROPERTY(QString activationCode READ getActivationCode WRITE setActivationCode NOTIFY activationCodeChanged) + Q_PROPERTY(QString configFilename READ getConfigFilename WRITE setConfigFilename NOTIFY configFilenameChanged) + Q_PROPERTY(bool isReadingQRCode READ getIsReadingQRCode WRITE setIsReadingQRCode NOTIFY isReadingQRCodeChanged) + Q_PROPERTY(bool isProcessing READ getIsProcessing WRITE setIsProcessing NOTIFY isProcessingChanged) + Q_PROPERTY(bool usePhoneNumber READ getUsePhoneNumber WRITE setUsePhoneNumber NOTIFY usePhoneNumberChanged) - Q_PROPERTY(QString email READ getEmail WRITE setEmail NOTIFY emailChanged); - Q_PROPERTY(QString password READ getPassword WRITE setPassword NOTIFY passwordChanged); - Q_PROPERTY(QString countryCode READ getCountryCode WRITE setCountryCode NOTIFY countryCodeChanged); - Q_PROPERTY(QString phoneNumber READ getPhoneNumber WRITE setPhoneNumber NOTIFY phoneNumberChanged); - Q_PROPERTY(QString username READ getUsername WRITE setUsername NOTIFY usernameChanged); - Q_PROPERTY(QString displayName READ getDisplayName WRITE setDisplayName NOTIFY displayNameChanged); - Q_PROPERTY(QString activationCode READ getActivationCode WRITE setActivationCode NOTIFY activationCodeChanged); - Q_PROPERTY(QString configFilename READ getConfigFilename WRITE setConfigFilename NOTIFY configFilenameChanged); - Q_PROPERTY(bool isReadingQRCode READ getIsReadingQRCode WRITE setIsReadingQRCode NOTIFY isReadingQRCodeChanged); - Q_PROPERTY(bool isProcessing READ getIsProcessing WRITE setIsProcessing NOTIFY isProcessingChanged); public: AssistantModel (QObject *parent = Q_NULLPTR); @@ -78,7 +83,10 @@ signals: void emailChanged (const QString &email, const QString &error); void passwordChanged (const QString &password, const QString &error); void countryCodeChanged (const QString &countryCode); + void usePhoneNumberChanged(); void phoneNumberChanged (const QString &phoneNumber, const QString &error); + void phoneCountryCodeChanged(); + void computedPhoneNumberChanged(); void usernameChanged (const QString &username, const QString &error); void displayNameChanged (const QString &displayName, const QString &error); void activationCodeChanged (const QString &activationCode); @@ -115,9 +123,16 @@ private: QString getCountryCode () const; void setCountryCode (const QString &countryCode); + bool getUsePhoneNumber() const; + void setUsePhoneNumber(bool use); + QString getPhoneNumber () const; + QString getComputedPhoneNumber () const; void setPhoneNumber (const QString &phoneNumber); + QString getPhoneCountryCode () const; + void setPhoneCountryCode (const QString &code); + QString getUsername () const; void setUsername (const QString &username); @@ -142,8 +157,11 @@ private: QString mCountryCode; QString mConfigFilename; QString mToken; + QString mPhoneCountryCode; + QString mPhoneNumber; bool mIsReadingQRCode; bool mIsProcessing; + bool mUsePhoneNumber = false; std::shared_ptr mAccountCreator; std::shared_ptr mHandlers; diff --git a/linphone-app/src/components/codecs/AbstractCodecsModel.cpp b/linphone-app/src/components/codecs/AbstractCodecsModel.cpp index 804e51edd..a301058a9 100644 --- a/linphone-app/src/components/codecs/AbstractCodecsModel.cpp +++ b/linphone-app/src/components/codecs/AbstractCodecsModel.cpp @@ -20,6 +20,7 @@ #include "app/paths/Paths.hpp" #include "components/core/CoreManager.hpp" +#include "components/settings/SettingsModel.hpp" #include "utils/Utils.hpp" #include "AbstractCodecsModel.hpp" @@ -45,6 +46,8 @@ void AbstractCodecsModel::enableCodec (int id, bool status) { shared_ptr codec = getCodecFromMap(map); if (codec) { codec->enable(status); + if(codec->getType() == PAYLOAD_VIDEO) + emit CoreManager::getInstance()->getSettingsModel()->haveAtLeastOneVideoCodecChanged(); map["enabled"] = codec->enabled(); emit dataChanged(index(id, 0), index(id, 0)); } diff --git a/linphone-app/src/components/settings/SettingsModel.cpp b/linphone-app/src/components/settings/SettingsModel.cpp index 8968aa9e5..966a140c5 100644 --- a/linphone-app/src/components/settings/SettingsModel.cpp +++ b/linphone-app/src/components/settings/SettingsModel.cpp @@ -55,6 +55,7 @@ SettingsModel::SettingsModel (QObject *parent) : QObject(parent) { mConfig = coreManager->getCore()->getConfig(); connect(this, &SettingsModel::dontAskAgainInfoEncryptionChanged, this, &SettingsModel::haveDontAskAgainChoicesChanged); + connect(this, &SettingsModel::haveAtLeastOneVideoCodecChanged, this, &SettingsModel::videoAvailableChanged); QObject::connect(coreManager->getHandlers().get(), &CoreHandlers::callCreated, this, &SettingsModel::handleCallCreated); @@ -678,6 +679,19 @@ void SettingsModel::setShowVideoCodecs (bool status) { emit showVideoCodecsChanged(status); } +bool SettingsModel::getVideoAvailable() const{ + return getVideoEnabled() && haveAtLeastOneVideoCodec(); +} + +bool SettingsModel::haveAtLeastOneVideoCodec() const{ + auto codecs = CoreManager::getInstance()->getCore()->getVideoPayloadTypes(); + for (auto &codec : codecs){ + if(codec->enabled() && codec->isUsable()) + return true; + } + return false; +} + // ============================================================================= void SettingsModel::updateCameraMode(){ auto mode = mConfig->getString("video", "main_display_mode", "OccupyAllSpace"); diff --git a/linphone-app/src/components/settings/SettingsModel.hpp b/linphone-app/src/components/settings/SettingsModel.hpp index b5b6374eb..2b13f3039 100644 --- a/linphone-app/src/components/settings/SettingsModel.hpp +++ b/linphone-app/src/components/settings/SettingsModel.hpp @@ -100,6 +100,7 @@ class SettingsModel : public QObject { Q_PROPERTY(QVariantMap videoDefinition READ getVideoDefinition WRITE setVideoDefinition NOTIFY videoDefinitionChanged) Q_PROPERTY(bool videoEnabled READ getVideoEnabled WRITE setVideoEnabled NOTIFY videoEnabledChanged) + Q_PROPERTY(bool videoAvailable READ getVideoAvailable NOTIFY videoAvailableChanged) Q_PROPERTY(bool showVideoCodecs READ getShowVideoCodecs WRITE setShowVideoCodecs NOTIFY showVideoCodecsChanged) @@ -387,8 +388,10 @@ public: Q_INVOKABLE QVariantMap getCurrentPreviewVideoDefinition () const; void setVideoDefinition (const QVariantMap &definition); - bool getVideoEnabled() const; + bool getVideoEnabled() const; // Enabled from settings void setVideoEnabled(const bool& enable); + bool getVideoAvailable() const; // Enabled and have enough codecs. + bool haveAtLeastOneVideoCodec() const; bool getShowVideoCodecs () const; void setShowVideoCodecs (bool status); @@ -742,6 +745,7 @@ signals: // Video. -------------------------------------------------------------------- void videoEnabledChanged(); + void videoAvailableChanged(); void videoDevicesChanged (const QStringList &devices); void videoDeviceChanged (const QString &device); @@ -758,6 +762,8 @@ signals: void callCameraModeChanged(); void videoConferenceLayoutChanged(); + void haveAtLeastOneVideoCodecChanged(); + // Chat & calls. ------------------------------------------------------------- void autoAnswerStatusChanged (bool status); diff --git a/linphone-app/src/components/telephone-numbers/TelephoneNumbersModel.cpp b/linphone-app/src/components/telephone-numbers/TelephoneNumbersModel.cpp index 64c4eb474..feb3b6c35 100644 --- a/linphone-app/src/components/telephone-numbers/TelephoneNumbersModel.cpp +++ b/linphone-app/src/components/telephone-numbers/TelephoneNumbersModel.cpp @@ -253,7 +253,7 @@ const QList> TelephoneNumbersModel::mCountryCod // ----------------------------------------------------------------------------- -TelephoneNumbersModel::TelephoneNumbersModel (QObject *parent) : QAbstractListModel(parent) {} +TelephoneNumbersModel::TelephoneNumbersModel (QObject *parent) : ProxyAbstractObject(parent) {} int TelephoneNumbersModel::rowCount (const QModelIndex &) const { return mCountryCodes.count(); @@ -275,13 +275,24 @@ QVariant TelephoneNumbersModel::data (const QModelIndex &index, int role) const if (role == Qt::DisplayRole) { return countryCode.second; }else if(role == Qt::DisplayRole+1) - return QStringLiteral("%1 (+%2)") - .arg(Utils::getCountryName(countryCode.first)) - .arg(countryCode.second); + return QStringLiteral("%1") + .arg(Utils::getCountryName(countryCode.first)); return QVariant(); } +QVariant TelephoneNumbersModel::getAt(int row){ + if (row < 0 || row >= mCountryCodes.count()) + return QVariant(); + QVariantMap result; + auto roles = roleNames(); + const QPair &countryCode = mCountryCodes[row]; + result[roles[Qt::DisplayRole]] = countryCode.second; + result[roles[Qt::DisplayRole+1]] = QStringLiteral("%1") + .arg(Utils::getCountryName(countryCode.first)); + return result; +} + int TelephoneNumbersModel::getDefaultIndex () const { QLocale::Country country = QLocale().country(); const auto it = find_if( diff --git a/linphone-app/src/components/telephone-numbers/TelephoneNumbersModel.hpp b/linphone-app/src/components/telephone-numbers/TelephoneNumbersModel.hpp index 949b9a14e..9435b580b 100644 --- a/linphone-app/src/components/telephone-numbers/TelephoneNumbersModel.hpp +++ b/linphone-app/src/components/telephone-numbers/TelephoneNumbersModel.hpp @@ -21,12 +21,11 @@ #ifndef TELEPHONE_NUMBERS_MODEL_H_ #define TELEPHONE_NUMBERS_MODEL_H_ -#include #include - +#include "app/proxyModel/ProxyAbstractObject.hpp" // ============================================================================= -class TelephoneNumbersModel : public QAbstractListModel { +class TelephoneNumbersModel : public ProxyAbstractObject { Q_OBJECT Q_PROPERTY(int defaultIndex READ getDefaultIndex CONSTANT) @@ -38,7 +37,8 @@ public: QHash roleNames () const override; QVariant data (const QModelIndex &index, int role = Qt::DisplayRole) const override; - + Q_INVOKABLE QVariant getAt(int); + private: int getDefaultIndex () const; diff --git a/linphone-app/src/config.h.cmake b/linphone-app/src/config.h.cmake index 052946678..6589a2798 100644 --- a/linphone-app/src/config.h.cmake +++ b/linphone-app/src/config.h.cmake @@ -26,6 +26,7 @@ #cmakedefine APPLICATION_VENDOR "${APPLICATION_VENDOR}" #cmakedefine APPLICATION_URL "${APPLICATION_URL}" #cmakedefine APPLICATION_LICENCE "${APPLICATION_LICENCE}" +#cmakedefine APPLICATION_LICENCE_URL "${APPLICATION_LICENCE_URL}" #cmakedefine APPLICATION_SEMVER "${APPLICATION_SEMVER}" #cmakedefine COPYRIGHT_RANGE_DATE "${COPYRIGHT_RANGE_DATE}" #cmakedefine ENABLE_UPDATE_CHECK 1 diff --git a/linphone-app/ui/modules/Common/Form/ComboBox.js b/linphone-app/ui/modules/Common/Form/ComboBox.js index b06d2368f..cbee770ec 100644 --- a/linphone-app/ui/modules/Common/Form/ComboBox.js +++ b/linphone-app/ui/modules/Common/Form/ComboBox.js @@ -66,9 +66,8 @@ function getSelectedEntryText () { // With a `QAbstractListModel`, `text` is empty. QML bug? var model = comboBox.model if (model.data) { - var item = model.data(model.index(comboBox.currentIndex, 0)) - var textRole = comboBox.textRole - return textRole.length > 0 ? item[textRole] : item + var item = model.data(model.index(comboBox.currentIndex, 0), comboBox.textRole) + return item ? item : '' } return '' diff --git a/linphone-app/ui/modules/Linphone/Calls/Calls.js b/linphone-app/ui/modules/Linphone/Calls/Calls.js index 76aba5aac..d603ca27c 100644 --- a/linphone-app/ui/modules/Linphone/Calls/Calls.js +++ b/linphone-app/ui/modules/Linphone/Calls/Calls.js @@ -83,7 +83,7 @@ function getParams (call) { if (status === CallModel.CallStatusIncoming) { var optActions = [] - if (Linphone.SettingsModel.videoEnabled) { + if (Linphone.SettingsModel.videoAvailable) { optActions.push({ handler: call.acceptWithVideo, name: qsTr('acceptVideoCall') diff --git a/linphone-app/ui/modules/Linphone/Dialog/MultimediaParametersDialog.qml b/linphone-app/ui/modules/Linphone/Dialog/MultimediaParametersDialog.qml index 32dbbe0fb..c695e77e2 100644 --- a/linphone-app/ui/modules/Linphone/Dialog/MultimediaParametersDialog.qml +++ b/linphone-app/ui/modules/Linphone/Dialog/MultimediaParametersDialog.qml @@ -198,7 +198,7 @@ DialogPlus { RowLayout { spacing: MultimediaParametersDialogStyle.column.entry.spacing width: parent.width - visible: SettingsModel.videoEnabled + visible: SettingsModel.videoAvailable Icon { icon: MultimediaParametersDialogStyle.column.entry.camera.icon diff --git a/linphone-app/ui/modules/Linphone/Menus/IncallMenu.qml b/linphone-app/ui/modules/Linphone/Menus/IncallMenu.qml index 0779139c2..e01d7a3c7 100644 --- a/linphone-app/ui/modules/Linphone/Menus/IncallMenu.qml +++ b/linphone-app/ui/modules/Linphone/Menus/IncallMenu.qml @@ -129,7 +129,7 @@ Rectangle{ : IncallMenuStyle.settingsIcons.activeSpeakerIcon : IncallMenuStyle.settingsIcons.audioOnlyIcon) , nextPage:layoutMenu - , visible: mainItem.callModel && mainItem.callModel.isConference && SettingsModel.videoEnabled}, + , visible: mainItem.callModel && mainItem.callModel.isConference && SettingsModel.videoAvailable}, { titleIndex: 2 , icon: IncallMenuStyle.settingsIcons.participantsIcon diff --git a/linphone-app/ui/modules/Linphone/Notifications/NotificationReceivedCall.qml b/linphone-app/ui/modules/Linphone/Notifications/NotificationReceivedCall.qml index 5b7cb48a4..30bcacd66 100644 --- a/linphone-app/ui/modules/Linphone/Notifications/NotificationReceivedCall.qml +++ b/linphone-app/ui/modules/Linphone/Notifications/NotificationReceivedCall.qml @@ -62,7 +62,7 @@ Notification { isCustom: true backgroundRadius: 90 colorSet: NotificationReceivedCallStyle.acceptVideoCall - visible: SettingsModel.videoEnabled && notification.call.getRemoteVideoEnabled() + visible: SettingsModel.videoAvailable && notification.call.getRemoteVideoEnabled() onClicked: notification._close(notification.call.acceptWithVideo) } diff --git a/linphone-app/ui/modules/Linphone/SmartSearchBar/SmartSearchBar.qml b/linphone-app/ui/modules/Linphone/SmartSearchBar/SmartSearchBar.qml index b9ea98d4c..e238f422c 100644 --- a/linphone-app/ui/modules/Linphone/SmartSearchBar/SmartSearchBar.qml +++ b/linphone-app/ui/modules/Linphone/SmartSearchBar/SmartSearchBar.qml @@ -67,7 +67,7 @@ SearchBox { searchBox.launchVideoCall(entry.sipAddress) searchBox.closeMenu() }, - visible: SettingsModel.videoEnabled && SettingsModel.outgoingCallsEnabled && SettingsModel.showStartVideoCallButton + visible: SettingsModel.videoAvailable && SettingsModel.outgoingCallsEnabled && SettingsModel.showStartVideoCallButton }, { colorSet: SipAddressesViewStyle.call, secure: 0, diff --git a/linphone-app/ui/modules/Linphone/View/SipAddressesView.qml b/linphone-app/ui/modules/Linphone/View/SipAddressesView.qml index c8c024881..17442528d 100644 --- a/linphone-app/ui/modules/Linphone/View/SipAddressesView.qml +++ b/linphone-app/ui/modules/Linphone/View/SipAddressesView.qml @@ -107,6 +107,10 @@ ScrollableListView { haveEncryption:false, securityLevel:1 }) + MouseArea { + anchors.fill: parent + onClicked: sipAddressesView.entryClicked(contact.entry, -1) + } } ActionBar { diff --git a/linphone-app/ui/scripts/Utils/utils.js b/linphone-app/ui/scripts/Utils/utils.js index 37b3a9bc3..c0a131c4b 100644 --- a/linphone-app/ui/scripts/Utils/utils.js +++ b/linphone-app/ui/scripts/Utils/utils.js @@ -263,7 +263,7 @@ function _indexFinder (array, cb, context) { var length = array.length for (var i = 0; i < length; i++) { - if (cb(array[i], i, array)) { + if (cb( (array.getAt ? array.getAt(i) : array[i]), i, array)) { return i } } diff --git a/linphone-app/ui/views/App/Calls/Dialogs/CallSipAddress.qml b/linphone-app/ui/views/App/Calls/Dialogs/CallSipAddress.qml index 5b8189d3e..2db9b18a5 100644 --- a/linphone-app/ui/views/App/Calls/Dialogs/CallSipAddress.qml +++ b/linphone-app/ui/views/App/Calls/Dialogs/CallSipAddress.qml @@ -75,7 +75,7 @@ DialogPlus { handler: function (entry) { launchVideoCall(entry.sipAddress) }, - visible: SettingsModel.videoEnabled && SettingsModel.showStartVideoCallButton, + visible: SettingsModel.videoAvailable && SettingsModel.showStartVideoCallButton, handlerSipAddress: function(sipAddress) { launchVideoCall(sipAddress) } diff --git a/linphone-app/ui/views/App/Calls/Incall.js b/linphone-app/ui/views/App/Calls/Incall.js index c44091fc6..9981acb92 100644 --- a/linphone-app/ui/views/App/Calls/Incall.js +++ b/linphone-app/ui/views/App/Calls/Incall.js @@ -65,7 +65,7 @@ function handleStatusChanged (status, isFullscreen) { } function handleVideoRequested (call) { - if (window.virtualWindowVisible || !Linphone.SettingsModel.videoEnabled) { + if (window.virtualWindowVisible || !Linphone.SettingsModel.videoAvailable) { call.rejectVideoRequest() return } diff --git a/linphone-app/ui/views/App/Calls/Incall.qml b/linphone-app/ui/views/App/Calls/Incall.qml index 02c045b8a..784e7cd85 100644 --- a/linphone-app/ui/views/App/Calls/Incall.qml +++ b/linphone-app/ui/views/App/Calls/Incall.qml @@ -549,7 +549,7 @@ Rectangle { colorSet: callModel && callModel.cameraEnabled ? IncallStyle.buttons.cameraOn : IncallStyle.buttons.cameraOff updating: callModel.videoEnabled && callModel.updating && !mainItem.layoutChanging enabled: callModel && !callModel.pausedByUser - visible: SettingsModel.videoEnabled + visible: SettingsModel.videoAvailable property bool _activateCamera: false onClicked: if(callModel && !mainItem.layoutChanging){ if( callModel.isConference){// Only deactivate camera in conference. diff --git a/linphone-app/ui/views/App/Calls/IncomingCall.qml b/linphone-app/ui/views/App/Calls/IncomingCall.qml index b0e74ea47..590f4686c 100644 --- a/linphone-app/ui/views/App/Calls/IncomingCall.qml +++ b/linphone-app/ui/views/App/Calls/IncomingCall.qml @@ -16,7 +16,7 @@ AbstractStartingCall { isCustom: true backgroundRadius: 90 colorSet: CallStyle.buttons.acceptVideoCall - visible: SettingsModel.videoEnabled + visible: SettingsModel.videoAvailable onClicked: call.acceptWithVideo() } diff --git a/linphone-app/ui/views/App/Calls/WaitingRoom.qml b/linphone-app/ui/views/App/Calls/WaitingRoom.qml index 5fab5831a..7486521e4 100644 --- a/linphone-app/ui/views/App/Calls/WaitingRoom.qml +++ b/linphone-app/ui/views/App/Calls/WaitingRoom.qml @@ -20,7 +20,7 @@ Rectangle { color: WaitingRoomStyle.backgroundColor.color property ConferenceInfoModel conferenceInfoModel property CallModel callModel // Store the call for processing calling. - property bool previewLoaderEnabled: callModel ? callModel.videoEnabled : SettingsModel.videoEnabled + property bool previewLoaderEnabled: callModel ? callModel.videoEnabled : SettingsModel.videoAvailable property var _sipAddressObserver: callModel ? SipAddressesModel.getSipAddressObserver(callModel.fullPeerAddress, callModel.fullLocalAddress) : undefined property bool isEnded: callModel && callModel.status == CallModel.CallStatusEnded @@ -157,7 +157,7 @@ Rectangle { : mainItem.callModel ? mainItem.callModel.conferenceModel : null - deactivateCamera: !SettingsModel.videoEnabled || !mainItem.previewLoaderEnabled || mainItem.isEnded + deactivateCamera: !SettingsModel.videoAvailable || !mainItem.previewLoaderEnabled || mainItem.isEnded /* image: mainItem._sipAddressObserver && mainItem._sipAddressObserver.contact && mainItem._sipAddressObserver.contact.vcard.avatar @@ -307,7 +307,7 @@ Rectangle { ActionSwitch { id: camera property bool cameraEnabled: true - visible: !mainItem.callModel && SettingsModel.videoEnabled + visible: !mainItem.callModel && SettingsModel.videoAvailable isCustom: true backgroundRadius: 90 colorSet: cameraEnabled ? WaitingRoomStyle.buttons.cameraOn : WaitingRoomStyle.buttons.cameraOff @@ -362,7 +362,7 @@ Rectangle { anchors.right: optionsButton.left anchors.rightMargin: 10 - visible: !mainItem.callModel && SettingsModel.videoEnabled + visible: !mainItem.callModel && SettingsModel.videoAvailable toggled: layoutMenu.visible isCustom: true backgroundRadius: width/2 diff --git a/linphone-app/ui/views/App/Main/Assistant/ActivateAppSipAccountWithPhoneNumber.qml b/linphone-app/ui/views/App/Main/Assistant/ActivateAppSipAccountWithPhoneNumber.qml index ab5c5b9b2..551d1b3ab 100644 --- a/linphone-app/ui/views/App/Main/Assistant/ActivateAppSipAccountWithPhoneNumber.qml +++ b/linphone-app/ui/views/App/Main/Assistant/ActivateAppSipAccountWithPhoneNumber.qml @@ -22,13 +22,13 @@ AssistantAbstractView { Column { anchors.centerIn: parent spacing: ActivateAppSipAccountWithPhoneNumberStyle.spacing - width: parent.width + width: parent.width - 10 Text { color: ActivateAppSipAccountWithPhoneNumberStyle.activationSteps.colorModel.color font.pointSize: ActivateAppSipAccountWithPhoneNumberStyle.activationSteps.pointSize horizontalAlignment: Text.AlignHCenter - text: qsTr('activationSteps').replace('%1', assistantModel.phoneNumber) + text: qsTr('activationSteps').replace('%1', assistantModel.computedPhoneNumber) width: parent.width wrapMode: Text.WordWrap } diff --git a/linphone-app/ui/views/App/Main/Assistant/CreateAppSipAccountWithPhoneNumber.qml b/linphone-app/ui/views/App/Main/Assistant/CreateAppSipAccountWithPhoneNumber.qml index 3035823cf..ce8dc7539 100644 --- a/linphone-app/ui/views/App/Main/Assistant/CreateAppSipAccountWithPhoneNumber.qml +++ b/linphone-app/ui/views/App/Main/Assistant/CreateAppSipAccountWithPhoneNumber.qml @@ -1,9 +1,13 @@ import QtQuick 2.7 +import QtQuick.Layouts 1.0 import Common 1.0 import Linphone 1.0 import Common.Styles 1.0 + +import 'qrc:/ui/scripts/Utils/utils.js' as Utils + // ============================================================================= AssistantAbstractView { @@ -12,13 +16,6 @@ AssistantAbstractView { property alias usernameError: username.error property alias phoneNumberError: phoneNumber.error - function setCountryCode (index) { - if(index>=0){ - var model = country.model - assistantModel.countryCode = model.data(model.index(index, 0),"countryCode") - } - } - title: qsTr('createAppSipAccountTitle').replace('%1', Qt.application.name.toUpperCase()) mainAction: requestBlock.execute @@ -45,39 +42,57 @@ AssistantAbstractView { currentIndex: model.defaultIndex model: TelephoneNumbersModel {} textRole: 'countryName' - + function setCode(code){ + currentIndex = Utils.findIndex(model, function (phoneModel) { + return phoneModel.countryCode === code + }) + assistantModel.setCountryCode(currentIndex) + } onActivated: { - view.setCountryCode(index) - var text = phoneNumber.text - if (text.length > 0) { - assistantModel.phoneNumber = text - } + assistantModel.setCountryCode(index) } } } - } - - FormLine { - FormGroup { - label: qsTr('phoneNumberLabel') - - TextField { - id: phoneNumber - - inputMethodHints: Qt.ImhDialableCharactersOnly - - onTextChanged: assistantModel.phoneNumber = text - } - } - } - + } + + FormLine { + FormGroup { + label: qsTr('phoneNumberLabel') + RowLayout{ + spacing: 5 + TextField { + id: countryCode + Layout.fillHeight: true + Layout.preferredWidth: 50 + inputMethodHints: Qt.ImhDialableCharactersOnly + text: "+"+assistantModel.countryCode + cursorPosition:1 + onCursorPositionChanged: if(cursorPosition == 0) cursorPosition = 1 + onTextEdited: { + country.setCode(text.substring(1)) + + } + } + TextField { + id: phoneNumber + Layout.fillHeight: true + Layout.fillWidth: true + inputMethodHints: Qt.ImhDialableCharactersOnly + + text: assistantModel.phoneNumber + onTextChanged: if( assistantModel.phoneNumber != text) assistantModel.phoneNumber = text + } + } + } + } + FormLine { FormGroup { label: qsTr('usernameLabel') TextField { id: username - placeholderText: phoneNumber.text + placeholderText: assistantModel.computedPhoneNumber onTextChanged: assistantModel.username = text } } @@ -111,8 +126,15 @@ AssistantAbstractView { id: assistantModel configFilename: 'create-app-sip-account.rc' + + function setCountryCode (index) { + if(index>=0){ + var model = country.model + assistantModel.countryCode = model.data(model.index(index, 0),"countryCode") + } + } - Component.onCompleted: view.setCountryCode(country.model.defaultIndex) + Component.onCompleted: setCountryCode(country.model.defaultIndex) onPhoneNumberChanged: phoneNumberError = error onUsernameChanged: usernameError = error diff --git a/linphone-app/ui/views/App/Main/Assistant/UseAppSipAccount.qml b/linphone-app/ui/views/App/Main/Assistant/UseAppSipAccount.qml index fa9197a26..b3dd12cba 100644 --- a/linphone-app/ui/views/App/Main/Assistant/UseAppSipAccount.qml +++ b/linphone-app/ui/views/App/Main/Assistant/UseAppSipAccount.qml @@ -12,7 +12,7 @@ import Common.Styles 1.0 AssistantAbstractView { id: view - readonly property bool usePhoneNumber: SettingsModel.assistantSupportsPhoneNumbers && !checkBox.checked + readonly property alias usePhoneNumber: assistantModel.usePhoneNumber mainAction: requestBlock.execute mainActionEnabled: { @@ -94,26 +94,34 @@ AssistantAbstractView { id: assistantModel function setCountryCode (index) { - var model = telephoneNumbersModel - assistantModel.countryCode = index !== -1 ? model.data(model.index(index, 0),"countryCode") || '' : '' + if( index >= 0) { + var model = telephoneNumbersModel + //assistantModel.countryCode = index !== -1 ? model.data(model.index(index, 0),"countryCode") || '' : '' + assistantModel.countryCode = model.data(model.index(index, 0),"countryCode") + } } configFilename: 'use-app-sip-account.rc' - - countryCode: setCountryCode(view.usePhoneNumber ? telephoneNumbersModel.defaultIndex : -1) + usePhoneNumber: SettingsModel.assistantSupportsPhoneNumbers && !checkBox.checked + //countryCode: setCountryCode(view.usePhoneNumber ? telephoneNumbersModel.defaultIndex : -1) onPasswordChanged: { - if (!view.usePhoneNumber) { + if (!usePhoneNumber) { loader.item.passwordError = error } } onPhoneNumberChanged: { - if (view.usePhoneNumber) { + if (usePhoneNumber) { loader.item.phoneNumberError = error } } - + onCreateStatusChanged: { + requestBlock.setText(error) + if (error.length) { + return + } + } onLoginStatusChanged: { requestBlock.setText(error) if (!error.length) { @@ -144,6 +152,7 @@ AssistantAbstractView { }) } } + Component.onCompleted: setCountryCode(telephoneNumbersModel.defaultIndex) } TelephoneNumbersModel { diff --git a/linphone-app/ui/views/App/Main/Assistant/UseAppSipAccountWithPhoneNumber.qml b/linphone-app/ui/views/App/Main/Assistant/UseAppSipAccountWithPhoneNumber.qml index 53bf24dfc..6ac1f34a8 100644 --- a/linphone-app/ui/views/App/Main/Assistant/UseAppSipAccountWithPhoneNumber.qml +++ b/linphone-app/ui/views/App/Main/Assistant/UseAppSipAccountWithPhoneNumber.qml @@ -1,5 +1,8 @@ import Common 1.0 import Linphone 1.0 +import QtQuick.Layouts 1.0 + +import 'qrc:/ui/scripts/Utils/utils.js' as Utils // ============================================================================= @@ -31,13 +34,15 @@ Form { currentIndex: model.defaultIndex model: telephoneNumbersModel textRole: 'countryName' - + function setCode(code){ + currentIndex = Utils.findIndex(model, function (phoneModel) { + return phoneModel.countryCode === code + }) + assistantModel.setCountryCode(currentIndex) + } + onActivated: { assistantModel.setCountryCode(index) - var text = phoneNumber.text - if (text.length > 0) { - assistantModel.phoneNumber = text - } } } } @@ -46,13 +51,30 @@ Form { FormLine { FormGroup { label: qsTr('phoneNumberLabel') - - TextField { - id: phoneNumber + RowLayout{ + spacing: 5 + TextField { + id: countryCode + Layout.fillHeight: true + Layout.preferredWidth: 50 + inputMethodHints: Qt.ImhDialableCharactersOnly + text: "+"+assistantModel.countryCode + cursorPosition:1 + onCursorPositionChanged: if(cursorPosition == 0) cursorPosition = 1 + onTextEdited: { + country.setCode(text.substring(1)) + + } + } + TextField { + id: phoneNumber + Layout.fillHeight: true + Layout.fillWidth: true - inputMethodHints: Qt.ImhDialableCharactersOnly - text: assistantModel.phoneNumber - onTextChanged: if( assistantModel.phoneNumber != text) assistantModel.phoneNumber = text + inputMethodHints: Qt.ImhDialableCharactersOnly + text: assistantModel.phoneNumber + onTextChanged: if( assistantModel.phoneNumber != text) assistantModel.phoneNumber = text + } } } } diff --git a/linphone-app/ui/views/App/Main/ContactEdit.qml b/linphone-app/ui/views/App/Main/ContactEdit.qml index 28f294d32..cd2fa8fb4 100644 --- a/linphone-app/ui/views/App/Main/ContactEdit.qml +++ b/linphone-app/ui/views/App/Main/ContactEdit.qml @@ -160,7 +160,7 @@ ColumnLayout { backgroundRadius: 90 colorSet: ContactEditStyle.videoCall - visible: SettingsModel.videoEnabled && SettingsModel.outgoingCallsEnabled && SettingsModel.showStartVideoCallButton + visible: SettingsModel.videoAvailable && SettingsModel.outgoingCallsEnabled && SettingsModel.showStartVideoCallButton onClicked: sipAddressesMenu.open(sipAddressesMenu.startVideoCall) } diff --git a/linphone-app/ui/views/App/Main/Contacts.qml b/linphone-app/ui/views/App/Main/Contacts.qml index 6420d42ce..0135fe46c 100644 --- a/linphone-app/ui/views/App/Main/Contacts.qml +++ b/linphone-app/ui/views/App/Main/Contacts.qml @@ -142,7 +142,7 @@ ColumnLayout { isCustom: true backgroundRadius: 90 colorSet: ContactsStyle.videoCall - visible: SettingsModel.videoEnabled && SettingsModel.outgoingCallsEnabled && SettingsModel.getShowStartVideoCallButton() + visible: SettingsModel.videoAvailable && SettingsModel.outgoingCallsEnabled && SettingsModel.getShowStartVideoCallButton() onClicked: actions.itemAt(0).open() } @@ -168,7 +168,7 @@ ColumnLayout { isCustom: true backgroundRadius: 90 colorSet: SettingsModel.getShowStartChatButton() ? ContactsStyle.chat : ContactsStyle.history - visible: SettingsModel.secureChatEnabled + visible: SettingsModel.secureChatEnabled && $modelData && $modelData.hasCapability(LinphoneEnums.FriendCapabilityLimeX3Dh) enabled: AccountSettingsModel.conferenceUri != '' Icon{ icon:'secure_level_1' diff --git a/linphone-app/ui/views/App/Main/Conversation.qml b/linphone-app/ui/views/App/Main/Conversation.qml index 6cb3a8e05..969d51c24 100644 --- a/linphone-app/ui/views/App/Main/Conversation.qml +++ b/linphone-app/ui/views/App/Main/Conversation.qml @@ -262,7 +262,7 @@ ColumnLayout { backgroundRadius: 1000 colorSet: ConversationStyle.bar.actions.videoCall - visible: SettingsModel.videoEnabled && SettingsModel.outgoingCallsEnabled && SettingsModel.showStartVideoCallButton && !conversation.haveMoreThanOneParticipants + visible: SettingsModel.videoAvailable && SettingsModel.outgoingCallsEnabled && SettingsModel.showStartVideoCallButton && !conversation.haveMoreThanOneParticipants onClicked: CallsListModel.launchVideoCall(chatRoomModel.participants.addressesToString) } diff --git a/linphone-app/ui/views/App/Main/Dialogs/About.qml b/linphone-app/ui/views/App/Main/Dialogs/About.qml index 1a5fa6c66..1bc69f475 100644 --- a/linphone-app/ui/views/App/Main/Dialogs/About.qml +++ b/linphone-app/ui/views/App/Main/Dialogs/About.qml @@ -103,6 +103,11 @@ DialogPlus { width: parent.width horizontalAlignment: Text.AlignHCenter + MouseArea{ + anchors.fill: parent + visible: applicationLicenceUrl + onClicked: Qt.openUrlExternally(applicationLicenceUrl) + } } Text { elide: Text.ElideRight diff --git a/linphone-app/ui/views/App/Main/HistoryView.qml b/linphone-app/ui/views/App/Main/HistoryView.qml index b53338c3e..17250e807 100644 --- a/linphone-app/ui/views/App/Main/HistoryView.qml +++ b/linphone-app/ui/views/App/Main/HistoryView.qml @@ -94,7 +94,7 @@ ColumnLayout { isCustom: true backgroundRadius: 90 colorSet: HistoryViewStyle.videoCall - visible: peerAddress && SettingsModel.videoEnabled && SettingsModel.outgoingCallsEnabled && SettingsModel.showStartVideoCallButton + visible: peerAddress && SettingsModel.videoAvailable && SettingsModel.outgoingCallsEnabled && SettingsModel.showStartVideoCallButton onClicked: CallsListModel.launchVideoCall(historyView.peerAddress) }