diff --git a/lexfloatclient/build.gradle b/lexfloatclient/build.gradle index 2a0c0a8..25494e5 100644 --- a/lexfloatclient/build.gradle +++ b/lexfloatclient/build.gradle @@ -35,6 +35,7 @@ android { dependencies { implementation 'net.java.dev.jna:jna:5.8.0' + implementation 'com.fasterxml.jackson.core:jackson-databind:2.14.2' } publishing { diff --git a/lexfloatclient/src/main/java/com/cryptlex/android/lexfloatclient/HostConfig.java b/lexfloatclient/src/main/java/com/cryptlex/android/lexfloatclient/HostConfig.java new file mode 100644 index 0000000..d013e16 --- /dev/null +++ b/lexfloatclient/src/main/java/com/cryptlex/android/lexfloatclient/HostConfig.java @@ -0,0 +1,3 @@ +public class HostConfig { + public String maxOfflineLeaseDuration; +} 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 8f140bd..fdc993a 100644 --- a/lexfloatclient/src/main/java/com/cryptlex/android/lexfloatclient/LexFloatClient.java +++ b/lexfloatclient/src/main/java/com/cryptlex/android/lexfloatclient/LexFloatClient.java @@ -5,6 +5,8 @@ import java.nio.CharBuffer; import java.io.UnsupportedEncodingException; import com.sun.jna.ptr.IntByReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.core.JsonProcessingException; import java.util.ArrayList; import java.util.List; @@ -123,7 +125,37 @@ public static String GetFloatingClientLibraryVersion() throws LexFloatClientExce return new String(buffer.array(), "UTF-8").trim(); } throw new LexFloatClientException(status); - } + } + + /** + * Gets the host configuration. + * + * @return Returns host configuration. + * @throws LexFloatClientException + * @throws UnsupportedEncodingException + */ + + public static HostConfig GetHostConfig() throws LexFloatClientException, UnsupportedEncodingException { + int status; + int bufferSize = 1024; + + ByteBuffer buffer = ByteBuffer.allocate(bufferSize); + status = LexFloatClientNative.GetHostConfigInternal(buffer, bufferSize); + if (LA_OK == status) { + String hostConfigJson = new String(buffer.array(), "UTF-8").trim(); + if (!hostConfigJson.isEmpty()) { + HostConfig hostConfig = null; + ObjectMapper objectMapper = new ObjectMapper(); + try { + hostConfig = objectMapper.readValue(hostConfigJson, HostConfig.class); + } catch (JsonProcessingException e) {} + return hostConfig; + } else { + return null; + } + } + throw new LexFloatClientException(status); + } /** * Gets the product version name. 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 dcabc29..2c5240f 100644 --- a/lexfloatclient/src/main/java/com/cryptlex/android/lexfloatclient/LexFloatClientNative.java +++ b/lexfloatclient/src/main/java/com/cryptlex/android/lexfloatclient/LexFloatClientNative.java @@ -23,6 +23,8 @@ 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);