Session Class Reference

One UI session. More...

#include <session_manager.h>

Inheritance diagram for Session:
Dictionary_r Dictionary zmm::Object

Public Member Functions

 Session (long timeout)
 Constructor, creates a session with a given timeout.
struct timespec * getLastAccessTime ()
 Returns the time of last access to the session.
long getTimeout ()
zmm::String getID ()
 Returns the session identifier.
void setID (zmm::String sessionID)
 Sets the session identifier.
bool isLoggedIn ()
void logIn ()
void logOut ()
void access ()
zmm::String getUIUpdateIDs ()
 Returns the updateIDs, collected for the sessions, and flushes the storage for the ids.
bool hasUIUpdateIDs ()
void clearUpdateIDs ()
void put (zmm::String key, zmm::String value)
 Adds a new key:value pair to the dictionary.
zmm::String get (zmm::String key)
 Returns the value for a given key.
void remove (zmm::String key)
 Deletes a key value pair.
zmm::String encode ()
 Returns an url encoded version of the whole dictionary.
void clear ()
 Removes all elements from the dictionary.
void decode (zmm::String url)
 Makes a dictionary out of url encoded data.
zmm::Ref< Dictionary_rclone ()
 Makes a shallow copy of the dictionary.
bool isSubsetOf (zmm::Ref< Dictionary > other)
bool isSubsetOf (zmm::Ref< Dictionary > other)
 returns true if the dictionary is a subset of another dictionary.#
bool equals (zmm::Ref< Dictionary > other)
bool equals (zmm::Ref< Dictionary > other)
 checks two dictionaries for equality
zmm::Ref< zmm::Array
< DictionaryElement > > 
getElements ()
void optimize ()
 Frees unnecessary memory.
int size ()
 Returns the number of elements in the dictinary.
zmm::String encodeSimple ()
 It seems that a lot of devices can not cope with a param=value encoded URL, so we will use a simplified encoding scheme.
void decodeSimple (zmm::String url)
 Makes a dictionary out of simplified url encoded data.
void merge (zmm::Ref< Dictionary > other)
 Merge dictionary with another dictionary. If keys with the same name already exist, the existing ones will be overwritten.
void retain ()
void release ()
int getRefCount ()

Static Public Member Functions

static void * operator new (size_t size)
static void operator delete (void *ptr)

Protected Member Functions

void containerChangedUI (int objectID)
 Is called by SessionManager if UI update is needed.
void containerChangedUI (zmm::Ref< zmm::IntArray > objectIDs)
zmm::String _encode (char sep1, char sep2)
 Allow to specify encoding separators.

Protected Attributes

bool updateAll
 True if the ui update id hash became to big and the UI shall update every container.
zmm::Ref< DBRHash< int > > uiUpdateIDs
long timeout
 maximum time the session can be idle (starting from last_access)
struct timespec last_access
 time of last access to the session, returned by getLastAccessTime()
zmm::String sessionID
 arbitrary but unique string representing the ID of the session (returned by getID())
bool loggedIn
zmm::Ref< Mutexmutex
zmm::Ref< zmm::Array
< DictionaryElement > > 
elements
 Array of DictionaryElements, representing our Dictionary.
mt_atomic_t _ref_count

Friends

class SessionManager

Detailed Description

One UI session.

When the user logs in for the first time (via the web UI) a new Session will be created. It then will be used to store various information to support the UI - remember the position of browsing for each driver, remember the page count for each driver and so on.

Definition at line 47 of file session_manager.h.


Constructor & Destructor Documentation

Session::Session ( long  timeout  ) 

Constructor, creates a session with a given timeout.

Parameters:
timeout time in milliseconds after which the session will expire if not accessed.

The session is created with a given timeout, each access to the session updates the last_access value, if last access lies further back than the timeout - the session will be deleted (will time out)

Definition at line 51 of file session_manager.cc.

References access(), INVALID_OBJECT_ID, INVALID_OBJECT_ID_2, loggedIn, MAX_UI_UPDATE_IDS, nil, sessionID, UI_UPDATE_ID_HASH_SIZE, uiUpdateIDs, and updateAll.


Member Function Documentation

String Dictionary::_encode ( char  sep1,
char  sep2 
) [protected, inherited]

Allow to specify encoding separators.

Definition at line 122 of file dictionary.cc.

References Dictionary::elements, and url_escape().

Referenced by Dictionary::encode(), and Dictionary::encodeSimple().

void Session::access (  )  [inline]

Definition at line 76 of file session_manager.h.

References getTimespecNow(), and last_access.

Referenced by Session().

void Dictionary_r::clear (  )  [inline, inherited]

Removes all elements from the dictionary.

Reimplemented from Dictionary.

Definition at line 164 of file dictionary.h.

References Dictionary_r::mutex.

void Session::clearUpdateIDs (  ) 

Definition at line 129 of file session_manager.cc.

References AUTOLOCK, log_debug, Dictionary_r::mutex, uiUpdateIDs, and updateAll.

zmm::Ref<Dictionary_r> Dictionary_r::clone (  )  [inline, inherited]

Makes a shallow copy of the dictionary.

Reimplemented from Dictionary.

Definition at line 178 of file dictionary.h.

References Dictionary::clone(), Dictionary_r::mutex, and RefCast.

void Session::containerChangedUI ( zmm::Ref< zmm::IntArray objectIDs  )  [protected]

Definition at line 81 of file session_manager.cc.

References AUTOLOCK, MAX_UI_UPDATE_IDS, Dictionary_r::mutex, nil, uiUpdateIDs, and updateAll.

void Session::containerChangedUI ( int  objectID  )  [protected]

Is called by SessionManager if UI update is needed.

Parameters:
objectID the container that needs to be updated

Definition at line 61 of file session_manager.cc.

References AUTOLOCK, INVALID_OBJECT_ID, MAX_UI_UPDATE_IDS, Dictionary_r::mutex, uiUpdateIDs, and updateAll.

void Dictionary_r::decode ( zmm::String  url  )  [inline, inherited]

Makes a dictionary out of url encoded data.

Reimplemented from Dictionary.

Definition at line 171 of file dictionary.h.

References Dictionary_r::mutex.

void Dictionary::decodeSimple ( zmm::String  url  )  [inherited]

Makes a dictionary out of simplified url encoded data.

Definition at line 174 of file dictionary.cc.

References zmm::String::index(), zmm::String::length(), Dictionary::put(), zmm::String::substring(), and url_unescape().

zmm::String Dictionary_r::encode (  )  [inline, inherited]

Returns an url encoded version of the whole dictionary.

Reimplemented from Dictionary.

Definition at line 156 of file dictionary.h.

References Dictionary_r::mutex.

String Dictionary::encodeSimple (  )  [inherited]

It seems that a lot of devices can not cope with a param=value encoded URL, so we will use a simplified encoding scheme.

Definition at line 142 of file dictionary.cc.

References Dictionary::_encode().

bool Dictionary::equals ( zmm::Ref< Dictionary other  )  [inherited]

checks two dictionaries for equality

Definition at line 242 of file dictionary.cc.

References Dictionary::isSubsetOf().

bool Dictionary_r::equals ( zmm::Ref< Dictionary other  )  [inline, inherited]

Definition at line 194 of file dictionary.h.

References Dictionary_r::mutex.

zmm::String Dictionary_r::get ( zmm::String  key  )  [inline, inherited]

Returns the value for a given key.

Reimplemented from Dictionary.

Definition at line 141 of file dictionary.h.

References Dictionary_r::mutex.

zmm::Ref<zmm::Array<DictionaryElement> > Dictionary_r::getElements (  )  [inline, inherited]

Reimplemented from Dictionary.

Definition at line 202 of file dictionary.h.

References Dictionary_r::mutex.

zmm::String Session::getID (  )  [inline]

Returns the session identifier.

Definition at line 65 of file session_manager.h.

References sessionID.

struct timespec* Session::getLastAccessTime (  )  [inline, read]

Returns the time of last access to the session.

Returns:
pointer to a timespec

Definition at line 60 of file session_manager.h.

References last_access.

int Object::getRefCount (  )  [inherited]

Definition at line 78 of file object.cc.

References zmm::Object::_ref_count, and atomic_get().

long Session::getTimeout (  )  [inline]

Definition at line 62 of file session_manager.h.

String Session::getUIUpdateIDs (  ) 

Returns the updateIDs, collected for the sessions, and flushes the storage for the ids.

Returns:
the container ids to be updated as String (comma separated)

Definition at line 103 of file session_manager.cc.

References _, AUTOLOCK, hash_data_array_t< KT >::data, hasUIUpdateIDs(), intArrayToCSV(), Dictionary_r::mutex, nil, hash_data_array_t< KT >::size, uiUpdateIDs, and updateAll.

bool Session::hasUIUpdateIDs (  ) 

Definition at line 121 of file session_manager.cc.

References uiUpdateIDs, and updateAll.

Referenced by getUIUpdateIDs().

bool Session::isLoggedIn (  )  [inline]

Definition at line 70 of file session_manager.h.

References loggedIn.

bool Dictionary::isSubsetOf ( zmm::Ref< Dictionary other  )  [inherited]

returns true if the dictionary is a subset of another dictionary.#

Definition at line 231 of file dictionary.cc.

References Dictionary::elements.

Referenced by Dictionary::equals().

bool Dictionary_r::isSubsetOf ( zmm::Ref< Dictionary other  )  [inline, inherited]

Definition at line 186 of file dictionary.h.

References Dictionary_r::mutex.

void Session::logIn (  )  [inline]

Definition at line 72 of file session_manager.h.

References loggedIn.

void Session::logOut (  )  [inline]

Definition at line 74 of file session_manager.h.

References loggedIn.

void Dictionary::merge ( zmm::Ref< Dictionary other  )  [inherited]

Merge dictionary with another dictionary. If keys with the same name already exist, the existing ones will be overwritten.

Definition at line 217 of file dictionary.cc.

References nil, and Dictionary::put().

void Object::operator delete ( void *  ptr  )  [static, inherited]

Definition at line 87 of file object.cc.

References FREE.

void * Object::operator new ( size_t  size  )  [static, inherited]

Definition at line 83 of file object.cc.

References MALLOC.

void Dictionary_r::optimize (  )  [inline, inherited]

Frees unnecessary memory.

Reimplemented from Dictionary.

Definition at line 210 of file dictionary.h.

References Dictionary_r::mutex.

void Dictionary_r::put ( zmm::String  key,
zmm::String  value 
) [inline, inherited]

Adds a new key:value pair to the dictionary.

Reimplemented from Dictionary.

Definition at line 134 of file dictionary.h.

References Dictionary_r::mutex.

void Object::release (  )  [inherited]
void Dictionary_r::remove ( zmm::String  key  )  [inline, inherited]

Deletes a key value pair.

Reimplemented from Dictionary.

Definition at line 149 of file dictionary.h.

References Dictionary_r::mutex.

void Object::retain (  )  [inherited]
void Session::setID ( zmm::String  sessionID  )  [inline]

Sets the session identifier.

Definition at line 68 of file session_manager.h.

int Dictionary::size (  )  [inherited]

Returns the number of elements in the dictinary.

Definition at line 104 of file dictionary.cc.

References Dictionary::elements.


Friends And Related Function Documentation

friend class SessionManager [friend]

Definition at line 111 of file session_manager.h.


Field Documentation

mt_atomic_t zmm::Object::_ref_count [protected, inherited]
struct timespec Session::last_access [read, protected]

time of last access to the session, returned by getLastAccessTime()

Definition at line 104 of file session_manager.h.

Referenced by access(), and getLastAccessTime().

bool Session::loggedIn [protected]

Definition at line 109 of file session_manager.h.

Referenced by isLoggedIn(), logIn(), logOut(), and Session().

zmm::Ref<Mutex> Dictionary_r::mutex [protected, inherited]

arbitrary but unique string representing the ID of the session (returned by getID())

Definition at line 107 of file session_manager.h.

Referenced by getID(), and Session().

long Session::timeout [protected]

maximum time the session can be idle (starting from last_access)

Definition at line 101 of file session_manager.h.

bool Session::updateAll [protected]

True if the ui update id hash became to big and the UI shall update every container.

Definition at line 96 of file session_manager.h.

Referenced by clearUpdateIDs(), containerChangedUI(), getUIUpdateIDs(), hasUIUpdateIDs(), and Session().


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

Generated on Fri Mar 26 20:16:57 2010 for MediaTomb by  doxygen 1.6.1