f1b1a1ae3a
Files correlati : librerie Ricompilazione Demo : [ ] Commento : git-svn-id: svn://10.65.10.50/trunk@19694 c028cbd2-c16b-5b4b-a496-9718f37d4682
846 lines
20 KiB
C++
Executable File
846 lines
20 KiB
C++
Executable File
#include <about.h>
|
|
#include <applicat.h>
|
|
#include <colors.h>
|
|
#include <dongle.h>
|
|
#include <extcdecl.h>
|
|
#include <isam.h>
|
|
#include <mask.h>
|
|
#include <modaut.h>
|
|
#include <printer.h>
|
|
#include <progind.h>
|
|
#include <urldefid.h>
|
|
#include <utility.h>
|
|
|
|
// Maschera scelta ditta
|
|
#include <bagn002.h>
|
|
|
|
#include <user.h>
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// Metodi di accesso globali all'applicazione corrente
|
|
///////////////////////////////////////////////////////////
|
|
|
|
HIDDEN TApplication* _application = NULL;
|
|
|
|
// @doc EXTERNAL
|
|
|
|
// @func Ritorna l'applicazione in corso
|
|
//
|
|
// @rdesc Ritorna il reference all'applicazione in corso
|
|
TApplication& main_app()
|
|
{
|
|
CHECK(_application, "NULL application!");
|
|
return *_application;
|
|
}
|
|
|
|
// @doc INTERNAL
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// Gestione dello sfondo della finestra principale
|
|
///////////////////////////////////////////////////////////
|
|
|
|
HIDDEN void paint_background(WINDOW win)
|
|
{
|
|
RCT r; xvt_vobj_get_client_rect(win, &r);
|
|
|
|
if (ADVANCED_GRAPHICS)
|
|
{
|
|
const int cy = r.bottom / 4;
|
|
RCT g = r; g.bottom = cy;
|
|
xvt_dwin_draw_gradient_linear(win, &g, MASK_LIGHT_COLOR, MASK_BACK_COLOR, 90);
|
|
g = r; g.top = cy;
|
|
xvt_dwin_draw_gradient_linear(win, &g, MASK_DARK_COLOR, MASK_LIGHT_COLOR, 90);
|
|
}
|
|
else
|
|
xvt_dwin_clear(win, MASK_DARK_COLOR);
|
|
|
|
int BIGY = 3*ROWY/2;
|
|
xvtil_set_font(win, XVT_FFN_TIMES, XVT_FS_BOLD | XVT_FS_ITALIC, BIGY);
|
|
|
|
const char* t = main_app().title();
|
|
int w = xvt_dwin_get_text_width(win, t, -1);
|
|
if (w > r.right)
|
|
{
|
|
BIGY = BIGY*r.right/w;
|
|
xvtil_set_font(win, XVT_FFN_TIMES, XVT_FS_BOLD | XVT_FS_ITALIC, BIGY);
|
|
w = xvt_dwin_get_text_width(win, t, -1);
|
|
}
|
|
|
|
int x = (r.right-w)/2, y = r.top+BIGY+ROWY;
|
|
if (ADVANCED_GRAPHICS)
|
|
{ // Disegna ombra
|
|
const int k = max(BIGY/24, 1);
|
|
xvt_dwin_set_fore_color(win, MASK_LIGHT_COLOR);
|
|
xvt_dwin_draw_text(win, x+k, y+k, t, -1);
|
|
}
|
|
xvt_dwin_set_fore_color(win, MASK_DARK_COLOR);
|
|
xvt_dwin_draw_text(win, x, y, t, -1);
|
|
|
|
xvtil_set_font(win, NULL, XVT_FS_NONE);
|
|
xvt_dwin_set_fore_color(win, NORMAL_COLOR);
|
|
|
|
TString spa; spa << dongle().product();
|
|
if (!xvt_sys_is_pda())
|
|
spa << " - " << dongle().reseller();
|
|
w = xvt_dwin_get_text_width(win, spa, -1);
|
|
x = (r.right-r.left-w)/2; y = r.bottom-CHARY;
|
|
xvt_dwin_draw_text(win, x, y, spa, -1);
|
|
|
|
if (ADVANCED_GRAPHICS)
|
|
{
|
|
const int ix = xvt_vobj_get_attr(NULL_WIN, ATTR_ICON_WIDTH);
|
|
const int iy = xvt_vobj_get_attr(NULL_WIN, ATTR_ICON_HEIGHT);
|
|
xvt_dwin_draw_icon(win, r.right-ix-CHARY, r.bottom-iy-CHARY, ICON_RSRC);
|
|
xvt_dwin_draw_icon(win, CHARY, r.bottom-iy-CHARY, ICON_RSRC);
|
|
}
|
|
}
|
|
|
|
long TApplication::task_eh(WINDOW win, EVENT *ep)
|
|
{
|
|
switch (ep->type)
|
|
{
|
|
case E_CREATE:
|
|
if (_application->pre_create())
|
|
{
|
|
if (dongle().demo())
|
|
{
|
|
const TString16 dname(encode("DATA"));
|
|
const TString16 hname(encode("ORA"));
|
|
TConfig c(CONFIG_INSTALL, "Main");
|
|
TDate data(decode(c.get(dname)));
|
|
TDate oggi(TODAY);
|
|
real remaining_time(decode(c.get(hname)));
|
|
main_app()._start_time = time(NULL);
|
|
|
|
if (data < oggi)
|
|
{
|
|
data = oggi;
|
|
c.set(dname, encode(data));
|
|
c.set(hname, encode("120.00"));
|
|
}
|
|
else
|
|
if (data == oggi)
|
|
{
|
|
if (remaining_time <= ZERO)
|
|
exit(0);
|
|
}
|
|
else
|
|
exit(0);
|
|
}
|
|
|
|
// Setta il vero menu principale se diverso dal default
|
|
const int meno = _application->argc() > 1 ? atoi(_application->argv(1)+1) : 0;
|
|
ignore_xvt_errors(TRUE);
|
|
MENU_ITEM* menu = xvt_res_get_menu(MENU_BAR_ID(meno));
|
|
ignore_xvt_errors(FALSE);
|
|
if (menu)
|
|
{
|
|
xvt_menu_set_tree(win, menu);
|
|
xvt_res_free_menu_tree(menu);
|
|
}
|
|
if (dictionary_active())
|
|
xvt_menu_translate_tree(win, dictionary_translate_menu_item);
|
|
|
|
// Setta la caption della task window
|
|
TString cap;
|
|
cap << _application->get_module_name() << " - " << dongle().product() << " - " << dongle().reseller();
|
|
xvt_vobj_set_title(win, cap);
|
|
|
|
// Carica colori e font
|
|
customize_controls(TRUE);
|
|
|
|
xvtil_create_statbar();
|
|
xvtil_statbar_set("");
|
|
|
|
do_events(); // strateggica non scancellare
|
|
}
|
|
break;
|
|
case E_UPDATE:
|
|
paint_background(win);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
return _application->handler(win, ep);
|
|
}
|
|
|
|
void TApplication::dispatch_e_menu(MENU_TAG tag)
|
|
{
|
|
EVENT e; memset(&e, 0, sizeof(e));
|
|
e.type = E_COMMAND;
|
|
e.v.cmd.tag = tag;
|
|
xvt_win_post_event(TASK_WIN, &e);
|
|
}
|
|
|
|
long TApplication::handler(WINDOW win, EVENT* ep)
|
|
{
|
|
switch (ep->type)
|
|
{
|
|
case E_CREATE:
|
|
_create_ok = create();
|
|
if (_create_ok)
|
|
{
|
|
on_firm_change();
|
|
on_config_change();
|
|
return 1;
|
|
}
|
|
else
|
|
stop_run();
|
|
break;
|
|
case E_COMMAND:
|
|
switch(ep->v.cmd.tag)
|
|
{
|
|
case M_FILE_QUIT:
|
|
if (can_close())
|
|
stop_run();
|
|
break;
|
|
case M_FILE_PG_SETUP:
|
|
printer().set();
|
|
break;
|
|
case M_FILE_PREVIEW:
|
|
preview();
|
|
break;
|
|
case M_FILE_PRINT:
|
|
print();
|
|
break;
|
|
case M_FILE_NEW:
|
|
set_firm();
|
|
break;
|
|
case M_FILE_ABOUT:
|
|
about();
|
|
break;
|
|
case M_HELP_CONTENTS:
|
|
{
|
|
TFilename n = "campo";
|
|
TString4 module; module.strncpy(name(), 2);
|
|
if (module != "ba")
|
|
n.insert(module);
|
|
|
|
FILE_SPEC fs; xvt_fsys_convert_str_to_fspec(n, &fs);
|
|
XVT_HELP_INFO hi = xvt_help_open_helpfile(&fs, 0);
|
|
xvt_help_process_event(hi, win, ep);
|
|
}
|
|
break;
|
|
case M_HELP_ONCONTEXT: // Ridirige l'help contestuale alla finestra corrente
|
|
{
|
|
WINDOW w = cur_win();
|
|
if (w != NULL_WIN && w != win)
|
|
dispatch_e_char(w, K_F1);
|
|
}
|
|
break;
|
|
case M_EDIT_CUT:
|
|
case M_EDIT_COPY:
|
|
case M_EDIT_PASTE:
|
|
{
|
|
// I comandi della clipboard vanno ridiretti alla finestra col focus
|
|
WINDOW w = xvt_scr_get_focus_vobj();
|
|
if (w == NULL_WIN) w = cur_win();
|
|
if (w != NULL_WIN && w != win) // Evito ciclo infinito
|
|
{
|
|
dispatch_event(w, *ep, true);
|
|
break;
|
|
}
|
|
}
|
|
// fall down to normal processing
|
|
default:
|
|
if (ep->v.cmd.tag > MAX_MENU_TAG)
|
|
{
|
|
WINDOW w = cur_win();
|
|
if (w != NULL_WIN && w != win)
|
|
dispatch_event(w, *ep, true);
|
|
}
|
|
else
|
|
{
|
|
if (ep->v.cmd.tag >= BAR_ITEM_ID(1))
|
|
{
|
|
if(!menu(ep->v.cmd.tag))
|
|
stop_run();
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
break;
|
|
case E_CLOSE:
|
|
if (can_close())
|
|
stop_run();
|
|
else
|
|
return 1; // Divieto!
|
|
break;
|
|
case E_QUIT:
|
|
if (ep->v.query)
|
|
{
|
|
if (can_close())
|
|
xvt_app_allow_quit();
|
|
}
|
|
else
|
|
stop_run();
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
return 0L;
|
|
}
|
|
|
|
void TApplication::stop_run()
|
|
{
|
|
if (_savefirm)
|
|
prefix().set_codditta(_savefirm);
|
|
if (dongle().demo())
|
|
{
|
|
const TString16 hname(encode("ORA"));
|
|
TConfig c(CONFIG_INSTALL, "Main");
|
|
real remaining_time(decode(c.get(hname)));
|
|
if (name() != "ba0100")
|
|
{
|
|
time_t wt = time(NULL);
|
|
int delay = (int) (wt - _start_time);
|
|
if (delay < 0)
|
|
remaining_time = ZERO;
|
|
else
|
|
remaining_time -= (delay / 60.0);
|
|
c.set(hname, encode(remaining_time.string()));
|
|
}
|
|
else
|
|
message_box(TR("Questo e' un programma dimostrativo.\nOggi rimangono %s minuti di utilizzo."), remaining_time.string(3, 0));
|
|
}
|
|
terminate();
|
|
|
|
xvt_app_destroy();
|
|
}
|
|
|
|
|
|
bool TApplication::add_menu(TString_array& menu, MENU_TAG id)
|
|
{
|
|
TTemp_window tw(TASK_WIN);
|
|
return tw.add_menu(menu,id,TRUE);
|
|
}
|
|
|
|
bool TApplication::remove_menu(MENU_TAG id)
|
|
{
|
|
TTemp_window tw(TASK_WIN);
|
|
return tw.remove_menu(id);
|
|
}
|
|
|
|
|
|
TApplication::TApplication()
|
|
: _god_vars(NULL),_savefirm(0), _running(FALSE), _create_ok(FALSE)
|
|
{
|
|
}
|
|
|
|
|
|
TApplication::~TApplication()
|
|
{
|
|
if (_god_vars != NULL)
|
|
delete _god_vars;
|
|
}
|
|
|
|
bool TApplication::create()
|
|
{ return true; }
|
|
|
|
|
|
bool TApplication::destroy()
|
|
{ return true; }
|
|
|
|
void TApplication::terminate()
|
|
{
|
|
close_all_dialogs();
|
|
|
|
if (_create_ok)
|
|
destroy(); // Distruzione files e maschere
|
|
|
|
do_events();
|
|
|
|
if (use_files())
|
|
{
|
|
_used_files.destroy();
|
|
free_global_vars(); // Distruzione variabili globali
|
|
}
|
|
|
|
printer_destroy();
|
|
|
|
dictionary_close();
|
|
|
|
xvt_help_close_helpfile(NULL_HELP_INFO);
|
|
|
|
customize_controls(FALSE); // Rilascio eventuali DLL
|
|
}
|
|
|
|
const char* TApplication::get_module_name() const
|
|
{
|
|
TString& module = ((TApplication*)this)->_module_name; // Fool the compiler
|
|
if (module.empty())
|
|
{
|
|
const TDongle& d = dongle();
|
|
const word aut = d.module_name2code(_name.left(2));
|
|
module = d.module_code2desc(aut);
|
|
bool ok = module.full();
|
|
if (ok && check_autorization())
|
|
ok = has_module(aut);
|
|
|
|
if (!ok)
|
|
{
|
|
if (module.empty())
|
|
module = "Tools";
|
|
TToken_string em(extra_modules());
|
|
if (!em.empty_items())
|
|
{
|
|
if (em != "*")
|
|
{
|
|
FOR_EACH_TOKEN(em, cod)
|
|
{
|
|
const word alt = d.module_name2code(cod);
|
|
if (has_module(alt))
|
|
{
|
|
ok = true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
ok = true;
|
|
}
|
|
if (!ok)
|
|
{
|
|
error_box(TR("Il modulo '%s' non e' autorizzato per l'utente %s"), (const char*)module, ((const char*)user()));
|
|
module.cut(0);
|
|
}
|
|
}
|
|
}
|
|
return module;
|
|
}
|
|
|
|
|
|
void TApplication::set_perms()
|
|
{
|
|
_user_aut.set(ENDAUT, true); // Forza dimensioni corrette del bit array!
|
|
_user_aut.reset(); // disabilita tutto ...
|
|
_user_aut.set(0, true); // ... tranne la BASE
|
|
|
|
const TString& utente = user();
|
|
if (utente.full())
|
|
{
|
|
if (utente.compare(::dongle().administrator(), -1, 0) != 0)
|
|
{
|
|
int err = _iskeynotfound;
|
|
if (use_files())
|
|
{
|
|
TLocalisamfile users(LF_USER);
|
|
users.put(USR_USERNAME, utente);
|
|
err = users.read();
|
|
if (err == NOERR)
|
|
{
|
|
const TString& aut = users.get(USR_AUTSTR);
|
|
if (aut.full())
|
|
{
|
|
for (int i = aut.len()-1; i > 0; i--)
|
|
_user_aut.set(i, aut[i] == 'X');
|
|
}
|
|
}
|
|
}
|
|
if (err != NOERR && utente.compare("GUEST", -1, true) == 0)
|
|
_user_aut.set(); // abilita tutto
|
|
}
|
|
else
|
|
{
|
|
_user_aut.set(); // abilita tutto
|
|
}
|
|
}
|
|
}
|
|
|
|
// @doc EXTERNAL
|
|
|
|
// @mfunc Legge il parametro /uUTENTE e lo toglie dalla lista
|
|
void TApplication::check_parameters(
|
|
int & argc, // @parm Numero del parametro da controllare
|
|
char* argv[]) // @parm Array di paramentri da passare all'applicazione
|
|
|
|
// @comm Nel caso si identifichi che il paramentro <p argc> sia il nome dell'utente
|
|
// si setta la variabile col nome dell'utente, altrimenti l'utente diventa PRASSI,
|
|
// e si diminuisce di uno il numero di argomenti da passare.
|
|
{
|
|
if (argc > 1)
|
|
{
|
|
const TFixed_string u(argv[argc-1]);
|
|
if (u.starts_with("-u", true) || u.starts_with("/u", true))
|
|
{
|
|
TString16 usr = u.mid(2,16);
|
|
usr.upper();
|
|
user() = usr;
|
|
argc--;
|
|
}
|
|
}
|
|
}
|
|
|
|
bool TApplication::test_assistance_year() const
|
|
{
|
|
const int dongle_year = dongle().year_assist();
|
|
int app_year, dum1, dum2, dum3;
|
|
bool ok = TApplication::get_version_info(app_year, dum1, dum2, dum3);
|
|
if (ok)
|
|
{
|
|
ok = app_year <= dongle_year;
|
|
if (ok)
|
|
{
|
|
const int solar_year = (dongle_year/1000)*1000 + (dongle_year%1000)/10;
|
|
ok = TDate(TODAY).year() <= solar_year+2;
|
|
}
|
|
}
|
|
return ok;
|
|
}
|
|
|
|
// @doc EXTERNAL
|
|
|
|
// @mfunc Fa partire l'applicazione
|
|
void TApplication::run(
|
|
int argc, // @parm Numero deglia argomenti da passara all'applicazione
|
|
char* argv[], // @parm Argomenti da passare all'applicazione
|
|
const char* title) // @parm Titolo dell'applicazione
|
|
|
|
// @comm E' in questa fase che si controlla se esiste la chiave e' attaccata
|
|
{
|
|
CHECK(_application == NULL, "Sorry, multitasking not implemented yet");
|
|
// Devo metterla qui per far funzionare la TDongle::network_login
|
|
_application = this;
|
|
|
|
TFilename base(argv[0]);
|
|
base.ext(""); base.lower();
|
|
|
|
_title = title;
|
|
|
|
if (user().empty())
|
|
check_parameters(argc, argv);
|
|
|
|
_argc_ = argc;
|
|
_argv_ = (const char**)argv;
|
|
|
|
if (argc > 1 && argv[1][0] == '-')
|
|
_name = cmd2name(argv[0], argv[1]);
|
|
else
|
|
_name = cmd2name(argv[0]);
|
|
|
|
const int sn = get_serial_number();
|
|
if (sn > 0 && !test_assistance_year())
|
|
{
|
|
error_box(TR("E' necessario attivare il contratto di assistenza per l'anno in corso"));
|
|
return;
|
|
}
|
|
|
|
if (use_files())
|
|
init_global_vars();
|
|
else
|
|
CGetPref();
|
|
|
|
set_perms();
|
|
|
|
const char* mod = get_module_name();
|
|
if (mod == NULL || *mod == '\0')
|
|
return;
|
|
|
|
XVT_CONFIG cfg; memset(&cfg, 0, sizeof(cfg));
|
|
cfg.menu_bar_ID = TASK_MENUBAR;
|
|
cfg.about_box_ID = 0;
|
|
cfg.base_appl_name = base.name();
|
|
cfg.appl_name = title;
|
|
cfg.taskwin_title = dongle().product();
|
|
|
|
int year, major, minor, patch;
|
|
if (TApplication::get_version_info(year, major, minor, patch))
|
|
{
|
|
TString16 ver; ver.format("%d %d.%d/%d", year, major, minor, patch);
|
|
xvt_vobj_set_attr(NULL_WIN, ATTR_APPL_VERSION_STRING, (long)(const char*)ver);
|
|
}
|
|
|
|
set_xvt_hooks();
|
|
|
|
_running = TRUE;
|
|
xvt_app_create(argc, argv, 0L, task_eh, &cfg);
|
|
}
|
|
|
|
bool TApplication::get_version_info(int& year, int& release, int& tag, int& patch)
|
|
{
|
|
const char* const VERSIONANDPATCH = "Don't cry for me Argentina.2091.10.00.0212.2313";
|
|
|
|
TToken_string vep(VERSIONANDPATCH, '.');
|
|
year = vep.get_int(1);
|
|
release = vep.get_int();
|
|
tag = vep.get_int();
|
|
patch = vep.get_int();
|
|
int checksum = vep.get_int();
|
|
|
|
bool valid = year >= 2091 && release > 0 && tag >= 0 && patch >= 0 &&
|
|
checksum == (year + release + tag + patch);
|
|
return valid;
|
|
}
|
|
|
|
// Risposta alla selezione Stampa del menu File
|
|
void TApplication::print()
|
|
{
|
|
#ifdef DBG
|
|
NFCHECK("Non saprei bene cosa stampare!");
|
|
#endif
|
|
enable_menu_item(M_FILE_PREVIEW, false);
|
|
enable_menu_item(M_FILE_PRINT, false);
|
|
}
|
|
|
|
void TApplication::preview()
|
|
{
|
|
TPrinter& p = printer();
|
|
const TPrtype oldmode = p.printtype();
|
|
p.set_printtype(screenvis);
|
|
print();
|
|
p.set_printtype(oldmode);
|
|
}
|
|
|
|
void TApplication::check_menu_item(MENU_TAG item, bool chk)
|
|
{
|
|
xvt_menu_set_item_checked(TASK_WIN, item, chk);
|
|
xvt_menu_update(TASK_WIN);
|
|
}
|
|
|
|
void TApplication::uncheck_menu_item(MENU_TAG item)
|
|
{
|
|
check_menu_item(item, false);
|
|
}
|
|
|
|
// @doc EXTERNAL
|
|
|
|
// @mfunc Permette di abilitare/disabilitare una voce di menu'
|
|
void TApplication::enable_menu_item(
|
|
MENU_TAG item, // @parm Voce del menu' da abilitare/disabilitare
|
|
bool on) // @parm Operazione da svolgere sulla voce del menu':
|
|
//
|
|
// @flag TRUE | Viene abilitata la voce del menu'
|
|
// @flag FALSE | Viene disabilitata la voce del menu'
|
|
{
|
|
xvt_menu_set_item_enabled(TASK_WIN, item, on);
|
|
xvt_menu_update(TASK_WIN);
|
|
}
|
|
|
|
bool TApplication::has_module(int module, int checktype) const
|
|
{
|
|
bool ok = dongle().active(module);
|
|
// Testa bit di attivazione dell'utente
|
|
if (ok && checktype != CHK_DONGLE)
|
|
ok = _user_aut[module];
|
|
return ok;
|
|
}
|
|
|
|
long TApplication::get_firm() const
|
|
{
|
|
return prefix().get_codditta();
|
|
}
|
|
|
|
const char* TApplication::get_firm_dir() const
|
|
{
|
|
return format("%s%s", __ptprf, prefix().name());
|
|
}
|
|
|
|
bool TApplication::set_firm(long newfirm)
|
|
{
|
|
const long oldfirm = get_firm();
|
|
const bool interactive = newfirm <= 0;
|
|
|
|
if (interactive && firm_change_enabled())
|
|
{
|
|
TMask mask("bagn002");
|
|
TFilename pp(__ptprf); pp.cut(pp.len()-1);
|
|
mask.set(F_PATHPREF, pp);
|
|
|
|
mask.show(-2, extended_firm());
|
|
|
|
disable_menu_item(M_FILE_NEW);
|
|
const KEY k = mask.run();
|
|
enable_menu_item(M_FILE_NEW);
|
|
|
|
if (k == K_ENTER)
|
|
{
|
|
newfirm = mask.get_long(F_CODDITTA);
|
|
const int tipodir = mask.get_int(F_TIPO);
|
|
|
|
if (tipodir == 0 && !prefix().exist(newfirm) &&
|
|
!prefix().build_firm_data(newfirm))
|
|
return false;
|
|
if (tipodir > 0)
|
|
{
|
|
if (_savefirm == 0) _savefirm = oldfirm; // E' necessario ricordare la ditta ...
|
|
prefix().set(tipodir == 1 ? "com" : ""); // ... se si setta il prefix a com
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (interactive)
|
|
{
|
|
if (newfirm <= 0)
|
|
return newfirm > 0;
|
|
}
|
|
else
|
|
{
|
|
if (newfirm == oldfirm || newfirm <= 0)
|
|
return newfirm > 0;
|
|
}
|
|
|
|
if (prefix().test(newfirm))
|
|
{
|
|
prefix().set_codditta(newfirm);
|
|
_savefirm = 0;
|
|
|
|
WINDOW w = cur_win();
|
|
if (w != NULL_WIN)
|
|
{
|
|
TWindow* win = (TWindow*) xvt_vobj_get_data(w);
|
|
win->on_firm_change();
|
|
}
|
|
xvtil_statbar_set("", true); // Aggiorna nome ditta nella barra
|
|
on_firm_change();
|
|
on_config_change();
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
// @doc EXTERNAL
|
|
|
|
// @mfunc Controlla se al programma corrente e' concesso cambiare ditta da menu.
|
|
//
|
|
// @rdesc Ritorna i seguenti valori:
|
|
//
|
|
// @flag TRUE | Se e' abilitata la voce di menu' per il cambio della ditta
|
|
// @flag FALSE | Se non e' possibile cambiare ditta da menu'
|
|
bool TApplication::firm_change_enabled() const
|
|
|
|
// @comm Praticamente controlla se e' stato lanciato da ba0 o dal program manager
|
|
{
|
|
return !dongle().demo();
|
|
}
|
|
|
|
void TApplication::on_firm_change()
|
|
{}
|
|
|
|
void TApplication::on_config_change()
|
|
{}
|
|
|
|
void TApplication::open_files(int logicnum, ...)
|
|
{
|
|
va_list marker;
|
|
va_start(marker, logicnum);
|
|
while (logicnum >= LF_USER && logicnum < LF_EXTERNAL)
|
|
{
|
|
if (_used_files.objptr(logicnum) == NULL)
|
|
_used_files.add(new TLocalisamfile(logicnum), logicnum);
|
|
logicnum = va_arg(marker, int);
|
|
}
|
|
}
|
|
|
|
bool TApplication::get_spotlite_path(TFilename& path) const
|
|
{
|
|
bool ok = dongle().active(RSAUT);
|
|
if (ok)
|
|
{
|
|
path = prefix().get_studio(); // Legge il persorso dello studio corrente
|
|
const TString16 study = path.name(); // Estrae il nome dello studio (senza percorso)
|
|
path.add("spotlite"); // Crea il nome standard della cartella per gli archivi
|
|
ok = path.exist(); // Controlla se esiste gia'
|
|
if (!ok)
|
|
{
|
|
TConfig ini("servers/servers.ini", "Spotlite");
|
|
for (int i = 0; ; i++)
|
|
{
|
|
const TString& s = ini.get("Study", NULL, i);
|
|
if (s.blank()) // NON e' mai stato configurato
|
|
{
|
|
ini.set("Study", study, NULL, TRUE, i);
|
|
ini.set("Data", path, NULL, TRUE, i);
|
|
ok = make_dir(path);
|
|
break;
|
|
}
|
|
else
|
|
{
|
|
if (s.compare(study, -1, true) == 0) // E' gia' configurato
|
|
{
|
|
path = ini.get("Data", NULL, i);
|
|
ok = path.exist();
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return ok;
|
|
}
|
|
|
|
bool TApplication::get_next_pdf(int anno, long ditta, const char* codnum,
|
|
long numdoc, long codcf, TFilename& pdf) const
|
|
{
|
|
bool ok = get_spotlite_path(pdf);
|
|
if (ok)
|
|
{
|
|
if (anno <= 0)
|
|
{
|
|
const TDate oggi(TODAY);
|
|
anno = oggi.year();
|
|
}
|
|
pdf.add(format("%04d", anno));
|
|
if (!pdf.exist())
|
|
ok = xvt_fsys_mkdir(pdf) != 0;
|
|
}
|
|
if (ok)
|
|
{
|
|
if (ditta < 0)
|
|
ditta = get_firm();
|
|
pdf.add(format("%05ldA", ditta));
|
|
if (!pdf.exist())
|
|
ok = xvt_fsys_mkdir(pdf) != 0;
|
|
|
|
if (ok)
|
|
{
|
|
pdf.add(_name);
|
|
if (codnum == NULL || *codnum <= ' ')
|
|
codnum = "report";
|
|
pdf << '_' << codnum;
|
|
|
|
if (numdoc <= 0)
|
|
{
|
|
const struct tm& loc = *xvt_time_now();
|
|
pdf << format("_%02d%02d%02d%02d%02d",
|
|
loc.tm_mon, loc.tm_mday, loc.tm_hour, loc.tm_min, loc.tm_sec);
|
|
}
|
|
else
|
|
pdf << format("_%010ld", numdoc);
|
|
|
|
if (codcf > 0)
|
|
pdf << format("_%07ld", codcf);
|
|
|
|
pdf.ext("pdf");
|
|
}
|
|
}
|
|
|
|
return ok;
|
|
}
|
|
|
|
bool TApplication::get_next_mail(TToken_string& to, TToken_string& cc, TToken_string& ccn,
|
|
TString& subj, TString& text, TToken_string& attach, bool& ui) const
|
|
{
|
|
bool ok = dongle().active(RSAUT);
|
|
ui = ok && to.blank();
|
|
return ok;
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// The Skeleton application!
|
|
///////////////////////////////////////////////////////////
|
|
|
|
bool TSkeleton_application::create()
|
|
{
|
|
dispatch_e_menu(BAR_ITEM_ID(1));
|
|
return TApplication::create();
|
|
}
|
|
|
|
bool TSkeleton_application::menu(MENU_TAG tag)
|
|
{
|
|
if (tag == BAR_ITEM_ID(1))
|
|
main_loop();
|
|
return FALSE;
|
|
} |