BPS C++ API  2.24.4
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>

+ Inheritance diagram for BpsLicenseToken:

Public Member Functions

 BpsLicenseToken (BpsDatastore *aDatastore, const QString &aLicenser, const QString &aLicenseGroup, const QString &aProgram, const QVariant &aInfo, QObject *aParent=nullptr)
 Create a new license token. More...
 
virtual int checkLicense (QDate *aExpires=nullptr)
 This method can be overloaded to implement a check for license validity. More...
 
void clear ()
 Clears the token and releases the license for re-use.
 
BpsDatastoredatastore () const
 
QVariant info () 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. More...
 
QDate validate ()
 Checks the license token. More...
 
virtual ~BpsLicenseToken ()
 The destructor clears the token and releases the license for re-use.
 
- Public Member Functions inherited from QObject
bool blockSignals (bool block)
 
const QObjectListchildren () const const
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectInfo ()
 
void dumpObjectInfo () const const
 
void dumpObjectTree ()
 
void dumpObjectTree () const const
 
QList< QByteArraydynamicPropertyNames () const const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegExp &regExp, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
QVariant property (const char *name) const const
 
 Q_CLASSINFO (Name, Value)
 
 Q_DISABLE_COPY (Class)
 
 Q_DISABLE_COPY_MOVE (Class)
 
 Q_DISABLE_MOVE (Class)
 
 Q_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_OBJECT Q_OBJECT
 
 Q_PROPERTY (...)
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SLOT Q_SLOT
 
 Q_SLOTS Q_SLOTS
 
qFindChild (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QRegExp &regExp)
 
QList< T > qFindChildren (const QObject *obj, const QString &name)
 
 QObject (QObject *parent)
 
qobject_cast (const QObject *object)
 
qobject_cast (QObject *object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds time, Qt::TimerType timerType)
 
QThreadthread () const const
 

Protected Member Functions

void setLicenseGroup (const QString &aLicenseGroup)
 Set a new license group. More...
 
- Protected Member Functions inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
int receivers (const char *signal) const const
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 

Additional Inherited Members

- Static Public Member Functions inherited from QObject
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
- Public Attributes inherited from QObject
typedef QObjectList
 
- Properties inherited from QObject
 objectName
 

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::BpsLicenseToken ( BpsDatastore aDatastore,
const QString aLicenser,
const QString aLicenseGroup,
const QString aProgram,
const QVariant aInfo,
QObject aParent = nullptr 
)

Create a new license token.

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

Parameters
aDatastoreThe current datastore connection. Should be connected and checked in.
aLicenserName of the software license granter.
aLicenseGroupName of the license group.
aProgramName of the program.
aInfoLicense specific internal information.
aParentThe parent object.

Member Function Documentation

◆ checkLicense()

virtual int BpsLicenseToken::checkLicense ( QDate aExpires = nullptr)
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
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.

◆ datastore()

BpsDatastore* BpsLicenseToken::datastore ( ) const
Returns
The datastore pointer.

◆ info()

QVariant BpsLicenseToken::info ( ) const
Returns
The license specific internal information.

◆ isValid()

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.

◆ licenseGroup()

QString BpsLicenseToken::licenseGroup ( ) const
Returns
The license group.

◆ licenser()

QString BpsLicenseToken::licenser ( ) const
Returns
The licenser name.

◆ program()

QString BpsLicenseToken::program ( ) const
Returns
The program name.

◆ setLicenseGroup()

void BpsLicenseToken::setLicenseGroup ( const QString aLicenseGroup)
protected

Set a new license group.

Parameters
aLicenseGroupthe new license group name.

◆ update()

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.

◆ validate()

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: