diff --git a/cryptlex/lexfloatclient/lexfloatclient.py b/cryptlex/lexfloatclient/lexfloatclient.py index e6c2a6b..e4dd21f 100644 --- a/cryptlex/lexfloatclient/lexfloatclient.py +++ b/cryptlex/lexfloatclient/lexfloatclient.py @@ -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(): @@ -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) diff --git a/cryptlex/lexfloatclient/lexfloatclient_native.py b/cryptlex/lexfloatclient/lexfloatclient_native.py index 0043bbb..4b03eb8 100644 --- a/cryptlex/lexfloatclient/lexfloatclient_native.py +++ b/cryptlex/lexfloatclient/lexfloatclient_native.py @@ -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 @@ -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 = [] diff --git a/cryptlex/lexfloatclient/lexfloatstatus_codes.py b/cryptlex/lexfloatclient/lexfloatstatus_codes.py index 2418b0a..a30a4da 100644 --- a/cryptlex/lexfloatclient/lexfloatstatus_codes.py +++ b/cryptlex/lexfloatclient/lexfloatstatus_codes.py @@ -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