start working on 0.7.x branch
- added FileLog which stores content to the file log - now Log is only a wrapper - it puts messages to the local buffer and when logsave is used then the buffer is put to FileLog - new base classes: WinixBase (Log, Config*, Synchro*) WinixModel : public WinixBase (morm::ModelConnector*, Plugin*) WinixSystem : public WinixModel (System*) WinixRequest : public WinixSystem (SLog, Cur*) - singletons: log, slog, plugin are depracated - now references to them are in base classses (WinixBase, WinixModel) - DbBase, DbConn and Db are depracated - now we are using Morm project (in WinixModel there is a model_connector pointer) each thread will have its own ModelConnector git-svn-id: svn://ttmath.org/publicrep/winix/branches/0.7.x@1146 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1 +1 @@
|
||||
o = acceptbaseparser.o app.o basethread.o bbcodeparser.o compress.o config.o crypt.o dircontainer.o dirs.o groups.o htmlfilter.o httpsimpleparser.o image.o ipbancontainer.o item.o job.o lastcontainer.o loadavg.o lock.o log.o misc.o mount.o mountparser.o mounts.o plugin.o plugindata.o postmultiparser.o rebus.o request.o run.o session.o sessioncontainer.o sessionidmanager.o sessionmanager.o sessionparser.o slog.o synchro.o system.o threadmanager.o timezone.o timezones.o user.o users.o
|
||||
o = acceptbaseparser.o app.o basethread.o bbcodeparser.o compress.o config.o crypt.o dircontainer.o dirs.o filelog.o groups.o htmlfilter.o httpsimpleparser.o image.o ipbancontainer.o item.o job.o lastcontainer.o loadavg.o lock.o log.o misc.o mount.o mountparser.o mounts.o plugin.o plugindata.o postmultiparser.o rebus.o request.o run.o session.o sessioncontainer.o sessionidmanager.o sessionmanager.o sessionparser.o slog.o synchro.o system.o threadmanager.o timezone.o timezones.o user.o users.o winixbase.o winixmodel.o winixrequest.o winixsystem.o
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* Copyright (c) 2008-2018, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -36,6 +36,7 @@
|
||||
#define headerfile_winix_core_acceptbaseparser
|
||||
|
||||
#include <string>
|
||||
#include "winixbase.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
@@ -46,7 +47,7 @@ namespace Winix
|
||||
|
||||
// sample (you must create your own class derived from this one):
|
||||
// object.Parse(L" text/html ; , ; q = 45, application / xhtml+xml ; q = 0.4 , application/xml ; q = 0.9 , */* ; q = 0.8 ");
|
||||
class AcceptBaseParser
|
||||
class AcceptBaseParser : public WinixBase
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@
|
||||
#include "convert/convert.h"
|
||||
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
@@ -64,36 +65,76 @@ App::App()
|
||||
last_sessions_save = std::time(0);
|
||||
fcgi_socket = -1;
|
||||
|
||||
log.SetLogBuffer(&log_buffer);
|
||||
log.SetFileLog(&file_log);
|
||||
log.Init(config.log_level, config.log_save_each_line, config.log_request);
|
||||
|
||||
// objects dependency for main thread
|
||||
winix_base.set_config(&config);
|
||||
winix_base.set_log_buffer(&log_buffer);
|
||||
winix_base.set_file_log(&file_log);
|
||||
winix_base.set_synchro(&synchro);
|
||||
|
||||
winix_model.set_dependency(&winix_base);
|
||||
winix_model.set_plugin(&plugin);
|
||||
winix_model.set_model_connector(&model_connector);
|
||||
|
||||
winix_system.set_dependency(&winix_model);
|
||||
winix_system.set_system(&system);
|
||||
|
||||
winix_request.set_dependency(&winix_system);
|
||||
winix_request.set_cur(&cur);
|
||||
winix_request.set_session_manager(&session_manager);
|
||||
winix_request.set_locale(&TemplatesFunctions::locale);
|
||||
// //////////////////////////////////
|
||||
|
||||
|
||||
config.SetFileLog(&file_log);
|
||||
|
||||
|
||||
// temporary there is only one request
|
||||
cur.request = &req;
|
||||
cur.session = session_manager.GetTmpSession();
|
||||
cur.mount = system.mounts.GetEmptyMount();
|
||||
|
||||
db_conn.set_dependency(&winix_base);
|
||||
|
||||
db.set_dependency(&winix_base);
|
||||
db.SetConn(db_conn);
|
||||
|
||||
plugin.set_dependency(&winix_base);
|
||||
plugin.SetDb(&db);
|
||||
plugin.SetConfig(&config);
|
||||
//plugin.SetConfig(&config);
|
||||
plugin.SetCur(&cur);
|
||||
plugin.SetSystem(&system);
|
||||
plugin.SetFunctions(&functions);
|
||||
plugin.SetTemplates(&templates);
|
||||
plugin.SetSynchro(&synchro);
|
||||
//plugin.SetSynchro(&synchro);
|
||||
plugin.SetSessionManager(&session_manager);
|
||||
plugin.SetWinixSystem(&winix_system);
|
||||
|
||||
req.SetConfig(&config);
|
||||
|
||||
functions.SetConfig(&config);
|
||||
functions.set_dependency(&winix_request);
|
||||
// functions.set_config(&config);
|
||||
// functions.set_file_log(&file_log);
|
||||
// functions.set_model_connector(&model_connector);
|
||||
// functions.set_synchro(&synchro);
|
||||
|
||||
//functions.SetConfig(&config);
|
||||
functions.SetCur(&cur);
|
||||
functions.SetDb(&db);
|
||||
functions.SetSystem(&system);
|
||||
functions.SetTemplates(&templates);
|
||||
functions.SetSynchro(&synchro);
|
||||
//functions.SetSynchro(&synchro);
|
||||
functions.SetSessionManager(&session_manager);
|
||||
|
||||
system.SetConfig(&config);
|
||||
|
||||
system.set_dependency(&winix_model);
|
||||
//system.SetConfig(&config);
|
||||
system.SetCur(&cur);
|
||||
system.SetDb(&db);
|
||||
system.SetSynchro(&synchro);
|
||||
//system.SetSynchro(&synchro);
|
||||
system.SetFunctions(&functions);
|
||||
system.SetSessionManager(&session_manager);
|
||||
|
||||
@@ -104,20 +145,33 @@ App::App()
|
||||
templates.SetFunctions(&functions);
|
||||
templates.SetSessionManager(&session_manager);
|
||||
|
||||
session_manager.set_dependency(&winix_model); // zobaczyc czy wskoczy do przeciazonej metody w session manager
|
||||
session_manager.SetLastContainer(&system.users.last);
|
||||
session_manager.SetConfig(&config);
|
||||
session_manager.SetCur(&cur);
|
||||
session_manager.SetSystem(&system);
|
||||
session_manager.SetSynchro(&synchro);
|
||||
|
||||
post_multi_parser.set_dependency(&winix_base);
|
||||
post_multi_parser.SetConfig(&config);
|
||||
|
||||
slog.SetCur(&cur);
|
||||
slog.SetLocale(&TemplatesFunctions::locale);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void App::InitFileLog()
|
||||
{
|
||||
file_log.set_synchro(&synchro);
|
||||
file_log.set_time_zones(&system.time_zones);
|
||||
file_log.init(config.log_file, config.log_stdout, config.log_time_zone_id);
|
||||
}
|
||||
|
||||
|
||||
void App::InitPlugins()
|
||||
{
|
||||
plugin.LoadPlugins(config.plugins_dir, config.plugin_file);
|
||||
}
|
||||
|
||||
|
||||
bool App::InitFCGI(char * sock, char * sock_user, char * sock_group)
|
||||
{
|
||||
if( !WideToUTF8(config.fcgi_socket, sock, WINIX_OS_PATH_SIZE) )
|
||||
@@ -213,14 +267,27 @@ return true;
|
||||
|
||||
bool App::Init()
|
||||
{
|
||||
// temporarily
|
||||
logger.init(config.log_level, config.log_save_each_line, L"/var/log/www/db.log", config.log_stdout);
|
||||
|
||||
postgresql_connector.set_logger(logger);
|
||||
postgresql_connector.set_conn_param(config.db_database, config.db_user, config.db_pass);
|
||||
postgresql_connector.wait_for_connection();
|
||||
|
||||
model_connector.set_flat_connector(json_connector);
|
||||
model_connector.set_db_connector(postgresql_connector);
|
||||
//model_connector.set_doc_connector(doc_html_connector);
|
||||
|
||||
db_conn.SetConnParam(config.db_database, config.db_user, config.db_pass);
|
||||
db_conn.WaitForConnection();
|
||||
db.PostgreSQLsmallerThan10(config.db_postgresql_smaller_than_10);
|
||||
db.LogQueries(config.log_db_query);
|
||||
|
||||
cur.request->Clear();
|
||||
compress.set_dependency(&winix_base);
|
||||
compress.Init();
|
||||
system.Init();
|
||||
|
||||
functions.Init();
|
||||
templates.Init(); // init templates after functions are created
|
||||
|
||||
@@ -234,9 +301,14 @@ bool App::Init()
|
||||
|
||||
CreateStaticTree();
|
||||
|
||||
post_parser.set_dependency(&winix_model);
|
||||
post_parser.LogValueSize(config.log_post_value_size);
|
||||
// post_multi_parser has a pointer to the config
|
||||
|
||||
cookie_parser.set_dependency(&winix_model);
|
||||
|
||||
accept_encoding_parser.set_dependency(&winix_base);
|
||||
|
||||
plugin.Call((Session*)0, WINIX_PLUGIN_INIT);
|
||||
|
||||
return true;
|
||||
@@ -246,10 +318,21 @@ return true;
|
||||
|
||||
void App::Close()
|
||||
{
|
||||
session_manager.SaveSessions();
|
||||
session_manager.DeleteSessions();
|
||||
cur.request->Clear();
|
||||
session_manager.UninitTmpSession();
|
||||
{
|
||||
Winix::Lock lock(synchro);
|
||||
|
||||
plugin.Call((Winix::Session*)0, WINIX_CLOSE);
|
||||
|
||||
session_manager.SaveSessions();
|
||||
session_manager.DeleteSessions();
|
||||
cur.request->Clear();
|
||||
session_manager.UninitTmpSession();
|
||||
|
||||
// now all sessions are cleared
|
||||
}
|
||||
|
||||
WaitForThreads();
|
||||
// now all others threads are terminated
|
||||
}
|
||||
|
||||
|
||||
@@ -673,7 +756,9 @@ void App::Make()
|
||||
if( cur.session->ip_ban && cur.session->ip_ban->IsIPBanned() )
|
||||
{
|
||||
PT::Date date(cur.session->ip_ban->expires);
|
||||
slog << logerror << T("this_ip_is_banned_until") << ' ' << date << " UTC" << logend;
|
||||
|
||||
// IMPROVE ME there is no slog now
|
||||
//slog << logerror << T("this_ip_is_banned_until") << ' ' << date << " UTC" << logend;
|
||||
|
||||
cur.request->status = WINIX_ERR_PERMISSION_DENIED;
|
||||
}
|
||||
@@ -972,7 +1057,7 @@ void App::SetSubdomain()
|
||||
void App::LogAccess()
|
||||
{
|
||||
log << log1;
|
||||
log.PrintDate(cur.request->start_date, config.log_time_zone_id);
|
||||
log.PrintDate(cur.request->start_date);
|
||||
|
||||
log << ' '
|
||||
<< cur.request->ip_str << ' '
|
||||
|
||||
@@ -45,11 +45,6 @@
|
||||
#include <errno.h>
|
||||
#include <fcgiapp.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "system.h"
|
||||
#include "mounts.h"
|
||||
#include "request.h"
|
||||
#include "synchro.h"
|
||||
#include "sessionmanager.h"
|
||||
#include "db/db.h"
|
||||
#include "functions/functions.h"
|
||||
@@ -61,6 +56,10 @@
|
||||
#include "acceptencodingparser.h"
|
||||
#include "space/jsontospaceparser.h"
|
||||
|
||||
#include "winixrequest.h"
|
||||
#include "logger/logger.h"
|
||||
#include "filelog.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
@@ -76,6 +75,8 @@ public:
|
||||
|
||||
bool InitFCGI();
|
||||
bool DropPrivileges();
|
||||
void InitFileLog();
|
||||
void InitPlugins();
|
||||
bool Init();
|
||||
void Start();
|
||||
void Close();
|
||||
@@ -101,7 +102,7 @@ public:
|
||||
// users sessions
|
||||
SessionManager session_manager;
|
||||
|
||||
// database
|
||||
// database (DEPRACATED)
|
||||
Db db;
|
||||
DbConn db_conn;
|
||||
|
||||
@@ -129,6 +130,11 @@ public:
|
||||
Templates templates;
|
||||
|
||||
|
||||
|
||||
FileLog file_log;
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
enum Header
|
||||
@@ -162,6 +168,27 @@ private:
|
||||
std::wstring http_header;
|
||||
std::string http_header_8bit;
|
||||
|
||||
PT::Logger logger; // temporarily
|
||||
morm::ModelConnector model_connector; // main thread model connector, each thread has its own connector
|
||||
morm::JSONConnector json_connector;
|
||||
morm::PostgreSQLConnector postgresql_connector;
|
||||
|
||||
// objects for main thread
|
||||
WinixBase winix_base;
|
||||
WinixModel winix_model;
|
||||
WinixSystem winix_system;
|
||||
WinixRequest winix_request;
|
||||
// ///////////////////////
|
||||
|
||||
Plugin plugin;
|
||||
|
||||
//////////////////////////
|
||||
|
||||
// log_buffer for the main thread
|
||||
TextStream<std::wstring> log_buffer;
|
||||
|
||||
// logger only for App object
|
||||
Log log;
|
||||
|
||||
bool InitFCGI(char * sock, char * sock_user, char * sock_group);
|
||||
bool InitFCGIChmodChownSocket(char * sock, char * sock_user, char * sock_group);
|
||||
|
||||
@@ -37,6 +37,8 @@
|
||||
|
||||
#include <pthread.h>
|
||||
#include "synchro.h"
|
||||
#include "winixmodel.h"
|
||||
|
||||
|
||||
|
||||
namespace Winix
|
||||
@@ -45,7 +47,7 @@ namespace Winix
|
||||
|
||||
|
||||
|
||||
class BaseThread
|
||||
class BaseThread : public WinixModel
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include <cstring>
|
||||
#include <zlib.h>
|
||||
#include "requesttypes.h"
|
||||
#include "winixbase.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
@@ -45,7 +46,7 @@ namespace Winix
|
||||
|
||||
|
||||
|
||||
class Compress
|
||||
class Compress : public WinixBase
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
|
||||
#include "config.h"
|
||||
#include "log.h"
|
||||
#include "plugin.h"
|
||||
#include "misc.h"
|
||||
#include "crypt.h"
|
||||
|
||||
@@ -50,9 +49,13 @@ Config::Config()
|
||||
}
|
||||
|
||||
|
||||
void Config::SetFileLog(FileLog * file_log)
|
||||
{
|
||||
log.SetFileLog(file_log);
|
||||
|
||||
//!! czy tu w ogole mozemy uzywac log << ?
|
||||
//!! przeciez jeszcze nie zostal przetworzony plik konfiguracyjny
|
||||
// the config is not read yet so we put some constants here
|
||||
log.Init(3, false, 1);
|
||||
}
|
||||
|
||||
|
||||
void Config::ShowError()
|
||||
@@ -130,7 +133,6 @@ void Config::AssignValues(bool stdout_is_closed)
|
||||
additional_groups = Bool(L"additional_groups", true);
|
||||
|
||||
log_file = Text(L"log_file");
|
||||
log_notify_file = Text(L"log_notify_file");
|
||||
log_delimiter = Text(L"log_delimiter", L"---------------------------------------------------------------------------------");
|
||||
fcgi_socket = Text(L"fcgi_socket");
|
||||
fcgi_socket_chmod = Int(L"fcgi_socket_chmod", 0770);
|
||||
|
||||
@@ -38,6 +38,9 @@
|
||||
#include <string>
|
||||
#include "space/spaceparser.h"
|
||||
#include "htmlfilter.h"
|
||||
#include "log.h"
|
||||
#include "filelog.h"
|
||||
|
||||
|
||||
|
||||
namespace Winix
|
||||
@@ -80,8 +83,8 @@ public:
|
||||
// default: true
|
||||
bool additional_groups;
|
||||
|
||||
// log file name, log file name for notifications (sending emails, etc)
|
||||
std::wstring log_file, log_notify_file;
|
||||
// log file name
|
||||
std::wstring log_file;
|
||||
|
||||
// the log level (how much info should be inserted to logs)
|
||||
// 1 - minimum
|
||||
@@ -818,11 +821,13 @@ public:
|
||||
// raw access to the config
|
||||
PT::Space space;
|
||||
|
||||
void SetFileLog(FileLog * file_log);
|
||||
|
||||
private:
|
||||
|
||||
PT::SpaceParser parser;
|
||||
bool errors_to_stdout;
|
||||
Log log;
|
||||
|
||||
void ShowError();
|
||||
void AssignValues(bool stdout_is_closed);
|
||||
|
||||
@@ -44,12 +44,18 @@ namespace Winix
|
||||
|
||||
|
||||
|
||||
void Crypt::SetConfig(Config * pconfig)
|
||||
{
|
||||
config = pconfig;
|
||||
}
|
||||
//void Crypt::SetConfig(Config * pconfig)
|
||||
//{
|
||||
// config = pconfig;
|
||||
//}
|
||||
|
||||
|
||||
void Crypt::set_dependency(WinixBase * winix_base)
|
||||
{
|
||||
WinixBase::set_dependency(winix_base);
|
||||
run.set_dependency(winix_base);
|
||||
}
|
||||
|
||||
|
||||
char Crypt::ConvertToHexForm(int val)
|
||||
{
|
||||
@@ -70,6 +76,7 @@ bool Crypt::HashBin(int hash, const char * in, size_t inlen, std::string & out)
|
||||
return false;
|
||||
|
||||
run.Clear();
|
||||
run.set_dependency(this);
|
||||
PT::WideToUTF8(config->opensll_path, command);
|
||||
run.Cmd(command);
|
||||
run.Par("dgst");
|
||||
|
||||
@@ -39,6 +39,8 @@
|
||||
#include "run.h"
|
||||
#include "config.h"
|
||||
#include "user.h"
|
||||
#include "winixbase.h"
|
||||
|
||||
|
||||
|
||||
namespace Winix
|
||||
@@ -63,12 +65,15 @@ namespace Winix
|
||||
/*
|
||||
calculating hashes, encrypting and decrypting with RSA
|
||||
*/
|
||||
class Crypt
|
||||
class Crypt : public WinixBase
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
void SetConfig(Config * pconfig);
|
||||
void set_dependency(WinixBase * winix_base);
|
||||
|
||||
|
||||
//void SetConfig(Config * pconfig);
|
||||
|
||||
|
||||
/*
|
||||
@@ -240,7 +245,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
Config * config;
|
||||
//Config * config;
|
||||
Run run;
|
||||
std::string command, bufina, keypatha;
|
||||
//std::wstring pass_salted;//, pass_hashed;
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include "item.h"
|
||||
#include "winixbase.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
@@ -45,7 +46,7 @@ namespace Winix
|
||||
|
||||
|
||||
|
||||
class DirContainer
|
||||
class DirContainer : public WinixBase
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* Copyright (c) 2008-2018, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
#include "dirs.h"
|
||||
#include "error.h"
|
||||
#include "log.h"
|
||||
#include "notify/notify.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* Copyright (c) 2008-2018, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -44,19 +44,21 @@
|
||||
#include "dircontainer.h"
|
||||
#include "db/db.h"
|
||||
#include "request.h"
|
||||
#include "notify/notify.h"
|
||||
#include "winixmodel.h"
|
||||
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
class Notify;
|
||||
|
||||
// !! IMPROVE ME
|
||||
// we do not support '..' in a path (for simplicity and security reasons)
|
||||
// (we will support '..' in the future)
|
||||
|
||||
|
||||
class Dirs
|
||||
class Dirs : public WinixModel
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
168
winixd/core/filelog.cpp
Normal file
168
winixd/core/filelog.cpp
Normal file
@@ -0,0 +1,168 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2018, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "filelog.h"
|
||||
#include <ctime>
|
||||
#include <string.h>
|
||||
#include "utf8/utf8.h"
|
||||
#include "timezones.h"
|
||||
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
FileLog::FileLog()
|
||||
{
|
||||
log_stdout = false;
|
||||
log_file_open = false;
|
||||
time_zones = nullptr;
|
||||
synchro = nullptr;
|
||||
log_time_zone_id = 0;
|
||||
}
|
||||
|
||||
|
||||
FileLog::~FileLog()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void FileLog::set_synchro(Synchro * synchro)
|
||||
{
|
||||
this->synchro = synchro;
|
||||
}
|
||||
|
||||
|
||||
void FileLog::init(const std::wstring & log_file, bool log_stdout, size_t log_time_zone_id)
|
||||
{
|
||||
this->log_stdout = log_stdout;
|
||||
this->log_time_zone_id = log_time_zone_id;
|
||||
PT::WideToUTF8(log_file, this->log_file);
|
||||
// don't open the file here
|
||||
// because it would be created with the root as an owner
|
||||
}
|
||||
|
||||
|
||||
|
||||
void FileLog::set_time_zones(TimeZones * time_zones)
|
||||
{
|
||||
this->time_zones = time_zones;
|
||||
}
|
||||
|
||||
|
||||
PT::Date FileLog::get_local_date(const PT::Date & date)
|
||||
{
|
||||
if( time_zones )
|
||||
{
|
||||
TimeZone * tz = time_zones->GetZone(log_time_zone_id);
|
||||
|
||||
if( tz )
|
||||
{
|
||||
PT::Date local_date = tz->ToLocal(date);
|
||||
return local_date;
|
||||
}
|
||||
else
|
||||
{
|
||||
return date;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return date;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void FileLog::open_file()
|
||||
{
|
||||
if( !log_file.empty() )
|
||||
{
|
||||
file.open( log_file.c_str(), std::ios_base::out | std::ios_base::app );
|
||||
log_file_open = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void FileLog::save_log(TextStream<std::wstring> * buffer)
|
||||
{
|
||||
if( buffer->Str().empty() )
|
||||
return;
|
||||
|
||||
if( synchro )
|
||||
{
|
||||
synchro->Lock();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if( log_stdout )
|
||||
PT::WideToUTF8(buffer->Str(), std::cout);
|
||||
|
||||
if( log_file.empty() )
|
||||
return;
|
||||
|
||||
if( !log_file_open || !file )
|
||||
{
|
||||
file.close();
|
||||
file.clear();
|
||||
|
||||
open_file();
|
||||
|
||||
if( !file )
|
||||
return;
|
||||
}
|
||||
|
||||
PT::WideToUTF8(buffer->Str(), file);
|
||||
file.flush();
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
}
|
||||
|
||||
if( synchro )
|
||||
{
|
||||
synchro->Unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
95
winixd/core/filelog.h
Normal file
95
winixd/core/filelog.h
Normal file
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2018, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_core_filelog
|
||||
#define headerfile_winix_core_filelog
|
||||
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include "textstream.h"
|
||||
#include "core/synchro.h"
|
||||
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
class TimeZones;
|
||||
|
||||
|
||||
class FileLog
|
||||
{
|
||||
public:
|
||||
|
||||
FileLog();
|
||||
~FileLog();
|
||||
|
||||
void set_synchro(Synchro * synchro);
|
||||
|
||||
void init(const std::wstring & log_file, bool log_stdout, size_t log_time_zone_id);
|
||||
void save_log(TextStream<std::wstring> * buffer);
|
||||
|
||||
void set_time_zones(TimeZones * time_zones);
|
||||
PT::Date get_local_date(const PT::Date & date);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// file log
|
||||
std::string log_file;
|
||||
std::ofstream file;
|
||||
|
||||
// logging to stdout
|
||||
bool log_stdout;
|
||||
|
||||
// is the config file already open
|
||||
bool log_file_open;
|
||||
|
||||
size_t log_time_zone_id;
|
||||
|
||||
TimeZones * time_zones;
|
||||
|
||||
Synchro * synchro;
|
||||
|
||||
void open_file();
|
||||
};
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* Copyright (c) 2008-2018, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -46,6 +46,13 @@ Groups::Groups()
|
||||
}
|
||||
|
||||
|
||||
void Groups::set_dependency(WinixModel * winix_model)
|
||||
{
|
||||
WinixModel::set_dependency(winix_model);
|
||||
table.set_dependency(winix_model);
|
||||
}
|
||||
|
||||
|
||||
void Groups::Clear()
|
||||
{
|
||||
table.Clear();
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* Copyright (c) 2008-2018, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -40,6 +40,8 @@
|
||||
#include "group.h"
|
||||
#include "ugcontainer.h"
|
||||
#include "db/db.h"
|
||||
#include "winixmodel.h"
|
||||
|
||||
|
||||
|
||||
namespace Winix
|
||||
@@ -47,7 +49,7 @@ namespace Winix
|
||||
|
||||
|
||||
|
||||
class Groups
|
||||
class Groups : public WinixModel
|
||||
{
|
||||
typedef UGContainer<Group> Table;
|
||||
|
||||
@@ -55,6 +57,8 @@ Table table;
|
||||
|
||||
public:
|
||||
|
||||
void set_dependency(WinixModel * winix_model);
|
||||
|
||||
typedef Table::Iterator Iterator;
|
||||
typedef Table::SizeType SizeType;
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* Copyright (c) 2008-2018, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -36,6 +36,7 @@
|
||||
#define headerfile_winix_core_httpsimpleparser
|
||||
|
||||
#include <string>
|
||||
#include "winixmodel.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
@@ -43,7 +44,7 @@ namespace Winix
|
||||
|
||||
|
||||
|
||||
class HttpSimpleParser
|
||||
class HttpSimpleParser : public WinixModel
|
||||
{
|
||||
protected:
|
||||
|
||||
|
||||
@@ -35,9 +35,7 @@
|
||||
#include <ctime>
|
||||
#include "image.h"
|
||||
#include "utf8/utf8.h"
|
||||
#include "log.h"
|
||||
#include "system.h"
|
||||
#include "plugin.h"
|
||||
#include "lock.h"
|
||||
|
||||
|
||||
@@ -492,34 +490,34 @@ void Image::ImageSavedCorrectly()
|
||||
}
|
||||
|
||||
log << log3 << "Image: generated a thumbnail: " << dst_path << logend;
|
||||
plugin.Call((Session*)0, WINIX_CREATED_THUMB, &file_work);
|
||||
plugin->Call((Session*)0, WINIX_CREATED_THUMB, &file_work);
|
||||
}
|
||||
else
|
||||
if( item_work.type == WINIX_IMAGE_TYPE_RESIZE )
|
||||
{
|
||||
log << log3 << "Image: image resized: " << dst_path << logend;
|
||||
plugin.Call((Session*)0, WINIX_IMAGE_RESIZED, &file_work);
|
||||
plugin->Call((Session*)0, WINIX_IMAGE_RESIZED, &file_work);
|
||||
}
|
||||
else
|
||||
if( item_work.type == WINIX_IMAGE_TYPE_CROP )
|
||||
{
|
||||
log << log3 << "Image: image cropped: " << dst_path << logend;
|
||||
// !! IMPROVE ME add a correct message
|
||||
//plugin.Call((Session*)0, WINIX_IMAGE_RESIZED, &file_work);
|
||||
//plugin->Call((Session*)0, WINIX_IMAGE_RESIZED, &file_work);
|
||||
}
|
||||
else
|
||||
if( item_work.type == WINIX_IMAGE_TYPE_CROP_THUMB )
|
||||
{
|
||||
log << log3 << "Image: image thumbnail cropped: " << dst_path << logend;
|
||||
// !! IMPROVE ME add a correct message
|
||||
//plugin.Call((Session*)0, WINIX_IMAGE_RESIZED, &file_work);
|
||||
//plugin->Call((Session*)0, WINIX_IMAGE_RESIZED, &file_work);
|
||||
}
|
||||
else
|
||||
if( item_work.type == WINIX_IMAGE_TYPE_CREATE_CROP_NEW_THUMB )
|
||||
{
|
||||
log << log3 << "Image: a new thumbnail from an original image was cropped: " << dst_path << logend;
|
||||
// !! IMPROVE ME add a correct message
|
||||
//plugin.Call((Session*)0, WINIX_IMAGE_RESIZED, &file_work);
|
||||
//plugin->Call((Session*)0, WINIX_IMAGE_RESIZED, &file_work);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2012-2014, Tomasz Sowa
|
||||
* Copyright (c) 2012-2018, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -37,6 +37,8 @@
|
||||
|
||||
#include <vector>
|
||||
#include "ipban.h"
|
||||
#include "winixmodel.h"
|
||||
|
||||
|
||||
|
||||
namespace Winix
|
||||
@@ -44,7 +46,7 @@ namespace Winix
|
||||
|
||||
|
||||
|
||||
class IPBanContainer
|
||||
class IPBanContainer : public WinixModel
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
@@ -169,7 +169,7 @@ void Job::DoJob(PT::Space & job)
|
||||
{
|
||||
try
|
||||
{
|
||||
PluginRes res = plugin.Call((Session*)0, WINIX_JOB, &job);
|
||||
PluginRes res = plugin->Call((Session*)0, WINIX_JOB, &job);
|
||||
|
||||
if( res.res_true == 0 )
|
||||
DoWinixJob(job);
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include <cstring>
|
||||
#include <ctime>
|
||||
#include "date/date.h"
|
||||
#include "winixbase.h"
|
||||
|
||||
|
||||
|
||||
@@ -81,7 +82,7 @@ struct LastItem
|
||||
|
||||
|
||||
|
||||
class LastContainer
|
||||
class LastContainer : public WinixBase
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* Copyright (c) 2008-2018, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
|
||||
#include "loadavg.h"
|
||||
#include "log.h"
|
||||
|
||||
|
||||
|
||||
namespace Winix
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* Copyright (c) 2008-2018, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -36,6 +36,7 @@
|
||||
#define headerfile_winix_core_loadavg
|
||||
|
||||
#include <ctime>
|
||||
#include "winixbase.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
@@ -51,7 +52,7 @@ namespace Winix
|
||||
|
||||
|
||||
|
||||
class LoadAvg
|
||||
class LoadAvg : WinixBase
|
||||
{
|
||||
public:
|
||||
LoadAvg();
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* Copyright (c) 2008-2018, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -36,7 +36,7 @@
|
||||
#include <ctime>
|
||||
#include <string.h>
|
||||
#include "utf8/utf8.h"
|
||||
#include "timezones.h"
|
||||
|
||||
|
||||
|
||||
namespace Winix
|
||||
@@ -52,8 +52,9 @@ Log::Log()
|
||||
max_requests = 1;
|
||||
lines = 0;
|
||||
max_lines = 5000;
|
||||
log_file_open = false;
|
||||
time_zones = 0;
|
||||
file_log = nullptr;
|
||||
save_each_line = false;
|
||||
buffer = nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -63,13 +64,30 @@ Log::~Log()
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Log::SetTimeZones(TimeZones * ptime_zones)
|
||||
void Log::SetLogBuffer(TextStream<std::wstring> * buffer)
|
||||
{
|
||||
time_zones = ptime_zones;
|
||||
this->buffer = buffer;
|
||||
}
|
||||
|
||||
|
||||
void Log::SetFileLog(FileLog * pfile_log)
|
||||
{
|
||||
this->file_log = pfile_log;
|
||||
}
|
||||
|
||||
|
||||
FileLog * Log::GetFileLog()
|
||||
{
|
||||
return file_log;
|
||||
}
|
||||
|
||||
|
||||
void Log::SetDependency(Log * log)
|
||||
{
|
||||
buffer = log->buffer;
|
||||
file_log = log->file_log;
|
||||
}
|
||||
|
||||
|
||||
int Log::LogLevel()
|
||||
{
|
||||
@@ -78,48 +96,24 @@ int Log::LogLevel()
|
||||
|
||||
|
||||
|
||||
void Log::Init(int log_level_, bool save_each_line_, const std::wstring & log_file_, bool log_std, int log_max_requests)
|
||||
void Log::Init(int log_level, bool save_each_line, int max_requests)
|
||||
{
|
||||
log_level = log_level_;
|
||||
log_stdout = log_std;
|
||||
max_requests = log_max_requests;
|
||||
save_each_line = save_each_line_;
|
||||
|
||||
PT::WideToUTF8(log_file_, log_file);
|
||||
// don't open the file here
|
||||
// because it would be created with the root as an owner
|
||||
this->log_level = log_level;
|
||||
this->save_each_line = save_each_line;
|
||||
this->max_requests = max_requests;
|
||||
}
|
||||
|
||||
|
||||
void Log::OpenFile()
|
||||
|
||||
void Log::PrintDate(const PT::Date & date)
|
||||
{
|
||||
if( !log_file.empty() )
|
||||
if( file_log )
|
||||
{
|
||||
file.open( log_file.c_str(), std::ios_base::out | std::ios_base::app );
|
||||
log_file_open = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Log::PrintDate(const PT::Date & date, size_t time_zone_id)
|
||||
{
|
||||
if( time_zones )
|
||||
{
|
||||
TimeZone * tz = time_zones->GetZone(time_zone_id);
|
||||
|
||||
if( tz )
|
||||
{
|
||||
PT::Date local_date = tz->ToLocal(date);
|
||||
log << local_date;
|
||||
}
|
||||
else
|
||||
{
|
||||
(*this) << date << " UTC"; // unknown time zone identifier
|
||||
}
|
||||
(*this) << file_log->get_local_date(date);
|
||||
}
|
||||
else
|
||||
{
|
||||
(*this) << date << " UTC"; // time_zones object was not set
|
||||
(*this) << date;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,10 +121,11 @@ void Log::PrintDate(const PT::Date & date, size_t time_zone_id)
|
||||
|
||||
Log & Log::operator<<(const void * s)
|
||||
{
|
||||
if( current_level > log_level )
|
||||
return *this;
|
||||
if( current_level <= log_level && buffer )
|
||||
{
|
||||
(*buffer) << s;
|
||||
}
|
||||
|
||||
buffer << s;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -138,13 +133,10 @@ Log & Log::operator<<(const void * s)
|
||||
|
||||
Log & Log::operator<<(const char * s)
|
||||
{
|
||||
if( current_level > log_level )
|
||||
return *this;
|
||||
|
||||
if( !s )
|
||||
return *this;
|
||||
|
||||
buffer << s;
|
||||
if( current_level <= log_level && buffer && s )
|
||||
{
|
||||
(*buffer) << s;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -153,10 +145,11 @@ return *this;
|
||||
|
||||
Log & Log::operator<<(const std::string & s)
|
||||
{
|
||||
if( current_level > log_level )
|
||||
return *this;
|
||||
if( current_level <= log_level && buffer )
|
||||
{
|
||||
(*buffer) << s;
|
||||
}
|
||||
|
||||
buffer << s;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -164,10 +157,11 @@ Log & Log::operator<<(const std::string & s)
|
||||
|
||||
Log & Log::operator<<(const std::string * s)
|
||||
{
|
||||
if( current_level > log_level )
|
||||
return *this;
|
||||
if( current_level <= log_level && buffer )
|
||||
{
|
||||
(*buffer) << *s;
|
||||
}
|
||||
|
||||
buffer << *s;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -178,10 +172,9 @@ Log & Log::operator<<(const std::string * s)
|
||||
|
||||
Log & Log::operator<<(const wchar_t * s)
|
||||
{
|
||||
if( current_level <= log_level )
|
||||
if( current_level <= log_level && buffer && s )
|
||||
{
|
||||
if( s )
|
||||
buffer << s;
|
||||
(*buffer) << s;
|
||||
}
|
||||
|
||||
return *this;
|
||||
@@ -191,9 +184,9 @@ return *this;
|
||||
|
||||
Log & Log::operator<<(const std::wstring & s)
|
||||
{
|
||||
if( current_level <= log_level )
|
||||
if( current_level <= log_level && buffer )
|
||||
{
|
||||
buffer << s;
|
||||
(*buffer) << s;
|
||||
}
|
||||
|
||||
return *this;
|
||||
@@ -203,9 +196,9 @@ Log & Log::operator<<(const std::wstring & s)
|
||||
|
||||
Log & Log::operator<<(const std::wstring * s)
|
||||
{
|
||||
if( current_level <= log_level )
|
||||
if( current_level <= log_level && buffer )
|
||||
{
|
||||
buffer << *s;
|
||||
(*buffer) << *s;
|
||||
}
|
||||
|
||||
return *this;
|
||||
@@ -217,9 +210,9 @@ Log & Log::operator<<(const std::wstring * s)
|
||||
|
||||
Log & Log::operator<<(int s)
|
||||
{
|
||||
if( current_level <= log_level )
|
||||
if( current_level <= log_level && buffer )
|
||||
{
|
||||
buffer << s;
|
||||
(*buffer) << s;
|
||||
}
|
||||
|
||||
return *this;
|
||||
@@ -229,9 +222,9 @@ Log & Log::operator<<(int s)
|
||||
|
||||
Log & Log::operator<<(long s)
|
||||
{
|
||||
if( current_level <= log_level )
|
||||
if( current_level <= log_level && buffer )
|
||||
{
|
||||
buffer << s;
|
||||
(*buffer) << s;
|
||||
}
|
||||
|
||||
return *this;
|
||||
@@ -242,9 +235,9 @@ Log & Log::operator<<(long s)
|
||||
|
||||
Log & Log::operator<<(char s)
|
||||
{
|
||||
if( current_level <= log_level )
|
||||
if( current_level <= log_level && buffer )
|
||||
{
|
||||
buffer << s;
|
||||
(*buffer) << s;
|
||||
}
|
||||
|
||||
return *this;
|
||||
@@ -253,9 +246,9 @@ Log & Log::operator<<(char s)
|
||||
|
||||
Log & Log::operator<<(wchar_t s)
|
||||
{
|
||||
if( current_level <= log_level )
|
||||
if( current_level <= log_level && buffer )
|
||||
{
|
||||
buffer << s;
|
||||
(*buffer) << s;
|
||||
}
|
||||
|
||||
return *this;
|
||||
@@ -264,9 +257,9 @@ Log & Log::operator<<(wchar_t s)
|
||||
|
||||
Log & Log::operator<<(size_t s)
|
||||
{
|
||||
if( current_level <= log_level )
|
||||
if( current_level <= log_level && buffer )
|
||||
{
|
||||
buffer << s;
|
||||
(*buffer) << s;
|
||||
}
|
||||
|
||||
return *this;
|
||||
@@ -276,9 +269,9 @@ Log & Log::operator<<(size_t s)
|
||||
|
||||
Log & Log::operator<<(double s)
|
||||
{
|
||||
if( current_level <= log_level )
|
||||
if( current_level <= log_level && buffer )
|
||||
{
|
||||
buffer << s;
|
||||
(*buffer) << s;
|
||||
}
|
||||
|
||||
return *this;
|
||||
@@ -288,9 +281,9 @@ Log & Log::operator<<(double s)
|
||||
|
||||
Log & Log::operator<<(const PT::Space & s)
|
||||
{
|
||||
if( current_level <= log_level )
|
||||
if( current_level <= log_level && buffer )
|
||||
{
|
||||
buffer << s;
|
||||
(*buffer) << s;
|
||||
}
|
||||
|
||||
return *this;
|
||||
@@ -300,9 +293,9 @@ return *this;
|
||||
|
||||
Log & Log::operator<<(const PT::Date & date)
|
||||
{
|
||||
if( current_level <= log_level )
|
||||
if( current_level <= log_level && buffer )
|
||||
{
|
||||
buffer << date;
|
||||
(*buffer) << date;
|
||||
}
|
||||
|
||||
return *this;
|
||||
@@ -315,9 +308,9 @@ Log & Log::operator<<(LogManipulators m)
|
||||
switch(m)
|
||||
{
|
||||
case logend:
|
||||
if( current_level <= log_level )
|
||||
if( current_level <= log_level && buffer )
|
||||
{
|
||||
buffer << '\n';
|
||||
(*buffer) << '\n';
|
||||
lines += 1;
|
||||
|
||||
if( save_each_line )
|
||||
@@ -383,6 +376,9 @@ void Log::LogBinary(const char * blob, size_t blob_len)
|
||||
size_t i=0;
|
||||
char buf[3];
|
||||
|
||||
if( !buffer )
|
||||
return;
|
||||
|
||||
|
||||
while( i < blob_len )
|
||||
{
|
||||
@@ -393,32 +389,32 @@ char buf[3];
|
||||
if( i < blob_len )
|
||||
{
|
||||
ToHEX(buf, blob[i]);
|
||||
buffer << buf << ' ';
|
||||
(*buffer) << buf << ' ';
|
||||
++i;
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer << " ";
|
||||
(*buffer) << " ";
|
||||
}
|
||||
|
||||
if( a == 7 )
|
||||
{
|
||||
if( i < blob_len )
|
||||
buffer << "- ";
|
||||
(*buffer) << "- ";
|
||||
else
|
||||
buffer << " ";
|
||||
(*buffer) << " ";
|
||||
}
|
||||
}
|
||||
|
||||
i = oldi;
|
||||
buffer << ' ';
|
||||
(*buffer) << ' ';
|
||||
|
||||
for(size_t a=0 ; a<16 && i<blob_len ; ++a, ++i)
|
||||
{
|
||||
if( blob[i] > 31 && blob[i] < 127 )
|
||||
buffer << blob[i];
|
||||
(*buffer) << blob[i];
|
||||
else
|
||||
buffer << '.';
|
||||
(*buffer) << '.';
|
||||
}
|
||||
|
||||
(*this) << logend;
|
||||
@@ -447,7 +443,11 @@ void Log::SaveLogAndClear()
|
||||
{
|
||||
SaveLog();
|
||||
|
||||
buffer.Clear();
|
||||
if( buffer )
|
||||
{
|
||||
buffer->Clear();
|
||||
}
|
||||
|
||||
request = 0;
|
||||
lines = 0;
|
||||
}
|
||||
@@ -455,28 +455,10 @@ void Log::SaveLogAndClear()
|
||||
|
||||
void Log::SaveLog()
|
||||
{
|
||||
if( buffer.Str().empty() )
|
||||
return;
|
||||
|
||||
if( log_stdout )
|
||||
PT::WideToUTF8(buffer.Str(), std::cout);
|
||||
|
||||
if( log_file.empty() )
|
||||
return;
|
||||
|
||||
if( !log_file_open || !file )
|
||||
if( file_log && buffer )
|
||||
{
|
||||
file.close();
|
||||
file.clear();
|
||||
|
||||
OpenFile();
|
||||
|
||||
if( !file )
|
||||
return;
|
||||
file_log->save_log(buffer);
|
||||
}
|
||||
|
||||
PT::WideToUTF8(buffer.Str(), file);
|
||||
file.flush();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* Copyright (c) 2008-2018, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -43,6 +43,7 @@
|
||||
#include "textstream.h"
|
||||
#include "logmanipulators.h"
|
||||
#include "textstream/textstream.h"
|
||||
#include "filelog.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
@@ -50,10 +51,6 @@ namespace Winix
|
||||
|
||||
|
||||
|
||||
class TimeZones;
|
||||
|
||||
|
||||
|
||||
class Log
|
||||
{
|
||||
public:
|
||||
@@ -61,8 +58,14 @@ public:
|
||||
Log();
|
||||
~Log();
|
||||
|
||||
void SetTimeZones(TimeZones * ptime_zones);
|
||||
void Init(int log_level_, bool save_each_line_, const std::wstring & log_file_, bool log_std, int log_max_requests);
|
||||
void SetLogBuffer(TextStream<std::wstring> * buffer);
|
||||
|
||||
void SetFileLog(FileLog * file_log);
|
||||
FileLog * GetFileLog();
|
||||
|
||||
void SetDependency(Log * log);
|
||||
|
||||
void Init(int log_level, bool save_each_line, int max_requests);
|
||||
|
||||
Log & operator<<(const void * s);
|
||||
Log & operator<<(const char * s);
|
||||
@@ -81,7 +84,7 @@ public:
|
||||
Log & operator<<(LogManipulators m);
|
||||
Log & operator<<(const PT::Date & date);
|
||||
|
||||
void PrintDate(const PT::Date & date, size_t time_zone_id);
|
||||
void PrintDate(const PT::Date & date);
|
||||
|
||||
template<typename char_type, size_t stack_size, size_t heap_block_size>
|
||||
Log & operator<<(const PT::TextStreamBase<char_type, stack_size, heap_block_size> & buf);
|
||||
@@ -101,13 +104,11 @@ public:
|
||||
int LogLevel();
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// time zones for printing the time in the log file
|
||||
TimeZones * time_zones;
|
||||
|
||||
// buffer for the log
|
||||
TextStream<std::wstring> buffer;
|
||||
TextStream<std::wstring> * buffer; // IMPROVE ME this buffer should be a common buffer for all objects for a one thread
|
||||
|
||||
// log lovel from the config file
|
||||
int log_level;
|
||||
@@ -122,19 +123,9 @@ private:
|
||||
// how many request to save at once
|
||||
int max_requests;
|
||||
|
||||
// file log
|
||||
std::string log_file;
|
||||
std::ofstream file;
|
||||
|
||||
// logging to stdout
|
||||
bool log_stdout;
|
||||
|
||||
// how many lines there are in the buffer
|
||||
int lines;
|
||||
|
||||
// is the config file already open
|
||||
bool log_file_open;
|
||||
|
||||
// how many lines can be in the config buffer
|
||||
// default: 5000
|
||||
int max_lines;
|
||||
@@ -142,7 +133,8 @@ private:
|
||||
// whether to save each line (for debug)
|
||||
bool save_each_line;
|
||||
|
||||
void OpenFile();
|
||||
FileLog * file_log;
|
||||
|
||||
char GetHEXdigit(unsigned char c);
|
||||
void ToHEX(char * buf, unsigned char c);
|
||||
|
||||
@@ -155,14 +147,14 @@ void Log::LogString(const StringType & value, size_t max_size)
|
||||
{
|
||||
size_t min_size = value.size() < max_size ? value.size() : max_size;
|
||||
|
||||
if( current_level <= log_level )
|
||||
if( current_level <= log_level && buffer )
|
||||
{
|
||||
for(size_t i=0 ; i<min_size ; ++i)
|
||||
{
|
||||
if( value[i] < 32 )
|
||||
buffer << '.';
|
||||
(*buffer) << '.';
|
||||
else
|
||||
buffer << value[i];
|
||||
(*buffer) << value[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -172,28 +164,17 @@ size_t min_size = value.size() < max_size ? value.size() : max_size;
|
||||
template<typename char_type, size_t stack_size, size_t heap_block_size>
|
||||
Log & Log::operator<<(const PT::TextStreamBase<char_type, stack_size, heap_block_size> & buf)
|
||||
{
|
||||
if( current_level <= log_level )
|
||||
buffer << buf;
|
||||
if( current_level <= log_level && buffer )
|
||||
(*buffer) << buf;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
extern Log log;
|
||||
extern Log nlog;
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
|
||||
|
||||
// for convenience, we have to use only #include "log.h" in the winix
|
||||
#include "slog.h"
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -38,7 +38,6 @@
|
||||
#include <fstream>
|
||||
#include <cstdlib>
|
||||
#include "misc.h"
|
||||
#include "log.h"
|
||||
#include "templates/templates.h"
|
||||
#include "convert/convert.h"
|
||||
|
||||
@@ -882,7 +881,7 @@ char dir_name[WINIX_OS_PATH_SIZE];
|
||||
|
||||
if( mkdir(dir_name, 0777) < 0 )
|
||||
{
|
||||
log << log1 << "Can't create a directory on fs: " << dir << logend;
|
||||
//log << log1 << "Can't create a directory on fs: " << dir << logend;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -958,7 +957,7 @@ char buffer[512];
|
||||
|
||||
if( getgrnam_r(group_name, &gr, buffer, sizeof(buffer)/sizeof(char), &result) != 0 )
|
||||
{
|
||||
log << log1 << "Misc: I cannot get the group_id for group name: " << name << logend;
|
||||
//log << log1 << "Misc: I cannot get the group_id for group name: " << name << logend;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -967,7 +966,7 @@ char buffer[512];
|
||||
*/
|
||||
if( result == 0 )
|
||||
{
|
||||
log << log1 << "Misc: There is no a group with name: " << name << logend;
|
||||
//log << log1 << "Misc: There is no a group with name: " << name << logend;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -994,7 +993,7 @@ char file_name[WINIX_OS_PATH_SIZE];
|
||||
|
||||
if( chmod(file_name, priv) < 0 )
|
||||
{
|
||||
log << log1 << "Misc: Can't set proper fs privileges on: " << name << logend;
|
||||
//log << log1 << "Misc: Can't set proper fs privileges on: " << name << logend;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1002,8 +1001,8 @@ char file_name[WINIX_OS_PATH_SIZE];
|
||||
{
|
||||
if( chown(file_name, geteuid(), group) < 0 )
|
||||
{
|
||||
log << log1 << "Can't set proper fs group on: " << name
|
||||
<< ", group id was: " << group << logend;
|
||||
//log << log1 << "Can't set proper fs group on: " << name
|
||||
// << ", group id was: " << group << logend;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1385,7 +1384,9 @@ void RemovePostFileTmp(PostFileTab & post_file_tab)
|
||||
const std::wstring & tmp_filename = i->second.tmp_filename;
|
||||
|
||||
if( !tmp_filename.empty() && RemoveFile(tmp_filename) )
|
||||
log << log3 << "Deleted tmp file: " << tmp_filename << logend;
|
||||
{
|
||||
//log << log3 << "Deleted tmp file: " << tmp_filename << logend;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1399,8 +1400,8 @@ bool WideToUTF8(const wchar_t * wide_string, char * utf8, size_t utf8_size)
|
||||
/*
|
||||
* either the 'utf8' buffer is too small or there was an error when converting
|
||||
*/
|
||||
log << log1 << "Misc: I cannot convert from a wide string to an UTF-8 string, original string was: "
|
||||
<< wide_string << logend;
|
||||
//log << log1 << "Misc: I cannot convert from a wide string to an UTF-8 string, original string was: "
|
||||
// << wide_string << logend;
|
||||
}
|
||||
|
||||
return res;
|
||||
|
||||
@@ -297,7 +297,9 @@ bool MountParser::ReadMountType()
|
||||
else
|
||||
{
|
||||
log << log1 << "MP: unknown mount type: " << temp << logend;
|
||||
slog << logerror << T("unknown_mount_type") << ": " << temp << logend;
|
||||
|
||||
// IMPROVE ME there is no slog now
|
||||
//slog << logerror << T("unknown_mount_type") << ": " << temp << logend;
|
||||
}
|
||||
|
||||
return mount.type != -1;
|
||||
@@ -319,7 +321,9 @@ bool MountParser::ReadMountPoint()
|
||||
else
|
||||
{
|
||||
log << log1 << "MP: there is no such a mount point (directory): " << last_dir << logend;
|
||||
slog << logerror << T("no_such_dir") << ": " << last_dir << logend;
|
||||
|
||||
// IMPROVE ME there is no slog now
|
||||
//slog << logerror << T("no_such_dir") << ": " << last_dir << logend;
|
||||
}
|
||||
|
||||
return pdir != 0;
|
||||
@@ -339,7 +343,9 @@ bool MountParser::ReadFs()
|
||||
else
|
||||
{
|
||||
log << log1 << "MP: unknown filesystem: " << temp << logend;
|
||||
slog << logerror << T("unknown_filesystem") << ": " << temp << " (" << last_dir << ")" << logend;
|
||||
|
||||
// IMPROVE ME there is no slog now
|
||||
//slog << logerror << T("unknown_filesystem") << ": " << temp << " (" << last_dir << ")" << logend;
|
||||
}
|
||||
|
||||
return mount.fs != -1;
|
||||
@@ -383,7 +389,9 @@ void MountParser::ReadMountParams()
|
||||
else
|
||||
{
|
||||
log << log1 << "MP: unknown mount param: " << temp << logend;
|
||||
slog << logwarning << T("unknown_mount_param") << ": " << temp << " (" << T("skipped") << ")" << logend;
|
||||
|
||||
// IMPROVE ME there is no slog now
|
||||
//slog << logwarning << T("unknown_mount_param") << ": " << temp << " (" << T("skipped") << ")" << logend;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -476,7 +484,9 @@ void MountParser::ReadRow()
|
||||
if( skip_static && mount.type==static_mount_id )
|
||||
{
|
||||
log << log1 << "MP: static mount points are skipped (dont_use_static_dirs in config is true)" << logend;
|
||||
slog << logwarning << T("skipped_static_mount") << ": " << last_dir << logend;
|
||||
|
||||
// IMPROVE ME there is no slog now
|
||||
//slog << logwarning << T("skipped_static_mount") << ": " << last_dir << logend;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -490,7 +500,9 @@ void MountParser::ReadRow()
|
||||
else
|
||||
{
|
||||
log << log1 << "MP: this mount point exists (skipped)" << logend;
|
||||
slog << logwarning << T("mount_exists") << ": " << last_dir << " (" << T("skipped") << ")" << logend;
|
||||
|
||||
// IMPROVE ME there is no slog now
|
||||
//slog << logwarning << T("mount_exists") << ": " << last_dir << " (" << T("skipped") << ")" << logend;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
#include "mount.h"
|
||||
#include "item.h"
|
||||
#include "dirs.h"
|
||||
#include "winixmodel.h"
|
||||
|
||||
|
||||
|
||||
@@ -52,7 +53,7 @@ namespace Winix
|
||||
|
||||
|
||||
|
||||
class MountParser
|
||||
class MountParser : public WinixModel
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009-2014, Tomasz Sowa
|
||||
* Copyright (c) 2009-2018, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -36,7 +36,7 @@
|
||||
#include "request.h"
|
||||
#include "log.h"
|
||||
#include "db/db.h"
|
||||
#include "plugin.h"
|
||||
#include "cur.h"
|
||||
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ void Mounts::CreateMounts()
|
||||
CreateMountFs();
|
||||
CreateMountPar();
|
||||
|
||||
plugin.Call((Session*)0, WINIX_ADD_MOUNTS);
|
||||
plugin->Call((Session*)0, WINIX_ADD_MOUNTS);
|
||||
|
||||
empty_mount.param.resize(mount_par_tab.size());
|
||||
empty_mount.ClearParams();
|
||||
@@ -210,6 +210,7 @@ const std::wstring & Mounts::GetMountPar(int id)
|
||||
// reading from 'mounts'
|
||||
void Mounts::ReadMounts(const std::wstring & mounts)
|
||||
{
|
||||
mount_parser.set_dependency(this);
|
||||
mount_parser.SkipStaticDirs(skip_static);
|
||||
mount_parser.SetStaticMountId(mount_type_static);
|
||||
mount_parser.SetDirs(dirs);
|
||||
@@ -217,10 +218,11 @@ void Mounts::ReadMounts(const std::wstring & mounts)
|
||||
mount_parser.SetMountFsTab(mount_fs_tab);
|
||||
mount_parser.SetMountParTab(mount_par_tab);
|
||||
|
||||
|
||||
mount_parser.Parse(mounts, mount_tab);
|
||||
|
||||
CalcCurMount();
|
||||
plugin.Call((Session*)0, WINIX_FSTAB_CHANGED);
|
||||
plugin->Call((Session*)0, WINIX_FSTAB_CHANGED);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009-2014, Tomasz Sowa
|
||||
* Copyright (c) 2009-2018, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -46,6 +46,7 @@
|
||||
#include "db/db.h"
|
||||
#include "request.h"
|
||||
#include "mountparser.h"
|
||||
#include "winixmodel.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
@@ -54,7 +55,7 @@ namespace Winix
|
||||
|
||||
|
||||
|
||||
class Mounts
|
||||
class Mounts : public WinixModel
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* Copyright (c) 2008-2018, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -35,8 +35,12 @@
|
||||
#include <dlfcn.h>
|
||||
#include <string.h>
|
||||
#include "plugin.h"
|
||||
#include "pluginmsg.h"
|
||||
#include "misc.h"
|
||||
#include "system.h"
|
||||
#include "sessionmanager.h"
|
||||
#include "functions/functions.h"
|
||||
#include "templates/templates.h"
|
||||
#include "winixsystem.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
@@ -61,14 +65,13 @@ Plugin::Plugin()
|
||||
{
|
||||
current_plugin = -1;
|
||||
|
||||
db = 0;
|
||||
config = 0;
|
||||
cur = 0;
|
||||
system = 0;
|
||||
functions = 0;
|
||||
templates = 0;
|
||||
synchro = 0;
|
||||
session_manager = 0;
|
||||
db = nullptr;
|
||||
cur = nullptr;
|
||||
system = nullptr;
|
||||
functions = nullptr;
|
||||
templates = nullptr;
|
||||
session_manager = nullptr;
|
||||
winix_system = nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -83,10 +86,10 @@ void Plugin::SetDb(Db * pdb)
|
||||
db = pdb;
|
||||
}
|
||||
|
||||
void Plugin::SetConfig(Config * pconfig)
|
||||
{
|
||||
config = pconfig;
|
||||
}
|
||||
//void Plugin::SetConfig(Config * pconfig)
|
||||
//{
|
||||
// config = pconfig;
|
||||
//}
|
||||
|
||||
|
||||
void Plugin::SetCur(Cur * pcur)
|
||||
@@ -113,10 +116,10 @@ void Plugin::SetTemplates(Templates * ptemplates)
|
||||
}
|
||||
|
||||
|
||||
void Plugin::SetSynchro(Synchro * psynchro)
|
||||
{
|
||||
synchro = psynchro;
|
||||
}
|
||||
//void Plugin::SetSynchro(Synchro * psynchro)
|
||||
//{
|
||||
// synchro = psynchro;
|
||||
//}
|
||||
|
||||
|
||||
void Plugin::SetSessionManager(SessionManager * psession_manager)
|
||||
@@ -125,6 +128,12 @@ void Plugin::SetSessionManager(SessionManager * psession_manager)
|
||||
}
|
||||
|
||||
|
||||
void Plugin::SetWinixSystem(WinixSystem * winix_system)
|
||||
{
|
||||
this->winix_system = winix_system;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Plugin::Lock()
|
||||
{
|
||||
@@ -142,10 +151,10 @@ void Plugin::Unlock()
|
||||
|
||||
|
||||
|
||||
bool Plugin::SetPointers(PluginInfo & info)
|
||||
bool Plugin::SetDependency(PluginInfo & info)
|
||||
{
|
||||
// for safety we call a plugin function only when all our pointers are not null
|
||||
bool res = (db && config && cur && system && functions && templates && synchro && session_manager);
|
||||
bool res = (db && config && cur && system && functions && templates && synchro && session_manager && winix_system);
|
||||
|
||||
if( !res )
|
||||
{
|
||||
@@ -162,6 +171,9 @@ bool Plugin::SetPointers(PluginInfo & info)
|
||||
info.templates = templates;
|
||||
info.synchro = synchro;
|
||||
info.session_manager = session_manager;
|
||||
info.winix_system = winix_system;
|
||||
info.plugin = this;
|
||||
info.log.SetDependency(&log);
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -233,7 +245,7 @@ void * plugin_handle;
|
||||
int old_current_plugin;
|
||||
PluginInfo info;
|
||||
|
||||
if( !SetPointers(info) )
|
||||
if( !SetDependency(info) )
|
||||
return;
|
||||
|
||||
if( !(plugin_handle = LoadInitFun(filename, fun_init)) )
|
||||
@@ -293,7 +305,7 @@ bool Plugin::HasMessage(int message)
|
||||
|
||||
void Plugin::Call(Session * ses, int message, Slots::iterator & slot, PluginInfo & info)
|
||||
{
|
||||
if( !SetPointers(info) )
|
||||
if( !SetDependency(info) )
|
||||
return;
|
||||
|
||||
current_plugin = slot->second.index;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* Copyright (c) 2008-2018, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -39,20 +39,23 @@
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include "pluginmsg.h"
|
||||
#include "log.h"
|
||||
#include "plugindata.h"
|
||||
#include "config.h"
|
||||
#include "request.h"
|
||||
#include "system.h"
|
||||
#include "sessionmanager.h"
|
||||
#include "synchro.h"
|
||||
#include "functions/functions.h"
|
||||
#include "templates/templates.h"
|
||||
#include "winixbase.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
class Db;
|
||||
class Cur;
|
||||
class System;
|
||||
class Functions;
|
||||
class Templates;
|
||||
class SessionManager;
|
||||
|
||||
class WinixSystem;
|
||||
|
||||
|
||||
|
||||
@@ -73,6 +76,8 @@ namespace Winix
|
||||
*/
|
||||
|
||||
|
||||
class Plugin;
|
||||
class Session;
|
||||
|
||||
|
||||
struct PluginInfo
|
||||
@@ -87,6 +92,7 @@ struct PluginInfo
|
||||
// unique plugin identifier
|
||||
int plugin_id;
|
||||
|
||||
|
||||
// objects from winix which are accessible from a plugin
|
||||
Db * db;
|
||||
Config * config;
|
||||
@@ -97,6 +103,13 @@ struct PluginInfo
|
||||
Synchro * synchro;
|
||||
SessionManager * session_manager;
|
||||
|
||||
// temporarily?
|
||||
Log log;
|
||||
WinixSystem * winix_system;
|
||||
|
||||
Plugin * plugin;
|
||||
|
||||
|
||||
// a session
|
||||
// some messages are sent in a session's context e.g. logging a user
|
||||
// this pointer in not always the same as cur->session, it is preferred
|
||||
@@ -151,7 +164,7 @@ struct PluginRes
|
||||
|
||||
|
||||
|
||||
class Plugin
|
||||
class Plugin : public WinixBase
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -193,14 +206,16 @@ public:
|
||||
~Plugin();
|
||||
|
||||
void SetDb(Db * pdb);
|
||||
void SetConfig(Config * pconfig);
|
||||
//void SetConfig(Config * pconfig);
|
||||
void SetCur(Cur * pcur);
|
||||
void SetSystem(System * psystem);
|
||||
void SetFunctions(Functions * pfunctions);
|
||||
void SetTemplates(Templates * ptemplates);
|
||||
void SetSynchro(Synchro * psynchro);
|
||||
//void SetSynchro(Synchro * psynchro);
|
||||
void SetSessionManager(SessionManager * psession_manager);
|
||||
|
||||
void SetWinixSystem(WinixSystem * winix_system);
|
||||
|
||||
void LoadPlugin(const wchar_t * filename);
|
||||
void LoadPlugin(const std::wstring & filename);
|
||||
|
||||
@@ -245,14 +260,16 @@ public:
|
||||
private:
|
||||
|
||||
Db * db;
|
||||
Config * config;
|
||||
//Config * config;
|
||||
Cur * cur;
|
||||
System * system;
|
||||
Functions * functions;
|
||||
Templates * templates;
|
||||
Synchro * synchro;
|
||||
//Synchro * synchro;
|
||||
SessionManager * session_manager;
|
||||
|
||||
WinixSystem * winix_system;
|
||||
|
||||
std::wstring temp_path; // used when loading plugins
|
||||
|
||||
Plugins plugins;
|
||||
@@ -263,17 +280,13 @@ private:
|
||||
void * LoadInitFun(const wchar_t * filename, Fun1 & fun_init);
|
||||
void Call(Session * ses, int message, Slots::iterator & slot, PluginInfo & info);
|
||||
|
||||
bool SetPointers(PluginInfo & info);
|
||||
bool SetDependency(PluginInfo & info);
|
||||
void Lock();
|
||||
void Unlock();
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
extern Plugin plugin;
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* Copyright (c) 2008-2018, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -35,7 +35,7 @@
|
||||
#include "plugindata.h"
|
||||
#include "plugin.h"
|
||||
#include "log.h"
|
||||
#include "session.h"
|
||||
|
||||
|
||||
|
||||
namespace Winix
|
||||
@@ -46,7 +46,6 @@ namespace Winix
|
||||
|
||||
PluginData::PluginData()
|
||||
{
|
||||
session = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +62,6 @@ PluginData & PluginData::operator=(const PluginData & p)
|
||||
// we don't copy all pointers - only resize the table
|
||||
// pointers will be set to zero
|
||||
Resize(p.Size());
|
||||
session = 0;
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -72,15 +70,10 @@ return *this;
|
||||
|
||||
PluginData::~PluginData()
|
||||
{
|
||||
DeleteAll();
|
||||
//DeleteAll();
|
||||
}
|
||||
|
||||
|
||||
void PluginData::SetSession(Session * ses)
|
||||
{
|
||||
session = ses;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void PluginData::Assign(size_t index, PluginDataBase * data)
|
||||
@@ -92,16 +85,16 @@ void PluginData::Assign(size_t index, PluginDataBase * data)
|
||||
}
|
||||
|
||||
|
||||
void PluginData::Assign(PluginDataBase * data)
|
||||
{
|
||||
if( plugin.current_plugin == -1 )
|
||||
{
|
||||
log << log1 << "PD: Assign(PluginDataBase*) should be called only from plugins" << logend;
|
||||
return;
|
||||
}
|
||||
|
||||
Assign(plugin.current_plugin, data);
|
||||
}
|
||||
//void PluginData::Assign(PluginDataBase * data)
|
||||
//{
|
||||
// if( plugin.current_plugin == -1 )
|
||||
// {
|
||||
// log << log1 << "PD: Assign(PluginDataBase*) should be called only from plugins" << logend;
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// Assign(plugin.current_plugin, data);
|
||||
//}
|
||||
|
||||
|
||||
|
||||
@@ -114,31 +107,23 @@ return table[index];
|
||||
}
|
||||
|
||||
|
||||
PluginDataBase * PluginData::Get()
|
||||
{
|
||||
if( plugin.current_plugin == -1 )
|
||||
{
|
||||
log << log1 << "PD: Get() should be called only from plugins" << logend;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return Get(plugin.current_plugin);
|
||||
}
|
||||
//PluginDataBase * PluginData::Get()
|
||||
//{
|
||||
// if( plugin.current_plugin == -1 )
|
||||
// {
|
||||
// log << log1 << "PD: Get() should be called only from plugins" << logend;
|
||||
// return 0;
|
||||
// }
|
||||
//
|
||||
//return Get(plugin.current_plugin);
|
||||
//}
|
||||
|
||||
|
||||
|
||||
|
||||
void PluginData::DeleteAll()
|
||||
bool PluginData::HasAllocatedData()
|
||||
{
|
||||
bool all_null = true;
|
||||
|
||||
/*
|
||||
when we copy a session's object (and this object then)
|
||||
we resize the table and there are only null pointers there
|
||||
consequently if all pointers are null there is no sens
|
||||
to send WINIX_PLUGIN_SESSION_DATA_REMOVE
|
||||
*/
|
||||
|
||||
for(size_t i=0 ; i<table.size() ; ++i)
|
||||
{
|
||||
if( table[i] != 0 )
|
||||
@@ -148,19 +133,40 @@ void PluginData::DeleteAll()
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
in the future this message may be removed
|
||||
and we directly 'delete' the pointers
|
||||
*/
|
||||
|
||||
if( !all_null )
|
||||
plugin.Call(session, WINIX_PLUGIN_SESSION_DATA_REMOVE);
|
||||
|
||||
table.clear();
|
||||
return !all_null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//void PluginData::DeleteAll()
|
||||
//{
|
||||
// bool all_null = true;
|
||||
//
|
||||
// when we copy a session's object (and this object then)
|
||||
// we resize the table and there are only null pointers there
|
||||
// consequently if all pointers are null there is no sens
|
||||
// to send WINIX_PLUGIN_SESSION_DATA_REMOVE
|
||||
//
|
||||
// for(size_t i=0 ; i<table.size() ; ++i)
|
||||
// {
|
||||
// if( table[i] != 0 )
|
||||
// {
|
||||
// all_null = false;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// in the future this message may be removed
|
||||
// and we directly 'delete' the pointers
|
||||
//
|
||||
// if( !all_null )
|
||||
// plugin.Call(session, WINIX_PLUGIN_SESSION_DATA_REMOVE);
|
||||
//
|
||||
// table.clear();
|
||||
//}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
size_t PluginData::Size() const
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* Copyright (c) 2008-2018, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -38,14 +38,12 @@
|
||||
#include <vector>
|
||||
#include <cstddef>
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
struct Session;
|
||||
|
||||
|
||||
struct PluginDataBase
|
||||
{
|
||||
virtual ~PluginDataBase() {}
|
||||
@@ -73,15 +71,13 @@ public:
|
||||
PluginData & operator=(const PluginData & p);
|
||||
~PluginData();
|
||||
|
||||
void SetSession(Session * ses);
|
||||
|
||||
void Assign(size_t index, PluginDataBase * data);
|
||||
void Assign(PluginDataBase * data);
|
||||
//void Assign(PluginDataBase * data);
|
||||
|
||||
PluginDataBase * Get(size_t index);
|
||||
PluginDataBase * Get();
|
||||
//PluginDataBase * Get();
|
||||
|
||||
void DeleteAll();
|
||||
bool HasAllocatedData();
|
||||
|
||||
size_t Size() const;
|
||||
void Resize(size_t new_size);
|
||||
@@ -89,7 +85,6 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
Session * session;
|
||||
std::vector<PluginDataBase*> table;
|
||||
};
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* Copyright (c) 2008-2018, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -42,6 +42,7 @@
|
||||
#include "requesttypes.h"
|
||||
#include "config.h"
|
||||
#include "misc.h"
|
||||
#include "winixbase.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
@@ -54,7 +55,7 @@ namespace Winix
|
||||
#define WINIX_POSTMULTI_OUTPUT_BUFFER 2097152
|
||||
|
||||
|
||||
class PostMultiParser
|
||||
class PostMultiParser : public WinixBase
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
@@ -41,8 +41,6 @@
|
||||
#include "requesttypes.h"
|
||||
#include "misc.h"
|
||||
#include "utf8/utf8.h"
|
||||
#include "log.h"
|
||||
#include "plugin.h"
|
||||
#include "convert/text.h"
|
||||
|
||||
|
||||
@@ -105,7 +103,7 @@ protected:
|
||||
std::pair<PostTab::iterator, bool> res;
|
||||
|
||||
if( has_winix_post_params_msg )
|
||||
plugin.Call(0, WINIX_POST_PARAMS, &name, &value);
|
||||
plugin->Call(0, WINIX_POST_PARAMS, &name, &value);
|
||||
|
||||
res = post_tab->insert( std::make_pair(name, value) );
|
||||
added = res.second;
|
||||
@@ -143,13 +141,13 @@ public:
|
||||
var_index = 1;
|
||||
raw_post.clear();
|
||||
|
||||
has_winix_post_params_msg = plugin.HasMessage(WINIX_POST_PARAMS);
|
||||
has_winix_raw_post_msg = plugin.HasMessage(WINIX_RAW_POST_STRING);
|
||||
has_winix_post_params_msg = plugin->HasMessage(WINIX_POST_PARAMS);
|
||||
has_winix_raw_post_msg = plugin->HasMessage(WINIX_RAW_POST_STRING);
|
||||
|
||||
HttpSimpleParser::Parse();
|
||||
|
||||
if( has_winix_raw_post_msg )
|
||||
plugin.Call(0, WINIX_RAW_POST_STRING, &raw_post);
|
||||
plugin->Call(0, WINIX_RAW_POST_STRING, &raw_post);
|
||||
|
||||
raw_post.clear();
|
||||
}
|
||||
|
||||
@@ -37,6 +37,8 @@
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "winixbase.h"
|
||||
|
||||
|
||||
|
||||
namespace Winix
|
||||
@@ -47,7 +49,7 @@ namespace Winix
|
||||
struct Cur;
|
||||
|
||||
|
||||
class Rebus
|
||||
class Rebus : public WinixBase
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
@@ -38,7 +38,6 @@
|
||||
#include <sys/wait.h>
|
||||
#include <cstring>
|
||||
#include "run.h"
|
||||
#include "log.h"
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2011-2014, Tomasz Sowa
|
||||
* Copyright (c) 2011-2018, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -38,6 +38,7 @@
|
||||
#include <string>
|
||||
#include <cstdio>
|
||||
#include <unistd.h>
|
||||
#include "winixbase.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
@@ -64,7 +65,7 @@ namespace Winix
|
||||
7. winix waitpid() for the child
|
||||
8. Go() returns
|
||||
*/
|
||||
class Run
|
||||
class Run : public WinixBase
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* Copyright (c) 2008-2018, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -44,7 +44,6 @@ namespace Winix
|
||||
Session::Session()
|
||||
{
|
||||
Clear();
|
||||
plugin_data.SetSession(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +62,6 @@ Session & Session::operator=(const Session & ses)
|
||||
|
||||
Clear();
|
||||
id = ses.id;
|
||||
plugin_data.SetSession(this);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* Copyright (c) 2008-2018, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -80,7 +80,12 @@ Table::iterator i = table.begin();
|
||||
// because plugins session data would not be erased
|
||||
while( i != table.end() )
|
||||
{
|
||||
i->plugin_data.DeleteAll(); // it's better to call it here instead in the destructor
|
||||
if( i->plugin_data.HasAllocatedData() )
|
||||
{
|
||||
plugin->Call(&*i, WINIX_PLUGIN_SESSION_DATA_REMOVE); // the session passed here is ok?
|
||||
}
|
||||
|
||||
//i->plugin_data.DeleteAll(); // it's better to call it here instead in the destructor
|
||||
table.erase(i++);
|
||||
}
|
||||
|
||||
@@ -108,7 +113,14 @@ IndexId::iterator i = index_id.find(id);
|
||||
|
||||
// call first DeleteAll() because if not then it would be called from the destructor
|
||||
// and there'll be a problem if it throws an exception there
|
||||
i->second->plugin_data.DeleteAll();
|
||||
|
||||
if( i->second->plugin_data.HasAllocatedData() )
|
||||
{
|
||||
plugin->Call(&*(i->second), WINIX_PLUGIN_SESSION_DATA_REMOVE); // the session passed here is ok?
|
||||
}
|
||||
|
||||
//i->second->plugin_data.DeleteAll();
|
||||
|
||||
table.erase(i->second);
|
||||
index_id.erase(i);
|
||||
table_size -= 1;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* Copyright (c) 2008-2018, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -42,6 +42,8 @@
|
||||
#include "session.h"
|
||||
#include "cur.h"
|
||||
#include "config.h"
|
||||
#include "winixmodel.h"
|
||||
|
||||
|
||||
|
||||
namespace Winix
|
||||
@@ -50,7 +52,7 @@ namespace Winix
|
||||
|
||||
|
||||
|
||||
class SessionContainer
|
||||
class SessionContainer : public WinixModel
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2014, Tomasz Sowa
|
||||
* Copyright (c) 2014-2018, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -39,7 +39,6 @@
|
||||
#include "space/spaceparser.h"
|
||||
#include "utf8/utf8.h"
|
||||
#include "date/date.h"
|
||||
#include "log.h"
|
||||
#include "misc.h"
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2014, Tomasz Sowa
|
||||
* Copyright (c) 2014-2018, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -42,6 +42,8 @@
|
||||
#include "base64.h"
|
||||
#include "space/space.h"
|
||||
#include "aes.h"
|
||||
#include "winixbase.h"
|
||||
|
||||
|
||||
|
||||
namespace Winix
|
||||
@@ -74,7 +76,7 @@ namespace Winix
|
||||
*
|
||||
*
|
||||
*/
|
||||
class SessionIdManager
|
||||
class SessionIdManager : public WinixBase
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
#include "log.h"
|
||||
#include "session.h"
|
||||
#include "sessionparser.h"
|
||||
#include "plugin.h"
|
||||
#include "functions/functionbase.h"
|
||||
|
||||
|
||||
|
||||
@@ -96,6 +96,14 @@ void SessionManager::SetLastContainer(LastContainer * plast_container)
|
||||
}
|
||||
|
||||
|
||||
void SessionManager::set_dependency(WinixModel * winix_model)
|
||||
{
|
||||
WinixModel::set_dependency(winix_model);
|
||||
session_tab.set_dependency(winix_model);
|
||||
session_id_manager.set_dependency(winix_model);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SessionManager::InitBanList()
|
||||
{
|
||||
@@ -554,7 +562,7 @@ void SessionManager::DeleteSessions()
|
||||
{
|
||||
if( i->puser && !i->remember_me )
|
||||
{
|
||||
plugin.Call(&(*i), WINIX_PREPARE_USER_TO_LOGOUT, i->puser);
|
||||
plugin->Call(&(*i), WINIX_PREPARE_USER_TO_LOGOUT, i->puser);
|
||||
last_container->UserLogout(i->puser->id, i->id);
|
||||
}
|
||||
}
|
||||
@@ -586,7 +594,7 @@ SessionContainer::Iterator i = session_tab.FindById(old_id);
|
||||
}
|
||||
|
||||
if( changed )
|
||||
plugin.Call(&(*i), WINIX_SESSION_CHANGED_ID, old_id, new_id);
|
||||
plugin->Call(&(*i), WINIX_SESSION_CHANGED_ID, old_id, new_id);
|
||||
else
|
||||
log << log1 << "SM: I cannot create a new session id (still uses old one)" << logend;
|
||||
}
|
||||
@@ -605,7 +613,7 @@ void SessionManager::InitTmpSession()
|
||||
|
||||
log << log4 << "SM: initializing temporary session" << logend;
|
||||
cur->session = &temporary_session;
|
||||
plugin.Call(WINIX_SESSION_CREATED);
|
||||
plugin->Call(WINIX_SESSION_CREATED);
|
||||
|
||||
cur->session = old_session;
|
||||
}
|
||||
@@ -618,7 +626,15 @@ void SessionManager::UninitTmpSession()
|
||||
|
||||
log << log4 << "SM: uninitializing temporary session" << logend;
|
||||
cur->session = &temporary_session;
|
||||
cur->session->plugin_data.DeleteAll(); // this will call plugin.Call(WINIX_PLUGIN_SESSION_DATA_REMOVE);
|
||||
|
||||
|
||||
if( cur->session->plugin_data.HasAllocatedData() )
|
||||
{
|
||||
plugin->Call(cur->session, WINIX_PLUGIN_SESSION_DATA_REMOVE);
|
||||
}
|
||||
|
||||
//cur->session->plugin_data.DeleteAll(); // this will call plugin.Call(WINIX_PLUGIN_SESSION_DATA_REMOVE);
|
||||
|
||||
cur->session->plugin_data.Resize(0);
|
||||
|
||||
cur->session = old_session;
|
||||
@@ -631,6 +647,8 @@ void SessionManager::LoadSessions()
|
||||
SessionParser sp;
|
||||
SessionContainer::Iterator i;
|
||||
|
||||
sp.set_dependency(this);
|
||||
|
||||
// sessions will be overwritten (pointers are invalidated)
|
||||
cur->session = &temporary_session;
|
||||
|
||||
@@ -639,8 +657,8 @@ SessionContainer::Iterator i;
|
||||
|
||||
for(i=session_tab.Begin() ; i != session_tab.End() ; ++i)
|
||||
{
|
||||
i->plugin_data.Resize(plugin.Size());
|
||||
plugin.Call(&(*i), WINIX_SESSION_CREATED);
|
||||
i->plugin_data.Resize(plugin->Size());
|
||||
plugin->Call(&(*i), WINIX_SESSION_CREATED);
|
||||
|
||||
/*
|
||||
!! IMPROVE ME
|
||||
@@ -648,7 +666,7 @@ SessionContainer::Iterator i;
|
||||
*/
|
||||
|
||||
if( i->puser )
|
||||
plugin.Call(&(*i), WINIX_USER_LOGGED);
|
||||
plugin->Call(&(*i), WINIX_USER_LOGGED);
|
||||
}
|
||||
|
||||
cur->session = &temporary_session;
|
||||
@@ -724,7 +742,7 @@ size_t SessionManager::MarkAllSessionsToRemove(long user_id)
|
||||
{
|
||||
if( i->puser && i->puser->id == user_id )
|
||||
{
|
||||
plugin.Call(&(*i), WINIX_PREPARE_USER_TO_LOGOUT, i->puser);
|
||||
plugin->Call(&(*i), WINIX_PREPARE_USER_TO_LOGOUT, i->puser);
|
||||
last_container->UserLogout(i->puser->id, i->id);
|
||||
i->remove_me = true;
|
||||
i->puser = 0;
|
||||
@@ -883,16 +901,16 @@ void SessionManager::DeleteSession(Session * del_session)
|
||||
{
|
||||
if( del_session->puser )
|
||||
{
|
||||
plugin.Call(del_session, WINIX_PREPARE_USER_TO_LOGOUT, del_session->puser);
|
||||
plugin->Call(del_session, WINIX_PREPARE_USER_TO_LOGOUT, del_session->puser);
|
||||
last_container->UserLogout(del_session->puser->id, del_session->id);
|
||||
del_session->puser = 0;
|
||||
}
|
||||
|
||||
long id = del_session->id;
|
||||
|
||||
plugin.Call(del_session, WINIX_PREPARE_SESSION_TO_REMOVE);
|
||||
plugin->Call(del_session, WINIX_PREPARE_SESSION_TO_REMOVE);
|
||||
session_tab.EraseById(del_session->id);
|
||||
plugin.Call((Session*)0, WINIX_SESSION_REMOVED, id);
|
||||
plugin->Call((Session*)0, WINIX_SESSION_REMOVED, id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -66,6 +66,7 @@ public:
|
||||
void SetSystem(System * psystem);
|
||||
void SetLastContainer(LastContainer * plast_container);
|
||||
|
||||
void set_dependency(WinixModel * winix_model);
|
||||
|
||||
// can return a null pointer
|
||||
Session * FindSession(long id);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* Copyright (c) 2008-2018, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -47,7 +47,7 @@ namespace Winix
|
||||
|
||||
|
||||
|
||||
class SessionParser
|
||||
class SessionParser : public WinixBase
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
@@ -164,8 +164,6 @@ return *this;
|
||||
}
|
||||
|
||||
|
||||
extern SLog slog;
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
@@ -37,7 +37,6 @@
|
||||
#include "error.h"
|
||||
#include "templates/templates.h"
|
||||
#include "functions/functions.h"
|
||||
#include "plugin.h"
|
||||
|
||||
|
||||
|
||||
@@ -53,10 +52,10 @@ void System::SetCur(Cur * pcur)
|
||||
}
|
||||
|
||||
|
||||
void System::SetConfig(Config * pconfig)
|
||||
{
|
||||
config = pconfig;
|
||||
}
|
||||
//void System::SetConfig(Config * pconfig)
|
||||
//{
|
||||
// config = pconfig;
|
||||
//}
|
||||
|
||||
|
||||
void System::SetDb(Db * pdb)
|
||||
@@ -65,10 +64,10 @@ void System::SetDb(Db * pdb)
|
||||
}
|
||||
|
||||
|
||||
void System::SetSynchro(Synchro * psynchro)
|
||||
{
|
||||
synchro = psynchro;
|
||||
}
|
||||
//void System::SetSynchro(Synchro * psynchro)
|
||||
//{
|
||||
// synchro = psynchro;
|
||||
//}
|
||||
|
||||
|
||||
void System::SetFunctions(Functions * pfunctions)
|
||||
@@ -82,6 +81,14 @@ void System::SetSessionManager(SessionManager * sm)
|
||||
}
|
||||
|
||||
|
||||
void System::set_dependency(WinixModel * winix_model)
|
||||
{
|
||||
job.set_dependency(winix_model);
|
||||
time_zones.set_dependency(winix_model);
|
||||
WinixModel::set_dependency(winix_model);
|
||||
}
|
||||
|
||||
|
||||
void System::ReadTimeZones()
|
||||
{
|
||||
if( config->etc_dir.empty() )
|
||||
@@ -107,31 +114,39 @@ void System::ReadTimeZones()
|
||||
|
||||
void System::Init()
|
||||
{
|
||||
thread_manager.SetSynchro(synchro);
|
||||
//thread_manager.SetSynchro(synchro);
|
||||
thread_manager.set_dependency(this);
|
||||
thread_manager.Init();
|
||||
|
||||
dirs.set_dependency(this);
|
||||
dirs.SetDb(db);
|
||||
dirs.SetCur(cur);
|
||||
dirs.SetCur(cur); // only one method is using cur, can be passed as a parameter to the method
|
||||
dirs.SetNotify(¬ify);
|
||||
dirs.ReadDirs();
|
||||
|
||||
mounts.set_dependency(this);
|
||||
mounts.SkipStaticDirs(config->dont_use_static_dirs);
|
||||
mounts.SetDirs(&dirs);
|
||||
mounts.SetDb(db);
|
||||
mounts.SetCur(cur);
|
||||
mounts.SetCur(cur); // only one method is using cur, can be passed as a parameter to the method
|
||||
mounts.CreateMounts();
|
||||
mounts.ReadMounts();
|
||||
|
||||
users.set_dependency(this);
|
||||
users.SetCur(cur);
|
||||
users.SetSessionManager(session_manager);
|
||||
users.ReadUsers(db);
|
||||
|
||||
groups.set_dependency(this);
|
||||
groups.ReadGroups(db); // !! chwilowe przekazanie argumentu, db bedzie zmienione
|
||||
|
||||
rebus.set_dependency(this);
|
||||
rebus.SetCur(cur);
|
||||
rebus.Init();
|
||||
|
||||
notify.set_dependency(this);
|
||||
notify.SetCur(cur);
|
||||
notify.SetConfig(config);
|
||||
//notify.SetConfig(config);
|
||||
notify.SetUsers(&users);
|
||||
notify.SetDirs(&dirs);
|
||||
notify.SetThreadManager(&thread_manager);
|
||||
@@ -142,7 +157,7 @@ void System::Init()
|
||||
image.SetSystem(this);
|
||||
thread_manager.Add(&image, L"image");
|
||||
|
||||
crypt.SetConfig(config);
|
||||
crypt.set_dependency(this);
|
||||
|
||||
// SetSynchro will be called by ThreadManager itself
|
||||
// job.ReadFromFile();
|
||||
@@ -1020,7 +1035,7 @@ Error System::AddFile(Item & item, int notify_code, bool call_plugins)
|
||||
notify.ItemChanged(notify_code, item);
|
||||
|
||||
if( call_plugins )
|
||||
plugin.Call(WINIX_FILE_ADDED, &item);
|
||||
plugin->Call(WINIX_FILE_ADDED, &item);
|
||||
}
|
||||
|
||||
return status;
|
||||
@@ -1052,7 +1067,7 @@ Error System::EditFile(Item & item, bool with_url, int notify_code, bool call_pl
|
||||
notify.ItemChanged(notify_code, item);
|
||||
|
||||
if( call_plugins )
|
||||
plugin.Call(WINIX_FILE_CHANGED, &item);
|
||||
plugin->Call(WINIX_FILE_CHANGED, &item);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ class SessionManager;
|
||||
|
||||
|
||||
// file system
|
||||
class System
|
||||
class System : WinixModel
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -110,11 +110,14 @@ public:
|
||||
|
||||
|
||||
void SetCur(Cur * pcur);
|
||||
void SetConfig(Config * pconfig);
|
||||
//void SetConfig(Config * pconfig);
|
||||
void SetDb(Db * pdb);
|
||||
void SetSynchro(Synchro * psynchro);
|
||||
//void SetSynchro(Synchro * psynchro);
|
||||
void SetFunctions(Functions * pfunctions);
|
||||
void SetSessionManager(SessionManager * sm);
|
||||
|
||||
void set_dependency(WinixModel * winix_model);
|
||||
|
||||
void Init();
|
||||
|
||||
void AddParams(const ParamTab & param_tab, std::wstring & str, bool clear_str = true);
|
||||
@@ -219,8 +222,8 @@ private:
|
||||
|
||||
Cur * cur;
|
||||
Db * db;
|
||||
Config * config;
|
||||
Synchro * synchro;
|
||||
//Config * config;
|
||||
//Synchro * synchro;
|
||||
Functions * functions;
|
||||
SessionManager * session_manager;
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2011-2014, Tomasz Sowa
|
||||
* Copyright (c) 2011-2018, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -49,10 +49,10 @@ ThreadManager::ThreadManager()
|
||||
}
|
||||
|
||||
|
||||
void ThreadManager::SetSynchro(Synchro * psynchro)
|
||||
{
|
||||
synchro = psynchro;
|
||||
}
|
||||
//void ThreadManager::SetSynchro(Synchro * psynchro)
|
||||
//{
|
||||
// synchro = psynchro;
|
||||
//}
|
||||
|
||||
|
||||
void ThreadManager::Init()
|
||||
@@ -70,20 +70,37 @@ sigset_t set;
|
||||
|
||||
|
||||
|
||||
|
||||
void ThreadManager::Add(BaseThread * pbase, const wchar_t * thread_name)
|
||||
{
|
||||
ThreadItem item;
|
||||
|
||||
item.object = pbase;
|
||||
item.name = thread_name;
|
||||
|
||||
thread_tab.push_back(item);
|
||||
thread_tab.back().thread_item_data = new ThreadItemData();
|
||||
thread_tab.back().object->set_dependency(this);
|
||||
|
||||
// the logger buffer and model_connector are different
|
||||
ThreadItemData & data = *thread_tab.back().thread_item_data;
|
||||
thread_tab.back().object->set_log_buffer(&data.log_buffer);
|
||||
|
||||
//data.postgresql_connector.set_logger(logger);
|
||||
data.postgresql_connector.set_conn_param(config->db_database, config->db_user, config->db_pass);
|
||||
data.postgresql_connector.wait_for_connection();
|
||||
data.model_connector.set_db_connector(data.postgresql_connector);
|
||||
data.model_connector.set_flat_connector(data.json_connector);
|
||||
thread_tab.back().object->set_model_connector(&data.model_connector);
|
||||
|
||||
if( were_started )
|
||||
Start(thread_tab.size() - 1);
|
||||
{
|
||||
Start(thread_tab.size() - 1, &thread_tab.back());
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log4 << "TM: added a thread to the queue, number: " << (thread_tab.size()-1)
|
||||
<< ", name: " << thread_name << logend;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -109,8 +126,13 @@ void ThreadManager::StartAll()
|
||||
{
|
||||
synchro->Lock();
|
||||
|
||||
for(size_t i=0 ; i<thread_tab.size() ; ++i)
|
||||
Start(i);
|
||||
int id = 0;
|
||||
|
||||
for(ThreadItem & item : thread_tab)
|
||||
{
|
||||
Start(id, &item);
|
||||
id += 1;
|
||||
}
|
||||
|
||||
synchro->Unlock();
|
||||
|
||||
@@ -118,22 +140,18 @@ void ThreadManager::StartAll()
|
||||
}
|
||||
|
||||
|
||||
void ThreadManager::Start(size_t i)
|
||||
void ThreadManager::Start(int id, ThreadItem * item)
|
||||
{
|
||||
if( i < thread_tab.size() )
|
||||
{
|
||||
thread_tab[i].object->SetSynchro(synchro);
|
||||
item->object->SetSynchro(synchro);
|
||||
|
||||
if( thread_tab[i].object->StartThread() )
|
||||
{
|
||||
log << log4 << "TM: thread " << i << " (" << thread_tab[i].object->ThreadId() << ", name: "
|
||||
<< thread_tab[i].name << ") started" << logend;
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log4 << "TM: cannot run a thread, thread number: " << i
|
||||
<< ", name: " << thread_tab[i].name << logend;
|
||||
}
|
||||
if( item->object->StartThread() )
|
||||
{
|
||||
log << log4 << "TM: thread " << id << " (" << item->object->ThreadId() << ", name: "
|
||||
<< item->name << ") started" << logend;
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log4 << "TM: cannot run a thread " << id << ", name: " << item->name << logend;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,21 +164,29 @@ void ThreadManager::StopAll()
|
||||
// WakeUpThread() should be used with Lock/Unlock
|
||||
synchro->Lock();
|
||||
|
||||
for(size_t i=0 ; i<thread_tab.size() ; ++i)
|
||||
thread_tab[i].object->WakeUpThread();
|
||||
for(ThreadItem & item : thread_tab)
|
||||
{
|
||||
item.object->WakeUpThread();
|
||||
}
|
||||
|
||||
synchro->Unlock();
|
||||
|
||||
|
||||
for(size_t i=0 ; i<thread_tab.size() ; ++i)
|
||||
int id = 0;
|
||||
|
||||
for(ThreadItem & item : thread_tab)
|
||||
{
|
||||
log << log4 << "TM: waiting for thread " << i << " (" << thread_tab[i].object->ThreadId()
|
||||
<< ", name: " << thread_tab[i].name << ")" << logend;
|
||||
log << log4 << "TM: waiting for thread " << id << " (" << item.object->ThreadId()
|
||||
<< ", name: " << item.name << ")" << logend;
|
||||
|
||||
thread_tab[i].object->WaitForThread();
|
||||
item.object->WaitForThread();
|
||||
log << log4 << "TM: thread " << id << " terminated" << logend;
|
||||
|
||||
log << log4 << "TM: thread " << i << " terminated" << logend;
|
||||
delete item.thread_item_data;
|
||||
id += 1;
|
||||
}
|
||||
|
||||
thread_tab.clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#define headerfile_winix_core_threadmanager
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include "basethread.h"
|
||||
#include "synchro.h"
|
||||
|
||||
@@ -47,14 +47,14 @@ namespace Winix
|
||||
|
||||
|
||||
|
||||
class ThreadManager
|
||||
class ThreadManager : public WinixModel
|
||||
{
|
||||
public:
|
||||
|
||||
ThreadManager();
|
||||
|
||||
// synchro object
|
||||
void SetSynchro(Synchro * psynchro);
|
||||
//void SetSynchro(Synchro * psynchro);
|
||||
|
||||
// initializing
|
||||
void Init();
|
||||
@@ -76,18 +76,30 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
struct ThreadItemData
|
||||
{
|
||||
morm::ModelConnector model_connector;
|
||||
morm::JSONConnector json_connector;
|
||||
morm::PostgreSQLConnector postgresql_connector;
|
||||
|
||||
TextStream<std::wstring> log_buffer;
|
||||
};
|
||||
|
||||
struct ThreadItem
|
||||
{
|
||||
BaseThread * object;
|
||||
std::wstring name;
|
||||
|
||||
ThreadItemData * thread_item_data;
|
||||
};
|
||||
|
||||
Synchro * synchro;
|
||||
typedef std::vector<ThreadItem> ThreadTab;
|
||||
|
||||
//Synchro * synchro;
|
||||
typedef std::list<ThreadItem> ThreadTab;
|
||||
ThreadTab thread_tab;
|
||||
bool were_started;
|
||||
|
||||
void Start(size_t i);
|
||||
void Start(int id, ThreadItem * item);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2012-2014, Tomasz Sowa
|
||||
* Copyright (c) 2012-2018, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -39,6 +39,7 @@
|
||||
#include <vector>
|
||||
#include "timezone.h"
|
||||
#include "space/spaceparser.h"
|
||||
#include "winixbase.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
@@ -47,7 +48,7 @@ namespace Winix
|
||||
|
||||
|
||||
|
||||
class TimeZones
|
||||
class TimeZones : public WinixBase
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include "log.h"
|
||||
#include "winixbase.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
@@ -46,7 +46,7 @@ namespace Winix
|
||||
|
||||
|
||||
template<class Type>
|
||||
class UGContainer
|
||||
class UGContainer : public WinixBase
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* Copyright (c) 2008-2018, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -35,7 +35,6 @@
|
||||
#include <arpa/inet.h>
|
||||
#include "users.h"
|
||||
#include "sessionmanager.h"
|
||||
#include "plugin.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
@@ -46,10 +45,19 @@ namespace Winix
|
||||
Users::Users()
|
||||
{
|
||||
how_many_logged = 0; // !! CHECK ME may it should be moved to Clear() method?
|
||||
table.set_dependency(this);
|
||||
Clear();
|
||||
}
|
||||
|
||||
|
||||
void Users::set_dependency(WinixModel * winix_model)
|
||||
{
|
||||
WinixModel::set_dependency(winix_model);
|
||||
table.set_dependency(winix_model);
|
||||
last.set_dependency(winix_model);
|
||||
}
|
||||
|
||||
|
||||
void Users::SetCur(Cur * pcur)
|
||||
{
|
||||
cur = pcur;
|
||||
@@ -155,11 +163,11 @@ bool Users::Remove(long user_id)
|
||||
if( puser )
|
||||
{
|
||||
LogoutUser(user_id);
|
||||
plugin.Call(WINIX_PREPARE_TO_REMOVE_USER, puser);
|
||||
plugin->Call(WINIX_PREPARE_TO_REMOVE_USER, puser);
|
||||
result = table.Remove(user_id);
|
||||
|
||||
if( result )
|
||||
plugin.Call(WINIX_USER_REMOVED, user_id);
|
||||
plugin->Call(WINIX_USER_REMOVED, user_id);
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -176,8 +184,8 @@ bool Users::LoginUserCheckSession(bool use_ses_log)
|
||||
{
|
||||
log << log1 << "Users: I cannot login a user on a temporary session" << logend;
|
||||
|
||||
if( use_ses_log )
|
||||
slog << logerror << T(L"service_unavailable") << logend;
|
||||
// if( use_ses_log )
|
||||
// slog << logerror << T(L"service_unavailable") << logend;
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -195,8 +203,8 @@ User * Users::LoginUserCheckStatus(long user_id, bool use_ses_log)
|
||||
{
|
||||
log << log1 << "Users: user id: " << user_id << " is not in system.users table" << logend;
|
||||
|
||||
if( use_ses_log )
|
||||
slog << logerror << T(L"service_unavailable") << logend;
|
||||
// if( use_ses_log )
|
||||
// slog << logerror << T(L"service_unavailable") << logend;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -208,6 +216,7 @@ User * Users::LoginUserCheckStatus(long user_id, bool use_ses_log)
|
||||
|
||||
if( use_ses_log )
|
||||
{
|
||||
/*
|
||||
if( puser->status == WINIX_ACCOUNT_NOT_ACTIVATED )
|
||||
slog << logerror << T(L"account_not_activated") << logend;
|
||||
else
|
||||
@@ -216,6 +225,7 @@ User * Users::LoginUserCheckStatus(long user_id, bool use_ses_log)
|
||||
else
|
||||
if( puser->status == WINIX_ACCOUNT_BLOCKED )
|
||||
slog << logerror << T(L"account_banned") << logend;
|
||||
*/
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -236,7 +246,7 @@ bool Users::LoginUser(long user_id, bool remember_me, bool use_ses_log)
|
||||
if( !puser )
|
||||
return false;
|
||||
|
||||
PluginRes res = plugin.Call(WINIX_PREPARE_USER_TO_LOGIN, puser);
|
||||
PluginRes res = plugin->Call(WINIX_PREPARE_USER_TO_LOGIN, puser);
|
||||
|
||||
if( res.res_false > 0 )
|
||||
{
|
||||
@@ -259,7 +269,7 @@ bool Users::LoginUser(long user_id, bool remember_me, bool use_ses_log)
|
||||
how_many_logged += 1;
|
||||
|
||||
log << log2 << "Users: user " << cur->session->puser->name << " (id: " << user_id << ") logged" << logend;
|
||||
plugin.Call(WINIX_USER_LOGGED);
|
||||
plugin->Call(WINIX_USER_LOGGED);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -296,7 +306,7 @@ void Users::LogoutCurrentUser()
|
||||
log << log2 << "Users: user " << cur->session->puser->name << ", id: "
|
||||
<< cur->session->puser->id << " logged out" << logend;
|
||||
|
||||
plugin.Call(WINIX_PREPARE_USER_TO_LOGOUT, cur->session->puser);
|
||||
plugin->Call(WINIX_PREPARE_USER_TO_LOGOUT, cur->session->puser);
|
||||
last.UserLogout(cur->session->puser->id, cur->session->id);
|
||||
|
||||
if( how_many_logged > 0 ) // for safety
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* Copyright (c) 2008-2018, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -41,6 +41,8 @@
|
||||
#include "lastcontainer.h"
|
||||
#include "cur.h"
|
||||
#include "db/db.h"
|
||||
#include "winixmodel.h"
|
||||
|
||||
|
||||
|
||||
namespace Winix
|
||||
@@ -51,12 +53,15 @@ namespace Winix
|
||||
class SessionManager;
|
||||
|
||||
|
||||
class Users
|
||||
class Users : public WinixModel
|
||||
{
|
||||
typedef UGContainer<User> Table;
|
||||
|
||||
public:
|
||||
|
||||
void set_dependency(WinixModel * winix_model);
|
||||
|
||||
|
||||
typedef Table::Iterator Iterator;
|
||||
typedef Table::SizeType SizeType;
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* Copyright (c) 2008-2018, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -41,8 +41,8 @@ namespace Winix
|
||||
|
||||
|
||||
#define WINIX_VER_MAJOR 0
|
||||
#define WINIX_VER_MINOR 6
|
||||
#define WINIX_VER_REVISION 6
|
||||
#define WINIX_VER_MINOR 7
|
||||
#define WINIX_VER_REVISION 0
|
||||
|
||||
|
||||
|
||||
|
||||
89
winixd/core/winixbase.cpp
Normal file
89
winixd/core/winixbase.cpp
Normal file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2018, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "winixbase.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
WinixBase::WinixBase()
|
||||
{
|
||||
config = nullptr;
|
||||
synchro = nullptr;
|
||||
}
|
||||
|
||||
|
||||
WinixBase::~WinixBase()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void WinixBase::set_config(Config * config)
|
||||
{
|
||||
this->config = config;
|
||||
}
|
||||
|
||||
|
||||
void WinixBase::set_synchro(Synchro * synchro)
|
||||
{
|
||||
this->synchro = synchro;
|
||||
}
|
||||
|
||||
|
||||
void WinixBase::set_log_buffer(TextStream<std::wstring> * log_buffer)
|
||||
{
|
||||
log.SetLogBuffer(log_buffer);
|
||||
}
|
||||
|
||||
|
||||
void WinixBase::set_file_log(FileLog * file_log)
|
||||
{
|
||||
log.SetFileLog(file_log);
|
||||
}
|
||||
|
||||
|
||||
void WinixBase::set_dependency(WinixBase * winix_base)
|
||||
{
|
||||
config = winix_base->config;
|
||||
synchro = winix_base->synchro;
|
||||
log.SetFileLog(winix_base->log.GetFileLog());
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
80
winixd/core/winixbase.h
Normal file
80
winixd/core/winixbase.h
Normal file
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2018, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_core_winixbase
|
||||
#define headerfile_winix_core_winixbase
|
||||
|
||||
#include <string>
|
||||
#include "core/config.h"
|
||||
#include "core/log.h"
|
||||
#include "core/synchro.h"
|
||||
#include "core/filelog.h"
|
||||
#include "lock.h"
|
||||
#include "textstream.h"
|
||||
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
class WinixBase
|
||||
{
|
||||
public:
|
||||
|
||||
WinixBase();
|
||||
virtual ~WinixBase();
|
||||
|
||||
void set_config(Config * config);
|
||||
void set_synchro(Synchro * synchro);
|
||||
void set_log_buffer(TextStream<std::wstring> * log_buffer);
|
||||
void set_file_log(FileLog * file_log);
|
||||
|
||||
void set_dependency(WinixBase * winix_base);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
Log log;
|
||||
|
||||
Config * config;
|
||||
Synchro * synchro;
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
83
winixd/core/winixmodel.cpp
Normal file
83
winixd/core/winixmodel.cpp
Normal file
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2018, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "winixmodel.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
WinixModel::WinixModel()
|
||||
{
|
||||
plugin = nullptr;
|
||||
model_connector = nullptr;
|
||||
}
|
||||
|
||||
|
||||
WinixModel::~WinixModel()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void WinixModel::set_plugin(Plugin * plugin)
|
||||
{
|
||||
this->plugin = plugin;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void WinixModel::set_model_connector(morm::ModelConnector * model_connector)
|
||||
{
|
||||
this->model_connector = model_connector;
|
||||
}
|
||||
|
||||
|
||||
void WinixModel::set_dependency(WinixBase * winix_base)
|
||||
{
|
||||
WinixBase::set_dependency(winix_base);
|
||||
}
|
||||
|
||||
|
||||
void WinixModel::set_dependency(WinixModel * winix_model)
|
||||
{
|
||||
WinixBase::set_dependency(winix_model);
|
||||
model_connector = winix_model->model_connector;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
71
winixd/core/winixmodel.h
Normal file
71
winixd/core/winixmodel.h
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2018, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_core_winixmodel
|
||||
#define headerfile_winix_core_winixmodel
|
||||
|
||||
#include "core/winixbase.h"
|
||||
#include "plugin.h"
|
||||
#include "morm.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
// may rename it to WinixConnector or WinixStorage?
|
||||
class WinixModel : public WinixBase
|
||||
{
|
||||
public:
|
||||
|
||||
WinixModel();
|
||||
virtual ~WinixModel();
|
||||
|
||||
void set_model_connector(morm::ModelConnector * model_connector);
|
||||
void set_plugin(Plugin * plugin);
|
||||
|
||||
void set_dependency(WinixBase * winix_base);
|
||||
void set_dependency(WinixModel * winix_model);
|
||||
|
||||
protected:
|
||||
|
||||
morm::ModelConnector * model_connector;
|
||||
Plugin * plugin;
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
108
winixd/core/winixrequest.cpp
Normal file
108
winixd/core/winixrequest.cpp
Normal file
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2018, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "winixrequest.h"
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
WinixRequest::WinixRequest()
|
||||
{
|
||||
cur = nullptr;
|
||||
locale = nullptr;
|
||||
session_manager = nullptr;
|
||||
}
|
||||
|
||||
|
||||
WinixRequest::~WinixRequest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void WinixRequest::set_cur(Cur * cur)
|
||||
{
|
||||
this->cur = cur;
|
||||
slog.SetCur(cur);
|
||||
}
|
||||
|
||||
|
||||
void WinixRequest::set_session_manager(SessionManager * session_manager)
|
||||
{
|
||||
this->session_manager = session_manager;
|
||||
}
|
||||
|
||||
|
||||
void WinixRequest::set_locale(Locale * locale)
|
||||
{
|
||||
this->locale = locale;
|
||||
slog.SetLocale(locale);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void WinixRequest::set_dependency(WinixBase * winix_base)
|
||||
{
|
||||
WinixBase::set_dependency(winix_base);
|
||||
}
|
||||
|
||||
|
||||
void WinixRequest::set_dependency(WinixModel * winix_model)
|
||||
{
|
||||
WinixModel::set_dependency(winix_model);
|
||||
}
|
||||
|
||||
|
||||
void WinixRequest::set_dependency(WinixSystem * winix_system)
|
||||
{
|
||||
WinixSystem::set_dependency(winix_system);
|
||||
}
|
||||
|
||||
|
||||
void WinixRequest::set_dependency(WinixRequest * winix_request)
|
||||
{
|
||||
WinixSystem::set_dependency(winix_request);
|
||||
cur = winix_request->cur;
|
||||
locale = winix_request->locale;
|
||||
session_manager = winix_request->session_manager;
|
||||
|
||||
// CHECK ME what about slog
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
82
winixd/core/winixrequest.h
Normal file
82
winixd/core/winixrequest.h
Normal file
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2018, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_core_winixrequest
|
||||
#define headerfile_winix_core_winixrequest
|
||||
|
||||
#include "core/winixsystem.h"
|
||||
#include "core/cur.h"
|
||||
#include "core/sessionmanager.h"
|
||||
#include "core/slog.h"
|
||||
#include "templates/locale.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
class WinixRequest : public WinixSystem
|
||||
{
|
||||
public:
|
||||
|
||||
WinixRequest();
|
||||
virtual ~WinixRequest();
|
||||
|
||||
virtual void set_cur(Cur * cur);
|
||||
virtual void set_session_manager(SessionManager * session_manager);
|
||||
virtual void set_locale(Locale * locale);
|
||||
|
||||
|
||||
void set_dependency(WinixBase * winix_base);
|
||||
void set_dependency(WinixModel * winix_model);
|
||||
void set_dependency(WinixSystem * winix_system);
|
||||
void set_dependency(WinixRequest * winix_request);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
SLog slog;
|
||||
|
||||
Cur * cur;
|
||||
Locale * locale; // locales can be used not only in templates -- should be moved to a better place
|
||||
SessionManager * session_manager; // may it should be moved to WinixSystem or System?
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
76
winixd/core/winixsystem.cpp
Normal file
76
winixd/core/winixsystem.cpp
Normal file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2018, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "winixsystem.h"
|
||||
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
WinixSystem::WinixSystem()
|
||||
{
|
||||
system = nullptr;
|
||||
}
|
||||
|
||||
|
||||
void WinixSystem::set_system(System * system)
|
||||
{
|
||||
this->system = system;
|
||||
}
|
||||
|
||||
|
||||
void WinixSystem::set_dependency(WinixBase * winix_base)
|
||||
{
|
||||
WinixBase::set_dependency(winix_base);
|
||||
}
|
||||
|
||||
|
||||
void WinixSystem::set_dependency(WinixModel * winix_model)
|
||||
{
|
||||
WinixModel::set_dependency(winix_model);
|
||||
}
|
||||
|
||||
|
||||
void WinixSystem::set_dependency(WinixSystem * winix_system)
|
||||
{
|
||||
WinixModel::set_dependency(winix_system);
|
||||
system = winix_system->system;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
71
winixd/core/winixsystem.h
Normal file
71
winixd/core/winixsystem.h
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2018, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_core_winixsystem
|
||||
#define headerfile_winix_core_winixsystem
|
||||
|
||||
#include "core/winixmodel.h"
|
||||
#include "core/system.h"
|
||||
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
class WinixSystem : public WinixModel
|
||||
{
|
||||
public:
|
||||
|
||||
WinixSystem();
|
||||
virtual ~WinixSystem();
|
||||
|
||||
void set_system(System * system);
|
||||
|
||||
void set_dependency(WinixBase * winix_base);
|
||||
void set_dependency(WinixModel * winix_model);
|
||||
void set_dependency(WinixSystem * winix_system);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
System * system;
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user