Skip to content
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
44 changes: 29 additions & 15 deletions cryptlex/lexfloatclient/lexfloatclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,30 @@ def SetFloatingClientMetadata(key, value):
cstring_key, cstring_value)
if LexFloatStatusCodes.LF_OK != status:
raise LexFloatClientException(status)

@staticmethod
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.

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(flag)
if LexFloatStatusCodes.LF_OK != status:
raise LexFloatClientException(status)

@staticmethod
def GetFloatingClientLibraryVersion():
Expand Down Expand Up @@ -351,26 +375,16 @@ def RequestFloatingLicense():
raise LexFloatClientException(status)

@staticmethod
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.

def RequestOfflineFloatingLicense(lease_duration):
"""Sends the request to lease the license from the LexFloatServer for offline usage.

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.
leaseDuration (int): seconds for which the lease should be obtained.

Raises:
LexFloatClientException
"""
status = LexFloatClientNative.SetPermissionFlag(flag)
status = LexFloatClientNative.RequestOfflineFloatingLicense(lease_duration)
if LexFloatStatusCodes.LF_OK != status:
raise LexFloatClientException(status)

Expand Down
10 changes: 7 additions & 3 deletions cryptlex/lexfloatclient/lexfloatclient_native.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ def byte_to_string(input):
SetFloatingClientMetadata.argtypes = [CSTRTYPE, CSTRTYPE]
SetFloatingClientMetadata.restype = c_int

SetPermissionFlag = library.SetPermissionFlag
SetPermissionFlag.argtypes = [c_uint32]
SetPermissionFlag.restype = c_int

GetFloatingClientLibraryVersion = library.GetFloatingClientLibraryVersion
GetFloatingClientLibraryVersion.argtypes = [STRTYPE, c_uint32]
GetFloatingClientLibraryVersion.restype = c_int
Expand Down Expand Up @@ -175,9 +179,9 @@ def byte_to_string(input):
RequestFloatingLicense.argtypes = []
RequestFloatingLicense.restype = c_int

SetPermissionFlag = library.SetPermissionFlag
SetPermissionFlag.argtypes = [c_uint32]
SetPermissionFlag.restype = c_int
RequestOfflineFloatingLicense = library.RequestOfflineFloatingLicense
RequestOfflineFloatingLicense.argtypes = [c_uint32]
RequestOfflineFloatingLicense.restype = c_int

DropFloatingLicense = library.DropFloatingLicense
DropFloatingLicense.argtypes = []
Expand Down
2 changes: 1 addition & 1 deletion cryptlex/lexfloatclient/lexfloatstatus_codes.py
Copy link
Contributor

@ahmad-kemsan ahmad-kemsan Aug 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@muneebkq Why these formatting changes? Plus error codes are not matched with the exceptions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This format is followed in every other function.

Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class LexFloatStatusCodes:
LF_E_FEATURE_FLAG_NOT_FOUND = 58

LF_E_SYSTEM_PERMISSION = 59

LF_E_IP = 60

LF_E_INVALID_PERMISSION_FLAG = 61
Expand Down