Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

borrowing develop #18

Merged
merged 30 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
e6f75fe
feat: add request offline floating license
muneebkq Jul 9, 2024
743ee84
feat: add GetFloatingClientLeaseExpiryDate
muneebkq Jul 9, 2024
1fc8583
feat: add get-floating-license-mode
muneebkq Jul 9, 2024
661e16d
feat: add set-permission-flag function
muneebkq Jul 9, 2024
0177a33
feta: add floating client metadata
muneebkq Jul 12, 2024
2434b8f
refactor: jsdoc
muneebkq Jul 30, 2024
22dbc64
refactor: jsdoc
muneebkq Jul 30, 2024
91864d0
refactor: jsdoc
muneebkq Jul 30, 2024
279c2b2
feat: add status code
muneebkq Jul 31, 2024
3bd2ed6
Merge pull request #13 from cryptlex/muneeb/get-floating-lease-expiry
ahmad-kemsan Aug 1, 2024
2d57beb
Merge branch 'borrowing-develop' into muneeb/get-floating-license-mode
ahmad-kemsan Aug 1, 2024
e7bcb93
refactor: error code
muneebkq Aug 2, 2024
d91a0cc
refactor: jsdoc
muneebkq Aug 2, 2024
d1eeeee
fix: remove LA values
muneebkq Aug 2, 2024
6fccba7
refactor: jsdocs
muneebkq Aug 2, 2024
f753ae2
refactor: jsdoc
muneebkq Aug 2, 2024
a6a9331
feat: add status code to header file
muneebkq Aug 2, 2024
b3b8c19
Merge branch 'borrowing-develop' into muneeb/request-offline-floating…
ahmad-kemsan Aug 6, 2024
0d8893d
Merge pull request #14 from cryptlex/muneeb/request-offline-floating-…
ahmad-kemsan Aug 6, 2024
75dcdc2
Merge branch 'borrowing-develop' into muneeb/get-floating-license-mode
ahmad-kemsan Aug 6, 2024
913664b
Merge pull request #12 from cryptlex/muneeb/get-floating-license-mode
ahmad-kemsan Aug 6, 2024
1c0f2f7
Merge branch 'borrowing-develop' into muneeb/set-permission-flags
ahmad-kemsan Aug 6, 2024
eea8ef6
Merge pull request #11 from cryptlex/muneeb/set-permission-flags
ahmad-kemsan Aug 6, 2024
8d8b7de
feat: add LF_E_PROXY_NOT_TRUSTED
muneebkq Aug 6, 2024
1dc0f43
Merge branch 'borrowing-develop' into muneeb/floating-client-metatdata
ahmad-kemsan Aug 6, 2024
ee23b4d
Merge pull request #10 from cryptlex/muneeb/floating-client-metatdata
ahmad-kemsan Aug 6, 2024
3679f3a
feat: add error code
muneebkq Aug 6, 2024
46638a3
Merge pull request #16 from cryptlex/muneeb/status-code
ahmad-kemsan Aug 6, 2024
023ffb7
feat: add getHostConfig
muneebkq Aug 6, 2024
ad913c4
Merge pull request #17 from cryptlex/muneeb/gethostconfig2
ahmad-kemsan Aug 6, 2024
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
160 changes: 150 additions & 10 deletions lexfloatclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,22 @@ void floatingLicenseCallbackCgoGateway(int status);
*/
import "C"
import (
"encoding/json"
"strings"
"unsafe"
)


type HostConfig struct {
MaxOfflineLeaseDuration int `json:"maxOfflineLeaseDuration"`
}


type callbackType func(int)

const (
LA_USER uint = 0
LA_SYSTEM uint = 1
LA_IN_MEMORY uint = 2
LF_USER uint = 10
LF_ALL_USERS uint = 11
)

var floatingLicenseCallbackFunction callbackType
Expand All @@ -32,6 +39,31 @@ func floatingLicenseCallbackWrapper(status int) {
floatingLicenseCallbackFunction(status)
}
}
/*
FUNCTION: SetPermissionFlag()

PURPOSE: Sets the permission flag.

This function must be called on every start of your program after SetHostProductId()
function in case the application allows borrowing of licenses or system wide activation.

PARAMETERS:
* flags - depending on your application's requirements, choose one of
the following values: LF_USER, LF_ALL_USERS.

- LF_USER: This flag indicates that the application does not require
admin or root permissions to run.

- LF_ALL_USERS: This flag is specifically designed for Windows and should be used
for system-wide activations.

RETURN CODES: LF_OK, LF_E_PRODUCT_ID
*/
func SetPermissionFlag(flags uint) int {
cFlags := (C.uint)(flags)
status := C.SetPermissionFlag(cFlags)
return int(status)
}

/*
FUNCTION: SetHostProductId()
Expand All @@ -50,6 +82,7 @@ func SetHostProductId(productId string) int {
freeCString(cProductId)
return int(status)
}

/*
FUNCTION: SetHostUrl()

Expand Down Expand Up @@ -125,14 +158,14 @@ func SetFloatingClientMetadata(key string, value string) int {
PARAMETERS:
* libraryVersion - pointer to a buffer that receives the value of the string
* length - size of the buffer pointed to by the libraryVersion parameter

RETURN CODES: LF_OK, LF_E_BUFFER_SIZE
*/
func GetFloatingClientLibraryVersion(libraryVersion *string) int {
var cLibraryVersion = getCArray()
status := C.GetFloatingClientLibraryVersion(&cLibraryVersion[0], maxCArrayLength)
*libraryVersion = ctoGoString(&cLibraryVersion[0])
return int(status)
var cLibraryVersion = getCArray()
status := C.GetFloatingClientLibraryVersion(&cLibraryVersion[0], maxCArrayLength)
*libraryVersion = ctoGoString(&cLibraryVersion[0])
return int(status)
}

/*
Expand Down Expand Up @@ -193,7 +226,7 @@ func GetHostProductVersionFeatureFlag(name string, enabled *bool, data *string)
*enabled = cEnabled > 0
*data = ctoGoString(&cData[0])
return int(status)
}
}

/*
FUNCTION: GetHostLicenseMetadata()
Expand Down Expand Up @@ -242,6 +275,7 @@ func GetHostLicenseMeterAttribute(name string, allowedUses *uint, totalUses *uin
freeCString(cName)
return int(status)
}

/*
FUNCTION: GetHostLicenseExpiryDate()

Expand All @@ -258,6 +292,7 @@ func GetHostLicenseExpiryDate(expiryDate *uint) int {
*expiryDate = uint(cExpiryDate)
return int(status)
}

/*
FUNCTION: GetFloatingClientMeterAttributeUses()

Expand All @@ -277,6 +312,29 @@ func GetFloatingClientMeterAttributeUses(name string, uses *uint) int {
freeCString(cName)
return int(status)
}

/*
FUNCTION: GetFloatingClientMetadata()

PURPOSE: Gets the value of the floating client metadata.

PARAMETERS:
* key - key of the metadata field whose value you want to retrieve
* value - pointer to a buffer that receives the value of the string

RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_BUFFER_SIZE,
LF_E_METADATA_KEY_NOT_FOUND
*/
func GetFloatingClientMetadata(key string, value *string) int {
cKey := goToCString(key)
var cValue = getCArray()
status := C.GetFloatingClientMetadata(cKey, &cValue[0], maxCArrayLength)
*value = ctoGoString(&cValue[0])
freeCString(cKey)
return int(status)

}

/*
FUNCTION: RequestFloatingLicense()

Expand All @@ -292,6 +350,23 @@ func RequestFloatingLicense() int {
return int(status)
}

/*
FUNCTION: GetFloatingClientLeaseExpiryDate()

PURPOSE: Gets the lease expiry date timestamp of the floating client.

PARAMETERS:
* leaseExpiryDate - pointer to the integer that receives the value

RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE
*/
func GetFloatingClientLeaseExpiryDate(leaseExpiryDate *uint) int {
var cLeaseExpiryDate C.uint
status := C.GetFloatingClientLeaseExpiryDate(&cLeaseExpiryDate)
*leaseExpiryDate = uint(cLeaseExpiryDate)
return int(status)
}

/*
FUNCTION: DropFloatingLicense()

Expand Down Expand Up @@ -322,6 +397,72 @@ func HasFloatingLicense() int {
return int(status)
}

/*
FUNCTION: GetHostConfig()

PURPOSE: Gets the host configuration.

This function sends a network request to LexFloatServer to get the configuration details.

PARAMETERS:
* hostConfig - pointer to a buffer that receives the value of the string
* length - size of the buffer pointed to by the hostConfigPtr parameter

RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_HOST_URL, LF_E_BUFFER_SIZE
LF_E_INET, LF_E_CLIENT, LF_E_IP, LF_E_SERVER
*/
func GetHostConfig(hostConfig *HostConfig) int {
var cHostConfig = getCArray()
hostConfigJson := ""
status := C.GetHostConfigInternal(&cHostConfig[0], maxCArrayLength)
hostConfigJson = strings.TrimRight(ctoGoString(&cHostConfig[0]), "\x00")
if hostConfigJson != "" {
config := []byte(hostConfigJson)
json.Unmarshal(config, hostConfig)
}
return int(status)
}

/*

FUNCTION: GetFloatinglicenseMode()

PURPOSE: Gets the mode of the floating license (online or offline).

PARAMETERS:
* mode - pointer to a buffer that receives the value of the string
* length - size of the buffer pointed to by the value parameter

RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_BUFFER_SIZE
*/
func GetFloatingLicenseMode(mode *string) int {
var cMode = getCArray()
status := C.GetFloatingLicenseMode(&cMode[0], maxCArrayLength)
*mode= ctoGoString(&cMode[0])
return int(status)
}

/*
FUNCTION: RequestOfflineFloatingLicense()

PURPOSE: 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

PARAMETERS:
* leaseDuration - value of the lease duration.

RETURN CODES: LF_OK, LF_FAIL, LF_E_PRODUCT_ID, LF_E_LICENSE_EXISTS, LF_E_HOST_URL,
LF_E_LICENSE_LIMIT_REACHED, LF_E_INET, LF_E_TIME, LF_E_CLIENT, LF_E_IP, LF_E_SERVER,
LF_E_SERVER_LICENSE_NOT_ACTIVATED, LF_E_SERVER_TIME_MODIFIED, LF_E_SERVER_LICENSE_SUSPENDED,
LF_E_SERVER_LICENSE_GRACE_PERIOD_OVER, LF_E_SERVER_LICENSE_EXPIRED, LF_E_WMIC, LF_E_SYSTEM_PERMISSION
*/
func RequestOfflineFloatingLicense(leaseDuration uint) int {
cLeaseDuration := (C.uint)(leaseDuration)
status := C.RequestOfflineFloatingLicense(cLeaseDuration)
return int(status)
}

/*
FUNCTION: IncrementFloatingClientMeterAttributeUses()

Expand All @@ -335,7 +476,6 @@ func HasFloatingLicense() int {
LF_E_INET, LF_E_LICENSE_NOT_FOUND, LF_E_CLIENT, LF_E_IP, LF_E_SERVER, LF_E_METER_ATTRIBUTE_USES_LIMIT_REACHED,
LF_E_SERVER_LICENSE_NOT_ACTIVATED, LF_E_SERVER_TIME_MODIFIED, LF_E_SERVER_LICENSE_SUSPENDED,
LF_E_SERVER_LICENSE_GRACE_PERIOD_OVER, LF_E_SERVER_LICENSE_EXPIRED

*/
func IncrementFloatingClientMeterAttributeUses(name string, increment uint) int {
cName := goToCString(name)
Expand Down
94 changes: 94 additions & 0 deletions lexfloatclient/LexFloatClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,28 @@
#endif
typedef void (LF_CC *CallbackType)(uint32_t);

/*
FUNCTION: SetPermissionFlag()

PURPOSE: Sets the permission flag.

This function must be called on every start of your program after SetHostProductId()
function in case the application allows borrowing of licenses or system wide activation.

PARAMETERS:
* flags - depending on your application's requirements, choose one of
the following values: LF_USER, LF_ALL_USERS.

- LF_USER: This flag indicates that the application does not require
admin or root permissions to run.

- LF_ALL_USERS: This flag is specifically designed for Windows and should be used
for system-wide activations.

RETURN CODES: LF_OK, LF_E_PRODUCT_ID
*/
LEXFLOATCLIENT_API int LF_CC SetPermissionFlag(uint32_t flags);

/*
FUNCTION: SetHostProductId()

Expand Down Expand Up @@ -124,6 +146,21 @@ LEXFLOATCLIENT_API int LF_CC SetFloatingLicenseCallback(CallbackType callback);
*/
LEXFLOATCLIENT_API int LF_CC SetFloatingClientMetadata(CSTRTYPE key, CSTRTYPE value);

/*
FUNCTION: GetHostConfigInternal()

PURPOSE: Gets the host configuration.
This function sends a network request to LexFloatServer to get the configuration details.

PARAMETERS:
* hostConfig - pointer to a buffer that receives the value of the string
* length - size of the buffer pointed to by the hostConfigPtr parameter

RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_HOST_URL, LF_E_BUFFER_SIZE
LF_E_INET, LF_E_CLIENT, LF_E_IP, LF_E_SERVER
*/
LEXFLOATCLIENT_API int LF_CC GetHostConfigInternal(STRTYPE hostConfig, uint32_t length);

/*
FUNCTION: GetFloatingClientLibraryVersion()

Expand Down Expand Up @@ -233,6 +270,21 @@ LEXFLOATCLIENT_API int LF_CC GetHostLicenseExpiryDate(uint32_t *expiryDate);
*/
LEXFLOATCLIENT_API int LF_CC GetFloatingClientMeterAttributeUses(CSTRTYPE name, uint32_t *uses);

/*
FUNCTION: GetFloatingClientMetadata()

PURPOSE: Gets the value of the floating client metadata.

PARAMETERS:
* key - key of the metadata field whose value you want to retrieve
* value - pointer to a buffer that receives the value of the string
* length - size of the buffer pointed to by the value parameter

RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_BUFFER_SIZE,
LF_E_METADATA_KEY_NOT_FOUND
*/
LEXFLOATCLIENT_API int LF_CC GetFloatingClientMetadata(CSTRTYPE key, STRTYPE value, uint32_t length);

/*
FUNCTION: RequestFloatingLicense()

Expand Down Expand Up @@ -269,6 +321,48 @@ LEXFLOATCLIENT_API int LF_CC DropFloatingLicense();
*/
LEXFLOATCLIENT_API int LF_CC HasFloatingLicense();

/*
FUNCTION: GetFloatinglicenseMode()

PURPOSE: Gets the mode of the floating license (online or offline).

PARAMETERS:
* modePtr - pointer to a buffer that receives the value of the string
* length - size of the buffer pointed to by the value parameter

RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_BUFFER_SIZE
*/
LEXFLOATCLIENT_API int LF_CC GetFloatingLicenseMode(STRTYPE modePtr, uint32_t length);

/*
FUNCTION: RequestOfflineFloatingLicense()

PURPOSE: 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

PARAMETERS:
* leaseDuration - value of the lease duration.

RETURN CODES: LF_OK, LF_FAIL, LF_E_PRODUCT_ID, LF_E_LICENSE_EXISTS, LF_E_HOST_URL,
LF_E_LICENSE_LIMIT_REACHED, LF_E_INET, LF_E_TIME, LF_E_CLIENT, LF_E_IP, LF_E_SERVER,
LF_E_SERVER_LICENSE_NOT_ACTIVATED, LF_E_SERVER_TIME_MODIFIED, LF_E_SERVER_LICENSE_SUSPENDED,
LF_E_SERVER_LICENSE_GRACE_PERIOD_OVER, LF_E_SERVER_LICENSE_EXPIRED, LF_E_WMIC, LF_E_SYSTEM_PERMISSION
*/
LEXFLOATCLIENT_API int LF_CC RequestOfflineFloatingLicense(uint32_t leaseDuration);

/*
FUNCTION: GetFloatingClientLeaseExpiryDate()

PURPOSE: Gets the lease expiry date timestamp of the floating client.

PARAMETERS:
* leaseExpiryDate - pointer to the integer that receives the value

RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE
*/
LEXFLOATCLIENT_API int LF_CC GetFloatingClientLeaseExpiryDate(uint32_t *leaseExpiryDate);

/*
FUNCTION: IncrementFloatingClientMeterAttributeUses()

Expand Down
Loading