Skip to content

Commit

Permalink
Merge pull request #34 from cryptlex/ahmad/unlimited-implementation
Browse files Browse the repository at this point in the history
feat: unlimited implementation
  • Loading branch information
adnan-kamili authored Jul 31, 2024
2 parents ac6be09 + 7ac1e61 commit eb79161
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 20 deletions.
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

0 comments on commit eb79161

Please sign in to comment.