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,28 +196,31 @@ bool DongleTest()
srand(883); srand(883);
DecodeString(line); DecodeString(line);
const int ass_year = atoi(line); const int ass_year = atoi(line);
srand(ass_year); if (ass_year > yearKey) // Non devo abbassare l'anno di assistenza!
while (!keys.eof())
{ {
keys.getline(line, sizeof(line)); srand(ass_year);
DecodeString(line); while (!keys.eof())
unsigned int sn = (unsigned int)atol(line);
if (sn == serno || line[0] == '*')
{ {
ok = TRUE; keys.getline(line, sizeof(line));
break; DecodeString(line);
unsigned int sn = (unsigned int)atol(line);
if (sn == serno || line[0] == '*')
{
ok = TRUE;
break;
}
}
if (ok)
{
wsprintf(line, "Il contratto di manutenzione %d verrà attivato automaticamente", ass_year);
WarningBox(line);
}
else
{
wsprintf(line, "È necessario contattare l'assistenza tecnica\n"
"per l'abilitazione del contratto di manutenzione %d", verYear);
WarningBox(line);
} }
}
if (ok)
{
wsprintf(line, "Il contratto di manutenzione %d verrà attivato automaticamente", ass_year);
WarningBox(line);
}
else
{
wsprintf(line, "È necessario contattare l'assistenza tecnica\n"
"per l'abilitazione del contratto di manutenzione %d", verYear);
WarningBox(line);
} }
} }
else else

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,43 +134,46 @@ 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);
srand(ass_year); if (ass_year > dongle().year_assist())
while (!keys.eof())
{ {
TString& line = keys.line(); const int serno = get_serial_number();
if (line.empty()) srand(ass_year);
break; while (!keys.eof())
decode_string(dninst_key, line.get_buffer());
sn = atoi(line);
if (sn == serno)
{ {
dongle().set_year_assist(ass_year); TString& line = keys.line();
if (dongle().burn()) if (line.empty())
break;
decode_string(dninst_key, line.get_buffer());
const int sn = atoi(line);
if (sn == serno)
{ {
message_box(FR("Il contratto %d è stato attivato automaticamente"), ass_year); dongle().set_year_assist(ass_year);
return TRUE; if (dongle().burn())
} {
else message_box(FR("Il contratto %d è stato attivato automaticamente"), ass_year);
{ return TRUE;
show_error(FR("errore di scrittura sulla chiave di protezione")); }
return FALSE; else
{
show_error(FR("Errore di scrittura sulla chiave di protezione"));
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"));