LicenseSpring C++ SDK
Easily add Software Licensing to your application
LicenseHandler.h
Go to the documentation of this file.
1#ifndef LS_C_LICENSE_HANDLER_H
2#define LS_C_LICENSE_HANDLER_H
3
4#include "Configuration.h"
5#include "ProductDetails.h"
6#include "Customer.h"
7#include "InstallationFile.h"
8#include "LicenseFeature.h"
9#include "LicenseID.h"
10#include <stdint.h>
11
12#ifdef __cplusplus
13extern "C"
14{
15#endif
16
17 LS_API typedef struct LSCustomField
18 {
19 char *name;
20 char *value;
24
25 // handler can be casted to LSLicenseHandler*
26 LS_API typedef void (*LSWatchdogCallback)(
27 const char *message, enum LSErrorCode errorCode, void *handler);
28
29 LS_API typedef struct LSLicenseHandler
30 {
31 // current configuration if present gets deleted automatically
32 void (*reconfigure)(struct LSLicenseHandler *self, struct LSConfiguration *config);
33
34 // ---------- Requests to the LicenseSpring backend ----------
35 bool (*isOnline)(struct LSLicenseHandler *self);
36 LSProductDetails *(*getProductDetailsWithCustomFieldsAndEnv)(struct LSLicenseHandler *self,
37 bool includeLatestVersion, bool includeCustomFields, const char *env);
38 LSProductDetails *(*getProductDetails)(
39 struct LSLicenseHandler *self, bool includeLatestVersion);
41 struct LSLicenseHandler *self, LSCustomer *user, const char *licensePolicy);
43 struct LSLicenseHandler *self, const char *userEmail);
44 const char *(*getSSOUrl)(
45 struct LSLicenseHandler *self, const char *accountCode, bool useAuthCode);
46 void (*activateLicense)(struct LSLicenseHandler *self, struct LSLicenseID licenseID);
47 void (*activateLicenseViaSSO)(struct LSLicenseHandler *self, const char *authData,
48 const char *accountCode, bool useAuthCode);
49 bool (*deactivateLicense)(struct LSLicenseHandler *self);
50 bool (*changePassword)(struct LSLicenseHandler *self, const char *password,
51 const char *newPassword, const char *user);
52 LSInstallationFile *(*checkLicense)(struct LSLicenseHandler *self);
53 LSInstallationFile *(*checkLicenseEx)(struct LSLicenseHandler *self, const char *channel,
54 const char *env, bool includeExpiredFeatures);
55 int (*getVersionList)(struct LSLicenseHandler *self, struct LSLicenseID licenseID,
56 int *lengths, char **versionList);
57 int (*getVersionListEx)(struct LSLicenseHandler *self, struct LSLicenseID licenseID,
58 const char *channel, const char *env, int *lengths, char **versionList);
59 LSInstallationFile *(*getInstallFile)(
60 struct LSLicenseHandler *self, struct LSLicenseID licenseID, const char *version);
61 LSInstallationFile *(*getInstallFileEx)(struct LSLicenseHandler *self,
62 struct LSLicenseID licenseID, const char *version, const char *channel,
63 const char *env);
65 struct LSLicenseHandler *self, struct LSCustomField *data, int dataSize);
66 void (*syncConsumption)(struct LSLicenseHandler *self);
67 void (*syncFeatureConsumption)(struct LSLicenseHandler *self, const char *featureCode);
69 void (*borrowFloatingLicense)(struct LSLicenseHandler *self, uint32_t hours, uint32_t days);
71 struct LSLicenseHandler *self, uint32_t hours, uint32_t days, const char *password);
73 struct LSLicenseHandler *self, const char *borrowEndDateTime);
75 struct LSLicenseHandler *self, const char *borrowEndDateTime, const char *password);
78 struct LSLicenseHandler *self, const char *featureCode, bool addToWatchdog);
79 void (*releaseFloatingFeature)(struct LSLicenseHandler *self, const char *featureCode);
80 const char *(*getAirGapActivationCode)(
81 struct LSLicenseHandler *self, const char *initializationCode, const char *licenseKey);
82 const char *(*getAirGapDeactivationCode)(
83 struct LSLicenseHandler *self, const char *initializationCode);
84 // ------------------------------------------------------------
85
86 // -------- Local license management and helper methods -------
87 bool (*isInitialized)(struct LSLicenseHandler *self);
88 bool (*isLicenseExists)(struct LSLicenseHandler *self);
89 void (*updateConsumption)(struct LSLicenseHandler *self, int value, bool saveLicense);
91 struct LSLicenseHandler *self, const char *featureCode, int value, bool saveLicense);
92 void (*checkLicenseLocal)(struct LSLicenseHandler *self, bool verifySignature);
93 void (*clearLocalStorage)(struct LSLicenseHandler *self);
96 struct LSLicenseHandler *self, LSWatchdogCallback callback, unsigned long timeout);
100 struct LSLicenseHandler *self, LSWatchdogCallback callback, unsigned long timeout);
103 void (*relinkLicense)(struct LSLicenseHandler *self,
104 enum DeviceIDAlgorithm deviceIdAlgorithm, const char *userPassword);
105 const wchar_t *(*getDataLocation)(struct LSLicenseHandler *self);
106 void (*setDataLocation)(struct LSLicenseHandler *self, const wchar_t *path);
107 const wchar_t *(*getLicenseFileName)(struct LSLicenseHandler *self);
108 void (*setLicenseFileName)(struct LSLicenseHandler *self, const wchar_t *name);
109 // ------------------------------------------------------------
110
111 // ---------------- Offline license management ----------------
112 const wchar_t *(*createOfflineActivationFile)(struct LSLicenseHandler *self,
113 struct LSLicenseID licenseID, const wchar_t *activationRequestFile);
115 struct LSLicenseHandler *self, const wchar_t *activationResponseFile);
116 const wchar_t *(*deactivateLicenseOffline)(
117 struct LSLicenseHandler *self, const wchar_t *deactivationRequestFile);
119 struct LSLicenseHandler *self, const wchar_t *path, bool resetConsumption);
120 void (*activateAirGapLicense)(struct LSLicenseHandler *self, const char *confirmationCode,
121 const wchar_t *policyFile, const char *licenseKey, unsigned long policyId);
123 struct LSLicenseHandler *self, const char *confirmationCode);
124 // ------------------------------------------------------------
125
126 // ----------------------- License data -----------------------
127 bool (*isLicenseValid)(struct LSLicenseHandler *self);
128 bool (*isLicenseTrial)(struct LSLicenseHandler *self);
130 bool (*isLicenseActive)(struct LSLicenseHandler *self);
131 bool (*isLicenseEnabled)(struct LSLicenseHandler *self);
132 bool (*isLicenseExpired)(struct LSLicenseHandler *self);
135 bool (*isLicenseFloating)(struct LSLicenseHandler *self);
136 bool (*isLicenseBorrowed)(struct LSLicenseHandler *self);
141 struct tm (*gracePeriodEndDateTime)(struct LSLicenseHandler *self);
142 struct tm (*gracePeriodEndDateTimeUTC)(struct LSLicenseHandler *self);
144
145 struct LSLicenseID (*getLicenseID)(struct LSLicenseHandler *self);
146 const char *(*getLicenseKey)(struct LSLicenseHandler *self);
147 const char *(*getLicenseUser)(struct LSLicenseHandler *self);
148 uint64_t (*getLicenseServerId)(struct LSLicenseHandler *self);
149 const char *(*getLicenseStatusStr)(struct LSLicenseHandler *self);
150 const char *(*getLicenseStartDate)(struct LSLicenseHandler *self);
151 const char *(*getLicenseMetadata)(struct LSLicenseHandler *self);
152 const char *(*getOrderStoreId)(struct LSLicenseHandler *self);
153 enum LSLicenseType (*getLicenseType)(struct LSLicenseHandler *self);
154 struct tm (*getLicenseExpiryDate)(struct LSLicenseHandler *self);
155 struct tm (*getLicenseExpiryDateUtc)(struct LSLicenseHandler *self);
156 struct tm (*getLicenseMaintenancePeriod)(struct LSLicenseHandler *self);
157 struct tm (*getLicenseMaintenancePeriodUtc)(struct LSLicenseHandler *self);
158 struct tm (*getLicenseLastCheckDate)(struct LSLicenseHandler *self);
159 struct tm (*getLicenseLastCheckDateUtc)(struct LSLicenseHandler *self);
160 struct tm (*getLicenseFloatingEndDateTime)(struct LSLicenseHandler *self);
161 struct tm (*getLicenseFloatingEndDateTimeUtc)(struct LSLicenseHandler *self);
162 int (*getDaysRemaining)(struct LSLicenseHandler *self);
165 LSCustomer *(*getLicenseOwner)(struct LSLicenseHandler *self);
167 struct LSLicenseFeature *(*getLicenseFeature)(
168 struct LSLicenseHandler *self, const char *featureCode);
169 int (*getLicenseFeatures)(struct LSLicenseHandler *self, struct LSLicenseFeature *features);
171 int (*getLicenseCustomFields)(struct LSLicenseHandler *self, struct LSCustomField *fields);
172 unsigned long (*getLicenseTimesActivated)(struct LSLicenseHandler *self);
173 unsigned long (*getLicenseMaxActivations)(struct LSLicenseHandler *self);
174 unsigned long (*getLicenseTransferCount)(struct LSLicenseHandler *self);
178 unsigned long (*getLicensePolicyId)(struct LSLicenseHandler *self);
179
180 // Meaningful only for Subscription license
182 struct tm (*validityWithGracePeriod)(struct LSLicenseHandler *self);
183 struct tm (*validityWithGracePeriodUtc)(struct LSLicenseHandler *self);
184
185 // Meaningful only for Consumption license
194
195 // Meaningful only for Floating license
196 unsigned long (*getLicenseFloatingTimeout)(struct LSLicenseHandler *self);
197 unsigned long (*getLicenseFloatingInUseCount)(struct LSLicenseHandler *self);
198 unsigned long (*getLicenseMaxFloatingUsers)(struct LSLicenseHandler *self);
199 unsigned long (*getMaxBorrowTime)(struct LSLicenseHandler *self);
200 // ------------------------------------------------------------
201
202 // ---------------------- Error handling ----------------------
203 bool (*wasError)(struct LSLicenseHandler *self);
204 enum LSErrorCode (*getLastError)(struct LSLicenseHandler *self);
205 const char *(*getLastErrorMsg)(struct LSLicenseHandler *self);
209 bool (*isNoInternetError)(struct LSLicenseHandler *self);
214 bool (*isHardwareIDError)(struct LSLicenseHandler *self);
215 bool (*isGeneralError)(struct LSLicenseHandler *self);
218 *self); // No Internet, network timeout and server errors can be ignored
219 // ------------------------------------------------------------
220
221 void *inner;
222
224
226
227 // LicenseHandler takes ownership of Configuration, so do not free it
229
230 // This function will also free current configuration, you do not need to explicitly call
231 // FreeLSConfiguration
233
234#ifdef __cplusplus
235} // end extern "C"
236#endif
237
238#endif // LS_C_LICENSE_HANDLER_H
#define LS_API
Definition: APIDef.h:23
LS_API typedef void(* LSWatchdogCallback)(const char *message, enum LSErrorCode errorCode, void *handler)
LS_API void FreeLSLicenseHandler(struct LSLicenseHandler *handler)
LS_API struct LSCustomField LSCustomField
LS_API struct LSLicenseHandler LSLicenseHandler
LS_API struct LSLicenseHandler * CreateLSLicenseHandler(struct LSConfiguration *config)
LSConsumptionPeriod
Consumption period.
Definition: PODTypes.h:36
DeviceIDAlgorithm
Type of Device ID algorithm used by the SDK.
Definition: PODTypes.h:119
LSLicenseType
License type.
Definition: PODTypes.h:26
LSErrorCode
LicenseSpring Error codes enum.
Definition: PODTypes.h:46
bool(* isLicenseFloating)(struct LSLicenseHandler *self)
int(* getLicenseTotalConsumption)(struct LSLicenseHandler *self)
bool(* isNoInternetError)(struct LSLicenseHandler *self)
bool(* isLicenseVMAllowed)(struct LSLicenseHandler *self)
bool(* isLicenseEnabled)(struct LSLicenseHandler *self)
struct tm(* validityWithGracePeriodUtc)(struct LSLicenseHandler *self)
int(* getDaysPassedSinceLastCheck)(struct LSLicenseHandler *self)
bool(* isGeneralError)(struct LSLicenseHandler *self)
bool(* isActivationFailed)(struct LSLicenseHandler *self)
int(* getDaysRemaining)(struct LSLicenseHandler *self)
bool(* isLicenseTrial)(struct LSLicenseHandler *self)
bool(* isInitializationError)(struct LSLicenseHandler *self)
bool(* isSubscriptionGracePeriodStarted)(struct LSLicenseHandler *self)
struct tm(* getLicenseFloatingEndDateTimeUtc)(struct LSLicenseHandler *self)
bool(* isInitialized)(struct LSLicenseHandler *self)
enum LSErrorCode(* getLastError)(struct LSLicenseHandler *self)
bool(* canIgnoreError)(struct LSLicenseHandler *self)
bool(* isLicenseBorrowed)(struct LSLicenseHandler *self)
bool(* isLicenseNegativeConsumptionAllowed)(struct LSLicenseHandler *self)
void(* releaseFloatingLicense)(struct LSLicenseHandler *self)
struct tm(* getLicenseExpiryDate)(struct LSLicenseHandler *self)
void(* activateLicense)(struct LSLicenseHandler *self, struct LSLicenseID licenseID)
unsigned long(* getLicenseFloatingTimeout)(struct LSLicenseHandler *self)
int(* getLicenseCustomFields)(struct LSLicenseHandler *self, struct LSCustomField *fields)
bool(* isLicenseAirGapped)(struct LSLicenseHandler *self)
bool(* isLicenseNotFoundError)(struct LSLicenseHandler *self)
void(* checkLicenseLocal)(struct LSLicenseHandler *self, bool verifySignature)
void(* registerFloatingLicense)(struct LSLicenseHandler *self)
bool(* isGracePeriodStarted)(struct LSLicenseHandler *self)
bool(* isHardwareIDError)(struct LSLicenseHandler *self)
struct tm(* getLicenseFloatingEndDateTime)(struct LSLicenseHandler *self)
void(* clearLocalStorage)(struct LSLicenseHandler *self)
bool(* isLicenseValid)(struct LSLicenseHandler *self)
int(* getVersionList)(struct LSLicenseHandler *self, struct LSLicenseID licenseID, int *lengths, char **versionList)
struct LSLicenseID(* getTrialLicense)(struct LSLicenseHandler *self, LSCustomer *user, const char *licensePolicy)
void(* stopLicenseWatchdog)(struct LSLicenseHandler *self)
void(* setDataLocation)(struct LSLicenseHandler *self, const wchar_t *path)
uint64_t(* getLicenseServerId)(struct LSLicenseHandler *self)
void(* borrowFloatingLicenseTill)(struct LSLicenseHandler *self, const char *borrowEndDateTime)
enum LSConsumptionPeriod(* getLicenseConsumptionPeriod)(struct LSLicenseHandler *self)
bool(* isLicenseUnlimitedConsumptionAllowed)(struct LSLicenseHandler *self)
struct LSLicenseID(* getLicenseID)(struct LSLicenseHandler *self)
void(* syncFeatureConsumption)(struct LSLicenseHandler *self, const char *featureCode)
struct tm(* getLicenseLastCheckDateUtc)(struct LSLicenseHandler *self)
int(* getLicenseMaxConsumption)(struct LSLicenseHandler *self)
void(* updateFeatureConsumption)(struct LSLicenseHandler *self, const char *featureCode, int value, bool saveLicense)
unsigned long(* getLicenseMaxActivations)(struct LSLicenseHandler *self)
enum LSLicenseType(* getLicenseType)(struct LSLicenseHandler *self)
bool(* isOnline)(struct LSLicenseHandler *self)
unsigned long(* getSubscriptionLicenseGracePeriod)(struct LSLicenseHandler *self)
bool(* deactivateLicense)(struct LSLicenseHandler *self)
bool(* isLicenseStateError)(struct LSLicenseHandler *self)
void(* activateLicenseViaSSO)(struct LSLicenseHandler *self, const char *authData, const char *accountCode, bool useAuthCode)
bool(* isLicenseExists)(struct LSLicenseHandler *self)
struct tm(* getLicenseMaintenancePeriod)(struct LSLicenseHandler *self)
void(* registerFloatingFeature)(struct LSLicenseHandler *self, const char *featureCode, bool addToWatchdog)
int(* getLicenseFeatures)(struct LSLicenseHandler *self, struct LSLicenseFeature *features)
void(* setupLicenseWatchdog)(struct LSLicenseHandler *self, LSWatchdogCallback callback, unsigned long timeout)
int(* getLicenseTransferLimit)(struct LSLicenseHandler *self)
bool(* wasError)(struct LSLicenseHandler *self)
struct tm(* getLicenseMaintenancePeriodUtc)(struct LSLicenseHandler *self)
struct tm(* validityWithGracePeriod)(struct LSLicenseHandler *self)
bool(* isDeviceTransferLimited)(struct LSLicenseHandler *self)
bool(* hasLicenseFeatures)(struct LSLicenseHandler *self)
bool(* isResetLicenseConsumptionEnabled)(struct LSLicenseHandler *self)
bool(* changePassword)(struct LSLicenseHandler *self, const char *password, const char *newPassword, const char *user)
int(* getMaintenanceDaysRemaining)(struct LSLicenseHandler *self)
unsigned long(* getLicenseTimesActivated)(struct LSLicenseHandler *self)
bool(* isNetworkTimeoutError)(struct LSLicenseHandler *self)
void(* resumeFeaturewatchdog)(struct LSLicenseHandler *self)
int(* getLicenseMaxOverages)(struct LSLicenseHandler *self)
bool(* isLicenseFeatureError)(struct LSLicenseHandler *self)
struct tm(* gracePeriodEndDateTimeUTC)(struct LSLicenseHandler *self)
bool(* isDeviceTransferAllowed)(struct LSLicenseHandler *self)
void(* activateAirGapLicense)(struct LSLicenseHandler *self, const char *confirmationCode, const wchar_t *policyFile, const char *licenseKey, unsigned long policyId)
void(* resumeLicenseWatchdog)(struct LSLicenseHandler *self)
bool(* isLicenseOfflineActivated)(struct LSLicenseHandler *self)
void(* deactivateAirGapLicense)(struct LSLicenseHandler *self, const char *confirmationCode)
void(* sendDeviceData)(struct LSLicenseHandler *self, struct LSCustomField *data, int dataSize)
void(* setupFeatureWatchdog)(struct LSLicenseHandler *self, LSWatchdogCallback callback, unsigned long timeout)
bool(* isLicenseExpired)(struct LSLicenseHandler *self)
bool(* isLicenseMaintenanceExpired)(struct LSLicenseHandler *self)
struct tm(* getLicenseLastCheckDate)(struct LSLicenseHandler *self)
unsigned long(* getLicenseMaxFloatingUsers)(struct LSLicenseHandler *self)
void(* stopFeatureWatchdog)(struct LSLicenseHandler *self)
void(* syncConsumption)(struct LSLicenseHandler *self)
bool(* isInternalServerError)(struct LSLicenseHandler *self)
void(* borrowFloatingLicense)(struct LSLicenseHandler *self, uint32_t hours, uint32_t days)
void(* reconfigure)(struct LSLicenseHandler *self, struct LSConfiguration *config)
struct LSLicenseID(* getTrialLicenseByEmail)(struct LSLicenseHandler *self, const char *userEmail)
unsigned long(* getLicenseFloatingInUseCount)(struct LSLicenseHandler *self)
struct LSConfiguration * currentConfig
int(* getVersionListEx)(struct LSLicenseHandler *self, struct LSLicenseID licenseID, const char *channel, const char *env, int *lengths, char **versionList)
void(* borrowFloatingLicenseWithPassword)(struct LSLicenseHandler *self, uint32_t hours, uint32_t days, const char *password)
void(* setLicenseFileName)(struct LSLicenseHandler *self, const wchar_t *name)
int(* gracePeriodHoursRemaining)(struct LSLicenseHandler *self)
int(* getLicenseTrialPeriod)(struct LSLicenseHandler *self)
bool(* isLicenseFileCorrupted)(struct LSLicenseHandler *self)
bool(* hasLicenseCustomFields)(struct LSLicenseHandler *self)
void(* updateConsumption)(struct LSLicenseHandler *self, int value, bool saveLicense)
bool(* isLicenseOveragesAllowed)(struct LSLicenseHandler *self)
unsigned long(* getLicenseTransferCount)(struct LSLicenseHandler *self)
bool(* updateOffline)(struct LSLicenseHandler *self, const wchar_t *path, bool resetConsumption)
void(* borrowFloatingLicenseTillWithPassword)(struct LSLicenseHandler *self, const char *borrowEndDateTime, const char *password)
struct tm(* gracePeriodEndDateTime)(struct LSLicenseHandler *self)
bool(* isLicenseExpiredError)(struct LSLicenseHandler *self)
unsigned long(* getMaxBorrowTime)(struct LSLicenseHandler *self)
void(* releaseFloatingFeature)(struct LSLicenseHandler *self, const char *featureCode)
struct tm(* getLicenseExpiryDateUtc)(struct LSLicenseHandler *self)
void(* relinkLicense)(struct LSLicenseHandler *self, enum DeviceIDAlgorithm deviceIdAlgorithm, const char *userPassword)
void(* activateLicenseOffline)(struct LSLicenseHandler *self, const wchar_t *activationResponseFile)
bool(* isLicenseActive)(struct LSLicenseHandler *self)
unsigned long(* getLicensePolicyId)(struct LSLicenseHandler *self)
const char * user
Definition: LicenseID.h:15