2009-04-16 03:59:42 +02:00
|
|
|
/*
|
2010-02-28 01:08:10 +01:00
|
|
|
* This file is a part of Winix
|
2009-04-16 03:59:42 +02:00
|
|
|
* and is not publicly distributed
|
|
|
|
*
|
|
|
|
* Copyright (c) 2009, Tomasz Sowa
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2011-01-23 15:15:30 +01:00
|
|
|
#ifndef headerfile_winix_core_lastcontainer
|
|
|
|
#define headerfile_winix_core_lastcontainer
|
2009-04-16 03:59:42 +02:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <list>
|
|
|
|
#include <cstring>
|
|
|
|
#include <ctime>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// how many items we store in the 'last' function
|
2011-01-23 15:15:30 +01:00
|
|
|
#define WINIX_LASTCONTAINER_TABLE_SIZE 100
|
2009-04-16 03:59:42 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct LastItem
|
|
|
|
{
|
|
|
|
long user_id;
|
|
|
|
|
|
|
|
// additional we store the whole string-name
|
|
|
|
// (you can delete a user from the database but we can still print the name)
|
2010-11-21 01:19:17 +01:00
|
|
|
std::wstring name;
|
2009-04-16 03:59:42 +02:00
|
|
|
|
|
|
|
// ip address
|
|
|
|
unsigned int ip;
|
|
|
|
|
|
|
|
// session id (used when logging out)
|
|
|
|
long session_id;
|
|
|
|
|
|
|
|
// start logging and end logging
|
|
|
|
tm start;
|
|
|
|
tm end;
|
|
|
|
|
|
|
|
|
|
|
|
LastItem();
|
|
|
|
bool IsLoggedOut();
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class LastContainer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
typedef std::list<LastItem> LastTab;
|
|
|
|
typedef LastTab::iterator Iterator;
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
Iterator Begin();
|
|
|
|
Iterator End();
|
2010-11-21 01:19:17 +01:00
|
|
|
void UserLogin(long user_id, const std::wstring & name, unsigned int ip, long session_id);
|
2009-04-16 03:59:42 +02:00
|
|
|
void UserLogout(long user_id, long session_id);
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
LastTab last_tab;
|
|
|
|
Iterator FindNotLoggedOut(long user_id, long session_id);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|