From eb22c29a1dacca121cc907fbfcc269e8107de153 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 25 Sep 2015 17:15:48 +0200 Subject: [PATCH] Allow belle-sip-tester for Windows 10 to be launched with the liblinphone-tester URI scheme. --- .../windows10/liblinphone-tester/App.xaml.cs | 18 ++++++++++++ .../liblinphone-tester/MainPage.xaml.cs | 28 +++++++++---------- .../liblinphone-tester/Package.appxmanifest | 5 ++++ tester/liblinphone_tester_windows.cpp | 2 +- 4 files changed, 37 insertions(+), 16 deletions(-) diff --git a/build/windows10/liblinphone-tester/App.xaml.cs b/build/windows10/liblinphone-tester/App.xaml.cs index e80598ed7..f3c4d0801 100644 --- a/build/windows10/liblinphone-tester/App.xaml.cs +++ b/build/windows10/liblinphone-tester/App.xaml.cs @@ -110,5 +110,23 @@ namespace liblinphone_tester //TODO: Save application state and stop any background activity deferral.Complete(); } + + protected override void OnActivated(IActivatedEventArgs args) + { + if (args.Kind == ActivationKind.Protocol) + { + var protocolArgs = (ProtocolActivatedEventArgs)args; + var uri = protocolArgs.Uri; + Frame rootFrame = Window.Current.Content as Frame; + if (rootFrame == null) + rootFrame = new Frame(); + + rootFrame.NavigationFailed += OnNavigationFailed; + rootFrame.Navigate(typeof(MainPage), uri); + Window.Current.Content = rootFrame; + Window.Current.Activate(); + } + base.OnActivated(args); + } } } diff --git a/build/windows10/liblinphone-tester/MainPage.xaml.cs b/build/windows10/liblinphone-tester/MainPage.xaml.cs index 005f38891..3985316a8 100644 --- a/build/windows10/liblinphone-tester/MainPage.xaml.cs +++ b/build/windows10/liblinphone-tester/MainPage.xaml.cs @@ -39,7 +39,10 @@ namespace liblinphone_tester base.OnNavigatedTo(e); LibLinphoneTester.Instance.setWritableDirectory(ApplicationData.Current.LocalFolder); _suites = UnitTestDataSource.GetSuites(LibLinphoneTester.Instance); - TryAutoLaunch(); + if ((e.Parameter is Uri) && (e.Parameter.ToString().Equals("liblinphone-tester:autolaunch"))) + { + AutoLaunch(); + } } public IEnumerable Suites @@ -173,23 +176,18 @@ namespace liblinphone_tester }); } - private async void TryAutoLaunch() + private void AutoLaunch() { - try + CommandBar.IsEnabled = false; + ProgressIndicator.IsIndeterminate = true; + ProgressIndicator.IsEnabled = true; + LibLinphoneTester.Instance.runAllToXml(); + if (LibLinphoneTester.Instance.AsyncAction != null) { - await ApplicationData.Current.LocalFolder.GetFileAsync("autolaunch"); - CommandBar.IsEnabled = false; - ProgressIndicator.IsIndeterminate = true; - ProgressIndicator.IsEnabled = true; - LibLinphoneTester.Instance.runAllToXml(); - if (LibLinphoneTester.Instance.AsyncAction != null) - { - LibLinphoneTester.Instance.AsyncAction.Completed += (asyncInfo, asyncStatus) => { - App.Current.Exit(); - }; - } + LibLinphoneTester.Instance.AsyncAction.Completed += (asyncInfo, asyncStatus) => { + App.Current.Exit(); + }; } - catch (Exception) { } } private UnitTestCase RunningTestCase; diff --git a/build/windows10/liblinphone-tester/Package.appxmanifest b/build/windows10/liblinphone-tester/Package.appxmanifest index a0e2eda7c..b8acf8233 100644 --- a/build/windows10/liblinphone-tester/Package.appxmanifest +++ b/build/windows10/liblinphone-tester/Package.appxmanifest @@ -23,6 +23,11 @@ + + + + + diff --git a/tester/liblinphone_tester_windows.cpp b/tester/liblinphone_tester_windows.cpp index 946345763..a628e8fcd 100644 --- a/tester/liblinphone_tester_windows.cpp +++ b/tester/liblinphone_tester_windows.cpp @@ -110,7 +110,7 @@ void LibLinphoneTester::runAllToXml() init(true); FILE *f = fopen(logFile, "w"); ortp_set_log_file(f); - bc_tester_start("liblinphone-tester"); + bc_tester_start(NULL); bc_tester_uninit(); fclose(f); free(xmlFile);