From 1b02ee8b0f006a49e10821a5d68056363cee8182 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Tue, 9 Apr 2024 14:42:55 +0200 Subject: [PATCH] EgtLock : - modifiche per meglio riconoscere il tipo di errore con la chiave di rete. --- KeyProc.cpp | 8 ++++++-- LockId.cpp | 16 +++++++++++++--- NetDongleId.cpp | 19 ++++++++++++------- NetDongleId.h | 5 +++-- 4 files changed, 34 insertions(+), 14 deletions(-) diff --git a/KeyProc.cpp b/KeyProc.cpp index 4bba48f..c6d752a 100644 --- a/KeyProc.cpp +++ b/KeyProc.cpp @@ -136,8 +136,12 @@ VerifyKey( const string& sKey, int nProd, int nVer, int nLev, { // creo la chiave di scramble string sLockId2 ; - if ( ! GetLockId2( sLockId2)) - return KEY_ERR_MACHID ; + if ( ! GetLockId2( sLockId2)) { + if ( NotFoundNetHwKey()) + return KEY_ERR_NETKEY_NOTFOUND ; + else + return KEY_ERR_MACHID ; + } string sScramKey ; if ( ! ConvertLockId2ToScramKey( sLockId2, sScramKey)) return KEY_ERR_SCRAMKEY ; diff --git a/LockId.cpp b/LockId.cpp index 4a49310..8badace 100644 --- a/LockId.cpp +++ b/LockId.cpp @@ -65,6 +65,16 @@ CloseNetHwKey( void) return NetDongleClose() ; } +//---------------------------------------------------------------------------- +bool +NotFoundNetHwKey( void) +{ + if ( s_bNetHwKey) + return NetDongleNotFound() ; + else + return false ; +} + //---------------------------------------------------------------------------- bool GetLockId( string& sLockId) @@ -80,10 +90,10 @@ GetLockId( string& sLockId) case KEY_LOCK_TYPE_SW : return GetMachineId( sLockId) ; case KEY_LOCK_TYPE_HW : - if ( ! s_bNetHwKey) - return GetDongleId( sLockId) ; - else + if ( s_bNetHwKey) return GetNetDongleId( s_nNetUserId, s_sAddrPort, sLockId) ; + else + return GetDongleId( sLockId) ; } } diff --git a/NetDongleId.cpp b/NetDongleId.cpp index ec25714..a406306 100644 --- a/NetDongleId.cpp +++ b/NetDongleId.cpp @@ -111,9 +111,11 @@ NetDongleConnect( int nNetUserId, const string& sAddrPort) int nStatusND = 0 ; if ( &sAddrPort == nullptr || sAddrPort.empty() || sAddrPort.find_first_not_of( " \t\r\n") == std::string::npos) - s_net_data = xnd_net_data_create_resolving_local_search( s_env, XND_DEFAULT_PORT, label, 30000, 0, 0, &nStatusND) ; - else - s_net_data = xnd_net_data_create_resolving_addr_port( s_env, s_sAddrPort.c_str(), 0, 30000, &nStatusND) ; + s_net_data = xnd_net_data_create_resolving_local_search( s_env, XND_DEFAULT_PORT, label, 10000, 0, 0, &nStatusND) ; + else { + s_sAddrPort = sAddrPort ; + s_net_data = xnd_net_data_create_resolving_addr_port( s_env, s_sAddrPort.c_str(), 0, 0, &nStatusND) ; + } if ( s_net_data == nullptr) { xnd_xlt_env_release( s_env) ; return false ; @@ -174,8 +176,6 @@ NetDongleConnect( int nNetUserId, const string& sAddrPort) } if ( s_dev_ctx == nullptr) { xnd_xlt_env_release( s_env) ; - s_env = nullptr ; - s_net_data = nullptr ; return false ; } // apro la sessione @@ -183,8 +183,6 @@ NetDongleConnect( int nNetUserId, const string& sAddrPort) if ( nStatOP != 0) { xnd_xlt_devctx_release( s_dev_ctx) ; xnd_xlt_env_release( s_env) ; - s_env = nullptr ; - s_net_data = nullptr ; s_dev_ctx = nullptr ; return false ; } @@ -202,3 +200,10 @@ NetDongleClose( void) s_env = nullptr ; return true ; } + +//---------------------------------------------------------------------------- +bool +NetDongleNotFound( void) +{ + return ( s_env != nullptr && s_net_data == nullptr) ; +} diff --git a/NetDongleId.h b/NetDongleId.h index 9eb6424..fcf59c3 100644 --- a/NetDongleId.h +++ b/NetDongleId.h @@ -1,7 +1,7 @@ //---------------------------------------------------------------------------- -// EgalTech 2022-2023 +// EgalTech 2022-2024 //---------------------------------------------------------------------------- -// File : NetDongleId.h Data : 09.10.23 Versione : 2.5j1 +// File : NetDongleId.h Data : 09.04.24 Versione : 2.6d2 // Contenuto : Dichiarazione funzioni locali per gestione/calcolo Id chiave. // // @@ -19,3 +19,4 @@ bool GetNetDongleId( int nNetUserId, const std::string& sAddrPort, std::string& sDongleId) ; bool NetDongleConnect( int nNetUserId, const std::string& sAddrPort) ; bool NetDongleClose( void) ; +bool NetDongleNotFound( void) ;