Commit b86525c1 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

PN calls working when app is in background

parent 8d732971
......@@ -22,7 +22,7 @@ namespace Linphone.Agents
Globals.Instance.StartServer(RegistrationHelper.OutOfProcServerClassNames);
//Force the callController to be initialized now to avoid creating it at the last moment (workaroud outgoing call crash after app started)
Globals.Instance.CallController.ToString();
Globals.Instance.CallController.IncomingCallViewDismissed = null;
}
/// <summary>
......
......@@ -10,6 +10,7 @@ using System.Linq;
using System.Xml.Linq;
using Microsoft.Phone.Shell;
using Windows.Phone.Networking.Voip;
using Windows.Storage;
namespace Linphone.Agents
{
......@@ -35,16 +36,19 @@ namespace Linphone.Agents
this.isIncomingCallAgent = true;
Debug.WriteLine("[IncomingCallAgent] Received VoIP Incoming Call task");
TileManager.Instance.UpdateTileWithMissedCalls(Globals.Instance.LinphoneCore.GetMissedCallsCount());
Globals.Instance.CallController.IncomingCallViewDismissed = OnIncomingCallDialogDismissed;
CreateLinphoneCore();
}
else
{
VoipKeepAliveTask keepAliveTask = task as VoipKeepAliveTask;
Debug.WriteLine("[KeepAliveAgent] Keep Alive");
if (keepAliveTask != null)
{
this.isIncomingCallAgent = false;
base.NotifyComplete();
Debug.WriteLine("[KeepAliveAgent] Keep Alive");
CreateLinphoneCore();
Globals.Instance.LinphoneCore.RefreshRegisters();
}
else
{
......@@ -53,10 +57,29 @@ namespace Linphone.Agents
}
}
private void CreateLinphoneCore()
{
// Initiate incoming call processing by creating the Linphone Core
Globals.Instance.LinphoneCoreFactory.CreateLinphoneCore(null, ApplicationData.Current.LocalFolder.Path + "\\linphonerc", "Assets/linphonerc-factory");
//Globals.Instance.BackgroundModeLogger.Configure(true, OutputTraceDest.TCPRemote, "192.168.0.217:38954");
//Globals.Instance.LinphoneCoreFactory.OutputTraceListener = Globals.Instance.BackgroundModeLogger;
//if (Globals.Instance.LinphoneCore.GetDefaultProxyConfig() != null)
//{
// string host, token;
// host = ((App)App.Current).PushChannelUri.Host;
// token = ((App)App.Current).PushChannelUri.AbsolutePath;
// Globals.Instance.LinphoneCore.GetDefaultProxyConfig().SetContactParameters("app-id=" + host + ";pn-type=wp;pn-tok=" + token + ";pn-msg-str=IM_MSG;pn-call-str=IC_MSG;pn-call-snd=ring.caf;pn-msg-snd=msg.caf");
//}
Globals.Instance.LinphoneCore.SetNetworkReachable(true);
}
// This method is called when the incoming call processing is complete
private void OnIncomingCallDialogDismissed()
{
Debug.WriteLine("[IncomingCallAgent] Incoming call processing is now complete.");
Globals.Instance.CallController.IncomingCallViewDismissed = null;
base.NotifyComplete();
}
......
......@@ -101,6 +101,16 @@ VoipPhoneCall^ CallController::NewOutgoingCall(Platform::String^ number, Platfor
return outgoingCall;
}
IncomingCallViewDismissedCallback^ CallController::IncomingCallViewDismissed::get()
{
return this->onIncomingCallViewDismissed;
}
void CallController::IncomingCallViewDismissed::set(IncomingCallViewDismissedCallback^ cb)
{
this->onIncomingCallViewDismissed = cb;
}
CallController::CallController() :
callInProgressPageUri(L"/Views/InCall.xaml"),
voipServiceName(nullptr),
......
......@@ -22,7 +22,13 @@ namespace Linphone
void EndCall(Windows::Phone::Networking::Voip::VoipPhoneCall^ call);
Windows::Phone::Networking::Voip::VoipPhoneCall^ NewOutgoingCall(Platform::String^ number, Platform::String^ name);
Windows::Phone::Networking::Voip::VoipPhoneCall^ NewOutgoingCall(Platform::String^ number, Platform::String^ name);
property IncomingCallViewDismissedCallback^ IncomingCallViewDismissed
{
IncomingCallViewDismissedCallback^ get();
void set(IncomingCallViewDismissedCallback^ cb);
}
private:
friend ref class Linphone::Core::Globals;
......
......@@ -60,7 +60,7 @@ namespace Linphone
{
Button button = sender as Button;
String tag = button.Tag as String;
LinphoneManager.Instance.LinphoneCore.PlayDTMF(Convert.ToChar(tag), 500);
LinphoneManager.Instance.LinphoneCore.PlayDTMF(Convert.ToChar(tag), 1000);
addressBox.Text += tag;
}
......
......@@ -41,12 +41,12 @@ namespace Linphone.Views
/// </summary>
protected override void OnNavigatedTo(NavigationEventArgs nee)
{
// Create LinphoneCore if not created yet, otherwise do nothing
LinphoneManager.Instance.LinphoneCore.CoreListener = LinphoneManager.Instance;
base.OnNavigatedTo(nee);
this.ViewModel.MuteListener = this;
this.ViewModel.PauseListener = this;
// Create LinphoneCore if not created yet, otherwise do nothing
LinphoneManager.Instance.InitLinphoneCore();
if (NavigationContext.QueryString.ContainsKey("sip"))
{
......@@ -142,14 +142,17 @@ namespace Linphone.Views
pause.IsChecked = isCallPaused;
pauseImg.Source = new BitmapImage(new Uri(isCallPaused ? pauseOn : pauseOff, UriKind.RelativeOrAbsolute));
if (!isCallPaused)
if (!isCallPaused && timer == null)
{
timer = new Timer(new TimerCallback(timerTick), null, 0, 1000);
watch.Start();
}
else
{
timer.Dispose();
if (timer != null)
{
timer.Dispose();
}
watch.Stop();
}
}
......
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