start working on 0.7.x branch

- added FileLog which stores content to the file log
- now Log is only a wrapper - it puts messages to the local buffer and when logsave is used then the buffer is put to FileLog
- new base classes:
  WinixBase (Log, Config*, Synchro*)
  WinixModel : public WinixBase (morm::ModelConnector*, Plugin*)
  WinixSystem : public WinixModel (System*)
  WinixRequest : public WinixSystem (SLog, Cur*)
- singletons: log, slog, plugin are depracated - now references to them are in base classses (WinixBase, WinixModel)
- DbBase,  DbConn and Db are depracated - now we are using Morm project (in WinixModel there is a model_connector pointer)
  each thread will have its own ModelConnector





git-svn-id: svn://ttmath.org/publicrep/winix/branches/0.7.x@1146 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2018-11-21 11:03:53 +00:00
parent a7c47140ae
commit a2ffc1e81c
121 changed files with 7832 additions and 6662 deletions

File diff suppressed because 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

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

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

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,12 +38,14 @@
#include "core/request.h"
#include "core/system.h"
#include "db/db.h"
#include "core/winixmodel.h"
namespace Winix
{
class PrivChanger
class PrivChanger : public WinixModel
{
public:

View File

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

View File

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

View File

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

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,7 +38,6 @@
#include <errno.h>
#include "upload.h"
#include "core/misc.h"
#include "core/plugin.h"
#include "functions/functions.h"
#include "templates/templates.h"
#include "utf8/utf8.h"
@@ -157,7 +156,7 @@ void Upload::UploadFile(Item & item, const std::wstring & tmp_filename)
{
cur->request->status = db->EditFileById(item, item.id);
plugin.Call(WINIX_FILE_ADDED, &item);
plugin->Call(WINIX_FILE_ADDED, &item);
if( item.file_type == WINIX_ITEM_FILETYPE_IMAGE )
{