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

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