diff --git a/cryptlex/lexfloatclient/lexfloatclient.py b/cryptlex/lexfloatclient/lexfloatclient.py index 0916277..e528ba9 100644 --- a/cryptlex/lexfloatclient/lexfloatclient.py +++ b/cryptlex/lexfloatclient/lexfloatclient.py @@ -13,6 +13,11 @@ def __init__(self, name, allowed_uses, total_uses, gross_uses): self.total_uses = total_uses self.gross_uses = gross_uses +class ProductVersionFeatureFlag(object): + def __init__(self, name, enabled, data): + self.name = name + self.enabled = enabled + self.data = data class LexFloatClient: @staticmethod @@ -96,6 +101,66 @@ def SetFloatingClientMetadata(key, value): if LexFloatStatusCodes.LF_OK != status: raise LexFloatClientException(status) + @staticmethod + def GetProductVersionName(): + """Gets the product version name. + + Raises: + LexFloatClientException + + Returns: + str: name of the product version. + """ + + buffer_size = 256 + buffer = LexFloatClientNative.get_ctype_string_buffer(buffer_size) + status = LexFloatClientNative.GetProductVersionName(buffer,buffer_size) + if status != LexFloatStatusCodes.LF_OK: + raise LexFloatClientException(status) + return LexFloatClientNative.byte_to_string(buffer.value) + + @staticmethod + def GetProductVersionDisplayName(): + """Gets the product version display name. + + Raises: + LexFloatClientException + + Returns: + str: display name of the product version. + """ + + buffer_size = 256 + buffer = LexFloatClientNative.get_ctype_string_buffer(buffer_size) + status = LexFloatClientNative.GetProductVersionDisplayName(buffer,buffer_size) + if status != LexFloatStatusCodes.LF_OK: + raise LexFloatClientException(status) + return LexFloatClientNative.byte_to_string(buffer.value) + + @staticmethod + def GetProductVersionFeatureFlag(name): + """Gets the product version feature flag. + + Args: + name (str): name of the feature flag + + Raises: + LexFloatClientException + + Returns: + ProductVersionFeatureFlag: product version feature flag + """ + cstring_name = LexFloatClientNative.get_ctype_string(name) + enabled = ctypes.c_uint() + buffer_size = 256 + buffer = LexFloatClientNative.get_ctype_string_buffer(buffer_size) + status = LexFloatClientNative.GetProductVersionFeatureFlag(cstring_name, ctypes.byref(enabled), buffer, buffer_size) + if status == LexFloatStatusCodes.LF_OK: + isEnabled = enabled.value > 0 + return ProductVersionFeatureFlag(name, isEnabled, LexFloatClientNative.byte_to_string(buffer.value)) + else: + raise LexFloatClientException(status) + @staticmethod def GetHostLicenseMetadata(key): """Get the value of the license metadata field associated with the diff --git a/cryptlex/lexfloatclient/lexfloatclient_exception.py b/cryptlex/lexfloatclient/lexfloatclient_exception.py index 3f98ac2..d2391eb 100644 --- a/cryptlex/lexfloatclient/lexfloatclient_exception.py +++ b/cryptlex/lexfloatclient/lexfloatclient_exception.py @@ -44,6 +44,10 @@ def get_error_message(code): return 'The meter attribute does not exist.' if code == LexFloatStatusCodes.LF_E_METER_ATTRIBUTE_USES_LIMIT_REACHED: return 'The meter attribute has reached it\'s usage limit.' + if code == LexFloatStatusCodes.LF_E_PRODUCT_VERSION_NOT_LINKED: + return 'No product version is linked with the license.' + if code == LexFloatStatusCodes.LF_E_FEATURE_FLAG_NOT_FOUND: + return 'The product version feature flag does not exist.' if code == LexFloatStatusCodes.LF_E_IP: return 'IP address is not allowed.' if code == LexFloatStatusCodes.LF_E_CLIENT: diff --git a/cryptlex/lexfloatclient/lexfloatclient_native.py b/cryptlex/lexfloatclient/lexfloatclient_native.py index d9758ec..1c7abb3 100644 --- a/cryptlex/lexfloatclient/lexfloatclient_native.py +++ b/cryptlex/lexfloatclient/lexfloatclient_native.py @@ -127,6 +127,18 @@ def byte_to_string(input): SetFloatingClientMetadata.argtypes = [CSTRTYPE, CSTRTYPE] SetFloatingClientMetadata.restype = c_int +GetProductVersionName = library.GetProductVersionName +GetProductVersionName.argtypes = [STRTYPE,c_uint32] +GetProductVersionName.restype = c_int + +GetProductVersionDisplayName = library.GetProductVersionDisplayName +GetProductVersionDisplayName.argtypes = [STRTYPE,c_uint32] +GetProductVersionDisplayName.restype = c_int + +GetProductVersionFeatureFlag = library.GetProductVersionFeatureFlag +GetProductVersionFeatureFlag.argtypes = [CSTRTYPE, POINTER(c_uint32), STRTYPE, c_uint32] +GetProductVersionFeatureFlag.restype = c_int + GetHostLicenseMetadata = library.GetHostLicenseMetadata GetHostLicenseMetadata.argtypes = [CSTRTYPE, STRTYPE, c_uint32] GetHostLicenseMetadata.restype = c_int diff --git a/cryptlex/lexfloatclient/lexfloatstatus_codes.py b/cryptlex/lexfloatclient/lexfloatstatus_codes.py index 1cc36a6..d8bacad 100644 --- a/cryptlex/lexfloatclient/lexfloatstatus_codes.py +++ b/cryptlex/lexfloatclient/lexfloatstatus_codes.py @@ -38,6 +38,10 @@ class LexFloatStatusCodes: LF_E_METER_ATTRIBUTE_USES_LIMIT_REACHED = 56 + LF_E_PRODUCT_VERSION_NOT_LINKED = 57 + + LF_E_FEATURE_FLAG_NOT_FOUND = 58 + LF_E_IP = 60 LF_E_CLIENT = 70