diff --git a/Linphone/core/account/AccountList.cpp b/Linphone/core/account/AccountList.cpp index 3b837b5e..920cec1f 100644 --- a/Linphone/core/account/AccountList.cpp +++ b/Linphone/core/account/AccountList.cpp @@ -99,9 +99,22 @@ void AccountList::setDefaultAccount(QSharedPointer account) { emit defaultAccountChanged(); } } + +AccountGui *AccountList::findAccountByAddress(const QString &address) { + for (auto &item : mList) { + if (auto isAccount = item.objectCast()) { + if (isAccount->getIdentityAddress() == address) { + return new AccountGui(isAccount); + } + } + } + return nullptr; +} + bool AccountList::getHaveAccount() const { return mHaveAccount; } + void AccountList::setHaveAccount(bool haveAccount) { if (mHaveAccount != haveAccount) { mHaveAccount = haveAccount; diff --git a/Linphone/core/account/AccountList.hpp b/Linphone/core/account/AccountList.hpp index 7b8febce..19c8fbce 100644 --- a/Linphone/core/account/AccountList.hpp +++ b/Linphone/core/account/AccountList.hpp @@ -43,6 +43,7 @@ public: AccountGui *getDefaultAccount() const; QSharedPointer getDefaultAccountCore() const; void setDefaultAccount(QSharedPointer account); + AccountGui *findAccountByAddress(const QString &address); bool getHaveAccount() const; void setHaveAccount(bool haveAccount); diff --git a/Linphone/core/account/AccountProxy.cpp b/Linphone/core/account/AccountProxy.cpp index 0cf37773..7de0bc30 100644 --- a/Linphone/core/account/AccountProxy.cpp +++ b/Linphone/core/account/AccountProxy.cpp @@ -61,6 +61,10 @@ void AccountProxy::resetDefaultAccount() { emit this->defaultAccountChanged(); // Warn the UI } +AccountGui *AccountProxy::findAccountByAddress(const QString &address) { + return dynamic_cast(sourceModel())->findAccountByAddress(address); +} + bool AccountProxy::getHaveAccount() const { return dynamic_cast(sourceModel())->getHaveAccount(); } diff --git a/Linphone/core/account/AccountProxy.hpp b/Linphone/core/account/AccountProxy.hpp index 65021940..75087495 100644 --- a/Linphone/core/account/AccountProxy.hpp +++ b/Linphone/core/account/AccountProxy.hpp @@ -44,6 +44,7 @@ public: AccountGui *getDefaultAccount(); // Get a new object from List or give the stored one. void setDefaultAccount(AccountGui *account); // TODO void resetDefaultAccount(); // Reset the default account to let UI build its new object if needed. + Q_INVOKABLE AccountGui *findAccountByAddress(const QString &address); bool getHaveAccount() const; diff --git a/Linphone/model/tool/ToolModel.cpp b/Linphone/model/tool/ToolModel.cpp index 97c7aba0..334db6eb 100644 --- a/Linphone/model/tool/ToolModel.cpp +++ b/Linphone/model/tool/ToolModel.cpp @@ -113,6 +113,13 @@ bool ToolModel::createCall(const QString &sipAddress, } return false; } + for (auto &account : core->getAccountList()) { + if (account->getContactAddress()->weakEqual(address)) { + *errorMessage = "The calling address is a connected account."; + lDebug() << "[" + QString(gClassName) + "]" + *errorMessage; + return false; + } + } std::shared_ptr params = core->createCallParams(nullptr); CallModel::activateLocalVideo(params, nullptr, localVideoEnabled); diff --git a/Linphone/view/App/CallsWindow.qml b/Linphone/view/App/CallsWindow.qml index f4948d9b..24954157 100644 --- a/Linphone/view/App/CallsWindow.qml +++ b/Linphone/view/App/CallsWindow.qml @@ -179,6 +179,7 @@ AppWindow { ZrtpTokenAuthenticationDialog { id: zrtpValidation call: mainWindow.call + modal: false } Popup { id: waitingPopup @@ -520,6 +521,10 @@ AppWindow { Layout.fillWidth: true Layout.maximumHeight: rightPanel.height visible: callList.contentHeight > 0 + leftPadding: 17 * DefaultStyle.dp + rightPadding: 17 * DefaultStyle.dp + topPadding: 16 * DefaultStyle.dp + bottomPadding: 16 * DefaultStyle.dp contentItem: ListView { id: callList @@ -537,8 +542,6 @@ AppWindow { RowLayout { id: delegateContent anchors.fill: parent - anchors.leftMargin: 10 * DefaultStyle.dp - anchors.rightMargin: 10 * DefaultStyle.dp spacing: 0 Avatar { id: delegateAvatar @@ -550,6 +553,7 @@ AppWindow { id: delegateName property var remoteAddress: UtilsCpp.getDisplayName(modelData.core.peerAddress) text: remoteAddress ? remoteAddress.value : "" + Layout.leftMargin: 8 * DefaultStyle.dp Connections { target: modelData.core } @@ -560,6 +564,7 @@ AppWindow { } Text { id: callStateText + Layout.rightMargin: 2 * DefaultStyle.dp text: modelData.core.state === LinphoneEnums.CallState.Paused || modelData.core.state === LinphoneEnums.CallState.PausedByRemote ? qsTr("Appel en pause") : qsTr("Appel en cours") @@ -568,7 +573,6 @@ AppWindow { id: listCallOptionsButton Layout.preferredWidth: 24 * DefaultStyle.dp Layout.preferredHeight: 24 * DefaultStyle.dp - Layout.alignment: Qt.AlignRight popup.contentItem: ColumnLayout { spacing: 0 diff --git a/Linphone/view/App/Layout/MainLayout.qml b/Linphone/view/App/Layout/MainLayout.qml index cf264bf2..06196102 100644 --- a/Linphone/view/App/Layout/MainLayout.qml +++ b/Linphone/view/App/Layout/MainLayout.qml @@ -219,7 +219,7 @@ Item { } Text { id: sipAddr - text: UtilsCpp.generateLinphoneSipAddress(magicSearchBar.text) + text: magicSearchBar.text } } Item { @@ -236,6 +236,7 @@ Item { } onClicked: { UtilsCpp.createCall(sipAddr.text) + magicSearchBar.clearText() } } Button { @@ -246,7 +247,10 @@ Item { anchors.fill: parent source: AppIcons.videoCamera } - onClicked: UtilsCpp.createCall(sipAddr.text, {'localVideoEnabled':true}) + onClicked: { + UtilsCpp.createCall(sipAddr.text, {'localVideoEnabled':true}) + magicSearchBar.clearText() + } } } Button { @@ -275,6 +279,7 @@ Item { } onClicked: { mainItem.createContact(magicSearchBar.text, sipAddr.text) + magicSearchBar.clearText() listPopup.close() } } diff --git a/Linphone/view/Item/Call/WaitingRoom.qml b/Linphone/view/Item/Call/WaitingRoom.qml index 3f99d08f..fbba735c 100644 --- a/Linphone/view/Item/Call/WaitingRoom.qml +++ b/Linphone/view/Item/Call/WaitingRoom.qml @@ -32,7 +32,7 @@ RowLayout { AccountProxy{ id: accounts } - account: accounts.defaultAccount + account: accounts.findAccountByAddress(mainItem.localAddress) } RowLayout { Layout.alignment: Qt.AlignHCenter diff --git a/Linphone/view/Item/Form/LoginForm.qml b/Linphone/view/Item/Form/LoginForm.qml index 5d5579ad..df2e4918 100644 --- a/Linphone/view/Item/Form/LoginForm.qml +++ b/Linphone/view/Item/Form/LoginForm.qml @@ -72,12 +72,13 @@ ColumnLayout { Layout.topMargin: 7 * DefaultStyle.dp spacing: 29 * DefaultStyle.dp Button { + id: connectionButton leftPadding: 20 * DefaultStyle.dp rightPadding: 20 * DefaultStyle.dp topPadding: 11 * DefaultStyle.dp bottomPadding: 11 * DefaultStyle.dp contentItem: StackLayout { - id: connectionButton + id: connectionButtonContent currentIndex: 0 Text { text: qsTr("Connexion") @@ -100,15 +101,16 @@ ColumnLayout { target: LoginPageCpp onRegistrationStateChanged: { if (LoginPageCpp.registrationState != LinphoneEnums.RegistrationState.Progress) { - connectionButton.currentIndex = 0 + connectionButtonContent.currentIndex = 0 } } onErrorMessageChanged: { - connectionButton.currentIndex = 0 + connectionButtonContent.currentIndex = 0 } } } - onClicked: { + + function trigger() { username.errorMessage = "" password.errorMessage = "" errorText.text = "" @@ -121,8 +123,14 @@ ColumnLayout { return } LoginPageCpp.login(usernameEdit.text, passwordEdit.text) - connectionButton.currentIndex = 1 + connectionButtonContent.currentIndex = 1 } + + Shortcut { + sequences: ["Return", "Enter"] + onActivated: connectionButton.trigger() + } + onPressed: connectionButton.trigger() } Button { background: Item { diff --git a/Linphone/view/Item/SearchBar.qml b/Linphone/view/Item/SearchBar.qml index 051a5a5c..ec717d30 100644 --- a/Linphone/view/Item/SearchBar.qml +++ b/Linphone/view/Item/SearchBar.qml @@ -19,6 +19,10 @@ Rectangle { onVisibleChanged: if (!visible && numericPad) numericPad.close() + function clearText() { + textField.text = "" + } + Connections { enabled: numericPad != undefined target: numericPad ? numericPad : null diff --git a/Linphone/view/Layout/Call/ActiveSpeakerLayout.qml b/Linphone/view/Layout/Call/ActiveSpeakerLayout.qml index c6ae3bd2..6e5ee04c 100644 --- a/Linphone/view/Layout/Call/ActiveSpeakerLayout.qml +++ b/Linphone/view/Layout/Call/ActiveSpeakerLayout.qml @@ -14,6 +14,11 @@ Item{ property alias call: allDevices.currentCall property ConferenceGui conference: call && call.core.conference || null property var callState: call && call.core.state || undefined + property string localAddress: call && call.conference + ? call.conference.core.me.core.sipAddress + : call.core.localAddress + || "" + onLocalAddressChanged: console.log("======== local addr changed", localAddress) property ParticipantDeviceProxy participantDevices : ParticipantDeviceProxy { id: allDevices @@ -80,11 +85,10 @@ Item{ anchors.bottom: mainItem.bottom anchors.rightMargin: 20 * DefaultStyle.dp anchors.bottomMargin: 10 * DefaultStyle.dp - //participantDevice: allDevices.me videoEnabled: preview.visible && mainItem.call && mainItem.call.core.localVideoEnabled onVideoEnabledChanged: console.log("P : " +videoEnabled + " / " +visible +" / " +mainItem.call) property AccountProxy accounts: AccountProxy{id: accountProxy} - account: accountProxy.defaultAccount + account: accountProxy.findAccountByAddress(mainItem.localAddress) call: mainItem.call displayAll: false displayPresence: false diff --git a/Linphone/view/Layout/Call/GridLayout.qml b/Linphone/view/Layout/Call/GridLayout.qml index e6c6fccb..6d43f02c 100644 --- a/Linphone/view/Layout/Call/GridLayout.qml +++ b/Linphone/view/Layout/Call/GridLayout.qml @@ -40,7 +40,7 @@ Mosaic { anchors.fill: parent qmlName: 'G_'+index call: !grid.call.core.isConference ? grid.call : null - account: index == 0 ? accountProxy.defaultAccount : null + account: index == 0 ? accountProxy.findAccountByAddress(mainItem.localAddress) : null displayAll: false bigBottomAddress: true displayPresence: false diff --git a/Linphone/view/Page/Main/CallPage.qml b/Linphone/view/Page/Main/CallPage.qml index e7f6e4aa..035ec549 100644 --- a/Linphone/view/Page/Main/CallPage.qml +++ b/Linphone/view/Page/Main/CallPage.qml @@ -512,7 +512,7 @@ AbstractMainPage { id: contactDetail visible: mainItem.selectedRowHistoryGui != undefined property var contactObj: UtilsCpp.findFriendByAddress(contactAddress) - contact: contactObj ? contactObj.value : null + contact: contactObj && contactObj.value || null contactAddress: mainItem.selectedRowHistoryGui && mainItem.selectedRowHistoryGui.core.remoteAddress || "" contactName: mainItem.selectedRowHistoryGui ? mainItem.selectedRowHistoryGui.core.displayName : "" anchors.top: rightPanelStackView.top