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:
Tomasz Sowa 2018-11-21 11:03:53 +00:00
parent a7c47140ae
commit a2ffc1e81c
121 changed files with 7832 additions and 6662 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -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

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2008-2014, Tomasz Sowa * Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -36,6 +36,7 @@
#define headerfile_winix_core_acceptbaseparser #define headerfile_winix_core_acceptbaseparser
#include <string> #include <string>
#include "winixbase.h"
namespace Winix namespace Winix
@ -46,7 +47,7 @@ namespace Winix
// sample (you must create your own class derived from this one): // 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 "); // 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: public:

View File

@ -52,6 +52,7 @@
#include "convert/convert.h" #include "convert/convert.h"
namespace Winix namespace Winix
{ {
@ -64,36 +65,76 @@ App::App()
last_sessions_save = std::time(0); last_sessions_save = std::time(0);
fcgi_socket = -1; 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 // temporary there is only one request
cur.request = &req; cur.request = &req;
cur.session = session_manager.GetTmpSession(); cur.session = session_manager.GetTmpSession();
cur.mount = system.mounts.GetEmptyMount(); cur.mount = system.mounts.GetEmptyMount();
db_conn.set_dependency(&winix_base);
db.set_dependency(&winix_base);
db.SetConn(db_conn); db.SetConn(db_conn);
plugin.set_dependency(&winix_base);
plugin.SetDb(&db); plugin.SetDb(&db);
plugin.SetConfig(&config); //plugin.SetConfig(&config);
plugin.SetCur(&cur); plugin.SetCur(&cur);
plugin.SetSystem(&system); plugin.SetSystem(&system);
plugin.SetFunctions(&functions); plugin.SetFunctions(&functions);
plugin.SetTemplates(&templates); plugin.SetTemplates(&templates);
plugin.SetSynchro(&synchro); //plugin.SetSynchro(&synchro);
plugin.SetSessionManager(&session_manager); plugin.SetSessionManager(&session_manager);
plugin.SetWinixSystem(&winix_system);
req.SetConfig(&config); 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.SetCur(&cur);
functions.SetDb(&db); functions.SetDb(&db);
functions.SetSystem(&system); functions.SetSystem(&system);
functions.SetTemplates(&templates); functions.SetTemplates(&templates);
functions.SetSynchro(&synchro); //functions.SetSynchro(&synchro);
functions.SetSessionManager(&session_manager); functions.SetSessionManager(&session_manager);
system.SetConfig(&config);
system.set_dependency(&winix_model);
//system.SetConfig(&config);
system.SetCur(&cur); system.SetCur(&cur);
system.SetDb(&db); system.SetDb(&db);
system.SetSynchro(&synchro); //system.SetSynchro(&synchro);
system.SetFunctions(&functions); system.SetFunctions(&functions);
system.SetSessionManager(&session_manager); system.SetSessionManager(&session_manager);
@ -104,20 +145,33 @@ App::App()
templates.SetFunctions(&functions); templates.SetFunctions(&functions);
templates.SetSessionManager(&session_manager); 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.SetLastContainer(&system.users.last);
session_manager.SetConfig(&config); session_manager.SetConfig(&config);
session_manager.SetCur(&cur); session_manager.SetCur(&cur);
session_manager.SetSystem(&system); session_manager.SetSystem(&system);
session_manager.SetSynchro(&synchro); session_manager.SetSynchro(&synchro);
post_multi_parser.set_dependency(&winix_base);
post_multi_parser.SetConfig(&config); 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) bool App::InitFCGI(char * sock, char * sock_user, char * sock_group)
{ {
if( !WideToUTF8(config.fcgi_socket, sock, WINIX_OS_PATH_SIZE) ) if( !WideToUTF8(config.fcgi_socket, sock, WINIX_OS_PATH_SIZE) )
@ -213,14 +267,27 @@ return true;
bool App::Init() 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.SetConnParam(config.db_database, config.db_user, config.db_pass);
db_conn.WaitForConnection(); db_conn.WaitForConnection();
db.PostgreSQLsmallerThan10(config.db_postgresql_smaller_than_10); db.PostgreSQLsmallerThan10(config.db_postgresql_smaller_than_10);
db.LogQueries(config.log_db_query); db.LogQueries(config.log_db_query);
cur.request->Clear(); cur.request->Clear();
compress.set_dependency(&winix_base);
compress.Init(); compress.Init();
system.Init(); system.Init();
functions.Init(); functions.Init();
templates.Init(); // init templates after functions are created templates.Init(); // init templates after functions are created
@ -234,9 +301,14 @@ bool App::Init()
CreateStaticTree(); CreateStaticTree();
post_parser.set_dependency(&winix_model);
post_parser.LogValueSize(config.log_post_value_size); post_parser.LogValueSize(config.log_post_value_size);
// post_multi_parser has a pointer to the config // 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); plugin.Call((Session*)0, WINIX_PLUGIN_INIT);
return true; return true;
@ -246,10 +318,21 @@ return true;
void App::Close() void App::Close()
{ {
session_manager.SaveSessions(); {
session_manager.DeleteSessions(); Winix::Lock lock(synchro);
cur.request->Clear();
session_manager.UninitTmpSession(); 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() ) if( cur.session->ip_ban && cur.session->ip_ban->IsIPBanned() )
{ {
PT::Date date(cur.session->ip_ban->expires); 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; cur.request->status = WINIX_ERR_PERMISSION_DENIED;
} }
@ -972,7 +1057,7 @@ void App::SetSubdomain()
void App::LogAccess() void App::LogAccess()
{ {
log << log1; log << log1;
log.PrintDate(cur.request->start_date, config.log_time_zone_id); log.PrintDate(cur.request->start_date);
log << ' ' log << ' '
<< cur.request->ip_str << ' ' << cur.request->ip_str << ' '

View File

@ -45,11 +45,6 @@
#include <errno.h> #include <errno.h>
#include <fcgiapp.h> #include <fcgiapp.h>
#include "config.h"
#include "system.h"
#include "mounts.h"
#include "request.h"
#include "synchro.h"
#include "sessionmanager.h" #include "sessionmanager.h"
#include "db/db.h" #include "db/db.h"
#include "functions/functions.h" #include "functions/functions.h"
@ -61,6 +56,10 @@
#include "acceptencodingparser.h" #include "acceptencodingparser.h"
#include "space/jsontospaceparser.h" #include "space/jsontospaceparser.h"
#include "winixrequest.h"
#include "logger/logger.h"
#include "filelog.h"
namespace Winix namespace Winix
{ {
@ -76,6 +75,8 @@ public:
bool InitFCGI(); bool InitFCGI();
bool DropPrivileges(); bool DropPrivileges();
void InitFileLog();
void InitPlugins();
bool Init(); bool Init();
void Start(); void Start();
void Close(); void Close();
@ -101,7 +102,7 @@ public:
// users sessions // users sessions
SessionManager session_manager; SessionManager session_manager;
// database // database (DEPRACATED)
Db db; Db db;
DbConn db_conn; DbConn db_conn;
@ -129,6 +130,11 @@ public:
Templates templates; Templates templates;
FileLog file_log;
private: private:
enum Header enum Header
@ -162,6 +168,27 @@ private:
std::wstring http_header; std::wstring http_header;
std::string http_header_8bit; 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 InitFCGI(char * sock, char * sock_user, char * sock_group);
bool InitFCGIChmodChownSocket(char * sock, char * sock_user, char * sock_group); bool InitFCGIChmodChownSocket(char * sock, char * sock_user, char * sock_group);

View File

@ -37,6 +37,8 @@
#include <pthread.h> #include <pthread.h>
#include "synchro.h" #include "synchro.h"
#include "winixmodel.h"
namespace Winix namespace Winix
@ -45,7 +47,7 @@ namespace Winix
class BaseThread class BaseThread : public WinixModel
{ {
public: public:

View File

@ -38,6 +38,7 @@
#include <cstring> #include <cstring>
#include <zlib.h> #include <zlib.h>
#include "requesttypes.h" #include "requesttypes.h"
#include "winixbase.h"
namespace Winix namespace Winix
@ -45,7 +46,7 @@ namespace Winix
class Compress class Compress : public WinixBase
{ {
public: public:

View File

@ -34,7 +34,6 @@
#include "config.h" #include "config.h"
#include "log.h" #include "log.h"
#include "plugin.h"
#include "misc.h" #include "misc.h"
#include "crypt.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 << ? // the config is not read yet so we put some constants here
//!! przeciez jeszcze nie zostal przetworzony plik konfiguracyjny log.Init(3, false, 1);
}
void Config::ShowError() void Config::ShowError()
@ -130,7 +133,6 @@ void Config::AssignValues(bool stdout_is_closed)
additional_groups = Bool(L"additional_groups", true); additional_groups = Bool(L"additional_groups", true);
log_file = Text(L"log_file"); log_file = Text(L"log_file");
log_notify_file = Text(L"log_notify_file");
log_delimiter = Text(L"log_delimiter", L"---------------------------------------------------------------------------------"); log_delimiter = Text(L"log_delimiter", L"---------------------------------------------------------------------------------");
fcgi_socket = Text(L"fcgi_socket"); fcgi_socket = Text(L"fcgi_socket");
fcgi_socket_chmod = Int(L"fcgi_socket_chmod", 0770); fcgi_socket_chmod = Int(L"fcgi_socket_chmod", 0770);

View File

@ -38,6 +38,9 @@
#include <string> #include <string>
#include "space/spaceparser.h" #include "space/spaceparser.h"
#include "htmlfilter.h" #include "htmlfilter.h"
#include "log.h"
#include "filelog.h"
namespace Winix namespace Winix
@ -80,8 +83,8 @@ public:
// default: true // default: true
bool additional_groups; bool additional_groups;
// log file name, log file name for notifications (sending emails, etc) // log file name
std::wstring log_file, log_notify_file; std::wstring log_file;
// the log level (how much info should be inserted to logs) // the log level (how much info should be inserted to logs)
// 1 - minimum // 1 - minimum
@ -818,11 +821,13 @@ public:
// raw access to the config // raw access to the config
PT::Space space; PT::Space space;
void SetFileLog(FileLog * file_log);
private: private:
PT::SpaceParser parser; PT::SpaceParser parser;
bool errors_to_stdout; bool errors_to_stdout;
Log log;
void ShowError(); void ShowError();
void AssignValues(bool stdout_is_closed); void AssignValues(bool stdout_is_closed);

View File

@ -44,12 +44,18 @@ namespace Winix
void Crypt::SetConfig(Config * pconfig) //void Crypt::SetConfig(Config * pconfig)
{ //{
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) 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; return false;
run.Clear(); run.Clear();
run.set_dependency(this);
PT::WideToUTF8(config->opensll_path, command); PT::WideToUTF8(config->opensll_path, command);
run.Cmd(command); run.Cmd(command);
run.Par("dgst"); run.Par("dgst");

View File

@ -39,6 +39,8 @@
#include "run.h" #include "run.h"
#include "config.h" #include "config.h"
#include "user.h" #include "user.h"
#include "winixbase.h"
namespace Winix namespace Winix
@ -63,12 +65,15 @@ namespace Winix
/* /*
calculating hashes, encrypting and decrypting with RSA calculating hashes, encrypting and decrypting with RSA
*/ */
class Crypt class Crypt : public WinixBase
{ {
public: public:
void SetConfig(Config * pconfig); void set_dependency(WinixBase * winix_base);
//void SetConfig(Config * pconfig);
/* /*
@ -240,7 +245,7 @@ public:
private: private:
Config * config; //Config * config;
Run run; Run run;
std::string command, bufina, keypatha; std::string command, bufina, keypatha;
//std::wstring pass_salted;//, pass_hashed; //std::wstring pass_salted;//, pass_hashed;

View File

@ -38,6 +38,7 @@
#include <list> #include <list>
#include <map> #include <map>
#include "item.h" #include "item.h"
#include "winixbase.h"
namespace Winix namespace Winix
@ -45,7 +46,7 @@ namespace Winix
class DirContainer class DirContainer : public WinixBase
{ {
public: public:

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2008-2014, Tomasz Sowa * Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -34,7 +34,7 @@
#include "dirs.h" #include "dirs.h"
#include "error.h" #include "error.h"
#include "log.h" #include "notify/notify.h"
namespace Winix namespace Winix

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2008-2014, Tomasz Sowa * Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -44,19 +44,21 @@
#include "dircontainer.h" #include "dircontainer.h"
#include "db/db.h" #include "db/db.h"
#include "request.h" #include "request.h"
#include "notify/notify.h" #include "winixmodel.h"
namespace Winix namespace Winix
{ {
class Notify;
// !! IMPROVE ME // !! IMPROVE ME
// we do not support '..' in a path (for simplicity and security reasons) // we do not support '..' in a path (for simplicity and security reasons)
// (we will support '..' in the future) // (we will support '..' in the future)
class Dirs class Dirs : public WinixModel
{ {
public: public:

168
winixd/core/filelog.cpp Normal file
View 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
View 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

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2008-2014, Tomasz Sowa * Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * 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() void Groups::Clear()
{ {
table.Clear(); table.Clear();

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2008-2014, Tomasz Sowa * Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -40,6 +40,8 @@
#include "group.h" #include "group.h"
#include "ugcontainer.h" #include "ugcontainer.h"
#include "db/db.h" #include "db/db.h"
#include "winixmodel.h"
namespace Winix namespace Winix
@ -47,7 +49,7 @@ namespace Winix
class Groups class Groups : public WinixModel
{ {
typedef UGContainer<Group> Table; typedef UGContainer<Group> Table;
@ -55,6 +57,8 @@ Table table;
public: public:
void set_dependency(WinixModel * winix_model);
typedef Table::Iterator Iterator; typedef Table::Iterator Iterator;
typedef Table::SizeType SizeType; typedef Table::SizeType SizeType;

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2008-2014, Tomasz Sowa * Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -36,6 +36,7 @@
#define headerfile_winix_core_httpsimpleparser #define headerfile_winix_core_httpsimpleparser
#include <string> #include <string>
#include "winixmodel.h"
namespace Winix namespace Winix
@ -43,7 +44,7 @@ namespace Winix
class HttpSimpleParser class HttpSimpleParser : public WinixModel
{ {
protected: protected:

View File

@ -35,9 +35,7 @@
#include <ctime> #include <ctime>
#include "image.h" #include "image.h"
#include "utf8/utf8.h" #include "utf8/utf8.h"
#include "log.h"
#include "system.h" #include "system.h"
#include "plugin.h"
#include "lock.h" #include "lock.h"
@ -492,34 +490,34 @@ void Image::ImageSavedCorrectly()
} }
log << log3 << "Image: generated a thumbnail: " << dst_path << logend; 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 else
if( item_work.type == WINIX_IMAGE_TYPE_RESIZE ) if( item_work.type == WINIX_IMAGE_TYPE_RESIZE )
{ {
log << log3 << "Image: image resized: " << dst_path << logend; 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 else
if( item_work.type == WINIX_IMAGE_TYPE_CROP ) if( item_work.type == WINIX_IMAGE_TYPE_CROP )
{ {
log << log3 << "Image: image cropped: " << dst_path << logend; log << log3 << "Image: image cropped: " << dst_path << logend;
// !! IMPROVE ME add a correct message // !! 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 else
if( item_work.type == WINIX_IMAGE_TYPE_CROP_THUMB ) if( item_work.type == WINIX_IMAGE_TYPE_CROP_THUMB )
{ {
log << log3 << "Image: image thumbnail cropped: " << dst_path << logend; log << log3 << "Image: image thumbnail cropped: " << dst_path << logend;
// !! IMPROVE ME add a correct message // !! 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 else
if( item_work.type == WINIX_IMAGE_TYPE_CREATE_CROP_NEW_THUMB ) 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; log << log3 << "Image: a new thumbnail from an original image was cropped: " << dst_path << logend;
// !! IMPROVE ME add a correct message // !! IMPROVE ME add a correct message
//plugin.Call((Session*)0, WINIX_IMAGE_RESIZED, &file_work); //plugin->Call((Session*)0, WINIX_IMAGE_RESIZED, &file_work);
} }
} }

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2012-2014, Tomasz Sowa * Copyright (c) 2012-2018, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -37,6 +37,8 @@
#include <vector> #include <vector>
#include "ipban.h" #include "ipban.h"
#include "winixmodel.h"
namespace Winix namespace Winix
@ -44,7 +46,7 @@ namespace Winix
class IPBanContainer class IPBanContainer : public WinixModel
{ {
public: public:

View File

@ -169,7 +169,7 @@ void Job::DoJob(PT::Space & job)
{ {
try try
{ {
PluginRes res = plugin.Call((Session*)0, WINIX_JOB, &job); PluginRes res = plugin->Call((Session*)0, WINIX_JOB, &job);
if( res.res_true == 0 ) if( res.res_true == 0 )
DoWinixJob(job); DoWinixJob(job);

View File

@ -40,6 +40,7 @@
#include <cstring> #include <cstring>
#include <ctime> #include <ctime>
#include "date/date.h" #include "date/date.h"
#include "winixbase.h"
@ -81,7 +82,7 @@ struct LastItem
class LastContainer class LastContainer : public WinixBase
{ {
public: public:

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2008-2014, Tomasz Sowa * Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -34,7 +34,7 @@
#include "loadavg.h" #include "loadavg.h"
#include "log.h"
namespace Winix namespace Winix

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2008-2014, Tomasz Sowa * Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -36,6 +36,7 @@
#define headerfile_winix_core_loadavg #define headerfile_winix_core_loadavg
#include <ctime> #include <ctime>
#include "winixbase.h"
namespace Winix namespace Winix
@ -51,7 +52,7 @@ namespace Winix
class LoadAvg class LoadAvg : WinixBase
{ {
public: public:
LoadAvg(); LoadAvg();

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2008-2014, Tomasz Sowa * Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -36,7 +36,7 @@
#include <ctime> #include <ctime>
#include <string.h> #include <string.h>
#include "utf8/utf8.h" #include "utf8/utf8.h"
#include "timezones.h"
namespace Winix namespace Winix
@ -52,8 +52,9 @@ Log::Log()
max_requests = 1; max_requests = 1;
lines = 0; lines = 0;
max_lines = 5000; max_lines = 5000;
log_file_open = false; file_log = nullptr;
time_zones = 0; save_each_line = false;
buffer = nullptr;
} }
@ -63,13 +64,30 @@ Log::~Log()
} }
void Log::SetLogBuffer(TextStream<std::wstring> * buffer)
void Log::SetTimeZones(TimeZones * ptime_zones)
{ {
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() 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_; this->log_level = log_level;
log_stdout = log_std; this->save_each_line = save_each_line;
max_requests = log_max_requests; this->max_requests = 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
} }
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 ); (*this) << file_log->get_local_date(date);
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
}
} }
else 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) Log & Log::operator<<(const void * s)
{ {
if( current_level > log_level ) if( current_level <= log_level && buffer )
return *this; {
(*buffer) << s;
}
buffer << s;
return *this; return *this;
} }
@ -138,13 +133,10 @@ Log & Log::operator<<(const void * s)
Log & Log::operator<<(const char * s) Log & Log::operator<<(const char * s)
{ {
if( current_level > log_level ) if( current_level <= log_level && buffer && s )
return *this; {
(*buffer) << s;
if( !s ) }
return *this;
buffer << s;
return *this; return *this;
} }
@ -153,10 +145,11 @@ return *this;
Log & Log::operator<<(const std::string & s) Log & Log::operator<<(const std::string & s)
{ {
if( current_level > log_level ) if( current_level <= log_level && buffer )
return *this; {
(*buffer) << s;
}
buffer << s;
return *this; return *this;
} }
@ -164,10 +157,11 @@ Log & Log::operator<<(const std::string & s)
Log & Log::operator<<(const std::string * s) Log & Log::operator<<(const std::string * s)
{ {
if( current_level > log_level ) if( current_level <= log_level && buffer )
return *this; {
(*buffer) << *s;
}
buffer << *s;
return *this; return *this;
} }
@ -178,10 +172,9 @@ Log & Log::operator<<(const std::string * s)
Log & Log::operator<<(const wchar_t * 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; return *this;
@ -191,9 +184,9 @@ return *this;
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; return *this;
@ -203,9 +196,9 @@ Log & Log::operator<<(const std::wstring & s)
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; return *this;
@ -217,9 +210,9 @@ Log & Log::operator<<(const std::wstring * s)
Log & Log::operator<<(int s) Log & Log::operator<<(int s)
{ {
if( current_level <= log_level ) if( current_level <= log_level && buffer )
{ {
buffer << s; (*buffer) << s;
} }
return *this; return *this;
@ -229,9 +222,9 @@ Log & Log::operator<<(int s)
Log & Log::operator<<(long s) Log & Log::operator<<(long s)
{ {
if( current_level <= log_level ) if( current_level <= log_level && buffer )
{ {
buffer << s; (*buffer) << s;
} }
return *this; return *this;
@ -242,9 +235,9 @@ Log & Log::operator<<(long s)
Log & Log::operator<<(char s) Log & Log::operator<<(char s)
{ {
if( current_level <= log_level ) if( current_level <= log_level && buffer )
{ {
buffer << s; (*buffer) << s;
} }
return *this; return *this;
@ -253,9 +246,9 @@ Log & Log::operator<<(char s)
Log & Log::operator<<(wchar_t s) Log & Log::operator<<(wchar_t s)
{ {
if( current_level <= log_level ) if( current_level <= log_level && buffer )
{ {
buffer << s; (*buffer) << s;
} }
return *this; return *this;
@ -264,9 +257,9 @@ Log & Log::operator<<(wchar_t s)
Log & Log::operator<<(size_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; return *this;
@ -276,9 +269,9 @@ Log & Log::operator<<(size_t s)
Log & Log::operator<<(double s) Log & Log::operator<<(double s)
{ {
if( current_level <= log_level ) if( current_level <= log_level && buffer )
{ {
buffer << s; (*buffer) << s;
} }
return *this; return *this;
@ -288,9 +281,9 @@ Log & Log::operator<<(double s)
Log & Log::operator<<(const PT::Space & 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; return *this;
@ -300,9 +293,9 @@ return *this;
Log & Log::operator<<(const PT::Date & date) Log & Log::operator<<(const PT::Date & date)
{ {
if( current_level <= log_level ) if( current_level <= log_level && buffer )
{ {
buffer << date; (*buffer) << date;
} }
return *this; return *this;
@ -315,9 +308,9 @@ Log & Log::operator<<(LogManipulators m)
switch(m) switch(m)
{ {
case logend: case logend:
if( current_level <= log_level ) if( current_level <= log_level && buffer )
{ {
buffer << '\n'; (*buffer) << '\n';
lines += 1; lines += 1;
if( save_each_line ) if( save_each_line )
@ -383,6 +376,9 @@ void Log::LogBinary(const char * blob, size_t blob_len)
size_t i=0; size_t i=0;
char buf[3]; char buf[3];
if( !buffer )
return;
while( i < blob_len ) while( i < blob_len )
{ {
@ -393,32 +389,32 @@ char buf[3];
if( i < blob_len ) if( i < blob_len )
{ {
ToHEX(buf, blob[i]); ToHEX(buf, blob[i]);
buffer << buf << ' '; (*buffer) << buf << ' ';
++i; ++i;
} }
else else
{ {
buffer << " "; (*buffer) << " ";
} }
if( a == 7 ) if( a == 7 )
{ {
if( i < blob_len ) if( i < blob_len )
buffer << "- "; (*buffer) << "- ";
else else
buffer << " "; (*buffer) << " ";
} }
} }
i = oldi; i = oldi;
buffer << ' '; (*buffer) << ' ';
for(size_t a=0 ; a<16 && i<blob_len ; ++a, ++i) for(size_t a=0 ; a<16 && i<blob_len ; ++a, ++i)
{ {
if( blob[i] > 31 && blob[i] < 127 ) if( blob[i] > 31 && blob[i] < 127 )
buffer << blob[i]; (*buffer) << blob[i];
else else
buffer << '.'; (*buffer) << '.';
} }
(*this) << logend; (*this) << logend;
@ -447,7 +443,11 @@ void Log::SaveLogAndClear()
{ {
SaveLog(); SaveLog();
buffer.Clear(); if( buffer )
{
buffer->Clear();
}
request = 0; request = 0;
lines = 0; lines = 0;
} }
@ -455,28 +455,10 @@ void Log::SaveLogAndClear()
void Log::SaveLog() void Log::SaveLog()
{ {
if( buffer.Str().empty() ) if( file_log && buffer )
return;
if( log_stdout )
PT::WideToUTF8(buffer.Str(), std::cout);
if( log_file.empty() )
return;
if( !log_file_open || !file )
{ {
file.close(); file_log->save_log(buffer);
file.clear();
OpenFile();
if( !file )
return;
} }
PT::WideToUTF8(buffer.Str(), file);
file.flush();
} }

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2008-2014, Tomasz Sowa * Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -43,6 +43,7 @@
#include "textstream.h" #include "textstream.h"
#include "logmanipulators.h" #include "logmanipulators.h"
#include "textstream/textstream.h" #include "textstream/textstream.h"
#include "filelog.h"
namespace Winix namespace Winix
@ -50,10 +51,6 @@ namespace Winix
class TimeZones;
class Log class Log
{ {
public: public:
@ -61,8 +58,14 @@ public:
Log(); Log();
~Log(); ~Log();
void SetTimeZones(TimeZones * ptime_zones); void SetLogBuffer(TextStream<std::wstring> * buffer);
void Init(int log_level_, bool save_each_line_, const std::wstring & log_file_, bool log_std, int log_max_requests);
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 void * s);
Log & operator<<(const char * s); Log & operator<<(const char * s);
@ -81,7 +84,7 @@ public:
Log & operator<<(LogManipulators m); Log & operator<<(LogManipulators m);
Log & operator<<(const PT::Date & date); 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> 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); Log & operator<<(const PT::TextStreamBase<char_type, stack_size, heap_block_size> & buf);
@ -101,13 +104,11 @@ public:
int LogLevel(); int LogLevel();
private: private:
// time zones for printing the time in the log file
TimeZones * time_zones;
// buffer for the log // 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 // log lovel from the config file
int log_level; int log_level;
@ -122,19 +123,9 @@ private:
// how many request to save at once // how many request to save at once
int max_requests; 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 // how many lines there are in the buffer
int lines; int lines;
// is the config file already open
bool log_file_open;
// how many lines can be in the config buffer // how many lines can be in the config buffer
// default: 5000 // default: 5000
int max_lines; int max_lines;
@ -142,7 +133,8 @@ private:
// whether to save each line (for debug) // whether to save each line (for debug)
bool save_each_line; bool save_each_line;
void OpenFile(); FileLog * file_log;
char GetHEXdigit(unsigned char c); char GetHEXdigit(unsigned char c);
void ToHEX(char * buf, 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; 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) for(size_t i=0 ; i<min_size ; ++i)
{ {
if( value[i] < 32 ) if( value[i] < 32 )
buffer << '.'; (*buffer) << '.';
else 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> 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) Log & Log::operator<<(const PT::TextStreamBase<char_type, stack_size, heap_block_size> & buf)
{ {
if( current_level <= log_level ) if( current_level <= log_level && buffer )
buffer << buf; (*buffer) << buf;
return *this; return *this;
} }
extern Log log;
extern Log nlog;
} // namespace Winix } // namespace Winix
// for convenience, we have to use only #include "log.h" in the winix
#include "slog.h"
#endif #endif

View File

@ -38,7 +38,6 @@
#include <fstream> #include <fstream>
#include <cstdlib> #include <cstdlib>
#include "misc.h" #include "misc.h"
#include "log.h"
#include "templates/templates.h" #include "templates/templates.h"
#include "convert/convert.h" #include "convert/convert.h"
@ -882,7 +881,7 @@ char dir_name[WINIX_OS_PATH_SIZE];
if( mkdir(dir_name, 0777) < 0 ) 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; return false;
} }
@ -958,7 +957,7 @@ char buffer[512];
if( getgrnam_r(group_name, &gr, buffer, sizeof(buffer)/sizeof(char), &result) != 0 ) 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; return -1;
} }
@ -967,7 +966,7 @@ char buffer[512];
*/ */
if( result == 0 ) 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; return -1;
} }
@ -994,7 +993,7 @@ char file_name[WINIX_OS_PATH_SIZE];
if( chmod(file_name, priv) < 0 ) 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; return false;
} }
@ -1002,8 +1001,8 @@ char file_name[WINIX_OS_PATH_SIZE];
{ {
if( chown(file_name, geteuid(), group) < 0 ) if( chown(file_name, geteuid(), group) < 0 )
{ {
log << log1 << "Can't set proper fs group on: " << name //log << log1 << "Can't set proper fs group on: " << name
<< ", group id was: " << group << logend; // << ", group id was: " << group << logend;
return false; return false;
} }
} }
@ -1385,7 +1384,9 @@ void RemovePostFileTmp(PostFileTab & post_file_tab)
const std::wstring & tmp_filename = i->second.tmp_filename; const std::wstring & tmp_filename = i->second.tmp_filename;
if( !tmp_filename.empty() && RemoveFile(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 * 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: " //log << log1 << "Misc: I cannot convert from a wide string to an UTF-8 string, original string was: "
<< wide_string << logend; // << wide_string << logend;
} }
return res; return res;

View File

@ -297,7 +297,9 @@ bool MountParser::ReadMountType()
else else
{ {
log << log1 << "MP: unknown mount type: " << temp << logend; 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; return mount.type != -1;
@ -319,7 +321,9 @@ bool MountParser::ReadMountPoint()
else else
{ {
log << log1 << "MP: there is no such a mount point (directory): " << last_dir << logend; 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; return pdir != 0;
@ -339,7 +343,9 @@ bool MountParser::ReadFs()
else else
{ {
log << log1 << "MP: unknown filesystem: " << temp << logend; 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; return mount.fs != -1;
@ -383,7 +389,9 @@ void MountParser::ReadMountParams()
else else
{ {
log << log1 << "MP: unknown mount param: " << temp << logend; 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 ) 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; 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 else
{ {
@ -490,7 +500,9 @@ void MountParser::ReadRow()
else else
{ {
log << log1 << "MP: this mount point exists (skipped)" << logend; 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;
} }
} }

View File

@ -44,6 +44,7 @@
#include "mount.h" #include "mount.h"
#include "item.h" #include "item.h"
#include "dirs.h" #include "dirs.h"
#include "winixmodel.h"
@ -52,7 +53,7 @@ namespace Winix
class MountParser class MountParser : public WinixModel
{ {
public: public:

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2009-2014, Tomasz Sowa * Copyright (c) 2009-2018, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -36,7 +36,7 @@
#include "request.h" #include "request.h"
#include "log.h" #include "log.h"
#include "db/db.h" #include "db/db.h"
#include "plugin.h" #include "cur.h"
@ -99,7 +99,7 @@ void Mounts::CreateMounts()
CreateMountFs(); CreateMountFs();
CreateMountPar(); 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.param.resize(mount_par_tab.size());
empty_mount.ClearParams(); empty_mount.ClearParams();
@ -210,6 +210,7 @@ const std::wstring & Mounts::GetMountPar(int id)
// reading from 'mounts' // reading from 'mounts'
void Mounts::ReadMounts(const std::wstring & mounts) void Mounts::ReadMounts(const std::wstring & mounts)
{ {
mount_parser.set_dependency(this);
mount_parser.SkipStaticDirs(skip_static); mount_parser.SkipStaticDirs(skip_static);
mount_parser.SetStaticMountId(mount_type_static); mount_parser.SetStaticMountId(mount_type_static);
mount_parser.SetDirs(dirs); mount_parser.SetDirs(dirs);
@ -217,10 +218,11 @@ void Mounts::ReadMounts(const std::wstring & mounts)
mount_parser.SetMountFsTab(mount_fs_tab); mount_parser.SetMountFsTab(mount_fs_tab);
mount_parser.SetMountParTab(mount_par_tab); mount_parser.SetMountParTab(mount_par_tab);
mount_parser.Parse(mounts, mount_tab); mount_parser.Parse(mounts, mount_tab);
CalcCurMount(); CalcCurMount();
plugin.Call((Session*)0, WINIX_FSTAB_CHANGED); plugin->Call((Session*)0, WINIX_FSTAB_CHANGED);
} }

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2009-2014, Tomasz Sowa * Copyright (c) 2009-2018, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -46,6 +46,7 @@
#include "db/db.h" #include "db/db.h"
#include "request.h" #include "request.h"
#include "mountparser.h" #include "mountparser.h"
#include "winixmodel.h"
namespace Winix namespace Winix
@ -54,7 +55,7 @@ namespace Winix
class Mounts class Mounts : public WinixModel
{ {
public: public:

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2008-2014, Tomasz Sowa * Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -35,8 +35,12 @@
#include <dlfcn.h> #include <dlfcn.h>
#include <string.h> #include <string.h>
#include "plugin.h" #include "plugin.h"
#include "pluginmsg.h"
#include "misc.h" #include "misc.h"
#include "system.h"
#include "sessionmanager.h"
#include "functions/functions.h"
#include "templates/templates.h"
#include "winixsystem.h"
namespace Winix namespace Winix
@ -61,14 +65,13 @@ Plugin::Plugin()
{ {
current_plugin = -1; current_plugin = -1;
db = 0; db = nullptr;
config = 0; cur = nullptr;
cur = 0; system = nullptr;
system = 0; functions = nullptr;
functions = 0; templates = nullptr;
templates = 0; session_manager = nullptr;
synchro = 0; winix_system = nullptr;
session_manager = 0;
} }
@ -83,10 +86,10 @@ void Plugin::SetDb(Db * pdb)
db = pdb; db = pdb;
} }
void Plugin::SetConfig(Config * pconfig) //void Plugin::SetConfig(Config * pconfig)
{ //{
config = pconfig; // config = pconfig;
} //}
void Plugin::SetCur(Cur * pcur) void Plugin::SetCur(Cur * pcur)
@ -113,10 +116,10 @@ void Plugin::SetTemplates(Templates * ptemplates)
} }
void Plugin::SetSynchro(Synchro * psynchro) //void Plugin::SetSynchro(Synchro * psynchro)
{ //{
synchro = psynchro; // synchro = psynchro;
} //}
void Plugin::SetSessionManager(SessionManager * psession_manager) 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() 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 // 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 ) if( !res )
{ {
@ -162,6 +171,9 @@ bool Plugin::SetPointers(PluginInfo & info)
info.templates = templates; info.templates = templates;
info.synchro = synchro; info.synchro = synchro;
info.session_manager = session_manager; info.session_manager = session_manager;
info.winix_system = winix_system;
info.plugin = this;
info.log.SetDependency(&log);
return res; return res;
} }
@ -233,7 +245,7 @@ void * plugin_handle;
int old_current_plugin; int old_current_plugin;
PluginInfo info; PluginInfo info;
if( !SetPointers(info) ) if( !SetDependency(info) )
return; return;
if( !(plugin_handle = LoadInitFun(filename, fun_init)) ) 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) void Plugin::Call(Session * ses, int message, Slots::iterator & slot, PluginInfo & info)
{ {
if( !SetPointers(info) ) if( !SetDependency(info) )
return; return;
current_plugin = slot->second.index; current_plugin = slot->second.index;

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2008-2014, Tomasz Sowa * Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -39,20 +39,23 @@
#include <string> #include <string>
#include <map> #include <map>
#include "pluginmsg.h" #include "pluginmsg.h"
#include "log.h"
#include "plugindata.h" #include "plugindata.h"
#include "config.h" #include "winixbase.h"
#include "request.h"
#include "system.h"
#include "sessionmanager.h"
#include "synchro.h"
#include "functions/functions.h"
#include "templates/templates.h"
namespace Winix 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 struct PluginInfo
@ -87,6 +92,7 @@ struct PluginInfo
// unique plugin identifier // unique plugin identifier
int plugin_id; int plugin_id;
// objects from winix which are accessible from a plugin // objects from winix which are accessible from a plugin
Db * db; Db * db;
Config * config; Config * config;
@ -97,6 +103,13 @@ struct PluginInfo
Synchro * synchro; Synchro * synchro;
SessionManager * session_manager; SessionManager * session_manager;
// temporarily?
Log log;
WinixSystem * winix_system;
Plugin * plugin;
// a session // a session
// some messages are sent in a session's context e.g. logging a user // 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 // 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: public:
@ -193,14 +206,16 @@ public:
~Plugin(); ~Plugin();
void SetDb(Db * pdb); void SetDb(Db * pdb);
void SetConfig(Config * pconfig); //void SetConfig(Config * pconfig);
void SetCur(Cur * pcur); void SetCur(Cur * pcur);
void SetSystem(System * psystem); void SetSystem(System * psystem);
void SetFunctions(Functions * pfunctions); void SetFunctions(Functions * pfunctions);
void SetTemplates(Templates * ptemplates); void SetTemplates(Templates * ptemplates);
void SetSynchro(Synchro * psynchro); //void SetSynchro(Synchro * psynchro);
void SetSessionManager(SessionManager * psession_manager); void SetSessionManager(SessionManager * psession_manager);
void SetWinixSystem(WinixSystem * winix_system);
void LoadPlugin(const wchar_t * filename); void LoadPlugin(const wchar_t * filename);
void LoadPlugin(const std::wstring & filename); void LoadPlugin(const std::wstring & filename);
@ -245,14 +260,16 @@ public:
private: private:
Db * db; Db * db;
Config * config; //Config * config;
Cur * cur; Cur * cur;
System * system; System * system;
Functions * functions; Functions * functions;
Templates * templates; Templates * templates;
Synchro * synchro; //Synchro * synchro;
SessionManager * session_manager; SessionManager * session_manager;
WinixSystem * winix_system;
std::wstring temp_path; // used when loading plugins std::wstring temp_path; // used when loading plugins
Plugins plugins; Plugins plugins;
@ -263,17 +280,13 @@ private:
void * LoadInitFun(const wchar_t * filename, Fun1 & fun_init); void * LoadInitFun(const wchar_t * filename, Fun1 & fun_init);
void Call(Session * ses, int message, Slots::iterator & slot, PluginInfo & info); void Call(Session * ses, int message, Slots::iterator & slot, PluginInfo & info);
bool SetPointers(PluginInfo & info); bool SetDependency(PluginInfo & info);
void Lock(); void Lock();
void Unlock(); void Unlock();
}; };
extern Plugin plugin;
} // namespace Winix } // namespace Winix

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2008-2014, Tomasz Sowa * Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -35,7 +35,7 @@
#include "plugindata.h" #include "plugindata.h"
#include "plugin.h" #include "plugin.h"
#include "log.h" #include "log.h"
#include "session.h"
namespace Winix namespace Winix
@ -46,7 +46,6 @@ namespace Winix
PluginData::PluginData() PluginData::PluginData()
{ {
session = 0;
} }
@ -63,7 +62,6 @@ PluginData & PluginData::operator=(const PluginData & p)
// we don't copy all pointers - only resize the table // we don't copy all pointers - only resize the table
// pointers will be set to zero // pointers will be set to zero
Resize(p.Size()); Resize(p.Size());
session = 0;
return *this; return *this;
} }
@ -72,15 +70,10 @@ return *this;
PluginData::~PluginData() PluginData::~PluginData()
{ {
DeleteAll(); //DeleteAll();
} }
void PluginData::SetSession(Session * ses)
{
session = ses;
}
void PluginData::Assign(size_t index, PluginDataBase * data) 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) //void PluginData::Assign(PluginDataBase * data)
{ //{
if( plugin.current_plugin == -1 ) // if( plugin.current_plugin == -1 )
{ // {
log << log1 << "PD: Assign(PluginDataBase*) should be called only from plugins" << logend; // log << log1 << "PD: Assign(PluginDataBase*) should be called only from plugins" << logend;
return; // return;
} // }
//
Assign(plugin.current_plugin, data); // Assign(plugin.current_plugin, data);
} //}
@ -114,31 +107,23 @@ return table[index];
} }
PluginDataBase * PluginData::Get() //PluginDataBase * PluginData::Get()
{ //{
if( plugin.current_plugin == -1 ) // if( plugin.current_plugin == -1 )
{ // {
log << log1 << "PD: Get() should be called only from plugins" << logend; // log << log1 << "PD: Get() should be called only from plugins" << logend;
return 0; // return 0;
} // }
//
return Get(plugin.current_plugin); //return Get(plugin.current_plugin);
} //}
bool PluginData::HasAllocatedData()
void PluginData::DeleteAll()
{ {
bool all_null = true; 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) for(size_t i=0 ; i<table.size() ; ++i)
{ {
if( table[i] != 0 ) if( table[i] != 0 )
@ -148,19 +133,40 @@ void PluginData::DeleteAll()
} }
} }
/* return !all_null;
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();
} }
//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 size_t PluginData::Size() const

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2008-2014, Tomasz Sowa * Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -38,14 +38,12 @@
#include <vector> #include <vector>
#include <cstddef> #include <cstddef>
namespace Winix namespace Winix
{ {
struct Session;
struct PluginDataBase struct PluginDataBase
{ {
virtual ~PluginDataBase() {} virtual ~PluginDataBase() {}
@ -73,15 +71,13 @@ public:
PluginData & operator=(const PluginData & p); PluginData & operator=(const PluginData & p);
~PluginData(); ~PluginData();
void SetSession(Session * ses);
void Assign(size_t index, PluginDataBase * data); void Assign(size_t index, PluginDataBase * data);
void Assign(PluginDataBase * data); //void Assign(PluginDataBase * data);
PluginDataBase * Get(size_t index); PluginDataBase * Get(size_t index);
PluginDataBase * Get(); //PluginDataBase * Get();
void DeleteAll(); bool HasAllocatedData();
size_t Size() const; size_t Size() const;
void Resize(size_t new_size); void Resize(size_t new_size);
@ -89,7 +85,6 @@ public:
private: private:
Session * session;
std::vector<PluginDataBase*> table; std::vector<PluginDataBase*> table;
}; };

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2008-2014, Tomasz Sowa * Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -42,6 +42,7 @@
#include "requesttypes.h" #include "requesttypes.h"
#include "config.h" #include "config.h"
#include "misc.h" #include "misc.h"
#include "winixbase.h"
namespace Winix namespace Winix
@ -54,7 +55,7 @@ namespace Winix
#define WINIX_POSTMULTI_OUTPUT_BUFFER 2097152 #define WINIX_POSTMULTI_OUTPUT_BUFFER 2097152
class PostMultiParser class PostMultiParser : public WinixBase
{ {
public: public:

View File

@ -41,8 +41,6 @@
#include "requesttypes.h" #include "requesttypes.h"
#include "misc.h" #include "misc.h"
#include "utf8/utf8.h" #include "utf8/utf8.h"
#include "log.h"
#include "plugin.h"
#include "convert/text.h" #include "convert/text.h"
@ -105,7 +103,7 @@ protected:
std::pair<PostTab::iterator, bool> res; std::pair<PostTab::iterator, bool> res;
if( has_winix_post_params_msg ) 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) ); res = post_tab->insert( std::make_pair(name, value) );
added = res.second; added = res.second;
@ -143,13 +141,13 @@ public:
var_index = 1; var_index = 1;
raw_post.clear(); raw_post.clear();
has_winix_post_params_msg = plugin.HasMessage(WINIX_POST_PARAMS); has_winix_post_params_msg = plugin->HasMessage(WINIX_POST_PARAMS);
has_winix_raw_post_msg = plugin.HasMessage(WINIX_RAW_POST_STRING); has_winix_raw_post_msg = plugin->HasMessage(WINIX_RAW_POST_STRING);
HttpSimpleParser::Parse(); HttpSimpleParser::Parse();
if( has_winix_raw_post_msg ) 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(); raw_post.clear();
} }

View File

@ -37,6 +37,8 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "winixbase.h"
namespace Winix namespace Winix
@ -47,7 +49,7 @@ namespace Winix
struct Cur; struct Cur;
class Rebus class Rebus : public WinixBase
{ {
public: public:

View File

@ -38,7 +38,6 @@
#include <sys/wait.h> #include <sys/wait.h>
#include <cstring> #include <cstring>
#include "run.h" #include "run.h"
#include "log.h"

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2011-2014, Tomasz Sowa * Copyright (c) 2011-2018, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -38,6 +38,7 @@
#include <string> #include <string>
#include <cstdio> #include <cstdio>
#include <unistd.h> #include <unistd.h>
#include "winixbase.h"
namespace Winix namespace Winix
@ -64,7 +65,7 @@ namespace Winix
7. winix waitpid() for the child 7. winix waitpid() for the child
8. Go() returns 8. Go() returns
*/ */
class Run class Run : public WinixBase
{ {
public: public:

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2008-2014, Tomasz Sowa * Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -44,7 +44,6 @@ namespace Winix
Session::Session() Session::Session()
{ {
Clear(); Clear();
plugin_data.SetSession(this);
} }
@ -63,7 +62,6 @@ Session & Session::operator=(const Session & ses)
Clear(); Clear();
id = ses.id; id = ses.id;
plugin_data.SetSession(this);
return *this; return *this;
} }

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2008-2014, Tomasz Sowa * Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * 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 // because plugins session data would not be erased
while( i != table.end() ) 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++); 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 // 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 // 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); table.erase(i->second);
index_id.erase(i); index_id.erase(i);
table_size -= 1; table_size -= 1;

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2008-2014, Tomasz Sowa * Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -42,6 +42,8 @@
#include "session.h" #include "session.h"
#include "cur.h" #include "cur.h"
#include "config.h" #include "config.h"
#include "winixmodel.h"
namespace Winix namespace Winix
@ -50,7 +52,7 @@ namespace Winix
class SessionContainer class SessionContainer : public WinixModel
{ {
public: public:

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2014, Tomasz Sowa * Copyright (c) 2014-2018, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -39,7 +39,6 @@
#include "space/spaceparser.h" #include "space/spaceparser.h"
#include "utf8/utf8.h" #include "utf8/utf8.h"
#include "date/date.h" #include "date/date.h"
#include "log.h"
#include "misc.h" #include "misc.h"

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2014, Tomasz Sowa * Copyright (c) 2014-2018, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -42,6 +42,8 @@
#include "base64.h" #include "base64.h"
#include "space/space.h" #include "space/space.h"
#include "aes.h" #include "aes.h"
#include "winixbase.h"
namespace Winix namespace Winix
@ -74,7 +76,7 @@ namespace Winix
* *
* *
*/ */
class SessionIdManager class SessionIdManager : public WinixBase
{ {
public: public:

View File

@ -39,7 +39,7 @@
#include "log.h" #include "log.h"
#include "session.h" #include "session.h"
#include "sessionparser.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() void SessionManager::InitBanList()
{ {
@ -554,7 +562,7 @@ void SessionManager::DeleteSessions()
{ {
if( i->puser && !i->remember_me ) 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); last_container->UserLogout(i->puser->id, i->id);
} }
} }
@ -586,7 +594,7 @@ SessionContainer::Iterator i = session_tab.FindById(old_id);
} }
if( changed ) 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 else
log << log1 << "SM: I cannot create a new session id (still uses old one)" << logend; 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; log << log4 << "SM: initializing temporary session" << logend;
cur->session = &temporary_session; cur->session = &temporary_session;
plugin.Call(WINIX_SESSION_CREATED); plugin->Call(WINIX_SESSION_CREATED);
cur->session = old_session; cur->session = old_session;
} }
@ -618,7 +626,15 @@ void SessionManager::UninitTmpSession()
log << log4 << "SM: uninitializing temporary session" << logend; log << log4 << "SM: uninitializing temporary session" << logend;
cur->session = &temporary_session; 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->plugin_data.Resize(0);
cur->session = old_session; cur->session = old_session;
@ -631,6 +647,8 @@ void SessionManager::LoadSessions()
SessionParser sp; SessionParser sp;
SessionContainer::Iterator i; SessionContainer::Iterator i;
sp.set_dependency(this);
// sessions will be overwritten (pointers are invalidated) // sessions will be overwritten (pointers are invalidated)
cur->session = &temporary_session; cur->session = &temporary_session;
@ -639,8 +657,8 @@ SessionContainer::Iterator i;
for(i=session_tab.Begin() ; i != session_tab.End() ; ++i) for(i=session_tab.Begin() ; i != session_tab.End() ; ++i)
{ {
i->plugin_data.Resize(plugin.Size()); i->plugin_data.Resize(plugin->Size());
plugin.Call(&(*i), WINIX_SESSION_CREATED); plugin->Call(&(*i), WINIX_SESSION_CREATED);
/* /*
!! IMPROVE ME !! IMPROVE ME
@ -648,7 +666,7 @@ SessionContainer::Iterator i;
*/ */
if( i->puser ) if( i->puser )
plugin.Call(&(*i), WINIX_USER_LOGGED); plugin->Call(&(*i), WINIX_USER_LOGGED);
} }
cur->session = &temporary_session; cur->session = &temporary_session;
@ -724,7 +742,7 @@ size_t SessionManager::MarkAllSessionsToRemove(long user_id)
{ {
if( i->puser && i->puser->id == 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); last_container->UserLogout(i->puser->id, i->id);
i->remove_me = true; i->remove_me = true;
i->puser = 0; i->puser = 0;
@ -883,16 +901,16 @@ void SessionManager::DeleteSession(Session * del_session)
{ {
if( del_session->puser ) 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); last_container->UserLogout(del_session->puser->id, del_session->id);
del_session->puser = 0; del_session->puser = 0;
} }
long id = del_session->id; 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); session_tab.EraseById(del_session->id);
plugin.Call((Session*)0, WINIX_SESSION_REMOVED, id); plugin->Call((Session*)0, WINIX_SESSION_REMOVED, id);
} }

View File

@ -66,6 +66,7 @@ public:
void SetSystem(System * psystem); void SetSystem(System * psystem);
void SetLastContainer(LastContainer * plast_container); void SetLastContainer(LastContainer * plast_container);
void set_dependency(WinixModel * winix_model);
// can return a null pointer // can return a null pointer
Session * FindSession(long id); Session * FindSession(long id);

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2008-2014, Tomasz Sowa * Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -47,7 +47,7 @@ namespace Winix
class SessionParser class SessionParser : public WinixBase
{ {
public: public:

View File

@ -164,8 +164,6 @@ return *this;
} }
extern SLog slog;
} // namespace Winix } // namespace Winix

View File

@ -37,7 +37,6 @@
#include "error.h" #include "error.h"
#include "templates/templates.h" #include "templates/templates.h"
#include "functions/functions.h" #include "functions/functions.h"
#include "plugin.h"
@ -53,10 +52,10 @@ void System::SetCur(Cur * pcur)
} }
void System::SetConfig(Config * pconfig) //void System::SetConfig(Config * pconfig)
{ //{
config = pconfig; // config = pconfig;
} //}
void System::SetDb(Db * pdb) void System::SetDb(Db * pdb)
@ -65,10 +64,10 @@ void System::SetDb(Db * pdb)
} }
void System::SetSynchro(Synchro * psynchro) //void System::SetSynchro(Synchro * psynchro)
{ //{
synchro = psynchro; // synchro = psynchro;
} //}
void System::SetFunctions(Functions * pfunctions) 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() void System::ReadTimeZones()
{ {
if( config->etc_dir.empty() ) if( config->etc_dir.empty() )
@ -107,31 +114,39 @@ void System::ReadTimeZones()
void System::Init() void System::Init()
{ {
thread_manager.SetSynchro(synchro); //thread_manager.SetSynchro(synchro);
thread_manager.set_dependency(this);
thread_manager.Init(); thread_manager.Init();
dirs.set_dependency(this);
dirs.SetDb(db); 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(&notify); dirs.SetNotify(&notify);
dirs.ReadDirs(); dirs.ReadDirs();
mounts.set_dependency(this);
mounts.SkipStaticDirs(config->dont_use_static_dirs); mounts.SkipStaticDirs(config->dont_use_static_dirs);
mounts.SetDirs(&dirs); mounts.SetDirs(&dirs);
mounts.SetDb(db); 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.CreateMounts();
mounts.ReadMounts(); mounts.ReadMounts();
users.set_dependency(this);
users.SetCur(cur); users.SetCur(cur);
users.SetSessionManager(session_manager); users.SetSessionManager(session_manager);
users.ReadUsers(db); users.ReadUsers(db);
groups.set_dependency(this);
groups.ReadGroups(db); // !! chwilowe przekazanie argumentu, db bedzie zmienione groups.ReadGroups(db); // !! chwilowe przekazanie argumentu, db bedzie zmienione
rebus.set_dependency(this);
rebus.SetCur(cur); rebus.SetCur(cur);
rebus.Init(); rebus.Init();
notify.set_dependency(this);
notify.SetCur(cur); notify.SetCur(cur);
notify.SetConfig(config); //notify.SetConfig(config);
notify.SetUsers(&users); notify.SetUsers(&users);
notify.SetDirs(&dirs); notify.SetDirs(&dirs);
notify.SetThreadManager(&thread_manager); notify.SetThreadManager(&thread_manager);
@ -142,7 +157,7 @@ void System::Init()
image.SetSystem(this); image.SetSystem(this);
thread_manager.Add(&image, L"image"); thread_manager.Add(&image, L"image");
crypt.SetConfig(config); crypt.set_dependency(this);
// SetSynchro will be called by ThreadManager itself // SetSynchro will be called by ThreadManager itself
// job.ReadFromFile(); // job.ReadFromFile();
@ -1020,7 +1035,7 @@ Error System::AddFile(Item & item, int notify_code, bool call_plugins)
notify.ItemChanged(notify_code, item); notify.ItemChanged(notify_code, item);
if( call_plugins ) if( call_plugins )
plugin.Call(WINIX_FILE_ADDED, &item); plugin->Call(WINIX_FILE_ADDED, &item);
} }
return status; 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); notify.ItemChanged(notify_code, item);
if( call_plugins ) if( call_plugins )
plugin.Call(WINIX_FILE_CHANGED, &item); plugin->Call(WINIX_FILE_CHANGED, &item);
} }

View File

@ -64,7 +64,7 @@ class SessionManager;
// file system // file system
class System class System : WinixModel
{ {
public: public:
@ -110,11 +110,14 @@ public:
void SetCur(Cur * pcur); void SetCur(Cur * pcur);
void SetConfig(Config * pconfig); //void SetConfig(Config * pconfig);
void SetDb(Db * pdb); void SetDb(Db * pdb);
void SetSynchro(Synchro * psynchro); //void SetSynchro(Synchro * psynchro);
void SetFunctions(Functions * pfunctions); void SetFunctions(Functions * pfunctions);
void SetSessionManager(SessionManager * sm); void SetSessionManager(SessionManager * sm);
void set_dependency(WinixModel * winix_model);
void Init(); void Init();
void AddParams(const ParamTab & param_tab, std::wstring & str, bool clear_str = true); void AddParams(const ParamTab & param_tab, std::wstring & str, bool clear_str = true);
@ -219,8 +222,8 @@ private:
Cur * cur; Cur * cur;
Db * db; Db * db;
Config * config; //Config * config;
Synchro * synchro; //Synchro * synchro;
Functions * functions; Functions * functions;
SessionManager * session_manager; SessionManager * session_manager;

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2011-2014, Tomasz Sowa * Copyright (c) 2011-2018, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -49,10 +49,10 @@ ThreadManager::ThreadManager()
} }
void ThreadManager::SetSynchro(Synchro * psynchro) //void ThreadManager::SetSynchro(Synchro * psynchro)
{ //{
synchro = psynchro; // synchro = psynchro;
} //}
void ThreadManager::Init() void ThreadManager::Init()
@ -70,20 +70,37 @@ sigset_t set;
void ThreadManager::Add(BaseThread * pbase, const wchar_t * thread_name) void ThreadManager::Add(BaseThread * pbase, const wchar_t * thread_name)
{ {
ThreadItem item; ThreadItem item;
item.object = pbase; item.object = pbase;
item.name = thread_name; item.name = thread_name;
thread_tab.push_back(item); 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 ) if( were_started )
Start(thread_tab.size() - 1); {
Start(thread_tab.size() - 1, &thread_tab.back());
}
else else
{
log << log4 << "TM: added a thread to the queue, number: " << (thread_tab.size()-1) log << log4 << "TM: added a thread to the queue, number: " << (thread_tab.size()-1)
<< ", name: " << thread_name << logend; << ", name: " << thread_name << logend;
}
} }
@ -109,8 +126,13 @@ void ThreadManager::StartAll()
{ {
synchro->Lock(); synchro->Lock();
for(size_t i=0 ; i<thread_tab.size() ; ++i) int id = 0;
Start(i);
for(ThreadItem & item : thread_tab)
{
Start(id, &item);
id += 1;
}
synchro->Unlock(); 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() ) item->object->SetSynchro(synchro);
{
thread_tab[i].object->SetSynchro(synchro);
if( thread_tab[i].object->StartThread() ) if( item->object->StartThread() )
{ {
log << log4 << "TM: thread " << i << " (" << thread_tab[i].object->ThreadId() << ", name: " log << log4 << "TM: thread " << id << " (" << item->object->ThreadId() << ", name: "
<< thread_tab[i].name << ") started" << logend; << item->name << ") started" << logend;
} }
else else
{ {
log << log4 << "TM: cannot run a thread, thread number: " << i log << log4 << "TM: cannot run a thread " << id << ", name: " << item->name << logend;
<< ", name: " << thread_tab[i].name << logend;
}
} }
} }
@ -146,21 +164,29 @@ void ThreadManager::StopAll()
// WakeUpThread() should be used with Lock/Unlock // WakeUpThread() should be used with Lock/Unlock
synchro->Lock(); synchro->Lock();
for(size_t i=0 ; i<thread_tab.size() ; ++i) for(ThreadItem & item : thread_tab)
thread_tab[i].object->WakeUpThread(); {
item.object->WakeUpThread();
}
synchro->Unlock(); 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() log << log4 << "TM: waiting for thread " << id << " (" << item.object->ThreadId()
<< ", name: " << thread_tab[i].name << ")" << logend; << ", 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();
} }

View File

@ -36,7 +36,7 @@
#define headerfile_winix_core_threadmanager #define headerfile_winix_core_threadmanager
#include <string> #include <string>
#include <vector> #include <list>
#include "basethread.h" #include "basethread.h"
#include "synchro.h" #include "synchro.h"
@ -47,14 +47,14 @@ namespace Winix
class ThreadManager class ThreadManager : public WinixModel
{ {
public: public:
ThreadManager(); ThreadManager();
// synchro object // synchro object
void SetSynchro(Synchro * psynchro); //void SetSynchro(Synchro * psynchro);
// initializing // initializing
void Init(); void Init();
@ -76,18 +76,30 @@ public:
private: private:
struct ThreadItemData
{
morm::ModelConnector model_connector;
morm::JSONConnector json_connector;
morm::PostgreSQLConnector postgresql_connector;
TextStream<std::wstring> log_buffer;
};
struct ThreadItem struct ThreadItem
{ {
BaseThread * object; BaseThread * object;
std::wstring name; std::wstring name;
ThreadItemData * thread_item_data;
}; };
Synchro * synchro;
typedef std::vector<ThreadItem> ThreadTab; //Synchro * synchro;
typedef std::list<ThreadItem> ThreadTab;
ThreadTab thread_tab; ThreadTab thread_tab;
bool were_started; bool were_started;
void Start(size_t i); void Start(int id, ThreadItem * item);
}; };

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2012-2014, Tomasz Sowa * Copyright (c) 2012-2018, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -39,6 +39,7 @@
#include <vector> #include <vector>
#include "timezone.h" #include "timezone.h"
#include "space/spaceparser.h" #include "space/spaceparser.h"
#include "winixbase.h"
namespace Winix namespace Winix
@ -47,7 +48,7 @@ namespace Winix
class TimeZones class TimeZones : public WinixBase
{ {
public: public:

View File

@ -37,7 +37,7 @@
#include <list> #include <list>
#include <map> #include <map>
#include "log.h" #include "winixbase.h"
namespace Winix namespace Winix
@ -46,7 +46,7 @@ namespace Winix
template<class Type> template<class Type>
class UGContainer class UGContainer : public WinixBase
{ {
public: public:

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2008-2014, Tomasz Sowa * Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -35,7 +35,6 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#include "users.h" #include "users.h"
#include "sessionmanager.h" #include "sessionmanager.h"
#include "plugin.h"
namespace Winix namespace Winix
@ -46,10 +45,19 @@ namespace Winix
Users::Users() Users::Users()
{ {
how_many_logged = 0; // !! CHECK ME may it should be moved to Clear() method? how_many_logged = 0; // !! CHECK ME may it should be moved to Clear() method?
table.set_dependency(this);
Clear(); 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) void Users::SetCur(Cur * pcur)
{ {
cur = pcur; cur = pcur;
@ -155,11 +163,11 @@ bool Users::Remove(long user_id)
if( puser ) if( puser )
{ {
LogoutUser(user_id); LogoutUser(user_id);
plugin.Call(WINIX_PREPARE_TO_REMOVE_USER, puser); plugin->Call(WINIX_PREPARE_TO_REMOVE_USER, puser);
result = table.Remove(user_id); result = table.Remove(user_id);
if( result ) if( result )
plugin.Call(WINIX_USER_REMOVED, user_id); plugin->Call(WINIX_USER_REMOVED, user_id);
} }
return result; 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; log << log1 << "Users: I cannot login a user on a temporary session" << logend;
if( use_ses_log ) // if( use_ses_log )
slog << logerror << T(L"service_unavailable") << logend; // slog << logerror << T(L"service_unavailable") << logend;
return false; 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; log << log1 << "Users: user id: " << user_id << " is not in system.users table" << logend;
if( use_ses_log ) // if( use_ses_log )
slog << logerror << T(L"service_unavailable") << logend; // slog << logerror << T(L"service_unavailable") << logend;
return 0; return 0;
} }
@ -208,6 +216,7 @@ User * Users::LoginUserCheckStatus(long user_id, bool use_ses_log)
if( use_ses_log ) if( use_ses_log )
{ {
/*
if( puser->status == WINIX_ACCOUNT_NOT_ACTIVATED ) if( puser->status == WINIX_ACCOUNT_NOT_ACTIVATED )
slog << logerror << T(L"account_not_activated") << logend; slog << logerror << T(L"account_not_activated") << logend;
else else
@ -216,6 +225,7 @@ User * Users::LoginUserCheckStatus(long user_id, bool use_ses_log)
else else
if( puser->status == WINIX_ACCOUNT_BLOCKED ) if( puser->status == WINIX_ACCOUNT_BLOCKED )
slog << logerror << T(L"account_banned") << logend; slog << logerror << T(L"account_banned") << logend;
*/
} }
return 0; return 0;
@ -236,7 +246,7 @@ bool Users::LoginUser(long user_id, bool remember_me, bool use_ses_log)
if( !puser ) if( !puser )
return false; 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 ) 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; how_many_logged += 1;
log << log2 << "Users: user " << cur->session->puser->name << " (id: " << user_id << ") logged" << logend; 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; return true;
} }
@ -296,7 +306,7 @@ void Users::LogoutCurrentUser()
log << log2 << "Users: user " << cur->session->puser->name << ", id: " log << log2 << "Users: user " << cur->session->puser->name << ", id: "
<< cur->session->puser->id << " logged out" << logend; << 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); last.UserLogout(cur->session->puser->id, cur->session->id);
if( how_many_logged > 0 ) // for safety if( how_many_logged > 0 ) // for safety

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2008-2014, Tomasz Sowa * Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -41,6 +41,8 @@
#include "lastcontainer.h" #include "lastcontainer.h"
#include "cur.h" #include "cur.h"
#include "db/db.h" #include "db/db.h"
#include "winixmodel.h"
namespace Winix namespace Winix
@ -51,12 +53,15 @@ namespace Winix
class SessionManager; class SessionManager;
class Users class Users : public WinixModel
{ {
typedef UGContainer<User> Table; typedef UGContainer<User> Table;
public: public:
void set_dependency(WinixModel * winix_model);
typedef Table::Iterator Iterator; typedef Table::Iterator Iterator;
typedef Table::SizeType SizeType; typedef Table::SizeType SizeType;

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2008-2014, Tomasz Sowa * Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * 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_MAJOR 0
#define WINIX_VER_MINOR 6 #define WINIX_VER_MINOR 7
#define WINIX_VER_REVISION 6 #define WINIX_VER_REVISION 0

89
winixd/core/winixbase.cpp Normal file
View 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
View 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

View 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
View 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

View 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
}
}

View 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

View 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
View 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

View File

@ -12,27 +12,23 @@ db.o: ../../../pikotools/textstream/textstream.h
db.o: ../../../pikotools/membuffer/membuffer.h db.o: ../../../pikotools/membuffer/membuffer.h
db.o: ../../../pikotools/textstream/types.h ../../../pikotools/utf8/utf8.h db.o: ../../../pikotools/textstream/types.h ../../../pikotools/utf8/utf8.h
db.o: ../../../winix/winixd/core/winix_const.h db.o: ../../../winix/winixd/core/winix_const.h
db.o: ../../../winix/winixd/core/error.h db.o: ../../../winix/winixd/core/winixbase.h
db.o: ../../../winix/winixd/core/config.h
db.o: ../../../pikotools/space/spaceparser.h ../../../pikotools/space/space.h db.o: ../../../pikotools/space/spaceparser.h ../../../pikotools/space/space.h
db.o: dbitemquery.h ../../../winix/winixd/core/item.h dbitemcolumns.h db.o: ../../../winix/winixd/core/htmlfilter.h
db.o: ../../../winix/winixd/core/user.h ../../../winix/winixd/core/group.h
db.o: ../../../winix/winixd/core/dircontainer.h
db.o: ../../../winix/winixd/core/ugcontainer.h
db.o: ../../../winix/winixd/core/log.h db.o: ../../../winix/winixd/core/log.h
db.o: ../../../winix/winixd/core/textstream.h db.o: ../../../winix/winixd/core/textstream.h
db.o: ../../../winix/winixd/core/logmanipulators.h db.o: ../../../winix/winixd/core/logmanipulators.h
db.o: ../../../winix/winixd/core/slog.h ../../../winix/winixd/core/cur.h db.o: ../../../winix/winixd/core/filelog.h
db.o: ../../../winix/winixd/core/request.h ../../../winix/winixd/core/error.h db.o: ../../../winix/winixd/core/synchro.h ../../../winix/winixd/core/log.h
db.o: ../../../winix/winixd/core/config.h db.o: ../../../winix/winixd/core/filelog.h ../../../winix/winixd/core/lock.h
db.o: ../../../winix/winixd/core/htmlfilter.h db.o: ../../../winix/winixd/core/synchro.h ../../../winix/winixd/core/error.h
db.o: ../../../winix/winixd/templates/htmltextstream.h db.o: dbitemquery.h ../../../winix/winixd/core/item.h dbitemcolumns.h
db.o: ../../../pikotools/space/spacetojson.h ../../../ezc/src/outstreams.h db.o: ../../../winix/winixd/core/user.h ../../../winix/winixd/core/group.h
db.o: ../../../winix/winixd/core/session.h ../../../winix/winixd/core/user.h db.o: ../../../winix/winixd/core/dircontainer.h
db.o: ../../../winix/winixd/core/plugindata.h db.o: ../../../winix/winixd/core/winixbase.h
db.o: ../../../winix/winixd/core/rebus.h ../../../winix/winixd/core/ipban.h db.o: ../../../winix/winixd/core/ugcontainer.h
db.o: ../../../winix/winixd/core/mount.h db.o: ../../../winix/winixd/core/misc.h
db.o: ../../../winix/winixd/templates/locale.h
db.o: ../../../winix/winixd/core/log.h ../../../winix/winixd/core/misc.h
dbbase.o: dbbase.h dbconn.h dbtextstream.h dbbase.o: dbbase.h dbconn.h dbtextstream.h
dbbase.o: ../../../winix/winixd/core/textstream.h dbbase.o: ../../../winix/winixd/core/textstream.h
dbbase.o: ../../../winix/winixd/core/misc.h ../../../winix/winixd/core/item.h dbbase.o: ../../../winix/winixd/core/misc.h ../../../winix/winixd/core/item.h
@ -48,9 +44,21 @@ dbbase.o: ../../../pikotools/membuffer/membuffer.h
dbbase.o: ../../../pikotools/textstream/types.h dbbase.o: ../../../pikotools/textstream/types.h
dbbase.o: ../../../pikotools/utf8/utf8.h dbbase.o: ../../../pikotools/utf8/utf8.h
dbbase.o: ../../../winix/winixd/core/winix_const.h dbbase.o: ../../../winix/winixd/core/winix_const.h
dbbase.o: ../../../winix/winixd/core/error.h dbbase.o: ../../../winix/winixd/core/winixbase.h
dbbase.o: ../../../winix/winixd/core/config.h
dbbase.o: ../../../pikotools/space/spaceparser.h dbbase.o: ../../../pikotools/space/spaceparser.h
dbbase.o: ../../../pikotools/space/space.h ../../../winix/winixd/core/log.h dbbase.o: ../../../pikotools/space/space.h
dbbase.o: ../../../winix/winixd/core/htmlfilter.h
dbbase.o: ../../../winix/winixd/core/log.h
dbbase.o: ../../../winix/winixd/core/textstream.h
dbbase.o: ../../../winix/winixd/core/logmanipulators.h
dbbase.o: ../../../winix/winixd/core/filelog.h
dbbase.o: ../../../winix/winixd/core/synchro.h
dbbase.o: ../../../winix/winixd/core/log.h
dbbase.o: ../../../winix/winixd/core/filelog.h
dbbase.o: ../../../winix/winixd/core/lock.h
dbbase.o: ../../../winix/winixd/core/synchro.h
dbbase.o: ../../../winix/winixd/core/error.h
dbbase.o: ../../../winix/winixd/core/misc.h dbbase.o: ../../../winix/winixd/core/misc.h
dbconn.o: dbconn.h dbtextstream.h ../../../winix/winixd/core/textstream.h dbconn.o: dbconn.h dbtextstream.h ../../../winix/winixd/core/textstream.h
dbconn.o: ../../../winix/winixd/core/misc.h ../../../winix/winixd/core/item.h dbconn.o: ../../../winix/winixd/core/misc.h ../../../winix/winixd/core/item.h
@ -66,7 +74,21 @@ dbconn.o: ../../../pikotools/membuffer/membuffer.h
dbconn.o: ../../../pikotools/textstream/types.h dbconn.o: ../../../pikotools/textstream/types.h
dbconn.o: ../../../pikotools/utf8/utf8.h dbconn.o: ../../../pikotools/utf8/utf8.h
dbconn.o: ../../../winix/winixd/core/winix_const.h dbconn.o: ../../../winix/winixd/core/winix_const.h
dbconn.o: ../../../winix/winixd/core/log.h ../../../winix/winixd/core/error.h dbconn.o: ../../../winix/winixd/core/winixbase.h
dbconn.o: ../../../winix/winixd/core/config.h
dbconn.o: ../../../pikotools/space/spaceparser.h
dbconn.o: ../../../pikotools/space/space.h
dbconn.o: ../../../winix/winixd/core/htmlfilter.h
dbconn.o: ../../../winix/winixd/core/log.h
dbconn.o: ../../../winix/winixd/core/textstream.h
dbconn.o: ../../../winix/winixd/core/logmanipulators.h
dbconn.o: ../../../winix/winixd/core/filelog.h
dbconn.o: ../../../winix/winixd/core/synchro.h
dbconn.o: ../../../winix/winixd/core/log.h
dbconn.o: ../../../winix/winixd/core/filelog.h
dbconn.o: ../../../winix/winixd/core/lock.h
dbconn.o: ../../../winix/winixd/core/synchro.h
dbconn.o: ../../../winix/winixd/core/error.h
dbitemcolumns.o: dbitemcolumns.h ../../../winix/winixd/core/item.h dbbase.h dbitemcolumns.o: dbitemcolumns.h ../../../winix/winixd/core/item.h dbbase.h
dbitemcolumns.o: dbconn.h dbtextstream.h dbitemcolumns.o: dbconn.h dbtextstream.h
dbitemcolumns.o: ../../../winix/winixd/core/textstream.h dbitemcolumns.o: ../../../winix/winixd/core/textstream.h
@ -85,10 +107,21 @@ dbitemcolumns.o: ../../../pikotools/membuffer/membuffer.h
dbitemcolumns.o: ../../../pikotools/textstream/types.h dbitemcolumns.o: ../../../pikotools/textstream/types.h
dbitemcolumns.o: ../../../pikotools/utf8/utf8.h dbitemcolumns.o: ../../../pikotools/utf8/utf8.h
dbitemcolumns.o: ../../../winix/winixd/core/winix_const.h dbitemcolumns.o: ../../../winix/winixd/core/winix_const.h
dbitemcolumns.o: ../../../winix/winixd/core/error.h dbitemcolumns.o: ../../../winix/winixd/core/winixbase.h
dbitemcolumns.o: ../../../winix/winixd/core/config.h
dbitemcolumns.o: ../../../pikotools/space/spaceparser.h dbitemcolumns.o: ../../../pikotools/space/spaceparser.h
dbitemcolumns.o: ../../../pikotools/space/space.h dbitemcolumns.o: ../../../pikotools/space/space.h
dbitemcolumns.o: ../../../winix/winixd/core/htmlfilter.h
dbitemcolumns.o: ../../../winix/winixd/core/log.h dbitemcolumns.o: ../../../winix/winixd/core/log.h
dbitemcolumns.o: ../../../winix/winixd/core/textstream.h
dbitemcolumns.o: ../../../winix/winixd/core/logmanipulators.h
dbitemcolumns.o: ../../../winix/winixd/core/filelog.h
dbitemcolumns.o: ../../../winix/winixd/core/synchro.h
dbitemcolumns.o: ../../../winix/winixd/core/log.h
dbitemcolumns.o: ../../../winix/winixd/core/filelog.h
dbitemcolumns.o: ../../../winix/winixd/core/lock.h
dbitemcolumns.o: ../../../winix/winixd/core/synchro.h
dbitemcolumns.o: ../../../winix/winixd/core/error.h
dbitemquery.o: dbitemquery.h ../../../winix/winixd/core/item.h dbitemquery.o: dbitemquery.h ../../../winix/winixd/core/item.h
dbtextstream.o: dbtextstream.h ../../../winix/winixd/core/textstream.h dbtextstream.o: dbtextstream.h ../../../winix/winixd/core/textstream.h
dbtextstream.o: ../../../winix/winixd/core/misc.h dbtextstream.o: ../../../winix/winixd/core/misc.h

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2008-2014, Tomasz Sowa * Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -43,6 +43,8 @@
#include "core/error.h" #include "core/error.h"
#include "space/spaceparser.h" #include "space/spaceparser.h"
#include "date/date.h" #include "date/date.h"
#include "core/winixbase.h"
namespace Winix namespace Winix
@ -50,7 +52,7 @@ namespace Winix
class DbBase class DbBase : public WinixBase
{ {
public: public:
@ -67,21 +69,19 @@ public:
PGresult * AssertQuery(const char * q, ExecStatusType t); PGresult * AssertQuery(const char * q, ExecStatusType t);
PGresult * AssertQuery(const DbTextStream & query, ExecStatusType t); PGresult * AssertQuery(const DbTextStream & query, ExecStatusType t);
void AssertResult(PGresult * r, ExecStatusType t); void AssertResult(PGresult * r, ExecStatusType t);
static int AssertColumn(PGresult * r, const char * column_name); int AssertColumn(PGresult * r, const char * column_name);
const char * AssertValue(PGresult * r, int row, int col);
const std::wstring & AssertValueWide(PGresult * r, int row, int col); // warning: this method uses a static buffer
void AssertValueWide(PGresult * r, int row, int col, std::wstring & result);
void AssertValueBin(PGresult * r, int row, int col, std::string & result);
long AssertValueLong(PGresult * r, int row, int col);
int AssertValueInt(PGresult * r, int row, int col);
bool AssertValueBool(PGresult * r, int row, int col);
unsigned long AssertValueULong(PGresult * r, int row, int col);
unsigned int AssertValueUInt(PGresult * r, int row, int col);
PT::Date AssertValueDate(PGresult * r, int row, int col);
// static assignments
static const char * AssertValue(PGresult * r, int row, int col);
static const std::wstring & AssertValueWide(PGresult * r, int row, int col); // warning: this method uses a static buffer
static void AssertValueWide(PGresult * r, int row, int col, std::wstring & result);
static void AssertValueBin(PGresult * r, int row, int col, std::string & result);
static long AssertValueLong(PGresult * r, int row, int col);
static int AssertValueInt(PGresult * r, int row, int col);
static bool AssertValueBool(PGresult * r, int row, int col);
static unsigned long AssertValueULong(PGresult * r, int row, int col);
static unsigned int AssertValueUInt(PGresult * r, int row, int col);
static PT::Date AssertValueDate(PGresult * r, int row, int col);
// non static assignments
bool AssertValueSpace(PGresult * r, int row, int col, PT::Space & space); bool AssertValueSpace(PGresult * r, int row, int col, PT::Space & space);
void ClearResult(PGresult * r); void ClearResult(PGresult * r);
@ -104,7 +104,7 @@ public:
// new API (returns only bool) // new API (returns only bool)
bool EndTrans(bool everything_ok); bool EndTrans(bool everything_ok);
static void UnescapeBin(const char * str, size_t len, std::string & out, bool clear_out = true); void UnescapeBin(const char * str, size_t len, std::string & out, bool clear_out = true);
protected: protected:
@ -126,7 +126,7 @@ private:
// static bool IsCorrectOctalDigit(char c); // static bool IsCorrectOctalDigit(char c);
// static int UnescapeBin(const char * str, size_t & i, size_t len); // static int UnescapeBin(const char * str, size_t & i, size_t len);
static char UnescapeBinHexToDigit(char hex); char UnescapeBinHexToDigit(char hex);
DbTextStream bquery; DbTextStream bquery;
PT::SpaceParser conf_parser; PT::SpaceParser conf_parser;

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2010-2014, Tomasz Sowa * Copyright (c) 2010-2018, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -38,6 +38,7 @@
#include <string> #include <string>
#include <libpq-fe.h> #include <libpq-fe.h>
#include "dbtextstream.h" #include "dbtextstream.h"
#include "core/winixbase.h"
namespace Winix namespace Winix
@ -45,7 +46,7 @@ namespace Winix
class DbConn class DbConn : public WinixBase
{ {
public: public:

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2008-2014, Tomasz Sowa * Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -80,36 +80,36 @@ void DbItemColumns::SetColumns(PGresult * r)
void DbItemColumns::SetItem(PGresult * r, long row, Item & item) void DbItemColumns::SetItem(PGresult * r, long row, Item & item)
{ {
if( id != -1 ) item.id = DbBase::AssertValueLong(r, row, id); if( id != -1 ) item.id = db_base.AssertValueLong(r, row, id);
if( user_id != -1 ) item.user_id = DbBase::AssertValueLong(r, row, user_id); if( user_id != -1 ) item.user_id = db_base.AssertValueLong(r, row, user_id);
if( group_id != -1 ) item.group_id = DbBase::AssertValueLong(r, row, group_id); if( group_id != -1 ) item.group_id = db_base.AssertValueLong(r, row, group_id);
if( privileges != -1 ) item.privileges = DbBase::AssertValueInt(r, row, privileges); if( privileges != -1 ) item.privileges = db_base.AssertValueInt(r, row, privileges);
if( date_creation != -1 ) item.date_creation = DbBase::AssertValueDate(r, row, date_creation); if( date_creation != -1 ) item.date_creation = db_base.AssertValueDate(r, row, date_creation);
if( date_modification != -1 ) item.date_modification = DbBase::AssertValueDate(r, row, date_modification); if( date_modification != -1 ) item.date_modification = db_base.AssertValueDate(r, row, date_modification);
if( type != -1 ) item.type = static_cast<Item::Type>( DbBase::AssertValueInt(r, row, type) ); if( type != -1 ) item.type = static_cast<Item::Type>( db_base.AssertValueInt(r, row, type) );
if( parent_id != -1 ) item.parent_id = DbBase::AssertValueLong(r, row, parent_id); if( parent_id != -1 ) item.parent_id = db_base.AssertValueLong(r, row, parent_id);
if( content_id != -1 ) item.content_id = DbBase::AssertValueLong(r, row, content_id); if( content_id != -1 ) item.content_id = db_base.AssertValueLong(r, row, content_id);
if( link_redirect != -1 ) item.link_redirect = DbBase::AssertValueInt(r, row, link_redirect); if( link_redirect != -1 ) item.link_redirect = db_base.AssertValueInt(r, row, link_redirect);
if( content_type != -1 ) item.content_type = static_cast<Item::ContentType>( DbBase::AssertValueInt(r, row, content_type) ); if( content_type != -1 ) item.content_type = static_cast<Item::ContentType>( db_base.AssertValueInt(r, row, content_type) );
if( modification_user_id != -1 ) item.modification_user_id = DbBase::AssertValueLong(r, row, modification_user_id); if( modification_user_id != -1 ) item.modification_user_id = db_base.AssertValueLong(r, row, modification_user_id);
if( file_fs != -1 ) item.file_fs = DbBase::AssertValueInt(r, row, file_fs); if( file_fs != -1 ) item.file_fs = db_base.AssertValueInt(r, row, file_fs);
if( file_type != -1 ) item.file_type = DbBase::AssertValueInt(r, row, file_type); if( file_type != -1 ) item.file_type = db_base.AssertValueInt(r, row, file_type);
if( has_thumb != -1 ) item.has_thumb = DbBase::AssertValueBool(r, row, has_thumb); if( has_thumb != -1 ) item.has_thumb = db_base.AssertValueBool(r, row, has_thumb);
if( hash != -1 ) DbBase::AssertValueWide(r, row, hash, item.hash); if( hash != -1 ) db_base.AssertValueWide(r, row, hash, item.hash);
if( hash_type != -1 ) item.hash_type = DbBase::AssertValueInt(r, row, hash_type); if( hash_type != -1 ) item.hash_type = db_base.AssertValueInt(r, row, hash_type);
if( file_size != -1 ) item.file_size = DbBase::AssertValueLong(r, row, file_size); if( file_size != -1 ) item.file_size = db_base.AssertValueLong(r, row, file_size);
if( ref != -1 ) item.ref = DbBase::AssertValueInt(r, row, ref); if( ref != -1 ) item.ref = db_base.AssertValueInt(r, row, ref);
if( modify_index != -1 ) item.modify_index = DbBase::AssertValueInt(r, row, modify_index); if( modify_index != -1 ) item.modify_index = db_base.AssertValueInt(r, row, modify_index);
if( url != -1 ) DbBase::AssertValueWide(r, row, url, item.url); if( url != -1 ) db_base.AssertValueWide(r, row, url, item.url);
if( content != -1 ) DbBase::AssertValueWide(r, row, content, item.content); if( content != -1 ) db_base.AssertValueWide(r, row, content, item.content);
if( subject != -1 ) DbBase::AssertValueWide(r, row, subject, item.subject); if( subject != -1 ) db_base.AssertValueWide(r, row, subject, item.subject);
if( file_path != -1 ) DbBase::AssertValueWide(r, row, file_path, item.file_path); if( file_path != -1 ) db_base.AssertValueWide(r, row, file_path, item.file_path);
if( link_to != -1 ) DbBase::AssertValueWide(r, row, link_to, item.link_to); if( link_to != -1 ) db_base.AssertValueWide(r, row, link_to, item.link_to);
if( guest_name != -1 ) DbBase::AssertValueWide(r, row, guest_name, item.guest_name); if( guest_name != -1 ) db_base.AssertValueWide(r, row, guest_name, item.guest_name);
if( html_template != -1 ) DbBase::AssertValueWide(r, row, html_template, item.html_template); if( html_template != -1 ) db_base.AssertValueWide(r, row, html_template, item.html_template);
if( sort_index != -1 ) item.sort_index = DbBase::AssertValueInt(r, row, sort_index); if( sort_index != -1 ) item.sort_index = db_base.AssertValueInt(r, row, sort_index);
if( meta != -1 ) db_base.AssertValueSpace(r, row, meta, item.meta); if( meta != -1 ) db_base.AssertValueSpace(r, row, meta, item.meta);
if( ameta != -1 ) db_base.AssertValueSpace(r, row, ameta, item.ameta); if( ameta != -1 ) db_base.AssertValueSpace(r, row, ameta, item.ameta);

File diff suppressed because it is too large Load Diff

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2008-2014, Tomasz Sowa * Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -34,8 +34,6 @@
#include <cstdlib> #include <cstdlib>
#include "adduser.h" #include "adduser.h"
#include "core/slog.h"
#include "core/plugin.h"
#include "core/misc.h" #include "core/misc.h"
#include "functions/functions.h" #include "functions/functions.h"
@ -240,7 +238,7 @@ bool AddUser::AddNewUser(const std::wstring & login,
{ {
system->users.LoginUser(user.id, false); system->users.LoginUser(user.id, false);
log << log2 << "AddUser: now logged as: " << user.name << logend; log << log2 << "AddUser: now logged as: " << user.name << logend;
plugin.Call(WINIX_USER_LOGGED); plugin->Call(WINIX_USER_LOGGED);
} }
if( user.status == WINIX_ACCOUNT_NOT_ACTIVATED ) if( user.status == WINIX_ACCOUNT_NOT_ACTIVATED )

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2008-2014, Tomasz Sowa * Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -50,6 +50,12 @@ Chmod::Chmod()
} }
void Chmod::set_dependency(WinixRequest * winix_request)
{
WinixRequest::set_dependency(winix_request);
priv_changer.set_dependency(winix_request);
}
void Chmod::MakePost() void Chmod::MakePost()
{ {
priv_changer.SetCur(cur); priv_changer.SetCur(cur);

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2010-2014, Tomasz Sowa * Copyright (c) 2010-2018, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -54,6 +54,8 @@ public:
void MakePost(); void MakePost();
void MakeGet(); void MakeGet();
void set_dependency(WinixRequest * winix_request);
private: private:
PrivChanger priv_changer; PrivChanger priv_changer;

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2008-2014, Tomasz Sowa * Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -50,6 +50,13 @@ Chown::Chown()
} }
void Chown::set_dependency(WinixRequest * winix_request)
{
WinixRequest::set_dependency(winix_request);
priv_changer.set_dependency(winix_request);
}
void Chown::MakePost() void Chown::MakePost()
{ {
priv_changer.SetCur(cur); priv_changer.SetCur(cur);

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2010-2014, Tomasz Sowa * Copyright (c) 2010-2018, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -54,6 +54,8 @@ public:
void MakePost(); void MakePost();
void MakeGet(); void MakeGet();
void set_dependency(WinixRequest * winix_request);
private: private:
PrivChanger priv_changer; PrivChanger priv_changer;

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2008-2014, Tomasz Sowa * Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -35,7 +35,7 @@
#include "cp.h" #include "cp.h"
#include "core/misc.h" #include "core/misc.h"
#include "functions.h" #include "functions.h"
#include "core/plugin.h"
@ -181,7 +181,7 @@ void Cp::CopyFile(Item & item, long dst_dir_id)
if( item.file_type != WINIX_ITEM_FILETYPE_NONE ) if( item.file_type != WINIX_ITEM_FILETYPE_NONE )
CopyStaticFile(item); CopyStaticFile(item);
plugin.Call(WINIX_FILE_COPIED, &item); plugin->Call(WINIX_FILE_COPIED, &item);
} }
} }

View File

@ -53,6 +53,10 @@ FunctionBase::FunctionBase()
fun.parent_id = -1; fun.parent_id = -1;
fun.id = -1; fun.id = -1;
fun.type = Item::file; fun.type = Item::file;
db = nullptr;
functions = nullptr;
templates = nullptr;
} }
@ -62,16 +66,16 @@ FunctionBase::~FunctionBase()
void FunctionBase::SetConfig(Config * pconfig) //void FunctionBase::SetConfig(Config * pconfig)
{ //{
config = pconfig; // config = pconfig;
} //}
void FunctionBase::SetCur(Cur * pcur) //void FunctionBase::SetCur(Cur * pcur)
{ //{
cur = pcur; // cur = pcur;
} //}
@ -81,10 +85,10 @@ void FunctionBase::SetDb(Db * pdb)
} }
void FunctionBase::SetSystem(System * psystem) //void FunctionBase::SetSystem(System * psystem)
{ //{
system = psystem; // system = psystem;
} //}
void FunctionBase::SetFunctions(Functions * pfunctions) void FunctionBase::SetFunctions(Functions * pfunctions)
@ -99,16 +103,16 @@ void FunctionBase::SetTemplates(Templates * ptemplates)
} }
void FunctionBase::SetSynchro(Synchro * psynchro) //void FunctionBase::SetSynchro(Synchro * psynchro)
{ //{
synchro = psynchro; // synchro = psynchro;
} //}
void FunctionBase::SetSessionManager(SessionManager * pmanager) //void FunctionBase::SetSessionManager(SessionManager * pmanager)
{ //{
session_manager = pmanager; // session_manager = pmanager;
} //}
void FunctionBase::Init() void FunctionBase::Init()

View File

@ -44,6 +44,9 @@
#include "core/system.h" #include "core/system.h"
#include "core/synchro.h" #include "core/synchro.h"
#include "notify/notify.h" #include "notify/notify.h"
#include "core/winixrequest.h"
namespace Winix namespace Winix
{ {
@ -54,8 +57,7 @@ class Templates;
class FunctionBase : public WinixRequest
class FunctionBase
{ {
public: public:
@ -90,25 +92,26 @@ public:
virtual void MakeGet(); virtual void MakeGet();
virtual void MakeDelete(); virtual void MakeDelete();
void SetConfig(Config * pconfig); //void SetConfig(Config * pconfig);
void SetCur(Cur * pcur); //void SetCur(Cur * pcur);
void SetDb(Db * pdb); void SetDb(Db * pdb);
void SetSystem(System * psystem); //void SetSystem(System * psystem);
void SetFunctions(Functions * pfunctions); void SetFunctions(Functions * pfunctions);
void SetTemplates(Templates * ptemplates); void SetTemplates(Templates * ptemplates);
void SetSynchro(Synchro * psynchro); //void SetSynchro(Synchro * psynchro);
void SetSessionManager(SessionManager * pmanager); //void SetSessionManager(SessionManager * pmanager);
protected: protected:
Config * config; //Config * config;
Cur * cur; //Cur * cur;
Db * db; Db * db; // depracated
System * system; //System * system;
Functions * functions; Functions * functions;
Templates * templates; Templates * templates;
Synchro * synchro; //Synchro * synchro;
SessionManager * session_manager; //SessionManager * session_manager;
}; };

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2008-2014, Tomasz Sowa * Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2008-2014, Tomasz Sowa * Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -39,6 +39,8 @@
#include "db/db.h" #include "db/db.h"
#include "core/cur.h" #include "core/cur.h"
#include "core/system.h" #include "core/system.h"
#include "core/winixmodel.h"
namespace Winix namespace Winix
{ {
@ -47,7 +49,7 @@ namespace Winix
class Functions; class Functions;
class FunctionParser class FunctionParser : public WinixModel
{ {
public: public:

View File

@ -33,9 +33,7 @@
*/ */
#include "functions.h" #include "functions.h"
#include "core/log.h"
#include "core/misc.h" #include "core/misc.h"
#include "core/plugin.h"
#include "templates/templates.h" #include "templates/templates.h"
@ -45,10 +43,10 @@ namespace Winix
void Functions::SetConfig(Config * pconfig) //void Functions::SetConfig(Config * pconfig)
{ //{
config = pconfig; // config = pconfig;
} //}
void Functions::SetCur(Cur * pcur) void Functions::SetCur(Cur * pcur)
@ -76,10 +74,10 @@ void Functions::SetTemplates(Templates * ptemplates)
} }
void Functions::SetSynchro(Synchro * psynchro) //void Functions::SetSynchro(Synchro * psynchro)
{ //{
synchro = psynchro; // synchro = psynchro;
} //}
void Functions::SetSessionManager(SessionManager * pmanager) void Functions::SetSessionManager(SessionManager * pmanager)
@ -88,6 +86,12 @@ void Functions::SetSessionManager(SessionManager * pmanager)
} }
void Functions::set_dependency(WinixRequest * winix_request)
{
WinixRequest::set_dependency(winix_request);
function_parser.set_dependency(winix_request);
}
size_t Functions::FunctionsSize() size_t Functions::FunctionsSize()
{ {
@ -171,14 +175,16 @@ return WINIX_NOTHING_TO_DO;
void Functions::SetObjects(FunctionBase * fun) void Functions::SetObjects(FunctionBase * fun)
{ {
fun->SetConfig(config); fun->set_dependency(this);
fun->SetCur(cur);
//fun->SetConfig(config);
//fun->SetCur(cur);
fun->SetDb(db); fun->SetDb(db);
fun->SetSystem(system); //fun->SetSystem(system);
fun->SetFunctions(this); fun->SetFunctions(this);
fun->SetTemplates(templates); fun->SetTemplates(templates);
fun->SetSynchro(synchro); //fun->SetSynchro(synchro);
fun->SetSessionManager(session_manager); //fun->SetSessionManager(session_manager);
} }
@ -258,7 +264,7 @@ void Functions::CreateFunctions()
Add(fun_who); Add(fun_who);
Add(fun_vim); Add(fun_vim);
plugin.Call((Session*)0, WINIX_CREATE_FUNCTIONS); plugin->Call((Session*)0, WINIX_CREATE_FUNCTIONS);
} }
@ -318,7 +324,7 @@ void Functions::SetDefaultFunction()
{ {
cur->request->function = 0; cur->request->function = 0;
plugin.Call(WINIX_SELECT_DEFAULT_FUNCTION); plugin->Call(WINIX_SELECT_DEFAULT_FUNCTION);
if( cur->request->function ) if( cur->request->function )
{ {

View File

@ -84,6 +84,7 @@
#include "who.h" #include "who.h"
#include "vim.h" #include "vim.h"
#include "core/htmlfilter.h" #include "core/htmlfilter.h"
#include "core/winixrequest.h"
namespace Winix namespace Winix
@ -94,7 +95,7 @@ class Templates;
class Functions class Functions : public WinixRequest
{ {
public: public:
@ -158,14 +159,16 @@ public:
void MakeFunction(); void MakeFunction();
void SetConfig(Config * pconfig); //void SetConfig(Config * pconfig);
void SetCur(Cur * pcur); void SetCur(Cur * pcur);
void SetDb(Db * pdb); void SetDb(Db * pdb);
void SetSystem(System * psystem); void SetSystem(System * psystem);
void SetTemplates(Templates * ptemplates); void SetTemplates(Templates * ptemplates);
void SetSynchro(Synchro * psynchro); //void SetSynchro(Synchro * psynchro);
void SetSessionManager(SessionManager * pmanager); void SetSessionManager(SessionManager * pmanager);
void set_dependency(WinixRequest * winix_request);
FunctionBase * Find(const std::wstring & function_name); FunctionBase * Find(const std::wstring & function_name);
Error CheckSpecialFile(const Item & item); Error CheckSpecialFile(const Item & item);
void PrepareUrl(Item & item); void PrepareUrl(Item & item);
@ -193,11 +196,11 @@ public:
private: private:
Config * config; //Config * config;
Cur * cur; Cur * cur;
Db * db; Db * db;
System * system; System * system;
Synchro * synchro; //Synchro * synchro;
Templates * templates; Templates * templates;
SessionManager * session_manager; SessionManager * session_manager;

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2008-2014, Tomasz Sowa * Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -34,7 +34,6 @@
#include "mkdir.h" #include "mkdir.h"
#include "functions.h" #include "functions.h"
#include "core/plugin.h"
@ -101,7 +100,7 @@ void Mkdir::PostFunMkdir(bool add_to_dir_tab, int privileges)
if( cur->request->status == WINIX_ERR_OK ) if( cur->request->status == WINIX_ERR_OK )
{ {
if( pdir ) if( pdir )
plugin.Call(WINIX_DIR_ADDED, pdir); plugin->Call(WINIX_DIR_ADDED, pdir);
system->RedirectTo(cur->request->item); system->RedirectTo(cur->request->item);
} }

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2008-2014, Tomasz Sowa * Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -35,7 +35,6 @@
#include <errno.h> #include <errno.h>
#include "mv.h" #include "mv.h"
#include "functions.h" #include "functions.h"
#include "core/plugin.h"
@ -299,7 +298,7 @@ void Mv::MoveFilesPrepareTreeGo(const Item & src_dir)
db->GetItems(files_item_tab, files_iq); db->GetItems(files_item_tab, files_iq);
for(size_t i=0 ; i<files_item_tab.size() ; ++i) for(size_t i=0 ; i<files_item_tab.size() ; ++i)
plugin.Call(WINIX_FILE_PREPARE_TO_MOVE, &files_item_tab[i]); plugin->Call(WINIX_FILE_PREPARE_TO_MOVE, &files_item_tab[i]);
} }
@ -309,7 +308,7 @@ void Mv::MoveFilesPrepareTree(const Item & src_dir)
// we only calling plugins here // we only calling plugins here
// so if there is no WINIX_FILE_PREPARE_TO_MOVE message // so if there is no WINIX_FILE_PREPARE_TO_MOVE message
// we can immediately return and the database will not be bothered // we can immediately return and the database will not be bothered
if( plugin.HasMessage(WINIX_FILE_PREPARE_TO_MOVE) ) if( plugin->HasMessage(WINIX_FILE_PREPARE_TO_MOVE) )
{ {
MoveFilesPrepareTreeGo(src_dir); MoveFilesPrepareTreeGo(src_dir);
} }
@ -332,9 +331,9 @@ void Mv::MoveFilesTree(const Item & dir)
{ {
if( files_item_tab[i].file_type != WINIX_ITEM_FILETYPE_NONE ) if( files_item_tab[i].file_type != WINIX_ITEM_FILETYPE_NONE )
{ {
plugin.Call(WINIX_FILE_PREPARE_TO_MOVE, &files_item_tab[i]); plugin->Call(WINIX_FILE_PREPARE_TO_MOVE, &files_item_tab[i]);
MoveStaticFile(files_item_tab[i]); MoveStaticFile(files_item_tab[i]);
plugin.Call(WINIX_FILE_MOVED, &files_item_tab[i]); plugin->Call(WINIX_FILE_MOVED, &files_item_tab[i]);
} }
} }
} }
@ -489,7 +488,7 @@ bool Mv::MoveDir2(Item & src_dir, const std::wstring & dst_path, bool check_acce
// private // private
bool Mv::MoveFileOrSymlink(Item & src_file, std::vector<Item*> & dst_dir_tab, const std::wstring & new_url) bool Mv::MoveFileOrSymlink(Item & src_file, std::vector<Item*> & dst_dir_tab, const std::wstring & new_url)
{ {
plugin.Call(WINIX_FILE_PREPARE_TO_MOVE, &src_file); plugin->Call(WINIX_FILE_PREPARE_TO_MOVE, &src_file);
old_url = src_file.url; old_url = src_file.url;
@ -516,7 +515,7 @@ bool Mv::MoveFileOrSymlink(Item & src_file, std::vector<Item*> & dst_dir_tab, co
if( src_file.file_type != WINIX_ITEM_FILETYPE_NONE ) if( src_file.file_type != WINIX_ITEM_FILETYPE_NONE )
MoveStaticFile(src_file); MoveStaticFile(src_file);
plugin.Call(WINIX_FILE_MOVED, &src_file); plugin->Call(WINIX_FILE_MOVED, &src_file);
return true; return true;
} }

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2008-2014, Tomasz Sowa * Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -51,6 +51,13 @@ Priv::Priv()
} }
void Priv::set_dependency(WinixRequest * winix_request)
{
WinixRequest::set_dependency(winix_request);
priv_changer.set_dependency(winix_request);
}
void Priv::MakePost() void Priv::MakePost()
{ {
priv_changer.SetCur(cur); priv_changer.SetCur(cur);

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2010-2014, Tomasz Sowa * Copyright (c) 2010-2018, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -54,9 +54,13 @@ public:
void MakePost(); void MakePost();
void MakeGet(); void MakeGet();
void set_dependency(WinixRequest * winix_request);
private: private:
PrivChanger priv_changer; PrivChanger priv_changer;
}; };

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2010-2014, Tomasz Sowa * Copyright (c) 2010-2018, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2010-2014, Tomasz Sowa * Copyright (c) 2010-2018, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -38,12 +38,14 @@
#include "core/request.h" #include "core/request.h"
#include "core/system.h" #include "core/system.h"
#include "db/db.h" #include "db/db.h"
#include "core/winixmodel.h"
namespace Winix namespace Winix
{ {
class PrivChanger class PrivChanger : public WinixModel
{ {
public: public:

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2008-2015, Tomasz Sowa * Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -34,11 +34,11 @@
#include <cstdio> #include <cstdio>
#include "rm.h" #include "rm.h"
#include "core/plugin.h"
#include "core/misc.h" #include "core/misc.h"
#include "templates/templates.h" #include "templates/templates.h"
namespace Winix namespace Winix
{ {
@ -188,7 +188,7 @@ void Rm::RemoveStaticFile(const Item & item)
*/ */
bool Rm::RemoveFile(Item & item) bool Rm::RemoveFile(Item & item)
{ {
plugin.Call(WINIX_FILE_PREPARE_TO_REMOVE, &item); plugin->Call(WINIX_FILE_PREPARE_TO_REMOVE, &item);
if( db->DelItem(item) == WINIX_ERR_OK ) if( db->DelItem(item) == WINIX_ERR_OK )
{ {
@ -204,7 +204,7 @@ bool Rm::RemoveFile(Item & item)
if( item.file_type != WINIX_ITEM_FILETYPE_NONE ) if( item.file_type != WINIX_ITEM_FILETYPE_NONE )
RemoveStaticFile(item); RemoveStaticFile(item);
plugin.Call(WINIX_FILE_REMOVED, &item); plugin->Call(WINIX_FILE_REMOVED, &item);
return true; return true;
} }
@ -370,7 +370,7 @@ void Rm::RemoveCurrentDir(Item * parent_dir, Item * current_dir, bool check_acce
} }
} }
plugin.Call(WINIX_DIR_PREPARE_TO_REMOVE, current_dir); plugin->Call(WINIX_DIR_PREPARE_TO_REMOVE, current_dir);
if( db->DelDirById(current_dir->id) == WINIX_ERR_OK ) if( db->DelDirById(current_dir->id) == WINIX_ERR_OK )
{ {
@ -379,7 +379,7 @@ void Rm::RemoveCurrentDir(Item * parent_dir, Item * current_dir, bool check_acce
system->dirs.DelDir(dir_id); system->dirs.DelDir(dir_id);
// don't use current_dir pointer anymore // don't use current_dir pointer anymore
log << log2 << "Rm: directory removed: " << old_url << logend; log << log2 << "Rm: directory removed: " << old_url << logend;
plugin.Call(WINIX_DIR_REMOVED, dir_id); plugin->Call(WINIX_DIR_REMOVED, dir_id);
} }
else else
{ {

View File

@ -187,7 +187,7 @@ void Sort::MakePost()
UpdateSortIndexes(); UpdateSortIndexes();
} }
plugin.Call(WINIX_DIR_CONTENT_SORTED, cur->request->dir_tab.back()); plugin->Call(WINIX_DIR_CONTENT_SORTED, cur->request->dir_tab.back());
system->RedirectToLastItem(); system->RedirectToLastItem();
} }

View File

@ -33,7 +33,6 @@
*/ */
#include "subject.h" #include "subject.h"
#include "core/plugin.h"
@ -93,7 +92,7 @@ void Subject::EditFileSubject()
cur->request->PostVar(L"subject", cur->request->item.subject); cur->request->PostVar(L"subject", cur->request->item.subject);
db->EditSubjectById(cur->request->item, cur->request->item.id); db->EditSubjectById(cur->request->item, cur->request->item.id);
plugin.Call(WINIX_FILE_CHANGED, &cur->request->item); plugin->Call(WINIX_FILE_CHANGED, &cur->request->item);
system->RedirectTo(cur->request->item); system->RedirectTo(cur->request->item);
} }

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2008-2014, Tomasz Sowa * Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -38,7 +38,6 @@
#include <errno.h> #include <errno.h>
#include "upload.h" #include "upload.h"
#include "core/misc.h" #include "core/misc.h"
#include "core/plugin.h"
#include "functions/functions.h" #include "functions/functions.h"
#include "templates/templates.h" #include "templates/templates.h"
#include "utf8/utf8.h" #include "utf8/utf8.h"
@ -157,7 +156,7 @@ void Upload::UploadFile(Item & item, const std::wstring & tmp_filename)
{ {
cur->request->status = db->EditFileById(item, item.id); cur->request->status = db->EditFileById(item, item.id);
plugin.Call(WINIX_FILE_ADDED, &item); plugin->Call(WINIX_FILE_ADDED, &item);
if( item.file_type == WINIX_ITEM_FILETYPE_IMAGE ) if( item.file_type == WINIX_ITEM_FILETYPE_IMAGE )
{ {

View File

@ -1,40 +1,50 @@
# DO NOT DELETE # DO NOT DELETE
main.o: ../../../winix/winixd/core/log.h main.o: ../../../winix/winixd/core/app.h
main.o: ../../../winix/winixd/core/textstream.h main.o: ../../../winix/winixd/core/sessionmanager.h
main.o: ../../../winix/winixd/core/misc.h ../../../winix/winixd/core/item.h main.o: ../../../winix/winixd/core/sessioncontainer.h
main.o: ../../../pikotools/space/space.h main.o: ../../../winix/winixd/core/session.h
main.o: ../../../winix/winixd/core/item.h ../../../pikotools/space/space.h
main.o: ../../../pikotools/textstream/types.h ../../../pikotools/date/date.h main.o: ../../../pikotools/textstream/types.h ../../../pikotools/date/date.h
main.o: ../../../pikotools/convert/convert.h main.o: ../../../pikotools/convert/convert.h
main.o: ../../../pikotools/convert/inttostr.h main.o: ../../../pikotools/convert/inttostr.h
main.o: ../../../pikotools/convert/strtoint.h main.o: ../../../pikotools/convert/strtoint.h
main.o: ../../../pikotools/convert/text.h main.o: ../../../pikotools/convert/text.h ../../../pikotools/convert/misc.h
main.o: ../../../winix/winixd/core/requesttypes.h main.o: ../../../winix/winixd/core/error.h ../../../winix/winixd/core/user.h
main.o: ../../../pikotools/textstream/textstream.h main.o: ../../../winix/winixd/core/plugindata.h
main.o: ../../../pikotools/membuffer/membuffer.h main.o: ../../../winix/winixd/core/rebus.h
main.o: ../../../pikotools/textstream/types.h ../../../pikotools/utf8/utf8.h main.o: ../../../winix/winixd/core/winixbase.h
main.o: ../../../winix/winixd/core/winix_const.h
main.o: ../../../winix/winixd/core/logmanipulators.h
main.o: ../../../winix/winixd/core/slog.h ../../../winix/winixd/core/cur.h
main.o: ../../../winix/winixd/core/request.h
main.o: ../../../winix/winixd/core/error.h
main.o: ../../../winix/winixd/core/config.h main.o: ../../../winix/winixd/core/config.h
main.o: ../../../pikotools/space/spaceparser.h main.o: ../../../pikotools/space/spaceparser.h
main.o: ../../../pikotools/space/space.h main.o: ../../../pikotools/space/space.h
main.o: ../../../winix/winixd/core/htmlfilter.h main.o: ../../../winix/winixd/core/htmlfilter.h
main.o: ../../../winix/winixd/core/log.h
main.o: ../../../winix/winixd/core/textstream.h
main.o: ../../../pikotools/textstream/textstream.h
main.o: ../../../pikotools/membuffer/membuffer.h
main.o: ../../../pikotools/textstream/types.h ../../../pikotools/utf8/utf8.h
main.o: ../../../winix/winixd/core/logmanipulators.h
main.o: ../../../winix/winixd/core/filelog.h
main.o: ../../../winix/winixd/core/synchro.h ../../../winix/winixd/core/log.h
main.o: ../../../winix/winixd/core/filelog.h
main.o: ../../../winix/winixd/core/lock.h
main.o: ../../../winix/winixd/core/synchro.h
main.o: ../../../winix/winixd/core/ipban.h ../../../winix/winixd/core/cur.h
main.o: ../../../winix/winixd/core/request.h
main.o: ../../../winix/winixd/core/requesttypes.h
main.o: ../../../winix/winixd/core/config.h
main.o: ../../../winix/winixd/templates/htmltextstream.h main.o: ../../../winix/winixd/templates/htmltextstream.h
main.o: ../../../winix/winixd/core/textstream.h main.o: ../../../winix/winixd/core/textstream.h
main.o: ../../../pikotools/space/spacetojson.h ../../../ezc/src/outstreams.h main.o: ../../../pikotools/space/spacetojson.h ../../../ezc/src/outstreams.h
main.o: ../../../winix/winixd/core/session.h
main.o: ../../../winix/winixd/core/user.h
main.o: ../../../winix/winixd/core/plugindata.h
main.o: ../../../winix/winixd/core/rebus.h ../../../winix/winixd/core/ipban.h
main.o: ../../../winix/winixd/core/mount.h main.o: ../../../winix/winixd/core/mount.h
main.o: ../../../winix/winixd/templates/locale.h main.o: ../../../winix/winixd/core/winixmodel.h
main.o: ../../../winix/winixd/core/slog.h ../../../winix/winixd/core/app.h main.o: ../../../winix/winixd/core/winixbase.h
main.o: ../../../winix/winixd/core/plugin.h
main.o: ../../../winix/winixd/core/pluginmsg.h
main.o: ../../../winix/winixd/core/ipbancontainer.h
main.o: ../../../winix/winixd/core/lastcontainer.h
main.o: ../../../winix/winixd/core/system.h ../../../winix/winixd/core/job.h main.o: ../../../winix/winixd/core/system.h ../../../winix/winixd/core/job.h
main.o: ../../../winix/winixd/core/basethread.h main.o: ../../../winix/winixd/core/basethread.h
main.o: ../../../winix/winixd/core/synchro.h
main.o: ../../../winix/winixd/core/dirs.h main.o: ../../../winix/winixd/core/dirs.h
main.o: ../../../winix/winixd/core/dircontainer.h main.o: ../../../winix/winixd/core/dircontainer.h
main.o: ../../../winix/winixd/db/db.h ../../../winix/winixd/db/dbbase.h main.o: ../../../winix/winixd/db/db.h ../../../winix/winixd/db/dbbase.h
@ -47,9 +57,19 @@ main.o: ../../../winix/winixd/db/dbitemcolumns.h
main.o: ../../../winix/winixd/core/user.h ../../../winix/winixd/core/group.h main.o: ../../../winix/winixd/core/user.h ../../../winix/winixd/core/group.h
main.o: ../../../winix/winixd/core/dircontainer.h main.o: ../../../winix/winixd/core/dircontainer.h
main.o: ../../../winix/winixd/core/ugcontainer.h main.o: ../../../winix/winixd/core/ugcontainer.h
main.o: ../../../winix/winixd/core/log.h main.o: ../../../winix/winixd/core/mounts.h
main.o: ../../../winix/winixd/core/mountparser.h
main.o: ../../../winix/winixd/core/crypt.h ../../../winix/winixd/core/run.h
main.o: ../../../winix/winixd/core/users.h
main.o: ../../../winix/winixd/core/ugcontainer.h
main.o: ../../../winix/winixd/core/groups.h
main.o: ../../../winix/winixd/core/group.h
main.o: ../../../winix/winixd/core/loadavg.h
main.o: ../../../winix/winixd/core/image.h
main.o: ../../../winix/winixd/core/threadmanager.h
main.o: ../../../winix/winixd/notify/notify.h main.o: ../../../winix/winixd/notify/notify.h
main.o: ../../../winix/winixd/notify/notifypool.h main.o: ../../../winix/winixd/notify/notifypool.h
main.o: ../../../winix/winixd/templates/locale.h
main.o: ../../../winix/winixd/templates/patterns.h main.o: ../../../winix/winixd/templates/patterns.h
main.o: ../../../winix/winixd/templates/locale.h main.o: ../../../winix/winixd/templates/locale.h
main.o: ../../../winix/winixd/templates/localefilter.h ../../../ezc/src/ezc.h main.o: ../../../winix/winixd/templates/localefilter.h ../../../ezc/src/ezc.h
@ -61,33 +81,22 @@ main.o: ../../../ezc/src/patternparser.h
main.o: ../../../winix/winixd/notify/notifythread.h main.o: ../../../winix/winixd/notify/notifythread.h
main.o: ../../../winix/winixd/core/basethread.h main.o: ../../../winix/winixd/core/basethread.h
main.o: ../../../winix/winixd/notify/templatesnotify.h main.o: ../../../winix/winixd/notify/templatesnotify.h
main.o: ../../../winix/winixd/core/config.h
main.o: ../../../winix/winixd/core/users.h main.o: ../../../winix/winixd/core/users.h
main.o: ../../../winix/winixd/core/ugcontainer.h main.o: ../../../winix/winixd/core/winixmodel.h
main.o: ../../../winix/winixd/core/lastcontainer.h
main.o: ../../../winix/winixd/core/mounts.h
main.o: ../../../winix/winixd/core/mountparser.h
main.o: ../../../winix/winixd/core/crypt.h ../../../winix/winixd/core/run.h
main.o: ../../../winix/winixd/core/users.h
main.o: ../../../winix/winixd/core/groups.h
main.o: ../../../winix/winixd/core/group.h
main.o: ../../../winix/winixd/core/loadavg.h
main.o: ../../../winix/winixd/core/image.h
main.o: ../../../winix/winixd/core/threadmanager.h
main.o: ../../../winix/winixd/core/timezones.h main.o: ../../../winix/winixd/core/timezones.h
main.o: ../../../winix/winixd/core/timezone.h main.o: ../../../winix/winixd/core/timezone.h
main.o: ../../../winix/winixd/core/sessionmanager.h
main.o: ../../../winix/winixd/core/sessioncontainer.h
main.o: ../../../winix/winixd/core/ipbancontainer.h
main.o: ../../../winix/winixd/core/sessionidmanager.h main.o: ../../../winix/winixd/core/sessionidmanager.h
main.o: ../../../tito/src/base64.h ../../../tito/src/aes.h main.o: ../../../tito/src/base64.h ../../../tito/src/aes.h
main.o: ../../../winix/winixd/functions/functions.h main.o: ../../../winix/winixd/functions/functions.h
main.o: ../../../winix/winixd/functions/functionbase.h main.o: ../../../winix/winixd/functions/functionbase.h
main.o: ../../../winix/winixd/core/request.h main.o: ../../../winix/winixd/core/request.h
main.o: ../../../winix/winixd/core/system.h main.o: ../../../winix/winixd/core/system.h
main.o: ../../../winix/winixd/core/synchro.h main.o: ../../../winix/winixd/core/winixrequest.h
main.o: ../../../winix/winixd/functions/functionparser.h main.o: ../../../winix/winixd/core/winixsystem.h
main.o: ../../../winix/winixd/core/cur.h main.o: ../../../winix/winixd/core/cur.h
main.o: ../../../winix/winixd/core/sessionmanager.h
main.o: ../../../winix/winixd/core/slog.h
main.o: ../../../winix/winixd/functions/functionparser.h
main.o: ../../../winix/winixd/functions/account.h main.o: ../../../winix/winixd/functions/account.h
main.o: ../../../winix/winixd/functions/adduser.h main.o: ../../../winix/winixd/functions/adduser.h
main.o: ../../../winix/winixd/functions/cat.h main.o: ../../../winix/winixd/functions/cat.h
@ -136,17 +145,15 @@ main.o: ../../../winix/winixd/templates/indexpatterns.h
main.o: ../../../winix/winixd/templates/patterns.h main.o: ../../../winix/winixd/templates/patterns.h
main.o: ../../../winix/winixd/templates/changepatterns.h main.o: ../../../winix/winixd/templates/changepatterns.h
main.o: ../../../winix/winixd/templates/htmltextstream.h main.o: ../../../winix/winixd/templates/htmltextstream.h
main.o: ../../../winix/winixd/core/sessionmanager.h
main.o: ../../../winix/winixd/core/compress.h main.o: ../../../winix/winixd/core/compress.h
main.o: ../../../winix/winixd/core/postparser.h main.o: ../../../winix/winixd/core/postparser.h
main.o: ../../../winix/winixd/core/httpsimpleparser.h main.o: ../../../winix/winixd/core/httpsimpleparser.h
main.o: ../../../winix/winixd/core/plugin.h
main.o: ../../../winix/winixd/core/pluginmsg.h
main.o: ../../../pikotools/convert/text.h main.o: ../../../pikotools/convert/text.h
main.o: ../../../winix/winixd/core/cookieparser.h main.o: ../../../winix/winixd/core/cookieparser.h
main.o: ../../../winix/winixd/core/postmultiparser.h main.o: ../../../winix/winixd/core/postmultiparser.h
main.o: ../../../winix/winixd/core/acceptencodingparser.h main.o: ../../../winix/winixd/core/acceptencodingparser.h
main.o: ../../../winix/winixd/core/acceptbaseparser.h main.o: ../../../winix/winixd/core/acceptbaseparser.h
main.o: ../../../pikotools/space/jsontospaceparser.h main.o: ../../../pikotools/space/jsontospaceparser.h
main.o: ../../../winix/winixd/core/plugin.h main.o: ../../../winix/winixd/core/winixrequest.h
main.o: ../../../pikotools/logger/logger.h
main.o: ../../../winix/winixd/core/version.h main.o: ../../../winix/winixd/core/version.h

View File

@ -40,23 +40,16 @@
#include <fcntl.h> #include <fcntl.h>
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
#include "core/log.h"
#include "core/slog.h"
#include "core/app.h" #include "core/app.h"
#include "core/plugin.h"
#include "core/version.h" #include "core/version.h"
#include "utf8/utf8.h" #include "utf8/utf8.h"
#include "core/filelog.h"
namespace Winix namespace Winix
{ {
Log log;
Log nlog; // notify log (used by a notification thread)
SLog slog; // session logger
Plugin plugin;
/* /*
@ -108,7 +101,7 @@ void CloseDescriptors()
void LogInfo(LogManipulators log_level, const char * msg, bool put_version, const char * msg2) void LogInfo(LogManipulators log_level, const char * msg, bool put_version, const char * msg2)
{ {
log << log_level; log << log_level;
log.PrintDate(PT::Date(std::time(0)), app.config.log_time_zone_id); log.PrintDate(PT::Date(std::time(0)));
log << ' ' << msg; log << ' ' << msg;
if( put_version ) if( put_version )
@ -191,12 +184,11 @@ using Winix::app;
if( app.config.demonize && !app.Demonize() ) if( app.config.demonize && !app.Demonize() )
return 4; return 4;
Winix::log.SetTimeZones(&app.system.time_zones);
Winix::log.Init(app.config.log_level, app.config.log_save_each_line, app.config.log_file, app.InitFileLog();
app.config.log_stdout, app.config.log_request);
Winix::nlog.Init(app.config.log_level, true, app.config.log_notify_file, false, 1); Winix::log.SetFileLog(&app.file_log); // IMPROVE ME the singleton will be removed
Winix::log.Init(app.config.log_level, app.config.log_save_each_line, app.config.log_request);
Winix::LogInfo(Winix::log3, "booting Winix", true, ""); Winix::LogInfo(Winix::log3, "booting Winix", true, "");
@ -212,7 +204,7 @@ using Winix::app;
// load plugins before loading sessions - session_manager.LoadSessions() // load plugins before loading sessions - session_manager.LoadSessions()
// because some of the plugins can init its own sessions dates // because some of the plugins can init its own sessions dates
Winix::plugin.LoadPlugins(app.config.plugins_dir, app.config.plugin_file); app.InitPlugins();
// app.Init() starts other threads as well (they will be waiting on the lock) // app.Init() starts other threads as well (they will be waiting on the lock)
if( !app.Init() ) if( !app.Init() )
@ -233,14 +225,7 @@ using Winix::app;
// main loop // main loop
app.Start(); app.Start();
app.Lock();
Winix::plugin.Call((Winix::Session*)0, WINIX_CLOSE);
app.Close(); app.Close();
// now all sessions are cleared
app.Unlock();
app.WaitForThreads();
// now all others threads are terminated
Winix::LogInfo(Winix::log1, "Winix", true, "stopped"); Winix::LogInfo(Winix::log1, "Winix", true, "stopped");
Winix::RemovePidFile(); Winix::RemovePidFile();

View File

@ -23,17 +23,29 @@ notify.o: ../../../ezc/src/objects.h ../../../ezc/src/pattern.h
notify.o: ../../../ezc/src/outstreams.h ../../../ezc/src/expressionparser.h notify.o: ../../../ezc/src/outstreams.h ../../../ezc/src/expressionparser.h
notify.o: ../../../ezc/src/patternparser.h notifythread.h notify.o: ../../../ezc/src/patternparser.h notifythread.h
notify.o: ../../../winix/winixd/core/basethread.h notify.o: ../../../winix/winixd/core/basethread.h
notify.o: ../../../winix/winixd/core/synchro.h templatesnotify.h notify.o: ../../../winix/winixd/core/synchro.h
notify.o: ../../../winix/winixd/core/textstream.h notify.o: ../../../winix/winixd/core/winixmodel.h
notify.o: ../../../winix/winixd/core/winixbase.h
notify.o: ../../../winix/winixd/core/config.h notify.o: ../../../winix/winixd/core/config.h
notify.o: ../../../winix/winixd/core/htmlfilter.h notify.o: ../../../winix/winixd/core/htmlfilter.h
notify.o: ../../../winix/winixd/core/users.h
notify.o: ../../../winix/winixd/core/user.h
notify.o: ../../../winix/winixd/core/ugcontainer.h
notify.o: ../../../winix/winixd/core/log.h notify.o: ../../../winix/winixd/core/log.h
notify.o: ../../../winix/winixd/core/textstream.h notify.o: ../../../winix/winixd/core/textstream.h
notify.o: ../../../winix/winixd/core/logmanipulators.h notify.o: ../../../winix/winixd/core/logmanipulators.h
notify.o: ../../../winix/winixd/core/slog.h ../../../winix/winixd/core/cur.h notify.o: ../../../winix/winixd/core/filelog.h
notify.o: ../../../winix/winixd/core/synchro.h
notify.o: ../../../winix/winixd/core/log.h
notify.o: ../../../winix/winixd/core/filelog.h
notify.o: ../../../winix/winixd/core/lock.h
notify.o: ../../../winix/winixd/core/plugin.h
notify.o: ../../../winix/winixd/core/pluginmsg.h
notify.o: ../../../winix/winixd/core/plugindata.h
notify.o: ../../../winix/winixd/core/winixbase.h templatesnotify.h
notify.o: ../../../winix/winixd/core/textstream.h
notify.o: ../../../winix/winixd/core/users.h
notify.o: ../../../winix/winixd/core/user.h
notify.o: ../../../winix/winixd/core/ugcontainer.h
notify.o: ../../../winix/winixd/core/lastcontainer.h
notify.o: ../../../winix/winixd/core/cur.h
notify.o: ../../../winix/winixd/core/request.h notify.o: ../../../winix/winixd/core/request.h
notify.o: ../../../winix/winixd/core/requesttypes.h notify.o: ../../../winix/winixd/core/requesttypes.h
notify.o: ../../../winix/winixd/core/error.h notify.o: ../../../winix/winixd/core/error.h
@ -41,13 +53,10 @@ notify.o: ../../../winix/winixd/core/config.h
notify.o: ../../../winix/winixd/templates/htmltextstream.h notify.o: ../../../winix/winixd/templates/htmltextstream.h
notify.o: ../../../pikotools/space/spacetojson.h notify.o: ../../../pikotools/space/spacetojson.h
notify.o: ../../../winix/winixd/core/session.h notify.o: ../../../winix/winixd/core/session.h
notify.o: ../../../winix/winixd/core/plugindata.h
notify.o: ../../../winix/winixd/core/rebus.h notify.o: ../../../winix/winixd/core/rebus.h
notify.o: ../../../winix/winixd/core/ipban.h notify.o: ../../../winix/winixd/core/ipban.h
notify.o: ../../../winix/winixd/core/mount.h notify.o: ../../../winix/winixd/core/mount.h ../../../winix/winixd/db/db.h
notify.o: ../../../winix/winixd/core/lastcontainer.h notify.o: ../../../winix/winixd/db/dbbase.h ../../../winix/winixd/db/dbconn.h
notify.o: ../../../winix/winixd/db/db.h ../../../winix/winixd/db/dbbase.h
notify.o: ../../../winix/winixd/db/dbconn.h
notify.o: ../../../winix/winixd/db/dbtextstream.h notify.o: ../../../winix/winixd/db/dbtextstream.h
notify.o: ../../../winix/winixd/core/error.h notify.o: ../../../winix/winixd/core/error.h
notify.o: ../../../winix/winixd/db/dbitemquery.h notify.o: ../../../winix/winixd/db/dbitemquery.h
@ -57,6 +66,7 @@ notify.o: ../../../winix/winixd/core/user.h
notify.o: ../../../winix/winixd/core/group.h notify.o: ../../../winix/winixd/core/group.h
notify.o: ../../../winix/winixd/core/dircontainer.h notify.o: ../../../winix/winixd/core/dircontainer.h
notify.o: ../../../winix/winixd/core/ugcontainer.h notify.o: ../../../winix/winixd/core/ugcontainer.h
notify.o: ../../../winix/winixd/core/winixmodel.h
notify.o: ../../../winix/winixd/templates/templates.h notify.o: ../../../winix/winixd/templates/templates.h
notify.o: ../../../winix/winixd/templates/patterncacher.h notify.o: ../../../winix/winixd/templates/patterncacher.h
notify.o: ../../../winix/winixd/templates/indexpatterns.h notify.o: ../../../winix/winixd/templates/indexpatterns.h
@ -69,7 +79,6 @@ notify.o: ../../../winix/winixd/core/job.h
notify.o: ../../../winix/winixd/core/basethread.h notify.o: ../../../winix/winixd/core/basethread.h
notify.o: ../../../winix/winixd/core/dirs.h notify.o: ../../../winix/winixd/core/dirs.h
notify.o: ../../../winix/winixd/core/dircontainer.h notify.o: ../../../winix/winixd/core/dircontainer.h
notify.o: ../../../winix/winixd/notify/notify.h
notify.o: ../../../winix/winixd/core/mounts.h notify.o: ../../../winix/winixd/core/mounts.h
notify.o: ../../../winix/winixd/core/mountparser.h notify.o: ../../../winix/winixd/core/mountparser.h
notify.o: ../../../winix/winixd/core/crypt.h ../../../winix/winixd/core/run.h notify.o: ../../../winix/winixd/core/crypt.h ../../../winix/winixd/core/run.h
@ -79,6 +88,7 @@ notify.o: ../../../winix/winixd/core/group.h
notify.o: ../../../winix/winixd/core/loadavg.h notify.o: ../../../winix/winixd/core/loadavg.h
notify.o: ../../../winix/winixd/core/image.h notify.o: ../../../winix/winixd/core/image.h
notify.o: ../../../winix/winixd/core/threadmanager.h notify.o: ../../../winix/winixd/core/threadmanager.h
notify.o: ../../../winix/winixd/notify/notify.h
notify.o: ../../../winix/winixd/core/timezones.h notify.o: ../../../winix/winixd/core/timezones.h
notify.o: ../../../winix/winixd/core/timezone.h notify.o: ../../../winix/winixd/core/timezone.h
notify.o: ../../../winix/winixd/core/sessionmanager.h notify.o: ../../../winix/winixd/core/sessionmanager.h
@ -91,53 +101,6 @@ notify.o: ../../../winix/winixd/core/htmlfilter.h
notify.o: ../../../winix/winixd/core/request.h notify.o: ../../../winix/winixd/core/request.h
notify.o: ../../../winix/winixd/core/dirs.h notify.o: ../../../winix/winixd/core/dirs.h
notify.o: ../../../winix/winixd/core/plugin.h notify.o: ../../../winix/winixd/core/plugin.h
notify.o: ../../../winix/winixd/core/pluginmsg.h
notify.o: ../../../winix/winixd/core/sessionmanager.h
notify.o: ../../../winix/winixd/functions/functions.h
notify.o: ../../../winix/winixd/functions/functionbase.h
notify.o: ../../../winix/winixd/core/synchro.h
notify.o: ../../../winix/winixd/functions/functionparser.h
notify.o: ../../../winix/winixd/functions/account.h
notify.o: ../../../winix/winixd/functions/adduser.h
notify.o: ../../../winix/winixd/functions/cat.h
notify.o: ../../../winix/winixd/functions/chmod.h
notify.o: ../../../winix/winixd/functions/privchanger.h
notify.o: ../../../winix/winixd/functions/chown.h
notify.o: ../../../winix/winixd/functions/ckeditor.h
notify.o: ../../../winix/winixd/functions/cp.h
notify.o: ../../../winix/winixd/functions/default.h
notify.o: ../../../winix/winixd/functions/download.h
notify.o: ../../../winix/winixd/functions/emacs.h
notify.o: ../../../winix/winixd/functions/env.h
notify.o: ../../../winix/winixd/functions/imgcrop.h
notify.o: ../../../winix/winixd/functions/last.h
notify.o: ../../../winix/winixd/functions/login.h
notify.o: ../../../winix/winixd/functions/logout.h
notify.o: ../../../winix/winixd/functions/ln.h
notify.o: ../../../winix/winixd/functions/ls.h
notify.o: ../../../winix/winixd/functions/man.h
notify.o: ../../../winix/winixd/functions/meta.h
notify.o: ../../../winix/winixd/functions/mkdir.h
notify.o: ../../../winix/winixd/functions/mv.h
notify.o: ../../../winix/winixd/functions/nicedit.h
notify.o: ../../../winix/winixd/functions/node.h
notify.o: ../../../winix/winixd/functions/passwd.h
notify.o: ../../../winix/winixd/functions/priv.h
notify.o: ../../../winix/winixd/functions/pw.h
notify.o: ../../../winix/winixd/functions/reload.h
notify.o: ../../../winix/winixd/functions/rm.h
notify.o: ../../../winix/winixd/functions/rmuser.h
notify.o: ../../../winix/winixd/functions/sort.h
notify.o: ../../../winix/winixd/functions/specialdefault.h
notify.o: ../../../winix/winixd/functions/stat.h
notify.o: ../../../winix/winixd/functions/subject.h
notify.o: ../../../winix/winixd/functions/template.h
notify.o: ../../../winix/winixd/functions/tinymce.h
notify.o: ../../../winix/winixd/functions/uname.h
notify.o: ../../../winix/winixd/functions/upload.h
notify.o: ../../../winix/winixd/functions/uptime.h
notify.o: ../../../winix/winixd/functions/who.h
notify.o: ../../../winix/winixd/functions/vim.h
notifypool.o: notifypool.h ../../../winix/winixd/templates/locale.h notifypool.o: notifypool.h ../../../winix/winixd/templates/locale.h
notifypool.o: ../../../pikotools/space/spaceparser.h notifypool.o: ../../../pikotools/space/spaceparser.h
notifypool.o: ../../../pikotools/space/space.h notifypool.o: ../../../pikotools/space/space.h
@ -152,15 +115,15 @@ notifypool.o: ../../../pikotools/convert/misc.h
notifypool.o: ../../../pikotools/membuffer/membuffer.h notifypool.o: ../../../pikotools/membuffer/membuffer.h
notifypool.o: ../../../pikotools/textstream/types.h notifypool.o: ../../../pikotools/textstream/types.h
notifythread.o: notifythread.h ../../../winix/winixd/core/basethread.h notifythread.o: notifythread.h ../../../winix/winixd/core/basethread.h
notifythread.o: ../../../winix/winixd/core/synchro.h templatesnotify.h notifythread.o: ../../../winix/winixd/core/synchro.h
notifythread.o: ../../../ezc/src/ezc.h ../../../ezc/src/generator.h notifythread.o: ../../../winix/winixd/core/winixmodel.h
notifythread.o: ../../../ezc/src/blocks.h ../../../ezc/src/item.h notifythread.o: ../../../winix/winixd/core/winixbase.h
notifythread.o: ../../../ezc/src/cache.h ../../../ezc/src/functions.h notifythread.o: ../../../winix/winixd/core/config.h
notifythread.o: ../../../pikotools/utf8/utf8.h ../../../ezc/src/funinfo.h notifythread.o: ../../../pikotools/space/spaceparser.h
notifythread.o: ../../../ezc/src/objects.h ../../../ezc/src/pattern.h notifythread.o: ../../../pikotools/space/space.h
notifythread.o: ../../../ezc/src/outstreams.h notifythread.o: ../../../pikotools/textstream/types.h
notifythread.o: ../../../ezc/src/expressionparser.h notifythread.o: ../../../winix/winixd/core/htmlfilter.h
notifythread.o: ../../../ezc/src/patternparser.h notifythread.o: ../../../winix/winixd/core/log.h
notifythread.o: ../../../winix/winixd/core/textstream.h notifythread.o: ../../../winix/winixd/core/textstream.h
notifythread.o: ../../../pikotools/convert/misc.h notifythread.o: ../../../pikotools/convert/misc.h
notifythread.o: ../../../pikotools/convert/text.h notifythread.o: ../../../pikotools/convert/text.h
@ -171,20 +134,31 @@ notifythread.o: ../../../pikotools/convert/inttostr.h
notifythread.o: ../../../pikotools/convert/strtoint.h notifythread.o: ../../../pikotools/convert/strtoint.h
notifythread.o: ../../../pikotools/textstream/textstream.h notifythread.o: ../../../pikotools/textstream/textstream.h
notifythread.o: ../../../pikotools/membuffer/membuffer.h notifythread.o: ../../../pikotools/membuffer/membuffer.h
notifythread.o: ../../../pikotools/textstream/types.h notifypool.h
notifythread.o: ../../../winix/winixd/templates/locale.h
notifythread.o: ../../../pikotools/space/spaceparser.h
notifythread.o: ../../../pikotools/space/space.h
notifythread.o: ../../../pikotools/textstream/types.h notifythread.o: ../../../pikotools/textstream/types.h
notifythread.o: ../../../winix/winixd/core/config.h notifythread.o: ../../../pikotools/utf8/utf8.h
notifythread.o: ../../../winix/winixd/core/htmlfilter.h notifythread.o: ../../../winix/winixd/core/logmanipulators.h
notifythread.o: ../../../winix/winixd/core/filelog.h
notifythread.o: ../../../winix/winixd/core/synchro.h
notifythread.o: ../../../winix/winixd/core/log.h
notifythread.o: ../../../winix/winixd/core/filelog.h
notifythread.o: ../../../winix/winixd/core/lock.h
notifythread.o: ../../../winix/winixd/core/plugin.h
notifythread.o: ../../../winix/winixd/core/pluginmsg.h
notifythread.o: ../../../winix/winixd/core/plugindata.h
notifythread.o: ../../../winix/winixd/core/winixbase.h templatesnotify.h
notifythread.o: ../../../ezc/src/ezc.h ../../../ezc/src/generator.h
notifythread.o: ../../../ezc/src/blocks.h ../../../ezc/src/item.h
notifythread.o: ../../../ezc/src/cache.h ../../../ezc/src/functions.h
notifythread.o: ../../../ezc/src/funinfo.h ../../../ezc/src/objects.h
notifythread.o: ../../../ezc/src/pattern.h ../../../ezc/src/outstreams.h
notifythread.o: ../../../ezc/src/expressionparser.h
notifythread.o: ../../../ezc/src/patternparser.h
notifythread.o: ../../../winix/winixd/core/textstream.h notifypool.h
notifythread.o: ../../../winix/winixd/templates/locale.h
notifythread.o: ../../../winix/winixd/core/users.h notifythread.o: ../../../winix/winixd/core/users.h
notifythread.o: ../../../winix/winixd/core/user.h notifythread.o: ../../../winix/winixd/core/user.h
notifythread.o: ../../../winix/winixd/core/ugcontainer.h notifythread.o: ../../../winix/winixd/core/ugcontainer.h
notifythread.o: ../../../winix/winixd/core/log.h notifythread.o: ../../../winix/winixd/core/lastcontainer.h
notifythread.o: ../../../winix/winixd/core/textstream.h
notifythread.o: ../../../winix/winixd/core/logmanipulators.h
notifythread.o: ../../../winix/winixd/core/slog.h
notifythread.o: ../../../winix/winixd/core/cur.h notifythread.o: ../../../winix/winixd/core/cur.h
notifythread.o: ../../../winix/winixd/core/request.h notifythread.o: ../../../winix/winixd/core/request.h
notifythread.o: ../../../winix/winixd/core/requesttypes.h notifythread.o: ../../../winix/winixd/core/requesttypes.h
@ -193,11 +167,9 @@ notifythread.o: ../../../winix/winixd/core/config.h
notifythread.o: ../../../winix/winixd/templates/htmltextstream.h notifythread.o: ../../../winix/winixd/templates/htmltextstream.h
notifythread.o: ../../../pikotools/space/spacetojson.h notifythread.o: ../../../pikotools/space/spacetojson.h
notifythread.o: ../../../winix/winixd/core/session.h notifythread.o: ../../../winix/winixd/core/session.h
notifythread.o: ../../../winix/winixd/core/plugindata.h
notifythread.o: ../../../winix/winixd/core/rebus.h notifythread.o: ../../../winix/winixd/core/rebus.h
notifythread.o: ../../../winix/winixd/core/ipban.h notifythread.o: ../../../winix/winixd/core/ipban.h
notifythread.o: ../../../winix/winixd/core/mount.h notifythread.o: ../../../winix/winixd/core/mount.h
notifythread.o: ../../../winix/winixd/core/lastcontainer.h
notifythread.o: ../../../winix/winixd/db/db.h notifythread.o: ../../../winix/winixd/db/db.h
notifythread.o: ../../../winix/winixd/db/dbbase.h notifythread.o: ../../../winix/winixd/db/dbbase.h
notifythread.o: ../../../winix/winixd/db/dbconn.h notifythread.o: ../../../winix/winixd/db/dbconn.h
@ -222,137 +194,21 @@ templatesnotify.o: ../../../ezc/src/objects.h ../../../ezc/src/pattern.h
templatesnotify.o: ../../../ezc/src/outstreams.h templatesnotify.o: ../../../ezc/src/outstreams.h
templatesnotify.o: ../../../ezc/src/expressionparser.h templatesnotify.o: ../../../ezc/src/expressionparser.h
templatesnotify.o: ../../../ezc/src/patternparser.h templatesnotify.o: ../../../ezc/src/patternparser.h
templatesnotify.o: ../../../winix/winixd/core/textstream.h templatesnotify.o: ../../../winix/winixd/core/textstream.h notifypool.h
templatesnotify.o: ../../../pikotools/convert/misc.h templatesnotify.o: ../../../winix/winixd/templates/locale.h
templatesnotify.o: ../../../pikotools/convert/text.h templatesnotify.o: ../../../pikotools/space/spaceparser.h
templatesnotify.o: ../../../pikotools/space/space.h
templatesnotify.o: ../../../pikotools/textstream/types.h
templatesnotify.o: ../../../pikotools/textstream/textstream.h
templatesnotify.o: ../../../pikotools/space/space.h templatesnotify.o: ../../../pikotools/space/space.h
templatesnotify.o: ../../../pikotools/date/date.h templatesnotify.o: ../../../pikotools/date/date.h
templatesnotify.o: ../../../pikotools/convert/convert.h templatesnotify.o: ../../../pikotools/convert/convert.h
templatesnotify.o: ../../../pikotools/convert/inttostr.h templatesnotify.o: ../../../pikotools/convert/inttostr.h
templatesnotify.o: ../../../pikotools/convert/strtoint.h templatesnotify.o: ../../../pikotools/convert/strtoint.h
templatesnotify.o: ../../../pikotools/textstream/textstream.h templatesnotify.o: ../../../pikotools/convert/text.h
templatesnotify.o: ../../../pikotools/convert/misc.h
templatesnotify.o: ../../../pikotools/membuffer/membuffer.h templatesnotify.o: ../../../pikotools/membuffer/membuffer.h
templatesnotify.o: ../../../pikotools/textstream/types.h notifypool.h
templatesnotify.o: ../../../winix/winixd/templates/locale.h
templatesnotify.o: ../../../pikotools/space/spaceparser.h
templatesnotify.o: ../../../pikotools/space/space.h
templatesnotify.o: ../../../pikotools/textstream/types.h templatesnotify.o: ../../../pikotools/textstream/types.h
templatesnotify.o: ../../../winix/winixd/core/plugin.h
templatesnotify.o: ../../../winix/winixd/core/pluginmsg.h
templatesnotify.o: ../../../winix/winixd/core/log.h
templatesnotify.o: ../../../winix/winixd/core/textstream.h
templatesnotify.o: ../../../winix/winixd/core/logmanipulators.h
templatesnotify.o: ../../../winix/winixd/core/slog.h
templatesnotify.o: ../../../winix/winixd/core/cur.h
templatesnotify.o: ../../../winix/winixd/core/request.h
templatesnotify.o: ../../../winix/winixd/core/requesttypes.h
templatesnotify.o: ../../../winix/winixd/core/error.h
templatesnotify.o: ../../../winix/winixd/core/config.h
templatesnotify.o: ../../../winix/winixd/templates/htmltextstream.h
templatesnotify.o: ../../../pikotools/space/spacetojson.h
templatesnotify.o: ../../../winix/winixd/core/session.h
templatesnotify.o: ../../../winix/winixd/core/user.h
templatesnotify.o: ../../../winix/winixd/core/plugindata.h
templatesnotify.o: ../../../winix/winixd/core/rebus.h
templatesnotify.o: ../../../winix/winixd/core/ipban.h
templatesnotify.o: ../../../winix/winixd/core/mount.h
templatesnotify.o: ../../../winix/winixd/core/system.h
templatesnotify.o: ../../../winix/winixd/core/sessionmanager.h
templatesnotify.o: ../../../winix/winixd/core/synchro.h
templatesnotify.o: ../../../winix/winixd/functions/functions.h
templatesnotify.o: ../../../winix/winixd/functions/functionbase.h
templatesnotify.o: ../../../winix/winixd/core/item.h
templatesnotify.o: ../../../winix/winixd/db/db.h
templatesnotify.o: ../../../winix/winixd/db/dbbase.h
templatesnotify.o: ../../../winix/winixd/db/dbconn.h
templatesnotify.o: ../../../winix/winixd/db/dbtextstream.h
templatesnotify.o: ../../../winix/winixd/core/error.h
templatesnotify.o: ../../../winix/winixd/db/dbitemquery.h
templatesnotify.o: ../../../winix/winixd/db/dbitemcolumns.h
templatesnotify.o: ../../../winix/winixd/core/user.h
templatesnotify.o: ../../../winix/winixd/core/group.h
templatesnotify.o: ../../../winix/winixd/core/dircontainer.h
templatesnotify.o: ../../../winix/winixd/core/ugcontainer.h
templatesnotify.o: ../../../winix/winixd/core/request.h
templatesnotify.o: ../../../winix/winixd/core/config.h
templatesnotify.o: ../../../winix/winixd/core/htmlfilter.h
templatesnotify.o: ../../../winix/winixd/core/system.h
templatesnotify.o: ../../../winix/winixd/core/job.h
templatesnotify.o: ../../../winix/winixd/core/basethread.h
templatesnotify.o: ../../../winix/winixd/core/dirs.h
templatesnotify.o: ../../../winix/winixd/core/dircontainer.h
templatesnotify.o: ../../../winix/winixd/notify/notify.h
templatesnotify.o: ../../../winix/winixd/core/mounts.h
templatesnotify.o: ../../../winix/winixd/core/mountparser.h
templatesnotify.o: ../../../winix/winixd/core/crypt.h
templatesnotify.o: ../../../winix/winixd/core/run.h
templatesnotify.o: ../../../winix/winixd/core/users.h
templatesnotify.o: ../../../winix/winixd/core/groups.h
templatesnotify.o: ../../../winix/winixd/core/group.h
templatesnotify.o: ../../../winix/winixd/core/ugcontainer.h
templatesnotify.o: ../../../winix/winixd/core/loadavg.h
templatesnotify.o: ../../../winix/winixd/core/image.h
templatesnotify.o: ../../../winix/winixd/core/threadmanager.h
templatesnotify.o: ../../../winix/winixd/core/timezones.h
templatesnotify.o: ../../../winix/winixd/core/timezone.h
templatesnotify.o: ../../../winix/winixd/core/synchro.h
templatesnotify.o: ../../../winix/winixd/functions/functionparser.h
templatesnotify.o: ../../../winix/winixd/core/cur.h
templatesnotify.o: ../../../winix/winixd/functions/account.h
templatesnotify.o: ../../../winix/winixd/functions/adduser.h
templatesnotify.o: ../../../winix/winixd/functions/cat.h
templatesnotify.o: ../../../winix/winixd/functions/chmod.h
templatesnotify.o: ../../../winix/winixd/functions/privchanger.h
templatesnotify.o: ../../../winix/winixd/functions/chown.h
templatesnotify.o: ../../../winix/winixd/functions/ckeditor.h
templatesnotify.o: ../../../winix/winixd/functions/cp.h
templatesnotify.o: ../../../winix/winixd/functions/default.h
templatesnotify.o: ../../../winix/winixd/functions/download.h
templatesnotify.o: ../../../winix/winixd/functions/emacs.h
templatesnotify.o: ../../../winix/winixd/functions/env.h
templatesnotify.o: ../../../winix/winixd/functions/imgcrop.h
templatesnotify.o: ../../../winix/winixd/functions/last.h
templatesnotify.o: ../../../winix/winixd/templates/locale.h
templatesnotify.o: ../../../winix/winixd/functions/login.h
templatesnotify.o: ../../../winix/winixd/functions/logout.h
templatesnotify.o: ../../../winix/winixd/functions/ln.h
templatesnotify.o: ../../../winix/winixd/functions/ls.h
templatesnotify.o: ../../../winix/winixd/functions/man.h
templatesnotify.o: ../../../winix/winixd/functions/meta.h
templatesnotify.o: ../../../winix/winixd/functions/mkdir.h
templatesnotify.o: ../../../winix/winixd/functions/mv.h
templatesnotify.o: ../../../winix/winixd/functions/nicedit.h
templatesnotify.o: ../../../winix/winixd/functions/node.h
templatesnotify.o: ../../../winix/winixd/functions/passwd.h
templatesnotify.o: ../../../winix/winixd/functions/priv.h
templatesnotify.o: ../../../winix/winixd/functions/pw.h
templatesnotify.o: ../../../winix/winixd/functions/reload.h
templatesnotify.o: ../../../winix/winixd/functions/rm.h
templatesnotify.o: ../../../winix/winixd/functions/rmuser.h
templatesnotify.o: ../../../winix/winixd/functions/sort.h
templatesnotify.o: ../../../winix/winixd/functions/specialdefault.h
templatesnotify.o: ../../../winix/winixd/functions/stat.h
templatesnotify.o: ../../../winix/winixd/functions/subject.h
templatesnotify.o: ../../../winix/winixd/functions/template.h
templatesnotify.o: ../../../winix/winixd/functions/tinymce.h
templatesnotify.o: ../../../winix/winixd/functions/uname.h
templatesnotify.o: ../../../winix/winixd/functions/upload.h
templatesnotify.o: ../../../winix/winixd/functions/uptime.h
templatesnotify.o: ../../../winix/winixd/functions/who.h
templatesnotify.o: ../../../winix/winixd/functions/vim.h
templatesnotify.o: ../../../winix/winixd/core/htmlfilter.h
templatesnotify.o: ../../../winix/winixd/templates/templates.h
templatesnotify.o: ../../../winix/winixd/templates/patterncacher.h
templatesnotify.o: ../../../winix/winixd/templates/indexpatterns.h
templatesnotify.o: ../../../winix/winixd/templates/patterns.h
templatesnotify.o: ../../../winix/winixd/templates/changepatterns.h
templatesnotify.o: ../../../winix/winixd/templates/htmltextstream.h
templatesnotify.o: ../../../winix/winixd/templates/localefilter.h
templatesnotify.o: ../../../winix/winixd/core/sessionmanager.h
templatesnotify.o: ../../../winix/winixd/core/sessioncontainer.h
templatesnotify.o: ../../../winix/winixd/core/ipbancontainer.h
templatesnotify.o: ../../../winix/winixd/core/lastcontainer.h
templatesnotify.o: ../../../winix/winixd/core/sessionidmanager.h
templatesnotify.o: ../../../tito/src/base64.h ../../../tito/src/aes.h
templatesnotify.o: ../../../winix/winixd/core/misc.h templatesnotify.o: ../../../winix/winixd/core/misc.h
templatesnotify.o: ../../../winix/winixd/core/requesttypes.h
templatesnotify.o: ../../../winix/winixd/core/winix_const.h templatesnotify.o: ../../../winix/winixd/core/winix_const.h

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2008-2014, Tomasz Sowa * Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -55,10 +55,10 @@ void Notify::SetCur(Cur * pcur)
} }
void Notify::SetConfig(Config * pconfig) //void Notify::SetConfig(Config * pconfig)
{ //{
config = pconfig; // config = pconfig;
} //}
void Notify::SetUsers(Users * pusers) void Notify::SetUsers(Users * pusers)
@ -77,12 +77,21 @@ void Notify::SetThreadManager(ThreadManager * pmanager)
} }
//void Notify::SetFileLog(FileLog * file_log)
//{
// this->file_log = file_log;
//}
void Notify::Init() void Notify::Init()
{ {
notify_thread.SetConfig(config); //notify_thread.SetConfig(config);
notify_thread.SetUsers(users); notify_thread.SetUsers(users);
notify_thread.SetNotifyPool(&notify_pool); notify_thread.SetNotifyPool(&notify_pool);
notify_thread.SetPatterns(&patterns); notify_thread.SetPatterns(&patterns);
//notify_thread.SetFileLog(file_log);
thread_manager->Add(&notify_thread, L"notifications"); thread_manager->Add(&notify_thread, L"notifications");
patterns.SetDirectories(config->txt_templates_dir, config->txt_templates_dir_default); patterns.SetDirectories(config->txt_templates_dir, config->txt_templates_dir_default);
@ -93,7 +102,7 @@ void Notify::Init()
notify_template_activate_account = AddTemplate(L"notify_confirm_account.txt"); notify_template_activate_account = AddTemplate(L"notify_confirm_account.txt");
notify_template_reset_password = AddTemplate(L"notify_reset_password.txt"); notify_template_reset_password = AddTemplate(L"notify_reset_password.txt");
plugin.Call((Session*)0, WINIX_NOTIFY_ADD_TEMPLATE); plugin->Call((Session*)0, WINIX_NOTIFY_ADD_TEMPLATE);
} }

Some files were not shown because too many files have changed in this diff Show More