Skip to content

Commit 34ba58a

Browse files
authored
Merge pull request #22 from cryptlex/ahmad/fix-borrowing
fix: add missing function
2 parents 562483d + 7fe9745 commit 34ba58a

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

lexfloatclient/src/main/java/com/cryptlex/android/lexfloatclient/LexFloatClient.java

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ public static void SetHostProductId(String productId) throws LexFloatClientExcep
6262
*/
6363
public static void SetPermissionFlag(int flags) throws LexFloatClientException {
6464
int status;
65-
status = LexFloatClientNative.SetProductId(flags);
66-
if (LA_OK != status) {
65+
status = LexFloatClientNative.SetPermissionFlag(flags);
66+
if (LF_OK != status) {
6767
throw new LexFloatClientException(status);
6868
}
6969
}
@@ -319,6 +319,25 @@ public static int GetHostLicenseExpiryDate() throws LexFloatClientException {
319319
throw new LexFloatClientException(status);
320320
}
321321
}
322+
323+
/**
324+
* Gets the mode of the floating license (online or offline).
325+
*
326+
* @return mode - Returns the floating license mode.
327+
* @throws LexFloatClientException
328+
* @throws UnsupportedEncodingException
329+
*/
330+
public static String GetFloatingLicenseMode() throws LexFloatClientException, UnsupportedEncodingException {
331+
int status;
332+
333+
ByteBuffer buffer = ByteBuffer.allocate(256);
334+
status = LexFloatClientNative.GetFloatingLicenseMode(buffer, 256);
335+
if (LF_OK == status) {
336+
return new String(buffer.array(), "UTF-8").trim();
337+
}
338+
throw new LexFloatClientException(status);
339+
}
340+
322341
/**
323342
* Gets the value of the floating client metadata.
324343
*
@@ -371,6 +390,7 @@ public static void RequestFloatingLicense() throws LexFloatClientException {
371390
}
372391
/**
373392
* Sends the request to lease the license from the LexFloatServer for offline usage.
393+
* The maximum value of lease duration is configured in the config.yml of LexFloatServer.
374394
*
375395
* @param leaseDuration
376396
*

lexfloatclient/src/main/java/com/cryptlex/android/lexfloatclient/LexFloatClientException.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ public static String getErrorMessage(int errorCode) {
281281

282282
/*
283283
* CODE: LF_E_SYSTEM_PERMISSION
284+
*
284285
* MESSAGE: Insufficient system permissions.
285286
*/
286287
public static final int LF_E_SYSTEM_PERMISSION = 59;

lexfloatclient/src/main/java/com/cryptlex/android/lexfloatclient/LexFloatClientNative.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ public interface CallbackType extends Callback {
2626

2727
public static native int SetHostProductId(String productId);
2828

29-
public static native int GetHostConfigInternal(ByteBuffer hostconfig, int length);
30-
3129
public static native int SetHostUrl(String hostUrl);
3230

3331
public static native int SetFloatingLicenseCallback(CallbackType callback);
@@ -38,6 +36,8 @@ public interface CallbackType extends Callback {
3836

3937
public static native int GetFloatingClientLibraryVersion(ByteBuffer libraryVersion, int length);
4038

39+
public static native int GetHostConfigInternal(ByteBuffer hostconfig, int length);
40+
4141
public static native int GetHostProductVersionName(ByteBuffer name, int length);
4242

4343
public static native int GetHostProductVersionDisplayName(ByteBuffer name, int length);
@@ -51,6 +51,8 @@ public interface CallbackType extends Callback {
5151
public static native int GetHostLicenseExpiryDate(IntByReference expiryDate);
5252

5353
public static native int GetFloatingClientMetadata(String key, ByteBuffer value, int length);
54+
55+
public static native int GetFloatingLicenseMode(ByteBuffer mode, int length);
5456

5557
public static native int GetFloatingClientMeterAttributeUses(String name, IntByReference uses);
5658

0 commit comments

Comments
 (0)