merge from branch 0.7.x:

- initial support for morm
- added: WinixBase, WinixModel, WinixSystem, WinixRequest
- logger moved to pikotools




git-svn-id: svn://ttmath.org/publicrep/winix/trunk@1171 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
Tomasz Sowa 2019-03-06 11:53:28 +00:00
commit def0f8d144
172 changed files with 12095 additions and 8109 deletions

View File

@ -5,7 +5,7 @@ include Makefile.dep
# https://www.gnu.org/software/make/manual/html_node/Flavors.html#Flavors
GLOBAL_WORKING_DIR := $(shell pwd)/../..
EZC_ADDITIONAL_INCLUDE := -I$(shell pwd) -I$(GLOBAL_WORKING_DIR)/ezc/src
current_path := $(shell pwd)
global_relative_working_dir := $(shell relative_path $(current_path) $(GLOBAL_WORKING_DIR))
@ -27,21 +27,19 @@ endif
# CXX = g++-4.8
ifndef CXXFLAGS
CXXFLAGS = -Wall -O0 -g -fPIC -pthread -std=c++17 -I/usr/local/include -I/usr/include/postgresql -DEZC_USE_WINIX_LOGGER -DEZC_HAS_SPECIAL_STREAM
CXXFLAGS = -Wall -O0 -g -fPIC -pthread -std=c++17 -I/usr/local/include -I/usr/include/postgresql -DEZC_HAS_SPECIAL_STREAM
endif
ifndef AR
AR = ar
endif
winix_include_paths = -I$(global_relative_working_dir)/winix/winixd -I$(global_relative_working_dir)/ezc/src -I$(global_relative_working_dir)/tito/src -I$(global_relative_working_dir)/pikotools
winix_include_paths = -I$(global_relative_working_dir)/winix/winixd -I$(global_relative_working_dir)/ezc/src -I$(global_relative_working_dir)/tito/src -I$(global_relative_working_dir)/morm/src -I$(global_relative_working_dir)/pikotools
ifndef LDFLAGS
LDFLAGS = -L/usr/local/lib
endif
# this macro is used in ezc's Makefile
EZC_USE_WINIX_LOGGER = yes
# for make install
@ -51,8 +49,6 @@ winix_install_dir = /usr/local/winix
export CXX
export CXXFLAGS
export LDFLAGS
export EZC_USE_WINIX_LOGGER
export EZC_ADDITIONAL_INCLUDE
export GLOBAL_WORKING_DIR
@ -73,7 +69,7 @@ winix.so: $(winix.src.files)
@cd $(GLOBAL_WORKING_DIR)/tito/src ; $(MAKE) -e
@cd $(GLOBAL_WORKING_DIR)/pikotools ; $(MAKE) -e
@cd $(GLOBAL_WORKING_DIR)/morm/src ; $(MAKE) -e
$(CXX) -shared -rdynamic -Wl,-whole-archive -o winix.so $(CXXFLAGS) $(winix_include_paths) core/*.o db/*.o functions/*.o templates/*.o notify/*.o $(GLOBAL_WORKING_DIR)/ezc/src/ezc.a $(GLOBAL_WORKING_DIR)/tito/src/tito.a $(GLOBAL_WORKING_DIR)/pikotools/convert/convert.a $(GLOBAL_WORKING_DIR)/pikotools/utf8/utf8.a $(GLOBAL_WORKING_DIR)/pikotools/space/space.a $(GLOBAL_WORKING_DIR)/pikotools/mainparser/mainparser.a $(GLOBAL_WORKING_DIR)/pikotools/date/date.a $(GLOBAL_WORKING_DIR)/pikotools/logger/logger.a $(GLOBAL_WORKING_DIR)/morm/src/morm.a $(LDFLAGS) -lfcgi -lpq -lz -lpthread -lcurl -Wl,-no-whole-archive
$(CXX) -shared -rdynamic -Wl,-whole-archive -o winix.so $(CXXFLAGS) $(winix_include_paths) core/*.o db/*.o functions/*.o templates/*.o notify/*.o $(GLOBAL_WORKING_DIR)/ezc/src/ezc.a $(GLOBAL_WORKING_DIR)/tito/src/tito.a $(GLOBAL_WORKING_DIR)/pikotools/convert/convert.a $(GLOBAL_WORKING_DIR)/pikotools/utf8/utf8.a $(GLOBAL_WORKING_DIR)/pikotools/space/space.a $(GLOBAL_WORKING_DIR)/pikotools/mainparser/mainparser.a $(GLOBAL_WORKING_DIR)/pikotools/date/date.a $(GLOBAL_WORKING_DIR)/pikotools/log/log.a $(GLOBAL_WORKING_DIR)/morm/src/morm.a $(LDFLAGS) -lfcgi -lpq -lz -lpthread -lcurl -Wl,-no-whole-archive
winix: winix.so $(winix.src.files)

File diff suppressed because one or more lines are too long

View File

@ -3,7 +3,7 @@ include Makefile.o.dep
current_path := $(shell pwd)
global_relative_working_dir := $(shell relative_path $(current_path) $(GLOBAL_WORKING_DIR))
winix_include_paths = -I$(global_relative_working_dir)/winix/winixd -I$(global_relative_working_dir)/ezc/src -I$(global_relative_working_dir)/tito/src -I$(global_relative_working_dir)/pikotools
winix_include_paths = -I$(global_relative_working_dir)/winix/winixd -I$(global_relative_working_dir)/ezc/src -I$(global_relative_working_dir)/tito/src -I$(global_relative_working_dir)/morm/src -I$(global_relative_working_dir)/pikotools
all: $(o)

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.
*
* Redistribution and use in source and binary forms, with or without
@ -36,6 +36,7 @@
#define headerfile_winix_core_acceptbaseparser
#include <string>
#include "winixbase.h"
namespace Winix
@ -46,7 +47,7 @@ namespace Winix
// sample (you must create your own class derived from this one):
// object.Parse(L" text/html ; , ; q = 45, application / xhtml+xml ; q = 0.4 , application/xml ; q = 0.9 , */* ; q = 0.8 ");
class AcceptBaseParser
class AcceptBaseParser : public WinixBase
{
public:

View File

@ -52,6 +52,7 @@
#include "convert/convert.h"
namespace Winix
{
@ -64,39 +65,83 @@ App::App()
last_sessions_save = std::time(0);
fcgi_socket = -1;
file_log.set_synchro(&synchro);
file_log.set_time_zones(&system.time_zones);
log.SetLogBuffer(&log_buffer);
log.SetFileLog(&file_log);
// 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);
config.SetLogBuffer(&log_buffer);
// temporary there is only one request
cur.request = &req;
cur.session = session_manager.GetTmpSession();
cur.mount = system.mounts.GetEmptyMount();
db_conn.set_dependency(&winix_base);
db.set_dependency(&winix_base);
db.SetConn(db_conn);
plugin.set_dependency(&winix_base);
plugin.SetDb(&db);
plugin.SetConfig(&config);
//plugin.SetConfig(&config);
plugin.SetCur(&cur);
plugin.SetSystem(&system);
plugin.SetFunctions(&functions);
plugin.SetTemplates(&templates);
plugin.SetSynchro(&synchro);
//plugin.SetSynchro(&synchro);
plugin.SetSessionManager(&session_manager);
plugin.SetWinixRequest(&winix_request);
req.SetConfig(&config);
functions.SetConfig(&config);
functions.set_dependency(&winix_request);
// functions.set_config(&config);
// functions.set_file_log(&file_log);
// functions.set_model_connector(&model_connector);
// functions.set_synchro(&synchro);
//functions.SetConfig(&config);
functions.SetCur(&cur);
functions.SetDb(&db);
functions.SetSystem(&system);
functions.SetTemplates(&templates);
functions.SetSynchro(&synchro);
//functions.SetSynchro(&synchro);
functions.SetSessionManager(&session_manager);
system.SetConfig(&config);
system.set_dependency(&winix_model);
//system.SetConfig(&config);
system.SetCur(&cur);
system.SetDb(&db);
system.SetSynchro(&synchro);
//system.SetSynchro(&synchro);
system.SetFunctions(&functions);
system.SetSessionManager(&session_manager);
templates.set_dependency(&winix_request);
templates.SetConfig(&config);
templates.SetCur(&cur);
templates.SetDb(&db);
@ -104,20 +149,39 @@ App::App()
templates.SetFunctions(&functions);
templates.SetSessionManager(&session_manager);
session_manager.set_dependency(&winix_model); // zobaczyc czy wskoczy do przeciazonej metody w session manager
session_manager.SetLastContainer(&system.users.last);
session_manager.SetConfig(&config);
session_manager.SetCur(&cur);
session_manager.SetSystem(&system);
session_manager.SetSynchro(&synchro);
post_multi_parser.set_dependency(&winix_base);
post_multi_parser.SetConfig(&config);
slog.SetCur(&cur);
slog.SetLocale(&TemplatesFunctions::locale);
}
void App::InitLoggers()
{
file_log.init(config.log_file, config.log_stdout, config.log_level, config.log_save_each_line, config.log_time_zone_id);
log.SetMaxRequests(config.log_request);
}
Log & App::GetMainLog()
{
return log;
}
void App::InitPlugins()
{
plugin.LoadPlugins(config.plugins_dir, config.plugin_file);
}
bool App::InitFCGI(char * sock, char * sock_user, char * sock_group)
{
if( !WideToUTF8(config.fcgi_socket, sock, WINIX_OS_PATH_SIZE) )
@ -213,14 +277,25 @@ return true;
bool App::Init()
{
postgresql_connector.set_conn_param(config.db_database, config.db_user, config.db_pass);
postgresql_connector.set_logger(log);
postgresql_connector.set_log_queries(config.log_db_query);
postgresql_connector.wait_for_connection();
model_connector.set_flat_connector(json_connector);
model_connector.set_db_connector(postgresql_connector);
//model_connector.set_doc_connector(doc_html_connector);
db_conn.SetConnParam(config.db_database, config.db_user, config.db_pass);
db_conn.WaitForConnection();
db.PostgreSQLsmallerThan10(config.db_postgresql_smaller_than_10);
db.LogQueries(config.log_db_query);
cur.request->Clear();
compress.set_dependency(&winix_base);
compress.Init();
system.Init();
functions.Init();
templates.Init(); // init templates after functions are created
@ -234,9 +309,14 @@ bool App::Init()
CreateStaticTree();
post_parser.set_dependency(&winix_model);
post_parser.LogValueSize(config.log_post_value_size);
// post_multi_parser has a pointer to the config
cookie_parser.set_dependency(&winix_model);
accept_encoding_parser.set_dependency(&winix_base);
plugin.Call((Session*)0, WINIX_PLUGIN_INIT);
return true;
@ -246,10 +326,21 @@ return true;
void App::Close()
{
{
Winix::Lock lock(synchro);
plugin.Call((Winix::Session*)0, WINIX_CLOSE);
session_manager.SaveSessions();
session_manager.DeleteSessions();
cur.request->Clear();
session_manager.UninitTmpSession();
// now all sessions are cleared
}
WaitForThreads();
// now all others threads are terminated
}
@ -673,7 +764,9 @@ void App::Make()
if( cur.session->ip_ban && cur.session->ip_ban->IsIPBanned() )
{
PT::Date date(cur.session->ip_ban->expires);
slog << logerror << T("this_ip_is_banned_until") << ' ' << date << " UTC" << logend;
// IMPROVE ME there is no slog now
//slog << logerror << T("this_ip_is_banned_until") << ' ' << date << " UTC" << logend;
cur.request->status = WINIX_ERR_PERMISSION_DENIED;
}
@ -717,12 +810,6 @@ void App::Make()
return;
}
if( !cur.request->info_serializer )
{
json_generic_serializer.Clear(); // !! IMPROVE ME add to the end of a request
cur.request->info_serializer = &json_generic_serializer;
}
plugin.Call(WINIX_CONTENT_MAKE);
MakePage();
}
@ -972,7 +1059,7 @@ void App::SetSubdomain()
void App::LogAccess()
{
log << log1;
log.PrintDate(cur.request->start_date, config.log_time_zone_id);
log.PrintDate(cur.request->start_date);
log << ' '
<< cur.request->ip_str << ' '
@ -1393,7 +1480,7 @@ void App::PrepareHeaders(bool compressing, int compress_encoding, Header header,
if( cur.request->send_as_attachment )
AddHeader(L"Content-Disposition", L"attachment");
if( !cur.request->redirect_to.empty() )
if( !cur.request->redirect_to.empty() && !cur.request->return_json )
{
PrepareHeadersRedirect();
}
@ -1417,6 +1504,23 @@ void App::PrepareHeaders(bool compressing, int compress_encoding, Header header,
}
void App::PrepareStandardJSONFields()
{
PT::Space & info = cur.request->info;
if( !info.GetFirstValue(L"status") )
{
info.Add(L"status", cur.request->status);
}
if( !cur.request->redirect_to.empty() && !info.GetFirstValue(L"redirect_to") )
{
info.Add(L"redirect_to", cur.request->redirect_to);
}
}
void App::FilterContent()
{
@ -1525,9 +1629,23 @@ void App::SelectCompression(size_t source_len, bool & compression_allowed, int &
bool App::CanSendContent()
{
if( !cur.request->redirect_to.empty() || !cur.request->x_sendfile.empty() )
// if there is a redirect or a file to send then we do not send a content
if( !cur.request->x_sendfile.empty() )
{
// if there is a file to send then we do not send a content
return false;
}
if( cur.request->return_json )
{
// if there is a redirect flag then it will be put to info struct
return true;
}
if( !cur.request->redirect_to.empty() )
{
// if there is a redirect and no json is requred then we do not send the content
return false;
}
/*
we don't have to check the HEAD method
@ -1692,6 +1810,15 @@ int compress_encoding;
void App::SendAnswer()
{
if( !cur.request->info_serializer )
{
json_generic_serializer.Clear(); // !! IMPROVE ME add to the end of a request
cur.request->info_serializer = &json_generic_serializer;
}
if( cur.request->return_json )
PrepareStandardJSONFields();
if( cur.request->send_bin_stream )
SendBinaryAnswer();
else
@ -1816,6 +1943,8 @@ void App::LogUserGroups()
{
LogUsers();
LogGroups();
log << log3 << "base_url: " << config.base_url << logend;
}

View File

@ -45,11 +45,6 @@
#include <errno.h>
#include <fcgiapp.h>
#include "config.h"
#include "system.h"
#include "mounts.h"
#include "request.h"
#include "synchro.h"
#include "sessionmanager.h"
#include "db/db.h"
#include "functions/functions.h"
@ -61,6 +56,10 @@
#include "acceptencodingparser.h"
#include "space/jsontospaceparser.h"
#include "winixrequest.h"
#include "log/log.h"
#include "filelog.h"
namespace Winix
{
@ -76,6 +75,9 @@ public:
bool InitFCGI();
bool DropPrivileges();
void InitLoggers();
Log & GetMainLog();
void InitPlugins();
bool Init();
void Start();
void Close();
@ -101,7 +103,7 @@ public:
// users sessions
SessionManager session_manager;
// database
// database (DEPRACATED)
Db db;
DbConn db_conn;
@ -129,6 +131,8 @@ public:
Templates templates;
private:
enum Header
@ -162,6 +166,29 @@ private:
std::wstring http_header;
std::string http_header_8bit;
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
PT::WTextStream log_buffer;
// logger only for App object
Log log;
// file logger, one object for every Log objects
FileLog file_log;
bool InitFCGI(char * sock, char * sock_user, char * sock_group);
bool InitFCGIChmodChownSocket(char * sock, char * sock_user, char * sock_group);
@ -223,6 +250,7 @@ private:
void PrepareHeadersCompression(int compress_encoding);
void PrepareHeadersNormal(Header header, size_t output_size);
void PrepareHeaders(bool compressing, int compress_encoding, Header header, size_t output_size);
void PrepareStandardJSONFields();
int SelectDeflateVersion();
void SelectCompression(size_t source_len, bool & compression_allowed, int & compression_encoding);
bool CanSendContent();

View File

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

View File

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

View File

@ -34,7 +34,6 @@
#include "config.h"
#include "log.h"
#include "plugin.h"
#include "misc.h"
#include "crypt.h"
@ -50,9 +49,16 @@ Config::Config()
}
void Config::SetFileLog(FileLog * file_log)
{
log.SetFileLog(file_log);
}
//!! czy tu w ogole mozemy uzywac log << ?
//!! przeciez jeszcze nie zostal przetworzony plik konfiguracyjny
void Config::SetLogBuffer(PT::WTextStream * log_buffer)
{
log.SetLogBuffer(log_buffer);
}
void Config::ShowError()
@ -130,7 +136,6 @@ void Config::AssignValues(bool stdout_is_closed)
additional_groups = Bool(L"additional_groups", true);
log_file = Text(L"log_file");
log_notify_file = Text(L"log_notify_file");
log_delimiter = Text(L"log_delimiter", L"---------------------------------------------------------------------------------");
fcgi_socket = Text(L"fcgi_socket");
fcgi_socket_chmod = Int(L"fcgi_socket_chmod", 0770);
@ -322,11 +327,6 @@ void Config::AssignValues(bool stdout_is_closed)
void Config::SetAdditionalVariables()
{
if( html_filter_orphans_mode_str == L"160" )
html_filter_orphans_mode = HTMLFilter::orphan_160space;
else
html_filter_orphans_mode = HTMLFilter::orphan_nbsp;
for(size_t i=0 ; i<static_dirs.size() ; ++i)
NoLastSlash(static_dirs[i]);

View File

@ -37,7 +37,9 @@
#include <string>
#include "space/spaceparser.h"
#include "htmlfilter.h"
#include "log.h"
#include "filelog.h"
namespace Winix
@ -80,8 +82,8 @@ public:
// default: true
bool additional_groups;
// log file name, log file name for notifications (sending emails, etc)
std::wstring log_file, log_notify_file;
// log file name
std::wstring log_file;
// the log level (how much info should be inserted to logs)
// 1 - minimum
@ -328,7 +330,6 @@ public:
// either: "nbsp" or "160"
// default: "nbsp"
std::wstring html_filter_orphans_mode_str;
HTMLFilter::OrphanMode html_filter_orphans_mode;
// the html nofilter tag
// content betweeng these tags (opening and closing) will not be filtered
@ -819,10 +820,15 @@ public:
PT::Space space;
void SetFileLog(FileLog * file_log);
void SetLogBuffer(PT::WTextStream * log_buffer);
private:
PT::SpaceParser parser;
bool errors_to_stdout;
Log log;
void ShowError();
void AssignValues(bool stdout_is_closed);

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2011-2014, Tomasz Sowa
* Copyright (c) 2011-2018, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -36,6 +36,7 @@
#include "crypt.h"
#include "utf8/utf8.h"
#include "log.h"
#include "misc.h"
@ -44,12 +45,18 @@ namespace Winix
void Crypt::SetConfig(Config * pconfig)
{
config = pconfig;
}
//void Crypt::SetConfig(Config * pconfig)
//{
// config = pconfig;
//}
void Crypt::set_dependency(WinixBase * winix_base)
{
WinixBase::set_dependency(winix_base);
run.set_dependency(winix_base);
}
char Crypt::ConvertToHexForm(int val)
{
@ -70,6 +77,7 @@ bool Crypt::HashBin(int hash, const char * in, size_t inlen, std::string & out)
return false;
run.Clear();
run.set_dependency(this);
PT::WideToUTF8(config->opensll_path, command);
run.Cmd(command);
run.Par("dgst");

View File

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

View File

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

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2008-2014, Tomasz Sowa
* Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -34,7 +34,7 @@
#include "dirs.h"
#include "error.h"
#include "log.h"
#include "notify/notify.h"
namespace Winix
@ -60,6 +60,13 @@ void Dirs::SetNotify(Notify * pnotify)
}
void Dirs::set_dependency(WinixModel * winix_model)
{
WinixModel::set_dependency(winix_model);
dir_tab.set_dependency(winix_model);
}
void Dirs::Clear()
{
dir_tab.Clear();

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2008-2014, Tomasz Sowa
* Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -44,19 +44,21 @@
#include "dircontainer.h"
#include "db/db.h"
#include "request.h"
#include "notify/notify.h"
#include "winixmodel.h"
namespace Winix
{
class Notify;
// !! IMPROVE ME
// we do not support '..' in a path (for simplicity and security reasons)
// (we will support '..' in the future)
class Dirs
class Dirs : public WinixModel
{
public:
@ -67,6 +69,8 @@ public:
void SetDb(Db * pdb);
void SetNotify(Notify * pnotify);
void set_dependency(WinixModel * winix_model);
// these methods return false if there is no such a dir
bool IsDir(long dir_id);
bool GetDirChilds(long parent_id, std::vector<Item*> & childs_tab); // !! zamienic na GetChilds()

134
winixd/core/filelog.cpp Normal file
View File

@ -0,0 +1,134 @@
/*
* 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 "filelog.h"
#include <ctime>
#include <string.h>
#include "utf8/utf8.h"
#include "timezones.h"
namespace Winix
{
FileLog::FileLog()
{
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, int log_level, bool save_each_line, size_t log_time_zone_id)
{
PT::FileLog::init(log_file, log_stdout, log_level, save_each_line);
this->log_time_zone_id = log_time_zone_id;
}
void FileLog::set_time_zones(TimeZones * time_zones)
{
this->time_zones = time_zones;
}
int FileLog::get_log_level()
{
return log_level;
}
bool FileLog::should_save_each_line()
{
return save_each_line;
}
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;
}
}
bool FileLog::synchro_lock()
{
return synchro->Lock();
}
void FileLog::synchro_unlock()
{
synchro->Unlock();
}
} // namespace Winix

92
winixd/core/filelog.h Normal file
View File

@ -0,0 +1,92 @@
/*
* 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 "core/synchro.h"
#include "log/log.h"
namespace Winix
{
class TimeZones;
class FileLog : public PT::FileLog
{
public:
FileLog();
virtual ~FileLog();
void set_synchro(Synchro * synchro);
void init(const std::wstring & log_file, bool log_stdout, int log_level, bool save_each_line, size_t log_time_zone_id);
void set_time_zones(TimeZones * time_zones);
PT::Date get_local_date(const PT::Date & date);
int get_log_level();
bool should_save_each_line();
protected:
size_t log_time_zone_id;
TimeZones * time_zones;
Synchro * synchro;
virtual bool synchro_lock();
virtual void synchro_unlock();
};
} // namespace Winix
#endif

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2008-2014, Tomasz Sowa
* Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -46,6 +46,13 @@ Groups::Groups()
}
void Groups::set_dependency(WinixModel * winix_model)
{
WinixModel::set_dependency(winix_model);
table.set_dependency(winix_model);
}
void Groups::Clear()
{
table.Clear();

View File

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

View File

@ -234,9 +234,12 @@ void HTMLFilter::ClearOrphans()
void HTMLFilter::OrphansMode(HTMLFilter::OrphanMode mode)
void HTMLFilter::OrphansMode(const std::wstring & orphan_mode_str)
{
orphan_mode = mode;
if( orphan_mode_str == L"160" )
orphan_mode = orphan_160space;
else
orphan_mode = orphan_nbsp;
}

View File

@ -39,6 +39,7 @@
#include <map>
#include <vector>
#include <algorithm>
#include "core/winixbase.h"
namespace Winix
@ -86,7 +87,7 @@ namespace Winix
the filter recognizes xml simple tags (with / at the end) such as: <br />
*/
class HTMLFilter
class HTMLFilter : public WinixBase
{
public:
@ -146,7 +147,7 @@ public:
// check 'orphans' for the specicic language
// if an orphan is detected then the non-break space ("&nbsp;" or ascii 160 code) will be put
// default disable (lang_none)
void OrphansMode(OrphanMode mode = orphan_nbsp);
void OrphansMode(const std::wstring & orphan_mode);
// skipping some unsafe tags
// (script, iframe, frame, frameset, applet, head, meta, html, link, body, ...)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2008-2014, Tomasz Sowa
* Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -36,7 +36,7 @@
#include <ctime>
#include <string.h>
#include "utf8/utf8.h"
#include "timezones.h"
namespace Winix
@ -46,91 +46,47 @@ namespace Winix
Log::Log()
{
log_level = 1;
current_level = 100; // nothing to log (call Init() first)
request = 0;
max_requests = 1;
lines = 0;
max_lines = 5000;
log_file_open = false;
time_zones = 0;
}
Log::~Log()
{
SaveLogAndClear();
}
void Log::SetTimeZones(TimeZones * ptime_zones)
void Log::SetDependency(Log * log)
{
time_zones = ptime_zones;
buffer = log->buffer;
file_log = log->file_log;
}
int Log::LogLevel()
void Log::SetMaxRequests(int max_requests)
{
return log_level;
this->max_requests = max_requests;
}
void Log::Init(int log_level_, bool save_each_line_, const std::wstring & log_file_, bool log_std, int log_max_requests)
void Log::PrintDate(const PT::Date & date)
{
log_level = log_level_;
log_stdout = log_std;
max_requests = log_max_requests;
save_each_line = save_each_line_;
FileLog * winix_file_log = dynamic_cast<FileLog*>(file_log);
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()
{
if( !log_file.empty() )
{
file.open( log_file.c_str(), std::ios_base::out | std::ios_base::app );
log_file_open = true;
}
}
void Log::PrintDate(const PT::Date & date, size_t time_zone_id)
{
if( time_zones )
{
TimeZone * tz = time_zones->GetZone(time_zone_id);
if( tz )
{
PT::Date local_date = tz->ToLocal(date);
log << local_date;
}
if( winix_file_log )
(*this) << winix_file_log->get_local_date(date);
else
{
(*this) << date << " UTC"; // unknown time zone identifier
}
}
else
{
(*this) << date << " UTC"; // time_zones object was not set
}
(*this) << date;
}
Log & Log::operator<<(const void * s)
{
if( current_level > log_level )
return *this;
buffer << s;
PT::Log::operator<<(s);
return *this;
}
@ -138,25 +94,15 @@ Log & Log::operator<<(const void * s)
Log & Log::operator<<(const char * s)
{
if( current_level > log_level )
PT::Log::operator<<(s);
return *this;
if( !s )
return *this;
buffer << s;
return *this;
}
Log & Log::operator<<(const std::string & s)
{
if( current_level > log_level )
return *this;
buffer << s;
PT::Log::operator<<(s);
return *this;
}
@ -164,10 +110,7 @@ Log & Log::operator<<(const std::string & s)
Log & Log::operator<<(const std::string * s)
{
if( current_level > log_level )
return *this;
buffer << *s;
PT::Log::operator<<(s);
return *this;
}
@ -178,24 +121,15 @@ Log & Log::operator<<(const std::string * s)
Log & Log::operator<<(const wchar_t * s)
{
if( current_level <= log_level )
{
if( s )
buffer << s;
}
return *this;
PT::Log::operator<<(s);
return *this;
}
Log & Log::operator<<(const std::wstring & s)
{
if( current_level <= log_level )
{
buffer << s;
}
PT::Log::operator<<(s);
return *this;
}
@ -203,25 +137,15 @@ Log & Log::operator<<(const std::wstring & s)
Log & Log::operator<<(const std::wstring * s)
{
if( current_level <= log_level )
{
buffer << *s;
}
PT::Log::operator<<(s);
return *this;
}
Log & Log::operator<<(int s)
{
if( current_level <= log_level )
{
buffer << s;
}
PT::Log::operator<<(s);
return *this;
}
@ -229,11 +153,7 @@ Log & Log::operator<<(int s)
Log & Log::operator<<(long s)
{
if( current_level <= log_level )
{
buffer << s;
}
PT::Log::operator<<(s);
return *this;
}
@ -242,33 +162,21 @@ Log & Log::operator<<(long s)
Log & Log::operator<<(char s)
{
if( current_level <= log_level )
{
buffer << s;
}
PT::Log::operator<<(s);
return *this;
}
Log & Log::operator<<(wchar_t s)
{
if( current_level <= log_level )
{
buffer << s;
}
PT::Log::operator<<(s);
return *this;
}
Log & Log::operator<<(size_t s)
{
if( current_level <= log_level )
{
buffer << s;
}
PT::Log::operator<<(s);
return *this;
}
@ -276,11 +184,7 @@ Log & Log::operator<<(size_t s)
Log & Log::operator<<(double s)
{
if( current_level <= log_level )
{
buffer << s;
}
PT::Log::operator<<(s);
return *this;
}
@ -288,24 +192,16 @@ Log & Log::operator<<(double s)
Log & Log::operator<<(const PT::Space & s)
{
if( current_level <= log_level )
{
buffer << s;
}
return *this;
PT::Log::operator<<(s);
return *this;
}
Log & Log::operator<<(const PT::Date & date)
{
if( current_level <= log_level )
{
buffer << date;
}
return *this;
PT::Log::operator<<(date);
return *this;
}
@ -314,42 +210,38 @@ Log & Log::operator<<(LogManipulators m)
{
switch(m)
{
case logend:
if( current_level <= log_level )
case LogManipulators::log1:
PT::Log::operator<<(PT::Log::log1);
break;
case LogManipulators::log2:
PT::Log::operator<<(PT::Log::log2);
break;
case LogManipulators::log3:
PT::Log::operator<<(PT::Log::log3);
break;
case LogManipulators::log4:
PT::Log::operator<<(PT::Log::log4);
break;
case LogManipulators::logend:
PT::Log::operator<<(PT::Log::logend);
break;
case LogManipulators::logsave:
PT::Log::operator<<(PT::Log::logsave);
break;
case LogManipulators::logendrequest:
if( ++request >= max_requests )
{
buffer << '\n';
lines += 1;
if( save_each_line )
SaveLogAndClear();
save_log_and_clear();
request = 0;
}
break;
case logsave:
SaveLogAndClear();
break;
case logendrequest:
if( ++request >= max_requests || lines > max_lines )
SaveLogAndClear();
break;
case log1:
current_level = 1;
break;
case log2:
current_level = 2;
break;
case log3:
current_level = 3;
break;
case log4:
current_level = 4;
break;
default:
break;
}
@ -358,81 +250,7 @@ return *this;
}
char Log::GetHEXdigit(unsigned char c)
{
if( c < 10 )
return c + '0';
return c - 10 + 'A';
}
void Log::ToHEX(char * buf, unsigned char c)
{
buf[0] = GetHEXdigit(c >> 4);
buf[1] = GetHEXdigit(c & 0xf);
buf[2] = 0;
}
void Log::LogBinary(const char * blob, size_t blob_len)
{
size_t i=0;
char buf[3];
while( i < blob_len )
{
size_t oldi = i;
for(size_t a=0 ; a<16 ; ++a)
{
if( i < blob_len )
{
ToHEX(buf, blob[i]);
buffer << buf << ' ';
++i;
}
else
{
buffer << " ";
}
if( a == 7 )
{
if( i < blob_len )
buffer << "- ";
else
buffer << " ";
}
}
i = oldi;
buffer << ' ';
for(size_t a=0 ; a<16 && i<blob_len ; ++a, ++i)
{
if( blob[i] > 31 && blob[i] < 127 )
buffer << blob[i];
else
buffer << '.';
}
(*this) << logend;
}
}
void Log::LogBinary(const std::string & blob)
{
LogBinary(blob.c_str(), blob.size());
}
void Log::SystemErr(int err)
Log & Log::SystemErr(int err)
{
(*this) << "errno: " << err;
@ -440,43 +258,37 @@ void Log::SystemErr(int err)
if( err_msg )
(*this) << " (" << err_msg << ")";
return *this;
}
void Log::SaveLogAndClear()
{
SaveLog();
buffer.Clear();
request = 0;
lines = 0;
Log & Log::LogString(const std::string & value, size_t max_size)
{
PT::Log::LogString(value, max_size);
return *this;
}
void Log::SaveLog()
Log & Log::LogString(const std::wstring & value, size_t max_size)
{
if( buffer.Str().empty() )
return;
PT::Log::LogString(value, max_size);
return *this;
}
if( log_stdout )
PT::WideToUTF8(buffer.Str(), std::cout);
if( log_file.empty() )
return;
Log & Log::LogBinary(const char * blob, size_t blob_len)
{
PT::Log::LogBinary(blob, blob_len);
return *this;
}
if( !log_file_open || !file )
{
file.close();
file.clear();
OpenFile();
if( !file )
return;
}
PT::WideToUTF8(buffer.Str(), file);
file.flush();
Log & Log::LogBinary(const std::string & blob)
{
PT::Log::LogBinary(blob);
return *this;
}

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2008-2014, Tomasz Sowa
* Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -40,9 +40,10 @@
#include <fstream>
#include <iostream>
#include <string>
#include "textstream.h"
#include "logmanipulators.h"
#include "textstream/textstream.h"
#include "filelog.h"
#include "log/log.h"
namespace Winix
@ -50,71 +51,51 @@ namespace Winix
class TimeZones;
class Log
class Log : public PT::Log
{
public:
Log();
~Log();
virtual ~Log();
void SetTimeZones(TimeZones * ptime_zones);
void Init(int log_level_, bool save_each_line_, const std::wstring & log_file_, bool log_std, int log_max_requests);
virtual void SetDependency(Log * log);
Log & operator<<(const void * s);
Log & operator<<(const char * s);
Log & operator<<(const std::string * s);
Log & operator<<(const std::string & s);
Log & operator<<(const wchar_t * s);
Log & operator<<(const std::wstring * s);
Log & operator<<(const std::wstring & s);
Log & operator<<(int s);
Log & operator<<(long s);
Log & operator<<(char s);
Log & operator<<(wchar_t s);
Log & operator<<(size_t s);
Log & operator<<(double s);
Log & operator<<(const PT::Space & space);
Log & operator<<(LogManipulators m);
Log & operator<<(const PT::Date & date);
virtual void SetMaxRequests(int max_requests);
void PrintDate(const PT::Date & date, size_t time_zone_id);
virtual Log & operator<<(const void * s);
virtual Log & operator<<(const char * s);
virtual Log & operator<<(const std::string * s);
virtual Log & operator<<(const std::string & s);
virtual Log & operator<<(const wchar_t * s);
virtual Log & operator<<(const std::wstring * s);
virtual Log & operator<<(const std::wstring & s);
virtual Log & operator<<(int s);
virtual Log & operator<<(long s);
virtual Log & operator<<(char s);
virtual Log & operator<<(wchar_t s);
virtual Log & operator<<(size_t s);
virtual Log & operator<<(double s);
virtual Log & operator<<(const PT::Space & space);
virtual Log & operator<<(LogManipulators m);
virtual Log & operator<<(const PT::Date & date);
virtual void PrintDate(const PT::Date & date);
template<typename char_type, size_t stack_size, size_t heap_block_size>
Log & operator<<(const PT::TextStreamBase<char_type, stack_size, heap_block_size> & buf);
template<class StringType>
void LogString(const StringType & value, size_t max_size);
virtual Log & LogString(const std::string & value, size_t max_size);
virtual Log & LogString(const std::wstring & value, size_t max_size);
void LogBinary(const char * blob, size_t blob_len);
void LogBinary(const std::string & blob);
virtual Log & LogBinary(const char * blob, size_t blob_len);
virtual Log & LogBinary(const std::string & blob);
void SystemErr(int err);
void SaveLog();
void SaveLogAndClear();
int LogLevel();
virtual Log & SystemErr(int err);
private:
// time zones for printing the time in the log file
TimeZones * time_zones;
// buffer for the log
TextStream<std::wstring> buffer;
// log lovel from the config file
int log_level;
// current level set by a modifier (e.g. log << log3)
int current_level;
// current request for logging
// starts from zero and incremented after logendrequest modifier
int request;
@ -122,78 +103,25 @@ private:
// how many request to save at once
int max_requests;
// file log
std::string log_file;
std::ofstream file;
// logging to stdout
bool log_stdout;
// how many lines there are in the buffer
int lines;
// is the config file already open
bool log_file_open;
// how many lines can be in the config buffer
// default: 5000
int max_lines;
// whether to save each line (for debug)
bool save_each_line;
void OpenFile();
char GetHEXdigit(unsigned char c);
void ToHEX(char * buf, unsigned char c);
};
template<class StringType>
void Log::LogString(const StringType & value, size_t max_size)
{
size_t min_size = value.size() < max_size ? value.size() : max_size;
if( current_level <= log_level )
{
for(size_t i=0 ; i<min_size ; ++i)
{
if( value[i] < 32 )
buffer << '.';
else
buffer << value[i];
}
}
}
template<typename char_type, size_t stack_size, size_t heap_block_size>
Log & Log::operator<<(const PT::TextStreamBase<char_type, stack_size, heap_block_size> & buf)
{
if( current_level <= log_level )
buffer << buf;
return *this;
PT::Log::operator<<(buf);
return *this;
}
extern Log log;
extern Log nlog;
} // namespace Winix
// for convenience, we have to use only #include "log.h" in the winix
#include "slog.h"
#endif

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2011-2014, Tomasz Sowa
* Copyright (c) 2011-2018, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -35,13 +35,13 @@
#ifndef headerfile_winix_core_logmanipulators
#define headerfile_winix_core_logmanipulators
#include "log/log.h"
namespace Winix
{
/*
log1 - the first level
log2
@ -65,10 +65,12 @@ enum LogManipulators
log2,
log3,
log4,
logend,
logendrequest,
logsave,
logendrequest,
loginfo,
logerror,
logwarning

View File

@ -38,7 +38,6 @@
#include <fstream>
#include <cstdlib>
#include "misc.h"
#include "log.h"
#include "templates/templates.h"
#include "convert/convert.h"
@ -882,7 +881,7 @@ char dir_name[WINIX_OS_PATH_SIZE];
if( mkdir(dir_name, 0777) < 0 )
{
log << log1 << "Can't create a directory on fs: " << dir << logend;
//log << log1 << "Can't create a directory on fs: " << dir << logend;
return false;
}
@ -958,7 +957,7 @@ char buffer[512];
if( getgrnam_r(group_name, &gr, buffer, sizeof(buffer)/sizeof(char), &result) != 0 )
{
log << log1 << "Misc: I cannot get the group_id for group name: " << name << logend;
//log << log1 << "Misc: I cannot get the group_id for group name: " << name << logend;
return -1;
}
@ -967,7 +966,7 @@ char buffer[512];
*/
if( result == 0 )
{
log << log1 << "Misc: There is no a group with name: " << name << logend;
//log << log1 << "Misc: There is no a group with name: " << name << logend;
return -1;
}
@ -994,7 +993,7 @@ char file_name[WINIX_OS_PATH_SIZE];
if( chmod(file_name, priv) < 0 )
{
log << log1 << "Misc: Can't set proper fs privileges on: " << name << logend;
//log << log1 << "Misc: Can't set proper fs privileges on: " << name << logend;
return false;
}
@ -1002,8 +1001,8 @@ char file_name[WINIX_OS_PATH_SIZE];
{
if( chown(file_name, geteuid(), group) < 0 )
{
log << log1 << "Can't set proper fs group on: " << name
<< ", group id was: " << group << logend;
//log << log1 << "Can't set proper fs group on: " << name
// << ", group id was: " << group << logend;
return false;
}
}
@ -1385,7 +1384,9 @@ void RemovePostFileTmp(PostFileTab & post_file_tab)
const std::wstring & tmp_filename = i->second.tmp_filename;
if( !tmp_filename.empty() && RemoveFile(tmp_filename) )
log << log3 << "Deleted tmp file: " << tmp_filename << logend;
{
//log << log3 << "Deleted tmp file: " << tmp_filename << logend;
}
}
}
@ -1399,8 +1400,8 @@ bool WideToUTF8(const wchar_t * wide_string, char * utf8, size_t utf8_size)
/*
* either the 'utf8' buffer is too small or there was an error when converting
*/
log << log1 << "Misc: I cannot convert from a wide string to an UTF-8 string, original string was: "
<< wide_string << logend;
//log << log1 << "Misc: I cannot convert from a wide string to an UTF-8 string, original string was: "
// << wide_string << logend;
}
return res;

View File

@ -297,7 +297,9 @@ bool MountParser::ReadMountType()
else
{
log << log1 << "MP: unknown mount type: " << temp << logend;
slog << logerror << T("unknown_mount_type") << ": " << temp << logend;
// IMPROVE ME there is no slog now
//slog << logerror << T("unknown_mount_type") << ": " << temp << logend;
}
return mount.type != -1;
@ -319,7 +321,9 @@ bool MountParser::ReadMountPoint()
else
{
log << log1 << "MP: there is no such a mount point (directory): " << last_dir << logend;
slog << logerror << T("no_such_dir") << ": " << last_dir << logend;
// IMPROVE ME there is no slog now
//slog << logerror << T("no_such_dir") << ": " << last_dir << logend;
}
return pdir != 0;
@ -339,7 +343,9 @@ bool MountParser::ReadFs()
else
{
log << log1 << "MP: unknown filesystem: " << temp << logend;
slog << logerror << T("unknown_filesystem") << ": " << temp << " (" << last_dir << ")" << logend;
// IMPROVE ME there is no slog now
//slog << logerror << T("unknown_filesystem") << ": " << temp << " (" << last_dir << ")" << logend;
}
return mount.fs != -1;
@ -383,7 +389,9 @@ void MountParser::ReadMountParams()
else
{
log << log1 << "MP: unknown mount param: " << temp << logend;
slog << logwarning << T("unknown_mount_param") << ": " << temp << " (" << T("skipped") << ")" << logend;
// IMPROVE ME there is no slog now
//slog << logwarning << T("unknown_mount_param") << ": " << temp << " (" << T("skipped") << ")" << logend;
}
}
}
@ -476,7 +484,9 @@ void MountParser::ReadRow()
if( skip_static && mount.type==static_mount_id )
{
log << log1 << "MP: static mount points are skipped (dont_use_static_dirs in config is true)" << logend;
slog << logwarning << T("skipped_static_mount") << ": " << last_dir << logend;
// IMPROVE ME there is no slog now
//slog << logwarning << T("skipped_static_mount") << ": " << last_dir << logend;
}
else
{
@ -490,7 +500,9 @@ void MountParser::ReadRow()
else
{
log << log1 << "MP: this mount point exists (skipped)" << logend;
slog << logwarning << T("mount_exists") << ": " << last_dir << " (" << T("skipped") << ")" << logend;
// IMPROVE ME there is no slog now
//slog << logwarning << T("mount_exists") << ": " << last_dir << " (" << T("skipped") << ")" << logend;
}
}

View File

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

View File

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

View File

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

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2008-2014, Tomasz Sowa
* Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -35,14 +35,56 @@
#include <dlfcn.h>
#include <string.h>
#include "plugin.h"
#include "pluginmsg.h"
#include "misc.h"
#include "system.h"
#include "sessionmanager.h"
#include "functions/functions.h"
#include "templates/templates.h"
#include "winixrequest.h"
namespace Winix
{
/*
*
* PluginInfo
*
*
*/
void PluginInfo::set_dependency_for(WinixBase * winix_base)
{
plugin->SetDependencyFor(winix_base);
}
void PluginInfo::set_dependency_for(WinixBase & winix_base)
{
set_dependency_for(&winix_base);
}
void PluginInfo::set_dependency_for(WinixModel * winix_model)
{
plugin->SetDependencyFor(winix_model);
}
void PluginInfo::set_dependency_for(WinixModel & winix_model)
{
set_dependency_for(&winix_model);
}
/*
*
* Plugin
*
*
*/
void Plugin::UnloadPlugins()
{
@ -61,14 +103,13 @@ Plugin::Plugin()
{
current_plugin = -1;
db = 0;
config = 0;
cur = 0;
system = 0;
functions = 0;
templates = 0;
synchro = 0;
session_manager = 0;
db = nullptr;
cur = nullptr;
system = nullptr;
functions = nullptr;
templates = nullptr;
session_manager = nullptr;
winix_request = nullptr;
}
@ -83,10 +124,10 @@ void Plugin::SetDb(Db * pdb)
db = pdb;
}
void Plugin::SetConfig(Config * pconfig)
{
config = pconfig;
}
//void Plugin::SetConfig(Config * pconfig)
//{
// config = pconfig;
//}
void Plugin::SetCur(Cur * pcur)
@ -113,10 +154,10 @@ void Plugin::SetTemplates(Templates * ptemplates)
}
void Plugin::SetSynchro(Synchro * psynchro)
{
synchro = psynchro;
}
//void Plugin::SetSynchro(Synchro * psynchro)
//{
// synchro = psynchro;
//}
void Plugin::SetSessionManager(SessionManager * psession_manager)
@ -125,6 +166,12 @@ void Plugin::SetSessionManager(SessionManager * psession_manager)
}
void Plugin::SetWinixRequest(WinixRequest * winix_request)
{
this->winix_request = winix_request;
}
void Plugin::Lock()
{
@ -142,10 +189,10 @@ void Plugin::Unlock()
bool Plugin::SetPointers(PluginInfo & info)
bool Plugin::SetDependency(PluginInfo & info)
{
// for safety we call a plugin function only when all our pointers are not null
bool res = (db && config && cur && system && functions && templates && synchro && session_manager);
bool res = (db && config && cur && system && functions && templates && synchro && session_manager && winix_request);
if( !res )
{
@ -162,11 +209,26 @@ bool Plugin::SetPointers(PluginInfo & info)
info.templates = templates;
info.synchro = synchro;
info.session_manager = session_manager;
info.plugin = this;
info.log.SetDependency(&log);
return res;
}
void Plugin::SetDependencyFor(WinixBase * winix_base)
{
winix_base->set_dependency(winix_request);
}
void Plugin::SetDependencyFor(WinixModel * winix_model)
{
winix_model->set_dependency(winix_request);
}
void Plugin::LoadPlugins(const std::wstring & plugins_dir, const std::vector<std::wstring> & plugins)
{
for(size_t i=0 ; i<plugins.size() ; ++i)
@ -233,7 +295,7 @@ void * plugin_handle;
int old_current_plugin;
PluginInfo info;
if( !SetPointers(info) )
if( !SetDependency(info) )
return;
if( !(plugin_handle = LoadInitFun(filename, fun_init)) )
@ -293,7 +355,7 @@ bool Plugin::HasMessage(int message)
void Plugin::Call(Session * ses, int message, Slots::iterator & slot, PluginInfo & info)
{
if( !SetPointers(info) )
if( !SetDependency(info) )
return;
current_plugin = slot->second.index;
@ -524,5 +586,13 @@ const Plugin::Plugins * Plugin::GetPlugins()
}
} // namespace Winix

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2008-2014, Tomasz Sowa
* Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -39,20 +39,23 @@
#include <string>
#include <map>
#include "pluginmsg.h"
#include "log.h"
#include "plugindata.h"
#include "config.h"
#include "request.h"
#include "system.h"
#include "sessionmanager.h"
#include "synchro.h"
#include "functions/functions.h"
#include "templates/templates.h"
#include "winixbase.h"
namespace Winix
{
class Db;
struct Cur;
class System;
class Functions;
class Templates;
class SessionManager;
class WinixModel;
class WinixRequest;
@ -73,8 +76,11 @@ namespace Winix
*/
class Plugin;
struct Session;
// move me to a different file
struct PluginInfo
{
// these variables are used for some purposes
@ -87,6 +93,7 @@ struct PluginInfo
// unique plugin identifier
int plugin_id;
// objects from winix which are accessible from a plugin
Db * db;
Config * config;
@ -97,6 +104,11 @@ struct PluginInfo
Synchro * synchro;
SessionManager * session_manager;
Log log;
Plugin * plugin;
// a session
// some messages are sent in a session's context e.g. logging a user
// this pointer in not always the same as cur->session, it is preferred
@ -116,6 +128,13 @@ struct PluginInfo
bool res;
void set_dependency_for(WinixBase * winix_base);
void set_dependency_for(WinixBase & winix_base);
void set_dependency_for(WinixModel * winix_model);
void set_dependency_for(WinixModel & winix_model);
void Clear()
{
// pointers to winix objects are not cleared here
@ -131,6 +150,7 @@ struct PluginInfo
res = false;
}
};
@ -151,7 +171,7 @@ struct PluginRes
class Plugin
class Plugin : public WinixBase
{
public:
@ -193,14 +213,16 @@ public:
~Plugin();
void SetDb(Db * pdb);
void SetConfig(Config * pconfig);
//void SetConfig(Config * pconfig);
void SetCur(Cur * pcur);
void SetSystem(System * psystem);
void SetFunctions(Functions * pfunctions);
void SetTemplates(Templates * ptemplates);
void SetSynchro(Synchro * psynchro);
//void SetSynchro(Synchro * psynchro);
void SetSessionManager(SessionManager * psession_manager);
void SetWinixRequest(WinixRequest * winix_request);
void LoadPlugin(const wchar_t * filename);
void LoadPlugin(const std::wstring & filename);
@ -245,14 +267,16 @@ public:
private:
Db * db;
Config * config;
//Config * config;
Cur * cur;
System * system;
Functions * functions;
Templates * templates;
Synchro * synchro;
//Synchro * synchro;
SessionManager * session_manager;
WinixRequest * winix_request;
std::wstring temp_path; // used when loading plugins
Plugins plugins;
@ -263,17 +287,17 @@ private:
void * LoadInitFun(const wchar_t * filename, Fun1 & fun_init);
void Call(Session * ses, int message, Slots::iterator & slot, PluginInfo & info);
bool SetPointers(PluginInfo & info);
bool SetDependency(PluginInfo & info);
void SetDependencyFor(WinixBase * winix_base);
void SetDependencyFor(WinixModel * winix_model);
void Lock();
void Unlock();
friend PluginInfo;
};
extern Plugin plugin;
} // namespace Winix

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2008-2014, Tomasz Sowa
* Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -35,7 +35,7 @@
#include "plugindata.h"
#include "plugin.h"
#include "log.h"
#include "session.h"
namespace Winix
@ -46,7 +46,6 @@ namespace Winix
PluginData::PluginData()
{
session = 0;
}
@ -63,7 +62,6 @@ PluginData & PluginData::operator=(const PluginData & p)
// we don't copy all pointers - only resize the table
// pointers will be set to zero
Resize(p.Size());
session = 0;
return *this;
}
@ -72,15 +70,10 @@ return *this;
PluginData::~PluginData()
{
DeleteAll();
//DeleteAll();
}
void PluginData::SetSession(Session * ses)
{
session = ses;
}
void PluginData::Assign(size_t index, PluginDataBase * data)
@ -92,16 +85,16 @@ void PluginData::Assign(size_t index, PluginDataBase * data)
}
void PluginData::Assign(PluginDataBase * data)
{
if( plugin.current_plugin == -1 )
{
log << log1 << "PD: Assign(PluginDataBase*) should be called only from plugins" << logend;
return;
}
Assign(plugin.current_plugin, data);
}
//void PluginData::Assign(PluginDataBase * data)
//{
// if( plugin.current_plugin == -1 )
// {
// log << log1 << "PD: Assign(PluginDataBase*) should be called only from plugins" << logend;
// return;
// }
//
// Assign(plugin.current_plugin, data);
//}
@ -114,31 +107,23 @@ return table[index];
}
PluginDataBase * PluginData::Get()
{
if( plugin.current_plugin == -1 )
{
log << log1 << "PD: Get() should be called only from plugins" << logend;
return 0;
}
return Get(plugin.current_plugin);
}
//PluginDataBase * PluginData::Get()
//{
// if( plugin.current_plugin == -1 )
// {
// log << log1 << "PD: Get() should be called only from plugins" << logend;
// return 0;
// }
//
//return Get(plugin.current_plugin);
//}
void PluginData::DeleteAll()
bool PluginData::HasAllocatedData()
{
bool all_null = true;
/*
when we copy a session's object (and this object then)
we resize the table and there are only null pointers there
consequently if all pointers are null there is no sens
to send WINIX_PLUGIN_SESSION_DATA_REMOVE
*/
for(size_t i=0 ; i<table.size() ; ++i)
{
if( table[i] != 0 )
@ -148,19 +133,40 @@ void PluginData::DeleteAll()
}
}
/*
in the future this message may be removed
and we directly 'delete' the pointers
*/
if( !all_null )
plugin.Call(session, WINIX_PLUGIN_SESSION_DATA_REMOVE);
table.clear();
return !all_null;
}
//void PluginData::DeleteAll()
//{
// bool all_null = true;
//
// when we copy a session's object (and this object then)
// we resize the table and there are only null pointers there
// consequently if all pointers are null there is no sens
// to send WINIX_PLUGIN_SESSION_DATA_REMOVE
//
// for(size_t i=0 ; i<table.size() ; ++i)
// {
// if( table[i] != 0 )
// {
// all_null = false;
// break;
// }
// }
//
// in the future this message may be removed
// and we directly 'delete' the pointers
//
// if( !all_null )
// plugin.Call(session, WINIX_PLUGIN_SESSION_DATA_REMOVE);
//
// table.clear();
//}
size_t PluginData::Size() const

View File

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

View File

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

View File

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

View File

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

View File

@ -38,7 +38,6 @@
#include <sys/wait.h>
#include <cstring>
#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.
*
* Redistribution and use in source and binary forms, with or without
@ -38,6 +38,7 @@
#include <string>
#include <cstdio>
#include <unistd.h>
#include "winixbase.h"
namespace Winix
@ -64,7 +65,7 @@ namespace Winix
7. winix waitpid() for the child
8. Go() returns
*/
class Run
class Run : public WinixBase
{
public:

View File

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

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2008-2014, Tomasz Sowa
* Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -80,7 +80,12 @@ Table::iterator i = table.begin();
// because plugins session data would not be erased
while( i != table.end() )
{
i->plugin_data.DeleteAll(); // it's better to call it here instead in the destructor
if( i->plugin_data.HasAllocatedData() )
{
plugin->Call(&*i, WINIX_PLUGIN_SESSION_DATA_REMOVE); // the session passed here is ok?
}
//i->plugin_data.DeleteAll(); // it's better to call it here instead in the destructor
table.erase(i++);
}
@ -108,7 +113,14 @@ IndexId::iterator i = index_id.find(id);
// call first DeleteAll() because if not then it would be called from the destructor
// and there'll be a problem if it throws an exception there
i->second->plugin_data.DeleteAll();
if( i->second->plugin_data.HasAllocatedData() )
{
plugin->Call(&*(i->second), WINIX_PLUGIN_SESSION_DATA_REMOVE); // the session passed here is ok?
}
//i->second->plugin_data.DeleteAll();
table.erase(i->second);
index_id.erase(i);
table_size -= 1;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -37,7 +37,6 @@
#include "error.h"
#include "templates/templates.h"
#include "functions/functions.h"
#include "plugin.h"
@ -53,10 +52,10 @@ void System::SetCur(Cur * pcur)
}
void System::SetConfig(Config * pconfig)
{
config = pconfig;
}
//void System::SetConfig(Config * pconfig)
//{
// config = pconfig;
//}
void System::SetDb(Db * pdb)
@ -65,10 +64,10 @@ void System::SetDb(Db * pdb)
}
void System::SetSynchro(Synchro * psynchro)
{
synchro = psynchro;
}
//void System::SetSynchro(Synchro * psynchro)
//{
// synchro = psynchro;
//}
void System::SetFunctions(Functions * pfunctions)
@ -82,6 +81,25 @@ void System::SetSessionManager(SessionManager * sm)
}
void System::set_dependency(WinixModel * winix_model)
{
WinixModel::set_dependency(winix_model);
dirs.set_dependency(this);
mounts.set_dependency(this);
users.set_dependency(this);
groups.set_dependency(this);
rebus.set_dependency(this);
load_avg.set_dependency(this);
notify.set_dependency(this);
image.set_dependency(this);
crypt.set_dependency(this);
thread_manager.set_dependency(this);
job.set_dependency(winix_model);
time_zones.set_dependency(winix_model);
}
void System::ReadTimeZones()
{
if( config->etc_dir.empty() )
@ -107,31 +125,33 @@ void System::ReadTimeZones()
void System::Init()
{
thread_manager.SetSynchro(synchro);
//thread_manager.SetSynchro(synchro);
thread_manager.Init();
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.ReadDirs();
mounts.SkipStaticDirs(config->dont_use_static_dirs);
mounts.SetDirs(&dirs);
mounts.SetDb(db);
mounts.SetCur(cur);
mounts.SetCur(cur); // only one method is using cur, can be passed as a parameter to the method
mounts.CreateMounts();
mounts.ReadMounts();
users.SetCur(cur);
users.SetSessionManager(session_manager);
users.ReadUsers(db);
groups.ReadGroups(db); // !! chwilowe przekazanie argumentu, db bedzie zmienione
rebus.SetCur(cur);
rebus.Init();
notify.SetCur(cur);
notify.SetConfig(config);
//notify.SetConfig(config);
notify.SetUsers(&users);
notify.SetDirs(&dirs);
notify.SetThreadManager(&thread_manager);
@ -142,7 +162,8 @@ void System::Init()
image.SetSystem(this);
thread_manager.Add(&image, L"image");
crypt.SetConfig(config);
// SetSynchro will be called by ThreadManager itself
// job.ReadFromFile();
@ -1020,7 +1041,7 @@ Error System::AddFile(Item & item, int notify_code, bool call_plugins)
notify.ItemChanged(notify_code, item);
if( call_plugins )
plugin.Call(WINIX_FILE_ADDED, &item);
plugin->Call(WINIX_FILE_ADDED, &item);
}
return status;
@ -1052,7 +1073,7 @@ Error System::EditFile(Item & item, bool with_url, int notify_code, bool call_pl
notify.ItemChanged(notify_code, item);
if( call_plugins )
plugin.Call(WINIX_FILE_CHANGED, &item);
plugin->Call(WINIX_FILE_CHANGED, &item);
}

View File

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

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2011-2014, Tomasz Sowa
* Copyright (c) 2011-2018, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -49,10 +49,10 @@ ThreadManager::ThreadManager()
}
void ThreadManager::SetSynchro(Synchro * psynchro)
{
synchro = psynchro;
}
//void ThreadManager::SetSynchro(Synchro * psynchro)
//{
// synchro = psynchro;
//}
void ThreadManager::Init()
@ -70,20 +70,39 @@ sigset_t set;
void ThreadManager::Add(BaseThread * pbase, const wchar_t * thread_name)
{
ThreadItem item;
item.object = pbase;
item.name = thread_name;
thread_tab.push_back(item);
thread_tab.back().thread_item_data = new ThreadItemData();
thread_tab.back().object->set_dependency(this);
// the logger buffer and model_connector are different
ThreadItemData & data = *thread_tab.back().thread_item_data;
thread_tab.back().object->set_log_buffer(&data.log_buffer);
//data.postgresql_connector.set_logger(logger);
data.postgresql_connector.set_conn_param(config->db_database, config->db_user, config->db_pass);
data.postgresql_connector.set_logger(thread_tab.back().object->get_logger());
data.postgresql_connector.set_log_queries(config->log_db_query);
data.postgresql_connector.wait_for_connection();
data.model_connector.set_db_connector(data.postgresql_connector);
data.model_connector.set_flat_connector(data.json_connector);
thread_tab.back().object->set_model_connector(&data.model_connector);
if( were_started )
Start(thread_tab.size() - 1);
{
Start(thread_tab.size() - 1, &thread_tab.back());
}
else
{
log << log4 << "TM: added a thread to the queue, number: " << (thread_tab.size()-1)
<< ", name: " << thread_name << logend;
}
}
@ -109,8 +128,13 @@ void ThreadManager::StartAll()
{
synchro->Lock();
for(size_t i=0 ; i<thread_tab.size() ; ++i)
Start(i);
int id = 0;
for(ThreadItem & item : thread_tab)
{
Start(id, &item);
id += 1;
}
synchro->Unlock();
@ -118,22 +142,18 @@ void ThreadManager::StartAll()
}
void ThreadManager::Start(size_t i)
void ThreadManager::Start(int id, ThreadItem * item)
{
if( i < thread_tab.size() )
{
thread_tab[i].object->SetSynchro(synchro);
item->object->SetSynchro(synchro);
if( thread_tab[i].object->StartThread() )
if( item->object->StartThread() )
{
log << log4 << "TM: thread " << i << " (" << thread_tab[i].object->ThreadId() << ", name: "
<< thread_tab[i].name << ") started" << logend;
log << log4 << "TM: thread " << id << " (" << item->object->ThreadId() << ", name: "
<< item->name << ") started" << logend;
}
else
{
log << log4 << "TM: cannot run a thread, thread number: " << i
<< ", name: " << thread_tab[i].name << logend;
}
log << log4 << "TM: cannot run a thread " << id << ", name: " << item->name << logend;
}
}
@ -146,21 +166,29 @@ void ThreadManager::StopAll()
// WakeUpThread() should be used with Lock/Unlock
synchro->Lock();
for(size_t i=0 ; i<thread_tab.size() ; ++i)
thread_tab[i].object->WakeUpThread();
for(ThreadItem & item : thread_tab)
{
item.object->WakeUpThread();
}
synchro->Unlock();
for(size_t i=0 ; i<thread_tab.size() ; ++i)
int id = 0;
for(ThreadItem & item : thread_tab)
{
log << log4 << "TM: waiting for thread " << i << " (" << thread_tab[i].object->ThreadId()
<< ", name: " << thread_tab[i].name << ")" << logend;
log << log4 << "TM: waiting for thread " << id << " (" << item.object->ThreadId()
<< ", name: " << item.name << ")" << logend;
thread_tab[i].object->WaitForThread();
item.object->WaitForThread();
log << log4 << "TM: thread " << id << " terminated" << logend;
log << log4 << "TM: thread " << i << " terminated" << logend;
delete item.thread_item_data;
id += 1;
}
thread_tab.clear();
}

View File

@ -36,9 +36,10 @@
#define headerfile_winix_core_threadmanager
#include <string>
#include <vector>
#include <list>
#include "basethread.h"
#include "synchro.h"
#include "textstream/textstream.h"
namespace Winix
@ -47,15 +48,12 @@ namespace Winix
class ThreadManager
class ThreadManager : public WinixModel
{
public:
ThreadManager();
// synchro object
void SetSynchro(Synchro * psynchro);
// initializing
void Init();
@ -76,18 +74,29 @@ public:
private:
struct ThreadItemData
{
morm::ModelConnector model_connector;
morm::JSONConnector json_connector;
morm::PostgreSQLConnector postgresql_connector;
PT::WTextStream log_buffer;
};
struct ThreadItem
{
BaseThread * object;
std::wstring name;
ThreadItemData * thread_item_data;
};
Synchro * synchro;
typedef std::vector<ThreadItem> ThreadTab;
typedef std::list<ThreadItem> ThreadTab;
ThreadTab thread_tab;
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.
*
* Redistribution and use in source and binary forms, with or without
@ -39,6 +39,7 @@
#include <vector>
#include "timezone.h"
#include "space/spaceparser.h"
#include "winixbase.h"
namespace Winix
@ -47,7 +48,7 @@ namespace Winix
class TimeZones
class TimeZones : public WinixBase
{
public:

View File

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

View File

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

View File

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

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2008-2014, Tomasz Sowa
* Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -41,8 +41,8 @@ namespace Winix
#define WINIX_VER_MAJOR 0
#define WINIX_VER_MINOR 6
#define WINIX_VER_REVISION 6
#define WINIX_VER_MINOR 7
#define WINIX_VER_REVISION 0

95
winixd/core/winixbase.cpp 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.
*
*/
#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(PT::WTextStream * log_buffer)
{
log.SetLogBuffer(log_buffer);
}
void WinixBase::set_file_log(FileLog * file_log)
{
log.SetFileLog(file_log);
}
Log * WinixBase::get_logger()
{
return &log;
}
void WinixBase::set_dependency(WinixBase * winix_base)
{
config = winix_base->config;
synchro = winix_base->synchro;
log.SetDependency(&winix_base->log);
}
}

82
winixd/core/winixbase.h Normal file
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_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/textstream.h"
namespace Winix
{
class WinixBase
{
public:
WinixBase();
virtual ~WinixBase();
void set_config(Config * config);
void set_synchro(Synchro * synchro);
void set_log_buffer(PT::WTextStream * log_buffer);
void set_file_log(FileLog * file_log);
Log * get_logger();
void set_dependency(WinixBase * winix_base);
protected:
Log log;
Config * config;
Synchro * synchro;
};
}
#endif

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 "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;
plugin = winix_model->plugin;
}
Plugin * WinixModel::get_plugin()
{
return plugin;
}
}

75
winixd/core/winixmodel.h Normal file
View File

@ -0,0 +1,75 @@
/*
* 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);
// temporarily for templates, will be removed
Plugin * get_plugin();
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,81 @@
/*
* 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;
}
WinixSystem::~WinixSystem()
{
}
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

@ -3,7 +3,7 @@ include Makefile.o.dep
current_path := $(shell pwd)
global_relative_working_dir := $(shell relative_path $(current_path) $(GLOBAL_WORKING_DIR))
winix_include_paths = -I$(global_relative_working_dir)/winix/winixd -I$(global_relative_working_dir)/ezc/src -I$(global_relative_working_dir)/tito/src -I$(global_relative_working_dir)/pikotools
winix_include_paths = -I$(global_relative_working_dir)/winix/winixd -I$(global_relative_working_dir)/ezc/src -I$(global_relative_working_dir)/tito/src -I$(global_relative_working_dir)/morm/src -I$(global_relative_working_dir)/pikotools
all: $(o)

View File

@ -4,69 +4,91 @@ db.o: db.h dbbase.h dbconn.h dbtextstream.h
db.o: ../../../winix/winixd/core/textstream.h
db.o: ../../../winix/winixd/core/misc.h ../../../winix/winixd/core/item.h
db.o: ../../../pikotools/space/space.h ../../../pikotools/textstream/types.h
db.o: ../../../pikotools/date/date.h ../../../pikotools/convert/convert.h
db.o: ../../../pikotools/convert/inttostr.h
db.o: ../../../pikotools/convert/strtoint.h ../../../pikotools/convert/text.h
db.o: ../../../pikotools/date/date.h ../../../pikotools/convert/inttostr.h
db.o: ../../../winix/winixd/core/requesttypes.h
db.o: ../../../pikotools/textstream/textstream.h
db.o: ../../../pikotools/membuffer/membuffer.h
db.o: ../../../pikotools/textstream/types.h ../../../pikotools/utf8/utf8.h
db.o: ../../../winix/winixd/core/winix_const.h
db.o: ../../../winix/winixd/core/error.h
db.o: ../../../pikotools/convert/convert.h
db.o: ../../../pikotools/convert/inttostr.h
db.o: ../../../pikotools/convert/patternreplacer.h
db.o: ../../../pikotools/convert/strtoint.h ../../../pikotools/convert/text.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: ../../../winix/winixd/core/log.h
db.o: ../../../winix/winixd/core/logmanipulators.h
db.o: ../../../pikotools/log/log.h ../../../pikotools/log/filelog.h
db.o: ../../../winix/winixd/core/log.h ../../../winix/winixd/core/synchro.h
db.o: ../../../winix/winixd/core/filelog.h ../../../winix/winixd/core/lock.h
db.o: ../../../winix/winixd/core/synchro.h ../../../winix/winixd/core/error.h
db.o: dbitemquery.h ../../../winix/winixd/core/item.h dbitemcolumns.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/winixbase.h
db.o: ../../../winix/winixd/core/ugcontainer.h
db.o: ../../../winix/winixd/core/log.h
db.o: ../../../winix/winixd/core/textstream.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/request.h ../../../winix/winixd/core/error.h
db.o: ../../../winix/winixd/core/config.h
db.o: ../../../winix/winixd/core/htmlfilter.h
db.o: ../../../winix/winixd/templates/htmltextstream.h
db.o: ../../../pikotools/space/spacetojson.h ../../../ezc/src/outstreams.h
db.o: ../../../winix/winixd/core/session.h ../../../winix/winixd/core/user.h
db.o: ../../../winix/winixd/core/plugindata.h
db.o: ../../../winix/winixd/core/rebus.h ../../../winix/winixd/core/ipban.h
db.o: ../../../winix/winixd/core/mount.h
db.o: ../../../winix/winixd/templates/locale.h
db.o: ../../../winix/winixd/core/log.h ../../../winix/winixd/core/misc.h
db.o: ../../../winix/winixd/core/misc.h
dbbase.o: dbbase.h dbconn.h dbtextstream.h
dbbase.o: ../../../winix/winixd/core/textstream.h
dbbase.o: ../../../winix/winixd/core/misc.h ../../../winix/winixd/core/item.h
dbbase.o: ../../../pikotools/space/space.h
dbbase.o: ../../../pikotools/textstream/types.h
dbbase.o: ../../../pikotools/date/date.h ../../../pikotools/convert/convert.h
dbbase.o: ../../../pikotools/date/date.h
dbbase.o: ../../../pikotools/convert/inttostr.h
dbbase.o: ../../../pikotools/convert/strtoint.h
dbbase.o: ../../../pikotools/convert/text.h
dbbase.o: ../../../winix/winixd/core/requesttypes.h
dbbase.o: ../../../pikotools/textstream/textstream.h
dbbase.o: ../../../pikotools/membuffer/membuffer.h
dbbase.o: ../../../pikotools/textstream/types.h
dbbase.o: ../../../pikotools/utf8/utf8.h
dbbase.o: ../../../winix/winixd/core/winix_const.h
dbbase.o: ../../../winix/winixd/core/error.h
dbbase.o: ../../../pikotools/convert/convert.h
dbbase.o: ../../../pikotools/convert/inttostr.h
dbbase.o: ../../../pikotools/convert/patternreplacer.h
dbbase.o: ../../../pikotools/convert/strtoint.h
dbbase.o: ../../../pikotools/convert/text.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/space.h ../../../winix/winixd/core/log.h
dbbase.o: ../../../winix/winixd/core/logmanipulators.h
dbbase.o: ../../../pikotools/log/log.h ../../../pikotools/log/filelog.h
dbbase.o: ../../../winix/winixd/core/log.h
dbbase.o: ../../../winix/winixd/core/synchro.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
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: ../../../pikotools/space/space.h
dbconn.o: ../../../pikotools/textstream/types.h
dbconn.o: ../../../pikotools/date/date.h ../../../pikotools/convert/convert.h
dbconn.o: ../../../pikotools/date/date.h
dbconn.o: ../../../pikotools/convert/inttostr.h
dbconn.o: ../../../pikotools/convert/strtoint.h
dbconn.o: ../../../pikotools/convert/text.h
dbconn.o: ../../../winix/winixd/core/requesttypes.h
dbconn.o: ../../../pikotools/textstream/textstream.h
dbconn.o: ../../../pikotools/membuffer/membuffer.h
dbconn.o: ../../../pikotools/textstream/types.h
dbconn.o: ../../../pikotools/utf8/utf8.h
dbconn.o: ../../../winix/winixd/core/winix_const.h
dbconn.o: ../../../winix/winixd/core/log.h ../../../winix/winixd/core/error.h
dbconn.o: ../../../pikotools/convert/convert.h
dbconn.o: ../../../pikotools/convert/inttostr.h
dbconn.o: ../../../pikotools/convert/patternreplacer.h
dbconn.o: ../../../pikotools/convert/strtoint.h
dbconn.o: ../../../pikotools/convert/text.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 ../../../winix/winixd/core/log.h
dbconn.o: ../../../winix/winixd/core/logmanipulators.h
dbconn.o: ../../../pikotools/log/log.h ../../../pikotools/log/filelog.h
dbconn.o: ../../../winix/winixd/core/log.h
dbconn.o: ../../../winix/winixd/core/synchro.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: dbconn.h dbtextstream.h
dbitemcolumns.o: ../../../winix/winixd/core/textstream.h
@ -75,20 +97,32 @@ dbitemcolumns.o: ../../../winix/winixd/core/item.h
dbitemcolumns.o: ../../../pikotools/space/space.h
dbitemcolumns.o: ../../../pikotools/textstream/types.h
dbitemcolumns.o: ../../../pikotools/date/date.h
dbitemcolumns.o: ../../../pikotools/convert/convert.h
dbitemcolumns.o: ../../../pikotools/convert/inttostr.h
dbitemcolumns.o: ../../../pikotools/convert/strtoint.h
dbitemcolumns.o: ../../../pikotools/convert/text.h
dbitemcolumns.o: ../../../winix/winixd/core/requesttypes.h
dbitemcolumns.o: ../../../pikotools/textstream/textstream.h
dbitemcolumns.o: ../../../pikotools/membuffer/membuffer.h
dbitemcolumns.o: ../../../pikotools/textstream/types.h
dbitemcolumns.o: ../../../pikotools/utf8/utf8.h
dbitemcolumns.o: ../../../winix/winixd/core/winix_const.h
dbitemcolumns.o: ../../../winix/winixd/core/error.h
dbitemcolumns.o: ../../../pikotools/convert/convert.h
dbitemcolumns.o: ../../../pikotools/convert/inttostr.h
dbitemcolumns.o: ../../../pikotools/convert/patternreplacer.h
dbitemcolumns.o: ../../../pikotools/convert/strtoint.h
dbitemcolumns.o: ../../../pikotools/convert/text.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/space.h
dbitemcolumns.o: ../../../winix/winixd/core/log.h
dbitemcolumns.o: ../../../winix/winixd/core/logmanipulators.h
dbitemcolumns.o: ../../../pikotools/log/log.h
dbitemcolumns.o: ../../../pikotools/log/filelog.h
dbitemcolumns.o: ../../../winix/winixd/core/log.h
dbitemcolumns.o: ../../../winix/winixd/core/synchro.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
dbtextstream.o: dbtextstream.h ../../../winix/winixd/core/textstream.h
dbtextstream.o: ../../../winix/winixd/core/misc.h
@ -96,13 +130,15 @@ dbtextstream.o: ../../../winix/winixd/core/item.h
dbtextstream.o: ../../../pikotools/space/space.h
dbtextstream.o: ../../../pikotools/textstream/types.h
dbtextstream.o: ../../../pikotools/date/date.h
dbtextstream.o: ../../../pikotools/convert/convert.h
dbtextstream.o: ../../../pikotools/convert/inttostr.h
dbtextstream.o: ../../../pikotools/convert/strtoint.h
dbtextstream.o: ../../../pikotools/convert/text.h
dbtextstream.o: ../../../winix/winixd/core/requesttypes.h
dbtextstream.o: ../../../pikotools/textstream/textstream.h
dbtextstream.o: ../../../pikotools/membuffer/membuffer.h
dbtextstream.o: ../../../pikotools/textstream/types.h
dbtextstream.o: ../../../pikotools/utf8/utf8.h
dbtextstream.o: ../../../winix/winixd/core/winix_const.h
dbtextstream.o: ../../../pikotools/convert/convert.h
dbtextstream.o: ../../../pikotools/convert/inttostr.h
dbtextstream.o: ../../../pikotools/convert/patternreplacer.h
dbtextstream.o: ../../../pikotools/convert/strtoint.h
dbtextstream.o: ../../../pikotools/convert/text.h

View File

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

View File

@ -43,6 +43,8 @@
#include "core/error.h"
#include "space/spaceparser.h"
#include "date/date.h"
#include "core/winixbase.h"
namespace Winix
@ -50,7 +52,7 @@ namespace Winix
class DbBase
class DbBase : public WinixBase
{
public:
@ -67,21 +69,19 @@ public:
PGresult * AssertQuery(const char * q, ExecStatusType t);
PGresult * AssertQuery(const DbTextStream & query, 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);
// 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);
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);
// non static assignments
bool AssertValueSpace(PGresult * r, int row, int col, PT::Space & space);
void ClearResult(PGresult * r);
@ -104,7 +104,7 @@ public:
// new API (returns only bool)
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:
@ -126,7 +126,7 @@ private:
// static bool IsCorrectOctalDigit(char c);
// static int UnescapeBin(const char * str, size_t & i, size_t len);
static char UnescapeBinHexToDigit(char hex);
char UnescapeBinHexToDigit(char hex);
DbTextStream bquery;
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.
*
* Redistribution and use in source and binary forms, with or without
@ -38,6 +38,7 @@
#include <string>
#include <libpq-fe.h>
#include "dbtextstream.h"
#include "core/winixbase.h"
namespace Winix
@ -45,7 +46,7 @@ namespace Winix
class DbConn
class DbConn : public WinixBase
{
public:

View File

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

View File

@ -3,7 +3,7 @@ include Makefile.o.dep
current_path := $(shell pwd)
global_relative_working_dir := $(shell relative_path $(current_path) $(GLOBAL_WORKING_DIR))
winix_include_paths = -I$(global_relative_working_dir)/winix/winixd -I$(global_relative_working_dir)/ezc/src -I$(global_relative_working_dir)/tito/src -I$(global_relative_working_dir)/pikotools
winix_include_paths = -I$(global_relative_working_dir)/winix/winixd -I$(global_relative_working_dir)/ezc/src -I$(global_relative_working_dir)/tito/src -I$(global_relative_working_dir)/morm/src -I$(global_relative_working_dir)/pikotools
all: $(o)

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.
*
* Redistribution and use in source and binary forms, with or without
@ -34,8 +34,6 @@
#include <cstdlib>
#include "adduser.h"
#include "core/slog.h"
#include "core/plugin.h"
#include "core/misc.h"
#include "functions/functions.h"
@ -240,7 +238,7 @@ bool AddUser::AddNewUser(const std::wstring & login,
{
system->users.LoginUser(user.id, false);
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 )

View File

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

View File

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

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2008-2014, Tomasz Sowa
* Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -35,7 +35,7 @@
#include "cp.h"
#include "core/misc.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 )
CopyStaticFile(item);
plugin.Call(WINIX_FILE_COPIED, &item);
plugin->Call(WINIX_FILE_COPIED, &item);
}
}

View File

@ -106,19 +106,6 @@ return true;
*/
// !! zmienic nazwy
// albo w ogole te metody nie sa potrzebne teraz (byly zmiany)
void Emacs::DoRedirectIfNeeded(bool adding)
{
if( cur->request->ParamValue(L"reqtype") != L"json" )
{
system->RedirectTo(cur->request->item);
}
}
int Emacs::NotifyCodeEdit()
{
// !! nie potrzebne
@ -172,19 +159,17 @@ void Emacs::MakePost()
if( cur->request->status == WINIX_ERR_OK )
{
DoRedirectIfNeeded(adding);
if( adding )
{
system->RedirectToLastFunction(nullptr, false);
}
functions->CheckSpecialFile(cur->request->item);
}
else
{
log << log1 << "Emacs: error: " << cur->request->status << logend;
}
if( cur->request->ParamValue(L"reqtype") == L"json" )
{
cur->request->info.Add(L"status", cur->request->status);
}
}

View File

@ -56,7 +56,6 @@ public:
private:
bool HasAccess(const Item & item); // !! takie funkcje to nie powinny byc skladowe modelu?
void DoRedirectIfNeeded(bool adding);
int NotifyCodeEdit();
int NotifyCodeAdd();

View File

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

View File

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

View File

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

View File

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

View File

@ -33,9 +33,7 @@
*/
#include "functions.h"
#include "core/log.h"
#include "core/misc.h"
#include "core/plugin.h"
#include "templates/templates.h"
@ -45,10 +43,10 @@ namespace Winix
void Functions::SetConfig(Config * pconfig)
{
config = pconfig;
}
//void Functions::SetConfig(Config * pconfig)
//{
// config = pconfig;
//}
void Functions::SetCur(Cur * pcur)
@ -76,10 +74,10 @@ void Functions::SetTemplates(Templates * ptemplates)
}
void Functions::SetSynchro(Synchro * psynchro)
{
synchro = psynchro;
}
//void Functions::SetSynchro(Synchro * psynchro)
//{
// synchro = psynchro;
//}
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()
{
@ -171,14 +175,16 @@ return WINIX_NOTHING_TO_DO;
void Functions::SetObjects(FunctionBase * fun)
{
fun->SetConfig(config);
fun->SetCur(cur);
fun->set_dependency(this);
//fun->SetConfig(config);
//fun->SetCur(cur);
fun->SetDb(db);
fun->SetSystem(system);
//fun->SetSystem(system);
fun->SetFunctions(this);
fun->SetTemplates(templates);
fun->SetSynchro(synchro);
fun->SetSessionManager(session_manager);
//fun->SetSynchro(synchro);
//fun->SetSessionManager(session_manager);
}
@ -258,7 +264,7 @@ void Functions::CreateFunctions()
Add(fun_who);
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;
plugin.Call(WINIX_SELECT_DEFAULT_FUNCTION);
plugin->Call(WINIX_SELECT_DEFAULT_FUNCTION);
if( cur->request->function )
{

View File

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

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2008-2014, Tomasz Sowa
* Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -34,7 +34,6 @@
#include "mkdir.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( pdir )
plugin.Call(WINIX_DIR_ADDED, pdir);
plugin->Call(WINIX_DIR_ADDED, pdir);
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.
*
* Redistribution and use in source and binary forms, with or without
@ -35,7 +35,6 @@
#include <errno.h>
#include "mv.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);
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
// so if there is no WINIX_FILE_PREPARE_TO_MOVE message
// 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);
}
@ -332,9 +331,9 @@ void Mv::MoveFilesTree(const Item & dir)
{
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]);
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
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;
@ -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 )
MoveStaticFile(src_file);
plugin.Call(WINIX_FILE_MOVED, &src_file);
plugin->Call(WINIX_FILE_MOVED, &src_file);
return true;
}

View File

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

View File

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

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