-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: add user metadata #19
Changes from 2 commits
3c50c0f
375ac99
10abd10
cb359c1
5a1e825
d900f34
01f9128
8f552c9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,11 +18,11 @@ | |
/// The name of the meter attribute. | ||
pub name: String, | ||
/// The number of allowed uses for the meter attribute. | ||
pub allowed_uses: u32, | ||
pub allowed_uses: i64, | ||
/// The total number of uses recorded for the meter attribute. | ||
pub total_uses: u32, | ||
pub total_uses: u64, | ||
/// The gross number of uses for the meter attribute. | ||
pub gross_uses: u32 | ||
pub gross_uses: u64 | ||
} | ||
|
||
/// Represents a product version feature flag. | ||
|
@@ -45,6 +45,15 @@ | |
pub current_mode: String | ||
} | ||
|
||
/// Represents a metadata | ||
#[derive(Debug, Deserialize, Default)] | ||
pub struct Metadata { | ||
/// The key of the metadata. | ||
pub key: String, | ||
/// The value of the metadata. | ||
pub value: String, | ||
} | ||
|
||
/// Represents an organization address. | ||
#[derive(Debug, Deserialize, Default)] | ||
pub struct OrganizationAddress { | ||
|
@@ -70,15 +79,17 @@ | |
pub struct UserLicense { | ||
/// The allowed activations count of a license. | ||
#[serde(rename = "allowedActivations")] | ||
pub allowed_activations: u32, | ||
pub allowed_activations: i64, | ||
/// The allowed deactivations count of a license. | ||
#[serde(rename = "allowedDeactivations")] | ||
pub allowed_deactivations: u32, | ||
pub allowed_deactivations: i64, | ||
/// The license key. | ||
pub key: String, | ||
/// The license type. | ||
#[serde(rename = "type")] | ||
pub license_type: String | ||
pub license_type: String, | ||
/// Optional metadata associated with the license. | ||
pub metadata: Vec<Metadata> | ||
} | ||
|
||
/// Represents various permission flags. | ||
|
@@ -96,7 +107,41 @@ | |
} | ||
|
||
// --------------- Setter functions ------------------------ | ||
|
||
Check warning on line 110 in src/lib.rs GitHub Actions / test (macos-latest)
Check warning on line 110 in src/lib.rs GitHub Actions / test (macos-latest)
Check warning on line 110 in src/lib.rs GitHub Actions / test (ubuntu-latest)
|
||
/// Sets the absolute path of the Product.dat file. | ||
/// | ||
Check warning on line 112 in src/lib.rs GitHub Actions / test (macos-latest)
Check warning on line 112 in src/lib.rs GitHub Actions / test (macos-latest)
Check warning on line 112 in src/lib.rs GitHub Actions / test (ubuntu-latest)
|
||
/// This function must be called on every start of your program before any other functions are called. | ||
/// | ||
Check warning on line 114 in src/lib.rs GitHub Actions / test (macos-latest)
Check warning on line 114 in src/lib.rs GitHub Actions / test (ubuntu-latest)
|
||
/// | ||
/// # Arguments | ||
/// | ||
Check warning on line 117 in src/lib.rs GitHub Actions / test (macos-latest)
Check warning on line 117 in src/lib.rs GitHub Actions / test (ubuntu-latest)
|
||
/// * `file_path` - absolute path of the product file (Product.dat). | ||
/// | ||
/// # Returns | ||
/// | ||
/// Returns `Ok(())` if the product path is set successfully, If an error occurs, an `Err` containing the `LexActivatorError`is returned. | ||
|
||
|
||
pub fn set_product_file(file_path: String) -> Result<(), LexActivatorError> { | ||
|
||
let status: i32; | ||
#[cfg(windows)] | ||
{ | ||
let file_path = to_utf16(file_path); | ||
status = unsafe { SetProductFile(file_path.as_ptr()) }; | ||
} | ||
#[cfg(not(windows))] | ||
{ | ||
let file_path = string_to_cstring(file_path)?; | ||
status = unsafe { SetProductFile(file_path.as_ptr()) }; | ||
} | ||
if status == 0 { | ||
Ok(()) | ||
} else { | ||
return Err(LexActivatorError::from(status)); | ||
} | ||
} | ||
|
||
/// Embeds the Product.dat file in the application. | ||
/// | ||
/// This function must be called on every start of your program before any other functions are called. | ||
|
@@ -113,7 +158,7 @@ | |
|
||
|
||
pub fn set_product_data(product_data: String) -> Result<(), LexActivatorError> { | ||
|
||
let status: i32; | ||
#[cfg(windows)] | ||
{ | ||
|
@@ -229,6 +274,28 @@ | |
let c_enable: c_uint = enable as c_uint; | ||
unsafe { SetDebugMode(c_enable) }; | ||
} | ||
|
||
/// Enables or disables in-memory caching for LexActivator. | ||
/// | ||
/// This function is designed to control caching behavior to suit specific application requirements. | ||
/// | ||
/// Caching is enabled by default to enhance performance. | ||
/// | ||
/// Disabling caching is recommended in environments where multiple processes access the same license on a | ||
/// | ||
/// single machine and require real-time updates to the license state. | ||
/// | ||
/// # Arguments | ||
/// | ||
/// * `mode` - False or True to disable or enable caching. | ||
/// | ||
/// Returns `Ok(())` if mode is set successfully. | ||
|
||
pub fn set_cache_mode(mode: bool) -> c_uint { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @muneebkq Please follow the Result return pattern for set_cache_mode(). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Jsdoc? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. result pattern followed |
||
let c_mode: c_uint = if mode { 1 } else { 0 }; | ||
unsafe { SetCacheMode(c_mode) } | ||
} | ||
|
||
|
||
/// In case you don't want to use the LexActivator's advanced device fingerprinting algorithm, this function can be used to set a custom device fingerprint. | ||
/// | ||
|
@@ -353,14 +420,14 @@ | |
/// | ||
/// # Arguments | ||
/// | ||
/// * `lease_duration` - The lease duration in seconds. | ||
/// * `lease_duration` - The lease duration in seconds. A value of -1 indicates unlimited lease duration. | ||
/// | ||
/// # Returns | ||
/// | ||
/// Returns `Ok(())` if the activation lease duration is set successfully, If an error occurs, an `Err` containing the `LexActivatorError`is returned. | ||
|
||
pub fn set_activation_lease_duration(lease_duration: u32) -> Result<(), LexActivatorError> { | ||
let c_lease_duration: c_uint = lease_duration as c_uint; | ||
pub fn set_activation_lease_duration(lease_duration: i64) -> Result<(), LexActivatorError> { | ||
let c_lease_duration: c_longlong = lease_duration as c_longlong; | ||
let status = unsafe { SetActivationLeaseDuration(c_lease_duration) }; | ||
if status == 0 { | ||
Ok(()) | ||
|
@@ -433,6 +500,37 @@ | |
} | ||
} | ||
|
||
/// Sets the current app version of your application. | ||
/// The app version appears along with the activation details in dashboard. | ||
/// It is also used to generate app analytics. | ||
|
||
/// # Arguments | ||
/// | ||
/// * `app_version` - string of maximum length 256 characters. | ||
/// | ||
/// # Returns | ||
/// | ||
/// Returns `Ok(())` if the release version is set successfully, If an error occurs, an `Err` containing the `LexActivatorError`is returned. | ||
|
||
pub fn set_app_version(app_version: String) -> Result<(), LexActivatorError> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @muneebkq There is no need for adding set_app_version(). This function has been deprecated as we already have the set_release_version(). |
||
let status: i32; | ||
#[cfg(windows)] | ||
{ | ||
let c_app_version = to_utf16(app_version); | ||
status = unsafe { SetAppVersion(c_app_version.as_ptr()) }; | ||
} | ||
#[cfg(not(windows))] | ||
{ | ||
let c_app_version = string_to_cstring(app_version)?; | ||
status = unsafe { SetAppVersion(c_app_version.as_ptr()) }; | ||
} | ||
if status == 0 { | ||
Ok(()) | ||
} else { | ||
return Err(LexActivatorError::from(status)); | ||
} | ||
} | ||
|
||
/// Sets the release version. | ||
/// | ||
/// # Arguments | ||
|
@@ -834,9 +932,9 @@ | |
pub fn get_license_meterattribute(name: String) -> Result<LicenseMeterAttribute, LexActivatorError> { | ||
let status: i32; | ||
let meter_attribute_name: String = name.clone(); | ||
let mut c_allowed_uses: c_uint = 0; | ||
let mut c_total_uses: c_uint = 0; | ||
let mut c_gross_uses: c_uint = 0; | ||
let mut c_allowed_uses: c_longlong = 0; | ||
let mut c_total_uses: c_ulonglong = 0; | ||
let mut c_gross_uses: c_ulonglong = 0; | ||
#[cfg(windows)] | ||
{ | ||
let c_name = to_utf16(name); | ||
|
@@ -893,10 +991,10 @@ | |
/// | ||
/// # Returns | ||
/// | ||
/// Returns `Ok(u32)` with the number of allowed activations if it is retrieved successfully, If an error occurs, an `Err` containing the `LexActivatorError`is returned. | ||
/// Returns `Ok(i64)` with the number of allowed activations if it is retrieved successfully, If an error occurs, an `Err` containing the `LexActivatorError`is returned. | ||
|
||
pub fn get_license_allowed_activations() -> Result<u32, LexActivatorError> { | ||
let mut allowed_activations: c_uint = 0; | ||
pub fn get_license_allowed_activations() -> Result<i64, LexActivatorError> { | ||
let mut allowed_activations: c_longlong = 0; | ||
let status = unsafe { GetLicenseAllowedActivations(&mut allowed_activations) }; | ||
if status == 0 { | ||
Ok(allowed_activations) | ||
|
@@ -925,10 +1023,10 @@ | |
/// | ||
/// # Returns | ||
/// | ||
/// Returns `Ok(u32)` with the number of allowed deactivations if it is retrieved successfully, If an error occurs, an `Err` containing the `LexActivatorError`is returned. | ||
/// Returns `Ok(i64)` with the number of allowed deactivations if it is retrieved successfully, If an error occurs, an `Err` containing the `LexActivatorError`is returned. | ||
|
||
pub fn get_license_allowed_deactivations() -> Result<u32, LexActivatorError> { | ||
let mut allowed_deactivations: c_uint = 0; | ||
pub fn get_license_allowed_deactivations() -> Result<i64, LexActivatorError> { | ||
let mut allowed_deactivations: c_longlong = 0; | ||
let status = unsafe { GetLicenseAllowedDeactivations(&mut allowed_deactivations) }; | ||
if status == 0 { | ||
Ok(allowed_deactivations) | ||
|
@@ -1243,7 +1341,7 @@ | |
|
||
pub fn get_user_licenses() -> Result<Vec<UserLicense>, LexActivatorError> { | ||
let status: i32; | ||
const LENGTH: usize = 256; | ||
const LENGTH: usize = 1024; | ||
let user_licenses_json: String; | ||
#[cfg(windows)] | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@muneebkq Remove this function, as we have deprecated SetProductFile(), so we will not include it in our rust wrapper.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed