Patch level : 4.0.0
Files correlati : setup.exe Ricompilazione Demo : [ ] Commento : Corretta ricerca server remoti git-svn-id: svn://10.65.10.50/trunk@15620 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
144a07f646
commit
22af546170
114
setup/Setup.cpp
114
setup/Setup.cpp
@ -28,6 +28,7 @@
|
|||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
// Utilities
|
// Utilities
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
wxString GetDefaultDestination()
|
wxString GetDefaultDestination()
|
||||||
{
|
{
|
||||||
wxString strDest;
|
wxString strDest;
|
||||||
@ -56,79 +57,6 @@ wxString GetDefaultDestination()
|
|||||||
return strDest;
|
return strDest;
|
||||||
}
|
}
|
||||||
|
|
||||||
class CampoDirCopier : public wxDirTraverser
|
|
||||||
{
|
|
||||||
wxString m_strSrc, m_strDst;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual wxDirTraverseResult OnDir(const wxString& dirname);
|
|
||||||
virtual wxDirTraverseResult OnFile(const wxString& filename);
|
|
||||||
|
|
||||||
public:
|
|
||||||
void RenameDLL(const wxString& strDLL, bool bOpenGL) const;
|
|
||||||
bool Copy(const wxString& src, const wxString& dst, bool bOpenGL);
|
|
||||||
};
|
|
||||||
|
|
||||||
wxDirTraverseResult CampoDirCopier::OnDir(const wxString& dirname)
|
|
||||||
{
|
|
||||||
return wxDIR_CONTINUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxDirTraverseResult CampoDirCopier::OnFile(const wxString& filename)
|
|
||||||
{
|
|
||||||
wxFileName strSource(filename);
|
|
||||||
strSource.MakeRelativeTo(m_strSrc);
|
|
||||||
|
|
||||||
wxString str = m_strDst;
|
|
||||||
str += strSource.GetPathSeparator();
|
|
||||||
str += strSource.GetFullPath();
|
|
||||||
|
|
||||||
wxFileName strDest(str);
|
|
||||||
if (!strDest.DirExists())
|
|
||||||
strDest.Mkdir();
|
|
||||||
|
|
||||||
::wxCopyFile(filename, str);
|
|
||||||
|
|
||||||
return wxDIR_CONTINUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CampoDirCopier::RenameDLL(const wxString& strDLL, bool bOpenGL) const
|
|
||||||
{
|
|
||||||
wxFileName file1(m_strDst, strDLL);
|
|
||||||
file1.SetExt(bOpenGL ? wxT("dll") : wxT("old"));
|
|
||||||
|
|
||||||
if (file1.FileExists())
|
|
||||||
{
|
|
||||||
wxFileName file2(file1);
|
|
||||||
file2.SetExt(bOpenGL ? wxT("old") : wxT("dll"));
|
|
||||||
wxRename(file1.GetFullPath(), file2.GetFullPath());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CampoDirCopier::Copy(const wxString& src, const wxString& dst, bool bOpenGL)
|
|
||||||
{
|
|
||||||
wxBusyCursor hourglass;
|
|
||||||
m_strSrc = src;
|
|
||||||
m_strDst = dst;
|
|
||||||
|
|
||||||
if (!wxDirExists(m_strDst)) // Utile precauzione
|
|
||||||
wxMkdir(m_strDst);
|
|
||||||
|
|
||||||
wxDir dir(m_strSrc);
|
|
||||||
dir.Traverse(*this);
|
|
||||||
|
|
||||||
RenameDLL(wxT("OpenGL32.dll"), bOpenGL);
|
|
||||||
RenameDLL(wxT("glu32.dll"), bOpenGL);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
// CampoWizardPage
|
// CampoWizardPage
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
@ -158,10 +86,11 @@ class CampoWizard : public wxWizard
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
DECLARE_EVENT_TABLE();
|
DECLARE_EVENT_TABLE();
|
||||||
int Pages() const { return m_nPages; }
|
|
||||||
CampoWizardPage* Page(int p) const { return m_pPage[p]; }
|
|
||||||
void OnNext(wxCommandEvent& e);
|
void OnNext(wxCommandEvent& e);
|
||||||
|
|
||||||
|
int Pages() const { return m_nPages; }
|
||||||
|
CampoWizardPage& Page(int p) const { wxASSERT(p >= 0 && p < m_nPages); return *m_pPage[p]; }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool Run();
|
bool Run();
|
||||||
wxString Get(wxWindowID id) const;
|
wxString Get(wxWindowID id) const;
|
||||||
@ -631,16 +560,25 @@ void CampoWizardPage4::OnEUPick(wxCommandEvent& e)
|
|||||||
|
|
||||||
void CampoWizardPage4::OnSRPick(wxCommandEvent& e)
|
void CampoWizardPage4::OnSRPick(wxCommandEvent& e)
|
||||||
{
|
{
|
||||||
wxString strSrvName;
|
static bool bSemaforo = false;
|
||||||
int year = 0;
|
if (!bSemaforo)
|
||||||
unsigned short serno = ServerLogin(year, strSrvName);
|
{
|
||||||
if (!strSrvName.IsEmpty())
|
bSemaforo = true;
|
||||||
Set(404, strSrvName);
|
wxBusyCursor hourglass;
|
||||||
|
wxString strSrvName;
|
||||||
|
int year = 0;
|
||||||
|
unsigned short serno = ServerLogin(year, strSrvName);
|
||||||
|
if (!strSrvName.IsEmpty())
|
||||||
|
Set(404, strSrvName);
|
||||||
|
bSemaforo = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CampoWizardPage4::ForwardValidate()
|
bool CampoWizardPage4::ForwardValidate()
|
||||||
{
|
{
|
||||||
//per poter proseguire deve aver trovato una chiave o un server!
|
//per poter proseguire deve aver trovato una chiave o un server!
|
||||||
|
|
||||||
|
GetWizard().SetSrvAuth(Get(404));
|
||||||
int nDongleType = DongleTest();
|
int nDongleType = DongleTest();
|
||||||
if (nDongleType == 0)
|
if (nDongleType == 0)
|
||||||
return ErrorBox("Per proseguire e' NECESSARIO installare una chiave locale o collegarsi ad una chiave di rete!");
|
return ErrorBox("Per proseguire e' NECESSARIO installare una chiave locale o collegarsi ad una chiave di rete!");
|
||||||
@ -1559,7 +1497,7 @@ void CampoWizard::OnNext(wxCommandEvent& e)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool CampoWizard::Run()
|
bool CampoWizard::Run()
|
||||||
{ return RunWizard(Page(0)); }
|
{ return RunWizard(m_pPage[0]); }
|
||||||
|
|
||||||
wxString CampoWizard::Get(wxWindowID id) const
|
wxString CampoWizard::Get(wxWindowID id) const
|
||||||
{
|
{
|
||||||
@ -1778,6 +1716,18 @@ CampoWizard::CampoWizard(wxWindow* pParent)
|
|||||||
wxWizardPageSimple::Chain(m_pPage[p-1], m_pPage[p]);
|
wxWizardPageSimple::Chain(m_pPage[p-1], m_pPage[p]);
|
||||||
|
|
||||||
GetPageAreaSizer()->Add(m_pPage[0]);
|
GetPageAreaSizer()->Add(m_pPage[0]);
|
||||||
|
|
||||||
|
wxWindow* pNext = FindWindowById(wxID_FORWARD);
|
||||||
|
if (pNext != NULL)
|
||||||
|
pNext->SetLabel("Continua");
|
||||||
|
|
||||||
|
wxWindow* pPrev = FindWindowById(wxID_BACKWARD);
|
||||||
|
if (pPrev != NULL)
|
||||||
|
pPrev->SetLabel("C'ho ripensato");
|
||||||
|
|
||||||
|
wxWindow* pCancel = FindWindowById(wxID_CANCEL);
|
||||||
|
if (pCancel != NULL)
|
||||||
|
pCancel->SetLabel("Mittico! Ma vaff...");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#include "wxinc.h"
|
#include "wxinc.h"
|
||||||
|
|
||||||
#include <wx/socket.h>
|
#include <wx/socket.h>
|
||||||
|
|
||||||
#include "setupkey.h"
|
#include "setupkey.h"
|
||||||
@ -10,7 +9,6 @@ extern "C"
|
|||||||
#include "../xvaga/skeylink.h"
|
#include "../xvaga/skeylink.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
// Utilities //
|
// Utilities //
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
@ -144,16 +142,82 @@ unsigned short EutronLogin(int& year)
|
|||||||
return serno;
|
return serno;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////
|
||||||
|
// Gestione Server di chiavi //
|
||||||
|
//////////////////////////////////
|
||||||
|
|
||||||
|
class TBordello
|
||||||
|
{
|
||||||
|
WX_DECLARE_STRING_HASH_MAP(wxSocketClient*, TBrothel);
|
||||||
|
TBrothel m_map;
|
||||||
|
|
||||||
|
public:
|
||||||
|
wxSocketClient& Zoccola(wxIPV4address& ip);
|
||||||
|
wxSocketClient* QuellaBuona();
|
||||||
|
void Chiudi();
|
||||||
|
virtual ~TBordello();
|
||||||
|
} m_bordello;
|
||||||
|
|
||||||
|
wxSocketClient& TBordello::Zoccola(wxIPV4address& ip)
|
||||||
|
{
|
||||||
|
const wxString strIP = ip.IPAddress();
|
||||||
|
if (m_map[strIP] == NULL)
|
||||||
|
{
|
||||||
|
m_map[strIP] = new wxSocketClient;
|
||||||
|
m_map[strIP]->SetTimeout(2);
|
||||||
|
}
|
||||||
|
return *m_map[strIP];
|
||||||
|
}
|
||||||
|
|
||||||
|
wxSocketClient* TBordello::QuellaBuona()
|
||||||
|
{
|
||||||
|
wxSocketClient* good = NULL;
|
||||||
|
for(TBrothel::iterator it = m_map.begin(); it != m_map.end(); ++it )
|
||||||
|
{
|
||||||
|
wxSocketClient* sc = (wxSocketClient*)it->second;
|
||||||
|
if (sc != NULL)
|
||||||
|
{
|
||||||
|
sc->WaitOnConnect(0, 1);
|
||||||
|
if (sc->IsConnected())
|
||||||
|
{
|
||||||
|
good = sc;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return good;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TBordello::Chiudi()
|
||||||
|
{
|
||||||
|
for(TBrothel::iterator it = m_map.begin(); it != m_map.end(); ++it )
|
||||||
|
{
|
||||||
|
wxSocketClient* sc = (wxSocketClient*)it->second;
|
||||||
|
if (sc != NULL)
|
||||||
|
sc->Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TBordello::~TBordello()
|
||||||
|
{
|
||||||
|
/* Non funziona per oggetti statici
|
||||||
|
for(TBrothel::iterator it = m_map.begin(); it != m_map.end(); ++it )
|
||||||
|
{
|
||||||
|
wxSocketClient* sc = (wxSocketClient*)it->second;
|
||||||
|
sc->Destroy();
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
m_map.clear();
|
||||||
|
}
|
||||||
|
|
||||||
//////////////////////////////////
|
|
||||||
// Gestione Server di chiavi //
|
|
||||||
//////////////////////////////////
|
|
||||||
static unsigned short InquireSocketNumber(wxSocketClient& sc, const wxString& strCommand)
|
static unsigned short InquireSocketNumber(wxSocketClient& sc, const wxString& strCommand)
|
||||||
{
|
{
|
||||||
sc.Write(strCommand, (wxUint32)strCommand.Len());
|
sc.Discard();
|
||||||
long number[2] = { 0L, 0L };
|
sc.Write(strCommand, (wxUint32)strCommand.Len());
|
||||||
sc.Read(number, sizeof(number));
|
long number[2] = { 0L, 0L };
|
||||||
return (unsigned short)number[1];
|
sc.Read(number, sizeof(number));
|
||||||
|
return (unsigned short)number[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned short InquireServer(const wxString& strSrvName, int& year, const bool bMsg)
|
static unsigned short InquireServer(const wxString& strSrvName, int& year, const bool bMsg)
|
||||||
@ -169,13 +233,12 @@ static unsigned short InquireServer(const wxString& strSrvName, int& year, const
|
|||||||
return serno;
|
return serno;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxSocketClient* sc = new wxSocketClient;
|
wxSocketClient& sc = m_bordello.Zoccola(ip);
|
||||||
sc->SetTimeout(2);
|
if (sc.IsConnected() || sc.Connect(ip)) //il computer remoto risponde
|
||||||
if (sc->Connect(ip)) //il computer remoto risponde ma il server no (non c'e' o e' spento)
|
|
||||||
{
|
{
|
||||||
serno = InquireSocketNumber(*sc, "DongleNumber()");
|
// ma il server e' davvero acceso o spento ?
|
||||||
year = InquireSocketNumber(*sc, "DongleYear()");
|
serno = InquireSocketNumber(sc, "DongleNumber()");
|
||||||
sc->Discard();
|
year = InquireSocketNumber(sc, "DongleYear()");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -187,7 +250,6 @@ static unsigned short InquireServer(const wxString& strSrvName, int& year, const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sc->Destroy();
|
|
||||||
return serno;
|
return serno;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,51 +270,35 @@ unsigned short ServerLogin(int& year, wxString& strSrvName)
|
|||||||
if (strMyIP.Len() > 7)
|
if (strMyIP.Len() > 7)
|
||||||
{
|
{
|
||||||
const unsigned short MaxSck = 256;
|
const unsigned short MaxSck = 256;
|
||||||
// for (int j = 3; j < 256 && serno == 0xFFFF; j += MaxSck)
|
for (int i = 0; i < MaxSck; i++)
|
||||||
{
|
{
|
||||||
wxSocketClient* sc[MaxSck];
|
//deve sostituire l'ultima cifra dell'IP con tutti i numeri che vanno da 0 a 255 alla ricerca del server
|
||||||
memset(sc, 0, sizeof(sc));
|
wxString strSrvIP = strMyIP.BeforeLast('.');
|
||||||
wxIPV4address ipRemote[MaxSck];
|
strSrvIP << "." << i; //ip del computer remoto
|
||||||
for (int i = 0; i < MaxSck; i++)
|
if (strSrvIP != strMyIP)
|
||||||
{
|
{
|
||||||
const int n = i; //+j;
|
wxIPV4address ipRemote;
|
||||||
if (n < 256)
|
if (ipRemote.Hostname(strSrvIP) && ipRemote.Service("1883"))
|
||||||
{
|
{
|
||||||
//deve sostituire l'ultima cifra dell'IP con tutti i numeri che vanno da 0 a 255 alla ricerca del server
|
wxSocketClient& sc = m_bordello.Zoccola(ipRemote);
|
||||||
wxString strSrvIP = strMyIP.BeforeLast('.');
|
if (!sc.IsConnected())
|
||||||
strSrvIP << "." << n; //ip del computer remoto
|
sc.Connect(ipRemote, ipLocal, false);
|
||||||
if (strSrvIP == strMyIP)
|
|
||||||
continue;
|
|
||||||
if (ipRemote[i].Hostname(strSrvIP) && ipRemote[i].Service("1883"))
|
|
||||||
{
|
|
||||||
sc[i] = new wxSocketClient;
|
|
||||||
sc[i]->SetTimeout(2);
|
|
||||||
sc[i]->Connect(ipRemote[i], false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wxMilliSleep(100);
|
}
|
||||||
for (int i = 0; i < MaxSck; i++) if (sc[i])
|
|
||||||
{
|
wxSleep(2);
|
||||||
sc[i]->WaitOnConnect(0, 1);
|
wxSocketClient* sc = m_bordello.QuellaBuona();
|
||||||
if (sc[i]->IsConnected())
|
if (sc != NULL)
|
||||||
{
|
{
|
||||||
sc[i]->GetPeer(ipRemote[i]);
|
wxIPV4address ipRemote;
|
||||||
strSrvName = ipRemote[i].Hostname();
|
sc->GetPeer(ipRemote);
|
||||||
serno = InquireSocketNumber(*sc[i], "DongleNumber()");
|
strSrvName = ipRemote.Hostname();
|
||||||
year = InquireSocketNumber(*sc[i], "DongleYear()");
|
}
|
||||||
sc[i]->Discard();
|
|
||||||
if (year > 0)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
sc[i]->Close();
|
|
||||||
} //for (inti =0...
|
|
||||||
for (int i = 0; i < MaxSck; i++) if (sc[i])
|
|
||||||
sc[i]->Destroy();
|
|
||||||
} //for(int j=0...
|
|
||||||
} //if(strMyIP.Len()...
|
} //if(strMyIP.Len()...
|
||||||
} //if(strSrvName.Is...
|
} //if(strSrvName.Is...
|
||||||
else
|
|
||||||
|
if (!strSrvName.IsEmpty())
|
||||||
serno = InquireServer(strSrvName, year, true);
|
serno = InquireServer(strSrvName, year, true);
|
||||||
|
|
||||||
return serno;
|
return serno;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user