| LicenseSpring C++ SDK 7.32.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 trialPeriod() const = 0;
144
148 virtual uint32_t maxFloatingUsers() const = 0;
149
154 virtual uint32_t floatingInUseCount() const = 0;
155
158 virtual uint32_t floatingTimeout() const = 0;
159
163 virtual const std::string& floatingClientId() const = 0;
164
167 virtual tm validityPeriod() const = 0;
168
171 virtual tm validityPeriodUtc() const = 0;
172
176 virtual tm validityWithGracePeriod() const = 0;
177
181 virtual tm validityWithGracePeriodUtc() const = 0;
182
186 virtual uint32_t subscriptionGracePeriod() const = 0;
187
191 virtual uint32_t maxBorrowTime() const = 0;
192
195 virtual tm maintenancePeriod() const = 0;
196
199 virtual tm maintenancePeriodUtc() const = 0;
200
203 virtual tm lastCheckDate() const = 0;
204
207 virtual tm lastCheckDateUtc() const = 0;
208
212 virtual tm floatingEndDateTime() const = 0;
213
217 virtual tm floatingEndDateTimeUtc() const = 0;
218
222 virtual const std::string& startDate() const = 0;
223
226 virtual const std::string& metadata() const = 0;
227
232 virtual LicenseFeature feature( const std::string& featureCode ) const = 0;
233
236 virtual std::vector<LicenseFeature> features() const = 0;
237
240 virtual std::vector<CustomField> customFields() const = 0;
241
245 virtual const std::vector<CustomField>& userData() const = 0;
246
251 virtual std::string userData( const std::string& key ) const = 0;
252
258 virtual void addUserData( const CustomField& data, bool saveLicense = true ) = 0;
259
263 virtual void removeUserData( const std::string& key = std::string(), bool saveLicense = true ) = 0;
264
267 virtual int32_t totalConsumption() const = 0;
268
271 virtual int32_t maxConsumption() const = 0;
272
275 virtual int32_t maxOverages() const = 0;
276
279 virtual bool isOveragesAllowed() const = 0;
280
283 virtual bool isUnlimitedConsumptionAllowed() const = 0;
284
287 virtual ConsumptionPeriod consumptionPeriod() const = 0;
288
291 virtual bool isResetConsumptionEnabled() const = 0;
292
295 virtual uint32_t timesActivated() const = 0;
296
299 virtual uint32_t maxActivations() const = 0;
300
303 virtual uint32_t transferCount() const = 0;
304
307 virtual int32_t transferLimit() const = 0;
308
311 virtual bool isDeviceTransferAllowed() const = 0;
312
315 virtual bool isDeviceTransferLimited() const = 0;
316
320 virtual bool isAutoReleaseSet() const = 0;
321
324 virtual void setAutoRelease( bool autoRelease ) = 0;
325
331 virtual void updateConsumption( int32_t value = 1, bool saveLicense = true ) = 0;
332
339 virtual void updateFeatureConsumption( const std::string& featureCode, int32_t value = 1, bool saveLicense = true ) = 0;
340
341 // Local checks
345 virtual bool isExpired() const = 0;
346
349 virtual bool isMaintenancePeriodExpired() const = 0;
350
354 virtual int daysRemainingUtc() const = 0;
355
359 virtual int daysRemaining() const = 0;
360
363 virtual int maintenanceDaysRemaining() const = 0;
364
367 static const int MaxDaysRemainingValue;
368
371 virtual int daysPassedSinceLastCheck() const = 0;
372
380 virtual void localCheck() = 0;
381
382 // Requests to LicenseSpring server
383
396 virtual bool deactivate( bool removeLocalData = false ) = 0;
397
402 virtual bool changePassword( const std::string& password, const std::string& newPassword ) = 0; // may throw exceptions
403
416 virtual InstallationFile::ptr_t check( const InstallFileFilter& filter = InstallFileFilter(), bool includeExpiredFeatures = false ) = 0;
417
430 virtual bool syncConsumption( int32_t requestOverage = -1 ) = 0;
431
444 virtual bool syncFeatureConsumption( const std::string& featureCode = std::string() ) = 0;
445
455 virtual void addDeviceVariable( const std::string& name, const std::string& value,
456 bool saveLicense = true ) = 0;
457
464 virtual void addDeviceVariable( const DeviceVariable& variable, bool saveLicense = true ) = 0;
465
469 virtual void addDeviceVariables( const std::vector<DeviceVariable>& variables ) = 0;
470
477 virtual bool sendDeviceVariables() = 0;
478
486 virtual std::vector<DeviceVariable> getDeviceVariables( bool getFromBackend = false ) = 0;
487
491 virtual DeviceVariable deviceVariable( const std::string& name ) const = 0;
492
496 virtual const std::string& deviceVariableValue( const std::string& name ) const = 0;
497
503 virtual void setupLicenseWatchdog( LicenseWatchdogCallback callback, uint32_t timeout = 0 ) = 0;
504
508 virtual void resumeLicenseWatchdog() = 0;
509
512 virtual void stopLicenseWatchdog() = 0;
513
518 virtual void setupFeatureWatchdog(LicenseWatchdogCallback callback, uint32_t timeout = 0 ) = 0;
519
523 virtual void resumeFeatureWatchdog() = 0;
524
527 virtual void stopFeatureWatchdog() = 0;
528
534 virtual void registerFloatingLicense() = 0;
535
544 virtual void releaseFloatingLicense( bool throwExceptions = false ) = 0;
545
556 virtual void borrow( uint32_t hours, uint32_t days = 0 ) = 0;
557
567 virtual void borrow( const std::string& borrowEndDateTime = std::string() ) = 0;
568
572 virtual std::wstring deactivateOffline( const std::wstring& deactivationRequestFile = std::wstring() ) = 0;
573
582 virtual bool updateOffline( const std::wstring& path, bool resetConsumption = false ) = 0;
583
588 virtual void unlinkFromDevice() = 0;
589
593 virtual std::string getAirGapDeactivationCode( const std::string& initializationCode ) = 0;
594
598 virtual void deactivateAirGap( const std::string& confirmationCode ) = 0;
599
602 virtual bool isLicenseBelongsToThisDevice( DeviceIDAlgorithm deviceIDAlgorithm ) = 0;
603
605 virtual bool checkLicenseBelongsToThisDevice() = 0;
606
611 virtual void registerFloatingFeature( const std::string& featureCode, bool addToWatchdog = true ) = 0;
612
618 virtual void releaseFloatingFeature( const std::string& featureCode ) = 0;
619 };
620
622 std::string LS_API TmToString( const tm& dateTime, const std::string& format = std::string( "%d-%m-%Y" ) );
623
624 } // namespace LicenseSpring
625
626 #pragma pop_macro("check")
627
628 #ifdef _MSC_VER
629 #pragma warning( pop )
630 #endif
631
632 #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:367
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:103
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:20