fix #LINQT-1338 custom error message in call window
This commit is contained in:
parent
23d73a9ab6
commit
536a67652d
8 changed files with 93 additions and 49 deletions
|
|
@ -257,12 +257,11 @@ void CallCore::setSelf(QSharedPointer<CallCore> me) {
|
||||||
mCallModelConnection->makeConnectToModel(&CallModel::microphoneVolumeChanged, [this](float volume) {
|
mCallModelConnection->makeConnectToModel(&CallModel::microphoneVolumeChanged, [this](float volume) {
|
||||||
mCallModelConnection->invokeToCore([this, volume]() { setMicrophoneVolume(volume); });
|
mCallModelConnection->invokeToCore([this, volume]() { setMicrophoneVolume(volume); });
|
||||||
});
|
});
|
||||||
|
mCallModelConnection->makeConnectToModel(
|
||||||
|
&CallModel::errorMessageChanged, [this](const QString &errorMessage) { setLastErrorMessage(errorMessage); });
|
||||||
mCallModelConnection->makeConnectToModel(&CallModel::stateChanged, [this](std::shared_ptr<linphone::Call> call,
|
mCallModelConnection->makeConnectToModel(&CallModel::stateChanged, [this](std::shared_ptr<linphone::Call> call,
|
||||||
linphone::Call::State state,
|
linphone::Call::State state,
|
||||||
const std::string &message) {
|
const std::string &message) {
|
||||||
mCallModelConnection->invokeToCore([this, state, message]() {
|
|
||||||
setState(LinphoneEnums::fromLinphone(state), Utils::coreStringToAppString(message));
|
|
||||||
});
|
|
||||||
double speakerVolume = mSpeakerVolumeGain;
|
double speakerVolume = mSpeakerVolumeGain;
|
||||||
double micVolumeGain = mMicrophoneVolumeGain;
|
double micVolumeGain = mMicrophoneVolumeGain;
|
||||||
if (state == linphone::Call::State::StreamsRunning) {
|
if (state == linphone::Call::State::StreamsRunning) {
|
||||||
|
|
@ -283,6 +282,7 @@ void CallCore::setSelf(QSharedPointer<CallCore> me) {
|
||||||
setPaused(state == linphone::Call::State::Paused || state == linphone::Call::State::PausedByRemote);
|
setPaused(state == linphone::Call::State::Paused || state == linphone::Call::State::PausedByRemote);
|
||||||
if (mConference) mConference->setSubject(subject);
|
if (mConference) mConference->setSubject(subject);
|
||||||
});
|
});
|
||||||
|
mCallModelConnection->invokeToCore([this, state, message]() { setState(LinphoneEnums::fromLinphone(state)); });
|
||||||
});
|
});
|
||||||
mCallModelConnection->makeConnectToModel(&CallModel::statusChanged, [this](linphone::Call::Status status) {
|
mCallModelConnection->makeConnectToModel(&CallModel::statusChanged, [this](linphone::Call::Status status) {
|
||||||
mCallModelConnection->invokeToCore([this, status]() { setStatus(LinphoneEnums::fromLinphone(status)); });
|
mCallModelConnection->invokeToCore([this, status]() { setStatus(LinphoneEnums::fromLinphone(status)); });
|
||||||
|
|
@ -492,14 +492,10 @@ LinphoneEnums::CallState CallCore::getState() const {
|
||||||
return mState;
|
return mState;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CallCore::setState(LinphoneEnums::CallState state, const QString &message) {
|
void CallCore::setState(LinphoneEnums::CallState state) {
|
||||||
mustBeInMainThread(log().arg(Q_FUNC_INFO));
|
mustBeInMainThread(log().arg(Q_FUNC_INFO));
|
||||||
if (mState != state) {
|
if (mState != state) {
|
||||||
mState = state;
|
mState = state;
|
||||||
if (state == LinphoneEnums::CallState::Error) {
|
|
||||||
lDebug() << "[CallCore] Error message : " << message;
|
|
||||||
setLastErrorMessage(message);
|
|
||||||
}
|
|
||||||
emit stateChanged(mState);
|
emit stateChanged(mState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -154,7 +154,7 @@ public:
|
||||||
void setDir(LinphoneEnums::CallDir dir);
|
void setDir(LinphoneEnums::CallDir dir);
|
||||||
|
|
||||||
LinphoneEnums::CallState getState() const;
|
LinphoneEnums::CallState getState() const;
|
||||||
void setState(LinphoneEnums::CallState state, const QString &message);
|
void setState(LinphoneEnums::CallState state);
|
||||||
|
|
||||||
QString getLastErrorMessage() const;
|
QString getLastErrorMessage() const;
|
||||||
void setLastErrorMessage(const QString &message);
|
void setLastErrorMessage(const QString &message);
|
||||||
|
|
|
||||||
|
|
@ -388,6 +388,29 @@ void CallModel::sendDtmf(const QString &dtmf) {
|
||||||
CoreModel::getInstance()->getCore()->playDtmf(key, gDtmfSoundDelay);
|
CoreModel::getInstance()->getCore()->playDtmf(key, gDtmfSoundDelay);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CallModel::updateCallErrorFromReason(linphone::Reason reason) {
|
||||||
|
QString error;
|
||||||
|
switch (reason) {
|
||||||
|
case linphone::Reason::Declined:
|
||||||
|
error = tr("Le correspondant a décliné l'appel");
|
||||||
|
break;
|
||||||
|
case linphone::Reason::NotFound:
|
||||||
|
error = tr("Le correspondant n'a pas été trouvé");
|
||||||
|
break;
|
||||||
|
case linphone::Reason::Busy:
|
||||||
|
error = tr("Le correspondant est occupé");
|
||||||
|
break;
|
||||||
|
case linphone::Reason::NotAcceptable:
|
||||||
|
error = tr("Le correspondant ne peut accepter votre appel.");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!error.isEmpty()) qInfo() << QStringLiteral("Call terminated with error (%1):").arg(error) << this;
|
||||||
|
emit errorMessageChanged(error);
|
||||||
|
}
|
||||||
|
|
||||||
void CallModel::onDtmfReceived(const std::shared_ptr<linphone::Call> &call, int dtmf) {
|
void CallModel::onDtmfReceived(const std::shared_ptr<linphone::Call> &call, int dtmf) {
|
||||||
CoreModel::getInstance()->getCore()->playDtmf(dtmf, gDtmfSoundDelay);
|
CoreModel::getInstance()->getCore()->playDtmf(dtmf, gDtmfSoundDelay);
|
||||||
emit dtmfReceived(call, dtmf);
|
emit dtmfReceived(call, dtmf);
|
||||||
|
|
@ -431,8 +454,9 @@ void CallModel::onStateChanged(const std::shared_ptr<linphone::Call> &call,
|
||||||
videoDirection == linphone::MediaDirection::SendRecv);
|
videoDirection == linphone::MediaDirection::SendRecv);
|
||||||
setConference(call->getConference());
|
setConference(call->getConference());
|
||||||
updateConferenceVideoLayout();
|
updateConferenceVideoLayout();
|
||||||
} else if (state == linphone::Call::State::End) {
|
} else if (state == linphone::Call::State::End || state == linphone::Call::State::Error) {
|
||||||
mDurationTimer.stop();
|
mDurationTimer.stop();
|
||||||
|
updateCallErrorFromReason(call->getReason());
|
||||||
}
|
}
|
||||||
emit stateChanged(call, state, message);
|
emit stateChanged(call, state, message);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,8 @@ public:
|
||||||
|
|
||||||
void sendDtmf(const QString &dtmf);
|
void sendDtmf(const QString &dtmf);
|
||||||
|
|
||||||
|
void updateCallErrorFromReason(linphone::Reason reason);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void microphoneMutedChanged(bool isMuted);
|
void microphoneMutedChanged(bool isMuted);
|
||||||
void speakerMutedChanged(bool isMuted);
|
void speakerMutedChanged(bool isMuted);
|
||||||
|
|
@ -107,6 +109,7 @@ signals:
|
||||||
void conferenceChanged();
|
void conferenceChanged();
|
||||||
void conferenceVideoLayoutChanged(LinphoneEnums::ConferenceLayout layout);
|
void conferenceVideoLayoutChanged(LinphoneEnums::ConferenceLayout layout);
|
||||||
void videoDescriptorChanged();
|
void videoDescriptorChanged();
|
||||||
|
void errorMessageChanged(const QString &error);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QTimer mDurationTimer;
|
QTimer mDurationTimer;
|
||||||
|
|
|
||||||
|
|
@ -148,6 +148,7 @@ LinphoneEnums::CallDir LinphoneEnums::fromLinphone(const linphone::Call::Dir &da
|
||||||
linphone::Call::Dir LinphoneEnums::toLinphone(const LinphoneEnums::CallDir &data) {
|
linphone::Call::Dir LinphoneEnums::toLinphone(const LinphoneEnums::CallDir &data) {
|
||||||
return static_cast<linphone::Call::Dir>(data);
|
return static_cast<linphone::Call::Dir>(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString LinphoneEnums::toString(const LinphoneEnums::CallDir &data) {
|
QString LinphoneEnums::toString(const LinphoneEnums::CallDir &data) {
|
||||||
switch (data) {
|
switch (data) {
|
||||||
case LinphoneEnums::CallDir::Incoming:
|
case LinphoneEnums::CallDir::Incoming:
|
||||||
|
|
@ -159,6 +160,14 @@ QString LinphoneEnums::toString(const LinphoneEnums::CallDir &data) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LinphoneEnums::Reason LinphoneEnums::fromLinphone(const linphone::Reason &data) {
|
||||||
|
return static_cast<LinphoneEnums::Reason>(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
linphone::Reason LinphoneEnums::toLinphone(const LinphoneEnums::Reason &data) {
|
||||||
|
return static_cast<linphone::Reason>(data);
|
||||||
|
}
|
||||||
|
|
||||||
linphone::Conference::Layout LinphoneEnums::toLinphone(const LinphoneEnums::ConferenceLayout &layout) {
|
linphone::Conference::Layout LinphoneEnums::toLinphone(const LinphoneEnums::ConferenceLayout &layout) {
|
||||||
if (layout != LinphoneEnums::ConferenceLayout::AudioOnly) return static_cast<linphone::Conference::Layout>(layout);
|
if (layout != LinphoneEnums::ConferenceLayout::AudioOnly) return static_cast<linphone::Conference::Layout>(layout);
|
||||||
else return linphone::Conference::Layout::Grid; // Audio Only mode
|
else return linphone::Conference::Layout::Grid; // Audio Only mode
|
||||||
|
|
|
||||||
|
|
@ -179,6 +179,38 @@ linphone::Call::Dir toLinphone(const LinphoneEnums::CallDir &data);
|
||||||
LinphoneEnums::CallDir fromLinphone(const linphone::Call::Dir &data);
|
LinphoneEnums::CallDir fromLinphone(const linphone::Call::Dir &data);
|
||||||
QString toString(const LinphoneEnums::CallDir &data);
|
QString toString(const LinphoneEnums::CallDir &data);
|
||||||
|
|
||||||
|
enum class Reason {
|
||||||
|
None = int(linphone::Reason::None),
|
||||||
|
NoResponse = int(linphone::Reason::NoResponse),
|
||||||
|
Forbidden = int(linphone::Reason::Forbidden),
|
||||||
|
Declined = int(linphone::Reason::Declined),
|
||||||
|
NotFound = int(linphone::Reason::NotFound),
|
||||||
|
NotAnswered = int(linphone::Reason::NotAnswered),
|
||||||
|
Busy = int(linphone::Reason::Busy),
|
||||||
|
UnsupportedContent = int(linphone::Reason::UnsupportedContent),
|
||||||
|
BadEvent = int(linphone::Reason::BadEvent),
|
||||||
|
IOError = int(linphone::Reason::IOError),
|
||||||
|
DoNotDisturb = int(linphone::Reason::DoNotDisturb),
|
||||||
|
Unauthorized = int(linphone::Reason::Unauthorized),
|
||||||
|
NotAcceptable = int(linphone::Reason::NotAcceptable),
|
||||||
|
NoMatch = int(linphone::Reason::NoMatch),
|
||||||
|
MovedPermanently = int(linphone::Reason::MovedPermanently),
|
||||||
|
Gone = int(linphone::Reason::Gone),
|
||||||
|
TemporarilyUnavailable = int(linphone::Reason::TemporarilyUnavailable),
|
||||||
|
AddressIncomplete = int(linphone::Reason::AddressIncomplete),
|
||||||
|
NotImplemented = int(linphone::Reason::NotImplemented),
|
||||||
|
BadGateway = int(linphone::Reason::BadGateway),
|
||||||
|
SessionIntervalTooSmall = int(linphone::Reason::SessionIntervalTooSmall),
|
||||||
|
ServerTimeout = int(linphone::Reason::ServerTimeout),
|
||||||
|
Unknown = int(linphone::Reason::Unknown),
|
||||||
|
Transferred = int(linphone::Reason::Transferred),
|
||||||
|
ConditionalRequestFailed = int(linphone::Reason::ConditionalRequestFailed),
|
||||||
|
SasCheckRequired = int(linphone::Reason::SasCheckRequired)
|
||||||
|
};
|
||||||
|
Q_ENUM_NS(Reason)
|
||||||
|
linphone::Reason toLinphone(const LinphoneEnums::Reason &data);
|
||||||
|
LinphoneEnums::Reason fromLinphone(const linphone::Reason &data);
|
||||||
|
|
||||||
enum class ConferenceLayout {
|
enum class ConferenceLayout {
|
||||||
Grid = int(linphone::Conference::Layout::Grid),
|
Grid = int(linphone::Conference::Layout::Grid),
|
||||||
ActiveSpeaker = int(linphone::Conference::Layout::ActiveSpeaker),
|
ActiveSpeaker = int(linphone::Conference::Layout::ActiveSpeaker),
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,9 @@ Item {
|
||||||
property CallGui call
|
property CallGui call
|
||||||
property ConferenceGui conference: call && call.core.conference
|
property ConferenceGui conference: call && call.core.conference
|
||||||
property bool callTerminatedByUser: false
|
property bool callTerminatedByUser: false
|
||||||
|
property bool callStarted: false
|
||||||
readonly property var callState: call && call.core.state || undefined
|
readonly property var callState: call && call.core.state || undefined
|
||||||
|
onCallStateChanged: if (callState === LinphoneEnums.CallState.Connected) callStarted = true
|
||||||
property int conferenceLayout: call && call.core.conferenceVideoLayout || 0
|
property int conferenceLayout: call && call.core.conferenceVideoLayout || 0
|
||||||
// property int participantDeviceCount: conference ? conference.core.participantDeviceCount : -1
|
// property int participantDeviceCount: conference ? conference.core.participantDeviceCount : -1
|
||||||
// onParticipantDeviceCountChanged: {
|
// onParticipantDeviceCountChanged: {
|
||||||
|
|
@ -25,15 +27,6 @@ Item {
|
||||||
console.log("CallLayout change : " +conferenceLayout)
|
console.log("CallLayout change : " +conferenceLayout)
|
||||||
setConferenceLayout()
|
setConferenceLayout()
|
||||||
}
|
}
|
||||||
onCallStateChanged: {
|
|
||||||
if( callState === LinphoneEnums.CallState.Error) {
|
|
||||||
centerLayout.currentIndex = 1
|
|
||||||
}
|
|
||||||
// else if( callState === LinphoneEnums.CallState.End) {
|
|
||||||
// callTerminatedText.visible = true
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
// onCallChanged: callTerminatedText.visible = false
|
|
||||||
|
|
||||||
function setConferenceLayout() {
|
function setConferenceLayout() {
|
||||||
callLayout.sourceComponent = undefined // unload old view before opening the new view to avoid conflicts in Video UI.
|
callLayout.sourceComponent = undefined // unload old view before opening the new view to avoid conflicts in Video UI.
|
||||||
|
|
@ -48,12 +41,16 @@ Item {
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.topMargin: 25 * DefaultStyle.dp
|
anchors.topMargin: 25 * DefaultStyle.dp
|
||||||
z: 1
|
z: 1
|
||||||
visible: callState === LinphoneEnums.CallState.End
|
visible: callState === LinphoneEnums.CallState.End || callState === LinphoneEnums.CallState.Error || callState === LinphoneEnums.CallState.Released
|
||||||
text: mainItem.conference
|
text: callState === LinphoneEnums.CallState.End
|
||||||
? qsTr("Vous avez quitté la conférence")
|
? mainItem.conference
|
||||||
: mainItem.callTerminatedByUser
|
? qsTr("Vous avez quitté la conférence")
|
||||||
? qsTr("Vous avez terminé l'appel")
|
: mainItem.callStarted
|
||||||
: qsTr("Votre correspondant a terminé l'appel")
|
? mainItem.callTerminatedByUser
|
||||||
|
? qsTr("Vous avez terminé l'appel")
|
||||||
|
: qsTr("Votre correspondant a terminé l'appel")
|
||||||
|
: call.core.lastErrorMessage
|
||||||
|
: call.core.lastErrorMessage
|
||||||
color: DefaultStyle.grey_0
|
color: DefaultStyle.grey_0
|
||||||
font {
|
font {
|
||||||
pixelSize: 22 * DefaultStyle.dp
|
pixelSize: 22 * DefaultStyle.dp
|
||||||
|
|
@ -61,31 +58,14 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Layout.StackLayout {
|
Loader{
|
||||||
id: centerLayout
|
id: callLayout
|
||||||
currentIndex: 0
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
Loader{
|
sourceComponent: mainItem.participantDeviceCount === 0
|
||||||
id: callLayout
|
? waitingForOthersComponent
|
||||||
Layout.Layout.fillWidth: true
|
: activeSpeakerComponent
|
||||||
Layout.Layout.fillHeight: true
|
|
||||||
sourceComponent: mainItem.participantDeviceCount === 0
|
|
||||||
? waitingForOthersComponent
|
|
||||||
: activeSpeakerComponent
|
|
||||||
}
|
|
||||||
Layout.ColumnLayout {
|
|
||||||
id: userNotFoundLayout
|
|
||||||
Layout.Layout.preferredWidth: parent.width
|
|
||||||
Layout.Layout.preferredHeight: parent.height
|
|
||||||
Layout.Layout.alignment: Qt.AlignCenter
|
|
||||||
Text {
|
|
||||||
text: mainItem.call ? mainItem.call.core.lastErrorMessage : ""
|
|
||||||
Layout.Layout.alignment: Qt.AlignCenter
|
|
||||||
color: DefaultStyle.grey_0
|
|
||||||
font.pixelSize: 40 * DefaultStyle.dp
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Component{
|
Component{
|
||||||
id: activeSpeakerComponent
|
id: activeSpeakerComponent
|
||||||
ActiveSpeakerLayout{
|
ActiveSpeakerLayout{
|
||||||
|
|
|
||||||
|
|
@ -139,7 +139,7 @@ AbstractWindow {
|
||||||
|
|
||||||
Timer {
|
Timer {
|
||||||
id: autoCloseWindow
|
id: autoCloseWindow
|
||||||
interval: 2000
|
interval: 3000
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
UtilsCpp.closeCallsWindow()
|
UtilsCpp.closeCallsWindow()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue