diff --git a/Borepin.sln b/Borepin.sln index 6019848..86ac32a 100644 --- a/Borepin.sln +++ b/Borepin.sln @@ -17,10 +17,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "S22.Sasl", "external\SASL\S EndProject 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}") = "NFC", "external\NFC\NFC\NFC.csproj", "{D53A98E8-48B5-4DCE-A98E-4623EE746E16}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Capnp.Net.Runtime", "external\capnproto-dotnetcore\Capnp.Net.Runtime\Capnp.Net.Runtime.csproj", "{C587AAC3-50A7-4871-A50D-7880B6F24EF6}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Borepin_Test", "Borepin_Test\Borepin_Test.csproj", "{A959A406-91A5-4D81-B90D-EF022812D97D}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{0EA0AA4A-A814-45A0-9EA7-E9147CCCCB6A}" @@ -32,6 +28,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Borepin.GTK", "Borepin\Borepin.GTK\Borepin.GTK.csproj", "{61D956D2-5819-4736-BBD8-AD8208DE6A62}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NFC", "external\NFC\NFC\NFC.csproj", "{AC068302-655B-46B8-BC8A-971A3D685437}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NFC.PCSC", "external\NFC\NFC.PCSC\NFC.PCSC.csproj", "{6E2927DD-791F-48FA-96E1-696611FB38EB}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Capnp.Net.Runtime", "external\capnproto-dotnetcore\Capnp.Net.Runtime\Capnp.Net.Runtime.csproj", "{6CC49E97-4F07-43DE-A2AF-50914498A276}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -264,54 +266,6 @@ 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 - {D53A98E8-48B5-4DCE-A98E-4623EE746E16}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D53A98E8-48B5-4DCE-A98E-4623EE746E16}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D53A98E8-48B5-4DCE-A98E-4623EE746E16}.Debug|ARM.ActiveCfg = Debug|Any CPU - {D53A98E8-48B5-4DCE-A98E-4623EE746E16}.Debug|ARM.Build.0 = Debug|Any CPU - {D53A98E8-48B5-4DCE-A98E-4623EE746E16}.Debug|iPhone.ActiveCfg = Debug|Any CPU - {D53A98E8-48B5-4DCE-A98E-4623EE746E16}.Debug|iPhone.Build.0 = Debug|Any CPU - {D53A98E8-48B5-4DCE-A98E-4623EE746E16}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU - {D53A98E8-48B5-4DCE-A98E-4623EE746E16}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU - {D53A98E8-48B5-4DCE-A98E-4623EE746E16}.Debug|x64.ActiveCfg = Debug|Any CPU - {D53A98E8-48B5-4DCE-A98E-4623EE746E16}.Debug|x64.Build.0 = Debug|Any CPU - {D53A98E8-48B5-4DCE-A98E-4623EE746E16}.Debug|x86.ActiveCfg = Debug|Any CPU - {D53A98E8-48B5-4DCE-A98E-4623EE746E16}.Debug|x86.Build.0 = Debug|Any CPU - {D53A98E8-48B5-4DCE-A98E-4623EE746E16}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D53A98E8-48B5-4DCE-A98E-4623EE746E16}.Release|Any CPU.Build.0 = Release|Any CPU - {D53A98E8-48B5-4DCE-A98E-4623EE746E16}.Release|ARM.ActiveCfg = Release|Any CPU - {D53A98E8-48B5-4DCE-A98E-4623EE746E16}.Release|ARM.Build.0 = Release|Any CPU - {D53A98E8-48B5-4DCE-A98E-4623EE746E16}.Release|iPhone.ActiveCfg = Release|Any CPU - {D53A98E8-48B5-4DCE-A98E-4623EE746E16}.Release|iPhone.Build.0 = Release|Any CPU - {D53A98E8-48B5-4DCE-A98E-4623EE746E16}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU - {D53A98E8-48B5-4DCE-A98E-4623EE746E16}.Release|iPhoneSimulator.Build.0 = Release|Any CPU - {D53A98E8-48B5-4DCE-A98E-4623EE746E16}.Release|x64.ActiveCfg = Release|Any CPU - {D53A98E8-48B5-4DCE-A98E-4623EE746E16}.Release|x64.Build.0 = Release|Any CPU - {D53A98E8-48B5-4DCE-A98E-4623EE746E16}.Release|x86.ActiveCfg = Release|Any CPU - {D53A98E8-48B5-4DCE-A98E-4623EE746E16}.Release|x86.Build.0 = Release|Any CPU - {C587AAC3-50A7-4871-A50D-7880B6F24EF6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C587AAC3-50A7-4871-A50D-7880B6F24EF6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C587AAC3-50A7-4871-A50D-7880B6F24EF6}.Debug|ARM.ActiveCfg = Debug|Any CPU - {C587AAC3-50A7-4871-A50D-7880B6F24EF6}.Debug|ARM.Build.0 = Debug|Any CPU - {C587AAC3-50A7-4871-A50D-7880B6F24EF6}.Debug|iPhone.ActiveCfg = Debug|Any CPU - {C587AAC3-50A7-4871-A50D-7880B6F24EF6}.Debug|iPhone.Build.0 = Debug|Any CPU - {C587AAC3-50A7-4871-A50D-7880B6F24EF6}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU - {C587AAC3-50A7-4871-A50D-7880B6F24EF6}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU - {C587AAC3-50A7-4871-A50D-7880B6F24EF6}.Debug|x64.ActiveCfg = Debug|Any CPU - {C587AAC3-50A7-4871-A50D-7880B6F24EF6}.Debug|x64.Build.0 = Debug|Any CPU - {C587AAC3-50A7-4871-A50D-7880B6F24EF6}.Debug|x86.ActiveCfg = Debug|Any CPU - {C587AAC3-50A7-4871-A50D-7880B6F24EF6}.Debug|x86.Build.0 = Debug|Any CPU - {C587AAC3-50A7-4871-A50D-7880B6F24EF6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C587AAC3-50A7-4871-A50D-7880B6F24EF6}.Release|Any CPU.Build.0 = Release|Any CPU - {C587AAC3-50A7-4871-A50D-7880B6F24EF6}.Release|ARM.ActiveCfg = Release|Any CPU - {C587AAC3-50A7-4871-A50D-7880B6F24EF6}.Release|ARM.Build.0 = Release|Any CPU - {C587AAC3-50A7-4871-A50D-7880B6F24EF6}.Release|iPhone.ActiveCfg = Release|Any CPU - {C587AAC3-50A7-4871-A50D-7880B6F24EF6}.Release|iPhone.Build.0 = Release|Any CPU - {C587AAC3-50A7-4871-A50D-7880B6F24EF6}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU - {C587AAC3-50A7-4871-A50D-7880B6F24EF6}.Release|iPhoneSimulator.Build.0 = Release|Any CPU - {C587AAC3-50A7-4871-A50D-7880B6F24EF6}.Release|x64.ActiveCfg = Release|Any CPU - {C587AAC3-50A7-4871-A50D-7880B6F24EF6}.Release|x64.Build.0 = Release|Any CPU - {C587AAC3-50A7-4871-A50D-7880B6F24EF6}.Release|x86.ActiveCfg = Release|Any CPU - {C587AAC3-50A7-4871-A50D-7880B6F24EF6}.Release|x86.Build.0 = Release|Any CPU {A959A406-91A5-4D81-B90D-EF022812D97D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A959A406-91A5-4D81-B90D-EF022812D97D}.Debug|Any CPU.Build.0 = Debug|Any CPU {A959A406-91A5-4D81-B90D-EF022812D97D}.Debug|ARM.ActiveCfg = Debug|Any CPU @@ -360,6 +314,78 @@ Global {61D956D2-5819-4736-BBD8-AD8208DE6A62}.Release|x64.Build.0 = Release|Any CPU {61D956D2-5819-4736-BBD8-AD8208DE6A62}.Release|x86.ActiveCfg = Release|Any CPU {61D956D2-5819-4736-BBD8-AD8208DE6A62}.Release|x86.Build.0 = Release|Any CPU + {AC068302-655B-46B8-BC8A-971A3D685437}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AC068302-655B-46B8-BC8A-971A3D685437}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AC068302-655B-46B8-BC8A-971A3D685437}.Debug|ARM.ActiveCfg = Debug|Any CPU + {AC068302-655B-46B8-BC8A-971A3D685437}.Debug|ARM.Build.0 = Debug|Any CPU + {AC068302-655B-46B8-BC8A-971A3D685437}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {AC068302-655B-46B8-BC8A-971A3D685437}.Debug|iPhone.Build.0 = Debug|Any CPU + {AC068302-655B-46B8-BC8A-971A3D685437}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {AC068302-655B-46B8-BC8A-971A3D685437}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {AC068302-655B-46B8-BC8A-971A3D685437}.Debug|x64.ActiveCfg = Debug|Any CPU + {AC068302-655B-46B8-BC8A-971A3D685437}.Debug|x64.Build.0 = Debug|Any CPU + {AC068302-655B-46B8-BC8A-971A3D685437}.Debug|x86.ActiveCfg = Debug|Any CPU + {AC068302-655B-46B8-BC8A-971A3D685437}.Debug|x86.Build.0 = Debug|Any CPU + {AC068302-655B-46B8-BC8A-971A3D685437}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AC068302-655B-46B8-BC8A-971A3D685437}.Release|Any CPU.Build.0 = Release|Any CPU + {AC068302-655B-46B8-BC8A-971A3D685437}.Release|ARM.ActiveCfg = Release|Any CPU + {AC068302-655B-46B8-BC8A-971A3D685437}.Release|ARM.Build.0 = Release|Any CPU + {AC068302-655B-46B8-BC8A-971A3D685437}.Release|iPhone.ActiveCfg = Release|Any CPU + {AC068302-655B-46B8-BC8A-971A3D685437}.Release|iPhone.Build.0 = Release|Any CPU + {AC068302-655B-46B8-BC8A-971A3D685437}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {AC068302-655B-46B8-BC8A-971A3D685437}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {AC068302-655B-46B8-BC8A-971A3D685437}.Release|x64.ActiveCfg = Release|Any CPU + {AC068302-655B-46B8-BC8A-971A3D685437}.Release|x64.Build.0 = Release|Any CPU + {AC068302-655B-46B8-BC8A-971A3D685437}.Release|x86.ActiveCfg = Release|Any CPU + {AC068302-655B-46B8-BC8A-971A3D685437}.Release|x86.Build.0 = Release|Any CPU + {6E2927DD-791F-48FA-96E1-696611FB38EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6E2927DD-791F-48FA-96E1-696611FB38EB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6E2927DD-791F-48FA-96E1-696611FB38EB}.Debug|ARM.ActiveCfg = Debug|Any CPU + {6E2927DD-791F-48FA-96E1-696611FB38EB}.Debug|ARM.Build.0 = Debug|Any CPU + {6E2927DD-791F-48FA-96E1-696611FB38EB}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {6E2927DD-791F-48FA-96E1-696611FB38EB}.Debug|iPhone.Build.0 = Debug|Any CPU + {6E2927DD-791F-48FA-96E1-696611FB38EB}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {6E2927DD-791F-48FA-96E1-696611FB38EB}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {6E2927DD-791F-48FA-96E1-696611FB38EB}.Debug|x64.ActiveCfg = Debug|Any CPU + {6E2927DD-791F-48FA-96E1-696611FB38EB}.Debug|x64.Build.0 = Debug|Any CPU + {6E2927DD-791F-48FA-96E1-696611FB38EB}.Debug|x86.ActiveCfg = Debug|Any CPU + {6E2927DD-791F-48FA-96E1-696611FB38EB}.Debug|x86.Build.0 = Debug|Any CPU + {6E2927DD-791F-48FA-96E1-696611FB38EB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6E2927DD-791F-48FA-96E1-696611FB38EB}.Release|Any CPU.Build.0 = Release|Any CPU + {6E2927DD-791F-48FA-96E1-696611FB38EB}.Release|ARM.ActiveCfg = Release|Any CPU + {6E2927DD-791F-48FA-96E1-696611FB38EB}.Release|ARM.Build.0 = Release|Any CPU + {6E2927DD-791F-48FA-96E1-696611FB38EB}.Release|iPhone.ActiveCfg = Release|Any CPU + {6E2927DD-791F-48FA-96E1-696611FB38EB}.Release|iPhone.Build.0 = Release|Any CPU + {6E2927DD-791F-48FA-96E1-696611FB38EB}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {6E2927DD-791F-48FA-96E1-696611FB38EB}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {6E2927DD-791F-48FA-96E1-696611FB38EB}.Release|x64.ActiveCfg = Release|Any CPU + {6E2927DD-791F-48FA-96E1-696611FB38EB}.Release|x64.Build.0 = Release|Any CPU + {6E2927DD-791F-48FA-96E1-696611FB38EB}.Release|x86.ActiveCfg = Release|Any CPU + {6E2927DD-791F-48FA-96E1-696611FB38EB}.Release|x86.Build.0 = Release|Any CPU + {6CC49E97-4F07-43DE-A2AF-50914498A276}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6CC49E97-4F07-43DE-A2AF-50914498A276}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6CC49E97-4F07-43DE-A2AF-50914498A276}.Debug|ARM.ActiveCfg = Debug|Any CPU + {6CC49E97-4F07-43DE-A2AF-50914498A276}.Debug|ARM.Build.0 = Debug|Any CPU + {6CC49E97-4F07-43DE-A2AF-50914498A276}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {6CC49E97-4F07-43DE-A2AF-50914498A276}.Debug|iPhone.Build.0 = Debug|Any CPU + {6CC49E97-4F07-43DE-A2AF-50914498A276}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {6CC49E97-4F07-43DE-A2AF-50914498A276}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {6CC49E97-4F07-43DE-A2AF-50914498A276}.Debug|x64.ActiveCfg = Debug|Any CPU + {6CC49E97-4F07-43DE-A2AF-50914498A276}.Debug|x64.Build.0 = Debug|Any CPU + {6CC49E97-4F07-43DE-A2AF-50914498A276}.Debug|x86.ActiveCfg = Debug|Any CPU + {6CC49E97-4F07-43DE-A2AF-50914498A276}.Debug|x86.Build.0 = Debug|Any CPU + {6CC49E97-4F07-43DE-A2AF-50914498A276}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6CC49E97-4F07-43DE-A2AF-50914498A276}.Release|Any CPU.Build.0 = Release|Any CPU + {6CC49E97-4F07-43DE-A2AF-50914498A276}.Release|ARM.ActiveCfg = Release|Any CPU + {6CC49E97-4F07-43DE-A2AF-50914498A276}.Release|ARM.Build.0 = Release|Any CPU + {6CC49E97-4F07-43DE-A2AF-50914498A276}.Release|iPhone.ActiveCfg = Release|Any CPU + {6CC49E97-4F07-43DE-A2AF-50914498A276}.Release|iPhone.Build.0 = Release|Any CPU + {6CC49E97-4F07-43DE-A2AF-50914498A276}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {6CC49E97-4F07-43DE-A2AF-50914498A276}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {6CC49E97-4F07-43DE-A2AF-50914498A276}.Release|x64.ActiveCfg = Release|Any CPU + {6CC49E97-4F07-43DE-A2AF-50914498A276}.Release|x64.Build.0 = Release|Any CPU + {6CC49E97-4F07-43DE-A2AF-50914498A276}.Release|x86.ActiveCfg = Release|Any CPU + {6CC49E97-4F07-43DE-A2AF-50914498A276}.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 628ea20..f81587e 100644 --- a/Borepin/Borepin.Android/MainActivity.cs +++ b/Borepin/Borepin.Android/MainActivity.cs @@ -1,12 +1,23 @@ - -using Android.App; +using Android.App; +using Android.Content; using Android.Content.PM; using Android.OS; using AndroidX.AppCompat.App; namespace Borepin.Droid { - [Activity(Theme = "@style/MainTheme", ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)] + [Activity(Theme = "@style/MainTheme", LaunchMode = LaunchMode.SingleTask, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation, Exported = true)] + [IntentFilter( + new[] + { + "android.nfc.action.NDEF_DISCOVERED", + }, + Categories = new[] + { + Intent.CategoryDefault + }, + DataScheme = "fabaccess" + )] public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity { protected override void OnCreate(Bundle savedInstanceState) @@ -24,6 +35,15 @@ namespace Borepin.Droid Xamarin.Forms.Forms.Init(this, savedInstanceState); LoadApplication(new App(new PlatformInitializer())); } + protected override void OnNewIntent(Intent intent) + { + if(intent.Action == "android.nfc.action.NDEF_DISCOVERED") + { + intent.SetAction(Intent.ActionView); + } + + base.OnNewIntent(intent); + } public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults) { diff --git a/Borepin/Borepin.Android/MainApplication.cs b/Borepin/Borepin.Android/MainApplication.cs index 3b9e7a7..29d747f 100644 --- a/Borepin/Borepin.Android/MainApplication.cs +++ b/Borepin/Borepin.Android/MainApplication.cs @@ -7,9 +7,9 @@ namespace Borepin.Droid [Application(Label = "FabAccess", Icon = "@mipmap/ic_launcher")] public class MainApplication : Application { - public MainApplication(IntPtr javaReference, JniHandleOwnership transfer) - : base(javaReference, transfer) + public MainApplication(IntPtr javaReference, JniHandleOwnership transfer) : base(javaReference, transfer) { + } } } \ No newline at end of file diff --git a/Borepin/Borepin.Android/PlatformInitializer.cs b/Borepin/Borepin.Android/PlatformInitializer.cs index 540b18b..c482a3b 100644 --- a/Borepin/Borepin.Android/PlatformInitializer.cs +++ b/Borepin/Borepin.Android/PlatformInitializer.cs @@ -16,6 +16,7 @@ namespace Borepin.Droid containerRegistry.Register(); containerRegistry.Register(); containerRegistry.Register(); + // TODO containerRegistry.Register(); containerRegistry.RegisterSingleton(); } diff --git a/Borepin/Borepin.Android/Properties/AndroidManifest.xml b/Borepin/Borepin.Android/Properties/AndroidManifest.xml index 45d1042..77db275 100644 --- a/Borepin/Borepin.Android/Properties/AndroidManifest.xml +++ b/Borepin/Borepin.Android/Properties/AndroidManifest.xml @@ -1,9 +1,13 @@  - - - - - - \ No newline at end of file + + + + + + + + + + diff --git a/Borepin/Borepin.Android/Properties/AssemblyInfo.cs b/Borepin/Borepin.Android/Properties/AssemblyInfo.cs index 79beedf..94577a1 100644 --- a/Borepin/Borepin.Android/Properties/AssemblyInfo.cs +++ b/Borepin/Borepin.Android/Properties/AssemblyInfo.cs @@ -27,6 +27,7 @@ using Android.App; // Add some common permissions, these can be removed if not needed [assembly: UsesPermission(Android.Manifest.Permission.Internet)] [assembly: UsesPermission(Android.Manifest.Permission.WriteExternalStorage)] +[assembly: UsesPermission(Android.Manifest.Permission.Nfc)] //#if DEBUG //[assembly: Application(Debuggable=true)] diff --git a/Borepin/Borepin.UWP/Borepin.UWP.csproj b/Borepin/Borepin.UWP/Borepin.UWP.csproj index 52680ed..bf2f6aa 100644 --- a/Borepin/Borepin.UWP/Borepin.UWP.csproj +++ b/Borepin/Borepin.UWP/Borepin.UWP.csproj @@ -187,9 +187,17 @@ - {c587aac3-50a7-4871-a50d-7880b6f24ef6} + {6cc49e97-4f07-43de-a2af-50914498a276} Capnp.Net.Runtime + + {6e2927dd-791f-48fa-96e1-696611fb38eb} + NFC.PCSC + + + {ac068302-655b-46b8-bc8a-971a3d685437} + NFC + {3251FCE9-FEA3-4662-8BEB-636BE6732D48} FabAccessAPI diff --git a/Borepin/Borepin.UWP/Package.appxmanifest b/Borepin/Borepin.UWP/Package.appxmanifest index f509582..82b7c23 100644 --- a/Borepin/Borepin.UWP/Package.appxmanifest +++ b/Borepin/Borepin.UWP/Package.appxmanifest @@ -54,6 +54,7 @@ - + + \ No newline at end of file diff --git a/Borepin/Borepin.UWP/PlatformInitializer.cs b/Borepin/Borepin.UWP/PlatformInitializer.cs index 0818906..b43322a 100644 --- a/Borepin/Borepin.UWP/PlatformInitializer.cs +++ b/Borepin/Borepin.UWP/PlatformInitializer.cs @@ -5,6 +5,8 @@ using Borepin.Service.Storage; using Borepin.Service.Versioning; using Borepin.Service; using Borepin.Service.Browser; +using NFC.PCSC; +using NFC.Interfaces; namespace Borepin.UWP { @@ -16,6 +18,7 @@ namespace Borepin.UWP containerRegistry.Register(); containerRegistry.Register(); containerRegistry.Register(); + containerRegistry.Register(); containerRegistry.RegisterSingleton(); } diff --git a/Borepin/Borepin.iOS/Info.plist b/Borepin/Borepin.iOS/Info.plist index 79a6f24..dd5e508 100644 --- a/Borepin/Borepin.iOS/Info.plist +++ b/Borepin/Borepin.iOS/Info.plist @@ -42,5 +42,18 @@ Light NSCameraUsageDescription Please allow access to the camera to scan barcodes + CFBundleURLTypes + + + CFBundleURLName + FabAccess + CFBundleURLSchemes + + fabaccess + + CFBundleTypeRole + Viewer + + diff --git a/Borepin/Borepin.iOS/PlatformInitializer.cs b/Borepin/Borepin.iOS/PlatformInitializer.cs index ade1f95..dc885eb 100644 --- a/Borepin/Borepin.iOS/PlatformInitializer.cs +++ b/Borepin/Borepin.iOS/PlatformInitializer.cs @@ -16,6 +16,7 @@ namespace Borepin.iOS containerRegistry.Register(); containerRegistry.Register(); containerRegistry.Register(); + // TODO containerRegistry.Register(); containerRegistry.RegisterSingleton(); } diff --git a/Borepin/Borepin/App.xaml.cs b/Borepin/Borepin/App.xaml.cs index 0398942..6adb105 100644 --- a/Borepin/Borepin/App.xaml.cs +++ b/Borepin/Borepin/App.xaml.cs @@ -13,6 +13,14 @@ using System; using Borepin.Service.Storage; using NLog; using Borepin.Service.ErrorMessage; +using Prism.Navigation.Xaml; +using Prism.Navigation; +using Borepin.Service; +using FabAccessAPI; +using FabAccessAPI.Schema; +using System.Threading.Tasks; +using System.Collections.Generic; +using Prism.Services; namespace Borepin { @@ -20,8 +28,8 @@ namespace Borepin { public App(IPlatformInitializer platformInitializer) : base(platformInitializer) { - var config = new NLog.Config.LoggingConfiguration(); - var logconsole = new NLog.Targets.ConsoleTarget("logconsole"); + NLog.Config.LoggingConfiguration config = new NLog.Config.LoggingConfiguration(); + NLog.Targets.ConsoleTarget logconsole = new NLog.Targets.ConsoleTarget("logconsole"); config.AddRule(LogLevel.Trace, LogLevel.Fatal, logconsole); LogManager.Configuration = config; } @@ -33,6 +41,52 @@ namespace Borepin await NavigationService.NavigateAsync(new Uri("https://borepin.fab-access.org/StartPage")).ConfigureAwait(false); } + + protected override async void OnAppLinkRequestReceived(Uri uri) + { + IPageDialogService pageDialogService = Container.Resolve(); + + if (uri.LocalPath.StartsWith("/resource/", StringComparison.OrdinalIgnoreCase)) + { + if (Container.IsRegistered() && Container.IsRegistered()) + { + string resource_id = uri.LocalPath.Remove(0, "/resource/".Length); + + IAPIService apiService = Container.Resolve(); + IAPI api = apiService.GetAPI(); + + if (api.IsConnected) + { + Optional optional = await api.Session.MachineSystem.Info.GetMachine(resource_id).ConfigureAwait(false); + + if (optional.Just == null) + { + Device.BeginInvokeOnMainThread(async () => + { + await pageDialogService.DisplayAlertAsync(Borepin.Resources.Text.TextResource.ALERT, Borepin.Resources.Text.TextResource.ALERT_ID, Borepin.Resources.Text.TextResource.OK).ConfigureAwait(false); + }); + return; + } + + Prism.Navigation.NavigationParameters parameters = new Prism.Navigation.NavigationParameters + { + { "instance", optional.Just.Id }, + }; + + Device.BeginInvokeOnMainThread(async () => + { + INavigationResult result = await Container.Resolve().NavigateAsync("/MainPage/NavigationPage/MachineListPage/MachinePage", parameters).ConfigureAwait(false); + }); + } + } + else + { + return; + } + } + + } + protected override void RegisterTypes(IContainerRegistry containerRegistry) { #region Register Basic Navigation @@ -51,6 +105,7 @@ namespace Borepin containerRegistry.RegisterForNavigation(); containerRegistry.RegisterForNavigation(); + containerRegistry.RegisterForNavigation(); containerRegistry.RegisterForNavigation(); containerRegistry.RegisterForNavigation(); #endregion diff --git a/Borepin/Borepin/Borepin.csproj b/Borepin/Borepin/Borepin.csproj index 69ae925..32ed436 100644 --- a/Borepin/Borepin/Borepin.csproj +++ b/Borepin/Borepin/Borepin.csproj @@ -111,6 +111,9 @@ MSBuild:UpdateDesignTimeXaml + + MSBuild:UpdateDesignTimeXaml + MSBuild:UpdateDesignTimeXaml @@ -156,6 +159,7 @@ + diff --git a/Borepin/Borepin/Model/CardConfig.cs b/Borepin/Borepin/Model/CardConfig.cs new file mode 100644 index 0000000..d55a89e --- /dev/null +++ b/Borepin/Borepin/Model/CardConfig.cs @@ -0,0 +1,68 @@ +using NFC.Helper; +using System; +using System.Globalization; +using System.Security.Cryptography; + +namespace Borepin.Model +{ + public class CardConfig + { + #region Constructors + public CardConfig() + { + PICCKey = GenerateEmptyKey(); + APPKey = GenerateEmptyKey(); + } + #endregion + + #region Fields + public string UserID; + + public byte[] PICCKey; + public byte[] APPKey; + + public bool DoFormat; + + public byte[] CardToken; + public byte[] MetaInfo; + public byte[] SpaceInfo; + #endregion + + #region Mehtods + public string ConvertToString(byte[] array) + { + string data = HexConverter.ConvertToHexString(array); + data = data.ToUpper(CultureInfo.InvariantCulture); + + for(int i = 2; i < data.Length; i += 3) + { + data = data.Insert(i, " "); + } + + return data; + } + + public byte[] ConvertFromString(string data) + { + data = data.Trim(); + data = data.Replace(" ", ""); + + byte[] array = HexConverter.ConvertFromHexString(data); + return array; + } + + public byte[] GenerateRandomKey() + { + byte[] key = ByteOperation.GenerateEmptyArray(16); + RNGCryptoServiceProvider cryptoProvider = new RNGCryptoServiceProvider(); + cryptoProvider.GetBytes(key); + return key; + } + + public byte[] GenerateEmptyKey() + { + return ByteOperation.GenerateEmptyArray(16); + } + #endregion + } +} diff --git a/Borepin/Borepin/Model/DESFireInterfaceDummy.cs b/Borepin/Borepin/Model/DESFireInterfaceDummy.cs new file mode 100644 index 0000000..ea982ae --- /dev/null +++ b/Borepin/Borepin/Model/DESFireInterfaceDummy.cs @@ -0,0 +1,63 @@ +using Borepin.Page; +using FabAccessAPI.Schema; +using ImTools; +using NFC.Helper; +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + +namespace Borepin.Model +{ + public class DESFireInterfaceDummy : User.ICardDESFireInterface + { + public Task Bind(IReadOnlyList token, IReadOnlyList auth_key, CancellationToken cancellationToken_ = default) + { + return Task.CompletedTask; + } + + public void Dispose() + { + + } + + public Task> GenCardToken(CancellationToken cancellationToken_ = default) + { + List token = new List(); + token.AddRange(HexConverter.ConvertFromHexString("11 00 00 00 00 00 00 00 00 00 00 00 00 00 00 11".Replace(" ", ""))); + return Task.FromResult((IReadOnlyList) token); + } + + public Task> GetMetaInfo(CancellationToken cancellationToken_ = default) + { + List data = new List(); + data.AddRange(Encoding.ASCII.GetBytes("FABACCESS\0DESFIRE\01.0\0").Append((byte)0x00)); + return Task.FromResult((IReadOnlyList)data); + } + + public Task> GetSpaceInfo(CancellationToken cancellationToken_ = default) + { + List data = new List(); + data.AddRange(Encoding.ASCII.GetBytes("urn:fabaccess:lab:fabaccess_test").Append((byte)0x00)); + return Task.FromResult((IReadOnlyList)data); + } + + public Task>> GetTokenList(CancellationToken cancellationToken_ = default) + { + List token = new List(); + token.AddRange(HexConverter.ConvertFromHexString("11 00 00 00 00 00 00 00 00 00 00 00 00 00 00 11".Replace(" ", ""))); + + IReadOnlyList> list = new List> + { + token + }; + return Task.FromResult(list); + } + + public Task Unbind(IReadOnlyList token, CancellationToken cancellationToken_ = default) + { + return Task.CompletedTask; + } + } +} diff --git a/Borepin/Borepin/Model/FabFireCard.cs b/Borepin/Borepin/Model/FabFireCard.cs new file mode 100644 index 0000000..511ca93 --- /dev/null +++ b/Borepin/Borepin/Model/FabFireCard.cs @@ -0,0 +1,116 @@ +using Borepin.Service.ErrorMessage; +using NFC.Cards.NXP_MIFARE_DESFire; +using NFC.Cards.NXP_MIFARE_DESFire.Enums; +using NFC.Helper; +using NFC.Helper.Crypto; +using NFC.Interfaces; +using System; +using System.Text; +using ZXing.Aztec.Internal; + +namespace Borepin.Model +{ + public class FabFireCard + { + #region Private Fields + readonly INFCService _NFCService; + readonly IErrorMessageService _ErrorMessageService; + #endregion + + #region Constructors + public FabFireCard(INFCService nfcService, IErrorMessageService errorMessageService) + { + _NFCService = nfcService; + _ErrorMessageService = errorMessageService; + } + #endregion + + #region Methods + /// + /// Format Card + /// + /// + /// + public void FormatCard(string readerID, CardConfig cardConfig) + { + CipherKey PICCKey = new CipherKey(cardConfig.PICCKey, CipherType.TDES, 0x00); + + _NFCService.Connect(readerID); + + NXP_MIFARE_DESFire card = new NXP_MIFARE_DESFire(_NFCService); + card.SelectApplication(0x000000); + card.AuthenticateISO_DES(0x00, PICCKey._Key); + card.Format(); + + _NFCService.Disconnect(); + } + + /// + /// Create DESFire Card for V1.0 + /// + /// + /// + /// Key #1 for authentication + public byte[] CreateCard(string readerID, CardConfig cardConfig) + { + CipherKey PICCKey = new CipherKey(cardConfig.PICCKey, CipherType.TDES, 0x00); + CipherKey MasterKey = new CipherKey(cardConfig.APPKey, CipherType.AES, 0x10); + CipherKey AuthKey = new CipherKey(cardConfig.GenerateRandomKey(), CipherType.AES, 0x10); + UInt32 AID = 0x464142; + + CipherKey _Default_DESKey = new CipherKey(CipherType.TDES); + CipherKey _Default_AESKey = new CipherKey(CipherType.AES); + + _NFCService.Connect(readerID); + NXP_MIFARE_DESFire card = new NXP_MIFARE_DESFire(_NFCService); + + if (cardConfig.DoFormat) + { + card.AuthenticateISO_DES(0x00, _Default_DESKey._Key); + } + else + { + card.AuthenticateISO_DES(0x00, PICCKey._Key); + } + + byte keySetting1 = card.GenerateKeySetting1(ChangeApplicationKey.MASTERKEY, ChangeMasterKeySettings.WITHMASTERKEY, CreateDeleteFile.ONLYMASTERKEY, FileDirectoryAccess.NOKEY, ChangeMasterKey.CHANGEABLE); + byte keySetting2 = card.GenerateKeySetting2(CryptoOperationsType.AES, FileIdentifies.NOTUSED, 0x02); + card.CreateApplication(AID, keySetting1, keySetting2); + + card.SelectApplication(AID); + card.AuthenticateISO_AES(0x00, _Default_AESKey._Key); + + card.ChangeKey_AES(0x00, MasterKey._Key, MasterKey._KeyVersion); + + card.AuthenticateISO_AES(0x00, MasterKey._Key); + card.ChangeOtherKey_AES(0x01, AuthKey._Key, _Default_AESKey._Key, AuthKey._KeyVersion); + + UInt16 accessRights = card.GenerateFileAccessRights((byte)FileAccessRights.FREE, 0x00, 0x00, 0x00); + + card.CreateFile_Standard(0x01, FileCommunication.PLAIN, accessRights, (uint)cardConfig.MetaInfo.Length); + card.CreateFile_Standard(0x02, FileCommunication.PLAIN, accessRights, (uint)cardConfig.SpaceInfo.Length); + card.CreateFile_Standard(0x03, FileCommunication.PLAIN, accessRights, (uint)47);// TODO (uint)cardConfig.CardToken.Length); + + card.WriteData(0x01, 0x00, cardConfig.MetaInfo); + card.WriteData(0x02, 0x00, cardConfig.SpaceInfo); + card.WriteData(0x03, 0x00, _TODOFixDataFileSize(cardConfig.CardToken)); + + _NFCService.Disconnect(); + + return AuthKey._Key; + } + + /// + /// TODO implement GetFileInfo in DESFire + /// + /// + /// + private byte[] _TODOFixDataFileSize(byte[] data) + { + byte[] array = ByteOperation.GenerateEmptyArray(47); + data.CopyTo(array, 0); + return array; + } + #endregion + } +} diff --git a/Borepin/Borepin/Model/KeyScan.cs b/Borepin/Borepin/Model/KeyScan.cs new file mode 100644 index 0000000..c590bb9 --- /dev/null +++ b/Borepin/Borepin/Model/KeyScan.cs @@ -0,0 +1,14 @@ +namespace Borepin.Model +{ + public class KeyScan + { + public KeyScan(CardConfig cardConfig, KeyTypes keyType) + { + CardConfig = cardConfig; + KeyType = keyType; + } + + public CardConfig CardConfig; + public KeyTypes KeyType; + } +} diff --git a/Borepin/Borepin/Model/KeyTypes.cs b/Borepin/Borepin/Model/KeyTypes.cs new file mode 100644 index 0000000..e2e6391 --- /dev/null +++ b/Borepin/Borepin/Model/KeyTypes.cs @@ -0,0 +1,9 @@ +namespace Borepin.Model +{ + public enum KeyTypes + { + NONE, + PICC, + APP + }; +} diff --git a/Borepin/Borepin/Model/MachineVisualize.cs b/Borepin/Borepin/Model/MachineVisualize.cs index 709c7c5..990a1c9 100644 --- a/Borepin/Borepin/Model/MachineVisualize.cs +++ b/Borepin/Borepin/Model/MachineVisualize.cs @@ -21,6 +21,11 @@ namespace Borepin.Model #region Methods public async Task LoadData() { + if(_Machine== null) + { + return; + } + //ID = _Machine.Id; //Space = new SpaceVisualize(_Machine.Space); Name = _Machine.Name; @@ -75,6 +80,7 @@ namespace Borepin.Model CanManage = !((ManageInterface_Proxy)_Machine.Manage).IsNull; CanAdmin = !((AdminInterface_Proxy)_Machine.Admin).IsNull; CanNotUseByPermission = State == MachineState.free && !CanUse; + IsLock = !((ProdInterface_Proxy)_Machine.Prodable).IsNull; } #endregion @@ -197,6 +203,13 @@ namespace Borepin.Model get => _CanNotUseByPermission; set => SetProperty(ref _CanNotUseByPermission, value); } + + private bool _IsLock; + public bool IsLock + { + get => _IsLock; + set => SetProperty(ref _IsLock, value); + } #endregion } } diff --git a/Borepin/Borepin/Model/UserVisualize.cs b/Borepin/Borepin/Model/UserVisualize.cs index 8f3d3b5..250c62a 100644 --- a/Borepin/Borepin/Model/UserVisualize.cs +++ b/Borepin/Borepin/Model/UserVisualize.cs @@ -20,6 +20,11 @@ namespace Borepin.Model #region LoadData public Task LoadData() { + if(_User == null) + { + return Task.CompletedTask; + } + //ID = _User.Id; Username = _User.Username; //Space = new SpaceVisualize(_User.Space); diff --git a/Borepin/Borepin/Page/AddServerProcess/AuthPlainPage.xaml b/Borepin/Borepin/Page/AddServerProcess/AuthPlainPage.xaml index 9a070a9..67ba8a6 100644 --- a/Borepin/Borepin/Page/AddServerProcess/AuthPlainPage.xaml +++ b/Borepin/Borepin/Page/AddServerProcess/AuthPlainPage.xaml @@ -13,7 +13,8 @@ - + diff --git a/Borepin/Borepin/Page/AddServerProcess/ChooseAuthTypePage.xaml b/Borepin/Borepin/Page/AddServerProcess/ChooseAuthTypePage.xaml index e247938..1d01460 100644 --- a/Borepin/Borepin/Page/AddServerProcess/ChooseAuthTypePage.xaml +++ b/Borepin/Borepin/Page/AddServerProcess/ChooseAuthTypePage.xaml @@ -13,7 +13,7 @@ - + diff --git a/Borepin/Borepin/Page/AddServerProcess/SelectServerPage.xaml b/Borepin/Borepin/Page/AddServerProcess/SelectServerPage.xaml index 8f17f52..b8b2a51 100644 --- a/Borepin/Borepin/Page/AddServerProcess/SelectServerPage.xaml +++ b/Borepin/Borepin/Page/AddServerProcess/SelectServerPage.xaml @@ -12,21 +12,24 @@ - - + + - + - + diff --git a/Borepin/Borepin/Page/CreateCardPage.xaml b/Borepin/Borepin/Page/CreateCardPage.xaml new file mode 100644 index 0000000..072c61e --- /dev/null +++ b/Borepin/Borepin/Page/CreateCardPage.xaml @@ -0,0 +1,64 @@ + + + + + + + + + + + + diff --git a/Borepin/Borepin/Page/MachinePage.xaml b/Borepin/Borepin/Page/MachinePage.xaml index 99ebf23..47857ae 100644 --- a/Borepin/Borepin/Page/MachinePage.xaml +++ b/Borepin/Borepin/Page/MachinePage.xaml @@ -43,15 +43,23 @@ -