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