Patch level :

Files correlati     :
Ricompilazione Demo : [ ]
Commento            :


git-svn-id: svn://10.65.10.50/trunk@15865 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
luca 2007-12-13 14:49:46 +00:00
parent 5b2e68378b
commit 8257473361
4 changed files with 222 additions and 100 deletions

View File

@ -118,6 +118,7 @@ protected:
const wxString GetSourceDir(const wxString strDirName) const;
void EmptyOutDir(const wxString& strDir) const;
bool UnzipModule(const wxString& strPrgLocPath, const wxString& strSrc, const wxString& strModule) const;
void CopyDir(const wxString& strSourceDir, const wxString& strDestDir) const;
bool CopyFilesAndDirs(const wxString& FilesListI, wxString strFileCurr, const bool bIni) const;
void UpdateInstallIni(const wxString strSourcePath, const wxString strDestPath, const wxString& strModule) const;
bool HTTPGet(const wxString& strLocalPath, const wxString& strWebPath) const;
@ -450,6 +451,21 @@ bool CampoSetup::CopyFilesAndDirs(const wxString& FilesListI, wxString strFileCu
return ok;
}
//metodo per copiare una directory e tutti i files che contiene
void CampoSetup::CopyDir(const wxString& strSourceDir, const wxString& strDestDir) const
{
if (!wxDir::Exists(strDestDir))
wxMkdir(strDestDir);
wxArrayString asFilesList;
const size_t uFilesToCopy = wxDir::GetAllFiles(strSourceDir, &asFilesList, "*.*", wxDIR_FILES);
const size_t uFrom = strSourceDir.Len();
for (size_t i = 0; i < uFilesToCopy; i++)
{
wxString strFileDest = strDestDir + asFilesList[i].Mid(uFrom);
::wxCopyFile(asFilesList[i], strFileDest);
}
}
//metodo per accoppare tutti i files di una directory
void CampoSetup::EmptyOutDir(const wxString& strDir) const
{
@ -836,6 +852,8 @@ void CampoSetup::NormalSetup()
wxArrayString asFilesList;
wxFileName strSourcePath(m_strSetupPath, "*.*");
strSourcePath.AppendDir("..");
strSourcePath.AppendDir("..");
strSourcePath.AppendDir("campo");
strSourcePath.MakeAbsolute();
//stringa inutile al programma ma decisiva per il programmatore
const wxString strSrc = strSourcePath.GetPath();
@ -1012,7 +1030,12 @@ void CampoSetup::NormalSetup()
//..conseguente riaggiornamento del livello versione/patch del SY in install.ini
const wxString strPrgCDPath = GetSourceDir("program");
if (wxFileName::DirExists(strPrgCDPath))
{
const wxString strSetupCDPath = strPrgCDPath + "/setup";
const wxString strSetupLocPath = strPrgLocPath + "/setup";
CopyDir(strSetupCDPath, strSetupLocPath);
UnzipModule(strPrgLocPath, strPrgCDPath, "sy");
}
// 8) CREAZIONE DELL'ICONA SUL DESKTOP
@ -1104,9 +1127,12 @@ void CampoSetup::OnTimer(wxTimerEvent& WXUNUSED(e))
return;
}
wxFileName strPath(argv[0]);
/*
//panegirico all'apparenza inutile ma in realta' decisivo per reperire i veri path assoluti dove funzionano...
//..setup, ba0, ba1. NON cancellare!!!
wxString strIni = "install.ini";
wxString strIni = "../install.ini";
wxFileName strPath;
if (wxFileName::FileExists(strIni))
{
@ -1123,7 +1149,7 @@ void CampoSetup::OnTimer(wxTimerEvent& WXUNUSED(e))
return;
}
}
*/
strPath.MakeAbsolute();
strPath.SetCwd();
//path del programma setup.exe in esecuzione; serve in seguito in quanto alcuni metodi (tipo la GetAllFiles)..

View File

@ -48,6 +48,128 @@ wxString GetDefaultDestination()
return strDest;
}
//metodo per avere la lista delle condivisioni remote connesse al computer (preso da MSDN)
size_t ListNetworkDisks(wxArrayString& asList)
{
DWORD dwResult, dwResultEnum;
HANDLE hEnum;
DWORD cbBuffer = 16384; // 16K is a good size
DWORD cEntries = -1; // enumerate all possible entries
LPNETRESOURCE lpnrLocal; // pointer to enumerated structures
DWORD i;
//
// Call the WNetOpenEnum function to begin the enumeration.
//
dwResult = WNetOpenEnum(RESOURCE_CONNECTED, // connected resources
RESOURCETYPE_DISK, // only disks
0, // enumerate all resources
NULL, // NULL first time the function is called
&hEnum); // handle to the resource
if (dwResult != NO_ERROR)
{
//
// Process errors with an application-defined error handler.
//
//NetErrorHandler(hwnd, dwResult, (LPSTR)"WNetOpenEnum");
//return false;
return 0;
}
//
// Call the GlobalAlloc function to allocate resources.
//
lpnrLocal = (LPNETRESOURCE) GlobalAlloc(GPTR, cbBuffer);
if (lpnrLocal == NULL)
return 0;
do
{
//
// Initialize the buffer.
//
ZeroMemory(lpnrLocal, cbBuffer);
//
// Call the WNetEnumResource function to continue
// the enumeration.
//
dwResultEnum = WNetEnumResource(hEnum, // resource handle
&cEntries, // defined locally as -1
lpnrLocal, // LPNETRESOURCE
&cbBuffer); // buffer size
//
// If the call succeeds, loop through the structures.
//
if (dwResultEnum == NO_ERROR)
{
for(i = 0; i < cEntries; i++)
{
asList.Add(lpnrLocal[i].lpLocalName);
}
}
// Process errors.
//
else if (dwResultEnum != ERROR_NO_MORE_ITEMS)
{
//NetErrorHandler(hwnd, dwResultEnum, (LPSTR)"WNetEnumResource");
break;
}
}
//
// End do.
//
while(dwResultEnum != ERROR_NO_MORE_ITEMS);
//
// Call the GlobalFree function to free the memory.
//
GlobalFree((HGLOBAL)lpnrLocal);
//
// Call WNetCloseEnum to end the enumeration.
//
dwResult = WNetCloseEnum(hEnum);
if(dwResult != NO_ERROR)
{
//
// Process errors.
//
//NetErrorHandler(hwnd, dwResult, (LPSTR)"WNetCloseEnum");
return 0;
}
return asList.GetCount();
}
//metodo per avere un array con la lista dei path delle condivisioni locali
size_t ListSharedDirectories(wxArrayString& asList)
{
#ifdef WIN32
NET_API_STATUS res = ERROR_MORE_DATA;
while (res == ERROR_MORE_DATA)
{
PSHARE_INFO_502 shi;
DWORD nEntriesRead = 0, nTotalEntries = 0, nResume = 0;
res = NetShareEnum(NULL, 502, (LPBYTE *)&shi, -1, &nEntriesRead, &nTotalEntries, &nResume);
if (res == ERROR_SUCCESS || res == ERROR_MORE_DATA)
{
for (DWORD i = 0; i < nEntriesRead; i++)
{
wxString strPath(shi[i].shi502_path);
if (!strPath.IsEmpty())
{
strPath.MakeLower();
asList.Add(strPath);
}
} //for(DWORD i...
NetApiBufferFree(shi);
} //if(res ==...
} //while (res==ERROR_MORE_DATA...
#endif
return asList.GetCount();
}
//Magico metodo per stabilire se una directory e' condivisa ed e' su un disco locale!!
bool IsSharedDirectory (const wxString& strDir)
{
@ -56,35 +178,19 @@ bool IsSharedDirectory (const wxString& strDir)
wxString strDataDir = strDir.Lower();
strDataDir.Replace ("/", "\\");
NET_API_STATUS res = ERROR_MORE_DATA;
while (res==ERROR_MORE_DATA && !found)
wxArrayString asList;
ListSharedDirectories(asList);
for (size_t i = 0; i < asList.GetCount(); i++)
{
PSHARE_INFO_502 shi;
DWORD nEntriesRead =0, nTotalEntries = 0, nResume = 0;
res = NetShareEnum(NULL, 502, (LPBYTE *)&shi, -1, &nEntriesRead, &nTotalEntries, &nResume);
if (res == ERROR_SUCCESS || res == ERROR_MORE_DATA)
const wxString& strPath = asList[i];
//se trova la directory di studio condivisa ed e' su disco locale -> server
if (strPath.Len() > 3 && strDir.StartsWith(strPath))
{
for (DWORD i = 0; i < nEntriesRead; i++)
{
/*Oh ignaro programmatore, questa parte commentata utilizza funzioni native di windows che non si sono riuscite..
..a far funzionare! Se osi, prova la tua forza rendendole utili!
//la directory dei dati deve essere leggibile,scrivibile,e filecreabile
int Result = NetShareGetInfo(NULL, shi[i].shi502_netname, 502, (LPBYTE *)&shi[i]);
if (shi[i].shi502_permissions & (PERM_FILE_READ | PERM_FILE_WRITE | PERM_FILE_CREATE))*/
{
wxString strPath(shi[i].shi502_path);
strPath.MakeLower();
//se trova la directory di studio condivisa ed e' su disco locale -> server
if (strDir.StartsWith(strPath))
{
found = true;
break;
}
}
} //for(DWORD i...
NetApiBufferFree(shi);
} //if(res ==...
} //while (res==ERROR_MORE_DATA...
found = true;
break;
}
} //for(DWORD i...
return found;
}

View File

@ -44,20 +44,28 @@ public:
};
*/
//progind
class CampoProgressDialog : public wxProgressDialog
{
public:
CampoProgressDialog(const wxString& strTitle, int nMaximum = 100, wxWindow* pParent = NULL);
};
//metodi generici
//finestre messaggio,errore,ecc...
bool ErrorBox(const wxString str);
bool WarningBox(const wxString str);
//trattamento files
void CheckAndMakeDir(const wxString& strDir, const wxString& strMsg);
bool UnzipFile(const char* strZipFile, const char* strDestdir);
//interfaccia con windows
wxString GetWindowsProgramDirectory();
int GetSessionId();
size_t ListNetworkDisks(wxArrayString& asList);
size_t ListSharedDirectories(wxArrayString& asList);
bool IsSharedDirectory (const wxString& strDir);
#endif

View File

@ -537,17 +537,17 @@ bool CampoWizardPage4::TransferDataToWindow()
{
case 1:
strBody += wxT("<p>E' stata rilevata una chiave tipo <b>Hardlock</b>:</p>");
strBody += wxT("<p align=center><img src=\"../servers/hardlock.gif\" /></p>");
strBody += wxT("<p align=center><img src=\"../../campo/servers/hardlock.gif\" /></p>");
strBody += wxT("<p>Si puo' procedere con l'installazione /aggiornamento del software <b><i>APPNAME</i></b>. Premere il pulsante \"Avanti\".</p>");
break;
case 2:
strBody += wxT("<p>E' stata rilevata una chiave tipo <b>Eutron</b>:</p>");
strBody += wxT("<p align=center><img src=\"../servers/eutron.gif\" /></p>");
strBody += wxT("<p align=center><img src=\"../../campo/servers/eutron.gif\" /></p>");
strBody += wxT("<p>Si puo' procedere con l'installazione /aggiornamento del software <b><i>APPNAME</i></b>. Premere il pulsante \"Avanti\".</p>");
break;
case 3:
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=\"../servers/autho.gif\" /></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>APPNAME</i></b>. Premere il pulsante \"Avanti\".</p>");
Set(404, GetWizard().GetSrvAuth());
break;
@ -592,7 +592,7 @@ wxString CampoWizardPage4::DecodeString(const wxString& data)
int CampoWizardPage4::VersionYear()
{
char ver[32];
GetPrivateProfileString("ba", "Versione", "", ver, sizeof(ver), "../../program/install.ini");
GetPrivateProfileString("ba", "Versione", "", ver, sizeof(ver), "../install.ini");
ver[4] = '\0';
return atoi(ver);
}
@ -624,57 +624,7 @@ int CampoWizardPage4::DongleTest()
else
dongle_type = 1; //chiave hardlock
}
if (serno == 0) // Chiave di sviluppo
return dongle_type;
if (serno == 0xFFFF) // Chiave inesistente o invisibile = Prima installazione o demo
return dongle_type;
const int verYear = VersionYear();
if (yearKey < verYear) // Chiave già programmata con assistenza pagata
{
bool ok = false;
wxFileInputStream file("../dninst.zip");
if (file.IsOk())
{
wxTextInputStream keys(file);
wxString line = keys.ReadLine();
srand(883);
const int ass_year = atoi(DecodeString(line));
if (ass_year > yearKey) // Non devo abbassare l'anno di assistenza!
{
srand(ass_year);
while (!file.Eof())
{
line = keys.ReadLine();
line = DecodeString(line);
unsigned int sn = (unsigned int)atol(line);
if (sn == serno || line[0] == '*')
{
ok = true;
break;
}
}
if (ok)
{
const int n = ass_year%10;
const int y = (ass_year / 1000) * 1000 + (ass_year%1000) /10;
line.Printf("Il contratto di manutenzione %d/%d verrà attivato automaticamente\ndurante l'installazione del software", y, n);
WarningBox(line);
}
else
{
line.Printf("È necessario contattare l'assistenza tecnica\n"
"per l'abilitazione del contratto di manutenzione %d", verYear);
WarningBox(line);
}
}
}
else
{
ErrorBox("Impossibile verificare il contratto di manutenzione");
}
}
return dongle_type;
}
@ -691,7 +641,7 @@ CampoWizardPage4::CampoWizardPage4(wxWizard* parent) : CampoWizardPage(parent)
//Hardlock label
AddLabel(gbsButtSizer, "Installa chiave locale di tipo Hardlock", 0, 0);
//Hardlock image
wxBitmap bmp_HL("../servers/hardlock.gif", wxBITMAP_TYPE_GIF);
wxBitmap bmp_HL("../../campo/servers/hardlock.gif", wxBITMAP_TYPE_GIF);
wxStaticBitmap* s_bmp_HL = new wxStaticBitmap(this, wxID_ANY, bmp_HL);
gbsButtSizer->Add(s_bmp_HL, wxGBPosition(0, 1));
//bottone Hardlock
@ -702,7 +652,7 @@ CampoWizardPage4::CampoWizardPage4(wxWizard* parent) : CampoWizardPage(parent)
//Eutron label
AddLabel(gbsButtSizer, "Installa chiave locale di tipo Eutron", 1, 0);
//Eutron image
wxBitmap bmp_EU("../servers/eutron.gif", wxBITMAP_TYPE_GIF);
wxBitmap bmp_EU("../../campo/servers/eutron.gif", wxBITMAP_TYPE_GIF);
wxStaticBitmap* s_bmp_EU = new wxStaticBitmap(this, wxID_ANY, bmp_EU);
gbsButtSizer->Add(s_bmp_EU, wxGBPosition(1, 1));
//bottone Eutron
@ -738,15 +688,16 @@ public:
bool CampoWizardPage5::ForwardValidate()
{
// controlla il tipo di installazione!
InstallationType nType = it_standalone;
const int nSessionId = GetSessionId();
int nType = 1;
//nessun SessionId -> installazione comune -> selection dal radiobutton
if (nSessionId == 0)
nType = m_pRadioBox->GetSelection() + 1;
nType = InstallationType(m_pRadioBox->GetSelection() + 1);
else //SessionId != 0 -> Terminal Server -> installazione di tipo Server obbligata!!!
nType = 2;
nType = it_server;
GetWizard().SetInstallationType((InstallationType)nType);
GetWizard().SetInstallationType(nType);
return true;
}
@ -1162,6 +1113,38 @@ void CampoWizardPage8::OnSrvClick(wxCommandEvent& e)
bool CampoWizardPage8::TransferDataToWindow()
{
bool bNoPrg = Get(803).IsEmpty();
bool bNoData = Get(805).IsEmpty();
if (bNoPrg || bNoData)
{
//cerca le unita' condivise in rete
wxArrayString asList;
const size_t nShared = ListNetworkDisks(asList);
//se ne trova controlla se sono valide come directory di programmi e dati
for (size_t i = 0; i < nShared; i++)
{
wxString strWrk = asList[i];
if (!wxEndsWithPathSeparator(strWrk))
strWrk << wxFILE_SEP_PATH;
UINT nDriveType = GetDriveType(strWrk);
if (nDriveType == DRIVE_REMOTE)
{
if (bNoPrg && CheckPrgDir(strWrk))
{
bNoPrg = false;
Set(803, strWrk);
}
if (bNoData && CheckDataDir(strWrk))
{
bNoData = false;
Set(805, strWrk);
}
}
} //for(size_t...
} //if(noPrg...
return true;
}
@ -1221,10 +1204,12 @@ CampoWizardPage8::CampoWizardPage8(wxWizard* parent) : CampoWizardPage(parent)
wxString strTitle = wxT("Installazione di tipo Client");
wxString strBody = wxT("<p>Digitare nel campo <b>'Cartella locale programma'</b> il percorso completo della cartella dove si desidera installare il programma. ");
strBody += wxT("Il percorso consigliato e' <i>C:\\APPNAME</i> </p>");
strBody += wxT("<p>Digitare nel campo <b>'Cartella remota origine programmi'</b> il percorso completo della cartella di rete dove sono i files origine del programma. ");
strBody += wxT("E' la cartella di programmi condivisa dal server precedentemente installato.</p>");
strBody += wxT("<p>Digitare nel campo <b>'Cartella remota dati da utilizzare'</b> il percorso completo della cartella di rete dove sono i dati. ");
strBody += wxT("E' la cartella dei dati condivisa dal server precedentemente installato.</p>");
strBody += wxT("<p>Il campo <b>'Cartella remota origine programmi'</b> contiene il percorso completo della cartella di rete dove sono i files origine del programma. ");
strBody += wxT("E' la cartella di programmi condivisa dal server precedentemente installato. Se condivisa e connessa correttamente viene rilevata automaticamente e proposta dal programma. ");
strBody += wxT("Se non viene proposta automaticamente, digitare il percorso completo (es. <i><b>Z:\\APPNAME</b></i>)</p>");
strBody += wxT("<p>Il campo <b>'Cartella remota dati da utilizzare'</b> contiene il percorso completo della cartella di rete dove sono i dati. ");
strBody += wxT("E' la cartella dei dati condivisa dal server precedentemente installato. Se condivisa e connessa correttamente viene rilevata automaticamente e proposta dal programma. ");
strBody += wxT("Se non viene proposta automaticamente, digitare il percorso completo (es. <i><b>Z:\\APPNAME\\Dati</b></i>)</p>");
strBody += wxT("<p><b>Gestore dizionari:</b> e' il computer gestore dei dizionari di APPNAME in lingue diverse dall'italiano. Generalmente e' il computer agente da server di APPNAME in rete. ");
strBody += wxT("Premere il bottone <u>Cerca</u> per attivare la ricerca automatica di tale computer. Qualora tale ricerca fallisse digitare il nome del computer gestore dei dizionari</p>");
@ -1251,9 +1236,7 @@ CampoWizardPage8::CampoWizardPage8(wxWizard* parent) : CampoWizardPage(parent)
//prompt
AddLabel(gbsSizer, "Cartella remota origine programmi", 1, 0);
//campo testo
strPath = "Z:\\";
strPath += APPNAME;
wxTextCtrl* tcSrcPrgPath = new wxTextCtrl(this, 803, strPath, wxDefaultPosition, wxSize(256,-1));
wxTextCtrl* tcSrcPrgPath = new wxTextCtrl(this, 803, "", wxDefaultPosition, wxSize(256,-1));
gbsSizer->Add(tcSrcPrgPath, wxGBPosition(1, 1));
//bottone 'sfoglia'
wxButton* bSrcPrgButton = new wxButton(this, 804, wxT("Sfoglia"), wxDefaultPosition, wxSize(48, -1));
@ -1263,8 +1246,7 @@ CampoWizardPage8::CampoWizardPage8(wxWizard* parent) : CampoWizardPage(parent)
//prompt
AddLabel(gbsSizer, "Cartella remota dati da utilizzare", 2, 0);
//campo testo
strPath += "/dati";
wxTextCtrl* tcDataPath = new wxTextCtrl(this, 805, strPath, wxDefaultPosition, wxSize(256,-1));
wxTextCtrl* tcDataPath = new wxTextCtrl(this, 805, "", wxDefaultPosition, wxSize(256,-1));
gbsSizer->Add(tcDataPath, wxGBPosition(2, 1));
//bottone 'sfoglia'
wxButton* bDataButton = new wxButton(this, 806, wxT("Sfoglia"), wxDefaultPosition, wxSize(48, -1));