Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: unlimited implementation #34

Merged
merged 3 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions src/Cryptlex.LexActivator/LexActivator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,9 @@ public static void SetLicenseCallback(CallbackType callback)
/// The activation lease duration is honoured when the allow client
/// lease duration property is enabled.
/// </summary>
/// <param name="leaseDuration"></param>
public static void SetActivationLeaseDuration(uint leaseDuration)
/// <param name="leaseDuration">value of the lease duration.
/// A value of -1 indicates unlimited lease duration.</param>
public static void SetActivationLeaseDuration(long leaseDuration)
{
int status;
if (LexActivatorNative.IsWindows())
Expand Down Expand Up @@ -736,7 +737,8 @@ public static string GetLicenseMetadata(string key)
/// <returns>Returns the values of meter attribute allowed, total and gross uses.</returns>
public static LicenseMeterAttribute GetLicenseMeterAttribute(string name)
{
uint allowedUses = 0, totalUses = 0, grossUses = 0;
long allowedUses = 0;
ulong totalUses = 0, grossUses = 0;
int status;
if (LexActivatorNative.IsWindows())
{
Expand Down Expand Up @@ -780,9 +782,9 @@ public static string GetLicenseKey()
/// Gets the allowed activations of the license.
/// </summary>
/// <returns>Returns the allowed activations.</returns>
public static uint GetLicenseAllowedActivations()
public static long GetLicenseAllowedActivations()
{
uint allowedActivations = 0;
long allowedActivations = 0;
int status;
if (LexActivatorNative.IsWindows())
{
Expand Down Expand Up @@ -834,9 +836,9 @@ public static uint GetLicenseTotalActivations()
/// Gets the allowed deactivations of the license.
/// </summary>
/// <returns>Returns the allowed deactivations.</returns>
public static uint GetLicenseAllowedDeactivations()
public static long GetLicenseAllowedDeactivations()
{
uint allowedDeactivations = 0;
long allowedDeactivations = 0;
int status;
if (LexActivatorNative.IsWindows())
{
Expand Down
18 changes: 9 additions & 9 deletions src/Cryptlex.LexActivator/LexActivatorNative.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public static bool IsWindows()
public static extern int SetLicenseCallback(LexActivator.CallbackType callback);

[DllImport(DLL_FILE_NAME, CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern int SetActivationLeaseDuration(uint leaseDuration);
public static extern int SetActivationLeaseDuration(long leaseDuration);

[DllImport(DLL_FILE_NAME, CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern int SetActivationMetadata(string key, string value);
Expand Down Expand Up @@ -167,10 +167,10 @@ public static bool IsWindows()
public static extern int GetLicenseMetadataA(string key, StringBuilder value, int length);

[DllImport(DLL_FILE_NAME, CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetLicenseMeterAttribute(string name, ref uint allowedUses, ref uint totalUses, ref uint grossUses);
public static extern int GetLicenseMeterAttribute(string name, ref long allowedUses, ref ulong totalUses, ref ulong grossUses);

[DllImport(DLL_FILE_NAME, CharSet = CharSet.Ansi, EntryPoint = "GetLicenseMeterAttribute", CallingConvention = CallingConvention.Cdecl)]
public static extern int GetLicenseMeterAttributeA(string name, ref uint allowedUses, ref uint totalUses, ref uint grossUses);
public static extern int GetLicenseMeterAttributeA(string name, ref long allowedUses, ref ulong totalUses, ref ulong grossUses);

[DllImport(DLL_FILE_NAME, CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetLicenseKey(StringBuilder licenseKey, int length);
Expand All @@ -179,13 +179,13 @@ public static bool IsWindows()
public static extern int GetLicenseKeyA(StringBuilder licenseKey, int length);

[DllImport(DLL_FILE_NAME, CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetLicenseAllowedActivations(ref uint allowedActivations);
public static extern int GetLicenseAllowedActivations(ref long allowedActivations);

[DllImport(DLL_FILE_NAME, CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetLicenseTotalActivations(ref uint totalActivations);

[DllImport(DLL_FILE_NAME, CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetLicenseAllowedDeactivations(ref uint allowedDeactivations);
public static extern int GetLicenseAllowedDeactivations(ref long allowedDeactivations);

[DllImport(DLL_FILE_NAME, CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetLicenseTotalDeactivations(ref uint totalDeactivations);
Expand Down Expand Up @@ -442,7 +442,7 @@ public static bool IsWindows()
public static extern int SetLicenseCallback_x86(LexActivator.CallbackType callback);

[DllImport(DLL_FILE_NAME_X86, CharSet = CharSet.Unicode, EntryPoint = "SetActivationLeaseDuration", CallingConvention = CallingConvention.Cdecl)]
public static extern int SetActivationLeaseDuration_x86(uint leaseDuration);
public static extern int SetActivationLeaseDuration_x86(long leaseDuration);

[DllImport(DLL_FILE_NAME_X86, CharSet = CharSet.Unicode, EntryPoint = "SetActivationMetadata", CallingConvention = CallingConvention.Cdecl)]
public static extern int SetActivationMetadata_x86(string key, string value);
Expand Down Expand Up @@ -493,19 +493,19 @@ public static bool IsWindows()
public static extern int GetLicenseMetadata_x86(string key, StringBuilder value, int length);

[DllImport(DLL_FILE_NAME_X86, CharSet = CharSet.Unicode, EntryPoint = "GetLicenseMeterAttribute", CallingConvention = CallingConvention.Cdecl)]
public static extern int GetLicenseMeterAttribute_x86(string name, ref uint allowedUses, ref uint totalUses, ref uint grossUses);
public static extern int GetLicenseMeterAttribute_x86(string name, ref long allowedUses, ref ulong totalUses, ref ulong grossUses);

[DllImport(DLL_FILE_NAME_X86, CharSet = CharSet.Unicode, EntryPoint = "GetLicenseKey", CallingConvention = CallingConvention.Cdecl)]
public static extern int GetLicenseKey_x86(StringBuilder licenseKey, int length);

[DllImport(DLL_FILE_NAME_X86, CharSet = CharSet.Unicode, EntryPoint = "GetLicenseAllowedActivations", CallingConvention = CallingConvention.Cdecl)]
public static extern int GetLicenseAllowedActivations_x86(ref uint allowedActivations);
public static extern int GetLicenseAllowedActivations_x86(ref long allowedActivations);

[DllImport(DLL_FILE_NAME_X86, CharSet = CharSet.Unicode, EntryPoint = "GetLicenseTotalActivations", CallingConvention = CallingConvention.Cdecl)]
public static extern int GetLicenseTotalActivations_x86(ref uint totalActivations);

[DllImport(DLL_FILE_NAME_X86, CharSet = CharSet.Unicode, EntryPoint = "GetLicenseAllowedDeactivations", CallingConvention = CallingConvention.Cdecl)]
public static extern int GetLicenseAllowedDeactivations_x86(ref uint allowedDeactivations);
public static extern int GetLicenseAllowedDeactivations_x86(ref long allowedDeactivations);

[DllImport(DLL_FILE_NAME_X86, CharSet = CharSet.Unicode, EntryPoint = "GetLicenseTotalDeactivations", CallingConvention = CallingConvention.Cdecl)]
public static extern int GetLicenseTotalDeactivations_x86(ref uint totalDeactivations);
Expand Down
20 changes: 16 additions & 4 deletions src/Cryptlex.LexActivator/LicenseMeterAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,27 @@ namespace Cryptlex
public class LicenseMeterAttribute
{

/// <summary>
/// The name of the meter attribute.
/// </summary>
public string Name;

public uint AllowedUses;
/// <summary>
/// The allowed uses of the meter attribute. A value of -1 indicates unlimited allowed uses.
/// </summary>
public long AllowedUses;

public uint TotalUses;
/// <summary>
/// The total uses of the meter attribute.
/// </summary>
public ulong TotalUses;

public uint GrossUses;
/// <summary>
/// The gross uses of the meter attribute.
/// </summary>
public ulong GrossUses;

public LicenseMeterAttribute(string name, uint allowedUses, uint totalUses, uint grossUses)
public LicenseMeterAttribute(string name, long allowedUses, ulong totalUses, ulong grossUses)
{
this.Name = name;
this.AllowedUses = allowedUses;
Expand Down