Documents > BPS V2 C++ API
BpsMdeSession Class Reference

BPS MDE session object. More...

#include <bpsmdesession.h>

List of all members.

Public Types

enum  SaveMode {
  S_DontSave,
  S_LocalServer,
  S_CentralUser
}
 Save mode for session values. More...

Signals

void logError (const QString &aText)
 Emitted when a error should get logged.
void logInformation (const QString &aText)
 Emitted when a information should get logged.
void logSuccess (const QString &aText)
 Emitted when a success should get logged.
void logWarning (const QString &aText)
 Emitted when a warning should get logged.

Public Member Functions

void addLicenseToken (BpsMdeApplication *aApplication, BpsLicenseToken *aLicenseToken)
 Add a application license token after logging in.
QHostAddress address () const
BpsBarcodebarcode () const
 BpsMdeSession (const QHostAddress &aAddress, QObject *aParent)
 Creates a disconnected session.
void clearLicense (BpsMdeApplication *aApplication)
 Clears a distinct license freeing it for others to use.
QString connName () const
BpsDatastoredatastore () const
QString formToken () const
bool isLicensedFor (BpsMdeApplication *aApplication)
 Checks if the session has a license token for the application allowing module usage, basically a check BpsLicenseToken::checkLicense() != 0.
QDateTime lastAccess () const
QList< BpsMdeApplication * > licenseApplications () const
void login (const QString &aConnection, int aUserId, int aPinCode)
 Log into the database with the given credentials.
void logout ()
 Log out from database.
QString myName () const
QString nextFormToken ()
 Creates a new form token.
qlonglong sessionId () const
void setUid (const QString &aUid)
 Set the unique terminal identifier.
void setValue (const QString &aKey, const QVariant &aValue, SaveMode aSaveMode=S_DontSave)
 Set a session global value.
void setValue (const QString &aGroup, const QString &aKey, const QVariant &aValue, SaveMode aSaveMode=S_DontSave)
 Set a session value.
void touch ()
 Touch the client.
QString uid () const
void validateLicense (BpsMdeApplication *aApplication)
 Validates and updates the license token.
QVariant value (const QString &aKey) const
 Get a session data global value.
QVariant value (const QString &aKey, const QVariant &aDefValue) const
 Get a session data global value providing a default value.
QVariant value (const QString &aGroup, const QString &aKey) const
 Get a session data value.
QVariant value (const QString &aGroup, const QString &aKey, const QVariant &aDefValue) const
 Get a session data value providing a default value.

Detailed Description

BPS MDE session object.

Used to describe a MDE session and its status.


Member Enumeration Documentation

Save mode for session values.

Local settings are loaded when setting a non-empty UUID. Central settings are loaded at login.

Enumerator:
S_DontSave 

Do not save the to the settings.

S_LocalServer 

Save in the local user settings of the MDE server. Requires a UUID support the device and browser, will silently not save anything for client devices without UUID. This works also while logged out and is used for login credentials primarly.

S_CentralUser 

Save to central user settings. Works only while logged in, will silently not save anything while not logged in.


Constructor & Destructor Documentation

BpsMdeSession::BpsMdeSession ( const QHostAddress &  aAddress,
QObject *  aParent 
)

Creates a disconnected session.

A new session id is created and will be sent to the client upon the next reply.

Parameters:
[in]aAddressThe clients TCP/IP address.
[in]aParentThe parent object.

Member Function Documentation

void BpsMdeSession::addLicenseToken ( BpsMdeApplication aApplication,
BpsLicenseToken aLicenseToken 
)

Add a application license token after logging in.

One license token get added by the login page for each main application.

Parameters:
[in]aApplicationThe application for which the license token is.
[in]aLicenseTokenThe license token.
QHostAddress BpsMdeSession::address ( ) const
Returns:
The clients TCP/IP address.
BpsBarcode* BpsMdeSession::barcode ( ) const
Returns:
The barcode object of the session. Unavailable (0) when isActive() returns false.
void BpsMdeSession::clearLicense ( BpsMdeApplication aApplication)

Clears a distinct license freeing it for others to use.

Parameters:
[in]aApplicationThe application to free the license for.
QString BpsMdeSession::connName ( ) const
Returns:
When logged in the name of the connection. When logged out "-".
BpsDatastore* BpsMdeSession::datastore ( ) const
Returns:
The datastore of the session. Unavailable (0) when isActive() returns false.
QString BpsMdeSession::formToken ( ) const
Returns:
The current form token.
bool BpsMdeSession::isLicensedFor ( BpsMdeApplication aApplication)

Checks if the session has a license token for the application allowing module usage, basically a check BpsLicenseToken::checkLicense() != 0.

Does not mean that there are also enough free licenses available at this time. Main use is to check if a menu item shall be displayed.

If there is no such license token and the datastore is connected, it is assumed to be a free module and true is returned.

If the datastore is not connected, false will be returned.

Parameters:
[in]aApplicationThe application to check.
Returns:
True if ok to display a menu item, false if not.
QDateTime BpsMdeSession::lastAccess ( ) const
Returns:
The last access (touch) time stamp.
QList<BpsMdeApplication*> BpsMdeSession::licenseApplications ( ) const
Returns:
List of the applications having a license token in the session.
void BpsMdeSession::logError ( const QString &  aText) [signal]

Emitted when a error should get logged.

Parameters:
[in]aTextThe text to log.
void BpsMdeSession::login ( const QString &  aConnection,
int  aUserId,
int  aPinCode 
)

Log into the database with the given credentials.

In case the session was already logged in, it is automatically logged out at begin.

Parameters:
[in]aConnectionThe connection name.
[in]aUserIdThe numeric user id.
[in]aPinCodeThe numeric PIN.
Exceptions:
BpsExceptionWhen login fails.
void BpsMdeSession::logInformation ( const QString &  aText) [signal]

Emitted when a information should get logged.

Parameters:
[in]aTextThe text to log.
void BpsMdeSession::logout ( )

Log out from database.

Any license tokens held are cleared and discarded. Does nothing if already logged out. Throws no exception, but creates log entries instead when cleanup operations fail.

void BpsMdeSession::logSuccess ( const QString &  aText) [signal]

Emitted when a success should get logged.

Parameters:
[in]aTextThe text to log.
void BpsMdeSession::logWarning ( const QString &  aText) [signal]

Emitted when a warning should get logged.

Parameters:
[in]aTextThe text to log.
QString BpsMdeSession::myName ( ) const
Returns:
When logged in the user/terminal as "john@10.56.1.7". When logged out, "unknown@10.56.1.7".
QString BpsMdeSession::nextFormToken ( )

Creates a new form token.

Form tokens are used to prevent processing of duplicate submissions. The form html includes a hidden input with name = n_formtoken and value = nextFormToken(). Upon processing the forms POST, the submitted value of n_formtoken is compared against formToken(). If not matching, the post is ignored. If matching, nextFormToken() is called again to invalidate the form's token, and the POST is processed.

Returns:
The new form token.
qlonglong BpsMdeSession::sessionId ( ) const
Returns:
The session id.
void BpsMdeSession::setUid ( const QString &  aUid)

Set the unique terminal identifier.

When setting a non-empty uuid, this method will load persistent session values back from the settings.

Parameters:
[in]aUidThe unique unit id to set.
void BpsMdeSession::setValue ( const QString &  aKey,
const QVariant &  aValue,
SaveMode  aSaveMode = S_DontSave 
)

Set a session global value.

This is a convenience shortcut for setValue(QString(), aKey, aValue, aPersistant);

Parameters:
[in]aKeyThe application value key.
[in]aValueThe application value to set.
[in]aSaveModeIf and where to save the value in the settings.
void BpsMdeSession::setValue ( const QString &  aGroup,
const QString &  aKey,
const QVariant &  aValue,
SaveMode  aSaveMode = S_DontSave 
)

Set a session value.

Parameters:
[in]aGroupThe group key.
[in]aKeyThe application value key.
[in]aValueThe application value to set.
[in]aSaveModeIf and where to save the value in the settings.
void BpsMdeSession::touch ( )

Touch the client.

Done by the MDE server each time a request is received.

QString BpsMdeSession::uid ( ) const
Returns:
The current unique terminal identifier.
void BpsMdeSession::validateLicense ( BpsMdeApplication aApplication)

Validates and updates the license token.

Also updates the monitor information.

Parameters:
[in]aApplicationThe application to validate the token for.
Exceptions:
BpsExceptionwhen validation fails.
QVariant BpsMdeSession::value ( const QString &  aKey) const

Get a session data global value.

This is a convenience shortcut for value(QString(), aKey);

Parameters:
[in]aKeyThe value key.
Returns:
The current value, or an invalid QVariant if no such data exists.
QVariant BpsMdeSession::value ( const QString &  aKey,
const QVariant &  aDefValue 
) const

Get a session data global value providing a default value.

This is a convenience shortcut for value(QString(), aKey, aDefValue);

Parameters:
[in]aKeyThe value key.
[in]aDefValueThe default value to use in case.
Returns:
The current value, or the given default if no such data exists.
QVariant BpsMdeSession::value ( const QString &  aGroup,
const QString &  aKey 
) const

Get a session data value.

Parameters:
[in]aGroupThe group key.
[in]aKeyThe value key.
Returns:
The current value, or an invalid QVariant if no such data exists.
QVariant BpsMdeSession::value ( const QString &  aGroup,
const QString &  aKey,
const QVariant &  aDefValue 
) const

Get a session data value providing a default value.

Parameters:
[in]aGroupThe group key.
[in]aKeyThe value key.
[in]aDefValueThe default value to use in case.
Returns:
The current value, or the given default if no such data exists.

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