From 7fe9745a449b818849d1496c8d0372a796df6aad Mon Sep 17 00:00:00 2001 From: Ahmad Kemsan Date: Wed, 7 Aug 2024 16:14:04 +0530 Subject: [PATCH] fix: add missing function --- .../lexfloatclient/LexFloatClient.java | 24 +++++++++++++++++-- .../LexFloatClientException.java | 1 + .../lexfloatclient/LexFloatClientNative.java | 6 +++-- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/lexfloatclient/src/main/java/com/cryptlex/android/lexfloatclient/LexFloatClient.java b/lexfloatclient/src/main/java/com/cryptlex/android/lexfloatclient/LexFloatClient.java index c5b94c7..4081990 100644 --- a/lexfloatclient/src/main/java/com/cryptlex/android/lexfloatclient/LexFloatClient.java +++ b/lexfloatclient/src/main/java/com/cryptlex/android/lexfloatclient/LexFloatClient.java @@ -62,8 +62,8 @@ public static void SetHostProductId(String productId) throws LexFloatClientExcep */ public static void SetPermissionFlag(int flags) throws LexFloatClientException { int status; - status = LexFloatClientNative.SetProductId(flags); - if (LA_OK != status) { + status = LexFloatClientNative.SetPermissionFlag(flags); + if (LF_OK != status) { throw new LexFloatClientException(status); } } @@ -319,6 +319,25 @@ public static int GetHostLicenseExpiryDate() throws LexFloatClientException { throw new LexFloatClientException(status); } } + + /** + * Gets the mode of the floating license (online or offline). + * + * @return mode - Returns the floating license mode. + * @throws LexFloatClientException + * @throws UnsupportedEncodingException + */ + public static String GetFloatingLicenseMode() throws LexFloatClientException, UnsupportedEncodingException { + int status; + + ByteBuffer buffer = ByteBuffer.allocate(256); + status = LexFloatClientNative.GetFloatingLicenseMode(buffer, 256); + if (LF_OK == status) { + return new String(buffer.array(), "UTF-8").trim(); + } + throw new LexFloatClientException(status); + } + /** * Gets the value of the floating client metadata. * @@ -371,6 +390,7 @@ public static void RequestFloatingLicense() throws LexFloatClientException { } /** * Sends the request to lease the license from the LexFloatServer for offline usage. + * The maximum value of lease duration is configured in the config.yml of LexFloatServer. * * @param leaseDuration * diff --git a/lexfloatclient/src/main/java/com/cryptlex/android/lexfloatclient/LexFloatClientException.java b/lexfloatclient/src/main/java/com/cryptlex/android/lexfloatclient/LexFloatClientException.java index 00cbc2c..c7698d5 100644 --- a/lexfloatclient/src/main/java/com/cryptlex/android/lexfloatclient/LexFloatClientException.java +++ b/lexfloatclient/src/main/java/com/cryptlex/android/lexfloatclient/LexFloatClientException.java @@ -281,6 +281,7 @@ public static String getErrorMessage(int errorCode) { /* * CODE: LF_E_SYSTEM_PERMISSION + * * MESSAGE: Insufficient system permissions. */ public static final int LF_E_SYSTEM_PERMISSION = 59; diff --git a/lexfloatclient/src/main/java/com/cryptlex/android/lexfloatclient/LexFloatClientNative.java b/lexfloatclient/src/main/java/com/cryptlex/android/lexfloatclient/LexFloatClientNative.java index 822e374..afc59fd 100644 --- a/lexfloatclient/src/main/java/com/cryptlex/android/lexfloatclient/LexFloatClientNative.java +++ b/lexfloatclient/src/main/java/com/cryptlex/android/lexfloatclient/LexFloatClientNative.java @@ -26,8 +26,6 @@ public interface CallbackType extends Callback { public static native int SetHostProductId(String productId); - public static native int GetHostConfigInternal(ByteBuffer hostconfig, int length); - public static native int SetHostUrl(String hostUrl); public static native int SetFloatingLicenseCallback(CallbackType callback); @@ -38,6 +36,8 @@ public interface CallbackType extends Callback { public static native int GetFloatingClientLibraryVersion(ByteBuffer libraryVersion, int length); + public static native int GetHostConfigInternal(ByteBuffer hostconfig, int length); + public static native int GetHostProductVersionName(ByteBuffer name, int length); public static native int GetHostProductVersionDisplayName(ByteBuffer name, int length); @@ -51,6 +51,8 @@ public interface CallbackType extends Callback { public static native int GetHostLicenseExpiryDate(IntByReference expiryDate); public static native int GetFloatingClientMetadata(String key, ByteBuffer value, int length); + + public static native int GetFloatingLicenseMode(ByteBuffer mode, int length); public static native int GetFloatingClientMeterAttributeUses(String name, IntByReference uses);