diff --git a/examples/LexActivator.rb b/examples/LexActivator.rb index ebe4d49..de0c090 100644 --- a/examples/LexActivator.rb +++ b/examples/LexActivator.rb @@ -2,7 +2,7 @@ module LexActivator extend FFI::Library - ffi_lib ["LexActivator", "./libLexActivator.so", "#{File.dirname(__FILE__)}/LexActivator.dll"] + ffi_lib ["#{File.dirname(__FILE__)}/libLexActivator.dylib", "./libLexActivator.so", "#{File.dirname(__FILE__)}/LexActivator.dll"] callback :license_callback, [:uint], :void callback :release_update_callback, [:uint], :void @@ -60,6 +60,12 @@ class UserLicense < FFI::Struct :metadata, [Metadata, MAX_METADATA_SIZE] end + class FeatureEntitlement < FFI::Struct + layout :featureName, [:char, BUFFER_SIZE_256], + :featureDisplayName, [:char, BUFFER_SIZE_256], + :value, [:char, BUFFER_SIZE_256] + end + # @method SetProductFile(file_path) # @param [String] file_path # @return [Integer] @@ -252,6 +258,34 @@ class UserLicense < FFI::Struct # @scope class attach_function :GetProductVersionFeatureFlag, :GetProductVersionFeatureFlag, [:string, :pointer, :pointer, :uint], :int + # @method GetLicenseEntitlementSetName(name, length) + # @param [String] name + # @param [Integer] length + # @return [Integer] + # @scope class + attach_function :GetLicenseEntitlementSetName, :GetLicenseEntitlementSetName, [:pointer, :uint], :int + + # @method GetLicenseEntitlementSetDisplayName(displayName, length) + # @param [String] displayName + # @param [Integer] length + # @return [Integer] + # @scope class + attach_function :GetLicenseEntitlementSetDisplayName, :GetLicenseEntitlementSetDisplayName, [:pointer, :uint], :int + + # @method GetFeatureEntitlements(featureEntitlements, length) + # @param [FFI::Pointer(*FeatureEntitlement)] featureEntitlements - Pointer to an array of FeatureEntitlement structs + # @param [Integer] length - The number of FeatureEntitlement structs in the array + # @return [Integer] + # @scope class + attach_function :GetFeatureEntitlements, :GetFeatureEntitlements, [:pointer, :uint], :int + + # @method GetFeatureEntitlement(featureName, featureEntitlement) + # @param [String] featureName - The name of the feature + # @param [FFI::Pointer(*FeatureEntitlement)] featureEntitlement - Pointer to a FeatureEntitlement struct + # @return [Integer] + # @scope class + attach_function :GetFeatureEntitlement, :GetFeatureEntitlement, [:string, :pointer], :int + # @method GetLicenseMetadata(key, value, length) # @param [String] key # @param [String] value @@ -330,9 +364,9 @@ class UserLicense < FFI::Struct # @scope class attach_function :GetLicenseOrganizationAddress, :GetLicenseOrganizationAddress, [:pointer], :int - # @method GetUserLicenses(userLicense, length) - # @param [FFI::Pointer(UserLicense)] userLicense - # @param [Integer] length + # @method GetUserLicenses(userLicenses, length) + # @param [FFI::Pointer(UserLicense)] userLicenses - Pointer to an array of UserLicense structs + # @param [Integer] length - The number of UserLicense structs in the array # @return [Integer] # @scope class attach_function :GetUserLicenses, :GetUserLicenses, [:pointer, :uint], :int diff --git a/examples/LexStatusCodes.rb b/examples/LexStatusCodes.rb index 93cce0c..6bdb957 100644 --- a/examples/LexStatusCodes.rb +++ b/examples/LexStatusCodes.rb @@ -260,6 +260,10 @@ module LexStatusCodes # MESSAGE: Client error. LA_E_CLIENT = 92 + # CODE: LA_E_ACCOUNT_ID + # MESSAGE: Invalid account ID. + LA_E_ACCOUNT_ID = 93 + # CODE: LA_E_LOGIN_TEMPORARILY_LOCKED # MESSAGE: The user account has been temporarily locked for 5 mins due to 5 failed attempts. LA_E_LOGIN_TEMPORARILY_LOCKED = 100 @@ -286,5 +290,21 @@ module LexStatusCodes # CODE: LA_E_FREE_PLAN_ACTIVATION_LIMIT_REACHED # MESSAGE: The free plan has reached its activation limit. - LA_E_INVALID_PERMISSION_FLAG = 106 + LA_E_FREE_PLAN_ACTIVATION_LIMIT_REACHED = 106 + + # CODE: LA_E_FEATURE_ENTITLEMENTS_INVALID + # MESSAGE: Invalid feature entitlements. + LA_E_FEATURE_ENTITLEMENTS_INVALID = 107 + + # CODE: LA_E_FEATURE_ENTITLEMENT_NOT_FOUND + # MESSAGE: The feature entitlement does not exist. + LA_E_FEATURE_ENTITLEMENT_NOT_FOUND = 108 + + # CODE: LA_E_ENTITLEMENT_SET_NOT_LINKED + # MESSAGE: No entitlement set is linked to the license. + LA_E_ENTITLEMENT_SET_NOT_LINKED = 109 + + # CODE: LA_E_LICENSE_NOT_EFFECTIVE + # MESSAGE: The license cannot be activated before its effective date. + LA_E_LICENSE_NOT_EFFECTIVE = 110 end diff --git a/examples/sample.rb b/examples/sample.rb index 24cbdc3..80c709a 100644 --- a/examples/sample.rb +++ b/examples/sample.rb @@ -1,11 +1,12 @@ require "./LexActivator" require "./LexStatusCodes" + # Refer to following link for LexActivator API docs: # https://github.com/cryptlex/lexactivator-c/blob/master/examples/LexActivator.h def init() - # status = LexActivator.SetProductFile("ABSOLUTE_PATH_OF_PRODUCT.DAT_FILE") + status = LexActivator.SetProductData(LexActivator::encode_utf16("PASTE_CONTENT_OF_PRODUCT.DAT_FILE")) if LexStatusCodes::LA_OK != status puts "Error Code: #{status}" @@ -18,7 +19,7 @@ def init() exit(status) end - status = LexActivator.SetAppVersion(LexActivator::encode_utf16("PASTE_YOUR_APP_VERION")) + status = LexActivator.SetReleaseVersion(LexActivator::encode_utf16("1.0.0")) if LexStatusCodes::LA_OK != status puts "Error Code: #{status}" exit(status) @@ -39,10 +40,11 @@ def activate() end status = LexActivator.ActivateLicense() - if LexStatusCodes::LA_OK == status || LexStatusCodes::LA_EXPIRED == status || LexStatusCodes::LA_SUSPENDED == status + if [LexStatusCodes::LA_OK, LexStatusCodes::LA_EXPIRED, LexStatusCodes::LA_SUSPENDED].include?(status) puts "License activated successfully: #{status}" else puts "License activation failed: #{status}" + exit(status) end end @@ -63,6 +65,7 @@ def activate_trial() end end +# License callback (optional) LicenseCallback = FFI::Function.new(:void, [:uint]) do |status| puts "License status: #{status}" end @@ -71,8 +74,9 @@ def activate_trial() puts "Release status: #{status}" end +# Run it init() -# activate() +activate() # uncomment this to activate the license LexActivator.SetLicenseCallback(LicenseCallback) status = LexActivator.IsLicenseGenuine() if LexStatusCodes::LA_OK == status @@ -88,7 +92,6 @@ def activate_trial() email = LexActivator::decode_utf16(buffer.read_string(buffer.size).rstrip) puts "License user email: #{email}" puts "License is genuinely activated!" - # puts "Checking for software release update..." # status = LexActivator.CheckForReleaseUpdate("windows", "1.0.0", "stable", SoftwareReleaseUpdateCallback) # if LexStatusCodes::LA_OK != status @@ -118,3 +121,6 @@ def activate_trial() activate_trial() end end + +puts "Press Enter to exit..." +gets