Commit 4aaaac1d authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Clean usings + fixes for history + resolve contact in manager to fill display name if empty

parent b0fe3719
using System;
using Linphone.Model;
using Linphone.Resources;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Networking.Voip;
using Microsoft.Phone.Notification;
using Microsoft.Phone.Scheduler;
using Microsoft.Phone.Shell;
using System;
using System.Diagnostics;
using System.Resources;
using System.Windows;
using System.Windows.Markup;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using Linphone.Resources;
using System.Windows.Media;
using Linphone.Model;
using Microsoft.Phone.Notification;
using Microsoft.Phone.Scheduler;
using Microsoft.Phone.Networking.Voip;
namespace Linphone
{
......
using Linphone.Core;
using Linphone.Model;
using Linphone.Model;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Navigation;
using System.Windows.Threading;
......
using Linphone.Controls;
using Microsoft.Phone.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Navigation;
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using System.Windows.Input;
using System.Windows.Media.Imaging;
namespace Linphone.Controls
{
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using System.Windows.Media.Imaging;
namespace Linphone.Controls
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using Linphone.Core;
using Linphone.Model;
using Linphone.Core;
using System.Windows.Media.Imaging;
using Linphone.Resources;
using System;
using System.Windows.Controls;
using System.Windows.Media.Imaging;
namespace Linphone.Controls
{
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using System.Windows.Media.Imaging;
using System.Windows.Input;
using System.Windows.Media.Imaging;
namespace Linphone.Controls
{
......
using Microsoft.Phone.Globalization;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Linphone.Model
{
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Navigation;
namespace Linphone.Model
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Linphone.Model
{
/// <summary>
......
using Linphone.Resources;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media.Imaging;
namespace Linphone.Model
......
using Microsoft.Phone.UserData;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Linphone.Model
{
......
using Microsoft.Phone;
using Microsoft.Phone.UserData;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Linphone.Model
{
......
using Microsoft.Phone.Networking.Voip;
using Linphone.Agents;
using Linphone.Core;
using Linphone.Core.OutOfProcess;
using Microsoft.Phone.Net.NetworkInformation;
using Microsoft.Phone.Networking.Voip;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Linphone.Resources;
using Windows.Phone.Networking.Voip;
using System.Windows.Media.Imaging;
using Windows.Phone.Media.Devices;
using System.Reflection;
using Microsoft.Phone.Net.NetworkInformation;
using Windows.Storage;
using Linphone.Agents;
using Windows.Phone.Networking.Voip;
namespace Linphone.Model
{
......@@ -27,12 +19,8 @@ namespace Linphone.Model
/// </summary>
public sealed class LinphoneManager : LinphoneCoreListener
{
#region Network state management
private bool lastNetworkState;
private LinphoneManager()
{
LastKnownState = Linphone.Core.RegistrationState.RegistrationNone;
}
private void OnNetworkStatusChanged(object sender, NetworkNotificationEventArgs e)
{
if (lastNetworkState != DeviceNetworkInformation.IsNetworkAvailable)
......@@ -42,6 +30,13 @@ namespace Linphone.Model
LinphoneCore.SetNetworkReachable(lastNetworkState);
}
}
#endregion
#region Class properties
private LinphoneManager()
{
LastKnownState = Linphone.Core.RegistrationState.RegistrationNone;
}
private static LinphoneManager singleton;
/// <summary>
......@@ -115,6 +110,7 @@ namespace Linphone.Model
/// Simple listener to notify pages' viewmodel when a call ends or starts
/// </summary>
public CallControllerListener CallListener { get; set; }
#endregion
#region Background Process
private bool BackgroundProcessConnected;
......@@ -228,6 +224,7 @@ namespace Linphone.Model
}
#endregion
#region Linphone Core init
/// <summary>
/// Creates a new LinphoneCore (if not created yet) using a LinphoneCoreFactory.
/// </summary>
......@@ -285,6 +282,7 @@ namespace Linphone.Model
server.LinphoneCoreFactory.SetLogLevel(appSettings.LogLevel);
Logger.Instance.TraceListener = server.BackgroundModeLogger;
}
#endregion
#region CallLogs
private List<CallLog> _history;
......@@ -297,13 +295,9 @@ namespace Linphone.Model
{
foreach (LinphoneCallLog log in LinphoneManager.Instance.LinphoneCore.GetCallLogs())
{
string to = log.GetTo().GetDisplayName();
if (to.Length == 0)
to = log.GetTo().AsStringUriOnly();
if (log.GetDirection() == CallDirection.Outgoing)
{
return to;
return log.GetTo().AsStringUriOnly();
}
}
return null;
......@@ -497,20 +491,31 @@ namespace Linphone.Model
public void CallState(LinphoneCall call, LinphoneCallState state)
{
string sipAddress = call.GetRemoteAddress().AsStringUriOnly();
Logger.Msg("[LinphoneManager] Call state changed: " + sipAddress + " => " + state.ToString());
if (state == LinphoneCallState.OutgoingProgress)
{
Logger.Msg("[LinphoneManager] Outgoing progress");
BaseModel.UIDispatcher.BeginInvoke(() =>
{
LookupForContact(sipAddress, call);
if (CallListener != null)
CallListener.NewCallStarted(sipAddress);
});
}
else if (state == LinphoneCallState.Connected)
else if (state == LinphoneCallState.IncomingReceived)
{
Logger.Msg("[LinphoneManager] Incoming received");
BaseModel.UIDispatcher.BeginInvoke(() =>
{
LookupForContact(sipAddress, call);
});
}
else if (state == LinphoneCallState.Connected)
{
Logger.Msg("[LinphoneManager] Connected");
BaseModel.UIDispatcher.BeginInvoke(() =>
{
if (CallListener != null)
CallListener.NewCallStarted(sipAddress);
......@@ -599,5 +604,50 @@ namespace Linphone.Model
}
#endregion
#region Contact Lookup
private ContactManager ContactManager
{
get
{
return ContactManager.Instance;
}
}
private void LookupForContact(String sipAddress, LinphoneCall call)
{
if (call.GetRemoteAddress().GetDisplayName().Length == 0)
{
String address = sipAddress;
if (address.StartsWith("sip:"))
{
address = address.Substring(4);
}
Logger.Msg("[LinphoneManager] Display name null, looking for remote address in contact: " + address);
ContactManager.ContactFound += OnContactFound;
ContactManager.FindContact(address);
}
else
{
Logger.Msg("[LinphoneManager] Display name found: " + call.GetRemoteAddress().GetDisplayName());
}
}
/// <summary>
/// Callback called when the search on a phone number for a contact has a match
/// </summary>
private void OnContactFound(object sender, ContactFoundEventArgs e)
{
Logger.Msg("[LinphoneManager] Contact found: " + e.ContactFound.DisplayName);
ContactManager.ContactFound -= OnContactFound;
// Store the contact name as display name for call logs
if (LinphoneManager.Instance.LinphoneCore.GetCurrentCall() != null)
{
LinphoneManager.Instance.LinphoneCore.GetCurrentCall().GetRemoteAddress().SetDisplayName(e.ContactFound.DisplayName);
}
}
#endregion
}
}
using Linphone.Core;
using System;
using System.IO;
using System.Linq;
using System.Text;
using System;
namespace Linphone.Model
{
/// <summary>
......
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
using System.Windows.Media;
......
......@@ -2,11 +2,6 @@
using Linphone.Resources;
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.IsolatedStorage;
using System.Linq;
using System.Resources;
using System.Text;
using System.Threading.Tasks;
using Windows.Storage;
......
......@@ -36,7 +36,7 @@
</BackBackgroundImageURI>
<BackTitle>
</BackTitle>
<DeviceLockImageURI IsRelative="true" IsResource="false">Assets\AppBar\feature.phone.png</DeviceLockImageURI>
<DeviceLockImageURI IsRelative="true" IsResource="false">Assets\pnicon.png</DeviceLockImageURI>
<HasLarge>False</HasLarge>
</TemplateFlip>
</PrimaryToken>
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using System.Windows.Documents;
using Linphone.Resources;
using Linphone.Resources;
using System;
using System.Globalization;
using System.Resources;
using System.Reflection;
using System.Resources;
using System.Windows.Documents;
namespace Linphone.Views
{
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using Linphone.Model;
using Linphone.Resources;
using Linphone.Model;
using Microsoft.Phone.Shell;
using System;
using System.Windows.Navigation;
namespace Linphone.Views
{
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using Linphone.Model;
using Linphone.Resources;
using Linphone.Model;
using Microsoft.Phone.Shell;
using System;
using System.Windows.Navigation;
namespace Linphone.Views
{
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Linphone.Model;
using Linphone.Resources;
using Microsoft.Phone.Shell;
using System.Threading.Tasks;
using Windows.Storage;
using System;
using System.IO;
using System.Text;
using Linphone.Resources;
using Linphone.Model;
using System.Threading.Tasks;
using System.Windows.Navigation;
using Windows.Storage;
namespace Linphone.Views
{
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using Linphone.Controls;
using Linphone.Model;
using Microsoft.Phone;
using Microsoft.Phone.UserData;
using System;
using System.IO;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using System.Windows.Media.Imaging;
using Microsoft.Phone;
using System.IO;
using Microsoft.Phone.UserData;
using Linphone.Model;
using Linphone.Controls;
namespace Linphone.Views
{
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using Linphone.Model;
using Microsoft.Phone.Controls;
using System;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using Microsoft.Phone.UserData;
using Linphone.Model;
using System.Diagnostics;
namespace Linphone.Views
{
......
using System;
using Linphone.Agents;
using Linphone.Core;
using Linphone.Model;
using Linphone.Resources;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using Linphone.Model;
using Linphone.Resources;
using Linphone.Agents;
using System.Windows.Data;
using System.Globalization;
using System.Windows.Media;
namespace Linphone.Views
{
......@@ -127,12 +124,13 @@ namespace Linphone.Views
private void callLog_Click_1(object sender, RoutedEventArgs e)
{
CallLog log = ((sender as StackPanel).Tag as CallLog);
LinphoneCallLog nativeLog = (LinphoneCallLog)log.NativeLog;
String address;
if (log.IsIncoming)
address = log.From;
address = nativeLog.GetFrom().AsStringUriOnly();
else
address = log.To;
address = nativeLog.GetTo().AsStringUriOnly();
SetAddressGoToDialerAndCall(address);
}
......
using Linphone.Core;
using Linphone.Model;
using Microsoft.Phone.Controls;
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using Windows.Phone.Networking.Voip;
namespace Linphone.Views
{
......@@ -103,9 +100,6 @@ namespace Linphone.Views
{
Number.Text = e.PhoneNumber;
}
// Store the contact name as display name for call logs
LinphoneManager.Instance.LinphoneCore.GetCurrentCall().GetRemoteAddress().SetDisplayName(e.ContactFound.DisplayName);
}
private void hangUp_Click(object sender, RoutedEventArgs e)
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using Linphone.Model;
using Linphone.Resources;
using Microsoft.Phone.Shell;
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using Linphone.Model;
using Linphone.Resources;
using System.Globalization;
using System.Resources;
using System.IO;
using System.Text;
namespace Linphone.Views
{
......
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