Skip to content

Commit a48b5f1

Browse files
authored
Merge pull request #12 from cryptlex/muneeb/set-permission-flag
feat: add permission flag
2 parents a4e5a34 + e471bb9 commit a48b5f1

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

cryptlex/lexfloatclient/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from cryptlex.lexfloatclient.lexfloatclient import LexFloatClient, LexFloatStatusCodes, LexFloatClientException
1+
from cryptlex.lexfloatclient.lexfloatclient import LexFloatClient, LexFloatStatusCodes, LexFloatClientException, PermissionFlags

cryptlex/lexfloatclient/lexfloatclient.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55

66
callback_list = []
77

8+
class PermissionFlags:
9+
LF_USER = 10
10+
LF_ALL_USERS = 11
811

912
class HostLicenseMeterAttribute(object):
1013
def __init__(self, name, allowed_uses, total_uses, gross_uses):
@@ -318,6 +321,30 @@ def RequestFloatingLicense():
318321
if LexFloatStatusCodes.LF_OK != status:
319322
raise LexFloatClientException(status)
320323

324+
@staticmethod
325+
def SetPermissionFlag(flag):
326+
"""Sets the permission flag.
327+
328+
This function must be called on every start of your program after SetHostProductId()
329+
function in case the application allows borrowing of licenses or system wide activation.
330+
331+
Args:
332+
flags : depending on your application's requirements, choose one of
333+
the following values: LF_USER, LF_ALL_USERS.
334+
335+
LF_USER: This flag indicates that the application does not require
336+
admin or root permissions to run.
337+
338+
LF_ALL_USERS: This flag is specifically designed for Windows and should be used
339+
for system-wide activations.
340+
341+
Raises:
342+
LexFloatClientException
343+
"""
344+
status = LexFloatClientNative.SetPermissionFlag(flag)
345+
if LexFloatStatusCodes.LF_OK != status:
346+
raise LexFloatClientException(status)
347+
321348
@staticmethod
322349
def DropFloatingLicense():
323350
"""Sends the request to the LexFloatServer to free the license.

cryptlex/lexfloatclient/lexfloatclient_native.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,10 @@ def byte_to_string(input):
171171
RequestFloatingLicense.argtypes = []
172172
RequestFloatingLicense.restype = c_int
173173

174+
SetPermissionFlag = library.SetPermissionFlag
175+
SetPermissionFlag.argtypes = [c_uint32]
176+
SetPermissionFlag.restype = c_int
177+
174178
DropFloatingLicense = library.DropFloatingLicense
175179
DropFloatingLicense.argtypes = []
176180
DropFloatingLicense.restype = c_int

0 commit comments

Comments
 (0)