Skip to content

Commit

Permalink
Added addtional option to set hardware events tracing
Browse files Browse the repository at this point in the history
  • Loading branch information
perevoznyk committed Oct 1, 2021
1 parent 349158d commit 40b5c98
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 19 deletions.
Binary file modified Redist/Swelio32.dll
Binary file not shown.
Binary file modified Redist/Swelio64.dll
Binary file not shown.
8 changes: 7 additions & 1 deletion Samples/C#/EIDTestApp/EIDTestApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<OldToolsVersion>3.5</OldToolsVersion>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
<TargetFrameworkProfile />
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
Expand All @@ -43,6 +43,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand All @@ -51,6 +52,7 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -59,6 +61,7 @@
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<OutputPath>bin\x86\Release\</OutputPath>
Expand All @@ -67,6 +70,7 @@
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -77,6 +81,7 @@
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
<OutputPath>bin\x64\Release\</OutputPath>
Expand All @@ -87,6 +92,7 @@
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
Expand Down
11 changes: 2 additions & 9 deletions Samples/C#/EIDTestApp/FormMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,8 @@
//used for purposes other than as intended.

using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using Swelio.Engine;

namespace EIDTestApp
Expand Down Expand Up @@ -192,6 +183,8 @@ private void ActivateCardEventsTracing()
engine.CardInserted += new EventHandler<CardEventArgs>(engine_CardInserted);
engine.CardRemoved += new EventHandler<CardEventArgs>(engine_CardRemoved);
engine.ReadersListChanged += new EventHandler(engine_ReadersListChanged);
engine.TraceHardwareEvents = true;
engine.TraceServiceEvents = true;
engine.TraceEvents = true;
}

Expand Down
8 changes: 8 additions & 0 deletions Samples/C#/EIDTestApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,17 @@ static class Program
[STAThread]
static void Main()
{

if (Environment.OSVersion.Version.Major >= 6)
SetProcessDPIAware();

Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new FormMain());
}

[System.Runtime.InteropServices.DllImport("user32.dll")]
private static extern bool SetProcessDPIAware();

}
}
4 changes: 2 additions & 2 deletions Samples/C#/EIDTestApp/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Samples/C#/EIDTestApp/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Samples/C#/EIDTestApp/app.config
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7"/></startup></configuration>
32 changes: 29 additions & 3 deletions Swelio.Engine/Swelio.Engine/Manager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public sealed class Manager : IDisposable
private List<CardReader> readers;
private bool traceEvents;
private bool traceServiceEvents;
private bool traceHardwareEvents;

private ReaderCallbackDelegate InternalCallbackDelegate;

Expand All @@ -30,6 +31,8 @@ public sealed class Manager : IDisposable
public Manager()
{
readers = new List<CardReader>();
traceHardwareEvents = true;
traceServiceEvents = true;
InternalCallbackDelegate = new ReaderCallbackDelegate(EventTracer);
}

Expand Down Expand Up @@ -98,10 +101,23 @@ private void EventTracer(ref int readerNumber, ref int eventCode, IntPtr userCon
}
break;
case CardEvent.ReadersChange:
ReloadReadersList();
if (ReadersListChanged != null)
int newReadersCount = NativeMethods.GetReadersCount();
if ( (newReadersCount != readers.Count) && traceHardwareEvents)
{
ReadersListChanged(this, EventArgs.Empty);
ReloadReadersList();
if (ReadersListChanged != null)
{
ReadersListChanged(this, EventArgs.Empty);
}
}
else
{
//Just continue to trace events
if (Active)
{
StopEventsTracing();
StartEventsTracing();
}
}
break;
case CardEvent.UnknownEvent:
Expand Down Expand Up @@ -142,6 +158,16 @@ public bool TraceServiceEvents
NativeMethods.IgnoreServiceEvents(!value);
}
}

public bool TraceHardwareEvents
{
get { return traceHardwareEvents; }
set
{
traceHardwareEvents = value;
}
}

public event EventHandler<CardEventArgs> CardInserted;
public event EventHandler<CardEventArgs> CardRemoved;
public event EventHandler ReadersListChanged;
Expand Down
2 changes: 1 addition & 1 deletion Swelio.Engine/Swelio.Engine/NativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2151,7 +2151,7 @@ public static void RemoveCallback()
}


public static void IgnoreServiceEvents(bool valie)
public static void IgnoreServiceEvents(bool value)
{
if (IsWOW64())
{
Expand Down

0 comments on commit 40b5c98

Please sign in to comment.