the first part of reimplementing has been done
now we have app object and singletons are only: log logn plugin and app git-svn-id: svn://ttmath.org/publicrep/winix/trunk@628 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
@@ -14,7 +14,6 @@
|
||||
|
||||
#include "log.h"
|
||||
#include "notify.h"
|
||||
#include "data.h"
|
||||
#include "misc.h"
|
||||
#include "request.h"
|
||||
|
||||
@@ -26,6 +25,30 @@ Notify * Notify::obj;
|
||||
|
||||
|
||||
|
||||
void Notify::SetRequest(Request * prequest)
|
||||
{
|
||||
request = prequest;
|
||||
}
|
||||
|
||||
|
||||
void Notify::SetConfig(Config * pconfig)
|
||||
{
|
||||
config = pconfig;
|
||||
}
|
||||
|
||||
|
||||
void Notify::SetSystem(System * psystem)
|
||||
{
|
||||
system = psystem;
|
||||
}
|
||||
|
||||
void Notify::SetTemplatesNotify(TemplatesNotify * ptemplates_notify)
|
||||
{
|
||||
templates_notify = ptemplates_notify;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
methods for the second thread
|
||||
@@ -71,10 +94,10 @@ void Notify::SendEmail(NotifyMsg & n)
|
||||
TemplatesNotifyFunctions::notify_msg = &n;
|
||||
|
||||
obj->Lock(); // templates can be reloaded from the first thread
|
||||
obj->templates_notify.Generate(n.lang);
|
||||
obj->templates_notify->Generate(n.lang);
|
||||
obj->Unlock();
|
||||
|
||||
SendEmail(n.email, obj->templates_notify.notify_str.str());
|
||||
SendEmail(n.email, obj->templates_notify->notify_str.str());
|
||||
}
|
||||
|
||||
|
||||
@@ -142,7 +165,7 @@ void Notify::ReadTemplates()
|
||||
// the second thread can use our templates and we must Lock()
|
||||
// (the second thread is using Lock() too)
|
||||
Lock();
|
||||
templates_notify.Read();
|
||||
templates_notify->Read();
|
||||
Unlock();
|
||||
}
|
||||
|
||||
@@ -150,7 +173,7 @@ void Notify::ReadTemplates()
|
||||
|
||||
bool Notify::Init()
|
||||
{
|
||||
templates_notify.CreateFunctions();
|
||||
templates_notify->CreateFunctions();
|
||||
|
||||
|
||||
int t = pthread_create(&thread, 0, ThreadRoutine, (void*)this);
|
||||
@@ -188,9 +211,9 @@ void Notify::CreateItemDir(std::string & dir, bool clear)
|
||||
if( clear )
|
||||
dir.clear();
|
||||
|
||||
for(size_t a=0 ; a<request.dir_table.size() ; ++a)
|
||||
for(size_t a=0 ; a<request->dir_table.size() ; ++a)
|
||||
{
|
||||
dir += request.dir_table[a]->url;
|
||||
dir += request->dir_table[a]->url;
|
||||
dir += '/';
|
||||
}
|
||||
}
|
||||
@@ -198,9 +221,9 @@ void Notify::CreateItemDir(std::string & dir, bool clear)
|
||||
|
||||
void Notify::CreateItemLink(std::string & link)
|
||||
{
|
||||
link = data.base_url;
|
||||
link = config->base_url;
|
||||
CreateItemDir(link, false);
|
||||
link += request.item.url;
|
||||
link += request->item.url;
|
||||
}
|
||||
|
||||
|
||||
@@ -213,8 +236,8 @@ Users::Iterator i;
|
||||
return;
|
||||
|
||||
n.notify_code = notify_code;
|
||||
n.current_mount_type = data.mounts.pmount->type;
|
||||
n.doc_base_url = data.base_url;
|
||||
n.current_mount_type = system->mounts.pmount->type;
|
||||
n.doc_base_url = config->base_url;
|
||||
CreateItemDir(n.item_dir);
|
||||
CreateItemLink(n.item_link);
|
||||
|
||||
@@ -225,17 +248,17 @@ Users::Iterator i;
|
||||
{
|
||||
// don't clear notify_pool here -- it is used (and will be cleared) by the second thread
|
||||
|
||||
for(i=data.users.Begin() ; i != data.users.End() ; ++i)
|
||||
for(i=system->users.Begin() ; i != system->users.End() ; ++i)
|
||||
{
|
||||
sending = false;
|
||||
|
||||
if( data.mounts.pmount->type == Mount::thread )
|
||||
if( system->mounts.pmount->type == Mount::thread )
|
||||
{
|
||||
if( (i->thread_notify & notify_code) != 0 )
|
||||
sending = true;
|
||||
}
|
||||
else
|
||||
if( data.mounts.pmount->type == Mount::cms )
|
||||
if( system->mounts.pmount->type == Mount::cms )
|
||||
{
|
||||
if( (i->cms_notify & notify_code) != 0 )
|
||||
sending = true;
|
||||
@@ -244,7 +267,7 @@ Users::Iterator i;
|
||||
if( sending )
|
||||
{
|
||||
n.email = i->email;
|
||||
n.lang = Locale::StrToLang(data.locale_str);// !! bedzie osobno dla kazdego uzytkownika
|
||||
n.lang = Locale::StrToLang(config->locale_str);// !! bedzie osobno dla kazdego uzytkownika
|
||||
|
||||
if( n.lang == Locale::lang_unknown )
|
||||
n.lang = Locale::lang_en;
|
||||
|
Reference in New Issue
Block a user