rewritten: sessions management

(Session, SessionContainer, SessionManager)
           now a Session object don't copy all fields in its copy constructor (only id)
           the rest fields are set after the object is inserted in SessionContainer
added:     after successfully login a session id is changed
added:     plugin.Call() methods with a first argument a pointer to a Session object



git-svn-id: svn://ttmath.org/publicrep/winix/trunk@823 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2012-03-17 05:11:23 +00:00
parent 70421b7bd1
commit e83fd91423
25 changed files with 444 additions and 183 deletions

View File

@@ -10,10 +10,49 @@
#include "plugindata.h"
#include "plugin.h"
#include "log.h"
#include "session.h"
PluginData::PluginData()
{
session = 0;
}
PluginData::PluginData(const PluginData & p)
{
operator=(p);
}
PluginData & PluginData::operator=(const PluginData & p)
{
// we don't copy all pointers - only resize the table
// pointers will be set to zero
Resize(p.Size());
session = 0;
return *this;
}
PluginData::~PluginData()
{
DeleteAll();
}
void PluginData::SetSession(Session * ses)
{
session = ses;
}
void PluginData::Assign(size_t index, PluginDataBase * data)
{
@@ -62,44 +101,37 @@ return Get(plugin.current_plugin);
void PluginData::DeleteAll()
{
if( table.empty() )
return;
bool all_null = true;
/*
when we copy a session's object (and this object then)
we resize the table and there are only null pointers there
consequently if all pointers are null there is no sens
to send WINIX_PLUGIN_SESSION_DATA_REMOVE
*/
for(size_t i=0 ; i<table.size() ; ++i)
{
if( table[i] != 0 )
{
all_null = false;
break;
}
}
/*
in the future this message may be removed
and we directly 'delete' the pointers
*/
if( !all_null )
plugin.Call(session, WINIX_PLUGIN_SESSION_DATA_REMOVE);
plugin.Call(WINIX_SESSION_REMOVE);
table.clear();
}
PluginData::PluginData()
{
}
PluginData::PluginData(const PluginData & p)
{
operator=(p);
}
PluginData & PluginData::operator=(const PluginData & p)
{
// we don't copy all pointers - only resize the table
// pointers will be set to zero
Resize(p.Size());
return *this;
}
PluginData::~PluginData()
{
DeleteAll();
}
size_t PluginData::Size() const