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
|
|
|
|
*
|
2009-04-21 22:50:55 +02:00
|
|
|
* Copyright (c) 2008-2009, Tomasz Sowa
|
2008-12-10 05:42:49 +01:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "session.h"
|
|
|
|
|
|
|
|
|
2009-04-21 22:50:55 +02:00
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
Session::Session()
|
|
|
|
{
|
|
|
|
Clear();
|
|
|
|
|
|
|
|
time = std::time(0);
|
2009-01-31 07:53:36 +01:00
|
|
|
tm_time = *std::localtime(&time);
|
|
|
|
|
|
|
|
last_time = time;
|
|
|
|
tm_last_time = tm_time;
|
2008-12-10 05:42:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
2009-11-17 00:36:38 +01:00
|
|
|
rebus_item = 0;
|
|
|
|
|
2009-02-06 14:12:03 +01:00
|
|
|
dir_old.clear();
|
2008-12-10 05:42:49 +01:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-06 14:12:03 +01:00
|
|
|
void Session::IncrementTimersIfExist()
|
|
|
|
{
|
|
|
|
if( done_timer != 0 )
|
|
|
|
++done_timer;
|
|
|
|
}
|