BPS MDE session object. More...
#include <bpsmdesession.h>
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 |
| BpsBarcode * | barcode () 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 |
| BpsDatastore * | datastore () 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. | |
BPS MDE session object.
Used to describe a MDE session and its status.
Save mode for session values.
Local settings are loaded when setting a non-empty UUID. Central settings are loaded at login.
| 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.
| [in] | aAddress | The clients TCP/IP address. |
| [in] | aParent | The parent object. |
| 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.
| [in] | aApplication | The application for which the license token is. |
| [in] | aLicenseToken | The license token. |
| QHostAddress BpsMdeSession::address | ( | ) | const |
| BpsBarcode* BpsMdeSession::barcode | ( | ) | const |
| void BpsMdeSession::clearLicense | ( | BpsMdeApplication * | aApplication | ) |
Clears a distinct license freeing it for others to use.
| [in] | aApplication | The application to free the license for. |
| QString BpsMdeSession::connName | ( | ) | const |
| BpsDatastore* BpsMdeSession::datastore | ( | ) | const |
| QString BpsMdeSession::formToken | ( | ) | const |
| 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.
| [in] | aApplication | The application to check. |
| QDateTime BpsMdeSession::lastAccess | ( | ) | const |
| QList<BpsMdeApplication*> BpsMdeSession::licenseApplications | ( | ) | const |
| void BpsMdeSession::logError | ( | const QString & | aText | ) | [signal] |
Emitted when a error should get logged.
| [in] | aText | The 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.
| [in] | aConnection | The connection name. |
| [in] | aUserId | The numeric user id. |
| [in] | aPinCode | The numeric PIN. |
| BpsException | When login fails. |
| void BpsMdeSession::logInformation | ( | const QString & | aText | ) | [signal] |
Emitted when a information should get logged.
| [in] | aText | The 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.
| [in] | aText | The text to log. |
| void BpsMdeSession::logWarning | ( | const QString & | aText | ) | [signal] |
Emitted when a warning should get logged.
| [in] | aText | The text to log. |
| QString BpsMdeSession::myName | ( | ) | const |
| 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.
| qlonglong BpsMdeSession::sessionId | ( | ) | const |
| 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.
| [in] | aUid | The 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);
| [in] | aKey | The application value key. |
| [in] | aValue | The application value to set. |
| [in] | aSaveMode | If 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.
| [in] | aGroup | The group key. |
| [in] | aKey | The application value key. |
| [in] | aValue | The application value to set. |
| [in] | aSaveMode | If 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 |
| void BpsMdeSession::validateLicense | ( | BpsMdeApplication * | aApplication | ) |
Validates and updates the license token.
Also updates the monitor information.
| [in] | aApplication | The application to validate the token for. |
| BpsException | when validation fails. |
| QVariant BpsMdeSession::value | ( | const QString & | aKey | ) | const |
Get a session data global value.
This is a convenience shortcut for value(QString(), aKey);
| [in] | aKey | The value key. |
| 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);
| [in] | aKey | The value key. |
| [in] | aDefValue | The default value to use in case. |
| QVariant BpsMdeSession::value | ( | const QString & | aGroup, |
| const QString & | aKey | ||
| ) | const |
Get a session data value.
| [in] | aGroup | The group key. |
| [in] | aKey | The value key. |
| QVariant BpsMdeSession::value | ( | const QString & | aGroup, |
| const QString & | aKey, | ||
| const QVariant & | aDefValue | ||
| ) | const |
Get a session data value providing a default value.
| [in] | aGroup | The group key. |
| [in] | aKey | The value key. |
| [in] | aDefValue | The default value to use in case. |