Patch level :

Files correlati     :
Ricompilazione Demo : [ ]
Commento            :


git-svn-id: svn://10.65.10.50/trunk@15732 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
luca 2007-10-25 15:48:37 +00:00
parent 9f480c4a3f
commit 851dbcdcd5
4 changed files with 195 additions and 67 deletions

View File

@ -110,6 +110,7 @@ protected:
const wxString GetSourceDir(const wxString strDirName) const;
void UnzipSystem(const wxString& strPrgLocPath) 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;
@ -338,6 +339,26 @@ const wxString CampoSetup::GetSourceDir(const wxString strDirName) const
return strSrc;
}
//metodo per aggiornare il modulo SY in install.ini
void CampoSetup::UpdateSyInstallIni(const wxString strSourcePath, const wxString strDestPath) const
{
for (int j = 0; j < 2; j++)
{
wxString strParagraph = "sy";
if (j > 0)
strParagraph << j;
CampoIniFile InstallIniSource(strSourcePath, strParagraph);
CampoIniFile InstallIniDest(strDestPath, strParagraph);
wxString strWrk;
long nIndex;
for (bool ok = InstallIniSource.GetFirstEntry(strWrk, nIndex); ok; ok = InstallIniSource.GetNextEntry(strWrk, nIndex))
{
InstallIniDest.Set(strWrk, InstallIniSource.Get(strWrk));
}
}
}
void CampoSetup::UnzipSystem(const wxString& strPrgLocPath) const
{
wxArrayString asFilesList;
@ -365,19 +386,7 @@ void CampoSetup::UnzipSystem(const wxString& strPrgLocPath) const
//adesso che ha trovato quello sporco ultimo .ini prende versione e patch e le copia nell'install.ini..
//..nella dir dei programmi; lo fa paragrafo x paragrafo ([sy],[sy1]..)
//potrebbe sembrare assurdo un for, ma e' per futuri sottomoduli con numero > 1
for (int j = 0; j < 2; j++)
{
wxString strParagraph = "sy";
if (j > 0)
strParagraph << j;
CampoIniFile SyLastPatch(strWrk, strParagraph);
const wxString strVersion = SyLastPatch.Get("Versione");
const wxString strPatch = SyLastPatch.Get("Patch");
CampoIniFile InstallIni(strPrgLocPath + "/install.ini", strParagraph);
InstallIni.Set("Versione", strVersion);
InstallIni.Set("Patch", strPatch);
}
UpdateSyInstallIni(strWrk, strPrgLocPath + "/install.ini");
}
}
@ -463,12 +472,17 @@ int CampoSetup::UpdateModule(const wxString& strLocalPath, const wxString& strRe
{
const wxString& strParagraph = asGroups[i];
CampoIniFile iniRemoteInstallModule(strRemotePath + "/install.ini", strParagraph);
//install.ini locale che deve essere aggiornato durante la copia dei files!
CampoIniFile iniLocalInstall(strLocalPath + "/install.ini", strParagraph);
//ogni file dell'elenco del sottomodulo corrente va copiato
for (int j = 0;; j++)
{
pi.Pulse(); //magica barra modello supercar!
wxString strCurrFile = iniRemoteInstallModule.Get(wxString::Format("File(%d)", j));
const wxString strVarName = wxString::Format("File(%d)", j);
wxString strCurrFile = iniRemoteInstallModule.Get(strVarName);
if (strCurrFile.IsEmpty())
break;
@ -501,11 +515,15 @@ int CampoSetup::UpdateModule(const wxString& strLocalPath, const wxString& strRe
{
UnzipFile(strDstPath, strLocalPath + "/res");
}
//se riesce la copia del file aggiorna l'install.ini sul file (se non lo facesse non comparirebbero...
//...eventuali nuovi files
iniLocalInstall.Set(strVarName, strCurrFile);
} //for(int j...
//una volta termiata la copia dei files del sottmodulo[i] scatta l'aggiornamento dell'install.ini locale...
//...al livello versione/patch appena copiate sempre del sottomodulo[i]
CampoIniFile iniLocalInstall(strLocalPath + "/install.ini", strParagraph);
iniLocalInstall.Set("Versione", nRemVer);
iniLocalInstall.Set("Patch", nRemPatch);
@ -655,23 +673,31 @@ void CampoSetup::NormalSetup()
//per ogni file da copiare controlla i path sorgente e destinazione(problema con sottodirectory tipo..
//..dati); strFileCurr va lasciato qui perche' DEVE ESSERE AZZERATO ad ogni cambio file!!!!!!
wxString strFileCurr;
//files dei dati standard! solo in caso di nuova installazione!!
if (asFilesList[i].Lower().Find("\\dati\\") > 0)
//controlla se il file corrente e' dentro una sottodirectory (tipo dati,servers,setup...) oppure e' al..
//..primo livello (quindi e' un file di programma)
wxString strSourceFile = asFilesList[i].Lower();
strSourceFile.Replace("\\", "/");
//e' in una subdir se la lunghezza del suo path prima dell'ultimo '/' e' > della lunghezza del path di root
const bool bIsSubDir = strSourceFile.Find('/', true) > (int)nPathLenght;
//2A) files con subdirectory
if (bIsSubDir)
{
//i DATI NON VANNO MAI installati in caso di aggiornamento!!!
//e nemmeno in caso si scelga di installare i dati demo (senno' sporca la dir dati e i datidemo non si installano)
//Ricordare che c'e' gia' stato il controllo nella Forward della pagina di selezione, quindi la cartella..
//..di destinazione e' comunque vuota
if (bNewInstallation && !bInstallDemoData)
//files dei dati standard! solo in caso di nuova installazione!!
if (strSourceFile.Find("\\dati\\") > 0)
{
strFileCurr = strDataPath;
strFileCurr += asFilesList[i].Mid(nPathLenght + 5);
}
}
else
{
//che fare con i servers? copiare la directory...
if (asFilesList[i].Lower().Find("\\servers\\") > 0)
//i DATI NON VANNO MAI installati in caso di aggiornamento!!!
//e nemmeno in caso si scelga di installare i dati demo (senno' sporca la dir dati e i datidemo non si installano)
//Ricordare che c'e' gia' stato il controllo nella Forward della pagina di selezione, quindi la cartella..
//..di destinazione e' comunque vuota
if (bNewInstallation && !bInstallDemoData)
{
strFileCurr = strDataPath;
strFileCurr += asFilesList[i].Mid(nPathLenght + 5);
}
} else
if (strSourceFile.Find("\\servers\\") > 0) //che fare con i servers? copiare la directory...
{
if (bInstallLurch) //..ma solo se devi installare i servers
{
@ -680,12 +706,18 @@ void CampoSetup::NormalSetup()
strFileCurr += asFilesList[i].Mid(nPathLenght + 8);
}
}
else //files dei programmi
else //files vari di altre subdirectory che si installano sempre (es. setup)
{
strFileCurr = strPrgLocPath;
strFileCurr += asFilesList[i].Mid(nPathLenght);
}
}
//2B) files senza subdirectory (programmi!)
else
{
strFileCurr = strPrgLocPath;
strFileCurr += asFilesList[i].Mid(nPathLenght);
}
//copia i files nella cartella di destinazione (programmi,dati,cazzi e mazzi);se il nome del file..
//..di destinazione e' vuoto significa che non lo deve copiare!! (es. dati in aggiornamento)
if (!strFileCurr.IsEmpty())
@ -700,6 +732,8 @@ void CampoSetup::NormalSetup()
} //if (!strFileCurr.IsEmpty()..
} //for(size_t...
UpdateSyInstallIni(strSrc + "/install.ini", strPrgLocPath + "/install.ini");
// 3) INSTALLAZIONE DATI DEMO
//---------------------------
//installazione dei dati dimostrativi (che schifo!).Non si puo' fare in aggiornamento!
@ -777,7 +811,6 @@ void CampoSetup::NormalSetup()
CampoInstall.Set("DiskPath", m_pWizard->GetPrgNetPath());
else //e' il path assoluto dell'install.ini che sta in 'program' (es. D:\program)
{
wxFileName strSourcePath(m_strSetupPath + "/install.ini");
const wxString strSrc = GetSourceDir("program");
CampoInstall.Set("DiskPath", strSrc);
}

View File

@ -98,42 +98,114 @@ bool WarningBox(const wxString str)
//classe per gestire i .Ini di campo
//-----------------------------------------------------------------------------------
CampoIniFile::CampoIniFile(const wxString strIniPath, const wxString strParagraph)
: wxFileConfig (wxEmptyString, wxEmptyString, strIniPath, wxEmptyString,
wxCONFIG_USE_LOCAL_FILE|wxCONFIG_USE_NO_ESCAPE_CHARACTERS)
bool CampoIniFile::GetFirstGroup(wxString& strGroup, long& nIndex)
{
m_asGroups.Clear();
char bufferone[1024*16];
::GetPrivateProfileSectionNames(bufferone, sizeof(bufferone), m_strIniName);
const char* inizio = bufferone;
for (const char* b = bufferone; ; b++) if (*b == '\0')
{
if (*inizio)
{
m_asGroups.Add(inizio);
inizio = b+1;
}
else
break;
}
nIndex = 0;
return GetNextGroup(strGroup, nIndex);
}
bool CampoIniFile::GetNextGroup(wxString& strGroup, long& nIndex)
{
const bool ok = nIndex >= 0 && nIndex < (long)m_asGroups.GetCount();
if (ok)
strGroup = m_asGroups[nIndex++];
return ok;
}
bool CampoIniFile::DeleteGroup(const wxString strGroup)
{
return WritePrivateProfileString(m_strGroup, NULL, NULL, m_strIniName) != 0;
}
bool CampoIniFile::GetFirstEntry(wxString& strEntry, long& nIndex)
{
m_asEntries.Clear();
char bufferone[1024*32];
::GetPrivateProfileSection(m_strGroup, bufferone, sizeof(bufferone), m_strIniName);
const char* pInizio = bufferone;
for (const char* b = bufferone; ; b++) if (*b == '\0')
{
if (*pInizio)
{
wxString strWrk = pInizio;
strWrk = strWrk.BeforeFirst('=');
strWrk.Trim();
//prende solo il nome della variabile per completare la lista! dopo l'= ci sarebbe il valore
m_asEntries.Add(strWrk);
pInizio = b+1;
}
else
break;
}
nIndex = 0;
return GetNextEntry(strEntry, nIndex);
}
bool CampoIniFile::GetNextEntry(wxString& strEntry, long& nIndex)
{
const bool ok = nIndex >= 0 && nIndex < (long)m_asEntries.GetCount();
if (ok)
strEntry = m_asEntries[nIndex++];
return ok;
}
wxString CampoIniFile::Get(const wxString strVariable) const
{
wxString strOutString;
char* buffer = strOutString.GetWriteBuf(256);
GetPrivateProfileString(m_strGroup, strVariable, "", buffer, 256, m_strIniName);
strOutString.UngetWriteBuf(); //sblocca la memoria senno' la stringa resta per sempre!!!
return strOutString;
}
bool CampoIniFile::GetBool(const wxString strVariable) const
{
const char chVal = Get(strVariable)[0];
return chVal == 'X' || chVal == 'Y' || chVal == '1';
}
int CampoIniFile::GetInt(const wxString strVariable) const
{
return atoi(Get(strVariable));
}
bool CampoIniFile::Set(const wxString strVariable, const wxString strValue)
{
return WritePrivateProfileString(m_strGroup, strVariable, strValue, m_strIniName) != 0;
}
bool CampoIniFile::Set(const wxString strVariable, const int uValue)
{
wxString strValue;
strValue << uValue;
return WritePrivateProfileString(m_strGroup, strVariable, strValue, m_strIniName) != 0;
}
//costruttore
CampoIniFile::CampoIniFile(const wxString strIniPath, wxString strGroup)
: m_strIniName(strIniPath), m_strGroup(strGroup)
{
if (!strParagraph.IsEmpty())
SetPath(strParagraph);
}
wxString CampoIniFile::Get(const wxString strVariable) const
{
return Read(strVariable);
}
bool CampoIniFile::GetBool(const wxString strVariable) const
{
wxString strBool = Get(strVariable);
return strBool == "X" || strBool == "Y";
}
int CampoIniFile::GetInt(const wxString strVariable) const
{
wxString str = Get(strVariable);
long val = 0;
str.ToLong(&val);
return val;
}
bool CampoIniFile::Set(const wxString strVariable, const wxString strValue)//, const wxString strParagraph) const
{
return Write(strVariable, strValue);
}
bool CampoIniFile::Set(const wxString strVariable, const int uValue)//, const wxString strParagraph) const
{
return Write(strVariable, uValue);
}
//metodo per sapere che cavolo di tipo di installazione sta esaminando (serve per leggere e scrivere...
//...correttamente il campo.ini

View File

@ -7,7 +7,29 @@ enum InstallationType { it_none, it_standalone, it_server, it_client, it_upgrade
enum LurchMode {lm_none, lm_service, lm_autostart};
////////////////////////////////////////////////////////////////////////////////////////////
//Classe per la gestione dei files di configurazione tipo campo.ini
class CampoIniFile : public wxFileConfig
class CampoIniFile : public wxObject
{
wxString m_strIniName, m_strGroup;
wxArrayString m_asGroups, m_asEntries;
public:
bool GetFirstGroup(wxString& strGroup, long& nIndex);
bool GetNextGroup(wxString& strGroup, long& nIndex);
bool DeleteGroup(const wxString strGroup);
bool GetFirstEntry(wxString& strEntry, long& nIndex);
bool GetNextEntry(wxString& strEntry, long& nIndex);
wxString Get(const wxString strVariable) const;
bool GetBool(const wxString strVariable) const;
int GetInt (const wxString strVariable) const;
bool Set(const wxString strVariable, const wxString strValue);
InstallationType GetInstallationType() const;
bool Set(const wxString strVariable, const int uValue);
CampoIniFile(const wxString strIniPath, wxString strGroup);
};
/*
class CampoIniFile : public wxFileConfig
{
protected:
public:
@ -20,6 +42,7 @@ public:
CampoIniFile(const wxString strIniPath, wxString strValue);
};
*/
bool ErrorBox(const wxString str);

View File

@ -424,7 +424,7 @@ CampoWizardPage3::CampoWizardPage3(wxWizard* parent) : CampoWizardPage(parent)
asCampi.Add("Nuova installazione");
m_pRadioBox = new wxRadioBox(this, 301, "Selezionare l'installazione da aggiornare (consigliato) o Nuova installazione",
wxDefaultPosition, wxDefaultSize, asCampi, 0, wxRA_SPECIFY_ROWS);
if (prechecked > 0)
if (prechecked >= 0)
m_pRadioBox->SetSelection(prechecked);
}