Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add permission flag #12

Merged
merged 2 commits into from
Aug 6, 2024
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
2 changes: 1 addition & 1 deletion cryptlex/lexfloatclient/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from cryptlex.lexfloatclient.lexfloatclient import LexFloatClient, LexFloatStatusCodes, LexFloatClientException
from cryptlex.lexfloatclient.lexfloatclient import LexFloatClient, LexFloatStatusCodes, LexFloatClientException, PermissionFlags
27 changes: 27 additions & 0 deletions cryptlex/lexfloatclient/lexfloatclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -278,6 +281,30 @@ def RequestFloatingLicense():
if LexFloatStatusCodes.LF_OK != status:
raise LexFloatClientException(status)

@staticmethod
def SetPermissionFlag(flag):
"""Sets the permission flag.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@muneebkq Sets the permission flag.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

changed to 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 DropFloatingLicense():
"""Sends the request to the LexFloatServer to free the license.
Expand Down
4 changes: 4 additions & 0 deletions cryptlex/lexfloatclient/lexfloatclient_native.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down