Commit 9d6bfbda authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Few fixes/changes + Console view to read logs in-app

parent e6450142
......@@ -80,7 +80,7 @@ void CallController::EndCall(VoipPhoneCall^ call)
call->NotifyCallEnded();
}
VoipPhoneCall^ CallController::NewOutgoingCall(Platform::String^ number, Platform::String^ name)
VoipPhoneCall^ CallController::NewOutgoingCall(Platform::String^ number)
{
std::lock_guard<std::recursive_mutex> lock(g_apiLock);
......@@ -89,7 +89,7 @@ VoipPhoneCall^ CallController::NewOutgoingCall(Platform::String^ number, Platfor
this->callCoordinator->RequestNewOutgoingCall(
this->callInProgressPageUri + "?sip=" + number,
name,
number,
this->voipServiceName,
VoipCallMedia::Audio,
&outgoingCall);
......
......@@ -34,7 +34,7 @@ namespace Linphone
/// <summary>
/// Starts an outgoing call using native VoipPhoneCall.
/// </summary>
Windows::Phone::Networking::Voip::VoipPhoneCall^ NewOutgoingCall(Platform::String^ number, Platform::String^ name);
Windows::Phone::Networking::Voip::VoipPhoneCall^ NewOutgoingCall(Platform::String^ number);
/// <summary>
/// Callback to be called when the PushNotification Agent has to be dismissed, i.e. after a call has been accepted, denied or stopped by the caller.
......
......@@ -816,7 +816,7 @@ void call_state_changed(::LinphoneCore *lc, ::LinphoneCall *call, ::LinphoneCall
lCall->CallContext = platformCall;
}
else if (state == Linphone::Core::LinphoneCallState::OutgoingProgress) {
Windows::Phone::Networking::Voip::VoipPhoneCall^ platformCall = callController->NewOutgoingCall(lCall->GetRemoteContact(), lCall->GetRemoteAddress()->AsStringUriOnly());
Windows::Phone::Networking::Voip::VoipPhoneCall^ platformCall = callController->NewOutgoingCall(lCall->GetRemoteAddress()->AsStringUriOnly());
lCall->CallContext = platformCall;
}
else if (state == Linphone::Core::LinphoneCallState::CallEnd || state == Linphone::Core::LinphoneCallState::Error) {
......
......@@ -141,6 +141,9 @@
<Compile Include="Views\CodecsSettings.xaml.cs">
<DependentUpon>CodecsSettings.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Console.xaml.cs">
<DependentUpon>Console.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Contact.xaml.cs">
<DependentUpon>Contact.xaml</DependentUpon>
</Compile>
......@@ -165,6 +168,7 @@
<Content Include="Assets\linphonerc" />
<Content Include="Assets\linphonerc-factory" />
<Content Include="Assets\rootca.pem" />
<Content Include="Views\logs.html" />
<None Include="packages.config" />
<None Include="Properties\AppManifest.xml" />
<None Include="Properties\WMAppManifest.xml">
......@@ -281,6 +285,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Console.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Contact.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
......
......@@ -277,10 +277,10 @@ namespace Linphone.Model
{
// To have the debug output in the debugger use the following commented configure and set your debugger to native mode
//server.BackgroundModeLogger.Configure(SettingsManager.isDebugEnabled, OutputTraceDest.Debugger, "");
// Else output the debug traces to a file
// Else output the debug traces to a file
ApplicationSettingsManager appSettings = new ApplicationSettingsManager();
appSettings.Load();
server.BackgroundModeLogger.Configure(appSettings.DebugEnabled, appSettings.LogDestination, appSettings.LogOption);
server.BackgroundModeLogger.Configure(appSettings.DebugEnabled, appSettings.LogDestination, appSettings.LogOption);
server.LinphoneCoreFactory.OutputTraceListener = server.BackgroundModeLogger;
server.LinphoneCoreFactory.SetLogLevel(appSettings.LogLevel);
Logger.Instance.TraceListener = server.BackgroundModeLogger;
......
......@@ -174,6 +174,15 @@ namespace Linphone.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Console.
/// </summary>
public static string ConsoleMenu {
get {
return ResourceManager.GetString("ConsoleMenu", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Contact.
/// </summary>
......@@ -336,6 +345,15 @@ namespace Linphone.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Refresh.
/// </summary>
public static string Refresh {
get {
return ResourceManager.GetString("Refresh", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to LeftToRight.
/// </summary>
......
......@@ -293,4 +293,10 @@ http://www.linphone.org/m/help
<data name="Dialing" xml:space="preserve">
<value>Dialing...</value>
</data>
<data name="ConsoleMenu" xml:space="preserve">
<value>Console</value>
</data>
<data name="Refresh" xml:space="preserve">
<value>Refresh</value>
</data>
</root>
\ No newline at end of file
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.18010
// Runtime Version:4.0.30319.18033
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
......
......@@ -53,14 +53,12 @@ namespace Linphone.Views
private void save_Click_1(object sender, EventArgs e)
{
_settings.AMRNB = ToBool(AMRNB.IsChecked);
_settings.AMRNB = ToBool(AMRNB.IsChecked);
_settings.AMRWB = ToBool(AMRWB.IsChecked);
_settings.Speex16 = ToBool(Speex16.IsChecked);
_settings.Speex8 = ToBool(Speex8.IsChecked);
_settings.PCMU = ToBool(PCMU.IsChecked);
_settings.PCMA = ToBool(PCMA.IsChecked);
_settings.PCMA = ToBool(PCMA.IsChecked);
_settings.G722 = ToBool(G722.IsChecked);
_settings.ILBC = ToBool(ILBC.IsChecked);
_settings.SILK16 = ToBool(SILK16.IsChecked);
......
<linphone:BasePage
x:Class="Linphone.Views.Console"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
xmlns:linphone="clr-namespace:Linphone"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Landscape" Orientation="Landscape"
mc:Ignorable="d"
shell:SystemTray.IsVisible="True">
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!--TitlePanel contains the name of the application and page title-->
<!--<StackPanel Grid.Row="0" Margin="12,5,0,0">
<TextBlock Foreground="Black" Text="{Binding Path=LocalizedResources.ApplicationTitle, Source={StaticResource LocalizedStrings}}" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock Text="{Binding Path=LocalizedResources.ConsoleMenu, Source={StaticResource LocalizedStrings}}" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>-->
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<phone:WebBrowser x:Name="Browser" IsScriptEnabled="True" LoadCompleted="Browser_LoadCompleted" Background="{StaticResource PhoneBackgroundBrush}"/>
</Grid>
</Grid>
</linphone:BasePage>
\ No newline at end of file
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.Threading.Tasks;
using Windows.Storage;
using System.IO;
using System.Text;
using Linphone.Resources;
using Linphone.Model;
namespace Linphone.Views
{
public partial class Console : BasePage
{
public Console()
{
InitializeComponent();
BuildLocalizedApplicationBar();
Browser.Navigate(new Uri("/Views/logs.html", UriKind.RelativeOrAbsolute));
}
private async void Browser_LoadCompleted(object sender, NavigationEventArgs e)
{
string logs = await ReadLogs();
FormatAndDisplayLogs(logs);
}
private void FormatAndDisplayLogs(string logs)
{
logs = logs.Replace("\r\n", "\n");
string[] lines = logs.Split('\n');
bool insertNewLine = false;
foreach (string line in lines)
{
if (line.Length == 0)
{
insertNewLine = false;
Browser.InvokeScript("append_nl");
}
else
{
if (insertNewLine == true)
{
Browser.InvokeScript("append_nl");
}
Browser.InvokeScript("append_text", line);
insertNewLine = true;
}
}
}
private async Task<string> ReadLogs()
{
ApplicationSettingsManager appSettings = new ApplicationSettingsManager();
appSettings.Load();
byte[] data;
StorageFolder folder = ApplicationData.Current.LocalFolder;
StorageFile file = await folder.GetFileAsync(appSettings.LogOption);
using (Stream s = await file.OpenStreamForReadAsync())
{
data = new byte[s.Length];
await s.ReadAsync(data, 0, (int)s.Length);
}
return Encoding.UTF8.GetString(data, 0, data.Length);
}
private async void refresh_Click_1(object sender, EventArgs e)
{
Browser.InvokeScript("clean");
string logs = await ReadLogs();
FormatAndDisplayLogs(logs);
}
private void BuildLocalizedApplicationBar()
{
ApplicationBar = new ApplicationBar();
ApplicationBarIconButton appBarRefresh = new ApplicationBarIconButton(new Uri("/Assets/AppBar/refresh.png", UriKind.Relative));
appBarRefresh.Text = AppResources.Refresh;
ApplicationBar.Buttons.Add(appBarRefresh);
appBarRefresh.Click += refresh_Click_1;
}
}
}
\ No newline at end of file
......@@ -6,6 +6,7 @@ using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Windows.Storage;
namespace Linphone
{
......@@ -22,7 +23,6 @@ namespace Linphone
public Dialer()
{
InitializeComponent();
BuildLocalizedApplicationBar();
addressBox.FocusListener = this;
ContactManager contactManager = ContactManager.Instance; //Force creation and init of ContactManager
......@@ -40,6 +40,8 @@ namespace Linphone
// Create LinphoneCore if not created yet, otherwise do nothing
LinphoneManager.Instance.InitLinphoneCore();
BuildLocalizedApplicationBar();
// Check for the navigation direction to avoid going to incall view when coming back from incall view
if (NavigationContext.QueryString.ContainsKey("sip") && e.NavigationMode != NavigationMode.Back)
{
......@@ -97,7 +99,12 @@ namespace Linphone
NavigationService.Navigate(new Uri("/Views/About.xaml", UriKind.RelativeOrAbsolute));
}
private void BuildLocalizedApplicationBar()
private void console_Click_1(object sender, EventArgs e)
{
NavigationService.Navigate(new Uri("/Views/Console.xaml", UriKind.RelativeOrAbsolute));
}
private async void BuildLocalizedApplicationBar()
{
ApplicationBar = new ApplicationBar();
......@@ -119,6 +126,21 @@ namespace Linphone
ApplicationBarMenuItem appBarAbout = new ApplicationBarMenuItem(AppResources.AboutMenu);
appBarAbout.Click += about_Click_1;
ApplicationBar.MenuItems.Add(appBarAbout);
ApplicationSettingsManager appSettings = new ApplicationSettingsManager();
appSettings.Load();
StorageFile logFile = null;
try
{
logFile = await ApplicationData.Current.LocalFolder.GetFileAsync(appSettings.LogOption);
}
catch { }
if (appSettings.LogDestination == Core.OutputTraceDest.File && logFile != null)
{
ApplicationBarMenuItem appBarConsole = new ApplicationBarMenuItem(AppResources.ConsoleMenu);
appBarConsole.Click += console_Click_1;
ApplicationBar.MenuItems.Add(appBarConsole);
}
}
private void Title_Tap(object sender, System.Windows.Input.GestureEventArgs e)
......
<html>
<head>
<title></title>
<style>
html { background-color: black; font-family:'Courier New'; font-size: 16pt; color: white; }
.debug { color: lightgray; }
.message { color: white; }
.warning { color: orange; }
.error { color: red; }
</style>
<script>
function append_text(msg) {
var content = document.getElementById("content");
var new_text = document.createTextNode(msg);
content.appendChild(new_text);
}
function append_nl() {
var content = document.getElementById("content");
var element = document.createElement('br');
content.appendChild(element);
}
function clean() {
var content = document.getElementById("content");
while (content.firstChild) {
content.removeChild(content.firstChild);
}
}
</script>
</head>
<body>
<p><pre id="content"></pre></p>
</body>
</html>
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