Grace Period Warnings in RLM-Based Applications

Summary

RLM does not natively support grace periods within the license file itself. Instead, grace period notifications can be achieved through the RLM API by adding logic that monitors expiration dates and notifies users accordingly. This article covers the recommended implementation approach, along with a supporting code example.

Recommended approach

Typical RLM implementation:

Warning before expiration with rlm_product_exp() (Pre-Checkout) or rlm_license_exp_days() (Post-Checkout) 

Other implementation options:

  • Disable certain features in app
  • Making the UI read-only
  • Redirecting to a renewal/upgrade page on login

Useful RLM API calls

The following API calls are typically used to implement the notification workflow. It’s important to distinguish when these calls should be made:

Pre-Checkout - all calls documented in rlm_products()

  • rlm_products(): Returns the list of products that can be checked out.
  • rlm_product_first(): Sets the products pointer to first item in the list
  • rlm_product_next(): Sets the product pointer to each subsequent item, returns 0 if there is another product in the list, or -1 if there are no more products in the list.
  • rlm_products_exp(): Returns the expiration date of a product.

Post-Checkout

  • rlm_checkout(): Checks out the license and returns an RLM_LICENSE handle.
  • rlm_license_stat(): Checks whether checkout succeeded and returns the license status.
  • rlm_license_exp_days(): Returns the number of days until expiration; use this for messages such as “Your license expires in N days.”
  • rlm_errstring(): Translates an RLM status code into readable text for logs or user-facing messages.
  • rlm_checkin(): Releases the license handle when the application is done with it.

Example implementation pattern

A common implementation is:

  • Call rlm_checkout().
  • Call rlm_license_stat() on the returned handle.
  • If checkout succeeds, call rlm_license_exp_days() and notify the user when the value is below your chosen threshold.

 If you want to check the expiration of a license without making a check-out, the implementation pattern would be:

  • Call rlm_products() and loop through each item(license) with
    • rlm_product_first()
    • rlm_product_next()
  • Call rlm_product_exp() for each item to determine whether the value Is below your chosen threshold.

Minimal code example – Post-Checkout

Note: RLM_HANDLE is defined as rh in this example and is assumed to already be initialized with rlm_init()

RLM_LICENSE lic;
int status;
int days;

lic = rlm_checkout(rh, "product", "1.0", 1);
status = rlm_license_stat(lic);

if (status == 0) {
days = rlm_license_exp_days(lic);
if (days > 0 && days <= 14) {
printf("Warning: license expires in %d day(s)\n", days);
}
} else {
char msg[RLM_ERRSTRING_MAX];
rlm_errstring_num(status, msg);
printf("License checkout failed: %s\n", msg);
}