Patch level :10.0 setup
Files correlati : Ricompilazione Demo : [ ] Commento :modifiche per l'aggiornamento via web git-svn-id: svn://10.65.10.50/trunk@15771 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
c973625d01
commit
fda95cd14e
165
setup/Setup.cpp
165
setup/Setup.cpp
@ -7,6 +7,7 @@
|
||||
#include <shlobj.h>
|
||||
#endif
|
||||
|
||||
#include <wx/protocol/http.h>
|
||||
#include <wx/snglinst.h>
|
||||
|
||||
#include "key.h"
|
||||
@ -94,6 +95,8 @@ private:
|
||||
protected:
|
||||
DECLARE_EVENT_TABLE()
|
||||
void OnTimer(wxTimerEvent& e);
|
||||
void DiskUpdate();
|
||||
void InternetUpdate();
|
||||
void ClientUpdate();
|
||||
void NormalSetup();
|
||||
bool CampoRunning(const wxString& strAppName, const wxString& strMsg) const;
|
||||
@ -108,12 +111,16 @@ protected:
|
||||
bool WriteLocalMachineRegistryKey(const wxString strKey, const wxString& strValue) const;
|
||||
|
||||
const wxString GetSourceDir(const wxString strDirName) const;
|
||||
void UnzipSystem(const wxString& strPrgLocPath) const;
|
||||
void EmptyOutDir(const wxString& strDir) const;
|
||||
bool UnzipModule(const wxString& strPrgLocPath, const wxString& strSrc, const wxString& strModule) const;
|
||||
bool CopyFilesAndDirs(const wxString& FilesListI, wxString strFileCurr, const bool bIni) const;
|
||||
|
||||
void UpdateSyInstallIni(const wxString strSourcePath, const wxString strDestPath) const;
|
||||
|
||||
int UpdateModule(const wxString& strLocalPath, const wxString& strRemotePath, const wxString strModule) const;
|
||||
|
||||
bool HTTPGet(const wxString& strLocalPath, const wxString& strWebPath) const;
|
||||
bool InternetUpdateModule(const wxString& strLocalPath, const wxString& strWebPath, const wxString strModule) const;
|
||||
|
||||
public:
|
||||
virtual bool OnInit();
|
||||
};
|
||||
@ -359,12 +366,12 @@ void CampoSetup::UpdateSyInstallIni(const wxString strSourcePath, const wxString
|
||||
}
|
||||
}
|
||||
|
||||
void CampoSetup::UnzipSystem(const wxString& strPrgLocPath) const
|
||||
bool CampoSetup::UnzipModule(const wxString& strPrgLocPath, const wxString& strSrc, const wxString& strModule) const
|
||||
{
|
||||
bool ok = false;
|
||||
wxArrayString asFilesList;
|
||||
const wxString strSrc = GetSourceDir("program");
|
||||
//..contando anche quanti sono e memorizzandoli in un array asFileList
|
||||
const size_t uFilesToCopy = wxDir::GetAllFiles(strSrc, &asFilesList, "sy*.zip");
|
||||
const size_t uFilesToCopy = wxDir::GetAllFiles(strSrc, &asFilesList, strModule+"*.zip");
|
||||
if (uFilesToCopy > 0)
|
||||
{
|
||||
//ordina le patch per numero crescente ma mette davanti a tutte il pacco (sysinst1)
|
||||
@ -388,6 +395,7 @@ void CampoSetup::UnzipSystem(const wxString& strPrgLocPath) const
|
||||
//potrebbe sembrare assurdo un for, ma e' per futuri sottomoduli con numero > 1
|
||||
UpdateSyInstallIni(strWrk, strPrgLocPath + "/install.ini");
|
||||
}
|
||||
return uFilesToCopy > 0;
|
||||
}
|
||||
|
||||
bool CampoSetup::CopyFilesAndDirs(const wxString& FilesListI, wxString strFileCurr, const bool bIni) const
|
||||
@ -540,10 +548,128 @@ int CampoSetup::UpdateModule(const wxString& strLocalPath, const wxString& strRe
|
||||
return cmp;
|
||||
}
|
||||
|
||||
bool CampoSetup::HTTPGet(const wxString& strLocalPath, const wxString& strWebPath) const
|
||||
{
|
||||
wxString strServer, strPath;
|
||||
int nSlash = strWebPath.First('/');
|
||||
strServer = strWebPath.Left(nSlash);
|
||||
strPath = strWebPath.Mid(nSlash);
|
||||
|
||||
//---------------------------------------------
|
||||
//metodo per l'aggiornamento dei client di rete
|
||||
//---------------------------------------------
|
||||
wxHTTP http;
|
||||
//connessione al server web con le patch
|
||||
if (http.Connect(strServer))
|
||||
{
|
||||
wxInputStream* pStream = http.GetInputStream(strPath);
|
||||
if (pStream != NULL)
|
||||
{
|
||||
//compila un file di testo temporaneo con l'elenco dei files che trova sul server
|
||||
wxFileOutputStream fos(strLocalPath);
|
||||
fos.Write(*pStream);
|
||||
delete pStream;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//metodo per accoppare tutti i files di una directory
|
||||
void CampoSetup::EmptyOutDir(const wxString& strDir) const
|
||||
{
|
||||
wxArrayString asFilesList;
|
||||
const size_t uFilesToKill = wxDir::GetAllFiles(strDir, &asFilesList, "*.*");
|
||||
if (uFilesToKill > 0)
|
||||
{
|
||||
for (size_t i = 0; i < uFilesToKill; i++)
|
||||
{
|
||||
::wxRemoveFile(asFilesList[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CampoSetup::InternetUpdateModule(const wxString& strLocalPath, const wxString& strWebPath, const wxString strModule) const
|
||||
{
|
||||
bool ok = false;
|
||||
int nLocVer, nLocPatch;
|
||||
{
|
||||
CampoIniFile iniLocalInstall(strLocalPath + "/install.ini", strModule);
|
||||
nLocVer = iniLocalInstall.GetInt("Versione");
|
||||
nLocPatch = iniLocalInstall.GetInt("Patch");
|
||||
}
|
||||
|
||||
const wxString strTempDir = wxFileName::GetTempDir() + "/setup/";
|
||||
EmptyOutDir(strTempDir); //deve svuotare la directory dai files per poterla eliminare
|
||||
if (::wxRmdir(strTempDir))
|
||||
//::wxMkdir(strTempDir);
|
||||
CheckAndMakeDir(strTempDir, "setup");
|
||||
|
||||
const wxString strTempFile = strTempDir + "httpdir.txt";
|
||||
if (HTTPGet(strTempFile, strWebPath))
|
||||
{
|
||||
//partendo dal file temporaneo ne compila un secondo con i soli nomi dei file validi da scaricare
|
||||
//i criteri di selezione sono il nome del modulo ed il livello patch
|
||||
wxTextFile tfFilesList;
|
||||
if (tfFilesList.Open((strTempFile)))
|
||||
{
|
||||
wxProgressDialog pi("Aggiornamento elenco files dal server...", "", (int)tfFilesList.GetLineCount(),
|
||||
NULL, wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_CAN_ABORT);
|
||||
|
||||
for (wxString strWrk = tfFilesList.GetFirstLine(); !tfFilesList.Eof(); strWrk = tfFilesList.GetNextLine())
|
||||
{
|
||||
int nPos = strWrk.Find("href");
|
||||
if (nPos > 0)
|
||||
{
|
||||
wxString strHref = strWrk.Mid(nPos + 5, 16);
|
||||
strHref = strHref.AfterFirst('"');
|
||||
strHref = strHref.BeforeLast('"');
|
||||
if ( strHref.StartsWith(strModule) && atoi(strHref.Mid(2)) > nLocPatch )
|
||||
{
|
||||
if (!pi.Update((int)tfFilesList.GetCurrentLine(), strHref))
|
||||
break;
|
||||
HTTPGet(strTempDir+strHref, strWebPath+strHref);
|
||||
}
|
||||
}
|
||||
}
|
||||
//chiude il file temporaneo
|
||||
tfFilesList.Close();
|
||||
} //if(tfFilesList...
|
||||
|
||||
//scompatta le patch di sistema e aggiorna l'install.ini locale
|
||||
ok = UnzipModule(strLocalPath, strTempDir, strModule);
|
||||
} //if(HTTPGet(...
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
//metodo per l'aggiornamento via internet attraverso Manutenzione/Installazione moduli
|
||||
//------------------------------------------------------------------------------------
|
||||
void CampoSetup::InternetUpdate()
|
||||
{
|
||||
//install.ini locale dove setup.exe e' in esecuzione
|
||||
wxFileName fn(m_strSetupPath, "install.ini");
|
||||
fn.AppendDir("..");
|
||||
fn.MakeAbsolute();
|
||||
const wxString strLocalPath = fn.GetPath();
|
||||
|
||||
//quale e' il path web da cui aggiornarmi?
|
||||
wxString strRemotePath;
|
||||
{
|
||||
//Install.ini locale da cui leggere il path di dove sta il mio server web
|
||||
CampoIniFile iniLocalInstall(fn.GetFullPath(), "Main");
|
||||
strRemotePath = iniLocalInstall.Get("WebPath");
|
||||
}
|
||||
|
||||
//aggiornamento del modulo SY via web
|
||||
InternetUpdateModule(strLocalPath, strRemotePath, "sy");
|
||||
|
||||
//lanciare ba1.exe -6 in uscita
|
||||
wxSetWorkingDirectory(strLocalPath);
|
||||
wxExecute("ba1 -6 /uADMIN");
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------
|
||||
//metodo per l'aggiornamento dei client di rete in automatico
|
||||
//-----------------------------------------------------------
|
||||
void CampoSetup::ClientUpdate()
|
||||
{
|
||||
wxFileName fn(m_strSetupPath, "install.ini");
|
||||
@ -552,17 +678,22 @@ void CampoSetup::ClientUpdate()
|
||||
const wxString strLocalPath = fn.GetPath();
|
||||
wxString strRemotePath;
|
||||
{
|
||||
//Install.ini locale da cui leggere il path di dove sta il mio server dei programmi
|
||||
CampoIniFile iniLocalInstall(fn.GetFullPath(), "Main");
|
||||
strRemotePath = iniLocalInstall.Get("DiskPath");
|
||||
}
|
||||
UpdateModule(strLocalPath, strRemotePath, "sy");
|
||||
|
||||
//lanciare ba1.exe -6 in uscita
|
||||
wxSetWorkingDirectory(strLocalPath);
|
||||
wxExecute("ba1 -6 /uADMIN");
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
//metodo per l'aggiornamento da CD attraverso il menu di Manutenzione/Installazione moduli
|
||||
//----------------------------------------------------------------------------------------
|
||||
void CampoSetup::DiskUpdate()
|
||||
{
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
//metodo per tutte le installazioni e gli aggiornamenti in locale
|
||||
//---------------------------------------------------------------
|
||||
@ -832,7 +963,8 @@ void CampoSetup::NormalSetup()
|
||||
//----------------------------------------------------------------------------------------------------------
|
||||
//procede poi al caricamento delle patch eventuali di sistema all'interno della dir 'program' e al..
|
||||
//..conseguente riaggiornamento del livello versione/patch del SY in install.ini
|
||||
UnzipSystem(strPrgLocPath);
|
||||
const wxString strPrgCDPath = GetSourceDir("program");
|
||||
UnzipModule(strPrgLocPath, strPrgCDPath, "sy");
|
||||
|
||||
|
||||
// 8) CREAZIONE DELL'ICONA SUL DESKTOP
|
||||
@ -954,8 +1086,15 @@ void CampoSetup::OnTimer(wxTimerEvent& WXUNUSED(e))
|
||||
if (strCommand.IsEmpty())
|
||||
NormalSetup();
|
||||
else
|
||||
ClientUpdate();
|
||||
|
||||
{
|
||||
wxSleep(2);
|
||||
if (strCommand == "-ud")
|
||||
DiskUpdate();
|
||||
if (strCommand == "-uc")
|
||||
ClientUpdate();
|
||||
if (strCommand == "-uw")
|
||||
InternetUpdate();
|
||||
}
|
||||
//finestrina x chiudere a mano il programma (sconsigliata causa lancio ba1.exe)
|
||||
// ::wxMessageBox(wxT("Installazione terminata"), APPNAME, wxOK | wxICON_INFORMATION);
|
||||
m_pMainFrame->Destroy();
|
||||
|
@ -209,6 +209,24 @@ static unsigned short InquireSocketNumber(wxSocketClient& sc, const wxString& st
|
||||
return (unsigned short)number[1];
|
||||
}
|
||||
|
||||
//metodo per sapere dal server di chiave quanti sono gli utonti connessi;non funziona finchè ai servers non..
|
||||
//..viene aggiunto il metodo NumberActiveUsers (è qui come segnaposto futuro)
|
||||
unsigned short InquireActiveUsers(const wxString& strSrvName)
|
||||
{
|
||||
unsigned short nUtonti = 0;
|
||||
wxIPV4address ip;
|
||||
if (ip.Hostname(strSrvName) && ip.Service("1883")) //riesce a connettersi
|
||||
{
|
||||
wxSocketClient& sc = m_bordello.Zoccola(ip);
|
||||
if (sc.IsConnected() || sc.Connect(ip)) //il computer remoto risponde
|
||||
{
|
||||
// quanti utonti sono appesi?
|
||||
nUtonti = InquireSocketNumber(sc, "NumberActiveUsers()");
|
||||
}
|
||||
}
|
||||
return nUtonti;
|
||||
}
|
||||
|
||||
static unsigned short InquireServer(const wxString& strSrvName, int& year, const bool bMsg)
|
||||
{
|
||||
unsigned short serno = 0xFFFF;
|
||||
|
@ -324,6 +324,10 @@ bool UnzipFile(const char* strZipFile, const char* strDestDir)
|
||||
|
||||
wxFileOutputStream fout(strOutFile);
|
||||
fout.Write(fin);
|
||||
fout.Close();
|
||||
|
||||
if (strOutFile.EndsWith("res.zip"))
|
||||
UnzipFile(strOutFile , strPath);
|
||||
}
|
||||
}
|
||||
return files > 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user