2009-04-16 03:59:42 +02:00
|
|
|
/*
|
2010-02-28 01:08:10 +01:00
|
|
|
* This file is a part of Winix
|
2014-10-04 20:04:03 +02:00
|
|
|
* and is distributed under the 2-Clause BSD licence.
|
|
|
|
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2014-02-12 17:30:49 +01:00
|
|
|
* Copyright (c) 2009-2014, Tomasz Sowa
|
2009-04-16 03:59:42 +02:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
2014-10-04 20:04:03 +02:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
|
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
2009-04-16 03:59:42 +02:00
|
|
|
*/
|
|
|
|
|
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>
|
2012-05-27 01:04:49 +02:00
|
|
|
#include "date/date.h"
|
2018-11-21 12:03:53 +01:00
|
|
|
#include "winixbase.h"
|
2009-04-16 03:59:42 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2014-02-12 17:30:49 +01:00
|
|
|
namespace Winix
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-04-16 03:59:42 +02:00
|
|
|
// 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
|
2021-05-20 20:59:12 +02:00
|
|
|
pt::Date start;
|
|
|
|
pt::Date end;
|
2009-04-16 03:59:42 +02:00
|
|
|
|
|
|
|
|
|
|
|
LastItem();
|
|
|
|
bool IsLoggedOut();
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-11-21 12:03:53 +01:00
|
|
|
class LastContainer : public WinixBase
|
2009-04-16 03:59:42 +02:00
|
|
|
{
|
|
|
|
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);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-02-12 17:30:49 +01:00
|
|
|
|
|
|
|
} // namespace Winix
|
|
|
|
|
|
|
|
|
2009-04-16 03:59:42 +02:00
|
|
|
#endif
|