![]() |
Zentitle SDK and Library
|
Pseudo-code for Nalpeiron Licensing using a license code, including
calls that provide basic info about various licensing analytics.
See C codekit, and here, for actual implementation details.
Pseudo-code docs in this series, illustrating various capabilities:
1) License Code Basics
2) Library Info Calls
3) Licensing Features
4) Licensing Analytics (this page)
5) Account Based Licensing (ABL) Basics
Library calls below are clickable; HOVER over comments or code for important tooltips.
// Library security constants #define XAUTH 111 #define YAUTH 555 #define ZAUTH 333
#define CUSTID 4321 #define PRODID 123 // last 5 digits of full ProductID, excluding any leading zeros
// Location of the licensing library #define LIBPATH "/full/path/to/mylibrary.so"
// Directory where cache, license, log, and info files are stored #define WORKDIR "/my/workdir"
// Logging level #define LOGLEVEL "4"
// License code given to your customer #define LICENSECODE "432100001817930859"
main() { // 'security' is used along with the authentication values stamped into the // library to create a unique offset that is added to all returns (except // library open and Nalpeiron Analytics calls). Using a random number for // 'security' ensures that the offset is different for every run of your // software. security = 1 + (unsigned int)(500.0 * rand() / (RAND_MAX + 1.0)); offset = XAUTH + ((security * YAUTH) % ZAUTH);
// Load library libHandle = dlopen(LIBPATH, RTLD_LOCAL | RTLD_LAZY);
// Open and initialize library returnValue = xxxNalpLibOpen(xmlParams, libHandle); // test return value, see code kits
// Validate the library returnValue = xxxNSLValidateLibrary(custID, prodID, libHandle); returnValue = returnValue - offset; // test return value, see code kits
// Check license status (returned in licenseStatus) returnValue = xxxNSLGetLicenseStatus(licenseStatus, libHandle); returnValue = returnValue - offset; // test return value and licenseStatus, see code kits
if ((returnValue < 0) || (licenseStatus <= 0)) // need to renew (reset lease) or get a license { returnValue = xxxNSLObtainLicense(LICENSECODE, licenseStatus, NULL, NULL, libHandle); returnValue = returnValue - offset; // test return value and licenseStatus, see code kits }
// If the application has a valid license, app execution may proceed. // If the license has a finite lease period (typically hours, or days), // the license status will have to be checked periodically. The simplest // method is to set a lease period of one day, and just check license // status at app startup as above (assumes app is started/stopped // once per day). See License Code Basics for another approach.
ANALYTICS // 1) Record the startup and shutdown of an application. // 2) Record the login and logout of a user. // 3) Record the beginning and ending of feature use. // 4) Record an exception. // 5) Get and set privacy setting. // 6) Record systen information. // 7) Send any cached information to the server. // 8) Get simple statistics from the Analytics Library.
// Record application start time. returnValue = xxxNSAAppStart(nsaName, nsaClientData, transID, libHandle); // test return value, see code kits
// Record login time for user. returnValue = xxxNSALogin(nsaName, nsaClientData, transID, libHandle); // test return value, see code kits
// Record start time for use of feature. returnValue = xxxNSAFeatureStart(nsaName, featureCode, nsaClientData, transID, libHandle); // test return value, see code kits
// Record custom diagnostic information. returnValue = xxxNSAException(nsaName, exceptionCode, description, nsaClientData, transID, libHandle); // test return value, see code kits
// Get privacy setting. returnValue = xxxNSAGetPrivacy(libHandle); // return value: 0 - no privacy, 1 - privacy enabled
// Record system information. returnValue = xxxdsoNSASysInfo(nsaName, appLang, version, edition, build, licenseStatus, nsaClientData, transID, libHandle); // test return value
// Send any cached info to server. returnValue = xxxNSASendCache(nsaName, transID, libHandle); // test return value, see code kits
// Return status information from the NSA library. returnValue = xxxNSAGetStats(nsaStats, libHandle); // test return value, see code kits
// Don't forget to call matching analytics calls for app startup (shutdown), login (logout), and begin (end) feature use.
// Return a concurrent (cloud) or network license just before the application exits returnValue = xxxNSLReturnLicense(LICENSECODE, licenseStatus, libHandle); returnValue = returnValue - offset;
// Close the library just before the application exits returnValue = xxxNalpLibClose(libHandle); // see code kits for additional cleanup
}