applicat.h Aggiunto metodo statico get_version_info

applicat.cpp Implementato metodo statico get_version_info
             Aggiunta gestione dei nomi del produttore del software


git-svn-id: svn://10.65.10.50/trunk@6035 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1998-01-27 10:27:24 +00:00
parent 3c829523bb
commit 933d3924d4
2 changed files with 65 additions and 14 deletions

View File

@ -27,7 +27,6 @@
#define BITTEST(w,p) (((w) & (0x0001 << (p))) != 0)
///////////////////////////////////////////////////////////
// Metodi di accesso globali all'applicazione corrente
///////////////////////////////////////////////////////////
@ -60,11 +59,34 @@ bool xvt_running()
HIDDEN char* prassi_spa()
{
TString firm(80);
ignore_xvt_errors(TRUE);
char* p = xvt_res_get_str(STR_FIRMNAME, firm.get_buffer(), firm.size());
ignore_xvt_errors(FALSE);
char* p = NULL;
TConfig ini("install.ini", "Main");
firm = ini.get("Producer");
if (firm.not_empty())
{
p = (char*)decode(firm);
for (const char* c = p; *c; c++)
{
if (*c > '\0' && *c < ' ')
{
p = NULL;
break;
}
}
}
if (p == NULL)
{
ignore_xvt_errors(TRUE);
p = xvt_res_get_str(STR_FIRMNAME, firm.get_buffer(), firm.size());
ignore_xvt_errors(FALSE);
}
if (p == NULL)
p = "PR.A.S.S.I. S.p.A.";
return p;
}
@ -365,7 +387,7 @@ void TApplication::stop_run()
c.set(hname, encode(remaining_time.string()));
}
else
message_box("Questo e' un programma dimostrativo.\n Oggi ti rimangono %s minuti di utilizzo.", remaining_time.string(3, 0));
message_box("Questo e' un programma dimostrativo.\n Oggi rimangono %s minuti di utilizzo.", remaining_time.string(3, 0));
}
#endif
terminate();
@ -560,15 +582,12 @@ void TApplication::run(
__argc = argc;
__argv = (const char**)argv;
/* int addbar = 0; */
if (argc > 1 && argv[1][0] == '-')
{
_name = cmd2name(argv[0], argv[1]);
// addbar = atoi(argv[1]+1);
}
else
{
// addbar = 0;
_name = cmd2name(argv[0]);
}
@ -580,9 +599,14 @@ void TApplication::run(
const int sn = get_serial_number(firm_change_enabled() ? _name : "ba0100");
if (sn < 0)
{
error_box("Perhaps you forgot to connect the dongle");
error_box("Probabilmente non e' stata inserita la chiave di protezione");
return;
}
if (!test_assistance_year())
{
error_box("Probabilmente e' scaduto il contratto di assistenza");
return;
}
set_perms();
@ -603,14 +627,38 @@ void TApplication::run(
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.1998.01.00.000.1999";
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 >= 1997 && release > 0 && tag >= 0 && patch >= 0 &&
checksum == (year + release + tag + patch);
return valid;
}
// About box: risposta alla opzione Informazioni del menu File
void TApplication::about() const
{
#include <prassi.ver>
const TFilename n(__argv[0]);
message_box("Versione %s\nProgramma %s\nLibreria del %s\nN.ro di serie %d-%s",
VERSION, (const char*)n.name(), __DATE__, SerNo, INTERNAL_VERSION);
int year, release, tag, patch;
if (get_version_info(year, release, tag, patch))
{
message_box("Versione %d.%02d\nProgramma %s\nN.ro di serie %d-%02d.%03d",
year, release, (const char*)n.name(), SerNo, tag, patch);
}
else
{
#include <prassi.ver>
message_box("Versione %s\nProgramma %s\nLibreria del %s\nN.ro di serie %d-%s",
VERSION, (const char*)n.name(), __DATE__, SerNo, INTERNAL_VERSION);
}
}
// Risposta alla selezione Stampa del menu File
@ -792,7 +840,7 @@ bool TApplication::config()
const char* fname = fref->name();
if (fname != NULL)
{
TString& oldvl = cnf.get(fname);
const TString& oldvl = cnf.get(fname);
if (!oldvl.empty())
f.set(oldvl);
}

View File

@ -123,7 +123,7 @@ public:
// @cmember Abilita la verifica del modulo cui appartiene il programma
virtual bool check_autorization() const
{return TRUE;}
// @cmember Forza la chiusura dell'applicazione
void stop_run();
@ -162,6 +162,9 @@ public:
// Legge il parametro /uUTENTE e lo toglie dalla lista
static void check_parameters(int& argc, char *argv[]);
// @cmember Ritorna i numeri della versione del programma
static bool get_version_info(int& year, int& release, int& tag, int& patch);
// @cmember Controlla se il modulo <p module> ha l'autorizzazione all'esecuzione
bool has_module(int module, int checktype = CHK_ALL) const;
// @cmember Setta la ditta corrente (Ritorna se ce l'ha fatta)