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(
138 uint32_t hours, uint32_t days = 0,
const std::string &password = std::string());
140 void borrowFloatingLicense(
const std::string &borrowEndDateTime = std::string(),
141 const std::string &password = std::string());
143 void releaseFloatingLicense();
145 void registerFloatingFeature(
const std::string &featureCode,
bool addToWatchdog =
true);
147 void releaseFloatingFeature(
const std::string &featureCode);
152 bool isInitialized()
const;
153 bool isLicenseExists()
const;
155 void updateConsumption(int32_t value = 1,
bool saveLicense =
true);
157 void updateFeatureConsumption(
158 const std::string &featureCode, int32_t value = 1,
bool saveLicense =
true);
160 void checkLicenseLocal(
bool verifySignature =
false);
162 void clearLocalStorage();
164 bool isLicenseFileCorrupted();
167 void addUserData(
const CustomField &data,
bool saveLicense =
true);
169 void removeUserData(
const std::string &key = std::string(),
bool saveLicense =
true);
171 const std::vector<CustomField> &userData();
173 std::string userData(
const std::string &key);
176 bool isAutoReleaseSet()
const;
178 void setAutoRelease(
bool autoRelease);
182 void resumeLicenseWatchdog();
184 void stopLicenseWatchdog();
188 void resumeFeatureWatchdog();
190 void stopFeatureWatchdog();
193 void addDeviceVariable(
194 const std::string &name,
const std::string &value,
bool saveLicense =
true);
196 void addDeviceVariable(
const DeviceVariable &variable,
bool saveLicense =
true);
198 void addDeviceVariables(
const std::vector<DeviceVariable> &variables);
202 const std::string &deviceVariableValue(
const std::string &name)
const;
207 const std::wstring &createOfflineActivationFile(
208 const LicenseID &licenseID,
const std::wstring &activationRequestFile = std::wstring());
210 const std::wstring &createOfflineActivationFile(
const LicenseID &licenseID,
211 const std::vector<DeviceVariable> &deviceVariables,
212 const std::wstring &activationRequestFile = std::wstring());
214 void activateLicenseOffline(
const std::wstring &activationResponseFile = std::wstring());
216 const std::wstring &deactivateLicenseOffline(
217 const std::wstring &deactivationRequestFile = std::wstring());
219 bool updateOffline(
const std::wstring &path = std::wstring(),
bool resetConsumption =
false);
224 bool isLicenseValid()
const;
226 bool isLicenseTrial()
const;
228 bool isLicenseAirGapped()
const;
230 bool isLicenseActive()
const;
232 bool isLicenseEnabled()
const;
234 bool isLicenseExpired()
const;
236 bool isLicenseMaintenanceExpired()
const;
238 bool isLicenseOfflineActivated()
const;
240 bool isLicenseFloating()
const;
242 bool isLicenseBorrowed()
const;
244 bool isLicenseOveragesAllowed()
const;
246 bool isLicenseUnlimitedConsumptionAllowed()
const;
248 bool isLicenseNegativeConsumptionAllowed()
const;
250 bool isLicenseVMAllowed()
const;
252 bool isSubscriptionGracePeriodStarted()
const;
254 bool isGracePeriodStarted()
const;
256 tm gracePeriodEndDateTime()
const;
258 tm gracePeriodEndDateTimeUTC()
const;
260 int gracePeriodHoursRemaining()
const;
262 uint32_t getLicenseTrialPeriod()
const;
267 const std::string &getLicenseKey()
const;
269 const std::string &getLicenseUser()
const;
272 const uint64_t getLicenseServerId()
const;
274 const std::string &getLicenseStatusStr()
const;
276 const std::string &getLicenseStartDate()
const;
278 const std::string &getLicenseMetadata()
const;
280 const std::string &getOrderStoreId()
const;
286 tm getLicenseExpiryDate()
const;
288 tm getLicenseExpiryDateUtc()
const;
290 tm getLicenseMaintenancePeriod()
const;
292 tm getLicenseMaintenancePeriodUtc()
const;
294 tm getLicenseLastCheckDate()
const;
296 tm getLicenseLastCheckDateUtc()
const;
298 tm getLicenseFloatingEndDateTime()
const;
300 tm getLicenseFloatingEndDateTimeUtc()
const;
302 int getDaysRemaining()
const;
304 int getMaintenanceDaysRemaining()
const;
306 int getDaysPassedSinceLastCheck()
const;
309 uint32_t getSubscriptionLicenseGracePeriod()
const;
311 tm validityWithGracePeriod()
const;
313 tm validityWithGracePeriodUtc()
const;
316 const Customer &getLicenseOwner()
const;
320 bool hasLicenseFeatures()
const;
322 const LicenseFeature &getLicenseFeature(
const std::string &featureCode)
const;
324 const std::vector<LicenseFeature> &getLicenseFeatures()
const;
326 bool hasLicenseCustomFields()
const;
328 const std::vector<CustomField> &getLicenseCustomFields()
const;
331 uint32_t getLicenseTimesActivated()
const;
333 uint32_t getLicenseMaxActivations()
const;
335 uint32_t getLicenseTransferCount()
const;
337 int32_t getLicenseTransferLimit()
const;
339 bool isDeviceTransferAllowed()
const;
341 bool isDeviceTransferLimited()
const;
344 uint32_t getLicensePolicyId()
const;
348 int32_t getLicenseTotalConsumption()
const;
350 int32_t getLicenseMaxConsumption()
const;
352 int32_t getLicenseMaxOverages()
const;
353 bool isResetLicenseConsumptionEnabled()
const;
358 uint32_t getLicenseFloatingTimeout()
const;
360 uint32_t getLicenseFloatingInUseCount()
const;
362 uint32_t getLicenseMaxFloatingUsers()
const;
364 uint32_t getMaxBorrowTime()
const;
368 void enableExceptions(
bool enable);
369 bool isExceptionsEnabled()
const;
370 bool wasError()
const;
372 const std::string &getLastErrorMsg()
const;
373 bool isInitializationError()
const;
374 bool isInternalServerError()
const;
375 bool isNetworkTimeoutError()
const;
376 bool isNoInternetError()
const;
377 bool isActivationFailed()
const;
378 bool isLicenseExpiredError()
const;
379 bool isLicenseNotFoundError()
const;
380 bool isLicenseStateError()
const;
381 bool isHardwareIDError()
const;
382 bool isGeneralError()
const;
383 bool isLicenseFeatureError()
const;
384 bool canIgnoreError()
const;
388 LicenseHandlerImpl *m_impl;
393 #endif // LS_LICENSE_HANDLER_H