fix transfer

This commit is contained in:
Gaelle Braud 2024-07-04 12:59:13 +02:00
parent bbc409f4b1
commit 7fe1129ea7
9 changed files with 94 additions and 116 deletions

View file

@ -280,20 +280,17 @@ void CallCore::setSelf(QSharedPointer<CallCore> me) {
mCallModelConnection->invokeToCore([this, paused]() { setPaused(paused); }); mCallModelConnection->invokeToCore([this, paused]() { setPaused(paused); });
}); });
mCallModelConnection->makeConnectToCore(&CallCore::lTransferCall, [this](const QString &address) { mCallModelConnection->makeConnectToCore(&CallCore::lTransferCall, [this](QString address) {
mCallModelConnection->invokeToModel( mCallModelConnection->invokeToModel([this, address]() {
[this, address]() { mCallModel->transferTo(ToolModel::interpretUrl(address)); }); auto linAddr = ToolModel::interpretUrl(address);
if (linAddr) mCallModel->transferTo(linAddr);
});
}); });
mCallModelConnection->makeConnectToModel( mCallModelConnection->makeConnectToModel(
&CallModel::transferStateChanged, &CallModel::transferStateChanged,
[this](const std::shared_ptr<linphone::Call> &call, linphone::Call::State state) { [this](const std::shared_ptr<linphone::Call> &call, linphone::Call::State state) {
mCallModelConnection->invokeToCore([this, state]() { mCallModelConnection->invokeToCore(
QString message; [this, state]() { setTransferState(LinphoneEnums::fromLinphone(state)); });
if (state == linphone::Call::State::Error) {
message = "L'appel n'a pas pu être transféré.";
}
setTransferState(LinphoneEnums::fromLinphone(state), message);
});
}); });
mCallModelConnection->makeConnectToModel( mCallModelConnection->makeConnectToModel(
&CallModel::encryptionChanged, &CallModel::encryptionChanged,
@ -715,10 +712,9 @@ LinphoneEnums::CallState CallCore::getTransferState() const {
return mTransferState; return mTransferState;
} }
void CallCore::setTransferState(LinphoneEnums::CallState state, const QString &message) { void CallCore::setTransferState(LinphoneEnums::CallState state) {
if (mTransferState != state) { if (mTransferState != state) {
mTransferState = state; mTransferState = state;
if (state == LinphoneEnums::CallState::Error) setLastErrorMessage(message);
emit transferStateChanged(); emit transferStateChanged();
} }
} }

View file

@ -217,7 +217,7 @@ public:
void setInputDeviceName(const QString &id); void setInputDeviceName(const QString &id);
LinphoneEnums::CallState getTransferState() const; LinphoneEnums::CallState getTransferState() const;
void setTransferState(LinphoneEnums::CallState state, const QString &message); void setTransferState(LinphoneEnums::CallState state);
LinphoneEnums::ConferenceLayout getConferenceVideoLayout() const; LinphoneEnums::ConferenceLayout getConferenceVideoLayout() const;
void setConferenceVideoLayout(LinphoneEnums::ConferenceLayout layout); void setConferenceVideoLayout(LinphoneEnums::ConferenceLayout layout);
@ -276,7 +276,7 @@ signals:
void lSetLocalVideoEnabled(bool enabled); void lSetLocalVideoEnabled(bool enabled);
void lSetVideoEnabled(bool enabled); void lSetVideoEnabled(bool enabled);
void lSetPaused(bool paused); void lSetPaused(bool paused);
void lTransferCall(QString &est); void lTransferCall(QString address);
void lStartRecording(); void lStartRecording();
void lStopRecording(); void lStopRecording();
void lCheckAuthenticationTokenSelected(const QString &token); void lCheckAuthenticationTokenSelected(const QString &token);

View file

@ -34,6 +34,8 @@ ApplicationWindow {
id: startCallPopup id: startCallPopup
property FriendGui contact property FriendGui contact
property bool videoEnabled property bool videoEnabled
// if currentCall, transfer call to contact
property CallGui currentCall
onContactChanged: { onContactChanged: {
console.log("contact changed", contact) console.log("contact changed", contact)
} }
@ -119,7 +121,10 @@ ApplicationWindow {
anchors.fill: parent anchors.fill: parent
hoverEnabled: true hoverEnabled: true
cursorShape: containsMouse ? Qt.PointingHandCursor : Qt.ArrowCursor cursorShape: containsMouse ? Qt.PointingHandCursor : Qt.ArrowCursor
onClicked: UtilsCpp.createCall(modelData.address, {'localVideoEnabled': startCallPopup.videoEnabled}) onClicked: {
if (startCallPopup.currentCall) startCallPopup.currentCall.core.lTransferCall(modelData.address)
else UtilsCpp.createCall(modelData.address, {'localVideoEnabled': startCallPopup.videoEnabled})
}
} }
} }
} }
@ -127,7 +132,7 @@ ApplicationWindow {
} }
function startCallWithContact(contact, videoEnabled, parentItem) { function startCallWithContact(contact, videoEnabled, parentItem) {
if (parentItem == undefined) parentItem = mainWindow if (parentItem == undefined) parentItem = mainWindow.contentItem
startCallPopup.parent = parentItem startCallPopup.parent = parentItem
if (contact) { if (contact) {
console.log("START CALL WITH", contact.core.displayName, "addresses count", contact.core.allAddresses.length) console.log("START CALL WITH", contact.core.displayName, "addresses count", contact.core.allAddresses.length)
@ -147,6 +152,28 @@ ApplicationWindow {
} }
} }
function transferCallToContact(call, contact, parentItem) {
if (!call || !contact) return
if (parentItem == undefined) parentItem = mainWindow.contentItem
startCallPopup.parent = parentItem
if (contact) {
console.log("TRANSFER CALL TO", contact.core.displayName, "addresses count", contact.core.allAddresses.length, call)
if (contact.core.allAddresses.length > 1) {
startCallPopup.contact = contact
startCallPopup.currentCall = call
startCallPopup.open()
} else {
var addressToCall = contact.core.defaultAddress.length === 0
? contact.core.phoneNumbers.length === 0
? ""
: contact.core.phoneNumbers[0].address
: contact.core.defaultAddress
if (addressToCall.length != 0) call.core.lTransferCall(contact.core.defaultAddress)
}
}
}
function removeFromPopupLayout(index) { function removeFromPopupLayout(index) {
popupLayout.popupList.splice(index, 1) popupLayout.popupList.splice(index, 1)
} }

View file

@ -42,8 +42,7 @@ AppWindow {
onTransferStateChanged: { onTransferStateChanged: {
console.log("Transfer state:", transferState) console.log("Transfer state:", transferState)
if (transferState === LinphoneEnums.CallState.Error) { if (transferState === LinphoneEnums.CallState.Error) {
transferErrorPopup.visible = true UtilsCpp.showInformationPopup(qsTr("Erreur"), qsTr("Le transfert d'appel a échoué"), false, mainWindow)
} }
else if (transferState === LinphoneEnums.CallState.Connected){ else if (transferState === LinphoneEnums.CallState.Connected){
var mainWin = UtilsCpp.getMainWindow() var mainWin = UtilsCpp.getMainWindow()
@ -202,46 +201,26 @@ AppWindow {
padding: 20 * DefaultStyle.dp padding: 20 * DefaultStyle.dp
underlineColor: DefaultStyle.main1_500_main underlineColor: DefaultStyle.main1_500_main
radius: 15 * DefaultStyle.dp radius: 15 * DefaultStyle.dp
width: 278 * DefaultStyle.dp
height: 115 * DefaultStyle.dp
contentItem: ColumnLayout { contentItem: ColumnLayout {
spacing: 0 spacing: 0
BusyIndicator{ BusyIndicator{
Layout.preferredWidth: 33 * DefaultStyle.dp
Layout.preferredHeight: 33 * DefaultStyle.dp
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
} }
Text { Text {
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
text: qsTr("Transfert en cours, veuillez patienter") text: qsTr("Transfert en cours, veuillez patienter")
font {
pixelSize: 14 * DefaultStyle.dp
weight: 400 * DefaultStyle.dp
}
} }
} }
} }
Timer {
id: autoClosePopup
interval: 2000
onTriggered: {
transferErrorPopup.close()
}
}
Popup {
id: transferErrorPopup
onVisibleChanged: if (visible) autoClosePopup.restart()
closePolicy: Control.Popup.NoAutoClose
x : parent.x + parent.width - width
y : parent.y + parent.height - height
rightMargin: 20 * DefaultStyle.dp
bottomMargin: 20 * DefaultStyle.dp
padding: 20 * DefaultStyle.dp
underlineColor: DefaultStyle.danger_500main
radius: 0
contentItem: ColumnLayout {
spacing: 0
Text {
text: qsTr("Erreur de transfert")
}
Text {
Layout.alignment: Qt.AlignHCenter
text: qsTr("Le transfert d'appel a échoué.")
}
}
}
/************************* CONTENT ********************************/ /************************* CONTENT ********************************/
Rectangle { Rectangle {
anchors.fill: parent anchors.fill: parent
@ -349,21 +328,25 @@ AppWindow {
EffectImage { EffectImage {
Layout.preferredWidth: 15 * DefaultStyle.dp Layout.preferredWidth: 15 * DefaultStyle.dp
Layout.preferredHeight: 15 * DefaultStyle.dp Layout.preferredHeight: 15 * DefaultStyle.dp
colorizationColor: mainWindow.call.core.encryption === LinphoneEnums.MediaEncryption.Srtp colorizationColor: mainWindow.call
? DefaultStyle.info_500_main ? mainWindow.call.core.encryption === LinphoneEnums.MediaEncryption.Srtp
: mainWindow.call.core.encryption === LinphoneEnums.MediaEncryption.Zrtp ? DefaultStyle.info_500_main
? mainWindow.call.core.isMismatch || !mainWindow.call.core.tokenVerified : mainWindow.call.core.encryption === LinphoneEnums.MediaEncryption.Zrtp
? DefaultStyle.warning_600 ? mainWindow.call.core.isMismatch || !mainWindow.call.core.tokenVerified
: DefaultStyle.info_500_main ? DefaultStyle.warning_600
: DefaultStyle.grey_0 : DefaultStyle.info_500_main
: DefaultStyle.grey_0
: "transparent"
visible: mainWindow.call && mainWindow.callState === LinphoneEnums.CallState.Connected || mainWindow.callState === LinphoneEnums.CallState.StreamsRunning visible: mainWindow.call && mainWindow.callState === LinphoneEnums.CallState.Connected || mainWindow.callState === LinphoneEnums.CallState.StreamsRunning
imageSource: mainWindow.call.core.encryption === LinphoneEnums.MediaEncryption.Srtp imageSource: mainWindow.call
? mainWindow.call.core.encryption === LinphoneEnums.MediaEncryption.Srtp
? AppIcons.lockSimple ? AppIcons.lockSimple
: mainWindow.call.core.encryption === LinphoneEnums.MediaEncryption.Zrtp : mainWindow.call.core.encryption === LinphoneEnums.MediaEncryption.Zrtp
? mainWindow.call.core.isMismatch || !mainWindow.call.core.tokenVerified ? mainWindow.call.core.isMismatch || !mainWindow.call.core.tokenVerified
? AppIcons.warningCircle ? AppIcons.warningCircle
: AppIcons.lockKey : AppIcons.lockKey
: AppIcons.lockSimpleOpen : AppIcons.lockSimpleOpen
: ""
} }
Text { Text {
text: mainWindow.call && mainWindow.callState === LinphoneEnums.CallState.Connected || mainWindow.callState === LinphoneEnums.CallState.StreamsRunning text: mainWindow.call && mainWindow.callState === LinphoneEnums.CallState.Connected || mainWindow.callState === LinphoneEnums.CallState.StreamsRunning
@ -502,6 +485,7 @@ AppWindow {
Item { Item {
Control.StackView.onActivated: rightPanel.headerTitleText = qsTr("Transfert d'appel") Control.StackView.onActivated: rightPanel.headerTitleText = qsTr("Transfert d'appel")
CallContactsLists { CallContactsLists {
id: callcontactslist
anchors.fill: parent anchors.fill: parent
anchors.topMargin: 21 * DefaultStyle.dp anchors.topMargin: 21 * DefaultStyle.dp
anchors.leftMargin: 16 * DefaultStyle.dp anchors.leftMargin: 16 * DefaultStyle.dp
@ -509,8 +493,8 @@ AppWindow {
groupCallVisible: false groupCallVisible: false
searchBarColor: DefaultStyle.grey_0 searchBarColor: DefaultStyle.grey_0
searchBarBorderColor: DefaultStyle.grey_200 searchBarBorderColor: DefaultStyle.grey_200
onCallButtonPressed: (address) => { onSelectedContactChanged: {
mainWindow.call.core.lTransferCall(address) if (selectedContact) mainWindow.transferCallToContact(mainWindow.call, selectedContact, callcontactslist)
} }
} }
} }

View file

@ -19,19 +19,17 @@ Item {
property bool helpHidden: true property bool helpHidden: true
signal addAccountRequest() signal addAccountRequest()
signal openNewCall()
signal createContactRequested(string name, string address)
function goToNewCall() { function goToNewCall() {
tabbar.currentIndex = 0 tabbar.currentIndex = 0
callPage.goToNewCall() mainItem.openNewCall()
}
function transferCallSucceed() {
transferSucceedPopup.open()
} }
function createContact(name, address) { function createContact(name, address) {
tabbar.currentIndex = 1 tabbar.currentIndex = 1
contactPage.createContact(name, address) mainItem.createContactRequested(name, address)
} }
AccountProxy { AccountProxy {
@ -46,54 +44,6 @@ Item {
transferSucceedPopup.close() transferSucceedPopup.close()
} }
} }
Popup {
id: transferSucceedPopup
onVisibleChanged: if (visible) autoClosePopup.restart()
closePolicy: Control.Popup.NoAutoClose
x : parent.x + parent.width - width
y : parent.y + parent.height - height
rightMargin: 20 * DefaultStyle.dp
bottomMargin: 20 * DefaultStyle.dp
padding: 20 * DefaultStyle.dp
underlineColor: DefaultStyle.success_500main
radius: 0
contentItem: RowLayout {
spacing: 15 * DefaultStyle.dp
EffectImage {
imageSource: AppIcons.smiley
colorizationColor: DefaultStyle.success_500main
Layout.preferredWidth: 32 * DefaultStyle.dp
Layout.preferredHeight: 32 * DefaultStyle.dp
width: 32 * DefaultStyle.dp
height: 32 * DefaultStyle.dp
}
Rectangle {
Layout.preferredWidth: 1 * DefaultStyle.dp
Layout.preferredHeight: parent.height
color: DefaultStyle.main2_200
}
ColumnLayout {
Text {
text: qsTr("Appel transféré")
color: DefaultStyle.success_500main
font {
pixelSize: 16 * DefaultStyle.dp
weight: 800 * DefaultStyle.dp
}
}
Text {
Layout.alignment: Qt.AlignHCenter
Layout.fillWidth: true
text: qsTr("Votre correspondant a été transféré au contact sélectionné")
color: DefaultStyle.main2_500main
font {
pixelSize: 12 * DefaultStyle.dp
weight: 300 * DefaultStyle.dp
}
}
}
}
}
Item{ Item{
anchors.fill: parent anchors.fill: parent
ColumnLayout{ ColumnLayout{
@ -417,12 +367,24 @@ Item {
currentIndex: tabbar.currentIndex currentIndex: tabbar.currentIndex
CallPage { CallPage {
id: callPage id: callPage
Connections {
target: mainItem
onOpenNewCall: callPage.goToNewCall()
}
onCreateContactRequested: (name, address) => { onCreateContactRequested: (name, address) => {
mainItem.createContact(name, address) mainItem.createContact(name, address)
} }
} }
ContactPage{ ContactPage{
id: contactPage id: contactPage
Connections {
target: mainItem
onCreateContactRequested: (name, address) => {
contactPage.createContact(name, address)
}
}
} }
Item{} Item{}
//ConversationPage{} //ConversationPage{}

View file

@ -30,7 +30,7 @@ AppWindow {
} }
function transferCallSucceed() { function transferCallSucceed() {
mainWindowStackView.replace(mainPage, StackView.Immediate) mainWindowStackView.replace(mainPage, StackView.Immediate)
mainWindowStackView.currentItem.transferCallSucceed() UtilsCpp.showInformationPopup(qsTr("Appel transféré"), qsTr("Votre correspondant a été transféré au contact sélectionné"))
} }
function initStackViewItem() { function initStackViewItem() {
if (accountProxy.haveAccount) mainWindowStackView.replace(mainPage, StackView.Immediate) if (accountProxy.haveAccount) mainWindowStackView.replace(mainPage, StackView.Immediate)

View file

@ -12,8 +12,10 @@ Item {
property bool groupCallVisible property bool groupCallVisible
property color searchBarColor: DefaultStyle.grey_100 property color searchBarColor: DefaultStyle.grey_100
property color searchBarBorderColor: "transparent" property color searchBarBorderColor: "transparent"
property alias searchBar: searchBar
signal callButtonPressed(string address) signal callButtonPressed(string address)
signal groupCallCreationRequested() signal groupCallCreationRequested()
property FriendGui selectedContact
property NumericPad numPad property NumericPad numPad
clip: true clip: true
@ -117,7 +119,7 @@ Item {
model: MagicSearchProxy { model: MagicSearchProxy {
searchText: searchBar.text.length === 0 ? "*" : searchBar.text searchText: searchBar.text.length === 0 ? "*" : searchBar.text
} }
onSelectedContactChanged: mainWindow.startCallWithContact(selectedContact, false, mainItem.parent) onSelectedContactChanged: mainItem.selectedContact = selectedContact
} }
} }
ColumnLayout { ColumnLayout {
@ -142,7 +144,7 @@ Item {
sourceFlags: LinphoneEnums.MagicSearchSource.All sourceFlags: LinphoneEnums.MagicSearchSource.All
aggregationFlag: LinphoneEnums.MagicSearchAggregation.Friend aggregationFlag: LinphoneEnums.MagicSearchAggregation.Friend
} }
onSelectedContactChanged: mainWindow.startCallWithContact(selectedContact, false, mainItem.parent) onSelectedContactChanged: mainItem.selectedContact = selectedContact
} }
} }
Item { Item {

View file

@ -272,7 +272,7 @@ RightPanelLayout {
} }
ErrorText { ErrorText {
id: addressesErrorText id: addressesErrorText
wrapMode: Qt.WordWrap wrapMode: Text.WordWrap
elide: Text.ElideRight elide: Text.ElideRight
Layout.fillWidth: true Layout.fillWidth: true
} }

View file

@ -23,6 +23,7 @@ AbstractMainPage {
property bool isRegistered: account ? account.core.registrationState == LinphoneEnums.RegistrationState.Ok : false property bool isRegistered: account ? account.core.registrationState == LinphoneEnums.RegistrationState.Ok : false
property int selectedParticipantsCount property int selectedParticipantsCount
signal startGroupCallRequested() signal startGroupCallRequested()
signal createCallFromSearchBarRequested()
signal createContactRequested(string name, string address) signal createContactRequested(string name, string address)
Connections { Connections {
@ -94,7 +95,7 @@ AbstractMainPage {
width: parent.width width: parent.width
height: parent.height height: parent.height
onLaunchCall: { onLaunchCall: {
UtilsCpp.createCall(searchBar.text) mainItem.createCallFromSearchBarRequested()
// TODO : auto completion instead of sip linphone // TODO : auto completion instead of sip linphone
} }
} }
@ -408,15 +409,21 @@ AbstractMainPage {
ColumnLayout { ColumnLayout {
Control.StackView.onActivated: titleLoader.sourceComponent = newCallTitle Control.StackView.onActivated: titleLoader.sourceComponent = newCallTitle
CallContactsLists { CallContactsLists {
id: callContactsList
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
numPad: numericPad numPad: numericPad
groupCallVisible: true groupCallVisible: true
searchBarColor: DefaultStyle.grey_100 searchBarColor: DefaultStyle.grey_100
onSelectedContactChanged: mainWindow.startCallWithContact(selectedContact, false, callContactsList)
onGroupCallCreationRequested: { onGroupCallCreationRequested: {
console.log("groupe call requetsed") console.log("groupe call requetsed")
listStackView.push(groupCallItem) listStackView.push(groupCallItem)
} }
Connections {
target: mainItem
onCreateCallFromSearchBarRequested: UtilsCpp.createCall(callContactsList.searchBar.text)
}
} }
} }
} }