1 #ifndef LS_LICENSE_HANDLER_H
2 #define LS_LICENSE_HANDLER_H
17 class LicenseHandlerImpl;
55 const std::wstring &dataLocation()
const;
57 void setDataLocation(
const std::wstring &path);
59 const std::wstring &licenseFileName()
const;
61 void setLicenseFileName(
const std::wstring &name);
63 const std::wstring &licenseFilePath()
const;
68 bool isOnline()
const;
73 bool includeLatestVersion,
bool includeCustomFields,
const std::string &env)
const;
76 Customer::ptr_t user =
nullptr,
const std::string &licensePolicy = std::string())
const;
78 const LicenseID &getTrialLicense(
const std::string &userEmail)
const;
80 const std::string &getSSOUrl(
81 const std::string &accountCode = std::string(),
bool useAuthCode =
true);
83 const std::string &getAirGapActivationCode(
84 const std::string &initializationCode,
const std::string &licenseKey);
86 const std::string &getAirGapDeactivationCode(
const std::string &initializationCode);
88 void activateAirGapLicense(
const std::string &confirmationCode,
89 const std::wstring &activationResponseFile,
const std::string &licenseKey,
92 void deactivateAirGapLicense(
const std::string &confirmationCode);
94 std::vector<LicenseUser::ptr_t> getLicenseUsers(
const Customer &customer);
96 std::vector<LicenseUser::ptr_t> getLicenseUsers(
const std::string &customerEmail);
98 std::vector<UserLicensesData::ptr_t> getUserLicenses(
99 const std::string &username,
const std::string &password);
101 void activateLicense(
const LicenseID &licenseID);
103 void activateLicense(
104 const LicenseID &licenseID,
const std::vector<DeviceVariable> &deviceVariables);
106 void activateLicense(
const std::string &authData,
107 const std::string &accountCode = std::string(),
bool useAuthCode =
true);
109 bool deactivateLicense();
111 bool changePassword(
const std::string &password,
const std::string &newPassword,
112 const std::string &user = std::string());
115 DeviceIDAlgorithm deviceIdAlgorithm,
const std::string &userPassword = std::string());
120 const std::vector<std::string> &getVersionList(
const LicenseID &licenseID =
LicenseID(),
124 const std::string &version = std::string(),
127 void sendDeviceVariables();
129 std::vector<DeviceVariable> getDeviceVariables(
bool getFromBackend =
false);
131 void syncConsumption(int32_t requestOverage = -1);
133 void syncFeatureConsumption(
const std::string &featureCode = std::string());
135 void registerFloatingLicense();
137 void borrowFloatingLicense(uint32_t hours, uint32_t days = 0);
139 void borrowFloatingLicense(
const std::string &borrowEndDateTime = std::string());
141 void releaseFloatingLicense();
143 void registerFloatingFeature(
const std::string &featureCode,
bool addToWatchdog =
true);
145 void releaseFloatingFeature(
const std::string &featureCode);
150 bool isInitialized()
const;
151 bool isLicenseExists()
const;
153 void updateConsumption(int32_t value = 1,
bool saveLicense =
true);
155 void updateFeatureConsumption(
156 const std::string &featureCode, int32_t value = 1,
bool saveLicense =
true);
158 void checkLicenseLocal(
bool verifySignature =
false);
160 void clearLocalStorage();
162 bool isLicenseFileCorrupted();
165 void addUserData(
const CustomField &data,
bool saveLicense =
true);
167 void removeUserData(
const std::string &key = std::string(),
bool saveLicense =
true);
169 const std::vector<CustomField> &userData();
171 std::string userData(
const std::string &key);
174 bool isAutoReleaseSet()
const;
176 void setAutoRelease(
bool autoRelease);
180 void resumeLicenseWatchdog();
182 void stopLicenseWatchdog();
186 void resumeFeatureWatchdog();
188 void stopFeatureWatchdog();
191 void addDeviceVariable(
192 const std::string &name,
const std::string &value,
bool saveLicense =
true);
194 void addDeviceVariable(
const DeviceVariable &variable,
bool saveLicense =
true);
196 void addDeviceVariables(
const std::vector<DeviceVariable> &variables);
200 const std::string &deviceVariableValue(
const std::string &name)
const;
205 const std::wstring &createOfflineActivationFile(
206 const LicenseID &licenseID,
const std::wstring &activationRequestFile = std::wstring());
208 const std::wstring &createOfflineActivationFile(
const LicenseID &licenseID,
209 const std::vector<DeviceVariable> &deviceVariables,
210 const std::wstring &activationRequestFile = std::wstring());
212 void activateLicenseOffline(
const std::wstring &activationResponseFile = std::wstring());
214 const std::wstring &deactivateLicenseOffline(
215 const std::wstring &deactivationRequestFile = std::wstring());
217 bool updateOffline(
const std::wstring &path = std::wstring(),
bool resetConsumption =
false);
222 bool isLicenseValid()
const;
224 bool isLicenseTrial()
const;
226 bool isLicenseAirGapped()
const;
228 bool isLicenseActive()
const;
230 bool isLicenseEnabled()
const;
232 bool isLicenseExpired()
const;
234 bool isLicenseMaintenanceExpired()
const;
236 bool isLicenseOfflineActivated()
const;
238 bool isLicenseFloating()
const;
240 bool isLicenseBorrowed()
const;
242 bool isLicenseOveragesAllowed()
const;
244 bool isLicenseUnlimitedConsumptionAllowed()
const;
246 bool isLicenseNegativeConsumptionAllowed()
const;
248 bool isLicenseVMAllowed()
const;
250 bool isSubscriptionGracePeriodStarted()
const;
252 bool isGracePeriodStarted()
const;
254 tm gracePeriodEndDateTime()
const;
256 tm gracePeriodEndDateTimeUTC()
const;
258 int gracePeriodHoursRemaining()
const;
260 uint32_t getLicenseTrialPeriod()
const;
265 const std::string &getLicenseKey()
const;
267 const std::string &getLicenseUser()
const;
270 const uint64_t getLicenseServerId()
const;
272 const std::string &getLicenseStatusStr()
const;
274 const std::string &getLicenseStartDate()
const;
276 const std::string &getLicenseMetadata()
const;
278 const std::string &getOrderStoreId()
const;
284 tm getLicenseExpiryDate()
const;
286 tm getLicenseExpiryDateUtc()
const;
288 tm getLicenseMaintenancePeriod()
const;
290 tm getLicenseMaintenancePeriodUtc()
const;
292 tm getLicenseLastCheckDate()
const;
294 tm getLicenseLastCheckDateUtc()
const;
296 tm getLicenseFloatingEndDateTime()
const;
298 tm getLicenseFloatingEndDateTimeUtc()
const;
300 int getDaysRemaining()
const;
302 int getMaintenanceDaysRemaining()
const;
304 int getDaysPassedSinceLastCheck()
const;
307 uint32_t getSubscriptionLicenseGracePeriod()
const;
309 tm validityWithGracePeriod()
const;
311 tm validityWithGracePeriodUtc()
const;
314 const Customer &getLicenseOwner()
const;
318 bool hasLicenseFeatures()
const;
320 const LicenseFeature &getLicenseFeature(
const std::string &featureCode)
const;
322 const std::vector<LicenseFeature> &getLicenseFeatures()
const;
324 bool hasLicenseCustomFields()
const;
326 const std::vector<CustomField> &getLicenseCustomFields()
const;
329 uint32_t getLicenseTimesActivated()
const;
331 uint32_t getLicenseMaxActivations()
const;
333 uint32_t getLicenseTransferCount()
const;
335 int32_t getLicenseTransferLimit()
const;
337 bool isDeviceTransferAllowed()
const;
339 bool isDeviceTransferLimited()
const;
342 uint32_t getLicensePolicyId()
const;
346 int32_t getLicenseTotalConsumption()
const;
348 int32_t getLicenseMaxConsumption()
const;
350 int32_t getLicenseMaxOverages()
const;
351 bool isResetLicenseConsumptionEnabled()
const;
356 uint32_t getLicenseFloatingTimeout()
const;
358 uint32_t getLicenseFloatingInUseCount()
const;
360 uint32_t getLicenseMaxFloatingUsers()
const;
362 uint32_t getMaxBorrowTime()
const;
366 void enableExceptions(
bool enable);
367 bool isExceptionsEnabled()
const;
368 bool wasError()
const;
370 const std::string &getLastErrorMsg()
const;
371 bool isInitializationError()
const;
372 bool isInternalServerError()
const;
373 bool isNetworkTimeoutError()
const;
374 bool isNoInternetError()
const;
375 bool isActivationFailed()
const;
376 bool isLicenseExpiredError()
const;
377 bool isLicenseNotFoundError()
const;
378 bool isLicenseStateError()
const;
379 bool isHardwareIDError()
const;
380 bool isGeneralError()
const;
381 bool isLicenseFeatureError()
const;
382 bool canIgnoreError()
const;
386 LicenseHandlerImpl *m_impl;
391 #endif // LS_LICENSE_HANDLER_H