diff --git a/include/dongle.cpp b/include/dongle.cpp index d467b93e2..dcd056539 100755 --- a/include/dongle.cpp +++ b/include/dongle.cpp @@ -70,11 +70,13 @@ bool destroy_dongle() delete _dongle; _dongle = NULL; +#ifndef _DEMO_ if (_eutron_key) { delete _eutron_key; _eutron_key = NULL; } +#endif // _DEMO_ } return ok; } @@ -230,7 +232,8 @@ bool TDongle::hardlock_login(bool test_all_keys) { if (data[0] == 0x3283 || data[0] == 0xA3AA) // chiave programmatori !! { - _type = _developer_dongle; + if (_type == _user_dongle) + _type = _developer_dongle; _serno = 0; } } @@ -427,7 +430,7 @@ bool TDongle::login(bool test_all_keys) #ifdef _DEMO_ _hardware = _dongle_hardlock; - _type = _dongle_user; + _type = _user_dongle; _serno = 0; _max_users = 1; _last_update = TDate(TODAY); @@ -437,12 +440,28 @@ bool TDongle::login(bool test_all_keys) #else if (_type != _no_dongle) // Already logged in logout(); - if (_hardware == _dongle_unknown || _hardware == _dongle_hardlock) + TConfig ini("prawin.ini", "Main"); + const TDongleHardware hw = (TDongleHardware)ini.get_int("Donglehw"); + if (_hardware == _dongle_unknown && (hw ==_dongle_hardlock || hw ==_dongle_eutron)) + _hardware = hw ; // ...presets hardware types only for LOCAL dongles ... + if (_hardware == _dongle_hardlock || _hardware == _dongle_unknown ) ok = hardlock_login(test_all_keys); - if (_hardware == _dongle_unknown || _hardware == _dongle_eutron) + if (_hardware == _dongle_eutron || _hardware == _dongle_unknown ) ok = eutron_login(test_all_keys); - if (_hardware == _dongle_unknown || _hardware == _dongle_network) + if (_hardware == _dongle_network || _hardware == _dongle_unknown) ok = network_login(test_all_keys); + if (!ok && hw != _dongle_unknown) + { + // retry login for various dongles ... + if (hw != _dongle_eutron) + ok = eutron_login(test_all_keys); + if (!ok && hw != _dongle_hardlock) + ok = hardlock_login(test_all_keys); + if (!ok && hw != _dongle_network) + ok = network_login(test_all_keys); + } + if (_hardware != hw) + ini.set("Donglehw",(int)(ok ? _hardware:_dongle_unknown)); #endif return ok; } @@ -630,7 +649,7 @@ bool TDongle::burn_eutron() memset(eh, 0, sizeof(TEutronHeader)); _last_update = TDate(TODAY); - sprintf(eh->_serno, "%lu", _serno); + sprintf(eh->_serno, "%lu", (unsigned long)_serno); eh->_year_assist = _year_assist; eh->_max_users = _max_users; eh->_last_date = atol(_last_update.string(ANSI));