Skip to content

Commit cc88fae

Browse files
authored
Merge pull request #14 from cryptlex/muneeb/request-offline-floating-license
feat: request offline float license
2 parents 467d968 + d0b904d commit cc88fae

File tree

3 files changed

+37
-19
lines changed

3 files changed

+37
-19
lines changed

cryptlex/lexfloatclient/lexfloatclient.py

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,30 @@ def SetFloatingClientMetadata(key, value):
109109
cstring_key, cstring_value)
110110
if LexFloatStatusCodes.LF_OK != status:
111111
raise LexFloatClientException(status)
112+
113+
@staticmethod
114+
def SetPermissionFlag(flag):
115+
"""Sets the permission flag.
116+
117+
This function must be called on every start of your program after SetHostProductId()
118+
function in case the application allows borrowing of licenses or system wide activation.
119+
120+
Args:
121+
flags : depending on your application's requirements, choose one of
122+
the following values: LF_USER, LF_ALL_USERS.
123+
124+
LF_USER: This flag indicates that the application does not require
125+
admin or root permissions to run.
126+
127+
LF_ALL_USERS: This flag is specifically designed for Windows and should be used
128+
for system-wide activations.
129+
130+
Raises:
131+
LexFloatClientException
132+
"""
133+
status = LexFloatClientNative.SetPermissionFlag(flag)
134+
if LexFloatStatusCodes.LF_OK != status:
135+
raise LexFloatClientException(status)
112136

113137
@staticmethod
114138
def GetFloatingClientLibraryVersion():
@@ -351,26 +375,16 @@ def RequestFloatingLicense():
351375
raise LexFloatClientException(status)
352376

353377
@staticmethod
354-
def SetPermissionFlag(flag):
355-
"""Sets the permission flag.
356-
357-
This function must be called on every start of your program after SetHostProductId()
358-
function in case the application allows borrowing of licenses or system wide activation.
359-
378+
def RequestOfflineFloatingLicense(lease_duration):
379+
"""Sends the request to lease the license from the LexFloatServer for offline usage.
380+
360381
Args:
361-
flags : depending on your application's requirements, choose one of
362-
the following values: LF_USER, LF_ALL_USERS.
363-
364-
LF_USER: This flag indicates that the application does not require
365-
admin or root permissions to run.
366-
367-
LF_ALL_USERS: This flag is specifically designed for Windows and should be used
368-
for system-wide activations.
382+
leaseDuration (int): seconds for which the lease should be obtained.
369383
370384
Raises:
371385
LexFloatClientException
372386
"""
373-
status = LexFloatClientNative.SetPermissionFlag(flag)
387+
status = LexFloatClientNative.RequestOfflineFloatingLicense(lease_duration)
374388
if LexFloatStatusCodes.LF_OK != status:
375389
raise LexFloatClientException(status)
376390

cryptlex/lexfloatclient/lexfloatclient_native.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ def byte_to_string(input):
127127
SetFloatingClientMetadata.argtypes = [CSTRTYPE, CSTRTYPE]
128128
SetFloatingClientMetadata.restype = c_int
129129

130+
SetPermissionFlag = library.SetPermissionFlag
131+
SetPermissionFlag.argtypes = [c_uint32]
132+
SetPermissionFlag.restype = c_int
133+
130134
GetFloatingClientLibraryVersion = library.GetFloatingClientLibraryVersion
131135
GetFloatingClientLibraryVersion.argtypes = [STRTYPE, c_uint32]
132136
GetFloatingClientLibraryVersion.restype = c_int
@@ -175,9 +179,9 @@ def byte_to_string(input):
175179
RequestFloatingLicense.argtypes = []
176180
RequestFloatingLicense.restype = c_int
177181

178-
SetPermissionFlag = library.SetPermissionFlag
179-
SetPermissionFlag.argtypes = [c_uint32]
180-
SetPermissionFlag.restype = c_int
182+
RequestOfflineFloatingLicense = library.RequestOfflineFloatingLicense
183+
RequestOfflineFloatingLicense.argtypes = [c_uint32]
184+
RequestOfflineFloatingLicense.restype = c_int
181185

182186
DropFloatingLicense = library.DropFloatingLicense
183187
DropFloatingLicense.argtypes = []

cryptlex/lexfloatclient/lexfloatstatus_codes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class LexFloatStatusCodes:
4343
LF_E_FEATURE_FLAG_NOT_FOUND = 58
4444

4545
LF_E_SYSTEM_PERMISSION = 59
46-
46+
4747
LF_E_IP = 60
4848

4949
LF_E_INVALID_PERMISSION_FLAG = 61

0 commit comments

Comments
 (0)