2008-12-10 05:42:49 +01:00
|
|
|
/*
|
|
|
|
* This file is a part of CMSLU -- Content Management System like Unix
|
|
|
|
* and is not publicly distributed
|
|
|
|
*
|
|
|
|
* Copyright (c) 2008, Tomasz Sowa
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "session.h"
|
|
|
|
|
|
|
|
|
|
|
|
Session::Session()
|
|
|
|
{
|
|
|
|
Clear();
|
|
|
|
|
|
|
|
time = std::time(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Session::Clear()
|
|
|
|
{
|
|
|
|
id = 0;
|
|
|
|
time = 0;
|
2008-12-21 22:17:09 +01:00
|
|
|
puser = 0;
|
2008-12-10 05:42:49 +01:00
|
|
|
done = Done::none;
|
|
|
|
done_status = Error::ok;
|
|
|
|
item.Clear();
|
|
|
|
done_timer = 0;
|
|
|
|
}
|
|
|
|
|
2008-12-30 02:05:03 +01:00
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
bool Session::operator==(const Session & s) const
|
|
|
|
{
|
|
|
|
return id == s.id;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool Session::operator<(const Session & s) const
|
|
|
|
{
|
|
|
|
return id < s.id;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool Session::DecTimer(int & timer)
|
|
|
|
{
|
|
|
|
if( timer == 0 )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
--timer;
|
|
|
|
|
|
|
|
if( timer == 0 )
|
|
|
|
return true; // we must clear our variables
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Session::CheckTimers()
|
|
|
|
{
|
|
|
|
if( DecTimer(done_timer) )
|
|
|
|
{
|
|
|
|
done = Done::none;
|
|
|
|
done_status = Error::ok;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|