Commit 127f7551 authored by Ghislain MARY's avatar Ghislain MARY

Show error popup in case of call failure.

parent 0b20244b
......@@ -26,7 +26,7 @@ namespace Linphone.Agents
// Changes the decline reason if needed.
if (Customs.DeclineCallWithBusyReason)
{
Globals.Instance.CallController.DeclineReason = DeclineReason.LinphoneReasonBusy;
Globals.Instance.CallController.DeclineReason = Reason.LinphoneReasonBusy;
}
}
......
......@@ -108,7 +108,7 @@ namespace Linphone.Agents
/// <summary>
/// Callback for LinphoneCoreListener
/// </summary>
public void CallState(LinphoneCall call, LinphoneCallState state)
public void CallState(LinphoneCall call, LinphoneCallState state, string message)
{
}
......
......@@ -196,15 +196,15 @@ void CallController::CustomIncomingCallView::set(Platform::Boolean value)
gApiLock.Unlock();
}
DeclineReason CallController::DeclineReason::get()
Reason CallController::DeclineReason::get()
{
TRACE; gApiLock.Lock();
Linphone::Core::DeclineReason value = this->declineReason;
Linphone::Core::Reason value = this->declineReason;
gApiLock.Unlock();
return value;
}
void CallController::DeclineReason::set(Linphone::Core::DeclineReason value)
void CallController::DeclineReason::set(Linphone::Core::Reason value)
{
TRACE; gApiLock.Lock();
this->declineReason = value;
......@@ -217,7 +217,7 @@ CallController::CallController() :
defaultContactImageUri(nullptr),
linphoneImageUri(nullptr),
ringtoneUri(nullptr),
declineReason(Linphone::Core::DeclineReason::LinphoneReasonDeclined),
declineReason(Linphone::Core::Reason::LinphoneReasonDeclined),
callCoordinator(VoipCallCoordinator::GetDefault())
{
// URIs required for interactions with the VoipCallCoordinator
......
......@@ -55,10 +55,10 @@ namespace Linphone
/// <summary>
/// Changes the reason used when declining an incoming call.
/// </summary>
property Linphone::Core::DeclineReason DeclineReason
property Linphone::Core::Reason DeclineReason
{
Linphone::Core::DeclineReason get();
void set(Linphone::Core::DeclineReason cb);
Linphone::Core::Reason get();
void set(Linphone::Core::Reason cb);
}
/// <summary>
......@@ -86,7 +86,7 @@ namespace Linphone
Platform::String^ callInProgressPageUri;
Linphone::Core::DeclineReason declineReason;
Linphone::Core::Reason declineReason;
// The URI to the contact image, jpg or png, 1mb max !
Windows::Foundation::Uri^ defaultContactImageUri;
......
......@@ -159,20 +159,29 @@ namespace Linphone
FileTransferDone = 5
};
public enum class DeclineReason : int
public enum class Reason : int
{
LinphoneReasonNone = 0,
LinphoneReasonNoResponse = 1, /**<No response received from remote*/
LinphoneReasonBadCredentials = 2, /**<Authentication failed due to bad*/
LinphoneReasonForbidden = 2, /**<Authentication failed due to bad credentials or resource forbidden*/
LinphoneReasonDeclined = 3, /**<The call has been declined*/
LinphoneReasonNotFound = 4, /**<Destination of the calls was not found.*/
LinphoneReasonNotAnswered = 5, /**<The call was not answered in time*/
LinphoneReasonNotFound = 4, /**<Destination of the call was not found.*/
LinphoneReasonNotAnswered = 5, /**<The call was not answered in time (request timeout)*/
LinphoneReasonBusy = 6, /**<Phone line was busy */
LinphoneReasonMedia = 7, /**<Incompatible media */
LinphoneReasonUnsupportedContent = 7, /**<Unsupported content */
LinphoneReasonIOError = 8, /**<Transport error: connection failures, disconnections etc...*/
LinphoneReasonDoNotDisturb = 9, /**<Do not disturb reason*/
LinphoneReasonUnauthorized = 10, /**<Operation is unauthorized because missing credential*/
LinphoneReasonNotAcceptable = 11 /**<Operation like call update rejected by peer*/
LinphoneReasonNotAcceptable = 11, /**<Operation like call update rejected by peer*/
LinphoneReasonNoMatch = 12, /**<Operation could not be executed by server or remote client because it didn't have any context for it*/
LinphoneReasonMovedPermanently = 13, /**<Resource moved permanently*/
LinphoneReasonGone = 14, /**<Resource no longer exists*/
LinphoneReasonTemporarilyUnavailable = 15, /**<Temporarily unavailable*/
LinphoneReasonAddressIncomplete = 16, /**<Address incomplete*/
LinphoneReasonNotImplemented = 17, /**<Not implemented*/
LinphoneReasonBadGateway = 18, /**<Bad gateway*/
LinphoneReasonServerTimeout = 19, /**<Server timeout*/
LinphoneReasonUnknown = 20 /**Unknown reason*/
};
public enum class LinphoneTransport : int
......
......@@ -233,6 +233,11 @@ Windows::Phone::Networking::Voip::VoipPhoneCall^ Linphone::Core::LinphoneCall::C
return this->callContext;
}
Linphone::Core::Reason Linphone::Core::LinphoneCall::Reason::get()
{
return (Linphone::Core::Reason)linphone_call_get_reason(this->call);
}
Linphone::Core::LinphoneCall::LinphoneCall(::LinphoneCall *call) :
call(call)
{
......
......@@ -92,7 +92,7 @@ namespace Linphone
/// </summary>
/// <returns>The current duration of the call in seconds</returns>
int GetDuration();
/// <summary>
/// Obtain real time quality rating of the call.
/// Based on local RTP statistics and RTCP feedback, a quality rating is computed and updated during all the duration of the call.
......@@ -198,6 +198,11 @@ namespace Linphone
void set(Windows::Phone::Networking::Voip::VoipPhoneCall^ cc);
}
property Linphone::Core::Reason Reason
{
Linphone::Core::Reason get();
}
private:
friend class Linphone::Core::Utils;
friend ref class Linphone::Core::LinphoneCore;
......
......@@ -362,7 +362,7 @@ void Linphone::Core::LinphoneCore::TerminateCall(Linphone::Core::LinphoneCall^ c
gApiLock.Unlock();
}
void Linphone::Core::LinphoneCore::DeclineCall(Linphone::Core::LinphoneCall^ call, DeclineReason reason)
void Linphone::Core::LinphoneCore::DeclineCall(Linphone::Core::LinphoneCall^ call, Linphone::Core::Reason reason)
{
TRACE; gApiLock.Lock();
linphone_core_decline_call(this->lc, call->call, (LinphoneReason)reason);
......@@ -1545,7 +1545,7 @@ void call_state_changed(::LinphoneCore *lc, ::LinphoneCall *call, ::LinphoneCall
Linphone::Core::LinphoneCoreListener^ listener = Linphone::Core::Globals::Instance->LinphoneCore->CoreListener;
if (listener != nullptr) {
listener->CallState(lCall, state);
listener->CallState(lCall, state, Linphone::Core::Utils::cctops(msg));
}
Linphone::Core::gApiLock.LeaveListener();
}
......
......@@ -297,7 +297,7 @@ namespace Linphone
/// <summary>
/// Declines an incoming call with a specific reason.
/// </summary>
void DeclineCall(LinphoneCall^ call, DeclineReason reason);
void DeclineCall(LinphoneCall^ call, Reason reason);
/// <summary>
/// Gets the current active call.
......
......@@ -37,7 +37,7 @@ namespace Linphone
/// </summary>
/// <param name="call">The call whose state has changed</param>
/// <param name="state">The new state of the call</param>
void CallState(LinphoneCall^ call, LinphoneCallState state);
void CallState(LinphoneCall^ call, LinphoneCallState state, Platform::String^ message);
/// <summary>
/// Callback method called when the state of the registration of a proxy config has changed.
......
......@@ -11,7 +11,9 @@ using Microsoft.Phone.Tasks;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Resources;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Threading;
using System.Threading.Tasks;
......@@ -48,9 +50,12 @@ namespace Linphone.Model
#endregion
#region Class properties
private ResourceManager ResourceManager;
private LinphoneManager()
{
LastKnownState = Linphone.Core.RegistrationState.RegistrationNone;
ResourceManager = new ResourceManager("Linphone.Resources.AppResources", typeof(AppResources).Assembly);
}
private static LinphoneManager singleton;
......@@ -771,10 +776,25 @@ namespace Linphone.Model
public delegate void CallStateChangedEventHandler(LinphoneCall call, LinphoneCallState state);
public event CallStateChangedEventHandler CallStateChanged;
private void ShowError(string message)
{
if (CallErrorNotification != null)
{
CallErrorNotification.Dismiss();
}
CallErrorNotification = new CustomMessageBox()
{
Caption = "Call error",
Message = message,
RightButtonContent = AppResources.Close
};
CallErrorNotification.Show();
}
/// <summary>
/// Callback for LinphoneCoreListener
/// </summary>
public void CallState(LinphoneCall call, LinphoneCallState state)
public void CallState(LinphoneCall call, LinphoneCallState state, string message)
{
if (state == LinphoneCallState.OutgoingProgress)
{
......@@ -787,7 +807,6 @@ namespace Linphone.Model
{
string sipAddress = call.GetRemoteAddress().AsStringUriOnly();
CallListener.NewCallStarted(sipAddress);
}
});
}
......@@ -822,9 +841,37 @@ namespace Linphone.Model
{
BaseModel.UIDispatcher.BeginInvoke(() =>
{
Logger.Msg("[LinphoneManager] Call ended\r\n");
Logger.Msg(String.Format("[LinphoneManager] Call ended: {0}\r\n", message));
if (CallListener != null)
CallListener.CallEnded(call);
string text;
switch (call.Reason)
{
case Reason.LinphoneReasonNone:
break;
case Reason.LinphoneReasonDeclined:
text = ResourceManager.GetString("CallErrorDeclined", CultureInfo.CurrentCulture);
ShowError(text.Replace("#address#", call.GetRemoteAddress().GetUserName()));
break;
case Reason.LinphoneReasonNotFound:
text = ResourceManager.GetString("CallErrorNotFound", CultureInfo.CurrentCulture);
ShowError(text.Replace("#address#", call.GetRemoteAddress().GetUserName()));
break;
case Reason.LinphoneReasonNotAnswered:
text = ResourceManager.GetString("CallErrorNotAnswered", CultureInfo.CurrentCulture);
ShowError(text.Replace("#address#", call.GetRemoteAddress().GetUserName()));
break;
case Reason.LinphoneReasonBusy:
text = ResourceManager.GetString("CallErrorBusy", CultureInfo.CurrentCulture);
ShowError(text.Replace("#address#", call.GetRemoteAddress().GetUserName()));
break;
case Reason.LinphoneReasonNotAcceptable:
ShowError(ResourceManager.GetString("CallErrorNotAcceptable", CultureInfo.CurrentCulture));
break;
default:
ShowError(ResourceManager.GetString("CallErrorUnknown", CultureInfo.CurrentCulture));
break;
}
});
}
else if (state == LinphoneCallState.Paused || state == LinphoneCallState.PausedByRemote)
......@@ -952,6 +999,11 @@ namespace Linphone.Model
/// </summary>
public CustomMessageBox MessageReceivedNotification { get; set; }
/// <summary>
/// Custom message box to display call errors.
/// </summary>
public CustomMessageBox CallErrorNotification { get; set; }
/// <summary>
/// Callback for LinphoneCoreListener
/// </summary>
......
......@@ -240,6 +240,60 @@ namespace Linphone.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to &apos;#address#&apos; is busy.
/// </summary>
public static string CallErrorBusy {
get {
return ResourceManager.GetString("CallErrorBusy", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &apos;#address#&apos; declined the call.
/// </summary>
public static string CallErrorDeclined {
get {
return ResourceManager.GetString("CallErrorDeclined", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Incompatible codecs or encryption mechanisms.
/// </summary>
public static string CallErrorNotAcceptable {
get {
return ResourceManager.GetString("CallErrorNotAcceptable", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &apos;#address#&apos; did not answer the call.
/// </summary>
public static string CallErrorNotAnswered {
get {
return ResourceManager.GetString("CallErrorNotAnswered", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &apos;#address#&apos; not found.
/// </summary>
public static string CallErrorNotFound {
get {
return ResourceManager.GetString("CallErrorNotFound", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Unknown error.
/// </summary>
public static string CallErrorUnknown {
get {
return ResourceManager.GetString("CallErrorUnknown", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Call.
/// </summary>
......
......@@ -628,4 +628,22 @@ Do you want to report it to the developpers ? It will help fix it faster.</value
<data name="ResetLogs" xml:space="preserve">
<value>Reset logs</value>
</data>
<data name="CallErrorNotFound" xml:space="preserve">
<value>'#address#' not found</value>
</data>
<data name="CallErrorDeclined" xml:space="preserve">
<value>'#address#' declined the call</value>
</data>
<data name="CallErrorNotAnswered" xml:space="preserve">
<value>'#address#' did not answer the call</value>
</data>
<data name="CallErrorBusy" xml:space="preserve">
<value>'#address#' is busy</value>
</data>
<data name="CallErrorUnknown" xml:space="preserve">
<value>Unknown error</value>
</data>
<data name="CallErrorNotAcceptable" xml:space="preserve">
<value>Incompatible codecs or encryption mechanisms</value>
</data>
</root>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment