added: Patterns class (in templates)
ezc patterns are managed by this class
added: some work in groupitem plugin (not finished yet)
changed: ConfParser can read a string from memory now
(need some testing yet)
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@757 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
@@ -1,33 +1,35 @@
|
||||
# DO NOT DELETE
|
||||
|
||||
notify.o: notify.h notifypool.h ../templates/locale.h ../core/confparser.h
|
||||
notify.o: ../templates/misc.h ../templates/localefilter.h
|
||||
notify.o: ../templates/locale.h ../../ezc/src/ezc.h ../../ezc/src/utf8.h
|
||||
notify.o: ../../ezc/src/generator.h ../../ezc/src/pattern.h
|
||||
notify.o: ../../ezc/src/item.h ../../ezc/src/funinfo.h
|
||||
notify.o: ../../ezc/src/functions.h ../../ezc/src/stringconv.h
|
||||
notify.o: ../templates/htmltextstream.h ../core/textstream.h ../core/misc.h
|
||||
notify.o: ../core/requesttypes.h ../core/user.h notifythread.h
|
||||
notify.o: ../templates/patterns.h ../templates/locale.h
|
||||
notify.o: ../templates/localefilter.h ../../ezc/src/ezc.h
|
||||
notify.o: ../../ezc/src/utf8.h ../../ezc/src/generator.h
|
||||
notify.o: ../../ezc/src/pattern.h ../../ezc/src/item.h
|
||||
notify.o: ../../ezc/src/funinfo.h ../../ezc/src/functions.h
|
||||
notify.o: ../../ezc/src/stringconv.h ../templates/misc.h
|
||||
notify.o: ../templates/htmltextstream.h ../core/textstream.h notifythread.h
|
||||
notify.o: ../core/basethread.h ../core/synchro.h templatesnotify.h
|
||||
notify.o: ../core/config.h ../core/confparser.h ../core/htmlfilter.h
|
||||
notify.o: ../core/users.h ../core/user.h ../core/ugcontainer.h ../core/log.h
|
||||
notify.o: ../core/textstream.h ../core/logmanipulators.h ../core/slog.h
|
||||
notify.o: ../core/cur.h ../core/request.h ../core/error.h ../core/config.h
|
||||
notify.o: ../templates/htmltextstream.h ../core/session.h
|
||||
notify.o: ../core/plugindata.h ../core/rebus.h ../core/mount.h
|
||||
notify.o: ../core/lastcontainer.h ../db/db.h ../db/dbbase.h ../db/dbconn.h
|
||||
notify.o: ../db/dbtextstream.h ../core/error.h ../db/dbitemquery.h
|
||||
notify.o: ../core/item.h ../db/dbitemcolumns.h ../core/group.h
|
||||
notify.o: ../core/dircontainer.h ../core/ugcontainer.h
|
||||
notify.o: ../templates/templates.h ../templates/patterncacher.h
|
||||
notify.o: ../templates/indexpatterns.h ../core/cur.h ../core/system.h
|
||||
notify.o: ../core/dirs.h ../core/dircontainer.h ../notify/notify.h
|
||||
notify.o: ../core/mounts.h ../core/mountparser.h ../core/crypt.h
|
||||
notify.o: ../core/run.h ../core/users.h ../core/groups.h ../core/group.h
|
||||
notify.o: ../core/loadavg.h ../core/thumb.h ../core/basethread.h
|
||||
notify.o: ../core/threadmanager.h ../core/sessionmanager.h
|
||||
notify.o: ../core/sessioncontainer.h ../core/system.h ../core/htmlfilter.h
|
||||
notify.o: ../core/request.h ../core/dirs.h ../core/synchro.h ../core/plugin.h
|
||||
notify.o: ../core/cur.h ../core/request.h ../core/requesttypes.h
|
||||
notify.o: ../core/error.h ../core/config.h ../templates/htmltextstream.h
|
||||
notify.o: ../core/session.h ../core/plugindata.h ../core/rebus.h
|
||||
notify.o: ../core/mount.h ../core/lastcontainer.h ../db/db.h ../db/dbbase.h
|
||||
notify.o: ../db/dbconn.h ../db/dbtextstream.h ../core/error.h
|
||||
notify.o: ../db/dbitemquery.h ../core/item.h ../db/dbitemcolumns.h
|
||||
notify.o: ../core/user.h ../core/group.h ../core/dircontainer.h
|
||||
notify.o: ../core/ugcontainer.h ../templates/misc.h ../templates/templates.h
|
||||
notify.o: ../templates/patterncacher.h ../templates/indexpatterns.h
|
||||
notify.o: ../templates/patterns.h ../templates/changepatterns.h ../core/cur.h
|
||||
notify.o: ../core/system.h ../core/dirs.h ../core/dircontainer.h
|
||||
notify.o: ../notify/notify.h ../core/mounts.h ../core/mountparser.h
|
||||
notify.o: ../core/crypt.h ../core/run.h ../core/users.h ../core/groups.h
|
||||
notify.o: ../core/group.h ../core/loadavg.h ../core/thumb.h
|
||||
notify.o: ../core/basethread.h ../core/threadmanager.h
|
||||
notify.o: ../core/sessionmanager.h ../core/sessioncontainer.h
|
||||
notify.o: ../core/system.h ../core/htmlfilter.h ../core/request.h
|
||||
notify.o: ../core/dirs.h ../core/synchro.h ../core/plugin.h
|
||||
notify.o: ../core/pluginmsg.h ../core/sessionmanager.h
|
||||
notify.o: ../functions/functions.h ../functions/functionbase.h
|
||||
notify.o: ../functions/functionparser.h ../functions/adduser.h
|
||||
@@ -48,31 +50,34 @@ notifythread.o: templatesnotify.h ../../ezc/src/ezc.h ../../ezc/src/utf8.h
|
||||
notifythread.o: ../../ezc/src/generator.h ../../ezc/src/pattern.h
|
||||
notifythread.o: ../../ezc/src/item.h ../../ezc/src/funinfo.h
|
||||
notifythread.o: ../../ezc/src/functions.h ../../ezc/src/stringconv.h
|
||||
notifythread.o: ../core/textstream.h ../core/misc.h ../core/requesttypes.h
|
||||
notifythread.o: notifypool.h ../templates/locale.h ../core/confparser.h
|
||||
notifythread.o: ../templates/misc.h ../templates/localefilter.h
|
||||
notifythread.o: ../templates/locale.h ../templates/htmltextstream.h
|
||||
notifythread.o: ../core/user.h ../core/config.h ../core/confparser.h
|
||||
notifythread.o: ../core/htmlfilter.h ../core/users.h ../core/user.h
|
||||
notifythread.o: ../core/ugcontainer.h ../core/log.h ../core/textstream.h
|
||||
notifythread.o: ../core/logmanipulators.h ../core/slog.h ../core/cur.h
|
||||
notifythread.o: ../core/request.h ../core/error.h ../core/config.h
|
||||
notifythread.o: ../core/textstream.h ../templates/misc.h
|
||||
notifythread.o: ../templates/localefilter.h ../templates/locale.h
|
||||
notifythread.o: ../templates/htmltextstream.h notifypool.h
|
||||
notifythread.o: ../templates/locale.h ../core/confparser.h ../core/config.h
|
||||
notifythread.o: ../core/confparser.h ../core/htmlfilter.h ../core/users.h
|
||||
notifythread.o: ../core/user.h ../core/ugcontainer.h ../core/log.h
|
||||
notifythread.o: ../core/textstream.h ../core/logmanipulators.h ../core/slog.h
|
||||
notifythread.o: ../core/cur.h ../core/request.h ../core/requesttypes.h
|
||||
notifythread.o: ../core/error.h ../core/config.h
|
||||
notifythread.o: ../templates/htmltextstream.h ../core/session.h
|
||||
notifythread.o: ../core/plugindata.h ../core/rebus.h ../core/mount.h
|
||||
notifythread.o: ../core/lastcontainer.h ../db/db.h ../db/dbbase.h
|
||||
notifythread.o: ../db/dbconn.h ../db/dbtextstream.h ../core/error.h
|
||||
notifythread.o: ../db/dbitemquery.h ../core/item.h ../db/dbitemcolumns.h
|
||||
notifythread.o: ../core/group.h ../core/dircontainer.h ../core/ugcontainer.h
|
||||
notifythread.o: ../core/user.h ../core/group.h ../core/dircontainer.h
|
||||
notifythread.o: ../core/ugcontainer.h ../templates/patterns.h
|
||||
templatesnotify.o: templatesnotify.h ../../ezc/src/ezc.h ../../ezc/src/utf8.h
|
||||
templatesnotify.o: ../../ezc/src/generator.h ../../ezc/src/pattern.h
|
||||
templatesnotify.o: ../../ezc/src/item.h ../../ezc/src/funinfo.h
|
||||
templatesnotify.o: ../../ezc/src/functions.h ../../ezc/src/stringconv.h
|
||||
templatesnotify.o: ../core/textstream.h ../core/misc.h ../core/requesttypes.h
|
||||
templatesnotify.o: notifypool.h ../templates/locale.h ../core/confparser.h
|
||||
templatesnotify.o: ../core/textstream.h ../templates/misc.h
|
||||
templatesnotify.o: ../templates/localefilter.h ../templates/locale.h
|
||||
templatesnotify.o: ../templates/htmltextstream.h notifypool.h
|
||||
templatesnotify.o: ../templates/locale.h ../core/confparser.h
|
||||
templatesnotify.o: ../core/plugin.h ../core/pluginmsg.h ../core/log.h
|
||||
templatesnotify.o: ../core/textstream.h ../core/logmanipulators.h
|
||||
templatesnotify.o: ../core/slog.h ../core/cur.h ../core/request.h
|
||||
templatesnotify.o: ../core/error.h ../core/config.h
|
||||
templatesnotify.o: ../core/requesttypes.h ../core/error.h ../core/config.h
|
||||
templatesnotify.o: ../templates/htmltextstream.h ../core/session.h
|
||||
templatesnotify.o: ../core/user.h ../core/plugindata.h ../core/rebus.h
|
||||
templatesnotify.o: ../core/mount.h ../core/system.h ../core/sessionmanager.h
|
||||
@@ -108,7 +113,7 @@ templatesnotify.o: ../functions/uname.h ../functions/upload.h
|
||||
templatesnotify.o: ../functions/uptime.h ../functions/who.h
|
||||
templatesnotify.o: ../functions/vim.h ../core/htmlfilter.h
|
||||
templatesnotify.o: ../templates/templates.h ../templates/patterncacher.h
|
||||
templatesnotify.o: ../templates/indexpatterns.h ../templates/localefilter.h
|
||||
templatesnotify.o: ../templates/locale.h ../templates/htmltextstream.h
|
||||
templatesnotify.o: ../core/sessionmanager.h ../core/sessioncontainer.h
|
||||
templatesnotify.o: ../core/lastcontainer.h ../core/misc.h
|
||||
templatesnotify.o: ../templates/indexpatterns.h ../templates/patterns.h
|
||||
templatesnotify.o: ../templates/changepatterns.h ../core/sessionmanager.h
|
||||
templatesnotify.o: ../core/sessioncontainer.h ../core/lastcontainer.h
|
||||
templatesnotify.o: ../core/misc.h
|
||||
|
||||
@@ -69,6 +69,11 @@ void Notify::Init()
|
||||
notify_thread.SetSynchro(synchro);
|
||||
thread_manager->Add(¬ify_thread);
|
||||
|
||||
patterns.SetUTF8(config->utf8);
|
||||
patterns.SetDirectories(config->txt_templates_dir, config->txt_templates_dir_default);
|
||||
patterns.SetLocale(&TemplatesFunctions::locale);
|
||||
patterns.SetLocaleFilter(&TemplatesFunctions::locale_filter);
|
||||
|
||||
notify_template_cms = AddTemplate(L"notify_email_cms.txt");
|
||||
|
||||
plugin.Call(WINIX_NOTIFY_ADD_TEMPLATE);
|
||||
@@ -78,29 +83,7 @@ void Notify::Init()
|
||||
|
||||
void Notify::ReadTemplates()
|
||||
{
|
||||
if( templates_names.empty() )
|
||||
{
|
||||
patterns.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
patterns.resize(TemplatesFunctions::locale.Size());
|
||||
|
||||
for(size_t i=0 ; i<patterns.size() ; ++i)
|
||||
{
|
||||
patterns[i].resize(templates_names.size());
|
||||
|
||||
for(size_t a=0 ; a<patterns[i].size() ; ++a)
|
||||
{
|
||||
patterns[i][a].UTF8(config->utf8);
|
||||
patterns[i][a].DeleteWhiteTextItems(false);
|
||||
patterns[i][a].Directory(config->txt_templates_dir, config->txt_templates_dir_default);
|
||||
patterns[i][a].ParseFile(templates_names[a]);
|
||||
|
||||
TemplatesFunctions::locale_filter.Filter(patterns[i][a], TemplatesFunctions::locale, i);
|
||||
}
|
||||
}
|
||||
|
||||
patterns.Reload();
|
||||
notify_thread.PatternsChanged();
|
||||
}
|
||||
|
||||
@@ -132,10 +115,7 @@ void Notify::ItemChanged(const NotifyMsg & msg)
|
||||
|
||||
size_t Notify::AddTemplate(const std::wstring & file_name)
|
||||
{
|
||||
size_t index = templates_names.size();
|
||||
templates_names.push_back(file_name);
|
||||
|
||||
return index;
|
||||
return patterns.Add(file_name, false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -13,9 +13,12 @@
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "notifypool.h"
|
||||
#include "templates/misc.h"
|
||||
#include "templates/patterns.h"
|
||||
#include "notifythread.h"
|
||||
|
||||
// !! skasowac?
|
||||
#include "templates/misc.h"
|
||||
|
||||
|
||||
class Request;
|
||||
class Config;
|
||||
@@ -61,11 +64,7 @@ private:
|
||||
|
||||
size_t notify_template_cms;
|
||||
|
||||
// templates file names
|
||||
std::vector<std::wstring> templates_names;
|
||||
|
||||
// vector table [language][file]
|
||||
TemplatesFunctions::Patterns patterns;
|
||||
Patterns patterns;
|
||||
|
||||
void CreateItemLink(const Item & item, std::wstring & link, std::wstring & dir_link);
|
||||
};
|
||||
|
||||
@@ -41,7 +41,7 @@ void NotifyThread::SetNotifyPool(NotifyPool * pool)
|
||||
|
||||
|
||||
// first thread (objects are locked)
|
||||
void NotifyThread::SetPatterns(TemplatesFunctions::Patterns * pat)
|
||||
void NotifyThread::SetPatterns(Patterns * pat)
|
||||
{
|
||||
pat_global = pat;
|
||||
}
|
||||
@@ -163,24 +163,25 @@ void NotifyThread::SendMail()
|
||||
size_t lang_index = TemplatesNotifyFunctions::notify_user_msg.lang;
|
||||
size_t template_index = TemplatesNotifyFunctions::notify_msg.template_index;
|
||||
|
||||
if( lang_index >= patterns.size() )
|
||||
return;
|
||||
Lock();
|
||||
// 'patterns' object can use logger or other stuff so we use Lock() before
|
||||
Ezc::Pattern * pat = patterns.Get(template_index, lang_index);
|
||||
|
||||
if( template_index >= patterns[lang_index].size() )
|
||||
if( !pat )
|
||||
log << log1 << "NotifyThread: I don't have a template with index: " << template_index
|
||||
<< " and locale index: " << lang_index << logend;
|
||||
|
||||
Unlock();
|
||||
|
||||
if( pat )
|
||||
{
|
||||
Lock();
|
||||
log << log1 << "NotifyThread: incorrect template index: " << template_index << logend;
|
||||
Unlock();
|
||||
return;
|
||||
generator.RecognizeSpecialChars(true);
|
||||
generator.TrimWhite(true);
|
||||
generator.SkipNewLine(true);
|
||||
generator.Generate(notify_stream, *pat, TemplatesNotifyFunctions::ezc_functions);
|
||||
|
||||
SendMail(TemplatesNotifyFunctions::notify_user_msg.email, notify_stream.Str());
|
||||
}
|
||||
|
||||
generator.RecognizeSpecialChars(true);
|
||||
generator.TrimWhite(true);
|
||||
generator.SkipNewLine(true);
|
||||
generator.Generate(notify_stream, patterns[lang_index][template_index],
|
||||
TemplatesNotifyFunctions::ezc_functions);
|
||||
|
||||
SendMail(TemplatesNotifyFunctions::notify_user_msg.email, notify_stream.Str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
#include "core/basethread.h"
|
||||
#include "templatesnotify.h"
|
||||
#include "ezc.h"
|
||||
#include "templates/misc.h"
|
||||
#include "core/config.h"
|
||||
#include "core/users.h"
|
||||
#include "templates/patterns.h"
|
||||
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ public:
|
||||
void SetConfig(Config * pconfig);
|
||||
void SetUsers(Users * pusers);
|
||||
void SetNotifyPool(NotifyPool * pool);
|
||||
void SetPatterns(TemplatesFunctions::Patterns * pat);
|
||||
void SetPatterns(Patterns * pat);
|
||||
void PatternsChanged();
|
||||
|
||||
private:
|
||||
@@ -38,14 +38,14 @@ private:
|
||||
Config * config;
|
||||
Users * users;
|
||||
NotifyPool * notify_pool;
|
||||
TemplatesFunctions::Patterns * pat_global;
|
||||
Patterns * pat_global;
|
||||
|
||||
NotifyUserMsg msg;
|
||||
typedef std::list<NotifyUserMsg> NotifyUser;
|
||||
NotifyUser notify_user;
|
||||
std::string sendmail_command;
|
||||
bool patterns_changed;
|
||||
TemplatesFunctions::Patterns patterns;
|
||||
Patterns patterns;
|
||||
TemplatesNotifyFunctions::NotifyStream notify_stream;
|
||||
Ezc::Generator<TemplatesNotifyFunctions::NotifyStream> generator;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user