From decfe79015d404bd2a818ef824a7c29c32eeeeb1 Mon Sep 17 00:00:00 2001 From: muneebkq Date: Mon, 8 Jul 2024 16:39:09 +0530 Subject: [PATCH 1/2] feat: add permission flag --- cryptlex/lexfloatclient/__init__.py | 2 +- cryptlex/lexfloatclient/lexfloatclient.py | 27 +++++++++++++++++++ .../lexfloatclient/lexfloatclient_native.py | 4 +++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/cryptlex/lexfloatclient/__init__.py b/cryptlex/lexfloatclient/__init__.py index 2a0e3db..6d85a8c 100644 --- a/cryptlex/lexfloatclient/__init__.py +++ b/cryptlex/lexfloatclient/__init__.py @@ -1 +1 @@ -from cryptlex.lexfloatclient.lexfloatclient import LexFloatClient, LexFloatStatusCodes, LexFloatClientException +from cryptlex.lexfloatclient.lexfloatclient import LexFloatClient, LexFloatStatusCodes, LexFloatClientException, PermissionFlags diff --git a/cryptlex/lexfloatclient/lexfloatclient.py b/cryptlex/lexfloatclient/lexfloatclient.py index 13f2e2c..fa1f5e3 100644 --- a/cryptlex/lexfloatclient/lexfloatclient.py +++ b/cryptlex/lexfloatclient/lexfloatclient.py @@ -5,6 +5,9 @@ callback_list = [] +class PermissionFlags: + LF_USER = 10 + LF_ALL_USERS = 11 class HostLicenseMeterAttribute(object): def __init__(self, name, allowed_uses, total_uses, gross_uses): @@ -278,6 +281,30 @@ def RequestFloatingLicense(): if LexFloatStatusCodes.LF_OK != status: raise LexFloatClientException(status) + @staticmethod + def SetPermissionFlag(flags): + """Sets the permission flags. + + This function must be called on every start of your program after SetHostProductId() + function in case the application allows borrowing of licenses or system wide activation. + + Args: + flags : depending on your application's requirements, choose one of + the following values: LF_USER, LF_ALL_USERS. + + LF_USER: This flag indicates that the application does not require + admin or root permissions to run. + + LF_ALL_USERS: This flag is specifically designed for Windows and should be used + for system-wide activations. + + Raises: + LexFloatClientException + """ + status = LexFloatClientNative.SetPermissionFlag(flags) + if LexFloatStatusCodes.LF_OK != status: + raise LexFloatClientException(status) + @staticmethod def DropFloatingLicense(): """Sends the request to the LexFloatServer to free the license. diff --git a/cryptlex/lexfloatclient/lexfloatclient_native.py b/cryptlex/lexfloatclient/lexfloatclient_native.py index e116d62..baaadd8 100644 --- a/cryptlex/lexfloatclient/lexfloatclient_native.py +++ b/cryptlex/lexfloatclient/lexfloatclient_native.py @@ -163,6 +163,10 @@ def byte_to_string(input): RequestFloatingLicense.argtypes = [] RequestFloatingLicense.restype = c_int +SetPermissionFlag = library.SetPermissionFlag +SetPermissionFlag.argtypes = [c_uint32] +SetPermissionFlag.restype = c_int + DropFloatingLicense = library.DropFloatingLicense DropFloatingLicense.argtypes = [] DropFloatingLicense.restype = c_int From e471bb9fc3652e53b9cdb98e763a33714bc767db Mon Sep 17 00:00:00 2001 From: muneebkq Date: Fri, 2 Aug 2024 12:54:20 +0530 Subject: [PATCH 2/2] refactor: arg name --- cryptlex/lexfloatclient/lexfloatclient.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cryptlex/lexfloatclient/lexfloatclient.py b/cryptlex/lexfloatclient/lexfloatclient.py index fa1f5e3..399b13c 100644 --- a/cryptlex/lexfloatclient/lexfloatclient.py +++ b/cryptlex/lexfloatclient/lexfloatclient.py @@ -282,8 +282,8 @@ def RequestFloatingLicense(): raise LexFloatClientException(status) @staticmethod - def SetPermissionFlag(flags): - """Sets the permission flags. + def SetPermissionFlag(flag): + """Sets the permission flag. This function must be called on every start of your program after SetHostProductId() function in case the application allows borrowing of licenses or system wide activation. @@ -301,7 +301,7 @@ def SetPermissionFlag(flags): Raises: LexFloatClientException """ - status = LexFloatClientNative.SetPermissionFlag(flags) + status = LexFloatClientNative.SetPermissionFlag(flag) if LexFloatStatusCodes.LF_OK != status: raise LexFloatClientException(status)