Patch level : 2.0 488

Files correlati     : ba1.exe
Ricompilazione Demo : [ ]
Commento            :

Eliminata possibilita' di programmare un anno di assistenza inferiore
a quello memorizzato sulla chiave di protezione


git-svn-id: svn://10.65.10.50/trunk@11203 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2003-06-03 08:28:28 +00:00
parent 4f569ec3c4
commit 06b62f6cb0
2 changed files with 55 additions and 47 deletions

View File

@ -137,7 +137,7 @@ void DecodeString(char* data)
int ThisYear() int ThisYear()
{ {
int anno = 2001; int anno = 2003;
time_t lt; time_t lt;
if (time(&lt) == 0) if (time(&lt) == 0)
{ {
@ -196,6 +196,8 @@ bool DongleTest()
srand(883); srand(883);
DecodeString(line); DecodeString(line);
const int ass_year = atoi(line); const int ass_year = atoi(line);
if (ass_year > yearKey) // Non devo abbassare l'anno di assistenza!
{
srand(ass_year); srand(ass_year);
while (!keys.eof()) while (!keys.eof())
{ {
@ -220,6 +222,7 @@ bool DongleTest()
WarningBox(line); WarningBox(line);
} }
} }
}
else else
{ {
ErrorBox("Impossibile verificare il contratto di manutenzione"); ErrorBox("Impossibile verificare il contratto di manutenzione");

View File

@ -53,7 +53,7 @@ HIDDEN bool build_dninst(const TFilename& name)
{ {
srand(883); srand(883);
year = atoi(line); year = atoi(line);
CHECKD(year >= 1997 && year <= 2997, "Anno errato:", year); CHECKD(year >= 2001 && year <= 3001, "Anno errato:", year);
} }
encode_string(dninst_key, line); encode_string(dninst_key, line);
@ -83,6 +83,7 @@ HIDDEN bool show_error(const char* str)
return error_box(msg); return error_box(msg);
} }
/*
HIDDEN int module2number(const TString& mod) HIDDEN int module2number(const TString& mod)
{ {
static TAssoc_array* ass = NULL; static TAssoc_array* ass = NULL;
@ -107,6 +108,7 @@ HIDDEN int module2number(const TString& mod)
} }
return n; return n;
} }
*/
bool update_dninst(bool force) bool update_dninst(bool force)
{ {
@ -122,7 +124,7 @@ bool update_dninst(bool force)
fcopy(remote_name, keys_name); fcopy(remote_name, keys_name);
#ifdef DBG #ifdef DBG
else else
build_dninst(remote_name); build_dninst(remote_name); // La cifrature del file avviene solo in DEBUG!
#endif #endif
} }
return TRUE; return TRUE;
@ -132,27 +134,27 @@ bool update_assistance_year()
{ {
update_dninst(TRUE); update_dninst(TRUE);
TScanner keys("dninst.zip"); const TFilename dninst = "dninst.zip";
bool ok = FALSE; if (dninst.exist())
if (keys.ok())
{ {
const int serno = get_serial_number();
int sn = 0;
char dninst_key[8] = ""; char dninst_key[8] = "";
TScanner keys(dninst);
TString& anno = keys.line(); TString& anno = keys.line();
srand(883); srand(883);
decode_string(dninst_key, anno.get_buffer()); decode_string(dninst_key, anno.get_buffer());
const int ass_year = atoi(anno); const int ass_year = atoi(anno);
if (ass_year > dongle().year_assist())
{
const int serno = get_serial_number();
srand(ass_year); srand(ass_year);
while (!keys.eof()) while (!keys.eof())
{ {
TString& line = keys.line(); TString& line = keys.line();
if (line.empty()) if (line.empty())
break; break;
decode_string(dninst_key, line.get_buffer()); decode_string(dninst_key, line.get_buffer());
sn = atoi(line); const int sn = atoi(line);
if (sn == serno) if (sn == serno)
{ {
dongle().set_year_assist(ass_year); dongle().set_year_assist(ass_year);
@ -163,13 +165,16 @@ bool update_assistance_year()
} }
else else
{ {
show_error(FR("errore di scrittura sulla chiave di protezione")); show_error(FR("Errore di scrittura sulla chiave di protezione"));
return FALSE; return FALSE;
} }
} }
} }
show_error(TR("Il numero di serie di questa postazione non è presente sul database")); show_error(TR("Il numero di serie di questa postazione non è presente sul database"));
} }
else
show_error(TR("L'anno di assistenza sul database e' inferiore a quello registrato sulla chiave di protezione"));
}
else else
show_error(TR("Il database dei numeri di serie non è accessibile")); show_error(TR("Il database dei numeri di serie non è accessibile"));
return FALSE; return FALSE;