Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,27 @@

public class HostLicenseMeterAttribute {

/**
* The name of the meter attribute.
*/
public String name;

public int allowedUses;
/**
* The allowed uses of the meter attribute. A value of -1 indicates unlimited allowed uses.
*/
public long allowedUses;

public int totalUses;
/**
* The total uses of the meter attribute.
*/
public long totalUses;

public int grossUses;
/**
* The gross uses of the meter attribute.
*/
public long grossUses;

public HostLicenseMeterAttribute(String name, int allowedUses, int totalUses, int grossUses) {
public HostLicenseMeterAttribute(String name, long allowedUses, long totalUses, long grossUses) {
this.name = name;
this.allowedUses = allowedUses;
this.totalUses = totalUses;
Expand Down
16 changes: 11 additions & 5 deletions src/main/java/com/cryptlex/lexfloatclient/LexFloatClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import java.nio.CharBuffer;
import java.io.UnsupportedEncodingException;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.LongByReference;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;

Expand All @@ -24,6 +26,10 @@ public class LexFloatClient {
*/
public static final int LF_FAIL = 1;

private static long toUnsignedLong(long value) {
return BigInteger.valueOf(value).and(BigInteger.valueOf(0xFFFFFFFFFFFFFFFFL)).longValue();
}

/**
* Sets the product id of your application
*
Expand Down Expand Up @@ -257,19 +263,19 @@ public static String GetHostLicenseMetadata(String key) throws LexFloatClientExc
*/
public static HostLicenseMeterAttribute GetHostLicenseMeterAttribute(String name) throws LexFloatClientException, UnsupportedEncodingException {
int status;
IntByReference allowedUses = new IntByReference(0);
IntByReference totalUses = new IntByReference(0);
IntByReference grossUses = new IntByReference(0);
LongByReference allowedUses = new LongByReference(0);
LongByReference totalUses = new LongByReference(0);
LongByReference grossUses = new LongByReference(0);

if (Platform.isWindows()) {
status = LexFloatClientNative.GetHostLicenseMeterAttribute(new WString(name), allowedUses, totalUses, grossUses);
if (LF_OK == status) {
return new HostLicenseMeterAttribute(name, allowedUses.getValue(), totalUses.getValue(), grossUses.getValue());
return new HostLicenseMeterAttribute(name, allowedUses.getValue(), toUnsignedLong(totalUses.getValue()), toUnsignedLong(grossUses.getValue()));
}
} else {
status = LexFloatClientNative.GetHostLicenseMeterAttribute(name, allowedUses, totalUses, grossUses);
if (LF_OK == status) {
return new HostLicenseMeterAttribute(name, allowedUses.getValue(), totalUses.getValue(), grossUses.getValue());
return new HostLicenseMeterAttribute(name, allowedUses.getValue(), toUnsignedLong(totalUses.getValue()), toUnsignedLong(grossUses.getValue()));
}
}
throw new LexFloatClientException(status);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.nio.CharBuffer;
import java.nio.ByteBuffer;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.LongByReference;
import com.sun.jna.Callback;
import java.io.File;

Expand Down Expand Up @@ -55,9 +56,9 @@ public interface CallbackType extends Callback {

public static native int GetHostLicenseMetadata(WString key, CharBuffer value, int length);

public static native int GetHostLicenseMeterAttribute(String name, IntByReference allowedUses, IntByReference totalUses, IntByReference grossUses);
public static native int GetHostLicenseMeterAttribute(String name, LongByReference allowedUses, LongByReference totalUses, LongByReference grossUses);

public static native int GetHostLicenseMeterAttribute(WString name, IntByReference allowedUses, IntByReference totalUses, IntByReference grossUses);
public static native int GetHostLicenseMeterAttribute(WString name, LongByReference allowedUses, LongByReference totalUses, LongByReference grossUses);

public static native int GetHostLicenseExpiryDate(IntByReference expiryDate);

Expand Down