| LicenseSpring C++ SDK 7.27.0 Easily add Software Licensing to your application

License.h
Go to the documentation of this file.
1 #ifndef LS_LICENSE_H
2 #define LS_LICENSE_H
3
4 #ifdef _MSC_VER
5 #pragma once
6 #pragma warning( push )
7 #pragma warning( disable : 4251 )
8 #endif
9
10 #include <vector>
11 #include <functional>
12 #include "LicenseType.h"
13 #include "CustomField.h"
14 #include "InstallationFile.h"
15 #include "LicenseID.h"
16 #include "LicenseFeature.h"
17 #include "DeviceVariable.h"
18 #include "Customer.h"
19 #include "ProductDetails.h"
20 #include "LicenseUser.h"
21 #include "Exceptions.h"
22
23 #pragma push_macro("check") // Workaround for Unreal Engine
24 #undef check
25
26 namespace LicenseSpring
27 {
29 using LicenseWatchdogCallback = std::function<void( const LicenseSpringException& ex )>;
30
33 class LS_API License
34 {
35 public:
36 using ptr_t = std::shared_ptr<License>;
37
39 virtual ~License() {};
40
43 virtual const LicenseID& id() const = 0;
44
47 virtual const std::string& key() const = 0;
48
51 virtual const std::string& user() const = 0;
52
55 virtual LicenseType type() const = 0;
56
59 virtual Customer owner() const = 0;
60
64 virtual LicenseUser::ptr_t licenseUser() const = 0;
65
70 virtual ProductDetails productDetails() const = 0;
71
74 virtual std::string status() const = 0;
75
78 virtual bool isActive() const = 0;
79
82 virtual bool isEnabled() const = 0;
83
86 virtual bool isValid() const = 0;
87
90 virtual bool isTrial() const = 0;
91
94 virtual bool isAirGapped() const = 0;
95
99 virtual uint32_t policyId() const = 0;
100
103 virtual bool isOfflineActivated() const = 0;
104
108 virtual bool isVMAllowed() const = 0;
109
112 virtual bool isFloating() const = 0;
113
117 virtual bool isBorrowed() const = 0;
118
122 virtual bool isSubscriptionGracePeriodStarted() const = 0;
123
126 virtual bool isGracePeriodStarted() const = 0;
127
130 virtual tm gracePeriodEndDateTime() const = 0;
131
134 virtual tm gracePeriodEndDateTimeUTC() const = 0;
135
138 virtual int gracePeriodHoursRemaining() const = 0;
139
143 virtual uint32_t maxFloatingUsers() const = 0;
144
149 virtual uint32_t floatingInUseCount() const = 0;
150
153 virtual uint32_t floatingTimeout() const = 0;
154
158 virtual const std::string& floatingClientId() const = 0;
159
162 virtual tm validityPeriod() const = 0;
163
166 virtual tm validityPeriodUtc() const = 0;
167
171 virtual tm validityWithGracePeriod() const = 0;
172
176 virtual tm validityWithGracePeriodUtc() const = 0;
177
181 virtual uint32_t subscriptionGracePeriod() const = 0;
182
186 virtual uint32_t maxBorrowTime() const = 0;
187
190 virtual tm maintenancePeriod() const = 0;
191
194 virtual tm maintenancePeriodUtc() const = 0;
195
198 virtual tm lastCheckDate() const = 0;
199
202 virtual tm lastCheckDateUtc() const = 0;
203
207 virtual tm floatingEndDateTime() const = 0;
208
212 virtual tm floatingEndDateTimeUtc() const = 0;
213
217 virtual const std::string& startDate() const = 0;
218
221 virtual const std::string& metadata() const = 0;
222
226 virtual LicenseFeature feature( const std::string& featureCode ) const = 0;
227
230 virtual std::vector<LicenseFeature> features() const = 0;
231
234 virtual std::vector<CustomField> customFields() const = 0;
235
239 virtual const std::vector<CustomField>& userData() const = 0;
240
245 virtual std::string userData( const std::string& key ) const = 0;
246
252 virtual void addUserData( const CustomField& data, bool saveLicense = true ) = 0;
253
257 virtual void removeUserData( const std::string& key = std::string(), bool saveLicense = true ) = 0;
258
261 virtual int32_t totalConsumption() const = 0;
262
265 virtual int32_t maxConsumption() const = 0;
266
269 virtual int32_t maxOverages() const = 0;
270
273 virtual bool isOveragesAllowed() const = 0;
274
277 virtual bool isUnlimitedConsumptionAllowed() const = 0;
278
281 virtual ConsumptionPeriod consumptionPeriod() const = 0;
282
285 virtual bool isResetConsumptionEnabled() const = 0;
286
289 virtual uint32_t timesActivated() const = 0;
290
293 virtual uint32_t maxActivations() const = 0;
294
297 virtual uint32_t transferCount() const = 0;
298
302 virtual bool isAutoReleaseSet() const = 0;
303
306 virtual void setAutoRelease( bool autoRelease ) = 0;
307
313 virtual void updateConsumption( int32_t value = 1, bool saveLicense = true ) = 0;
314
321 virtual void updateFeatureConsumption( const std::string& featureCode, int32_t value = 1, bool saveLicense = true ) = 0;
322
323 // Local checks
327 virtual bool isExpired() const = 0;
328
331 virtual bool isMaintenancePeriodExpired() const = 0;
332
336 virtual int daysRemainingUtc() const = 0;
337
341 virtual int daysRemaining() const = 0;
342
345 virtual int maintenanceDaysRemaining() const = 0;
346
349 static const int MaxDaysRemainingValue;
350
353 virtual int daysPassedSinceLastCheck() const = 0;
354
362 virtual void localCheck() = 0;
363
364 // Requests to LicenseSpring server
365
378 virtual bool deactivate( bool removeLocalData = false ) = 0;
379
384 virtual bool changePassword( const std::string& password, const std::string& newPassword ) = 0; // may throw exceptions
385
397 virtual InstallationFile::ptr_t check( const InstallFileFilter& filter = InstallFileFilter() ) = 0;
398
411 virtual bool syncConsumption( int32_t requestOverage = -1 ) = 0;
412
425 virtual bool syncFeatureConsumption( const std::string& featureCode = std::string() ) = 0;
426
436 virtual void addDeviceVariable( const std::string& name, const std::string& value,
437 bool saveLicense = true ) = 0;
438
445 virtual void addDeviceVariable( const DeviceVariable& variable, bool saveLicense = true ) = 0;
446
450 virtual void addDeviceVariables( const std::vector<DeviceVariable>& variables ) = 0;
451
458 virtual bool sendDeviceVariables() = 0;
459
467 virtual std::vector<DeviceVariable> getDeviceVariables( bool getFromBackend = false ) = 0;
468
472 virtual DeviceVariable deviceVariable( const std::string& name ) const = 0;
473
477 virtual const std::string& deviceVariableValue( const std::string& name ) const = 0;
478
484 virtual void setupLicenseWatchdog( LicenseWatchdogCallback callback, uint32_t timeout = 0 ) = 0;
485
489 virtual void resumeLicenseWatchdog() = 0;
490
493 virtual void stopLicenseWatchdog() = 0;
494
500 virtual void registerFloatingLicense() = 0;
501
510 virtual void releaseFloatingLicense( bool throwExceptions = false ) = 0;
511
522 virtual void borrow( uint32_t hours, uint32_t days = 0 ) = 0;
523
533 virtual void borrow( const std::string& borrowEndDateTime = std::string() ) = 0;
534
538 virtual std::wstring deactivateOffline( const std::wstring& deactivationRequestFile = std::wstring() ) = 0;
539
548 virtual bool updateOffline( const std::wstring& path, bool resetConsumption = false ) = 0;
549
554 virtual void unlinkFromDevice() = 0;
555
559 virtual std::string getAirGapDeactivationCode( const std::string& initializationCode ) = 0;
560
564 virtual void deactivateAirGap( const std::string& confirmationCode ) = 0;
565
568 virtual bool isLicenseBelongsToThisDevice( DeviceIDAlgorithm deviceIDAlgorithm ) = 0;
569
571 virtual bool checkLicenseBelongsToThisDevice() = 0;
572 };
573
575 std::string LS_API TmToString( const tm& dateTime, const std::string& format = std::string( "%d-%m-%Y" ) );
576
577 } // namespace LicenseSpring
578
579 #pragma pop_macro("check")
580
581 #ifdef _MSC_VER
582 #pragma warning( pop )
583 #endif
584
585 #endif // LS_LICENSE_H
LicenseUser.h
LicenseSpring::TmToString
std::string LS_API TmToString(const tm &dateTime, const std::string &format=std::string("%d-%m-%Y"))
Helper function, converts datetime to string using given format. See strftime reference for format de...
Customer.h
LicenseSpring
Definition: BaseManager.h:15
LicenseSpring::DeviceVariable
Class for storing key-value device variable.
Definition: DeviceVariable.h:18
LicenseSpring::ConsumptionPeriod
Class used for encapsulating LSConsumptionPeriod and converting cosumption period to/from string...
Definition: ConsumptionPeriod.h:10
LicenseSpring::CustomField
Class for storing key-value data field.
Definition: CustomField.h:17
LicenseSpring::LicenseType
Class used for encapsulating the type of license, comparing types of licenses, and converting them to...
Definition: LicenseType.h:18
LicenseSpring::Customer
Class that encapsulates information about a customer.
Definition: Customer.h:17
LicenseSpring::License::ptr_t
std::shared_ptr< License > ptr_t
Definition: License.h:36
DeviceVariable.h
LicenseSpring::License::MaxDaysRemainingValue
static const int MaxDaysRemainingValue
Maximum value for daysRemaining, e.g. in case of perpetual license.
Definition: License.h:349
LicenseSpring::LicenseFeature
Class that encapsulates information about license feature.
Definition: LicenseFeature.h:20
LicenseSpring::LicenseWatchdogCallback
std::function< void(const LicenseSpringException &ex)> LicenseWatchdogCallback
Callback function which being called in case of error in background thread (watchdog thread)...
Definition: License.h:29
LicenseSpring::LicenseUser::ptr_t
std::shared_ptr< LicenseUser > ptr_t
Definition: LicenseUser.h:21
DeviceIDAlgorithm
DeviceIDAlgorithm
Type of Device ID algorithm used by the SDK.
Definition: PODTypes.h:100
ProductDetails.h
LicenseID.h
LicenseFeature.h
LicenseSpring::License::~License
virtual ~License()
Destructor for license.
Definition: License.h:39
LS_API
#define LS_API
Macros that expands to dllexport, dllimport or nothing on non Windows platforms or in case of static ...
Definition: APIDef.h:22
LicenseSpring::License
Class that encapsulates license information.
Definition: License.h:33
CustomField.h
LicenseSpring::LicenseID
Class that represents License identifier.
Definition: LicenseID.h:18
Exceptions.h
LicenseType.h
LicenseSpring::InstallationFile::ptr_t
std::shared_ptr< InstallationFile > ptr_t
Definition: InstallationFile.h:54
LicenseSpring::InstallFileFilter
Helper struct for filtering installation files by environment and channel.
Definition: InstallationFile.h:18
InstallationFile.h
LicenseSpring::ProductDetails
Class that encapsulates information about a product.
Definition: ProductDetails.h:19