Patch level :

Files correlati     :
Ricompilazione Demo : [ ]
Commento            :


git-svn-id: svn://10.65.10.50/trunk@15614 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
luca 2007-09-13 11:30:52 +00:00
parent 614cf9d5bf
commit fb5e59b49c
2 changed files with 65 additions and 42 deletions

View File

@ -596,6 +596,8 @@ protected:
DECLARE_EVENT_TABLE();
void OnHLPick(wxCommandEvent& e);
void OnEUPick(wxCommandEvent& e);
void OnSRPick(wxCommandEvent& e);
virtual bool ForwardValidate();
virtual bool TransferDataToWindow();
@ -612,6 +614,7 @@ public:
BEGIN_EVENT_TABLE(CampoWizardPage4, CampoWizardPage)
EVT_BUTTON(401, OnHLPick)
EVT_BUTTON(402, OnEUPick)
EVT_BUTTON(403, OnSRPick)
END_EVENT_TABLE()
void CampoWizardPage4::OnHLPick(wxCommandEvent& e)
@ -626,12 +629,22 @@ void CampoWizardPage4::OnEUPick(wxCommandEvent& e)
wxExecute(path, wxEXEC_SYNC);
}
void CampoWizardPage4::OnSRPick(wxCommandEvent& e)
{
wxString strSrvName;
int year = 0;
unsigned short serno = ServerLogin(year, strSrvName);
if (!strSrvName.IsEmpty())
Set(404, strSrvName);
}
bool CampoWizardPage4::ForwardValidate()
{
/* int serno = 0xFFFF;
if (Get(403) != "")
if (Get(404) != "")
{
serno = ServerLogin(0, Get(403));
int year;
serno = ServerLogin(year, Get(404));
}
if (serno == 0xFFFF)
return ErrorBox("Impossibile trovare la chiave in rete!!");*/
@ -644,6 +657,7 @@ bool CampoWizardPage4::TransferDataToWindow()
FindWindowById(401)->Disable();
FindWindowById(402)->Disable();
FindWindowById(403)->Disable();
FindWindowById(404)->Disable();
//controlla preventivamente se la chiave c'e' ed eventualmente quale e' (hardlock,eutron,server di chiavi)
const int nDongleType = DongleTest();
@ -667,17 +681,19 @@ bool CampoWizardPage4::TransferDataToWindow()
strBody += wxT("<p>E' stato rilevata una chiave remota condivisa in rete con il servizio di gestione autorizzazioni:</p>");
strBody += wxT("<p align=center><img src=\"../campo/servers/autho.gif\" /></p>");
strBody += wxT("<p>Si puo' procedere con l'installazione /aggiornamento del software <b><i>Campo</i></b>. Premere il pulsante \"Next\".</p>");
Set(403, GetWizard().GetSrvAuth());
Set(404, GetWizard().GetSrvAuth());
break;
default:
strBody += wxT("<p><b>Non e' stata rilevata alcuna chiave hardware installata sul computer!</b></p>");
strBody += wxT("<p>Per procedere all'installazione della chiave hardware, <u>collegarla al computer e premere il bottone corrispondente</u> alla tipologia della chiave stessa per installarne i driver.</p>");
strBody += wxT("<p>Se si utilizza una chiave remota collegata ad un altro computer e condivisa in rete attraverso il servizio gestione di autorizzazioni ");
strBody += wxT("<u>indicare il nome del computer (o l'indirizzo IP) cui e' collegata la chiave e su cui e' <b>installato e funzionante</b> il gestore di autorizzazioni</u>. ");
strBody += wxT("premere il bottone <u>Cerca</u> per attivare la ricerca automatica della chiave remota. Qualora tale ricerca fallisse digitare il nome del computer ");
strBody += wxT("(o l'indirizzo IP) cui e' collegata la chiave di rete e su cui e' <b>installato e funzionante</b> il gestore di autorizzazioni. ");
FindWindowById(401)->Enable();
FindWindowById(402)->Enable();
FindWindowById(403)->Enable();
FindWindowById(404)->Enable();
break;
}
@ -715,12 +731,12 @@ int CampoWizardPage4::VersionYear()
int CampoWizardPage4::DongleTest()
{
wxString strSrvName = GetWizard().GetSrvAuth(); //nome del server di autorizzazioni (se c'e')
int dongle_type = 0;
int yearKey = 0;
unsigned int serno = 0xFFFF;
wxString strSrvName = GetWizard().GetSrvAuth(); //nome del server di autorizzazioni (se c'e')
if (!strSrvName.IsEmpty())
{
serno = ServerLogin(yearKey, strSrvName);
@ -736,18 +752,6 @@ int CampoWizardPage4::DongleTest()
serno = EutronLogin(yearKey);
if (serno != 0xFFFF)
dongle_type = 2; //chiave eutron
else
{
if (strSrvName.IsEmpty())
{
serno = ServerLogin(yearKey, strSrvName);
if (serno != 0xFFFF)
{
dongle_type = 3; //chiave remota
GetWizard().SetSrvAuth(strSrvName);
}
}
}
}
else
dongle_type = 1; //chiave hardlock
@ -840,14 +844,13 @@ CampoWizardPage4::CampoWizardPage4(wxWizard* parent) : CampoWizardPage(parent)
//terza riga della griglia
//Server label
AddLabel(gbsButtSizer, "Nome o indirizzo IP del server di autorizzazioni", 2, 0);
//Server image
wxBitmap bmp_Srv("../campo/servers/autho.gif", wxBITMAP_TYPE_GIF);
wxStaticBitmap* s_bmp_Srv = new wxStaticBitmap(this, wxID_ANY, bmp_Srv);
gbsButtSizer->Add(s_bmp_Srv, wxGBPosition(2, 1));
//nome Server
wxTextCtrl* tcSrvName = new wxTextCtrl(this, 403, "", wxDefaultPosition, wxSize(320,-1));
gbsButtSizer->Add(tcSrvName, wxGBPosition(2, 2));
wxTextCtrl* tcSrvName = new wxTextCtrl(this, 404, "", wxDefaultPosition, wxSize(128,-1));
gbsButtSizer->Add(tcSrvName, wxGBPosition(2, 1));
//bottone Eutron
wxButton* bSrvButton = new wxButton(this, 403, wxT("Cerca"), wxDefaultPosition, wxSize(64, -1));
gbsButtSizer->Add(bSrvButton, wxGBPosition(2, 2), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
}
/**********************************************************************************************************/

View File

@ -177,34 +177,54 @@ static unsigned short InquireServer(const wxString& strSrvName, int& year, const
unsigned short ServerLogin(int& year, wxString& strSrvName)
{
unsigned short serno = 0xFFFF;
//se non specificato un nome/indirizzo di server, lo cerca tra i miei "cpu fratelli" in rete
if (strSrvName.IsEmpty())
{
//intanto deve trovare il suo IP di rete
wxIPV4address ip;
ip.AnyAddress();
wxString strMyName = ip.Hostname();
ip.Hostname(strMyName);
wxString strMyIP = ip.IPAddress();
wxString strSrvIP;
for (int i = 9; i < 256; i++)
wxIPV4address ipLocal;
ipLocal.AnyAddress();
wxString strMyName = ipLocal.Hostname();
ipLocal.Hostname(strMyName);
const wxString strMyIP = ipLocal.IPAddress();
if (strMyIP.Len() > 7)
{
//deve sostituire l'ultima cifra dell'IP con tutti i numeri che vanno da 0 a 255 alla ricerca del server
strSrvIP = strMyIP.BeforeLast('.');
strSrvIP << "." << i;
serno = InquireServer(strSrvIP, year, false);
if (serno != 0xFFFF)
wxSocketClient sc[256];
for (int i = 0; i < 256; i++)
{
ip.Hostname(strSrvIP);
strSrvName = ip.Hostname();
break;
//deve sostituire l'ultima cifra dell'IP con tutti i numeri che vanno da 0 a 255 alla ricerca del server
wxString strSrvIP = strMyIP.BeforeLast('.');
strSrvIP << "." << i;
wxIPV4address ipRemote;
if (ipRemote.Hostname(strSrvIP) && ipRemote.Service("1883"))
{
sc[i].SetTimeout(2);
sc[i].Connect(ipRemote, false);
}
}
wxSleep(2);
for (int i = 0; i < 256; i++)
{
sc[i].WaitOnConnect(0, 10);
if (sc[i].IsConnected())
{
wxIPV4address ipRemote;
sc[i].GetPeer(ipRemote);
strSrvName = ipRemote.Hostname();
serno = InquireSocketNumber(sc[i], "DongleNumber()");
year = InquireSocketNumber(sc[i], "DongleYear()");
if (year > 0)
break;
}
}
for (int i = 0; i < 256; i++)
sc[i].Destroy();
}
}
else //se invece e' specificato un server vede se il server di chiavi c'e' e funziona davvero
{
else
serno = InquireServer(strSrvName, year, true);
}
return serno;
}