From 65ea3ef6e9cf18214ef02a35d4fd83b8b1a72c90 Mon Sep 17 00:00:00 2001 From: TheJoKlLa Date: Wed, 24 Feb 2021 19:08:50 +0100 Subject: [PATCH] Fixed: Android Deadlock from RPC Connection --- .gitmodules | 3 ++ Borepin.sln | 28 ++++++++++++++++++- Borepin/Borepin.Android/MainActivity.cs | 6 +--- .../Properties/AndroidManifest.xml | 1 + .../Properties/AssemblyInfo.cs | 1 - Borepin/Borepin.Android/SplashActivity.cs | 2 -- .../Borepin.GTK/Properties/AssemblyInfo.cs | 1 - Borepin/Borepin.UWP/App.xaml.cs | 10 ------- Borepin/Borepin.UWP/MainPage.xaml.cs | 17 +---------- .../Borepin.UWP/Properties/AssemblyInfo.cs | 1 - Borepin/Borepin.iOS/AppDelegate.cs | 5 +--- Borepin/Borepin.iOS/Main.cs | 7 +---- .../Borepin.iOS/Properties/AssemblyInfo.cs | 1 - Borepin/Borepin.macOS/AppDelegate.cs | 1 - Borepin/Borepin/Dialog/ConfirmDialog.xaml.cs | 7 +---- Borepin/Borepin/Model/Credentials.cs | 2 -- .../AddServerDialog/HostSelectPage.xaml.cs | 7 +---- .../AddServerDialog/LoginChoosePage.xaml.cs | 7 +---- .../AddServerDialog/LoginPasswordPage.xaml.cs | 7 +---- Borepin/Borepin/Page/ListPage.xaml.cs | 7 +---- Borepin/Borepin/Page/MachineListPage.xaml.cs | 7 +---- Borepin/Borepin/Page/MachinePage.xaml.cs | 7 +---- Borepin/Borepin/Page/ServerListPage.xaml.cs | 7 +---- Borepin/Borepin/Page/ServerPage.xaml.cs | 7 +---- Borepin/Borepin/Page/SettingsPage.xaml.cs | 7 +---- .../AddServerDialog/HostSelectPageModel.cs | 9 +++--- .../AddServerDialog/LoginChoosePageModel.cs | 3 -- .../AddServerDialog/LoginPasswordPageModel.cs | 9 +++--- Borepin/Borepin/PageModel/MachinePageModel.cs | 3 -- Borepin/Borepin/PageModel/ServerPageModel.cs | 5 ++-- Borepin/Borepin/Service/BFFH/BFFHService.cs | 13 ++++----- Borepin/Borepin/View/ListItemView.xaml.cs | 7 +---- .../Borepin/View/MachineListItemView.xaml.cs | 7 +---- .../Borepin/View/ServerListItemView.xaml.cs | 7 +---- .../ViewModel/ServerListItemViewModel.cs | 4 +-- FabAccessAPI/Auth.cs | 8 ++---- FabAccessAPI/Connection.cs | 11 ++++---- FabAccessAPI/FabAccessAPI.csproj | 3 +- FabAccessAPI/Machines.cs | 4 +-- FabAccessAPI/Permissions.cs | 10 ++----- NFC_Test/Crypto/CipherKey_Test.cs | 3 -- external/CapnProto | 1 + 42 files changed, 83 insertions(+), 180 deletions(-) create mode 160000 external/CapnProto diff --git a/.gitmodules b/.gitmodules index f04abcd..7aaf40d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "external/SASL"] path = external/SASL url = https://github.com/kjkriegel/S22.Sasl.git +[submodule "external/CapnProto"] + path = external/CapnProto + url = git@github.com:c80k/capnproto-dotnetcore.git diff --git a/Borepin.sln b/Borepin.sln index 409eea6..16b5838 100644 --- a/Borepin.sln +++ b/Borepin.sln @@ -23,7 +23,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FabAccessAPI", "FabAccessAP EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "S22.Sasl", "external\SASL\S22.Sasl.csproj", "{7FEC3D5E-C240-41B6-BBFA-895C4F4D45CA}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FabAccessAPI_Test", "FabAccessAPI_Test\FabAccessAPI_Test.csproj", "{1C85978A-9FC0-4064-8399-FA2455C5EC2A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FabAccessAPI_Test", "FabAccessAPI_Test\FabAccessAPI_Test.csproj", "{1C85978A-9FC0-4064-8399-FA2455C5EC2A}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Capnp.Net.Runtime", "external\CapnProto\Capnp.Net.Runtime\Capnp.Net.Runtime.csproj", "{2B1EB47B-C63B-4C0D-AFB4-F6C98823CF93}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -353,6 +355,30 @@ Global {1C85978A-9FC0-4064-8399-FA2455C5EC2A}.Release|x64.Build.0 = Release|Any CPU {1C85978A-9FC0-4064-8399-FA2455C5EC2A}.Release|x86.ActiveCfg = Release|Any CPU {1C85978A-9FC0-4064-8399-FA2455C5EC2A}.Release|x86.Build.0 = Release|Any CPU + {2B1EB47B-C63B-4C0D-AFB4-F6C98823CF93}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2B1EB47B-C63B-4C0D-AFB4-F6C98823CF93}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2B1EB47B-C63B-4C0D-AFB4-F6C98823CF93}.Debug|ARM.ActiveCfg = Debug|Any CPU + {2B1EB47B-C63B-4C0D-AFB4-F6C98823CF93}.Debug|ARM.Build.0 = Debug|Any CPU + {2B1EB47B-C63B-4C0D-AFB4-F6C98823CF93}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {2B1EB47B-C63B-4C0D-AFB4-F6C98823CF93}.Debug|iPhone.Build.0 = Debug|Any CPU + {2B1EB47B-C63B-4C0D-AFB4-F6C98823CF93}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {2B1EB47B-C63B-4C0D-AFB4-F6C98823CF93}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {2B1EB47B-C63B-4C0D-AFB4-F6C98823CF93}.Debug|x64.ActiveCfg = Debug|Any CPU + {2B1EB47B-C63B-4C0D-AFB4-F6C98823CF93}.Debug|x64.Build.0 = Debug|Any CPU + {2B1EB47B-C63B-4C0D-AFB4-F6C98823CF93}.Debug|x86.ActiveCfg = Debug|Any CPU + {2B1EB47B-C63B-4C0D-AFB4-F6C98823CF93}.Debug|x86.Build.0 = Debug|Any CPU + {2B1EB47B-C63B-4C0D-AFB4-F6C98823CF93}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2B1EB47B-C63B-4C0D-AFB4-F6C98823CF93}.Release|Any CPU.Build.0 = Release|Any CPU + {2B1EB47B-C63B-4C0D-AFB4-F6C98823CF93}.Release|ARM.ActiveCfg = Release|Any CPU + {2B1EB47B-C63B-4C0D-AFB4-F6C98823CF93}.Release|ARM.Build.0 = Release|Any CPU + {2B1EB47B-C63B-4C0D-AFB4-F6C98823CF93}.Release|iPhone.ActiveCfg = Release|Any CPU + {2B1EB47B-C63B-4C0D-AFB4-F6C98823CF93}.Release|iPhone.Build.0 = Release|Any CPU + {2B1EB47B-C63B-4C0D-AFB4-F6C98823CF93}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {2B1EB47B-C63B-4C0D-AFB4-F6C98823CF93}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {2B1EB47B-C63B-4C0D-AFB4-F6C98823CF93}.Release|x64.ActiveCfg = Release|Any CPU + {2B1EB47B-C63B-4C0D-AFB4-F6C98823CF93}.Release|x64.Build.0 = Release|Any CPU + {2B1EB47B-C63B-4C0D-AFB4-F6C98823CF93}.Release|x86.ActiveCfg = Release|Any CPU + {2B1EB47B-C63B-4C0D-AFB4-F6C98823CF93}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Borepin/Borepin.Android/MainActivity.cs b/Borepin/Borepin.Android/MainActivity.cs index e50ec56..e339f11 100644 --- a/Borepin/Borepin.Android/MainActivity.cs +++ b/Borepin/Borepin.Android/MainActivity.cs @@ -1,10 +1,6 @@ -using System; - + using Android.App; using Android.Content.PM; -using Android.Runtime; -using Android.Views; -using Android.Widget; using Android.OS; namespace Borepin.Droid diff --git a/Borepin/Borepin.Android/Properties/AndroidManifest.xml b/Borepin/Borepin.Android/Properties/AndroidManifest.xml index e1bd04c..0c3da49 100644 --- a/Borepin/Borepin.Android/Properties/AndroidManifest.xml +++ b/Borepin/Borepin.Android/Properties/AndroidManifest.xml @@ -3,4 +3,5 @@ + \ No newline at end of file diff --git a/Borepin/Borepin.Android/Properties/AssemblyInfo.cs b/Borepin/Borepin.Android/Properties/AssemblyInfo.cs index c32fecd..296bfd9 100644 --- a/Borepin/Borepin.Android/Properties/AssemblyInfo.cs +++ b/Borepin/Borepin.Android/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Android.App; diff --git a/Borepin/Borepin.Android/SplashActivity.cs b/Borepin/Borepin.Android/SplashActivity.cs index 519c0ea..dd72a08 100644 --- a/Borepin/Borepin.Android/SplashActivity.cs +++ b/Borepin/Borepin.Android/SplashActivity.cs @@ -1,8 +1,6 @@ using Android.App; -using Android.OS; using Android.Support.V7.App; using Android.Content; -using Android.Util; namespace Borepin.Droid { diff --git a/Borepin/Borepin.GTK/Properties/AssemblyInfo.cs b/Borepin/Borepin.GTK/Properties/AssemblyInfo.cs index 625ae7c..80a4f8e 100644 --- a/Borepin/Borepin.GTK/Properties/AssemblyInfo.cs +++ b/Borepin/Borepin.GTK/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // Allgemeine Informationen über eine Assembly werden über die folgenden diff --git a/Borepin/Borepin.UWP/App.xaml.cs b/Borepin/Borepin.UWP/App.xaml.cs index 5b30b25..9e740ce 100644 --- a/Borepin/Borepin.UWP/App.xaml.cs +++ b/Borepin/Borepin.UWP/App.xaml.cs @@ -1,18 +1,8 @@ using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Runtime.InteropServices.WindowsRuntime; using Windows.ApplicationModel; using Windows.ApplicationModel.Activation; -using Windows.Foundation; -using Windows.Foundation.Collections; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Controls.Primitives; -using Windows.UI.Xaml.Data; -using Windows.UI.Xaml.Input; -using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Navigation; namespace Borepin.UWP diff --git a/Borepin/Borepin.UWP/MainPage.xaml.cs b/Borepin/Borepin.UWP/MainPage.xaml.cs index 6326904..c6ee445 100644 --- a/Borepin/Borepin.UWP/MainPage.xaml.cs +++ b/Borepin/Borepin.UWP/MainPage.xaml.cs @@ -1,19 +1,4 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Runtime.InteropServices.WindowsRuntime; -using Windows.Foundation; -using Windows.Foundation.Collections; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Controls.Primitives; -using Windows.UI.Xaml.Data; -using Windows.UI.Xaml.Input; -using Windows.UI.Xaml.Media; -using Windows.UI.Xaml.Navigation; - -namespace Borepin.UWP +namespace Borepin.UWP { public sealed partial class MainPage { diff --git a/Borepin/Borepin.UWP/Properties/AssemblyInfo.cs b/Borepin/Borepin.UWP/Properties/AssemblyInfo.cs index 641991d..1f214f7 100644 --- a/Borepin/Borepin.UWP/Properties/AssemblyInfo.cs +++ b/Borepin/Borepin.UWP/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following diff --git a/Borepin/Borepin.iOS/AppDelegate.cs b/Borepin/Borepin.iOS/AppDelegate.cs index 2ce8115..529071b 100644 --- a/Borepin/Borepin.iOS/AppDelegate.cs +++ b/Borepin/Borepin.iOS/AppDelegate.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; - + using Foundation; using UIKit; diff --git a/Borepin/Borepin.iOS/Main.cs b/Borepin/Borepin.iOS/Main.cs index 2a71ca7..65a739e 100644 --- a/Borepin/Borepin.iOS/Main.cs +++ b/Borepin/Borepin.iOS/Main.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; - -using Foundation; -using UIKit; +using UIKit; namespace Borepin.iOS { diff --git a/Borepin/Borepin.iOS/Properties/AssemblyInfo.cs b/Borepin/Borepin.iOS/Properties/AssemblyInfo.cs index 1d988a7..34e7a8c 100644 --- a/Borepin/Borepin.iOS/Properties/AssemblyInfo.cs +++ b/Borepin/Borepin.iOS/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following diff --git a/Borepin/Borepin.macOS/AppDelegate.cs b/Borepin/Borepin.macOS/AppDelegate.cs index b389a19..e68d5a6 100644 --- a/Borepin/Borepin.macOS/AppDelegate.cs +++ b/Borepin/Borepin.macOS/AppDelegate.cs @@ -2,7 +2,6 @@ using Foundation; using Xamarin.Forms; using Xamarin.Forms.Platform.MacOS; -using Borepin; namespace Borepin.macOS { diff --git a/Borepin/Borepin/Dialog/ConfirmDialog.xaml.cs b/Borepin/Borepin/Dialog/ConfirmDialog.xaml.cs index 25d9481..9d61c34 100644 --- a/Borepin/Borepin/Dialog/ConfirmDialog.xaml.cs +++ b/Borepin/Borepin/Dialog/ConfirmDialog.xaml.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - + using Xamarin.Forms; using Xamarin.Forms.Xaml; diff --git a/Borepin/Borepin/Model/Credentials.cs b/Borepin/Borepin/Model/Credentials.cs index 748ba47..c7f0004 100644 --- a/Borepin/Borepin/Model/Credentials.cs +++ b/Borepin/Borepin/Model/Credentials.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; namespace Borepin.Model { diff --git a/Borepin/Borepin/Page/AddServerDialog/HostSelectPage.xaml.cs b/Borepin/Borepin/Page/AddServerDialog/HostSelectPage.xaml.cs index 68fc850..e6bb8a5 100644 --- a/Borepin/Borepin/Page/AddServerDialog/HostSelectPage.xaml.cs +++ b/Borepin/Borepin/Page/AddServerDialog/HostSelectPage.xaml.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - + using Xamarin.Forms; using Xamarin.Forms.Xaml; diff --git a/Borepin/Borepin/Page/AddServerDialog/LoginChoosePage.xaml.cs b/Borepin/Borepin/Page/AddServerDialog/LoginChoosePage.xaml.cs index d559b2d..25b0161 100644 --- a/Borepin/Borepin/Page/AddServerDialog/LoginChoosePage.xaml.cs +++ b/Borepin/Borepin/Page/AddServerDialog/LoginChoosePage.xaml.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - + using Xamarin.Forms; using Xamarin.Forms.Xaml; diff --git a/Borepin/Borepin/Page/AddServerDialog/LoginPasswordPage.xaml.cs b/Borepin/Borepin/Page/AddServerDialog/LoginPasswordPage.xaml.cs index bdaae22..608ff29 100644 --- a/Borepin/Borepin/Page/AddServerDialog/LoginPasswordPage.xaml.cs +++ b/Borepin/Borepin/Page/AddServerDialog/LoginPasswordPage.xaml.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - + using Xamarin.Forms; using Xamarin.Forms.Xaml; diff --git a/Borepin/Borepin/Page/ListPage.xaml.cs b/Borepin/Borepin/Page/ListPage.xaml.cs index cadb3dc..4f57114 100644 --- a/Borepin/Borepin/Page/ListPage.xaml.cs +++ b/Borepin/Borepin/Page/ListPage.xaml.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - + using Xamarin.Forms; using Xamarin.Forms.Xaml; diff --git a/Borepin/Borepin/Page/MachineListPage.xaml.cs b/Borepin/Borepin/Page/MachineListPage.xaml.cs index 65f3609..3d148b8 100644 --- a/Borepin/Borepin/Page/MachineListPage.xaml.cs +++ b/Borepin/Borepin/Page/MachineListPage.xaml.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - + using Xamarin.Forms; using Xamarin.Forms.Xaml; diff --git a/Borepin/Borepin/Page/MachinePage.xaml.cs b/Borepin/Borepin/Page/MachinePage.xaml.cs index fe09902..e42e174 100644 --- a/Borepin/Borepin/Page/MachinePage.xaml.cs +++ b/Borepin/Borepin/Page/MachinePage.xaml.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - + using Xamarin.Forms; using Xamarin.Forms.Xaml; diff --git a/Borepin/Borepin/Page/ServerListPage.xaml.cs b/Borepin/Borepin/Page/ServerListPage.xaml.cs index 44b8921..d6ae321 100644 --- a/Borepin/Borepin/Page/ServerListPage.xaml.cs +++ b/Borepin/Borepin/Page/ServerListPage.xaml.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - + using Xamarin.Forms; using Xamarin.Forms.Xaml; diff --git a/Borepin/Borepin/Page/ServerPage.xaml.cs b/Borepin/Borepin/Page/ServerPage.xaml.cs index 49f6ee5..e81d41c 100644 --- a/Borepin/Borepin/Page/ServerPage.xaml.cs +++ b/Borepin/Borepin/Page/ServerPage.xaml.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - + using Xamarin.Forms; using Xamarin.Forms.Xaml; diff --git a/Borepin/Borepin/Page/SettingsPage.xaml.cs b/Borepin/Borepin/Page/SettingsPage.xaml.cs index 93d965a..4784e7d 100644 --- a/Borepin/Borepin/Page/SettingsPage.xaml.cs +++ b/Borepin/Borepin/Page/SettingsPage.xaml.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - + using Xamarin.Forms; using Xamarin.Forms.Xaml; diff --git a/Borepin/Borepin/PageModel/AddServerDialog/HostSelectPageModel.cs b/Borepin/Borepin/PageModel/AddServerDialog/HostSelectPageModel.cs index 9e39e9a..ac95c8d 100644 --- a/Borepin/Borepin/PageModel/AddServerDialog/HostSelectPageModel.cs +++ b/Borepin/Borepin/PageModel/AddServerDialog/HostSelectPageModel.cs @@ -1,5 +1,4 @@ -using Borepin.Model; -using Borepin.Service.BFFH; +using Borepin.Service.BFFH; using Borepin.Service.Connections; using Prism.Mvvm; using Prism.Navigation; @@ -63,7 +62,7 @@ namespace Borepin.PageModel builder.Port = 59661; } - Connection connection = new Connection() + Model.Connection connection = new Model.Connection() { Address = builder.Uri }; @@ -71,7 +70,7 @@ namespace Borepin.PageModel await _BFFHService.Connect(connection); INavigationResult result = await _NavigationService.NavigateAsync("LoginChoosePage"); - if (!result.Success) + if(!result.Success) { System.Diagnostics.Debugger.Break(); } @@ -87,7 +86,7 @@ namespace Borepin.PageModel private void DetectHostCommandExecuted() { // Use Demo Host - Host = "127.0.0.1:59661"; + Host = "192.168.178.20:59661"; } } } diff --git a/Borepin/Borepin/PageModel/AddServerDialog/LoginChoosePageModel.cs b/Borepin/Borepin/PageModel/AddServerDialog/LoginChoosePageModel.cs index c78cba1..7147f03 100644 --- a/Borepin/Borepin/PageModel/AddServerDialog/LoginChoosePageModel.cs +++ b/Borepin/Borepin/PageModel/AddServerDialog/LoginChoosePageModel.cs @@ -1,8 +1,5 @@ using Prism.Mvvm; using Prism.Navigation; -using System; -using System.Collections.Generic; -using System.Text; using System.Windows.Input; using Xamarin.Forms; diff --git a/Borepin/Borepin/PageModel/AddServerDialog/LoginPasswordPageModel.cs b/Borepin/Borepin/PageModel/AddServerDialog/LoginPasswordPageModel.cs index 975fc4b..6da87c1 100644 --- a/Borepin/Borepin/PageModel/AddServerDialog/LoginPasswordPageModel.cs +++ b/Borepin/Borepin/PageModel/AddServerDialog/LoginPasswordPageModel.cs @@ -1,11 +1,11 @@ using Borepin.Model; using Borepin.Service.BFFH; using Borepin.Service.Connections; +using Prism.Commands; using Prism.Mvvm; using Prism.Navigation; using System.Threading.Tasks; using System.Windows.Input; -using Xamarin.Forms; namespace Borepin.PageModel { @@ -21,7 +21,7 @@ namespace Borepin.PageModel _BFFHService = bffhService; _ConnectionService = connectionService; - AuthenticateCommand = new Command(AuthenticateCommandExecuted); + AuthenticateCommand = new DelegateCommand(async () => await AuthenticateCommandExecuted()); Task.Run(LoadData); } @@ -52,17 +52,18 @@ namespace Borepin.PageModel set => SetProperty(ref _AuthenticateCommand, value); } - private async void AuthenticateCommandExecuted() + private async Task AuthenticateCommandExecuted() { Connection connection_update = _BFFHService.ActiveConnection; connection_update.Username = Username; + await _BFFHService.Authenticate(connection_update, Password); await _ConnectionService.AddConnection(_BFFHService.ActiveConnection); await _ConnectionService.LogConnect(_BFFHService.ActiveConnection); - var result = await _NavigationService.NavigateAsync("/MainPage/NavigationPage/MachinesPage"); + var result = await _NavigationService.NavigateAsync("/MainPage/NavigationPage/MachineListPage"); if (!result.Success) { diff --git a/Borepin/Borepin/PageModel/MachinePageModel.cs b/Borepin/Borepin/PageModel/MachinePageModel.cs index c5de6fe..5548a24 100644 --- a/Borepin/Borepin/PageModel/MachinePageModel.cs +++ b/Borepin/Borepin/PageModel/MachinePageModel.cs @@ -1,11 +1,8 @@ using Borepin.Model; -using Borepin.Service.BFFH; using Prism.Commands; using Prism.Mvvm; using Prism.Navigation; -using System.Threading.Tasks; using System.Windows.Input; -using Xamarin.Forms; using static FabAccessAPI.Schema.Machine.WriteInterface; namespace Borepin.PageModel diff --git a/Borepin/Borepin/PageModel/ServerPageModel.cs b/Borepin/Borepin/PageModel/ServerPageModel.cs index ea7ba6f..e450157 100644 --- a/Borepin/Borepin/PageModel/ServerPageModel.cs +++ b/Borepin/Borepin/PageModel/ServerPageModel.cs @@ -6,6 +6,7 @@ using Prism.Commands; using Prism.Mvvm; using Prism.Navigation; using Prism.Services.Dialogs; +using System.Threading.Tasks; using System.Windows.Input; namespace Borepin.PageModel @@ -27,7 +28,7 @@ namespace Borepin.PageModel _BFFHService = bffhService; _CredentialService = credentialService; - ConnectCommand = new DelegateCommand(ConnectCommandExecuted); + ConnectCommand = new DelegateCommand(async () => await ConnectCommandExecuted()); DeleteCommand = new DelegateCommand(DeleteCommandExecuted); } @@ -55,7 +56,7 @@ namespace Borepin.PageModel set => SetProperty(ref _ConnectCommand, value); } - private async void ConnectCommandExecuted() + private async Task ConnectCommandExecuted() { if(IsConnected) { diff --git a/Borepin/Borepin/Service/BFFH/BFFHService.cs b/Borepin/Borepin/Service/BFFH/BFFHService.cs index db6aedf..de85dbb 100644 --- a/Borepin/Borepin/Service/BFFH/BFFHService.cs +++ b/Borepin/Borepin/Service/BFFH/BFFHService.cs @@ -3,6 +3,8 @@ using Borepin.Service.Credentials; using System.Threading.Tasks; using Capnp.Rpc; using System.Collections.Generic; +using System.Threading; +using System; namespace Borepin.Service.BFFH { @@ -32,13 +34,8 @@ namespace Borepin.Service.BFFH rpcClient.Connect(connection.Address.Host, connection.Address.Port); - await Task.Run(async () => - { - while (rpcClient.State == ConnectionState.Initializing) - { - await Task.Delay(100); - } - }); + // IMPORTANT: without ConfigureAwait(false) every Call for CapnProto Runtime deadlocks on Android + await rpcClient.WhenConnected.ConfigureAwait(false); FabAccessAPI.Connection connection_test = new FabAccessAPI.Connection(rpcClient); @@ -62,7 +59,7 @@ namespace Borepin.Service.BFFH { string password = await _CredentialService.GetPasswordAsync(ActiveConnection); - await _Connection.Auth("PLAIN", new Dictionary { { "Username", ActiveConnection.Username }, { "Password", password } }); + await _Connection.Auth("PLAIN", new Dictionary { { "Username", ActiveConnection.Username }, { "Password", "secret" } }); return await Task.FromResult(true); } diff --git a/Borepin/Borepin/View/ListItemView.xaml.cs b/Borepin/Borepin/View/ListItemView.xaml.cs index edf0c2a..9751765 100644 --- a/Borepin/Borepin/View/ListItemView.xaml.cs +++ b/Borepin/Borepin/View/ListItemView.xaml.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - + using Xamarin.Forms; using Xamarin.Forms.Xaml; diff --git a/Borepin/Borepin/View/MachineListItemView.xaml.cs b/Borepin/Borepin/View/MachineListItemView.xaml.cs index 4476cd0..4e86b91 100644 --- a/Borepin/Borepin/View/MachineListItemView.xaml.cs +++ b/Borepin/Borepin/View/MachineListItemView.xaml.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - + using Xamarin.Forms; using Xamarin.Forms.Xaml; diff --git a/Borepin/Borepin/View/ServerListItemView.xaml.cs b/Borepin/Borepin/View/ServerListItemView.xaml.cs index 219209d..d540038 100644 --- a/Borepin/Borepin/View/ServerListItemView.xaml.cs +++ b/Borepin/Borepin/View/ServerListItemView.xaml.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - + using Xamarin.Forms; using Xamarin.Forms.Xaml; diff --git a/Borepin/Borepin/ViewModel/ServerListItemViewModel.cs b/Borepin/Borepin/ViewModel/ServerListItemViewModel.cs index 43524ee..0a4d80f 100644 --- a/Borepin/Borepin/ViewModel/ServerListItemViewModel.cs +++ b/Borepin/Borepin/ViewModel/ServerListItemViewModel.cs @@ -1,6 +1,4 @@ -using Borepin.Model; -using FabAccessAPI; -using Prism.Mvvm; +using Prism.Mvvm; namespace Borepin.ViewModel { diff --git a/FabAccessAPI/Auth.cs b/FabAccessAPI/Auth.cs index ab83078..8e18ac1 100644 --- a/FabAccessAPI/Auth.cs +++ b/FabAccessAPI/Auth.cs @@ -1,14 +1,12 @@ -using Capnp; -using FabAccessAPI.Schema; +using FabAccessAPI.Schema; using S22.Sasl; -using System; using System.Collections.Generic; -using System.IO; using System.Linq; using System.Threading.Tasks; using Exception = System.Exception; -namespace FabAccessAPI { +namespace FabAccessAPI +{ /// Authentication Identity /// /// Under the hood a string because the form depends heavily on the method diff --git a/FabAccessAPI/Connection.cs b/FabAccessAPI/Connection.cs index 6bbaee1..3fe02ab 100644 --- a/FabAccessAPI/Connection.cs +++ b/FabAccessAPI/Connection.cs @@ -3,6 +3,7 @@ using FabAccessAPI.Schema; using System; using System.Collections.Generic; using System.Linq; +using System.Threading; using System.Threading.Tasks; namespace FabAccessAPI { @@ -37,18 +38,18 @@ namespace FabAccessAPI { /// The desired authentication mechanism /// Key-Value data specific to the mechanism /// - public async Task Auth(string mech, Dictionary kvs) { + public async Task Auth(string mech, Dictionary kvs, CancellationToken cancellationToken_ = default) { // _bootstrapCap = await _bootstrapCap.Unwrap(); - var authCap = await _bootstrapCap.Auth(); + var authCap = await _bootstrapCap.Auth(cancellationToken_); _auth = new Auth(authCap); - var mechs = await _auth.GetMechanisms().ConfigureAwait(false); + var mechs = await _auth.GetMechanisms(); _Log.Debug($"The Server supports the following auth mechs: {string.Join(", ", mechs)}"); if (!mechs.Contains(mech)) { throw new UnsupportedMechanismException(); } - await _auth.Authenticate(mech, kvs).ConfigureAwait(false); + await _auth.Authenticate(mech, kvs); } /// @@ -56,7 +57,7 @@ namespace FabAccessAPI { /// /// A wrapped capability to interact with machines public async Task AccessMachines() { - _machines ??= new Machines((await _bootstrapCap.Machines().ConfigureAwait(false))); + _machines ??= new Machines(await _bootstrapCap.Machines()); return _machines; } } diff --git a/FabAccessAPI/FabAccessAPI.csproj b/FabAccessAPI/FabAccessAPI.csproj index 1ccb7e6..6134b9a 100644 --- a/FabAccessAPI/FabAccessAPI.csproj +++ b/FabAccessAPI/FabAccessAPI.csproj @@ -11,13 +11,14 @@ - + + diff --git a/FabAccessAPI/Machines.cs b/FabAccessAPI/Machines.cs index 5b75e75..e38c11f 100644 --- a/FabAccessAPI/Machines.cs +++ b/FabAccessAPI/Machines.cs @@ -1,10 +1,10 @@ using FabAccessAPI.Schema; using System; using System.Collections.Generic; -using System.Linq; using System.Threading.Tasks; -namespace FabAccessAPI { +namespace FabAccessAPI +{ public class MachineException : Exception { } diff --git a/FabAccessAPI/Permissions.cs b/FabAccessAPI/Permissions.cs index 121aa3e..b0e3be2 100644 --- a/FabAccessAPI/Permissions.cs +++ b/FabAccessAPI/Permissions.cs @@ -1,10 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Text; - - -//This is where the permissions subsystem will live -namespace FabAccessAPI { +//This is where the permissions subsystem will live +namespace FabAccessAPI +{ public class Permissions { #region Log private static readonly log4net.ILog _Log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); diff --git a/NFC_Test/Crypto/CipherKey_Test.cs b/NFC_Test/Crypto/CipherKey_Test.cs index 492d2d1..0535544 100644 --- a/NFC_Test/Crypto/CipherKey_Test.cs +++ b/NFC_Test/Crypto/CipherKey_Test.cs @@ -1,7 +1,4 @@ using NUnit.Framework; -using System; -using System.Collections.Generic; -using System.Text; namespace NFC_Unit_Test.Crypto { diff --git a/external/CapnProto b/external/CapnProto new file mode 160000 index 0000000..c2d17d6 --- /dev/null +++ b/external/CapnProto @@ -0,0 +1 @@ +Subproject commit c2d17d689cd262bf9bf03366f1364d80c864b862