PLicensing Class Reference

Detailed Description

The PLicensing class is the license manager (singleton) used to manage Papillon licenses for both Core and plugins; thread-safe.

This component is a thread-safe singleton.

Definition at line 38 of file PLicensing.h.

#include <PLicensing.h>

Constructor & Destructor Documentation

◆ ~PLicensing()

virtual PLicensing::~PLicensing ( )
virtual

Destroys this object.

Member Function Documentation

◆ CheckInLicense()

PResult PLicensing::CheckInLicense ( PLicense license)

Gives back the license to the license manager.

Returns the (no more useful because the program will exit or stop activity) license to the server.

Returns PResult::C_OK if the license has been successfully checked-in, another result otherwise.

◆ CheckLicense()

PResult PLicensing::CheckLicense ( PLicense  license)

Check status of the license.

This function needs to be called regularly and it is "cheap" to call.

Returns PResult::C_OK if the license is still valid, another result otherwise.

◆ CheckOutLicense()

PResult PLicensing::CheckOutLicense ( const PString productName,
const PString productVersion,
PLicense license 
)

Tries to retrieve a license.

Asks the server (specified in the license file) in order to obtain a license for the given product at the given version. This class is meant to be used by a single-license program. If another license has already been checked out, it returns true but does nothing. Always remember, if checkOutLicense() fails, to call checkInLicense() straight after to free the allocated memory. This is not automatically done by checkOutLicense() to let you free to retrieve the error code (which is reset by checkInLicense())

Returns PResult::C_OK if the license has been successfully obtained, another result otherwise.

◆ GetInstance()

static PLicensing& PLicensing::GetInstance ( )
static

Returns the unique instance of this license manager.

◆ GetLicenseFilenames()

papillon::PStringList PLicensing::GetLicenseFilenames ( ) const

Returns full list of license filenames currently used by the license manager.

◆ GetLicenseInfo()

PResult PLicensing::GetLicenseInfo ( const PString productName,
papillon::int32 &  total,
papillon::int32 &  used,
PString expiration 
) const

Gets total number of licenses and number of currently used licenses for a specified product.

  • If there is no product with the specified name registered in the License Manager, then the method will return an error and 'total'=-1, 'used'=-1, 'expiration'=1-JAN-1970.
  • If number of licenses is unlimited, 'total' will be 0 and 'used' will always be 0.
  • If the license is permanent (no expiration date), then 'expiration' will be "permanent".

Returns PResult::C_OK if success, another result otherwise.

◆ GetLicenseInfoExt()

PResult PLicensing::GetLicenseInfoExt ( const PString productName,
PVersion version,
papillon::int32 &  total,
papillon::int32 &  used,
PString expiration,
papillon::int32 &  expDays 
) const

Gets license information for the specified product.

  • If there is no product with the specified name registered in the License Manager, then the method will return an error and version='0.0', 'total'=-1, 'used'=-1, 'expiration'=1-JAN-1970.
  • If number of licenses is unlimited, 'total' will be 0 and 'used' will always be 0.
  • If the license is permanent (no expiration date), then 'expiration' will be "permanent"and 'expDays' will be 0.
  • For a license which expires today, 'expDays' will be 1.

Returns PResult::C_OK if success, another result otherwise.

◆ GetListProducts()

PStringList PLicensing::GetListProducts ( ) const

Returns the full list of products which have a license registered in the license manager.

◆ Initialise()

PResult PLicensing::Initialise ( const PString argv0,
const PString license,
PLog::ELogLevel  logLevel 
)

Initialises the license manager.

When using PapillonSDK::Initialise(), you don't need to call this method; see SetLicense() in PapillonSDK.h instead.

Parameters
argv0name of the executable (argv[0]).
license(1) a license file OR (2) a folder which contain 1 or more license file(s) (*.lic) OR (3) "port @ server", the license server to contact to checkout licenses (typically "2764@127.0.0.1") If not provided, local license files (*.lic) will be used (see below).
logLevellog level to be used by this object

If "license" argument is empty, then:

  1. Try to find license files (need at least 1) in the current folder
  2. If no license file found in current folder, then try to find license files in the directory specified by the PAPILLON_INSTALL_DIR environment variable.

Returns PResult::C_OK if success, another result otherwise.

See also
Reset()

◆ IsLicenseServerEnabled()

bool PLicensing::IsLicenseServerEnabled ( ) const

Returns true if the license server is enabled and can be reached, false otherwise.

If no license server available, then try to use local license files.

◆ Reset()

void PLicensing::Reset ( )

Check-in all licenses, close the connection with the license server, reset the license manager.

After having called this function, another call to Initialise() is necessary before any other use of the license handler.

See also
Initialise()

◆ Status()

PString PLicensing::Status ( ) const

Returns the current status of this license manager.

◆ ToString()

PString PLicensing::ToString ( )

Returns a string representation of this object.