BPS C++ API  2.24.4
BpsMdeSession Class Reference

BPS MDE session object. More...

#include <bpsmdesession.h>

+ Inheritance diagram for BpsMdeSession:

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. More...
 
void logInformation (const QString &aText)
 Emitted when a information should get logged. More...
 
void logSuccess (const QString &aText)
 Emitted when a success should get logged. More...
 
void logWarning (const QString &aText)
 Emitted when a warning should get logged. More...
 

Public Member Functions

void addLicenseToken (BpsMdeApplication *aApplication, BpsLicenseToken *aLicenseToken)
 Add a application license token after logging in. More...
 
QHostAddress address () const
 
BpsBarcodebarcode () const
 
 BpsMdeSession (const QHostAddress &aAddress, QObject *aParent)
 Creates a disconnected session. More...
 
void clearLicense (BpsMdeApplication *aApplication)
 Clears a distinct license freeing it for others to use. More...
 
QString connName () const
 
BpsDatastoredatastore () const
 
void emitError (const QString &aText)
 Emitted en error. More...
 
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. More...
 
QDateTime lastAccess () const
 
QList< BpsMdeApplication * > licenseApplications () const
 
void login (const QString &aConnection, int aUserId, int aPinCode)
 Log into the database with the given credentials. More...
 
void logout ()
 Log out from database. More...
 
QString myName () const
 
QString nextFormToken ()
 Creates a new form token. More...
 
BpsOrderUtilsorderUtils () const
 
qlonglong sessionId () const
 
void setUid (const QString &aUid)
 Set the unique terminal identifier. More...
 
void setValue (const QString &aGroup, const QString &aKey, const QVariant &aValue, SaveMode aSaveMode=S_DontSave)
 Set a session value. More...
 
void setValue (const QString &aKey, const QVariant &aValue, SaveMode aSaveMode=S_DontSave)
 Set a session global value. More...
 
void touch ()
 Touch the client. More...
 
QString uid () const
 
void validateLicense (BpsMdeApplication *aApplication)
 Validates and updates the license token. More...
 
QVariant value (const QString &aGroup, const QString &aKey) const
 Get a session data value. More...
 
QVariant value (const QString &aGroup, const QString &aKey, const QVariant &aDefValue) const
 Get a session data value providing a default value. More...
 
QVariant value (const QString &aKey) const
 Get a session data global value. More...
 
QVariant value (const QString &aKey, const QVariant &aDefValue) const
 Get a session data global value providing a default value. More...
 
QString zoneCond (const QString &aKeyCol, bool aNullOk=false) const
 Create zone condition for a given query column based on the zones the current user has permission for. More...
 
int zoneCount () const
 Get number of zones the current user has permissions for. More...
 
QVariant zoneKey (int aIndex) const
 Get key of a zone the current user has permission for. More...
 
QString zoneName (int aIndex) const
 Get name of a zone the current user has permission for. More...
 
- 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
 

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
 
- 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)
 
- Properties inherited from QObject
 objectName
 

Detailed Description

BPS MDE session object.

Used to describe a MDE session and its status.

Member Enumeration Documentation

◆ SaveMode

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::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
aAddressThe clients TCP/IP address.
aParentThe parent object.

Member Function Documentation

◆ addLicenseToken()

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
aApplicationThe application for which the license token is.
aLicenseTokenThe license token.

◆ address()

QHostAddress BpsMdeSession::address ( ) const
Returns
The clients TCP/IP address.

◆ barcode()

BpsBarcode* BpsMdeSession::barcode ( ) const
Returns
The barcode object of the session. Unavailable (0) when isActive() returns false.

◆ clearLicense()

void BpsMdeSession::clearLicense ( BpsMdeApplication aApplication)

Clears a distinct license freeing it for others to use.

Parameters
aApplicationThe application to free the license for.

◆ connName()

QString BpsMdeSession::connName ( ) const
Returns
When logged in the name of the connection. When logged out "-".

◆ datastore()

BpsDatastore* BpsMdeSession::datastore ( ) const
Returns
The datastore of the session. Unavailable (0) when isActive() returns false.

◆ emitError()

void BpsMdeSession::emitError ( const QString aText)

Emitted en error.

Parameters
aTextThe error text.

◆ formToken()

QString BpsMdeSession::formToken ( ) const
Returns
The current form token.

◆ isLicensedFor()

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
aApplicationThe application to check.
Returns
True if ok to display a menu item, false if not.

◆ lastAccess()

QDateTime BpsMdeSession::lastAccess ( ) const
Returns
The last access (touch) time stamp.

◆ licenseApplications()

QList<BpsMdeApplication*> BpsMdeSession::licenseApplications ( ) const
Returns
List of the applications having a license token in the session.

◆ logError

void BpsMdeSession::logError ( const QString aText)
signal

Emitted when a error should get logged.

Parameters
aTextThe text to log.

◆ login()

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
aConnectionThe connection name.
aUserIdThe numeric user id.
aPinCodeThe numeric PIN.
Exceptions
BpsExceptionWhen login fails.

◆ logInformation

void BpsMdeSession::logInformation ( const QString aText)
signal

Emitted when a information should get logged.

Parameters
aTextThe text to log.

◆ logout()

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.

◆ logSuccess

void BpsMdeSession::logSuccess ( const QString aText)
signal

Emitted when a success should get logged.

Parameters
aTextThe text to log.

◆ logWarning

void BpsMdeSession::logWarning ( const QString aText)
signal

Emitted when a warning should get logged.

Parameters
aTextThe text to log.

◆ myName()

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".

◆ nextFormToken()

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.

◆ orderUtils()

BpsOrderUtils* BpsMdeSession::orderUtils ( ) const
Returns
The order utils object of the session. Unavailable (0) when isActive() returns false.

◆ sessionId()

qlonglong BpsMdeSession::sessionId ( ) const
Returns
The session id.

◆ setUid()

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
aUidThe unique unit id to set.

◆ setValue() [1/2]

void BpsMdeSession::setValue ( const QString aGroup,
const QString aKey,
const QVariant aValue,
SaveMode  aSaveMode = S_DontSave 
)

Set a session value.

Parameters
aGroupThe group key.
aKeyThe application value key.
aValueThe application value to set.
aSaveModeIf and where to save the value in the settings.

◆ setValue() [2/2]

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
aKeyThe application value key.
aValueThe application value to set.
aSaveModeIf and where to save the value in the settings.

◆ touch()

void BpsMdeSession::touch ( )

Touch the client.

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

◆ uid()

QString BpsMdeSession::uid ( ) const
Returns
The current unique terminal identifier.

◆ validateLicense()

void BpsMdeSession::validateLicense ( BpsMdeApplication aApplication)

Validates and updates the license token.

Also updates the monitor information.

Parameters
aApplicationThe application to validate the token for.
Exceptions
BpsExceptionwhen validation fails.

◆ value() [1/4]

QVariant BpsMdeSession::value ( const QString aGroup,
const QString aKey 
) const

Get a session data value.

Parameters
aGroupThe group key.
aKeyThe value key.
Returns
The current value, or an invalid QVariant if no such data exists.

◆ value() [2/4]

QVariant BpsMdeSession::value ( const QString aGroup,
const QString aKey,
const QVariant aDefValue 
) const

Get a session data value providing a default value.

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

◆ value() [3/4]

QVariant BpsMdeSession::value ( const QString aKey) const

Get a session data global value.

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

Parameters
aKeyThe value key.
Returns
The current value, or an invalid QVariant if no such data exists.

◆ value() [4/4]

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
aKeyThe value key.
aDefValueThe default value to use in case.
Returns
The current value, or the given default if no such data exists.

◆ zoneCond()

QString BpsMdeSession::zoneCond ( const QString aKeyCol,
bool  aNullOk = false 
) const

Create zone condition for a given query column based on the zones the current user has permission for.

Parameters
aKeyColName of the zone key column.
aNullOkTrue if NULL shall also be accepted as zone.
Returns
The condition. Example for key "s.c_zone" and NULL's ok: "(s.c_zone is null or s.c_zone in (12,5,3)"

◆ zoneCount()

int BpsMdeSession::zoneCount ( ) const

Get number of zones the current user has permissions for.

The zone list is loaded at login and cleared at logout. The list is ordered by name in case-insensitive manner.

Returns
Zone count.

◆ zoneKey()

QVariant BpsMdeSession::zoneKey ( int  aIndex) const

Get key of a zone the current user has permission for.

Parameters
aIndexIndex if the zone 0 ... zoneCount()-1.
Returns
Zone key.

◆ zoneName()

QString BpsMdeSession::zoneName ( int  aIndex) const

Get name of a zone the current user has permission for.

Parameters
aIndexIndex if the zone 0 ... zoneCount()-1.
Returns
Zone key.

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