From e6f75fe52c0726d2604be04fed12766b64e44e31 Mon Sep 17 00:00:00 2001 From: muneebkq Date: Tue, 9 Jul 2024 13:20:48 +0530 Subject: [PATCH 01/18] feat: add request offline floating license --- lexfloatclient.go | 16 ++++++++++++++++ lexfloatclient/LexFloatClient.h | 12 ++++++++++++ 2 files changed, 28 insertions(+) diff --git a/lexfloatclient.go b/lexfloatclient.go index 0862ca6..713d597 100644 --- a/lexfloatclient.go +++ b/lexfloatclient.go @@ -322,6 +322,22 @@ func HasFloatingLicense() int { return int(status) } +/* + FUNCTION: RequestOfflineFloatingLicense() + + PURPOSE: Sends the request to lease the license from the LexFloatServer for offline usage. + + 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() diff --git a/lexfloatclient/LexFloatClient.h b/lexfloatclient/LexFloatClient.h index 619e290..556589a 100644 --- a/lexfloatclient/LexFloatClient.h +++ b/lexfloatclient/LexFloatClient.h @@ -269,6 +269,18 @@ LEXFLOATCLIENT_API int LF_CC DropFloatingLicense(); */ LEXFLOATCLIENT_API int LF_CC HasFloatingLicense(); +/* + FUNCTION: RequestOfflineFloatingLicense() + + PURPOSE: Sends the request to lease the license from the LexFloatServer for offline usage. + + 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: IncrementFloatingClientMeterAttributeUses() From 743ee849cf663a9cc961cd9193308d1a797b76a5 Mon Sep 17 00:00:00 2001 From: muneebkq Date: Tue, 9 Jul 2024 14:54:47 +0530 Subject: [PATCH 02/18] feat: add GetFloatingClientLeaseExpiryDate --- lexfloatclient.go | 17 +++++++++++++++++ lexfloatclient/LexFloatClient.h | 12 ++++++++++++ 2 files changed, 29 insertions(+) diff --git a/lexfloatclient.go b/lexfloatclient.go index 0862ca6..449a288 100644 --- a/lexfloatclient.go +++ b/lexfloatclient.go @@ -292,6 +292,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() diff --git a/lexfloatclient/LexFloatClient.h b/lexfloatclient/LexFloatClient.h index 619e290..ee04a47 100644 --- a/lexfloatclient/LexFloatClient.h +++ b/lexfloatclient/LexFloatClient.h @@ -269,6 +269,18 @@ LEXFLOATCLIENT_API int LF_CC DropFloatingLicense(); */ LEXFLOATCLIENT_API int LF_CC HasFloatingLicense(); +/* + 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() From 1fc858391d75dde6246d68e89c1e42d11fe295fc Mon Sep 17 00:00:00 2001 From: muneebkq Date: Tue, 9 Jul 2024 15:59:12 +0530 Subject: [PATCH 03/18] feat: add get-floating-license-mode --- lexfloatclient.go | 306 +++++++++++++++++--------------- lexfloatclient/LexFloatClient.h | 13 ++ 2 files changed, 177 insertions(+), 142 deletions(-) diff --git a/lexfloatclient.go b/lexfloatclient.go index 0862ca6..2780937 100644 --- a/lexfloatclient.go +++ b/lexfloatclient.go @@ -34,15 +34,15 @@ func floatingLicenseCallbackWrapper(status int) { } /* - FUNCTION: SetHostProductId() +FUNCTION: SetHostProductId() - PURPOSE: Sets the product id of your application. +PURPOSE: Sets the product id of your application. - PARAMETERS: +PARAMETERS: * productId - the unique product id of your application as mentioned - on the product page in the dashboard. + on the product page in the dashboard. - RETURN CODES: LF_OK, LF_E_PRODUCT_ID +RETURN CODES: LF_OK, LF_E_PRODUCT_ID */ func SetHostProductId(productId string) int { cProductId := goToCString(productId) @@ -50,17 +50,18 @@ func SetHostProductId(productId string) int { freeCString(cProductId) return int(status) } + /* - FUNCTION: SetHostUrl() +FUNCTION: SetHostUrl() - PURPOSE: Sets the network address of the LexFloatServer. +PURPOSE: Sets the network address of the LexFloatServer. - The url format should be: http://[ip or hostname]:[port] +The url format should be: http://[ip or hostname]:[port] - PARAMETERS: - * hostUrl - url string having the correct format +PARAMETERS: +* hostUrl - url string having the correct format - RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_HOST_URL +RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_HOST_URL */ func SetHostUrl(hostUrl string) int { cHostUrl := goToCString(hostUrl) @@ -70,22 +71,22 @@ func SetHostUrl(hostUrl string) int { } /* - FUNCTION: SetFloatingLicenseCallback() +FUNCTION: SetFloatingLicenseCallback() - PURPOSE: Sets the renew license callback function. +PURPOSE: Sets the renew license callback function. - Whenever the license lease is about to expire, a renew request is sent to the - server. When the request completes, the license callback function - gets invoked with one of the following status codes: +Whenever the license lease is about to expire, a renew request is sent to the +server. When the request completes, the license callback function +gets invoked with one of the following status codes: - LF_OK, LF_E_INET, LF_E_LICENSE_EXPIRED_INET, LF_E_LICENSE_NOT_FOUND, LF_E_CLIENT, LF_E_IP, - LF_E_SERVER, LF_E_TIME, LF_E_SERVER_LICENSE_NOT_ACTIVATED,LF_E_SERVER_TIME_MODIFIED, - LF_E_SERVER_LICENSE_SUSPENDED, LF_E_SERVER_LICENSE_EXPIRED, LF_E_SERVER_LICENSE_GRACE_PERIOD_OVER +LF_OK, LF_E_INET, LF_E_LICENSE_EXPIRED_INET, LF_E_LICENSE_NOT_FOUND, LF_E_CLIENT, LF_E_IP, +LF_E_SERVER, LF_E_TIME, LF_E_SERVER_LICENSE_NOT_ACTIVATED,LF_E_SERVER_TIME_MODIFIED, +LF_E_SERVER_LICENSE_SUSPENDED, LF_E_SERVER_LICENSE_EXPIRED, LF_E_SERVER_LICENSE_GRACE_PERIOD_OVER - PARAMETERS: - * callback - name of the callback function +PARAMETERS: +* callback - name of the callback function - RETURN CODES: LF_OK, LF_E_PRODUCT_ID +RETURN CODES: LF_OK, LF_E_PRODUCT_ID */ func SetFloatingLicenseCallback(callbackFunction func(int)) int { status := C.SetFloatingLicenseCallback((C.CallbackType)(unsafe.Pointer(C.floatingLicenseCallbackCgoGateway))) @@ -94,19 +95,19 @@ func SetFloatingLicenseCallback(callbackFunction func(int)) int { } /* - FUNCTION: SetFloatingClientMetadata() +FUNCTION: SetFloatingClientMetadata() - PURPOSE: Sets the floating client metadata. +PURPOSE: Sets the floating client metadata. - The metadata appears along with the license details of the license - in LexFloatServer dashboard. +The metadata appears along with the license details of the license +in LexFloatServer dashboard. - PARAMETERS: - * key - string of maximum length 256 characters with utf-8 encoding. - * value - string of maximum length 4096 characters with utf-8 encoding. +PARAMETERS: +* key - string of maximum length 256 characters with utf-8 encoding. +* value - string of maximum length 4096 characters with utf-8 encoding. - RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_METADATA_KEY_LENGTH, - LF_E_METADATA_VALUE_LENGTH, LF_E_ACTIVATION_METADATA_LIMIT +RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_METADATA_KEY_LENGTH, +LF_E_METADATA_VALUE_LENGTH, LF_E_ACTIVATION_METADATA_LIMIT */ func SetFloatingClientMetadata(key string, value string) int { cKey := goToCString(key) @@ -118,33 +119,33 @@ func SetFloatingClientMetadata(key string, value string) int { } /* - FUNCTION: GetFloatingClientLibraryVersion() +FUNCTION: GetFloatingClientLibraryVersion() + +PURPOSE: Gets the version of this library. - PURPOSE: Gets the version of this library. +PARAMETERS: +* libraryVersion - pointer to a buffer that receives the value of the string +* length - size of the buffer pointed to by the libraryVersion parameter - 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 +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) } /* - FUNCTION: GetHostProductVersionName() +FUNCTION: GetHostProductVersionName() - PURPOSE: Gets the product version name. +PURPOSE: Gets the product version name. - PARAMETERS: - * name - pointer to a buffer that receives the value of the string - * length - size of the buffer pointed to by the name parameter +PARAMETERS: +* name - pointer to a buffer that receives the value of the string +* length - size of the buffer pointed to by the name parameter - RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_PRODUCT_VERSION_NOT_LINKED, LF_E_BUFFER_SIZE +RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_PRODUCT_VERSION_NOT_LINKED, LF_E_BUFFER_SIZE */ func GetHostProductVersionName(name *string) int { var cName = getCArray() @@ -154,15 +155,15 @@ func GetHostProductVersionName(name *string) int { } /* - FUNCTION: GetHostProductVersionDisplayName() +FUNCTION: GetHostProductVersionDisplayName() - PURPOSE: Gets the product version display name. +PURPOSE: Gets the product version display name. - PARAMETERS: - * displayName - pointer to a buffer that receives the value of the string - * length - size of the buffer pointed to by the displayName parameter +PARAMETERS: +* displayName - pointer to a buffer that receives the value of the string +* length - size of the buffer pointed to by the displayName parameter - RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_PRODUCT_VERSION_NOT_LINKED, LF_E_BUFFER_SIZE +RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_PRODUCT_VERSION_NOT_LINKED, LF_E_BUFFER_SIZE */ func GetHostProductVersionDisplayName(displayName *string) int { var cDisplayName = getCArray() @@ -172,41 +173,41 @@ func GetHostProductVersionDisplayName(displayName *string) int { } /* - FUNCTION: GetHostProductVersionFeatureFlag() +FUNCTION: GetHostProductVersionFeatureFlag() - PURPOSE: Gets the product version feature flag. +PURPOSE: Gets the product version feature flag. - PARAMETERS: - * name - name of the feature flag - * enabled - pointer to the integer that receives the value - 0 or 1 - * data - pointer to a buffer that receives the value of the string - * length - size of the buffer pointed to by the data parameter +PARAMETERS: +* name - name of the feature flag +* enabled - pointer to the integer that receives the value - 0 or 1 +* data - pointer to a buffer that receives the value of the string +* length - size of the buffer pointed to by the data parameter - RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_PRODUCT_VERSION_NOT_LINKED, LF_E_FEATURE_FLAG_NOT_FOUND, LF_E_BUFFER_SIZE +RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_PRODUCT_VERSION_NOT_LINKED, LF_E_FEATURE_FLAG_NOT_FOUND, LF_E_BUFFER_SIZE */ func GetHostProductVersionFeatureFlag(name string, enabled *bool, data *string) int { - cName := goToCString(name) - var cEnabled C.uint - var cData = getCArray() - status := C.GetHostProductVersionFeatureFlag(cName, &cEnabled, &cData[0], maxCArrayLength) - freeCString(cName) - *enabled = cEnabled > 0 - *data = ctoGoString(&cData[0]) - return int(status) - } + cName := goToCString(name) + var cEnabled C.uint + var cData = getCArray() + status := C.GetHostProductVersionFeatureFlag(cName, &cEnabled, &cData[0], maxCArrayLength) + freeCString(cName) + *enabled = cEnabled > 0 + *data = ctoGoString(&cData[0]) + return int(status) +} /* - FUNCTION: GetHostLicenseMetadata() +FUNCTION: GetHostLicenseMetadata() - PURPOSE: Get the value of the license metadata field associated with the LexFloatServer license. +PURPOSE: Get the value of the license metadata field associated with the LexFloatServer license. - PARAMETERS: - * key - key of the metadata field whose value you want to get - * value - pointer to a buffer that receives the value of the string - * length - size of the buffer pointed to by the value parameter +PARAMETERS: +* key - key of the metadata field whose value you want to get +* 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 +RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_BUFFER_SIZE, +LF_E_METADATA_KEY_NOT_FOUND */ func GetHostLicenseMetadata(key string, value *string) int { cKey := goToCString(key) @@ -218,17 +219,17 @@ func GetHostLicenseMetadata(key string, value *string) int { } /* - FUNCTION: GetHostLicenseMeterAttribute() +FUNCTION: GetHostLicenseMeterAttribute() - PURPOSE: Gets the license meter attribute allowed uses and total uses associated with the LexFloatServer license. +PURPOSE: Gets the license meter attribute allowed uses and total uses associated with the LexFloatServer license. - PARAMETERS: - * name - name of the meter attribute - * allowedUses - pointer to the integer that receives the value - * totalUses - pointer to the integer that receives the value - * grossUses - pointer to the integer that receives the value +PARAMETERS: +* name - name of the meter attribute +* allowedUses - pointer to the integer that receives the value +* totalUses - pointer to the integer that receives the value +* grossUses - pointer to the integer that receives the value - RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_METER_ATTRIBUTE_NOT_FOUND +RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_METER_ATTRIBUTE_NOT_FOUND */ func GetHostLicenseMeterAttribute(name string, allowedUses *uint, totalUses *uint, grossUses *uint) int { cName := goToCString(name) @@ -242,15 +243,16 @@ func GetHostLicenseMeterAttribute(name string, allowedUses *uint, totalUses *uin freeCString(cName) return int(status) } + /* - FUNCTION: GetHostLicenseExpiryDate() +FUNCTION: GetHostLicenseExpiryDate() - PURPOSE: Gets the license expiry date timestamp of the LexFloatServer license. +PURPOSE: Gets the license expiry date timestamp of the LexFloatServer license. - PARAMETERS: - * expiryDate - pointer to the integer that receives the value +PARAMETERS: +* expiryDate - pointer to the integer that receives the value - RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE +RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE */ func GetHostLicenseExpiryDate(expiryDate *uint) int { var cExpiryDate C.uint @@ -258,16 +260,17 @@ func GetHostLicenseExpiryDate(expiryDate *uint) int { *expiryDate = uint(cExpiryDate) return int(status) } + /* - FUNCTION: GetFloatingClientMeterAttributeUses() +FUNCTION: GetFloatingClientMeterAttributeUses() - PURPOSE: Gets the meter attribute uses consumed by the floating client. +PURPOSE: Gets the meter attribute uses consumed by the floating client. - PARAMETERS: - * name - name of the meter attribute - * uses - pointer to the integer that receives the value +PARAMETERS: +* name - name of the meter attribute +* uses - pointer to the integer that receives the value - RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_METER_ATTRIBUTE_NOT_FOUND +RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_METER_ATTRIBUTE_NOT_FOUND */ func GetFloatingClientMeterAttributeUses(name string, uses *uint) int { cName := goToCString(name) @@ -277,15 +280,16 @@ func GetFloatingClientMeterAttributeUses(name string, uses *uint) int { freeCString(cName) return int(status) } + /* - FUNCTION: RequestFloatingLicense() +FUNCTION: RequestFloatingLicense() - PURPOSE: Sends the request to lease the license from the LexFloatServer. +PURPOSE: Sends the request to lease the license from the LexFloatServer. - RETURN CODES: LF_OK, LF_FAIL, LF_E_PRODUCT_ID, LF_E_LICENSE_EXISTS, LF_E_HOST_URL, - LF_E_CALLBACK, 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 +RETURN CODES: LF_OK, LF_FAIL, LF_E_PRODUCT_ID, LF_E_LICENSE_EXISTS, LF_E_HOST_URL, +LF_E_CALLBACK, 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 */ func RequestFloatingLicense() int { status := C.RequestFloatingLicense() @@ -293,16 +297,16 @@ func RequestFloatingLicense() int { } /* - FUNCTION: DropFloatingLicense() +FUNCTION: DropFloatingLicense() - PURPOSE: Sends the request to the LexFloatServer to free the license. +PURPOSE: Sends the request to the LexFloatServer to free the license. - Call this function before you exit your application to prevent zombie licenses. +Call this function before you exit your application to prevent zombie licenses. - RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_HOST_URL, LF_E_CALLBACK, - LF_E_INET, LF_E_LICENSE_NOT_FOUND, 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 +RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_HOST_URL, LF_E_CALLBACK, +LF_E_INET, LF_E_LICENSE_NOT_FOUND, 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 */ func DropFloatingLicense() int { status := C.DropFloatingLicense() @@ -310,12 +314,12 @@ func DropFloatingLicense() int { } /* - FUNCTION: HasFloatingLicense() +FUNCTION: HasFloatingLicense() - PURPOSE: Checks whether any license has been leased or not. If yes, - it retuns LF_OK. +PURPOSE: Checks whether any license has been leased or not. If yes, +it retuns LF_OK. - RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE +RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE */ func HasFloatingLicense() int { status := C.HasFloatingLicense() @@ -323,19 +327,37 @@ func HasFloatingLicense() int { } /* - FUNCTION: IncrementFloatingClientMeterAttributeUses() + 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 +*/ - PURPOSE: Increments the meter attribute uses of the floating client. +func GetFloatingLicenseMode(modePtr *string) int { + var cModePtr = getCArray() + status := C.GetFloatingLicenseMode(&cModePtr[0], maxCArrayLength) + *modePtr = ctoGoString(&cModePtr[0]) + return int(status) +} + +/* +FUNCTION: IncrementFloatingClientMeterAttributeUses() - PARAMETERS: - * name - name of the meter attribute - * increment - the increment value +PURPOSE: Increments the meter attribute uses of the floating client. - RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_HOST_URL, LF_E_METER_ATTRIBUTE_NOT_FOUND, - 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 +PARAMETERS: +* name - name of the meter attribute +* increment - the increment value +RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_HOST_URL, LF_E_METER_ATTRIBUTE_NOT_FOUND, +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) @@ -346,20 +368,20 @@ func IncrementFloatingClientMeterAttributeUses(name string, increment uint) int } /* - FUNCTION: DecrementFloatingClientMeterAttributeUses() +FUNCTION: DecrementFloatingClientMeterAttributeUses() - PURPOSE: Decrements the meter attribute uses of the floating client. +PURPOSE: Decrements the meter attribute uses of the floating client. - PARAMETERS: - * name - name of the meter attribute - * decrement - the decrement value +PARAMETERS: +* name - name of the meter attribute +* decrement - the decrement value - RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_HOST_URL, LF_E_METER_ATTRIBUTE_NOT_FOUND, - LF_E_INET, LF_E_LICENSE_NOT_FOUND, 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 +RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_HOST_URL, LF_E_METER_ATTRIBUTE_NOT_FOUND, +LF_E_INET, LF_E_LICENSE_NOT_FOUND, 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 - NOTE: If the decrement is more than the current uses, it resets the uses to 0. +NOTE: If the decrement is more than the current uses, it resets the uses to 0. */ func DecrementFloatingClientMeterAttributeUses(name string, decrement uint) int { cName := goToCString(name) @@ -370,17 +392,17 @@ func DecrementFloatingClientMeterAttributeUses(name string, decrement uint) int } /* - FUNCTION: ResetFloatingClientMeterAttributeUses() +FUNCTION: ResetFloatingClientMeterAttributeUses() - PURPOSE: Resets the meter attribute uses consumed by the floating client. +PURPOSE: Resets the meter attribute uses consumed by the floating client. - PARAMETERS: - * name - name of the meter attribute +PARAMETERS: +* name - name of the meter attribute - RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_HOST_URL, LF_E_METER_ATTRIBUTE_NOT_FOUND, - LF_E_INET, LF_E_LICENSE_NOT_FOUND, 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 +RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_HOST_URL, LF_E_METER_ATTRIBUTE_NOT_FOUND, +LF_E_INET, LF_E_LICENSE_NOT_FOUND, 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 */ func ResetFloatingClientMeterAttributeUses(name string) int { cName := goToCString(name) diff --git a/lexfloatclient/LexFloatClient.h b/lexfloatclient/LexFloatClient.h index 619e290..b6b7847 100644 --- a/lexfloatclient/LexFloatClient.h +++ b/lexfloatclient/LexFloatClient.h @@ -269,6 +269,19 @@ 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: IncrementFloatingClientMeterAttributeUses() From 661e16d0dc42c4693c597292d35b0759408e6be1 Mon Sep 17 00:00:00 2001 From: muneebkq Date: Tue, 9 Jul 2024 16:42:05 +0530 Subject: [PATCH 04/18] feat: add set-permission-flag function --- lexfloatclient.go | 27 +++++++++++++++++++++++++++ lexfloatclient/LexFloatClient.h | 22 ++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/lexfloatclient.go b/lexfloatclient.go index 0862ca6..bbb5202 100644 --- a/lexfloatclient.go +++ b/lexfloatclient.go @@ -22,6 +22,8 @@ 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 @@ -32,6 +34,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() diff --git a/lexfloatclient/LexFloatClient.h b/lexfloatclient/LexFloatClient.h index 619e290..a344f3c 100644 --- a/lexfloatclient/LexFloatClient.h +++ b/lexfloatclient/LexFloatClient.h @@ -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() From 0177a335d4357d97a9252f1656294c852ad9b54f Mon Sep 17 00:00:00 2001 From: muneebkq Date: Fri, 12 Jul 2024 11:42:56 +0530 Subject: [PATCH 05/18] feta: add floating client metadata --- lexfloatclient.go | 23 +++++++++++++++++++++++ lexfloatclient/LexFloatClient.h | 15 +++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/lexfloatclient.go b/lexfloatclient.go index 0862ca6..be6e5ab 100644 --- a/lexfloatclient.go +++ b/lexfloatclient.go @@ -277,6 +277,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 + * 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 +*/ +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() diff --git a/lexfloatclient/LexFloatClient.h b/lexfloatclient/LexFloatClient.h index 619e290..1961ae9 100644 --- a/lexfloatclient/LexFloatClient.h +++ b/lexfloatclient/LexFloatClient.h @@ -233,6 +233,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() From 2434b8f567e72e3a1c5fd061a3da8944b1e06a68 Mon Sep 17 00:00:00 2001 From: muneebkq Date: Tue, 30 Jul 2024 18:01:15 +0530 Subject: [PATCH 06/18] refactor: jsdoc --- lexfloatclient.go | 258 +++++++++++++++++++++++----------------------- 1 file changed, 129 insertions(+), 129 deletions(-) diff --git a/lexfloatclient.go b/lexfloatclient.go index 2780937..2c1ad52 100644 --- a/lexfloatclient.go +++ b/lexfloatclient.go @@ -34,15 +34,15 @@ func floatingLicenseCallbackWrapper(status int) { } /* -FUNCTION: SetHostProductId() + FUNCTION: SetHostProductId() -PURPOSE: Sets the product id of your application. + PURPOSE: Sets the product id of your application. -PARAMETERS: - * productId - the unique product id of your application as mentioned - on the product page in the dashboard. + PARAMETERS: + * productId - the unique product id of your application as mentioned + on the product page in the dashboard. -RETURN CODES: LF_OK, LF_E_PRODUCT_ID + RETURN CODES: LF_OK, LF_E_PRODUCT_ID */ func SetHostProductId(productId string) int { cProductId := goToCString(productId) @@ -52,16 +52,16 @@ func SetHostProductId(productId string) int { } /* -FUNCTION: SetHostUrl() + FUNCTION: SetHostUrl() -PURPOSE: Sets the network address of the LexFloatServer. + PURPOSE: Sets the network address of the LexFloatServer. -The url format should be: http://[ip or hostname]:[port] + The url format should be: http://[ip or hostname]:[port] -PARAMETERS: -* hostUrl - url string having the correct format + PARAMETERS: + * hostUrl - url string having the correct format -RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_HOST_URL + RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_HOST_URL */ func SetHostUrl(hostUrl string) int { cHostUrl := goToCString(hostUrl) @@ -71,22 +71,22 @@ func SetHostUrl(hostUrl string) int { } /* -FUNCTION: SetFloatingLicenseCallback() + FUNCTION: SetFloatingLicenseCallback() -PURPOSE: Sets the renew license callback function. + PURPOSE: Sets the renew license callback function. -Whenever the license lease is about to expire, a renew request is sent to the -server. When the request completes, the license callback function -gets invoked with one of the following status codes: + Whenever the license lease is about to expire, a renew request is sent to the + server. When the request completes, the license callback function + gets invoked with one of the following status codes: -LF_OK, LF_E_INET, LF_E_LICENSE_EXPIRED_INET, LF_E_LICENSE_NOT_FOUND, LF_E_CLIENT, LF_E_IP, -LF_E_SERVER, LF_E_TIME, LF_E_SERVER_LICENSE_NOT_ACTIVATED,LF_E_SERVER_TIME_MODIFIED, -LF_E_SERVER_LICENSE_SUSPENDED, LF_E_SERVER_LICENSE_EXPIRED, LF_E_SERVER_LICENSE_GRACE_PERIOD_OVER + LF_OK, LF_E_INET, LF_E_LICENSE_EXPIRED_INET, LF_E_LICENSE_NOT_FOUND, LF_E_CLIENT, LF_E_IP, + LF_E_SERVER, LF_E_TIME, LF_E_SERVER_LICENSE_NOT_ACTIVATED,LF_E_SERVER_TIME_MODIFIED, + LF_E_SERVER_LICENSE_SUSPENDED, LF_E_SERVER_LICENSE_EXPIRED, LF_E_SERVER_LICENSE_GRACE_PERIOD_OVER -PARAMETERS: -* callback - name of the callback function + PARAMETERS: + * callback - name of the callback function -RETURN CODES: LF_OK, LF_E_PRODUCT_ID + RETURN CODES: LF_OK, LF_E_PRODUCT_ID */ func SetFloatingLicenseCallback(callbackFunction func(int)) int { status := C.SetFloatingLicenseCallback((C.CallbackType)(unsafe.Pointer(C.floatingLicenseCallbackCgoGateway))) @@ -95,19 +95,19 @@ func SetFloatingLicenseCallback(callbackFunction func(int)) int { } /* -FUNCTION: SetFloatingClientMetadata() + FUNCTION: SetFloatingClientMetadata() -PURPOSE: Sets the floating client metadata. + PURPOSE: Sets the floating client metadata. -The metadata appears along with the license details of the license -in LexFloatServer dashboard. + The metadata appears along with the license details of the license + in LexFloatServer dashboard. -PARAMETERS: -* key - string of maximum length 256 characters with utf-8 encoding. -* value - string of maximum length 4096 characters with utf-8 encoding. + PARAMETERS: + * key - string of maximum length 256 characters with utf-8 encoding. + * value - string of maximum length 4096 characters with utf-8 encoding. -RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_METADATA_KEY_LENGTH, -LF_E_METADATA_VALUE_LENGTH, LF_E_ACTIVATION_METADATA_LIMIT + RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_METADATA_KEY_LENGTH, + LF_E_METADATA_VALUE_LENGTH, LF_E_ACTIVATION_METADATA_LIMIT */ func SetFloatingClientMetadata(key string, value string) int { cKey := goToCString(key) @@ -119,15 +119,15 @@ func SetFloatingClientMetadata(key string, value string) int { } /* -FUNCTION: GetFloatingClientLibraryVersion() + FUNCTION: GetFloatingClientLibraryVersion() -PURPOSE: Gets the version of this library. + PURPOSE: Gets the version of this library. -PARAMETERS: -* libraryVersion - pointer to a buffer that receives the value of the string -* length - size of the buffer pointed to by the libraryVersion parameter + 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 + RETURN CODES: LF_OK, LF_E_BUFFER_SIZE */ func GetFloatingClientLibraryVersion(libraryVersion *string) int { var cLibraryVersion = getCArray() @@ -137,15 +137,15 @@ func GetFloatingClientLibraryVersion(libraryVersion *string) int { } /* -FUNCTION: GetHostProductVersionName() + FUNCTION: GetHostProductVersionName() -PURPOSE: Gets the product version name. + PURPOSE: Gets the product version name. -PARAMETERS: -* name - pointer to a buffer that receives the value of the string -* length - size of the buffer pointed to by the name parameter + PARAMETERS: + * name - pointer to a buffer that receives the value of the string + * length - size of the buffer pointed to by the name parameter -RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_PRODUCT_VERSION_NOT_LINKED, LF_E_BUFFER_SIZE + RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_PRODUCT_VERSION_NOT_LINKED, LF_E_BUFFER_SIZE */ func GetHostProductVersionName(name *string) int { var cName = getCArray() @@ -155,15 +155,15 @@ func GetHostProductVersionName(name *string) int { } /* -FUNCTION: GetHostProductVersionDisplayName() + FUNCTION: GetHostProductVersionDisplayName() -PURPOSE: Gets the product version display name. + PURPOSE: Gets the product version display name. -PARAMETERS: -* displayName - pointer to a buffer that receives the value of the string -* length - size of the buffer pointed to by the displayName parameter + PARAMETERS: + * displayName - pointer to a buffer that receives the value of the string + * length - size of the buffer pointed to by the displayName parameter -RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_PRODUCT_VERSION_NOT_LINKED, LF_E_BUFFER_SIZE + RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_PRODUCT_VERSION_NOT_LINKED, LF_E_BUFFER_SIZE */ func GetHostProductVersionDisplayName(displayName *string) int { var cDisplayName = getCArray() @@ -173,17 +173,17 @@ func GetHostProductVersionDisplayName(displayName *string) int { } /* -FUNCTION: GetHostProductVersionFeatureFlag() + FUNCTION: GetHostProductVersionFeatureFlag() -PURPOSE: Gets the product version feature flag. + PURPOSE: Gets the product version feature flag. -PARAMETERS: -* name - name of the feature flag -* enabled - pointer to the integer that receives the value - 0 or 1 -* data - pointer to a buffer that receives the value of the string -* length - size of the buffer pointed to by the data parameter + PARAMETERS: + * name - name of the feature flag + * enabled - pointer to the integer that receives the value - 0 or 1 + * data - pointer to a buffer that receives the value of the string + * length - size of the buffer pointed to by the data parameter -RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_PRODUCT_VERSION_NOT_LINKED, LF_E_FEATURE_FLAG_NOT_FOUND, LF_E_BUFFER_SIZE + RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_PRODUCT_VERSION_NOT_LINKED, LF_E_FEATURE_FLAG_NOT_FOUND, LF_E_BUFFER_SIZE */ func GetHostProductVersionFeatureFlag(name string, enabled *bool, data *string) int { cName := goToCString(name) @@ -197,17 +197,17 @@ func GetHostProductVersionFeatureFlag(name string, enabled *bool, data *string) } /* -FUNCTION: GetHostLicenseMetadata() + FUNCTION: GetHostLicenseMetadata() -PURPOSE: Get the value of the license metadata field associated with the LexFloatServer license. + PURPOSE: Get the value of the license metadata field associated with the LexFloatServer license. -PARAMETERS: -* key - key of the metadata field whose value you want to get -* value - pointer to a buffer that receives the value of the string -* length - size of the buffer pointed to by the value parameter + PARAMETERS: + * key - key of the metadata field whose value you want to get + * 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 + RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_BUFFER_SIZE, + LF_E_METADATA_KEY_NOT_FOUND */ func GetHostLicenseMetadata(key string, value *string) int { cKey := goToCString(key) @@ -219,17 +219,17 @@ func GetHostLicenseMetadata(key string, value *string) int { } /* -FUNCTION: GetHostLicenseMeterAttribute() + FUNCTION: GetHostLicenseMeterAttribute() -PURPOSE: Gets the license meter attribute allowed uses and total uses associated with the LexFloatServer license. + PURPOSE: Gets the license meter attribute allowed uses and total uses associated with the LexFloatServer license. -PARAMETERS: -* name - name of the meter attribute -* allowedUses - pointer to the integer that receives the value -* totalUses - pointer to the integer that receives the value -* grossUses - pointer to the integer that receives the value + PARAMETERS: + * name - name of the meter attribute + * allowedUses - pointer to the integer that receives the value + * totalUses - pointer to the integer that receives the value + * grossUses - pointer to the integer that receives the value -RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_METER_ATTRIBUTE_NOT_FOUND + RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_METER_ATTRIBUTE_NOT_FOUND */ func GetHostLicenseMeterAttribute(name string, allowedUses *uint, totalUses *uint, grossUses *uint) int { cName := goToCString(name) @@ -245,14 +245,14 @@ func GetHostLicenseMeterAttribute(name string, allowedUses *uint, totalUses *uin } /* -FUNCTION: GetHostLicenseExpiryDate() + FUNCTION: GetHostLicenseExpiryDate() -PURPOSE: Gets the license expiry date timestamp of the LexFloatServer license. + PURPOSE: Gets the license expiry date timestamp of the LexFloatServer license. -PARAMETERS: -* expiryDate - pointer to the integer that receives the value + PARAMETERS: + * expiryDate - pointer to the integer that receives the value -RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE + RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE */ func GetHostLicenseExpiryDate(expiryDate *uint) int { var cExpiryDate C.uint @@ -262,15 +262,15 @@ func GetHostLicenseExpiryDate(expiryDate *uint) int { } /* -FUNCTION: GetFloatingClientMeterAttributeUses() + FUNCTION: GetFloatingClientMeterAttributeUses() -PURPOSE: Gets the meter attribute uses consumed by the floating client. + PURPOSE: Gets the meter attribute uses consumed by the floating client. -PARAMETERS: -* name - name of the meter attribute -* uses - pointer to the integer that receives the value + PARAMETERS: + * name - name of the meter attribute + * uses - pointer to the integer that receives the value -RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_METER_ATTRIBUTE_NOT_FOUND + RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_METER_ATTRIBUTE_NOT_FOUND */ func GetFloatingClientMeterAttributeUses(name string, uses *uint) int { cName := goToCString(name) @@ -282,14 +282,14 @@ func GetFloatingClientMeterAttributeUses(name string, uses *uint) int { } /* -FUNCTION: RequestFloatingLicense() + FUNCTION: RequestFloatingLicense() -PURPOSE: Sends the request to lease the license from the LexFloatServer. + PURPOSE: Sends the request to lease the license from the LexFloatServer. -RETURN CODES: LF_OK, LF_FAIL, LF_E_PRODUCT_ID, LF_E_LICENSE_EXISTS, LF_E_HOST_URL, -LF_E_CALLBACK, 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 + RETURN CODES: LF_OK, LF_FAIL, LF_E_PRODUCT_ID, LF_E_LICENSE_EXISTS, LF_E_HOST_URL, + LF_E_CALLBACK, 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 */ func RequestFloatingLicense() int { status := C.RequestFloatingLicense() @@ -297,16 +297,16 @@ func RequestFloatingLicense() int { } /* -FUNCTION: DropFloatingLicense() + FUNCTION: DropFloatingLicense() -PURPOSE: Sends the request to the LexFloatServer to free the license. + PURPOSE: Sends the request to the LexFloatServer to free the license. -Call this function before you exit your application to prevent zombie licenses. + Call this function before you exit your application to prevent zombie licenses. -RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_HOST_URL, LF_E_CALLBACK, -LF_E_INET, LF_E_LICENSE_NOT_FOUND, 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 + RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_HOST_URL, LF_E_CALLBACK, + LF_E_INET, LF_E_LICENSE_NOT_FOUND, 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 */ func DropFloatingLicense() int { status := C.DropFloatingLicense() @@ -314,12 +314,12 @@ func DropFloatingLicense() int { } /* -FUNCTION: HasFloatingLicense() + FUNCTION: HasFloatingLicense() -PURPOSE: Checks whether any license has been leased or not. If yes, -it retuns LF_OK. + PURPOSE: Checks whether any license has been leased or not. If yes, + it retuns LF_OK. -RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE + RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE */ func HasFloatingLicense() int { status := C.HasFloatingLicense() @@ -346,18 +346,18 @@ func GetFloatingLicenseMode(modePtr *string) int { } /* -FUNCTION: IncrementFloatingClientMeterAttributeUses() + FUNCTION: IncrementFloatingClientMeterAttributeUses() -PURPOSE: Increments the meter attribute uses of the floating client. + PURPOSE: Increments the meter attribute uses of the floating client. -PARAMETERS: -* name - name of the meter attribute -* increment - the increment value + PARAMETERS: + * name - name of the meter attribute + * increment - the increment value -RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_HOST_URL, LF_E_METER_ATTRIBUTE_NOT_FOUND, -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 + RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_HOST_URL, LF_E_METER_ATTRIBUTE_NOT_FOUND, + 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) @@ -368,20 +368,20 @@ func IncrementFloatingClientMeterAttributeUses(name string, increment uint) int } /* -FUNCTION: DecrementFloatingClientMeterAttributeUses() + FUNCTION: DecrementFloatingClientMeterAttributeUses() -PURPOSE: Decrements the meter attribute uses of the floating client. + PURPOSE: Decrements the meter attribute uses of the floating client. -PARAMETERS: -* name - name of the meter attribute -* decrement - the decrement value + PARAMETERS: + * name - name of the meter attribute + * decrement - the decrement value -RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_HOST_URL, LF_E_METER_ATTRIBUTE_NOT_FOUND, -LF_E_INET, LF_E_LICENSE_NOT_FOUND, 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 + RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_HOST_URL, LF_E_METER_ATTRIBUTE_NOT_FOUND, + LF_E_INET, LF_E_LICENSE_NOT_FOUND, 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 -NOTE: If the decrement is more than the current uses, it resets the uses to 0. + NOTE: If the decrement is more than the current uses, it resets the uses to 0. */ func DecrementFloatingClientMeterAttributeUses(name string, decrement uint) int { cName := goToCString(name) @@ -392,17 +392,17 @@ func DecrementFloatingClientMeterAttributeUses(name string, decrement uint) int } /* -FUNCTION: ResetFloatingClientMeterAttributeUses() + FUNCTION: ResetFloatingClientMeterAttributeUses() -PURPOSE: Resets the meter attribute uses consumed by the floating client. + PURPOSE: Resets the meter attribute uses consumed by the floating client. -PARAMETERS: -* name - name of the meter attribute + PARAMETERS: + * name - name of the meter attribute -RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_HOST_URL, LF_E_METER_ATTRIBUTE_NOT_FOUND, -LF_E_INET, LF_E_LICENSE_NOT_FOUND, 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 + RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_HOST_URL, LF_E_METER_ATTRIBUTE_NOT_FOUND, + LF_E_INET, LF_E_LICENSE_NOT_FOUND, 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 */ func ResetFloatingClientMeterAttributeUses(name string) int { cName := goToCString(name) From 22dbc64793318e2d9af08284cc7a27606d79f8c8 Mon Sep 17 00:00:00 2001 From: muneebkq Date: Tue, 30 Jul 2024 18:03:38 +0530 Subject: [PATCH 07/18] refactor: jsdoc --- lexfloatclient.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lexfloatclient.go b/lexfloatclient.go index 2c1ad52..da72e52 100644 --- a/lexfloatclient.go +++ b/lexfloatclient.go @@ -39,8 +39,8 @@ func floatingLicenseCallbackWrapper(status int) { PURPOSE: Sets the product id of your application. PARAMETERS: - * productId - the unique product id of your application as mentioned - on the product page in the dashboard. + * productId - the unique product id of your application as mentioned + on the product page in the dashboard. RETURN CODES: LF_OK, LF_E_PRODUCT_ID */ From 91864d025e3fd3fb3cc9a6e02411e0f202f1230c Mon Sep 17 00:00:00 2001 From: muneebkq Date: Tue, 30 Jul 2024 18:06:24 +0530 Subject: [PATCH 08/18] refactor: jsdoc --- lexfloatclient.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lexfloatclient.go b/lexfloatclient.go index da72e52..578c027 100644 --- a/lexfloatclient.go +++ b/lexfloatclient.go @@ -186,14 +186,14 @@ func GetHostProductVersionDisplayName(displayName *string) int { RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_PRODUCT_VERSION_NOT_LINKED, LF_E_FEATURE_FLAG_NOT_FOUND, LF_E_BUFFER_SIZE */ func GetHostProductVersionFeatureFlag(name string, enabled *bool, data *string) int { - cName := goToCString(name) - var cEnabled C.uint - var cData = getCArray() - status := C.GetHostProductVersionFeatureFlag(cName, &cEnabled, &cData[0], maxCArrayLength) - freeCString(cName) - *enabled = cEnabled > 0 - *data = ctoGoString(&cData[0]) - return int(status) + cName := goToCString(name) + var cEnabled C.uint + var cData = getCArray() + status := C.GetHostProductVersionFeatureFlag(cName, &cEnabled, &cData[0], maxCArrayLength) + freeCString(cName) + *enabled = cEnabled > 0 + *data = ctoGoString(&cData[0]) + return int(status) } /* From 279c2b2e3f5e4775fb72d32f0767f1bf4b0316f5 Mon Sep 17 00:00:00 2001 From: muneebkq Date: Wed, 31 Jul 2024 18:12:13 +0530 Subject: [PATCH 09/18] feat: add status code --- lexfloatstatus_codes.go | 52 ++++++++++++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 14 deletions(-) diff --git a/lexfloatstatus_codes.go b/lexfloatstatus_codes.go index ac5107e..5d9fe5b 100644 --- a/lexfloatstatus_codes.go +++ b/lexfloatstatus_codes.go @@ -4,7 +4,7 @@ package lexfloatclient // int enumeration from lexfloatclient/int.h int =4 const ( - // Success code. + // Success code. LF_OK int = 0 // Failure code. @@ -31,16 +31,15 @@ const ( // License has already been leased. LF_E_LICENSE_EXISTS int = 46 - // License does not exist on server or has already expired. This - // happens when the request to refresh the license is delayed. + // License does not exist on server or has already expired. + // This happens when the request to refresh the license is delayed. LF_E_LICENSE_NOT_FOUND int = 47 - // License lease has expired due to network error. This - // happens when the request to refresh the license fails due to - // network error. + // License lease has expired due to network error. + // This happens when the request to refresh the license fails due to network error. LF_E_LICENSE_EXPIRED_INET int = 48 - // The server has reached it's allowed limit of floating licenses. + // The server has reached its allowed limit of floating licenses. LF_E_LICENSE_LIMIT_REACHED int = 49 // The buffer size was smaller than required. @@ -55,32 +54,57 @@ const ( // Metadata value length is more than 4096 characters. LF_E_METADATA_VALUE_LENGTH int = 53 - // The floating client has reached it's metadata fields limit. + // The floating client has reached its metadata fields limit. LF_E_FLOATING_CLIENT_METADATA_LIMIT int = 54 // The meter attribute does not exist. LF_E_METER_ATTRIBUTE_NOT_FOUND int = 55 - // The meter attribute has reached it's usage limit. + // The meter attribute has reached its usage limit. LF_E_METER_ATTRIBUTE_USES_LIMIT_REACHED int = 56 // No product version is linked with the license. - LF_E_PRODUCT_VERSION_NOT_LINKED int = 57 + LF_E_PRODUCT_VERSION_NOT_LINKED int = 57 - // The product version feature flag does not exist. - LF_E_FEATURE_FLAG_NOT_FOUND int = 58 + // The product version feature flag does not exist. + LF_E_FEATURE_FLAG_NOT_FOUND int = 58 + + // Insufficient system permissions. + LF_E_SYSTEM_PERMISSION int = 59 // IP address is not allowed. LF_E_IP int = 60 + // Invalid permission flag. + LF_E_INVALID_PERMISSION_FLAG int = 61 + + // Offline floating license is not allowed for per-instance leasing strategy. + LF_E_OFFLINE_FLOATING_LICENSE_NOT_ALLOWED int = 62 + + // Maximum offline lease duration exceeded. + LF_E_MAX_OFFLINE_LEASE_DURATION_EXCEEDED int = 63 + + // Allowed offline floating clients limit reached. + LF_E_ALLOWED_OFFLINE_FLOATING_CLIENTS_LIMIT_REACHED int = 64 + + // Fingerprint couldn't be generated because Windows Management Instrumentation (WMI) service has been disabled. + // This error is specific to Windows only. + LF_E_WMIC int = 65 + + // Machine fingerprint has changed since activation. + LF_E_MACHINE_FINGERPRINT int = 66 + + // Request blocked due to untrusted proxy. + LF_E_PROXY_NOT_TRUSTED int = 67 + // Client error. LF_E_CLIENT int = 70 // Server error. LF_E_SERVER int = 71 - // System time on server has been tampered with. Ensure - // your date and time settings are correct on the server machine. + // System time on server has been tampered with. + // Ensure your date and time settings are correct on the server machine. LF_E_SERVER_TIME_MODIFIED int = 72 // The server has not been activated using a license key. From e7bcb9304b7928ba1c84c28903abf9625f1b9a85 Mon Sep 17 00:00:00 2001 From: muneebkq Date: Fri, 2 Aug 2024 14:35:37 +0530 Subject: [PATCH 10/18] refactor: error code --- lexfloatstatus_codes.go | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/lexfloatstatus_codes.go b/lexfloatstatus_codes.go index 5d9fe5b..00b941a 100644 --- a/lexfloatstatus_codes.go +++ b/lexfloatstatus_codes.go @@ -31,15 +31,16 @@ const ( // License has already been leased. LF_E_LICENSE_EXISTS int = 46 - // License does not exist on server or has already expired. - // This happens when the request to refresh the license is delayed. + // License does not exist on server or has already expired. This + // happens when the request to refresh the license is delayed. LF_E_LICENSE_NOT_FOUND int = 47 - // License lease has expired due to network error. - // This happens when the request to refresh the license fails due to network error. + // License lease has expired due to network error. This + // happens when the request to refresh the license fails due to + // network error. LF_E_LICENSE_EXPIRED_INET int = 48 - // The server has reached its allowed limit of floating licenses. + // The server has reached it's allowed limit of floating licenses. LF_E_LICENSE_LIMIT_REACHED int = 49 // The buffer size was smaller than required. @@ -54,13 +55,13 @@ const ( // Metadata value length is more than 4096 characters. LF_E_METADATA_VALUE_LENGTH int = 53 - // The floating client has reached its metadata fields limit. + // The floating client has reached it's metadata fields limit. LF_E_FLOATING_CLIENT_METADATA_LIMIT int = 54 // The meter attribute does not exist. LF_E_METER_ATTRIBUTE_NOT_FOUND int = 55 - // The meter attribute has reached its usage limit. + // The meter attribute has reached it's usage limit. LF_E_METER_ATTRIBUTE_USES_LIMIT_REACHED int = 56 // No product version is linked with the license. @@ -68,7 +69,7 @@ const ( // The product version feature flag does not exist. LF_E_FEATURE_FLAG_NOT_FOUND int = 58 - + // Insufficient system permissions. LF_E_SYSTEM_PERMISSION int = 59 @@ -87,24 +88,22 @@ const ( // Allowed offline floating clients limit reached. LF_E_ALLOWED_OFFLINE_FLOATING_CLIENTS_LIMIT_REACHED int = 64 - // Fingerprint couldn't be generated because Windows Management Instrumentation (WMI) service has been disabled. - // This error is specific to Windows only. + // Fingerprint couldn't be generated because Windows Management + // Instrumentation (WMI) service has been disabled. This error is specific + // to Windows only. LF_E_WMIC int = 65 // Machine fingerprint has changed since activation. LF_E_MACHINE_FINGERPRINT int = 66 - // Request blocked due to untrusted proxy. - LF_E_PROXY_NOT_TRUSTED int = 67 - // Client error. LF_E_CLIENT int = 70 // Server error. LF_E_SERVER int = 71 - // System time on server has been tampered with. - // Ensure your date and time settings are correct on the server machine. + // System time on server has been tampered with. Ensure + // your date and time settings are correct on the server machine. LF_E_SERVER_TIME_MODIFIED int = 72 // The server has not been activated using a license key. From d91a0ccdccfc218a9b5143aec1ab6867eaade1b8 Mon Sep 17 00:00:00 2001 From: muneebkq Date: Fri, 2 Aug 2024 17:19:55 +0530 Subject: [PATCH 11/18] refactor: jsdoc --- lexfloatclient.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lexfloatclient.go b/lexfloatclient.go index be6e5ab..5364f62 100644 --- a/lexfloatclient.go +++ b/lexfloatclient.go @@ -286,8 +286,7 @@ func GetFloatingClientMeterAttributeUses(name string, uses *uint) int { 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 */ From d1eeeeedd97310eb58990ccb45f0e0e8aca77095 Mon Sep 17 00:00:00 2001 From: muneebkq Date: Fri, 2 Aug 2024 17:21:38 +0530 Subject: [PATCH 12/18] fix: remove LA values --- lexfloatclient.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/lexfloatclient.go b/lexfloatclient.go index bbb5202..7a2f5cf 100644 --- a/lexfloatclient.go +++ b/lexfloatclient.go @@ -19,9 +19,6 @@ import ( 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 ) From 6fccba734740eae8f169cca7c10cebd23ab51bb5 Mon Sep 17 00:00:00 2001 From: muneebkq Date: Fri, 2 Aug 2024 17:28:07 +0530 Subject: [PATCH 13/18] refactor: jsdocs --- lexfloatclient.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/lexfloatclient.go b/lexfloatclient.go index 254b783..41879d1 100644 --- a/lexfloatclient.go +++ b/lexfloatclient.go @@ -18,7 +18,7 @@ import ( type callbackType func(int) -const ( +const ( LA_USER uint = 0 LA_SYSTEM uint = 1 LA_IN_MEMORY uint = 2 @@ -40,7 +40,7 @@ func floatingLicenseCallbackWrapper(status int) { PARAMETERS: * productId - the unique product id of your application as mentioned - on the product page in the dashboard. + on the product page in the dashboard. RETURN CODES: LF_OK, LF_E_PRODUCT_ID */ @@ -349,16 +349,15 @@ func HasFloatingLicense() int { PURPOSE: Gets the mode of the floating license (online or offline). PARAMETERS: - * modePtr - pointer to a buffer that receives the value of the string + * 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(modePtr *string) int { - var cModePtr = getCArray() - status := C.GetFloatingLicenseMode(&cModePtr[0], maxCArrayLength) - *modePtr = ctoGoString(&cModePtr[0]) +func GetFloatingLicenseMode(mode *string) int { + var cMode = getCArray() + status := C.GetFloatingLicenseMode(&cMode[0], maxCArrayLength) + *mode= ctoGoString(&cMode[0]) return int(status) } From f753ae2f1a72b00f7c69c429bca203e6ddc5e1a3 Mon Sep 17 00:00:00 2001 From: muneebkq Date: Fri, 2 Aug 2024 18:15:58 +0530 Subject: [PATCH 14/18] refactor: jsdoc --- lexfloatclient.go | 5 +++++ lexfloatclient/LexFloatClient.h | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/lexfloatclient.go b/lexfloatclient.go index 713d597..380b951 100644 --- a/lexfloatclient.go +++ b/lexfloatclient.go @@ -327,6 +327,11 @@ func HasFloatingLicense() int { 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, diff --git a/lexfloatclient/LexFloatClient.h b/lexfloatclient/LexFloatClient.h index 556589a..cec4c6b 100644 --- a/lexfloatclient/LexFloatClient.h +++ b/lexfloatclient/LexFloatClient.h @@ -273,6 +273,11 @@ LEXFLOATCLIENT_API int LF_CC HasFloatingLicense(); 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, From a6a9331db1551290ab1288f1dbba2a987d350b05 Mon Sep 17 00:00:00 2001 From: muneebkq Date: Fri, 2 Aug 2024 18:18:03 +0530 Subject: [PATCH 15/18] feat: add status code to header file --- lexfloatclient/LexFloatStatusCodes.h | 54 +++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/lexfloatclient/LexFloatStatusCodes.h b/lexfloatclient/LexFloatStatusCodes.h index f3f2d56..d4b2476 100644 --- a/lexfloatclient/LexFloatStatusCodes.h +++ b/lexfloatclient/LexFloatStatusCodes.h @@ -114,7 +114,7 @@ enum LexFloatStatusCodes /* CODE: LF_E_METADATA_VALUE_LENGTH - MESSAGE: Metadata value length is more than 4096 characters. + MESSAGE: Metadata value length is more than 256 characters. */ LF_E_METADATA_VALUE_LENGTH = 53, @@ -153,6 +153,13 @@ enum LexFloatStatusCodes */ LF_E_FEATURE_FLAG_NOT_FOUND = 58, + /* + CODE: LF_E_SYSTEM_PERMISSION + + MESSAGE: Insufficient system permissions. + */ + LF_E_SYSTEM_PERMISSION = 59, + /* CODE: LF_E_IP @@ -160,6 +167,51 @@ enum LexFloatStatusCodes */ LF_E_IP = 60, + /* + CODE: LF_E_INVALID_PERMISSION_FLAG + + MESSAGE: Invalid permission flag. + */ + LF_E_INVALID_PERMISSION_FLAG = 61, + + /* + CODE: LF_E_OFFLINE_FLOATING_LICENSE_NOT_ALLOWED + + MESSAGE: Offline floating license is not allowed for per-instance leasing strategy. + */ + LF_E_OFFLINE_FLOATING_LICENSE_NOT_ALLOWED = 62, + + /* + CODE: LF_E_MAX_OFFLINE_LEASE_DURATION_EXCEEDED + + MESSAGE: Maximum offline lease duration exeeded. + */ + LF_E_MAX_OFFLINE_LEASE_DURATION_EXCEEDED = 63, + + /* + CODE: LF_E_ALLOWED_OFFLINE_FLOATING_CLIENTS_LIMIT_REACHED + + MESSAGE: Allowed offline floating clients limit reached. + */ + LF_E_ALLOWED_OFFLINE_FLOATING_CLIENTS_LIMIT_REACHED = 64, + + /* + CODE: LF_E_WMIC + + MESSAGE: Fingerprint couldn't be generated because Windows Management + Instrumentation (WMI) service has been disabled. This error is specific + to Windows only. + */ + LF_E_WMIC = 65, + + /* + CODE: LF_E_MACHINE_FINGERPRINT + + MESSAGE: Machine fingerprint has changed since activation. + */ + LF_E_MACHINE_FINGERPRINT = 66, + + /* CODE: LF_E_CLIENT From 8d8b7de0c077ab4b4825c7f750039f8b19c6c63a Mon Sep 17 00:00:00 2001 From: muneebkq Date: Tue, 6 Aug 2024 10:22:18 +0530 Subject: [PATCH 16/18] feat: add LF_E_PROXY_NOT_TRUSTED --- lexfloatclient/LexFloatStatusCodes.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lexfloatclient/LexFloatStatusCodes.h b/lexfloatclient/LexFloatStatusCodes.h index d4b2476..554f3ab 100644 --- a/lexfloatclient/LexFloatStatusCodes.h +++ b/lexfloatclient/LexFloatStatusCodes.h @@ -114,7 +114,7 @@ enum LexFloatStatusCodes /* CODE: LF_E_METADATA_VALUE_LENGTH - MESSAGE: Metadata value length is more than 256 characters. + MESSAGE: Metadata value length is more than 4096 characters. */ LF_E_METADATA_VALUE_LENGTH = 53, @@ -210,8 +210,14 @@ enum LexFloatStatusCodes MESSAGE: Machine fingerprint has changed since activation. */ LF_E_MACHINE_FINGERPRINT = 66, - - + + /* + * CODE: LF_E_PROXY_NOT_TRUSTED + * + * MESSAGE: Request blocked due to untrusted proxy. + */ + LF_E_PROXY_NOT_TRUSTED = 67, + /* CODE: LF_E_CLIENT From 3679f3a200304d463d7c2841bca86477c9730817 Mon Sep 17 00:00:00 2001 From: muneebkq Date: Tue, 6 Aug 2024 10:35:28 +0530 Subject: [PATCH 17/18] feat: add error code --- lexfloatstatus_codes.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lexfloatstatus_codes.go b/lexfloatstatus_codes.go index 00b941a..55cfdc5 100644 --- a/lexfloatstatus_codes.go +++ b/lexfloatstatus_codes.go @@ -96,6 +96,9 @@ const ( // Machine fingerprint has changed since activation. LF_E_MACHINE_FINGERPRINT int = 66 + // Request blocked due to untrusted proxy. + LF_E_PROXY_NOT_TRUSTED int = 67 + // Client error. LF_E_CLIENT int = 70 From 023ffb740a864fe7e79aa73f16175a81d46b545a Mon Sep 17 00:00:00 2001 From: muneebkq Date: Tue, 6 Aug 2024 11:18:30 +0530 Subject: [PATCH 18/18] feat: add getHostConfig --- lexfloatclient.go | 34 +++++++++++++++++++++++++++++++++ lexfloatclient/LexFloatClient.h | 15 +++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/lexfloatclient.go b/lexfloatclient.go index 69bfc43..94cc956 100644 --- a/lexfloatclient.go +++ b/lexfloatclient.go @@ -13,9 +13,17 @@ void floatingLicenseCallbackCgoGateway(int status); */ import "C" import ( + "encoding/json" + "strings" "unsafe" ) + +type HostConfig struct { + MaxOfflineLeaseDuration int `json:"maxOfflineLeaseDuration"` +} + + type callbackType func(int) const ( @@ -389,6 +397,32 @@ 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() diff --git a/lexfloatclient/LexFloatClient.h b/lexfloatclient/LexFloatClient.h index e076c73..4f6054d 100644 --- a/lexfloatclient/LexFloatClient.h +++ b/lexfloatclient/LexFloatClient.h @@ -146,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()