added: sessions data for plugins (plugindata.h plugindata.cpp)
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@598 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
@@ -14,6 +14,11 @@
|
||||
#include "data.h"
|
||||
#include "session.h"
|
||||
#include "sessionparser.h"
|
||||
#include "plugin.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
SessionManager::SessionManager()
|
||||
@@ -22,6 +27,7 @@ SessionManager::SessionManager()
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool SessionManager::IsSession(long id)
|
||||
{
|
||||
if( session_table.FindById(id) == session_table.End() )
|
||||
@@ -31,6 +37,7 @@ return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
long SessionManager::CreateSessionId()
|
||||
{
|
||||
long id;
|
||||
@@ -61,6 +68,7 @@ return id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SessionManager::CreateTemporarySession()
|
||||
{
|
||||
SessionContainer::Iterator i = session_table.FindById( 0 );
|
||||
@@ -80,6 +88,7 @@ void SessionManager::CreateTemporarySession()
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SessionManager::CreateSession()
|
||||
{
|
||||
Session s;
|
||||
@@ -97,7 +106,7 @@ int attempts = 100;
|
||||
request.session->new_session = true;
|
||||
|
||||
log << log2 << "SM: created a new session: " << request.session->id << logend;
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -138,6 +147,7 @@ return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SessionManager::SetSession()
|
||||
{
|
||||
CookieTable::iterator i = request.cookie_table.find(data.http_session_id_name);
|
||||
@@ -160,6 +170,14 @@ void SessionManager::SetSession()
|
||||
}
|
||||
|
||||
// request.session is set now
|
||||
|
||||
if( request.session->new_session )
|
||||
{
|
||||
request.session->plugin_data.Resize(plugin.Size());
|
||||
plugin.Call(WINIX_SESSION_CREATED);
|
||||
}
|
||||
|
||||
plugin.Call(WINIX_SESSION_CHANGED);
|
||||
}
|
||||
|
||||
|
||||
@@ -169,6 +187,8 @@ SessionContainer::Iterator SessionManager::SessionBegin()
|
||||
return session_table.Begin();
|
||||
}
|
||||
|
||||
|
||||
|
||||
SessionContainer::Iterator SessionManager::SessionEnd()
|
||||
{
|
||||
return session_table.End();
|
||||
@@ -192,15 +212,50 @@ void SessionManager::DeleteOldSessions()
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SessionManager::DeleteAllPluginsData()
|
||||
{
|
||||
SessionContainer::Iterator i = session_table.Begin();
|
||||
|
||||
Session * old_session = request.session;
|
||||
|
||||
for( ; i!=session_table.End() ; ++i )
|
||||
{
|
||||
request.session = &(*i);
|
||||
i->plugin_data.DeleteAll();
|
||||
}
|
||||
|
||||
request.session = old_session;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void SessionManager::LoadSessions()
|
||||
{
|
||||
SessionParser sp;
|
||||
SessionContainer::Iterator i;
|
||||
|
||||
Session * old_session = request.session;
|
||||
|
||||
sp.Parse(data.session_file, session_table);
|
||||
i = session_table.Begin();
|
||||
|
||||
for( ; i!=session_table.End() ; ++i )
|
||||
{
|
||||
i->plugin_data.Resize(plugin.Size());
|
||||
request.session = &(*i);
|
||||
plugin.Call(WINIX_SESSION_CREATED);
|
||||
}
|
||||
|
||||
request.session = old_session;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void SessionManager::SaveSessions()
|
||||
{
|
||||
if( data.session_file.empty() )
|
||||
|
Reference in New Issue
Block a user