2010-09-30 00:41:34 +02:00
|
|
|
/*
|
|
|
|
* This file is a part of Winix
|
|
|
|
* and is not publicly distributed
|
|
|
|
*
|
|
|
|
* Copyright (c) 2010, Tomasz Sowa
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef headerfile_winix_plugins_ticket_ticketinfo
|
|
|
|
#define headerfile_winix_plugins_ticket_ticketinfo
|
2010-09-29 23:24:34 +02:00
|
|
|
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include "ticket.h"
|
2010-10-11 22:42:49 +02:00
|
|
|
#include "ticketparser.h"
|
2010-09-29 23:24:34 +02:00
|
|
|
#include "core/item.h"
|
2010-09-30 22:58:20 +02:00
|
|
|
#include "core/system.h"
|
2011-01-05 22:24:11 +01:00
|
|
|
#include "functions/functions.h"
|
2010-09-29 23:24:34 +02:00
|
|
|
#include "db/db.h"
|
|
|
|
#include "tdb.h"
|
|
|
|
|
|
|
|
|
2011-01-20 19:37:51 +01:00
|
|
|
|
2010-09-29 23:24:34 +02:00
|
|
|
namespace Ticket
|
|
|
|
{
|
|
|
|
|
|
|
|
|
2010-10-11 22:42:49 +02:00
|
|
|
struct TicketConfWrap
|
|
|
|
{
|
|
|
|
bool to_delete;
|
2010-11-21 01:19:17 +01:00
|
|
|
std::wstring file_name;
|
2010-10-11 22:42:49 +02:00
|
|
|
TicketConf conf;
|
|
|
|
|
|
|
|
TicketConfWrap()
|
|
|
|
{
|
|
|
|
to_delete = false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-09-29 23:24:34 +02:00
|
|
|
class TicketInfo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
TicketInfo();
|
|
|
|
|
|
|
|
void SetTDb(TDb * ptdb);
|
|
|
|
void SetDb(Db * pdb);
|
2011-01-05 22:24:11 +01:00
|
|
|
void SetConfig(Config * pconfig);
|
2010-09-30 22:58:20 +02:00
|
|
|
void SetSystem(System * psystem);
|
2011-01-23 15:15:30 +01:00
|
|
|
void SetCur(Cur * pcur);
|
2011-01-05 22:24:11 +01:00
|
|
|
void SetFunctions(Functions * pfunctions);
|
2010-09-29 23:24:34 +02:00
|
|
|
|
|
|
|
void Clear();
|
|
|
|
|
2011-01-05 22:24:11 +01:00
|
|
|
// current ticket for templates
|
|
|
|
const Ticket * ticket;
|
|
|
|
|
|
|
|
// for displaying all tickets in a directory
|
|
|
|
std::vector<Item> item_tab;
|
2010-09-29 23:24:34 +02:00
|
|
|
std::vector<Ticket> ticket_tab;
|
2011-01-05 22:24:11 +01:00
|
|
|
std::vector<Item*> item_sort_tab;
|
|
|
|
|
|
|
|
|
2010-10-11 22:42:49 +02:00
|
|
|
// <dir_id, TicketConfWrap>
|
|
|
|
typedef std::map<long, TicketConfWrap> ConfTab;
|
|
|
|
ConfTab conf_tab;
|
|
|
|
|
2011-01-05 22:24:11 +01:00
|
|
|
// current ticket config
|
|
|
|
// will be set by FindCurrentConf()
|
2010-10-19 02:31:20 +02:00
|
|
|
const TicketConfWrap * cur_conf_wrap;
|
2011-01-05 22:24:11 +01:00
|
|
|
const TicketConf * cur_conf;
|
2010-10-11 22:42:49 +02:00
|
|
|
|
2010-10-19 02:31:20 +02:00
|
|
|
// default: "progress"
|
|
|
|
// can be set in config in option: ticket_form_progress_prefix
|
2010-11-21 01:19:17 +01:00
|
|
|
std::wstring progress_prefix;
|
2010-09-29 23:24:34 +02:00
|
|
|
|
2011-01-05 22:24:11 +01:00
|
|
|
// ticket plugin id
|
|
|
|
int plugin_id;
|
2010-09-29 23:24:34 +02:00
|
|
|
|
2010-10-11 22:42:49 +02:00
|
|
|
|
2011-01-05 22:24:11 +01:00
|
|
|
int mount_type_ticket;
|
|
|
|
int mount_par_ticket_conf;
|
2010-09-29 23:24:34 +02:00
|
|
|
|
|
|
|
|
2010-12-06 01:25:46 +01:00
|
|
|
// template index for notifications
|
|
|
|
size_t template_index;
|
|
|
|
|
|
|
|
|
2010-10-11 22:42:49 +02:00
|
|
|
void ReadTicketConf(bool skip_existing_configs = false);
|
2010-10-19 02:31:20 +02:00
|
|
|
void FindCurrentConf();
|
2011-01-05 22:24:11 +01:00
|
|
|
void CheckMinMaxValue(const TicketConf::TicketItem & conf_item, Ticket::TicketParam & par);
|
|
|
|
void ReadTicketParams(Ticket & ticket, bool clear_ticket = true, std::vector<long> * file_map = 0);
|
2010-09-30 22:58:20 +02:00
|
|
|
|
2011-01-24 00:23:24 +01:00
|
|
|
void RemoveTicket(long file_id);
|
|
|
|
|
2010-09-29 23:24:34 +02:00
|
|
|
private:
|
2011-01-05 22:24:11 +01:00
|
|
|
|
|
|
|
Db * db;
|
|
|
|
TDb * tdb;
|
|
|
|
Config * config;
|
|
|
|
System * system;
|
2011-01-23 15:15:30 +01:00
|
|
|
Cur * cur;
|
2011-01-05 22:24:11 +01:00
|
|
|
Functions * functions;
|
|
|
|
|
|
|
|
// for reading parameters
|
|
|
|
Ticket::TicketParam ticket_param;
|
|
|
|
|
|
|
|
// for adding a new image/file to a ticket
|
|
|
|
Item file;
|
|
|
|
|
|
|
|
// for reading config file
|
2010-10-11 22:42:49 +02:00
|
|
|
TicketParser ticket_parser;
|
2011-01-05 22:24:11 +01:00
|
|
|
std::vector<Item*> config_dir_tab;
|
|
|
|
Item config_file;
|
2010-09-29 23:24:34 +02:00
|
|
|
|
2011-01-05 22:24:11 +01:00
|
|
|
// for Clearing
|
|
|
|
// (we don't want to use empty pointers)
|
2010-10-19 02:31:20 +02:00
|
|
|
const TicketConfWrap cur_conf_wrap_empty;
|
2011-01-05 22:24:11 +01:00
|
|
|
const TicketConf cur_conf_empty;
|
|
|
|
const Ticket ticket_empty;
|
2010-10-19 02:31:20 +02:00
|
|
|
|
2011-01-24 00:23:24 +01:00
|
|
|
// for removing a ticket
|
|
|
|
Ticket rm_ticket;
|
|
|
|
|
2010-11-21 01:19:17 +01:00
|
|
|
bool GetConfContent(const std::wstring & path);
|
|
|
|
bool ParseTicketConf(long mount_dir_id, const std::wstring & path);
|
2010-10-11 22:42:49 +02:00
|
|
|
void ReadTicketConf(Mounts & mounts, bool skip_existing_configs);
|
|
|
|
void MarkAllConfToDelete();
|
|
|
|
void DeleteAllMarkedConf();
|
|
|
|
|
2011-01-05 22:24:11 +01:00
|
|
|
|
|
|
|
bool ReadTicketValue(const TicketConf::TicketItem & conf_item, Ticket::TicketParam & par, const std::wstring & value);
|
|
|
|
bool ReadTicketValue(const TicketConf::TicketItem & conf_item, Ticket::TicketParam & par, const PostFile & value, std::vector<long> * file_map);
|
|
|
|
void ReadTicketParam(Ticket & ticket, int param_id, const std::wstring & value);
|
|
|
|
void ReadTicketParam(Ticket & ticket, int param_id, const PostFile & value, std::vector<long> * file_map);
|
|
|
|
|
2010-09-29 23:24:34 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|