8 #ifndef _HttpSession_H_ 9 #define _HttpSession_H_ 16 #include <QMutexLocker> 17 #include <QStringList> 18 #include <QSharedPointer> 22 class HttpSessionStore;
39 QByteArray
id()
const {
40 QMutexLocker locker(&m_mutex);
41 return (m_data == NULL) ? QByteArray() : m_data->id;
48 return m_data != NULL;
56 QMutexLocker locker(&m_mutex);
58 return m_data->values.contains(key);
66 void add(
const QString& key,
const QVariant&
value) {
67 QMutexLocker locker(&m_mutex);
69 m_data->values[key] =
value;
76 void remove(
const QString& key) {
77 QMutexLocker locker(&m_mutex);
79 m_data->values.remove(key);
86 QVariant
value(
const QString& key)
const {
87 QMutexLocker locker(&m_mutex);
88 return (m_data == NULL) ? QVariant() : m_data->values.value(key);
95 QMutexLocker locker(&m_mutex);
96 return (m_data == NULL) ? QDateTime() : m_data->lastAccess;
103 QMutexLocker locker(&m_mutex);
104 if (m_data != NULL) {
105 m_data->lastAccess = QDateTime::currentDateTime();
109 QStringList keys()
const {
111 if (m_data != NULL) {
112 QHashIterator<QString, QVariant> iterator(m_data->values);
113 while (iterator.hasNext()) {
115 list << iterator.key();
122 QVariantHash variantHash()
const {
123 if (m_data == NULL) {
return QVariantHash(); }
124 return m_data->values;
137 #ifndef DOXYGEN_SHOULD_SKIP_THIS 138 QSharedPointer<HttpSessionData> m_data;
139 mutable QMutex m_mutex;
QByteArray id() const
Returns session ID.
QDateTime lastAccess
Time of last access.
HttpSession()
Constructor, should be private. Do not use in your code.
QDateTime lastAccess()
Return time of last access to the session.
Information about one session.
void setLastAccess()
Sets time of last access to the session.
bool isNull() const
Returns true if the session is valid (not null)
QHash< QString, QVariant > values
List of values.
QVariant value(const QString &key) const
Returns an item from the session.
void add(const QString &key, const QVariant &value)
Adds an item to the session.
bool contains(const QString &key) const
Returns true if the session contains key.
HttpSession & operator=(const HttpSession &other)
Operator=(), should be private. Do not use in your code.
Namespace of HTTP server.