Documents > BPS V2 C++ API
BpsLicenseToken Class Reference

The license token is used to check permission of software usage, and maintains the list in table t_licensetokens. More...

#include <bpslicensetoken.h>

List of all members.

Public Member Functions

 BpsLicenseToken (BpsDatastore *aDatastore, const QString &aLicenser, const QString &aLicenseGroup, const QString &aProgram, QObject *aParent=0)
 Create a new license token.
virtual int checkLicense (QDate *aExpires=0)
 This method can be overloaded to implement a check for license validity.
void clear ()
 Clears the token and releases the license for re-use.
BpsDatastoredatastore () const
bool isValid () const
QString licenseGroup () const
QString licenser () const
QString program () const
void update ()
 Makes sure the token is still present and unmodified in table t_licensetokens, and updates the timestamp.
QDate validate ()
 Checks the license token.
virtual ~BpsLicenseToken ()
 The destructor clears the token and releases the license for re-use.

Detailed Description

The license token is used to check permission of software usage, and maintains the list in table t_licensetokens.

It is good practice for all applications to create and validate, and regularly update license tokens, even if usage of a license group is free and unlimited. That way all activities of the system can be monitored.

A licenser who provides licensed modules can derive a class of BpsLicensToken and re-implement the checkLicense method to validate licenses with his private procedure. Licenses would usually be stored in the central system settings in the group Settings/Licenses/{LicenserName}.


Constructor & Destructor Documentation

BpsLicenseToken::BpsLicenseToken ( BpsDatastore aDatastore,
const QString &  aLicenser,
const QString &  aLicenseGroup,
const QString &  aProgram,
QObject *  aParent = 0 
)

Create a new license token.

The token is initially invalid and needs to be validated before becoming effective.

Parameters:
[in]aDatastoreThe current datastore connection. Should be connected and checked in.
[in]aLicenserName of the software license granter.
[in]aLicenseGroupName of the license group.
[in]aProgramName of the program.
[in]aParentThe parent object.

Member Function Documentation

virtual int BpsLicenseToken::checkLicense ( QDate *  aExpires = 0) [virtual]

This method can be overloaded to implement a check for license validity.

The default implementation does not check anything but returns -1 in any case.

Parameters:
[out]aExpiresDate when the licenses will expire. Only used when number of valid licenses is not 0.
Returns:
Number of valid licenses when >0. No valid license when 0. Unlimited licenses when -1.
BpsDatastore* BpsLicenseToken::datastore ( ) const
Returns:
The datastore pointer.
bool BpsLicenseToken::isValid ( ) const
Returns:
Status: True if license token is still valid and update() should do. False if token is invalid, better run validate() now.
QString BpsLicenseToken::licenseGroup ( ) const
Returns:
The license group.
QString BpsLicenseToken::licenser ( ) const
Returns:
The licenser name.
QString BpsLicenseToken::program ( ) const
Returns:
The program name.
void BpsLicenseToken::update ( )

Makes sure the token is still present and unmodified in table t_licensetokens, and updates the timestamp.

This method should be called regularly by the application.

Exceptions:
ThrowsBpsException when no success.
QDate BpsLicenseToken::validate ( )

Checks the license token.

This is the first action to do after creating the new token.

Returns:
Expire date of the license. Usually the application would display a warning if there is less than 30 days left before expire date.
Exceptions:
ThrowsBpsException when validation fails.

The documentation for this class was generated from the following file: