Commit 5c3c738b authored by Sylvain Berfini's avatar Sylvain Berfini

A lot of improvements for background mode when not in call + started image chat messages

parent 5b8bedf5
......@@ -39,7 +39,7 @@ namespace Linphone.Agents
Debug.WriteLine("[LinphoneForegroundLifeTimeAgent] Background process {0} is ready", currentProcessId);
}
Debug.WriteLine("[LinphoneForegroundLifeTimeAgent] NotifyComplete");
Debug.WriteLine("[LinphoneForegroundLifeTimeAgent] NotifyComplete");
base.NotifyComplete();
}
}
......
......@@ -37,8 +37,6 @@ namespace Linphone.Agents
{
this.isIncomingCallAgent = false;
Debug.WriteLine("[KeepAliveAgent] Keep Alive");
//BackgroundManager.Instance.InitLinphoneCore();
}
else
{
......
......@@ -32,7 +32,7 @@ namespace Linphone
/// <summary>
/// An event that is raised when the push channel URI changes
/// </summary>
public event EventHandler<Uri> PushChannelUriChanged;
public event EventHandler<Uri> PushChannelUriChanged;
/// <summary>
/// Constructor for the Application object.
......@@ -58,7 +58,7 @@ namespace Linphone
InitHttpNotificationTask();
// Initalize the task to perform periodic maintenance
InitKeepAliveTask();
InitKeepAliveTask();
// Show graphics profiling information while debugging.
if (Debugger.IsAttached)
......@@ -291,8 +291,6 @@ namespace Linphone
// Disconnect the listeners to prevent crash of the background process
LinphoneManager.Instance.LinphoneCore.CoreListener = null;
LinphoneManager.Instance.isLinphoneRunning = false;
Debug.WriteLine("[App] Removed listener, killing UI to force clean state at next start");
Application.Current.Terminate();
}
}
......
......@@ -40,6 +40,11 @@
Style="{StaticResource MessageStyle}"
TextAlignment="Left"/>
<Image
Grid.Row="0"
Stretch="UniformToFill"
x:Name="Image" />
<StackPanel
Grid.Row="1"
Orientation="Horizontal"
......
......@@ -28,6 +28,8 @@ namespace Linphone.Controls
{
InitializeComponent();
_message = message;
Message.Visibility = Visibility.Visible;
Image.Visibility = Visibility.Collapsed;
Message.Text = message.Message;
Timestamp.Text = timestamp;
......@@ -36,6 +38,22 @@ namespace Linphone.Controls
Background.Fill = new SolidColorBrush(darkAccent);
}
/// <summary>
/// Public constructor.
/// </summary>
public OutgoingChatBubble(BitmapImage image, string timestamp)
{
InitializeComponent();
Image.Source = image;
Message.Visibility = Visibility.Collapsed;
Image.Visibility = Visibility.Visible;
Timestamp.Text = timestamp;
System.Windows.Media.Color accent = (System.Windows.Media.Color)Resources["PhoneAccentColor"];
System.Windows.Media.Color darkAccent = System.Windows.Media.Color.FromArgb(accent.A, (byte)(accent.R / 2), (byte)(accent.G / 2), (byte)(accent.B / 2));
Background.Fill = new SolidColorBrush(darkAccent);
}
/// <summary>
/// Changes the icon indicating the status of the message (InProgress, Delivered or NotDelivered).
/// </summary>
......
......@@ -193,7 +193,6 @@
<Content Include="Assets\linphonerc-factory" />
<Content Include="Assets\rootca.pem" />
<Content Include="Assets\Sounds\toy-mono.wav" />
<Content Include="README_FIRST.txt" />
<Content Include="Toolkit.Content\ApplicationBar.Cancel.png" />
<Content Include="Toolkit.Content\ApplicationBar.Check.png" />
<Content Include="Toolkit.Content\ApplicationBar.Delete.png" />
......
......@@ -87,7 +87,14 @@ namespace Linphone.Views
}
private void LocalVideoTimerCallback(Object state)
{
{
if (LinphoneManager.Instance.LinphoneCore == null)
{
localVideoTimer.Dispose();
localVideoTimer = null;
return;
}
int rotation = LinphoneManager.Instance.LinphoneCore.GetCameraSensorRotation();
if (rotation >= 0)
{
......
using Linphone.Agents;
using Linphone.Core;
using Linphone.Core.OutOfProcess;
using Linphone.Resources;
using Linphone.Views;
using Linphone.Core.OutOfProcess;
using Linphone.Resources;
using Linphone.Views;
using Microsoft.Phone.Net.NetworkInformation;
using Microsoft.Phone.Networking.Voip;
using Microsoft.Phone.Shell;
......@@ -12,6 +12,7 @@ using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Linq;
using Windows.Phone.Media.Capture;
using Windows.Phone.Media.Devices;
......@@ -133,7 +134,7 @@ namespace Linphone.Model
private EventWaitHandle uiDisconnectedEvent;
// A proxy to the server object in the background agent host process
private Server server;
private Server server = null;
// A timespan representing fifteen seconds
private static readonly TimeSpan fifteenSecs = new TimeSpan(0, 0, 15);
......@@ -188,15 +189,9 @@ namespace Linphone.Model
// and in that case, the following statement would fail - so, at this point, we don't explicitly guard against this condition.
// Create an instance of the server in the background process.
if (BackgroundManager.Instance.OopServer != null)
{
server = BackgroundManager.Instance.OopServer;
}
else
{
server = (Server)WindowsRuntimeMarshal.GetActivationFactory(typeof(Server)).ActivateInstance();
BackgroundManager.Instance.OopServer = server;
}
BackgroundManager.Instance.OopServer = null;
server = (Server)WindowsRuntimeMarshal.GetActivationFactory(typeof(Server)).ActivateInstance();
BackgroundManager.Instance.OopServer = server;
// Un-set an event that indicates that the UI process is disconnected from the background process.
// The background process waits for this event to get set before shutting down.
......@@ -242,12 +237,12 @@ namespace Linphone.Model
/// <summary>
/// Creates a new LinphoneCore (if not created yet) using a LinphoneCoreFactory.
/// </summary>
public async void InitLinphoneCore()
public async Task InitLinphoneCore()
{
if ((server.LinphoneCoreFactory != null) && (server.LinphoneCore != null))
{
// Reconnect the listeners when coming back from background mode
Logger.Msg("[LinphoneManager] LinphoneCore already created, skipping");
Debug.WriteLine("[LinphoneManager] LinphoneCore already created, skipping");
server.LinphoneCore.CoreListener = this;
isLinphoneRunning = true;
......@@ -256,14 +251,14 @@ namespace Linphone.Model
return;
}
Logger.Msg("[LinphoneManager] Creating LinphoneCore");
Debug.WriteLine("[LinphoneManager] Creating LinphoneCore");
await SettingsManager.InstallConfigFile();
LpConfig config = server.LinphoneCoreFactory.CreateLpConfig(SettingsManager.GetConfigPath(), SettingsManager.GetFactoryConfigPath());
ConfigureLogger();
server.LinphoneCoreFactory.CreateLinphoneCore(this, config);
server.LinphoneCore.SetUserAgent(DefaultValues.UserAgent, XDocument.Load("WMAppManifest.xml").Root.Element("App").Attribute("Version").Value);
server.LinphoneCore.SetRootCA("Assets/rootca.pem");
Logger.Msg("[LinphoneManager] LinphoneCore created");
Debug.WriteLine("[LinphoneManager] LinphoneCore created");
AudioRoutingManager.GetDefault().AudioEndpointChanged += AudioEndpointChanged;
CallController.MuteRequested += MuteRequested;
......
......@@ -660,6 +660,15 @@ namespace Linphone.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to send picture.
/// </summary>
public static string SendPicture {
get {
return ResourceManager.GetString("SendPicture", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Settings.
/// </summary>
......
......@@ -425,4 +425,7 @@ http://www.linphone.org/m/help
<data name="ContextMenuCopy" xml:space="preserve">
<value>Copy</value>
</data>
<data name="SendPicture" xml:space="preserve">
<value>send picture</value>
</data>
</root>
\ No newline at end of file
......@@ -14,6 +14,7 @@ using System.Diagnostics;
using Linphone.Controls;
using Microsoft.Phone.Tasks;
using System.ComponentModel;
using System.Windows.Media.Imaging;
namespace Linphone.Views
{
......@@ -63,21 +64,21 @@ namespace Linphone.Views
/// Method called when the page is displayed.
/// Check if the uri contains a sip address, if yes, it displays the matching chat history.
/// </summary>
protected override void OnNavigatedTo(NavigationEventArgs e)
protected override async void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
LinphoneManager.Instance.MessageListener = this;
_SentMessages = new List<OutgoingChatBubble>();
// Create LinphoneCore if not created yet, otherwise do nothing
LinphoneManager.Instance.InitLinphoneCore();
await LinphoneManager.Instance.InitLinphoneCore();
ContactManager cm = ContactManager.Instance;
cm.ContactFound += cm_ContactFound;
NewChat.Visibility = Visibility.Collapsed;
ContactName.Visibility = Visibility.Visible;
if (NavigationContext.QueryString.ContainsKey("sip") && e.NavigationMode != NavigationMode.Back)
if (NavigationContext.QueryString.ContainsKey("sip"))
{
sipAddress = NavigationContext.QueryString["sip"];
if (sipAddress.StartsWith("sip:"))
......@@ -148,6 +149,7 @@ namespace Linphone.Views
/// </summary>
protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
{
chatRoom = null;
DatabaseManager.Instance.SubmitChanges();
base.OnNavigatingFrom(e);
LinphoneManager.Instance.MessageListener = null;
......@@ -264,6 +266,31 @@ namespace Linphone.Views
}
}
private void send_image_Click_1(object sender, EventArgs e)
{
PhotoChooserTask task = new PhotoChooserTask();
task.Completed += task_Completed;
task.ShowCamera = true;
task.Show();
}
void task_Completed(object sender, PhotoResult e)
{
if (e.TaskResult == TaskResult.OK)
{
BitmapImage image = new BitmapImage();
image.SetSource(e.ChosenPhoto);
//TODO: Actually send the message
DateTime now = DateTime.Now;
OutgoingChatBubble bubble = new OutgoingChatBubble(image, FormatDate(now));
bubble.MessageDeleted += bubble_MessageDeleted;
MessagesList.Children.Add(bubble);
scrollToBottom();
}
}
private void BuildLocalizedApplicationBar()
{
ApplicationBar = new ApplicationBar();
......@@ -272,6 +299,11 @@ namespace Linphone.Views
appBarSend.Text = AppResources.SendMessage;
ApplicationBar.Buttons.Add(appBarSend);
appBarSend.Click += send_Click_1;
ApplicationBarIconButton appBarSendImage = new ApplicationBarIconButton(new Uri("/Assets/AppBar/feature.camera.png", UriKind.Relative));
appBarSendImage.Text = AppResources.SendPicture;
ApplicationBar.Buttons.Add(appBarSendImage);
appBarSendImage.Click += send_image_Click_1;
}
/// <summary>
......
......@@ -3,6 +3,7 @@ using Linphone.Model;
using Linphone.Resources;
using Microsoft.Phone.Shell;
using System;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
......@@ -32,13 +33,13 @@ namespace Linphone
/// Method called when the page is displayed.
/// Check if the uri contains a sip address, if yes, it starts a call to this address.
/// </summary>
protected override void OnNavigatedTo(NavigationEventArgs e)
protected override async void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
StatusBar = status;
// Create LinphoneCore if not created yet, otherwise do nothing
LinphoneManager.Instance.InitLinphoneCore();
Task t = LinphoneManager.Instance.InitLinphoneCore();
BuildLocalizedApplicationBar();
......@@ -48,6 +49,8 @@ namespace Linphone
String sipAddressToCall = NavigationContext.QueryString["sip"];
addressBox.Text = sipAddressToCall;
}
await t;
}
private void call_Click_1(object sender, EventArgs e)
......
......@@ -35,10 +35,13 @@ namespace Linphone.Views
/// Fetches the logs from the LinphoneManager and displays them.
/// </summary>
/// <param name="e"></param>
protected override void OnNavigatedTo(NavigationEventArgs e)
protected override async void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
// Create LinphoneCore if not created yet, otherwise do nothing
await LinphoneManager.Instance.InitLinphoneCore();
TileManager tileManager = TileManager.Instance;
tileManager.RemoveMissedCallsTile();
LinphoneManager.Instance.LinphoneCore.ResetMissedCallsCount();
......
......@@ -7,6 +7,7 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Imaging;
......@@ -51,10 +52,10 @@ namespace Linphone.Views
/// Method called when the page is displayed.
/// Searches for a matching contact using the current call address or number and display information if found.
/// </summary>
protected override void OnNavigatedTo(NavigationEventArgs nee)
protected override async void OnNavigatedTo(NavigationEventArgs nee)
{
// Create LinphoneCore if not created yet, otherwise do nothing
LinphoneManager.Instance.InitLinphoneCore();
Task t = LinphoneManager.Instance.InitLinphoneCore();
base.OnNavigatedTo(nee);
this.ViewModel.MuteListener = this;
......@@ -78,6 +79,8 @@ namespace Linphone.Views
cm.FindContact(calledNumber);
}
}
await t;
}
/// <summary>
......
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