LicenseSpring C++ SDK 7.27.0
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
11#ifdef __cplusplus
12extern "C" {
13#endif
14
15 LS_API typedef struct LSCustomField
16 {
17 char* name;
18 char* value;
22
23 // handler can be casted to LSLicenseHandler*
24 LS_API typedef void ( *LSWatchdogCallback )( const char* message, enum LSErrorCode errorCode, void* handler );
25
26 LS_API typedef struct LSLicenseHandler
27 {
28 // current configuration if present gets deleted automatically
29 void ( *reconfigure )( struct LSLicenseHandler* self, struct LSConfiguration* config );
30
31 // ---------- Requests to the LicenseSpring backend ----------
32 bool ( *isOnline )( struct LSLicenseHandler* self );
33 LSProductDetails* ( *getProductDetails )( struct LSLicenseHandler* self );
34 struct LSLicenseID ( *getTrialLicense )( struct LSLicenseHandler* self, LSCustomer* user, const char* licensePolicy );
35 struct LSLicenseID ( *getTrialLicenseByEmail )( struct LSLicenseHandler* self, const char* userEmail );
36 const char* ( *getSSOUrl )( struct LSLicenseHandler* self, const char* accountCode, bool useAuthCode );
37 void ( *activateLicense )( struct LSLicenseHandler* self, struct LSLicenseID licenseID );
38 void ( *activateLicenseViaSSO )( struct LSLicenseHandler* self, const char* authData,
39 const char* accountCode, bool useAuthCode );
40 bool ( *deactivateLicense )( struct LSLicenseHandler* self );
41 bool ( *changePassword )( struct LSLicenseHandler* self, const char* password, const char* newPassword, const char* user );
42 LSInstallationFile* ( *checkLicense )( struct LSLicenseHandler* self );
43 LSInstallationFile* ( *checkLicenseEx )(struct LSLicenseHandler* self, const char* channel, const char* env );
44 int ( *getVersionList )( struct LSLicenseHandler* self, struct LSLicenseID licenseID, int* lengths, char** versionList );
45 int ( *getVersionListEx )( struct LSLicenseHandler* self, struct LSLicenseID licenseID,
46 const char* channel, const char* env, int* lengths, char** versionList );
47 LSInstallationFile* ( *getInstallFile )( struct LSLicenseHandler* self, struct LSLicenseID licenseID, const char* version );
48 LSInstallationFile* ( *getInstallFileEx )( struct LSLicenseHandler* self, struct LSLicenseID licenseID,
49 const char* version, const char* channel, const char* env );
50 void ( *sendDeviceData )( struct LSLicenseHandler* self, struct LSCustomField* data, int dataSize );
51 void ( *syncConsumption )( struct LSLicenseHandler* self );
52 void ( *syncFeatureConsumption )( struct LSLicenseHandler* self, const char* featureCode );
53 void ( *registerFloatingLicense )( struct LSLicenseHandler* self );
54 void ( *borrowFloatingLicense )( struct LSLicenseHandler* self, uint32_t hours, uint32_t days );
55 void ( *borrowFloatingLicenseTill )(struct LSLicenseHandler* self, const char* borrowEndDateTime );
56 void ( *releaseFloatingLicense )( struct LSLicenseHandler* self );
57 const char* ( *getAirGapActivationCode )( struct LSLicenseHandler* self, const char* initializationCode, const char* licenseKey );
58 const char* ( *getAirGapDeactivationCode )( struct LSLicenseHandler* self, const char* initializationCode );
59 // ------------------------------------------------------------
60
61 // -------- Local license management and helper methods -------
62 bool ( *isInitialized )( struct LSLicenseHandler* self );
63 bool ( *isLicenseExists )( struct LSLicenseHandler* self );
64 void ( *updateConsumption )( struct LSLicenseHandler* self, int value, bool saveLicense );
65 void ( *updateFeatureConsumption )( struct LSLicenseHandler* self, const char* featureCode, int value, bool saveLicense );
66 void ( *checkLicenseLocal )( struct LSLicenseHandler* self );
67 void ( *clearLocalStorage )( struct LSLicenseHandler* self );
68 void ( *setupLicenseWatchdog )( struct LSLicenseHandler* self, LSWatchdogCallback callback, unsigned long timeout );
69 void ( *resumeLicenseWatchdog )( struct LSLicenseHandler* self );
70 void ( *stopLicenseWatchdog )( struct LSLicenseHandler* self );
71 void ( *relinkLicense )( struct LSLicenseHandler* self, enum DeviceIDAlgorithm deviceIdAlgorithm, const char* userPassword );
72 // ------------------------------------------------------------
73
74 // ---------------- Offline license management ----------------
75 const wchar_t* ( *createOfflineActivationFile )( struct LSLicenseHandler* self, struct LSLicenseID licenseID, const wchar_t* activationRequestFile );
76 void ( *activateLicenseOffline )( struct LSLicenseHandler* self, const wchar_t* activationResponseFile );
77 const wchar_t* ( *deactivateLicenseOffline )( struct LSLicenseHandler* self, const wchar_t* deactivationRequestFile );
78 bool ( *updateOffline )( struct LSLicenseHandler* self, const wchar_t* path, bool resetConsumption );
79 void ( *activateAirGapLicense )( struct LSLicenseHandler* self, const char* confirmationCode, const wchar_t* policyFile, const char* licenseKey, unsigned long policyId );
80 void ( *deactivateAirGapLicense )( struct LSLicenseHandler* self, const char* confirmationCode );
81 // ------------------------------------------------------------
82
83 // ----------------------- License data -----------------------
84 bool ( *isLicenseValid )( struct LSLicenseHandler* self );
85 bool ( *isLicenseTrial )( struct LSLicenseHandler* self );
86 bool ( *isLicenseAirGapped )( struct LSLicenseHandler* self );
87 bool ( *isLicenseActive )( struct LSLicenseHandler* self );
88 bool ( *isLicenseEnabled )( struct LSLicenseHandler* self );
89 bool ( *isLicenseExpired )( struct LSLicenseHandler* self );
92 bool ( *isLicenseFloating )( struct LSLicenseHandler* self );
93 bool ( *isLicenseBorrowed )( struct LSLicenseHandler* self );
94 bool ( *isLicenseVMAllowed )( struct LSLicenseHandler* self );
96 bool ( *isGracePeriodStarted )( struct LSLicenseHandler* self );
98 struct tm ( *gracePeriodEndDateTime )( struct LSLicenseHandler* self );
99 struct tm ( *gracePeriodEndDateTimeUTC )( struct LSLicenseHandler* self );
100
101 struct LSLicenseID ( *getLicenseID )( struct LSLicenseHandler* self );
102 const char* ( *getLicenseKey )( struct LSLicenseHandler* self );
103 const char* ( *getLicenseUser )( struct LSLicenseHandler* self );
104 const char* ( *getLicenseStatusStr )( struct LSLicenseHandler* self );
105 const char* ( *getLicenseStartDate )( struct LSLicenseHandler* self );
106 const char* ( *getLicenseMetadata )( struct LSLicenseHandler* self );
107 enum LSLicenseType( *getLicenseType )( struct LSLicenseHandler* self );
108 struct tm( *getLicenseExpiryDate )( struct LSLicenseHandler* self );
109 struct tm( *getLicenseExpiryDateUtc )( struct LSLicenseHandler* self );
110 struct tm( *getLicenseMaintenancePeriod )( struct LSLicenseHandler* self );
111 struct tm( *getLicenseMaintenancePeriodUtc )( struct LSLicenseHandler* self );
112 struct tm( *getLicenseLastCheckDate )( struct LSLicenseHandler* self );
113 struct tm( *getLicenseLastCheckDateUtc )( struct LSLicenseHandler* self );
114 struct tm( *getLicenseFloatingEndDateTime )( struct LSLicenseHandler* self );
115 struct tm( *getLicenseFloatingEndDateTimeUtc )( struct LSLicenseHandler* self );
116 int ( *getDaysRemaining )( struct LSLicenseHandler* self );
119 LSCustomer* ( *getLicenseOwner )( struct LSLicenseHandler* self );
120 bool ( *hasLicenseFeatures )( struct LSLicenseHandler* self );
121 struct LSLicenseFeature* ( *getLicenseFeature )( struct LSLicenseHandler* self, const char* featureCode );
122 int ( *getLicenseFeatures )( struct LSLicenseHandler* self, struct LSLicenseFeature* features );
123 bool ( *hasLicenseCustomFields )( struct LSLicenseHandler* self );
124 int ( *getLicenseCustomFields )( struct LSLicenseHandler* self, struct LSCustomField* fields );
125 unsigned long ( *getLicenseTimesActivated )( struct LSLicenseHandler* self );
126 unsigned long ( *getLicenseMaxActivations )( struct LSLicenseHandler* self );
127 unsigned long ( *getLicenseTransferCount )( struct LSLicenseHandler* self );
128 unsigned long ( *getLicensePolicyId )( struct LSLicenseHandler* self );
129
130 // Meaningful only for Subscription license
131 unsigned long ( *getSubscriptionLicenseGracePeriod )( struct LSLicenseHandler* self );
132 struct tm ( *validityWithGracePeriod )( struct LSLicenseHandler* self );
133 struct tm ( *validityWithGracePeriodUtc )( struct LSLicenseHandler* self );
134
135 // Meaningful only for Consumption license
140 int ( *getLicenseMaxOverages )( struct LSLicenseHandler* self );
143
144 // Meaningful only for Floating license
145 unsigned long ( *getLicenseFloatingTimeout )( struct LSLicenseHandler* self );
146 unsigned long ( *getLicenseFloatingInUseCount )( struct LSLicenseHandler* self );
147 unsigned long ( *getLicenseMaxFloatingUsers )( struct LSLicenseHandler* self );
148 unsigned long (* getMaxBorrowTime )( struct LSLicenseHandler* self );
149 // ------------------------------------------------------------
150
151 // ---------------------- Error handling ----------------------
152 bool ( *wasError )( struct LSLicenseHandler* self );
153 enum LSErrorCode( *getLastError )( struct LSLicenseHandler* self );
154 const char* ( *getLastErrorMsg )( struct LSLicenseHandler* self );
155 bool ( *isInitializationError )( struct LSLicenseHandler* self );
156 bool ( *isInternalServerError )( struct LSLicenseHandler* self );
157 bool ( *isNetworkTimeoutError )( struct LSLicenseHandler* self );
158 bool ( *isNoInternetError )( struct LSLicenseHandler* self );
159 bool ( *isActivationFailed )( struct LSLicenseHandler* self );
160 bool ( *isLicenseExpiredError )( struct LSLicenseHandler* self );
161 bool ( *isLicenseNotFoundError )( struct LSLicenseHandler* self );
162 bool ( *isLicenseStateError )( struct LSLicenseHandler* self );
163 bool ( *isHardwareIDError )( struct LSLicenseHandler* self );
164 bool ( *isGeneralError )( struct LSLicenseHandler* self );
165 bool ( *isLicenseFeatureError )( struct LSLicenseHandler* self );
166 bool ( *canIgnoreError )( struct LSLicenseHandler* self ); // No Internet, network timeout and server errors can be ignored
167 // ------------------------------------------------------------
168
169 void* inner;
170
172
174
175 // LicenseHandler takes ownership of Configuration, so do not free it
177
178 // This function will also free current configuration, you do not need to explicitly call FreeLSConfiguration
180
181#ifdef __cplusplus
182} // end extern "C"
183#endif
184
185#endif // LS_C_LICENSE_HANDLER_H
#define LS_API
Macros that expands to dllexport, dllimport or nothing on non Windows platforms or in case of static ...
Definition: APIDef.h:22
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:38
DeviceIDAlgorithm
Type of Device ID algorithm used by the SDK.
Definition: PODTypes.h:101
LSLicenseType
License type.
Definition: PODTypes.h:28
LSErrorCode
LicenseSpring Error codes enum.
Definition: PODTypes.h:48
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)
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(* 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(* 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)
void(* checkLicenseLocal)(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)
int(* getLicenseFeatures)(struct LSLicenseHandler *self, struct LSLicenseFeature *features)
void(* setupLicenseWatchdog)(struct LSLicenseHandler *self, LSWatchdogCallback callback, unsigned long timeout)
bool(* wasError)(struct LSLicenseHandler *self)
struct tm(* getLicenseMaintenancePeriodUtc)(struct LSLicenseHandler *self)
struct tm(* validityWithGracePeriod)(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)
int(* getLicenseMaxOverages)(struct LSLicenseHandler *self)
bool(* isLicenseFeatureError)(struct LSLicenseHandler *self)
struct tm(* gracePeriodEndDateTimeUTC)(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)
bool(* isLicenseExpired)(struct LSLicenseHandler *self)
bool(* isLicenseMaintenanceExpired)(struct LSLicenseHandler *self)
struct tm(* getLicenseLastCheckDate)(struct LSLicenseHandler *self)
unsigned long(* getLicenseMaxFloatingUsers)(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)
int(* gracePeriodHoursRemaining)(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)
struct tm(* gracePeriodEndDateTime)(struct LSLicenseHandler *self)
bool(* isLicenseExpiredError)(struct LSLicenseHandler *self)
unsigned long(* getMaxBorrowTime)(struct LSLicenseHandler *self)
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:13