libhomegear-base  0.7
Base library for Homegear and Homegear family modules.
BaseLib::Licensing::Licensing Class Referenceabstract

#include <Licensing.h>

Classes

struct  DeviceInfo
 
struct  LicenseData
 

Public Types

typedef std::shared_ptr< DeviceInfoPDeviceInfo
 
typedef std::map< int32_t, std::map< int32_t, PDeviceInfo > > DeviceStates
 

Public Member Functions

struct BaseLib::Licensing::Licensing::DeviceInfo __attribute__ ((aligned(64)))
 
 Licensing (BaseLib::SharedObjects *bl)
 
virtual ~Licensing ()
 
virtual bool init ()=0
 
virtual void dispose ()
 
virtual void load ()
 
virtual int32_t getModuleId ()
 
virtual DeviceStates getDeviceStates ()
 Returns a map with all unlicensed devices. More...
 
virtual bool getDeviceState (int32_t familyId, int32_t deviceId)
 Returns the activation status of a device or family. More...
 
virtual int32_t checkLicense (int32_t familyId, int32_t deviceId, const std::string &licenseKey="")=0
 Checks if a license key is valid. More...
 
virtual void removeLicense (int32_t familyId, int32_t deviceId)
 Removes a license. More...
 
virtual std::string getLicenseKey (int32_t familyId, int32_t deviceId)
 Returns the license key stored in the database. More...
 
virtual int64_t getTrialStartTime (int32_t familyId, int32_t deviceId)
 Returns the start time of a trial version. More...
 
virtual void decryptScript (const std::vector< char > &input, std::string &output)=0
 
virtual void decryptDeviceDescription (const std::vector< char > &input, std::vector< char > &output)=0
 

Protected Member Functions

struct BaseLib::Licensing::Licensing::LicenseData __attribute__ ((aligned(64)))
 
uint64_t getMapKey (int32_t familyId, int32_t deviceId)
 
virtual void addDevice (int32_t familyId, int32_t deviceId, bool state, std::string licenseKey)
 
virtual void removeDevice (int32_t familyId, int32_t deviceId)
 
virtual void updateDevice (int32_t familyId, int32_t deviceId, bool state, std::string licenseKey)
 
virtual void loadVariables ()
 
virtual void saveVariable (uint64_t index, int32_t intValue)
 
virtual void saveVariable (uint64_t index, int64_t intValue)
 
virtual void saveVariable (uint64_t index, std::string &stringValue)
 
virtual void saveVariable (uint64_t index, std::vector< uint8_t > &binaryValue)
 
virtual void saveVariable (uint64_t index, LicenseData &licenseData)
 

Protected Attributes

BaseLib::SharedObjects_bl = nullptr
 
bool _disposed = false
 
int32_t _moduleId = -1
 
std::map< uint64_t, uint32_t > _variableDatabaseIds
 
std::map< uint64_t, LicenseData_licenseData
 
std::mutex _devicesMutex
 
DeviceStates _devices
 

Member Typedef Documentation

§ DeviceStates

typedef std::map<int32_t, std::map<int32_t, PDeviceInfo> > BaseLib::Licensing::Licensing::DeviceStates

§ PDeviceInfo

Constructor & Destructor Documentation

§ Licensing()

BaseLib::Licensing::Licensing::Licensing ( BaseLib::SharedObjects bl)
explicit

§ ~Licensing()

BaseLib::Licensing::Licensing::~Licensing ( )
virtual

Member Function Documentation

§ __attribute__() [1/2]

struct BaseLib::Licensing::Licensing::LicenseData BaseLib::Licensing::Licensing::__attribute__ ( (aligned(64))  )
protected

§ __attribute__() [2/2]

struct BaseLib::Licensing::Licensing::DeviceInfo BaseLib::Licensing::Licensing::__attribute__ ( (aligned(64))  )

§ addDevice()

void BaseLib::Licensing::Licensing::addDevice ( int32_t  familyId,
int32_t  deviceId,
bool  state,
std::string  licenseKey 
)
protectedvirtual

§ checkLicense()

virtual int32_t BaseLib::Licensing::Licensing::checkLicense ( int32_t  familyId,
int32_t  deviceId,
const std::string &  licenseKey = "" 
)
pure virtual

Checks if a license key is valid.

Parameters
familyIdThe family id the license key is for.
deviceIdThe device id the license key is for or -1 if not applicable.
licenseKeyThe license key to check. If empty the mothod reads the license key for this device from the database.
Returns
Returns -1 on application errors, -2 if the licensing module could not be found, -3 on communication errors, -4 if the activation server returned invalid data, -5 if the license key is invalid, -6 if the license key is valid but blocked, -7 if the activation key validation failed, -8 if no license key was passed and no license key was found in the database, -9 if no license key was passed and the activation key verification failed, -10 if the trial period has expired, 0 if the license key is valid and already known, 1 if the license key is valid and on new activation, 2 on successful trial activation and 3 with valid trial key which is already known.

§ decryptDeviceDescription()

virtual void BaseLib::Licensing::Licensing::decryptDeviceDescription ( const std::vector< char > &  input,
std::vector< char > &  output 
)
pure virtual

§ decryptScript()

virtual void BaseLib::Licensing::Licensing::decryptScript ( const std::vector< char > &  input,
std::string &  output 
)
pure virtual

§ dispose()

void BaseLib::Licensing::Licensing::dispose ( )
virtual

§ getDeviceState()

bool BaseLib::Licensing::Licensing::getDeviceState ( int32_t  familyId,
int32_t  deviceId 
)
virtual

Returns the activation status of a device or family.

Parameters
familyIdThe family id.
deviceIdThe device id or -1.
Returns
Returns true when the device or family is activated otherwise false. When the device is unknown, false is returned.

§ getDeviceStates()

Licensing::DeviceStates BaseLib::Licensing::Licensing::getDeviceStates ( )
virtual

Returns a map with all unlicensed devices.

Returns
Returns a map with all unlicensed devices. The first pair element is the family id the second the device id. When the device id is "-1" the whole device family is not activated.

§ getLicenseKey()

std::string BaseLib::Licensing::Licensing::getLicenseKey ( int32_t  familyId,
int32_t  deviceId 
)
virtual

Returns the license key stored in the database.

Parameters
familyIdThe family id the license key is for.
deviceIdThe device id the license key is for or -1 if not applicable.
Returns
Returns the license key or an empty string if no license key was found.

§ getMapKey()

uint64_t BaseLib::Licensing::Licensing::getMapKey ( int32_t  familyId,
int32_t  deviceId 
)
protected

§ getModuleId()

virtual int32_t BaseLib::Licensing::Licensing::getModuleId ( )
inlinevirtual

§ getTrialStartTime()

int64_t BaseLib::Licensing::Licensing::getTrialStartTime ( int32_t  familyId,
int32_t  deviceId 
)
virtual

Returns the start time of a trial version.

The default method reads the start time from the license key, if it is the format: "trial<unix timestamp in milliseconds>", e. g. "trial1487608697439".

Parameters
familyIdThe family id the license key is for.
deviceIdThe device id the license key is for or -1 if not applicable.
Returns
Returns the start time of a trial version as unix timestamp in milliseconds or -1 if not applicable.

§ init()

virtual bool BaseLib::Licensing::Licensing::init ( )
pure virtual

§ load()

void BaseLib::Licensing::Licensing::load ( )
virtual

§ loadVariables()

void BaseLib::Licensing::Licensing::loadVariables ( )
protectedvirtual

§ removeDevice()

void BaseLib::Licensing::Licensing::removeDevice ( int32_t  familyId,
int32_t  deviceId 
)
protectedvirtual

§ removeLicense()

void BaseLib::Licensing::Licensing::removeLicense ( int32_t  familyId,
int32_t  deviceId 
)
virtual

Removes a license.

Parameters
familyIdThe family id the license key is for.
deviceIdThe device id the license key is for or -1 if not applicable.

§ saveVariable() [1/5]

void BaseLib::Licensing::Licensing::saveVariable ( uint64_t  index,
int32_t  intValue 
)
protectedvirtual

§ saveVariable() [2/5]

void BaseLib::Licensing::Licensing::saveVariable ( uint64_t  index,
int64_t  intValue 
)
protectedvirtual

§ saveVariable() [3/5]

void BaseLib::Licensing::Licensing::saveVariable ( uint64_t  index,
std::string &  stringValue 
)
protectedvirtual

§ saveVariable() [4/5]

void BaseLib::Licensing::Licensing::saveVariable ( uint64_t  index,
std::vector< uint8_t > &  binaryValue 
)
protectedvirtual

§ saveVariable() [5/5]

void BaseLib::Licensing::Licensing::saveVariable ( uint64_t  index,
LicenseData licenseData 
)
protectedvirtual

§ updateDevice()

void BaseLib::Licensing::Licensing::updateDevice ( int32_t  familyId,
int32_t  deviceId,
bool  state,
std::string  licenseKey 
)
protectedvirtual

Member Data Documentation

§ _bl

BaseLib::SharedObjects* BaseLib::Licensing::Licensing::_bl = nullptr
protected

§ _devices

DeviceStates BaseLib::Licensing::Licensing::_devices
protected

§ _devicesMutex

std::mutex BaseLib::Licensing::Licensing::_devicesMutex
protected

§ _disposed

bool BaseLib::Licensing::Licensing::_disposed = false
protected

§ _licenseData

std::map<uint64_t, LicenseData> BaseLib::Licensing::Licensing::_licenseData
protected

§ _moduleId

int32_t BaseLib::Licensing::Licensing::_moduleId = -1
protected

§ _variableDatabaseIds

std::map<uint64_t, uint32_t> BaseLib::Licensing::Licensing::_variableDatabaseIds
protected

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