dongle.cpp Modificata priorita' nella scelta del dongle cui loggarsi

dongle.h     Aggiunto metodo TDongle::can_use_server()
os_*.*       Aggiunta funzione os_dongle_server_running()
skeytsr.h    Aggiunto #pragma pack(1) per 32 bit


git-svn-id: svn://10.65.10.50/trunk@6701 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1998-05-28 10:09:12 +00:00
parent ca9c5a6b32
commit a04f282de0
6 changed files with 79 additions and 18 deletions

View File

@ -4,6 +4,7 @@
#include <config.h>
#include <dongle.h>
#include <isamrpc.h>
#include <os_dep.h>
#include <utility.h>
///////////////////////////////////////////////////////////
@ -37,6 +38,8 @@ extern "C"
HIDDEN KEY_NET* _eutron_key = NULL;
#pragma pack(1)
struct TEutronHeader
{
char _serno[8];
@ -47,6 +50,8 @@ struct TEutronHeader
unsigned long _checksum; // Must be the last item!
};
#pragma pack()
#endif // _DEMO_
///////////////////////////////////////////////////////////
@ -321,6 +326,7 @@ bool TDongle::eutron_login(bool test_all_keys)
_eutron_key = new KEY_NET;
memset(_eutron_key, 0, sizeof(KEY_NET));
_eutron_key->net_command = NET_KEY_OPEN;
_eutron_key->command = LOCATING_MODE;
const char* labels[5] = { "AGA.INFORMATICA", "AGA.PRASSI", "AGA.PROCOM",
"AGA.CAMPO", "25EBAI" };
@ -424,6 +430,16 @@ bool TDongle::network_login(bool test_all_keys)
#endif // _DEMO_
int TDongle::can_try_server() const
{
if (os_dongle_server_running())
return 3;
TConfig ini("prawin.ini", "Server");
const TString& dongle = ini.get("Dongle");
return dongle.not_empty();
}
bool TDongle::login(bool test_all_keys)
{
bool ok = TRUE;
@ -440,28 +456,54 @@ bool TDongle::login(bool test_all_keys)
#else
if (_type != _no_dongle) // Already logged in
logout();
TDongleHardware hw = _hardware;
if (hw == _dongle_unknown)
{
if (can_try_server() == 3)
{
hw = _dongle_network;
}
else
{
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 )
hw = (TDongleHardware)ini.get_int("Donglehw");
}
}
switch(hw)
{
case _dongle_hardlock:
ok = hardlock_login(test_all_keys);
if (_hardware == _dongle_eutron || _hardware == _dongle_unknown )
break;
case _dongle_eutron:
ok = eutron_login(test_all_keys);
if (_hardware == _dongle_network || _hardware == _dongle_unknown)
break;
case _dongle_network:
ok = network_login(test_all_keys);
if (!ok && hw != _dongle_unknown)
break;
default:
ok = FALSE;
break;
}
if (!ok)
{
// retry login for various dongles ...
if (hw != _dongle_eutron)
const int use_server = can_try_server();
if (hw != _dongle_network && use_server)
ok = network_login(test_all_keys);
if (!ok && use_server != 3)
{
if (!ok && 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));
if (ok)
{
TConfig ini("prawin.ini", "Main");
ini.set("Donglehw",(int)_hardware);
}
}
#endif
return ok;
}

View File

@ -33,6 +33,8 @@ protected:
bool burn_hardlock();
bool burn_eutron();
int can_try_server() const;
public: // TObject
virtual bool ok() const
{ return _hardware != _dongle_unknown &&

View File

@ -47,5 +47,6 @@ bool os_spool_row(const char* str);
bool os_close_spool_row();
bool os_get_image_editor_path(TFilename& name);
bool os_dongle_server_running();
#endif

View File

@ -658,3 +658,9 @@ void os_maximize_window(WINDOW win)
HWND hwnd = (HWND)xvt_vobj_get_attr(win, ATTR_NATIVE_WINDOW);
ShowWindow(hwnd, SW_SHOWMAXIMIZED);
}
bool os_dongle_server_running()
{
ATOM a = GlobalFindAtom("DONGLE_SERVER_ATOM");
return a != 0;
}

View File

@ -476,3 +476,9 @@ void os_maximize_window(WINDOW win)
HWND hwnd = (HWND)xvt_vobj_get_attr(win, ATTR_NATIVE_WINDOW);
ShowWindow(hwnd, SW_SHOWMAXIMIZED);
}
bool os_dongle_server_running()
{
ATOM a = GlobalFindAtom("DONGLE_SERVER_ATOM");
return a != 0;
}

View File

@ -98,6 +98,8 @@
/* Communication structure definition */
/* -------------------------------------------------------------------- */
#pragma pack(1)
typedef struct smartkey {
short net_command;
unsigned long net_password;
@ -111,6 +113,8 @@ typedef struct smartkey {
unsigned char ext_data[EXTENDED_DATA_LENGTH];
} KEY_NET;
#pragma pack()
/* -------------------------------------------------------------------- */
/* Interface function prototype */
/* -------------------------------------------------------------------- */