added ticket parser: plugins/ticket/ticketparser.h plugins/ticket/ticketparser.cpp
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@663 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
@@ -3,20 +3,21 @@
|
||||
createticket.o: createticket.h tdb.h ticket.h ../../db/dbbase.h
|
||||
createticket.o: ../../db/dbconn.h ../../db/dbtextstream.h
|
||||
createticket.o: ../../core/textstream.h ../../core/error.h ../../core/log.h
|
||||
createticket.o: ticketinfo.h ../../core/item.h ../../core/system.h
|
||||
createticket.o: ../../core/dirs.h ../../core/item.h ../../core/dircontainer.h
|
||||
createticket.o: ../../db/db.h ../../db/dbbase.h ../../db/dbitemquery.h
|
||||
createticket.o: ../../db/dbitemcolumns.h ../../core/user.h ../../core/group.h
|
||||
createticket.o: ../../core/thread.h ../../core/dircontainer.h
|
||||
createticket.o: ../../core/ugcontainer.h ../../core/request.h
|
||||
createticket.o: ../../core/requesttypes.h ../../core/session.h
|
||||
createticket.o: ../../core/error.h ../../core/user.h ../../core/plugindata.h
|
||||
createticket.o: ../../core/rebus.h ../../core/config.h
|
||||
createticket.o: ../../core/confparser.h ../../core/htmlfilter.h
|
||||
createticket.o: ../../core/mounts.h ../../core/mount.h
|
||||
createticket.o: ../../core/mountparser.h ../../core/users.h
|
||||
createticket.o: ../../core/ugcontainer.h ../../core/lastcontainer.h
|
||||
createticket.o: ../../core/groups.h ../../core/group.h ../../core/loadavg.h
|
||||
createticket.o: ticketinfo.h ticketparser.h ticketconf.h ../../core/item.h
|
||||
createticket.o: ../../core/system.h ../../core/dirs.h ../../core/item.h
|
||||
createticket.o: ../../core/dircontainer.h ../../db/db.h ../../db/dbbase.h
|
||||
createticket.o: ../../db/dbitemquery.h ../../db/dbitemcolumns.h
|
||||
createticket.o: ../../core/user.h ../../core/group.h ../../core/thread.h
|
||||
createticket.o: ../../core/dircontainer.h ../../core/ugcontainer.h
|
||||
createticket.o: ../../core/request.h ../../core/requesttypes.h
|
||||
createticket.o: ../../core/session.h ../../core/error.h ../../core/user.h
|
||||
createticket.o: ../../core/plugindata.h ../../core/rebus.h
|
||||
createticket.o: ../../core/config.h ../../core/confparser.h
|
||||
createticket.o: ../../core/htmlfilter.h ../../core/mounts.h
|
||||
createticket.o: ../../core/mount.h ../../core/mountparser.h
|
||||
createticket.o: ../../core/users.h ../../core/ugcontainer.h
|
||||
createticket.o: ../../core/lastcontainer.h ../../core/groups.h
|
||||
createticket.o: ../../core/group.h ../../core/loadavg.h
|
||||
createticket.o: ../../functions/functionbase.h ../../core/request.h
|
||||
createticket.o: ../../core/config.h ../../core/notify.h
|
||||
createticket.o: ../../templatesnotify/templatesnotify.h
|
||||
@@ -42,10 +43,10 @@ createticket.o: ../../functions/upload.h ../../functions/uptime.h
|
||||
createticket.o: ../../functions/who.h ../../core/htmlfilter.h
|
||||
editticket.o: editticket.h tdb.h ticket.h ../../db/dbbase.h ../../db/dbconn.h
|
||||
editticket.o: ../../db/dbtextstream.h ../../core/textstream.h
|
||||
editticket.o: ../../core/error.h ../../core/log.h ticketinfo.h
|
||||
editticket.o: ../../core/item.h ../../core/system.h ../../core/dirs.h
|
||||
editticket.o: ../../core/item.h ../../core/dircontainer.h ../../db/db.h
|
||||
editticket.o: ../../db/dbbase.h ../../db/dbitemquery.h
|
||||
editticket.o: ../../core/error.h ../../core/log.h ticketinfo.h ticketparser.h
|
||||
editticket.o: ticketconf.h ../../core/item.h ../../core/system.h
|
||||
editticket.o: ../../core/dirs.h ../../core/item.h ../../core/dircontainer.h
|
||||
editticket.o: ../../db/db.h ../../db/dbbase.h ../../db/dbitemquery.h
|
||||
editticket.o: ../../db/dbitemcolumns.h ../../core/user.h ../../core/group.h
|
||||
editticket.o: ../../core/thread.h ../../core/dircontainer.h
|
||||
editticket.o: ../../core/ugcontainer.h ../../core/request.h
|
||||
@@ -81,10 +82,10 @@ editticket.o: ../../functions/uptime.h ../../functions/who.h
|
||||
editticket.o: ../../core/htmlfilter.h
|
||||
funticket.o: funticket.h tdb.h ticket.h ../../db/dbbase.h ../../db/dbconn.h
|
||||
funticket.o: ../../db/dbtextstream.h ../../core/textstream.h
|
||||
funticket.o: ../../core/error.h ../../core/log.h ticketinfo.h
|
||||
funticket.o: ../../core/item.h ../../core/system.h ../../core/dirs.h
|
||||
funticket.o: ../../core/item.h ../../core/dircontainer.h ../../db/db.h
|
||||
funticket.o: ../../db/dbbase.h ../../db/dbitemquery.h
|
||||
funticket.o: ../../core/error.h ../../core/log.h ticketinfo.h ticketparser.h
|
||||
funticket.o: ticketconf.h ../../core/item.h ../../core/system.h
|
||||
funticket.o: ../../core/dirs.h ../../core/item.h ../../core/dircontainer.h
|
||||
funticket.o: ../../db/db.h ../../db/dbbase.h ../../db/dbitemquery.h
|
||||
funticket.o: ../../db/dbitemcolumns.h ../../core/user.h ../../core/group.h
|
||||
funticket.o: ../../core/thread.h ../../core/dircontainer.h
|
||||
funticket.o: ../../core/ugcontainer.h ../../core/request.h
|
||||
@@ -103,17 +104,17 @@ funticket.o: ../../templates/localefilter.h ../../core/locale.h
|
||||
funticket.o: ../../core/system.h
|
||||
init.o: tdb.h ticket.h ../../db/dbbase.h ../../db/dbconn.h
|
||||
init.o: ../../db/dbtextstream.h ../../core/textstream.h ../../core/error.h
|
||||
init.o: ../../core/log.h funticket.h ticketinfo.h ../../core/item.h
|
||||
init.o: ../../core/system.h ../../core/dirs.h ../../core/item.h
|
||||
init.o: ../../core/dircontainer.h ../../db/db.h ../../db/dbbase.h
|
||||
init.o: ../../db/dbitemquery.h ../../db/dbitemcolumns.h ../../core/user.h
|
||||
init.o: ../../core/group.h ../../core/thread.h ../../core/dircontainer.h
|
||||
init.o: ../../core/ugcontainer.h ../../core/request.h
|
||||
init.o: ../../core/requesttypes.h ../../core/session.h ../../core/error.h
|
||||
init.o: ../../core/user.h ../../core/plugindata.h ../../core/rebus.h
|
||||
init.o: ../../core/config.h ../../core/confparser.h ../../core/htmlfilter.h
|
||||
init.o: ../../core/mounts.h ../../core/mount.h ../../core/mountparser.h
|
||||
init.o: ../../core/users.h ../../core/ugcontainer.h
|
||||
init.o: ../../core/log.h funticket.h ticketinfo.h ticketparser.h ticketconf.h
|
||||
init.o: ../../core/item.h ../../core/system.h ../../core/dirs.h
|
||||
init.o: ../../core/item.h ../../core/dircontainer.h ../../db/db.h
|
||||
init.o: ../../db/dbbase.h ../../db/dbitemquery.h ../../db/dbitemcolumns.h
|
||||
init.o: ../../core/user.h ../../core/group.h ../../core/thread.h
|
||||
init.o: ../../core/dircontainer.h ../../core/ugcontainer.h
|
||||
init.o: ../../core/request.h ../../core/requesttypes.h ../../core/session.h
|
||||
init.o: ../../core/error.h ../../core/user.h ../../core/plugindata.h
|
||||
init.o: ../../core/rebus.h ../../core/config.h ../../core/confparser.h
|
||||
init.o: ../../core/htmlfilter.h ../../core/mounts.h ../../core/mount.h
|
||||
init.o: ../../core/mountparser.h ../../core/users.h ../../core/ugcontainer.h
|
||||
init.o: ../../core/lastcontainer.h ../../core/groups.h ../../core/group.h
|
||||
init.o: ../../core/loadavg.h ../../functions/functionbase.h
|
||||
init.o: ../../core/request.h ../../core/config.h ../../core/notify.h
|
||||
@@ -143,42 +144,43 @@ init.o: ../../templates/misc.h ../../templates/patterncacher.h
|
||||
init.o: ../../core/item.h ../../templates/ckeditorgetparser.h
|
||||
init.o: ../../core/httpsimpleparser.h ../../core/log.h
|
||||
init.o: ../../templates/indexpatterns.h ../../core/sessionmanager.h
|
||||
readticket.o: readticket.h ticket.h ticketinfo.h ../../core/item.h
|
||||
readticket.o: ../../core/system.h ../../core/dirs.h ../../core/item.h
|
||||
readticket.o: ../../core/dircontainer.h ../../db/db.h ../../db/dbbase.h
|
||||
readticket.o: ../../db/dbitemquery.h ../../db/dbitemcolumns.h
|
||||
readticket.o: ../../core/user.h ../../core/group.h ../../core/thread.h
|
||||
readticket.o: ../../core/error.h ../../core/log.h ../../core/dircontainer.h
|
||||
readticket.o: ../../core/ugcontainer.h ../../core/request.h
|
||||
readticket.o: ../../core/requesttypes.h ../../core/session.h
|
||||
readticket.o: ../../core/error.h ../../core/user.h ../../core/plugindata.h
|
||||
readticket.o: ../../core/rebus.h ../../core/config.h ../../core/confparser.h
|
||||
readticket.o: ../../core/htmlfilter.h ../../core/mounts.h ../../core/mount.h
|
||||
readticket.o: ../../core/mountparser.h ../../core/users.h
|
||||
readticket.o: ../../core/ugcontainer.h ../../core/lastcontainer.h
|
||||
readticket.o: ../../core/groups.h ../../core/group.h ../../core/loadavg.h
|
||||
readticket.o: tdb.h ../../db/dbbase.h ../../db/dbconn.h
|
||||
readticket.o: ../../db/dbtextstream.h ../../core/textstream.h
|
||||
readticket.o: ../../core/request.h
|
||||
readticket.o: readticket.h ticket.h ticketinfo.h ticketparser.h ticketconf.h
|
||||
readticket.o: ../../core/item.h ../../core/system.h ../../core/dirs.h
|
||||
readticket.o: ../../core/item.h ../../core/dircontainer.h ../../db/db.h
|
||||
readticket.o: ../../db/dbbase.h ../../db/dbitemquery.h
|
||||
readticket.o: ../../db/dbitemcolumns.h ../../core/user.h ../../core/group.h
|
||||
readticket.o: ../../core/thread.h ../../core/error.h ../../core/log.h
|
||||
readticket.o: ../../core/dircontainer.h ../../core/ugcontainer.h
|
||||
readticket.o: ../../core/request.h ../../core/requesttypes.h
|
||||
readticket.o: ../../core/session.h ../../core/error.h ../../core/user.h
|
||||
readticket.o: ../../core/plugindata.h ../../core/rebus.h ../../core/config.h
|
||||
readticket.o: ../../core/confparser.h ../../core/htmlfilter.h
|
||||
readticket.o: ../../core/mounts.h ../../core/mount.h ../../core/mountparser.h
|
||||
readticket.o: ../../core/users.h ../../core/ugcontainer.h
|
||||
readticket.o: ../../core/lastcontainer.h ../../core/groups.h
|
||||
readticket.o: ../../core/group.h ../../core/loadavg.h tdb.h ../../db/dbbase.h
|
||||
readticket.o: ../../db/dbconn.h ../../db/dbtextstream.h
|
||||
readticket.o: ../../core/textstream.h ../../core/request.h
|
||||
tdb.o: tdb.h ticket.h ../../db/dbbase.h ../../db/dbconn.h
|
||||
tdb.o: ../../db/dbtextstream.h ../../core/textstream.h ../../core/error.h
|
||||
tdb.o: ../../core/log.h ../../core/log.h
|
||||
templates.o: ../../../ezc/src/ezc.h ticketinfo.h ticket.h ../../core/item.h
|
||||
templates.o: ../../core/system.h ../../core/dirs.h ../../core/item.h
|
||||
templates.o: ../../core/dircontainer.h ../../db/db.h ../../db/dbbase.h
|
||||
templates.o: ../../db/dbitemquery.h ../../db/dbitemcolumns.h
|
||||
templates.o: ../../core/user.h ../../core/group.h ../../core/thread.h
|
||||
templates.o: ../../core/error.h ../../core/log.h ../../core/dircontainer.h
|
||||
templates.o: ../../core/ugcontainer.h ../../core/request.h
|
||||
templates.o: ../../core/requesttypes.h ../../core/session.h
|
||||
templates.o: ../../core/error.h ../../core/user.h ../../core/plugindata.h
|
||||
templates.o: ../../core/rebus.h ../../core/config.h ../../core/confparser.h
|
||||
templates.o: ../../core/htmlfilter.h ../../core/mounts.h ../../core/mount.h
|
||||
templates.o: ../../core/mountparser.h ../../core/users.h
|
||||
templates.o: ../../core/ugcontainer.h ../../core/lastcontainer.h
|
||||
templates.o: ../../core/groups.h ../../core/group.h ../../core/loadavg.h
|
||||
templates.o: tdb.h ../../db/dbbase.h ../../db/dbconn.h
|
||||
templates.o: ../../db/dbtextstream.h ../../core/textstream.h editticket.h
|
||||
templates.o: ../../../ezc/src/ezc.h ticketinfo.h ticket.h ticketparser.h
|
||||
templates.o: ticketconf.h ../../core/item.h ../../core/system.h
|
||||
templates.o: ../../core/dirs.h ../../core/item.h ../../core/dircontainer.h
|
||||
templates.o: ../../db/db.h ../../db/dbbase.h ../../db/dbitemquery.h
|
||||
templates.o: ../../db/dbitemcolumns.h ../../core/user.h ../../core/group.h
|
||||
templates.o: ../../core/thread.h ../../core/error.h ../../core/log.h
|
||||
templates.o: ../../core/dircontainer.h ../../core/ugcontainer.h
|
||||
templates.o: ../../core/request.h ../../core/requesttypes.h
|
||||
templates.o: ../../core/session.h ../../core/error.h ../../core/user.h
|
||||
templates.o: ../../core/plugindata.h ../../core/rebus.h ../../core/config.h
|
||||
templates.o: ../../core/confparser.h ../../core/htmlfilter.h
|
||||
templates.o: ../../core/mounts.h ../../core/mount.h ../../core/mountparser.h
|
||||
templates.o: ../../core/users.h ../../core/ugcontainer.h
|
||||
templates.o: ../../core/lastcontainer.h ../../core/groups.h
|
||||
templates.o: ../../core/group.h ../../core/loadavg.h tdb.h ../../db/dbbase.h
|
||||
templates.o: ../../db/dbconn.h ../../db/dbtextstream.h
|
||||
templates.o: ../../core/textstream.h editticket.h
|
||||
templates.o: ../../functions/functionbase.h ../../core/request.h
|
||||
templates.o: ../../core/config.h ../../core/notify.h
|
||||
templates.o: ../../templatesnotify/templatesnotify.h ../../core/mount.h
|
||||
@@ -209,9 +211,11 @@ templates.o: ../../templates/patterncacher.h ../../core/item.h
|
||||
templates.o: ../../templates/ckeditorgetparser.h
|
||||
templates.o: ../../core/httpsimpleparser.h ../../core/log.h
|
||||
templates.o: ../../templates/indexpatterns.h ../../core/sessionmanager.h
|
||||
ticketinfo.o: ticketinfo.h ticket.h ../../core/item.h ../../core/system.h
|
||||
ticketinfo.o: ../../core/dirs.h ../../core/item.h ../../core/dircontainer.h
|
||||
ticketinfo.o: ../../db/db.h ../../db/dbbase.h ../../db/dbitemquery.h
|
||||
ticketconf.o: ticketconf.h
|
||||
ticketinfo.o: ticketinfo.h ticket.h ticketparser.h ticketconf.h
|
||||
ticketinfo.o: ../../core/item.h ../../core/system.h ../../core/dirs.h
|
||||
ticketinfo.o: ../../core/item.h ../../core/dircontainer.h ../../db/db.h
|
||||
ticketinfo.o: ../../db/dbbase.h ../../db/dbitemquery.h
|
||||
ticketinfo.o: ../../db/dbitemcolumns.h ../../core/user.h ../../core/group.h
|
||||
ticketinfo.o: ../../core/thread.h ../../core/error.h ../../core/log.h
|
||||
ticketinfo.o: ../../core/dircontainer.h ../../core/ugcontainer.h
|
||||
@@ -224,4 +228,5 @@ ticketinfo.o: ../../core/users.h ../../core/ugcontainer.h
|
||||
ticketinfo.o: ../../core/lastcontainer.h ../../core/groups.h
|
||||
ticketinfo.o: ../../core/group.h ../../core/loadavg.h tdb.h ../../db/dbbase.h
|
||||
ticketinfo.o: ../../db/dbconn.h ../../db/dbtextstream.h
|
||||
ticketinfo.o: ../../core/textstream.h
|
||||
ticketinfo.o: ../../core/textstream.h ../../core/log.h
|
||||
ticketparser.o: ticketparser.h ticketconf.h ../../core/log.h
|
||||
|
@@ -1 +1 @@
|
||||
o = createticket.o editticket.o funticket.o init.o readticket.o tdb.o templates.o ticketinfo.o
|
||||
o = createticket.o editticket.o funticket.o init.o readticket.o tdb.o templates.o ticketconf.o ticketinfo.o ticketparser.o
|
||||
|
@@ -55,6 +55,8 @@ void AddMounts(PluginInfo & info)
|
||||
|
||||
ticket_info.mount_type_ticket = m.AddMountType("ticket");
|
||||
ticket_info.mount_par_ticket = m.AddMountPar("ticket");
|
||||
ticket_info.mount_par_ticket_conf = m.AddMountPar("ticket_conf");
|
||||
|
||||
ticket_info.mount_par_ticket_type = m.AddMountPar("ticket_type");
|
||||
ticket_info.mount_par_ticket_type_default = m.AddMountPar("ticket_type_default");
|
||||
ticket_info.mount_par_ticket_status = m.AddMountPar("ticket_status");
|
||||
@@ -69,6 +71,24 @@ void AddMounts(PluginInfo & info)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void FstabChanged(PluginInfo & info)
|
||||
{
|
||||
ticket_info.ReadTicketConf(true);
|
||||
}
|
||||
|
||||
|
||||
void ContentMake(PluginInfo & info)
|
||||
{
|
||||
if( info.request->function == &info.functions->fun_reload )
|
||||
{
|
||||
if( info.request->IsParam("tickets") )
|
||||
ticket_info.ReadTicketConf();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void AddEzcFunctions(PluginInfo & info);
|
||||
|
||||
} // namespace Ticket
|
||||
@@ -83,6 +103,8 @@ using namespace Ticket;
|
||||
plugin.Assign(WINIX_CREATE_FUNCTIONS, AddFunctions);
|
||||
plugin.Assign(WINIX_SELECT_DEFAULT_FUNCTION, SelectDefaultFunction);
|
||||
plugin.Assign(WINIX_ADD_MOUNTS, AddMounts);
|
||||
plugin.Assign(WINIX_FSTAB_CHANGED, FstabChanged);
|
||||
plugin.Assign(WINIX_CONTENT_MAKE, ContentMake);
|
||||
|
||||
tdb.SetConn(info.db->GetConn());
|
||||
|
||||
|
28
plugins/ticket/ticketconf.cpp
Executable file
28
plugins/ticket/ticketconf.cpp
Executable file
@@ -0,0 +1,28 @@
|
||||
#include <limits>
|
||||
#include "ticketconf.h"
|
||||
|
||||
|
||||
TicketConf::TicketItem::TicketItem()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
|
||||
void TicketConf::TicketItem::Clear()
|
||||
{
|
||||
id = 0;
|
||||
name.clear();
|
||||
type = TypeInteger;
|
||||
integer_min = std::numeric_limits<int>::min();
|
||||
integer_max = std::numeric_limits<int>::max();
|
||||
select.clear();
|
||||
select_default = 0;
|
||||
}
|
||||
|
||||
void TicketConf::Clear()
|
||||
{
|
||||
tab.clear();
|
||||
}
|
||||
|
||||
|
||||
|
47
plugins/ticket/ticketconf.h
Executable file
47
plugins/ticket/ticketconf.h
Executable file
@@ -0,0 +1,47 @@
|
||||
#ifndef headerfile_winix_plugins_ticket_ticketconf
|
||||
#define headerfile_winix_plugins_ticket_ticketconf
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
|
||||
|
||||
|
||||
struct TicketConf
|
||||
{
|
||||
struct TicketItem
|
||||
{
|
||||
struct Select
|
||||
{
|
||||
std::string name;
|
||||
int id;
|
||||
};
|
||||
|
||||
|
||||
TicketItem();
|
||||
void Clear();
|
||||
|
||||
enum Type { TypeInteger, TypeSelect };
|
||||
|
||||
int id;
|
||||
|
||||
std::string name;
|
||||
Type type;
|
||||
|
||||
// used when type is TypeInteger
|
||||
int integer_min, integer_max;
|
||||
|
||||
// used when type is TypeSelect
|
||||
std::vector<Select> select;
|
||||
size_t select_default;
|
||||
};
|
||||
|
||||
typedef std::vector<TicketItem> Table;
|
||||
Table tab;
|
||||
|
||||
void Clear();
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@@ -11,7 +11,7 @@
|
||||
#include <ctime>
|
||||
#include "ticketinfo.h"
|
||||
#include "core/error.h"
|
||||
|
||||
#include "core/log.h"
|
||||
|
||||
|
||||
namespace Ticket
|
||||
@@ -81,4 +81,124 @@ std::vector<Ticket>::iterator i;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void TicketInfo::MarkAllConfToDelete()
|
||||
{
|
||||
ConfTab::iterator i = conf_tab.begin();
|
||||
|
||||
for( ; i!=conf_tab.end() ; ++i)
|
||||
i->second.to_delete = true;
|
||||
}
|
||||
|
||||
|
||||
void TicketInfo::DeleteAllMarkedConf()
|
||||
{
|
||||
ConfTab::iterator inext;
|
||||
ConfTab::iterator i = conf_tab.begin();
|
||||
|
||||
while( i != conf_tab.end() )
|
||||
{
|
||||
inext = i;
|
||||
++inext;
|
||||
|
||||
if( i->second.to_delete )
|
||||
{
|
||||
log << log3 << "Ticket: deleting ticket conf for dir id: " << i->first << logend;
|
||||
conf_tab.erase(i);
|
||||
}
|
||||
|
||||
i = inext;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool TicketInfo::GetConfContent(const std::string & path)
|
||||
{
|
||||
long path_dir_id;
|
||||
|
||||
if( system->dirs.AnalyzePath(path, path_dir_id, path_dir, path_file) != 0 )
|
||||
{
|
||||
log << log1 << "Ticket: there is no file: " << path << logend;
|
||||
return false;
|
||||
}
|
||||
|
||||
Error err = db->GetItem(path_dir_id, path_file, item_conf);
|
||||
|
||||
if( err == WINIX_ERR_NO_ITEM )
|
||||
{
|
||||
log << log1 << "Ticket: there is no file: " << path << " in the database" << logend;
|
||||
return false;
|
||||
}
|
||||
|
||||
if( err != WINIX_ERR_OK )
|
||||
{
|
||||
log << log1 << "Ticket: db problem with fetching: " << path << logend;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool TicketInfo::ParseTicketConf(long mount_dir_id, const std::string & path)
|
||||
{
|
||||
log << log3 << "Ticket: parsing conf file: " << path << logend;
|
||||
|
||||
int code = ticket_parser.Parse(item_conf.content, conf_tab[mount_dir_id].conf);
|
||||
conf_tab[mount_dir_id].file_name = path;
|
||||
|
||||
return code == WINIX_TICKET_ERR_OK;
|
||||
}
|
||||
|
||||
|
||||
// if skip_existing_configs is true then only new config files will be parsed
|
||||
void TicketInfo::ReadTicketConf(Mounts & mounts, bool skip_existing_configs)
|
||||
{
|
||||
Mounts::MountTab::const_iterator i;
|
||||
const Mounts::MountTab * mtab = mounts.GetMountTab();
|
||||
|
||||
// loop through all mount points
|
||||
for(i=mtab->begin() ; i!=mtab->end() ; ++i)
|
||||
{
|
||||
const Mount & mount = i->second;
|
||||
|
||||
if( mount.param[mount_par_ticket_conf].defined &&
|
||||
mount.param[mount_par_ticket_conf].arg.size() == 1 )
|
||||
{
|
||||
const std::string & file_name = mount.param[mount_par_ticket_conf].arg[0];
|
||||
ConfTab::iterator c = conf_tab.find(mount.dir_id);
|
||||
bool exists = (c != conf_tab.end() && c->second.file_name == file_name);
|
||||
|
||||
if( exists )
|
||||
c->second.to_delete = false;
|
||||
|
||||
if( !(skip_existing_configs && exists) )
|
||||
{
|
||||
if( GetConfContent(file_name) )
|
||||
{
|
||||
if( !ParseTicketConf(mount.dir_id, file_name) )
|
||||
conf_tab[mount.dir_id].to_delete = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( exists )
|
||||
c->second.to_delete = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// if skip_existing_configs is true then only new config files will be parsed
|
||||
void TicketInfo::ReadTicketConf(bool skip_existing_configs)
|
||||
{
|
||||
MarkAllConfToDelete();
|
||||
ReadTicketConf(system->mounts, skip_existing_configs);
|
||||
DeleteAllMarkedConf();
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace
|
||||
|
@@ -13,6 +13,7 @@
|
||||
|
||||
#include <vector>
|
||||
#include "ticket.h"
|
||||
#include "ticketparser.h"
|
||||
#include "core/item.h"
|
||||
#include "core/system.h"
|
||||
#include "db/db.h"
|
||||
@@ -24,6 +25,19 @@ namespace Ticket
|
||||
{
|
||||
|
||||
|
||||
struct TicketConfWrap
|
||||
{
|
||||
bool to_delete;
|
||||
std::string file_name;
|
||||
TicketConf conf;
|
||||
|
||||
TicketConfWrap()
|
||||
{
|
||||
to_delete = false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class TicketInfo
|
||||
{
|
||||
public:
|
||||
@@ -42,10 +56,18 @@ public:
|
||||
bool is_ticket;
|
||||
Ticket ticket;
|
||||
std::vector<Ticket> ticket_tab;
|
||||
|
||||
// <dir_id, TicketConfWrap>
|
||||
typedef std::map<long, TicketConfWrap> ConfTab;
|
||||
ConfTab conf_tab;
|
||||
|
||||
|
||||
|
||||
int mount_type_ticket;
|
||||
|
||||
int mount_par_ticket;
|
||||
int mount_par_ticket_conf;
|
||||
|
||||
int mount_par_ticket_type;
|
||||
int mount_par_ticket_type_default;
|
||||
int mount_par_ticket_status;
|
||||
@@ -59,15 +81,25 @@ public:
|
||||
|
||||
int mount_par_createticket_on;
|
||||
|
||||
|
||||
void ReadTicketConf(bool skip_existing_configs = false);
|
||||
|
||||
|
||||
private:
|
||||
TDb * tdb;
|
||||
Db * db;
|
||||
System * system;
|
||||
TicketParser ticket_parser;
|
||||
Item item_conf;
|
||||
std::string path_dir;
|
||||
std::string path_file;
|
||||
|
||||
static bool SortTicketsFun(const Ticket & t1, const Ticket & t2);
|
||||
bool GetConfContent(const std::string & path);
|
||||
bool ParseTicketConf(long mount_dir_id, const std::string & path);
|
||||
void ReadTicketConf(Mounts & mounts, bool skip_existing_configs);
|
||||
void MarkAllConfToDelete();
|
||||
void DeleteAllMarkedConf();
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
308
plugins/ticket/ticketparser.cpp
Executable file
308
plugins/ticket/ticketparser.cpp
Executable file
@@ -0,0 +1,308 @@
|
||||
#include "ticketparser.h"
|
||||
#include "core/log.h"
|
||||
|
||||
|
||||
bool TicketParser::IsWhite(int c)
|
||||
{
|
||||
return (c==' ' || c=='\t' || c==13);
|
||||
}
|
||||
|
||||
|
||||
void TicketParser::SkipLine()
|
||||
{
|
||||
while( *pchar!=0 && *pchar!=10 )
|
||||
pchar += 1;
|
||||
}
|
||||
|
||||
|
||||
void TicketParser::SkipWhite()
|
||||
{
|
||||
while( IsWhite(*pchar) || *pchar=='#' )
|
||||
{
|
||||
if( *pchar=='#' )
|
||||
SkipLine();
|
||||
else
|
||||
pchar += 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TicketParser::SkipWhiteLines()
|
||||
{
|
||||
while( IsWhite(*pchar) || *pchar == 10 || *pchar=='#' )
|
||||
{
|
||||
if( *pchar=='#' )
|
||||
SkipLine();
|
||||
else
|
||||
pchar += 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TicketParser::ReadTextQuoted(std::string & text)
|
||||
{
|
||||
pchar += 1;
|
||||
|
||||
while( *pchar!=0 && *pchar!=10 && *pchar!='\"' )
|
||||
{
|
||||
if( *pchar == '\\' )
|
||||
pchar += 1;
|
||||
|
||||
text += *pchar;
|
||||
pchar += 1;
|
||||
}
|
||||
|
||||
if( *pchar == '\"' )
|
||||
pchar += 1;
|
||||
}
|
||||
|
||||
|
||||
void TicketParser::ReadTextSimple(std::string & text, bool comma_separator)
|
||||
{
|
||||
while( *pchar!=0 && *pchar!=10 && !IsWhite(*pchar) && *pchar!='(' && *pchar!=')' &&
|
||||
(!comma_separator || *pchar!=',' ) )
|
||||
{
|
||||
text += *pchar;
|
||||
pchar += 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TicketParser::ReadText(std::string & text, bool comma_separator)
|
||||
{
|
||||
SkipWhite();
|
||||
text.clear();
|
||||
|
||||
if( *pchar == '\"' )
|
||||
ReadTextQuoted(text);
|
||||
else
|
||||
ReadTextSimple(text, comma_separator);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void TicketParser::CheckId(int & id, bool & def)
|
||||
{
|
||||
if( *pchar != '(' )
|
||||
return;
|
||||
|
||||
// dont set id and def here
|
||||
// there are only changed if exists
|
||||
pchar += 1;
|
||||
|
||||
while( *pchar!=0 && *pchar!=10 && *pchar!=')' )
|
||||
{
|
||||
ReadText(id_str, true);
|
||||
|
||||
if( id_str == "def" )
|
||||
def = true;
|
||||
else
|
||||
id = atoi(id_str.c_str());
|
||||
|
||||
if( *pchar == ',' )
|
||||
pchar += 1;
|
||||
}
|
||||
|
||||
if( *pchar == ')' )
|
||||
pchar += 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool TicketParser::ReadItemType()
|
||||
{
|
||||
ReadText(type);
|
||||
|
||||
if( type.empty() )
|
||||
return false;
|
||||
|
||||
if( type == "integer" )
|
||||
item.type = TicketConf::TicketItem::TypeInteger;
|
||||
else
|
||||
if( type == "select" )
|
||||
item.type = TicketConf::TicketItem::TypeSelect;
|
||||
else
|
||||
{
|
||||
error = WINIX_TICKET_ERR_UKNOWN_TYPE;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void TicketParser::SetItemId()
|
||||
{
|
||||
int id;
|
||||
bool def;
|
||||
|
||||
id = (!pconf->tab.empty()) ? pconf->tab.back().id + 1 : 0;
|
||||
CheckId(id, def);
|
||||
|
||||
item.id = id;
|
||||
}
|
||||
|
||||
|
||||
bool TicketParser::ReadItemName()
|
||||
{
|
||||
ReadText(item.name);
|
||||
|
||||
if( item.name.empty() )
|
||||
{
|
||||
error = WINIX_TICKET_ERR_NO_ITEM_NAME;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void TicketParser::ReadItemInteger()
|
||||
{
|
||||
ReadText(int_min);
|
||||
ReadText(int_max);
|
||||
|
||||
if( !int_min.empty() )
|
||||
item.integer_min = atoi(int_min.c_str());
|
||||
|
||||
if( !int_max.empty() )
|
||||
item.integer_max = atoi(int_max.c_str());
|
||||
}
|
||||
|
||||
|
||||
void TicketParser::ReadItemSelect()
|
||||
{
|
||||
bool def;
|
||||
|
||||
while( *pchar!=0 && *pchar!=10 )
|
||||
{
|
||||
ReadText(select.name);
|
||||
select.id = (!item.select.empty()) ? item.select.back().id + 1 : 0;
|
||||
def = false;
|
||||
CheckId(select.id, def);
|
||||
|
||||
if( !select.name.empty() )
|
||||
{
|
||||
item.select.push_back(select);
|
||||
|
||||
if( def )
|
||||
item.select_default = item.select.size() - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool TicketParser::CheckEndLine()
|
||||
{
|
||||
SkipWhite();
|
||||
|
||||
if( *pchar != 0 && *pchar != 10 )
|
||||
{
|
||||
error = WINIX_TICKET_ERR_SYNTAX_ERROR;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool TicketParser::ReadItem()
|
||||
{
|
||||
SkipWhiteLines();
|
||||
item.Clear();
|
||||
|
||||
if( !ReadItemType() )
|
||||
return false;
|
||||
|
||||
SetItemId();
|
||||
|
||||
if( !ReadItemName() )
|
||||
return false;
|
||||
|
||||
if( item.type == TicketConf::TicketItem::TypeInteger )
|
||||
ReadItemInteger();
|
||||
else
|
||||
ReadItemSelect();
|
||||
|
||||
if( !CheckEndLine() )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void TicketParser::LogItemInteger(TicketConf::TicketItem & item)
|
||||
{
|
||||
log << log3 << "TicketParser: item_type: integer"
|
||||
<< ", item_name: " << item.name
|
||||
<< ", item_id: " << item.id
|
||||
<< ", min: " << item.integer_min
|
||||
<< ", max: " << item.integer_max
|
||||
<< logend;
|
||||
}
|
||||
|
||||
|
||||
void TicketParser::LogItemSelect(TicketConf::TicketItem & item)
|
||||
{
|
||||
log << log3 << "TicketParser: item_type: select"
|
||||
<< ", item_name: " << item.name
|
||||
<< ", item_id: " << item.id
|
||||
<< ", options: ";
|
||||
|
||||
for(size_t i=0 ; i<item.select.size() ; ++i)
|
||||
{
|
||||
log << item.select[i].name << "(" << item.select[i].id;
|
||||
|
||||
if( item.select_default == i )
|
||||
log << ", def";
|
||||
|
||||
log << ")";
|
||||
|
||||
if( i+1 < item.select.size() )
|
||||
log << ", ";
|
||||
}
|
||||
|
||||
log << logend;
|
||||
}
|
||||
|
||||
|
||||
void TicketParser::LogItem(TicketConf::TicketItem & item)
|
||||
{
|
||||
if( item.type == TicketConf::TicketItem::TypeInteger )
|
||||
LogItemInteger(item);
|
||||
else
|
||||
if( item.type == TicketConf::TicketItem::TypeSelect )
|
||||
LogItemSelect(item);
|
||||
}
|
||||
|
||||
|
||||
int TicketParser::Parse(const char * str, TicketConf & conf)
|
||||
{
|
||||
pchar = str;
|
||||
pconf = &conf;
|
||||
error = WINIX_TICKET_ERR_OK;
|
||||
conf.Clear();
|
||||
|
||||
while( ReadItem() )
|
||||
{
|
||||
conf.tab.push_back(item);
|
||||
LogItem(item);
|
||||
}
|
||||
|
||||
if( error != WINIX_TICKET_ERR_OK )
|
||||
{
|
||||
log << log1 << "TicketParser: some errors occured during parsing the config (clearing the table)";
|
||||
conf.Clear();
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int TicketParser::Parse(const std::string & str, TicketConf & conf)
|
||||
{
|
||||
return Parse(str.c_str(), conf);
|
||||
}
|
56
plugins/ticket/ticketparser.h
Executable file
56
plugins/ticket/ticketparser.h
Executable file
@@ -0,0 +1,56 @@
|
||||
#ifndef headerfile_winix_plugins_ticket_ticketparser
|
||||
#define headerfile_winix_plugins_ticket_ticketparser
|
||||
|
||||
|
||||
#include "ticketconf.h"
|
||||
|
||||
#define WINIX_TICKET_ERR_OK 0
|
||||
#define WINIX_TICKET_ERR_UKNOWN_TYPE 1
|
||||
#define WINIX_TICKET_ERR_NO_ITEM_NAME 2
|
||||
#define WINIX_TICKET_ERR_SYNTAX_ERROR 3
|
||||
|
||||
|
||||
|
||||
class TicketParser
|
||||
{
|
||||
public:
|
||||
|
||||
int Parse(const char * str, TicketConf & conf);
|
||||
int Parse(const std::string & str, TicketConf & conf);
|
||||
|
||||
private:
|
||||
|
||||
TicketConf * pconf;
|
||||
const char * pchar;
|
||||
int error; // last error code
|
||||
TicketConf::TicketItem item;
|
||||
std::string type;
|
||||
std::string id_str;
|
||||
std::string int_min, int_max;
|
||||
TicketConf::TicketItem::Select select;
|
||||
|
||||
bool IsWhite(int c);
|
||||
void SkipWhite();
|
||||
void SkipWhiteLines();
|
||||
void SkipLine();
|
||||
void ReadTextQuoted(std::string & text);
|
||||
void ReadTextSimple(std::string & text, bool comma_separator);
|
||||
void ReadText(std::string & text, bool comma_separator = false);
|
||||
|
||||
void CheckId(int & id, bool & def);
|
||||
void SetItemId();
|
||||
bool CheckEndLine();
|
||||
|
||||
bool ReadItemType();
|
||||
bool ReadItemName();
|
||||
void ReadItemInteger();
|
||||
void ReadItemSelect();
|
||||
bool ReadItem();
|
||||
|
||||
void LogItemInteger(TicketConf::TicketItem & item);
|
||||
void LogItemSelect(TicketConf::TicketItem & item);
|
||||
void LogItem(TicketConf::TicketItem & item);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user