diff --git a/setup/Setup.cpp b/setup/Setup.cpp index f64b49939..174c4b283 100755 --- a/setup/Setup.cpp +++ b/setup/Setup.cpp @@ -609,14 +609,14 @@ void CampoSetup::NormalSetup() // 1) RACCOLTA PARAMETRI GENERALI INSTALLAZIONE (tipo,path,cartelle,servers,...) //------------------------------------------------------------------------------ //tipo di installazione/aggiornamento - const unsigned int uInstallationType = m_pWizard->GetInstallationType(); - const bool bNewInstallation = uInstallationType < 3; + const InstallationType uInstallationType = m_pWizard->GetInstallationType(); + const bool bNewInstallation = uInstallationType != it_upgrade; //installazione servers? solo per server di campo - const bool bInstallLurch = uInstallationType == 1 && (m_pWizard->GetInstUseAuth() || m_pWizard->GetInstUseDict()); + const bool bInstallLurch = uInstallationType == it_server && (m_pWizard->GetInstUseAuth() || m_pWizard->GetInstUseDict()); //uso servers? sarebbe solo per i client ma lo teniamo buono per tutti - const bool bUseLurch = uInstallationType != 1 && (!m_pWizard->GetSrvAuth().IsEmpty() || !m_pWizard->GetSrvDict().IsEmpty()); + const bool bUseLurch = uInstallationType != it_server && (!m_pWizard->GetSrvAuth().IsEmpty() || !m_pWizard->GetSrvDict().IsEmpty()); //installazione datidemo? (oddio speriamo di no!; comunque vale solo per installazione standard) - const bool bInstallDemoData = uInstallationType == 0 && m_pWizard->GetInstDemoData(); + const bool bInstallDemoData = uInstallationType == it_standalone && m_pWizard->GetInstDemoData(); //cartelle selezionate dall'utente const wxString& strPrgLocPath = m_pWizard->GetPrgLocPath(); const wxString& strDataPath = m_pWizard->GetDataPath(); @@ -745,8 +745,8 @@ void CampoSetup::NormalSetup() CampoIniMain.Set("Study", strDataPath); CampoIniMain.Set("Firm", "com"); //client o non client? - //(attenzione che in Campo e' Std=1 Srv=2 Cli=3, mentre qui e' Std=0 Srv=1 Cli=2) - CampoIniMain.Set("Type", uInstallationType + 1); + //(attenzione che in Campo e' Std=1 Srv=2 Cli=3) + CampoIniMain.Set("Type", uInstallationType); } //paragrafo [Server] if (bInstallLurch || bUseLurch) @@ -762,7 +762,7 @@ void CampoSetup::NormalSetup() //SOLO se sta aggiornando una versione antecedente alla 10.0 scrive la variabile Type nel campo.ini.. //..ovvero deve testare se Type = 0 if (CampoIniMain.GetInt("Type") == 0) - CampoIniMain.Set("Type", CampoIniMain.GetInstallationTypeNumber()); + CampoIniMain.Set("Type", CampoIniMain.GetInstallationType()); } // 5) COMPILAZIONE\AGGIORNAMENTO INSTALL.INI CON DISKPATH @@ -771,7 +771,7 @@ void CampoSetup::NormalSetup() //parentesi necessaria per la scrittura immediata (non cancellare! serve per debug) { CampoIniFile CampoInstall(strPrgLocPath + "/install.ini", "Main"); - if (uInstallationType == 2) //client: directory origine sul server + if (uInstallationType == it_client) //client: directory origine sul server CampoInstall.Set("DiskPath", m_pWizard->GetPrgNetPath()); else //e' il path assoluto dell'install.ini che sta in 'program' (es. D:\program) { @@ -786,9 +786,9 @@ void CampoSetup::NormalSetup() //------------------------------------------------ //solo se sta installando campo in postazione server e deve installare un gestore di servizi.. //..avvia la procedura della creazione dell'autostart(un casino) - if (bInstallLurch) + const int iSrvAutostartMode = m_pWizard->GetSrvAutostartMode(); + if (iSrvAutostartMode != lm_none) { - const int iSrvAutostartMode = m_pWizard->GetSrvAutostartMode(); CreateAutostartMode(iSrvAutostartMode, strPrgLocPath); } @@ -809,16 +809,13 @@ void CampoSetup::NormalSetup() wxString strLnk; CampoIniFile CampoIniMain(strPrgLocPath + "/campo.ini", "Main"); - int nInstType = CampoIniMain.GetInstallationTypeNumber(); + InstallationType nInstType = CampoIniMain.GetInstallationType(); switch (nInstType) { - case 1: - strLnk = "Campo"; - break; - case 2: + case it_server: strLnk = "Campo (Server)"; break; - case 3: + case it_client: strLnk = "Campo (Client)"; break; default: diff --git a/setup/utils.cpp b/setup/utils.cpp index 7b4e0e377..5e466ebe3 100755 --- a/setup/utils.cpp +++ b/setup/utils.cpp @@ -137,12 +137,12 @@ bool CampoIniFile::Set(const wxString strVariable, const int uValue)//, const wx //metodo per sapere che cavolo di tipo di installazione sta esaminando (serve per leggere e scrivere... //...correttamente il campo.ini -int CampoIniFile::GetInstallationTypeNumber() const +InstallationType CampoIniFile::GetInstallationType() const { - int nType = GetInt("Type"); - if (nType < 1 || nType > 3) + InstallationType nType = (InstallationType)GetInt("Type"); + if (nType < it_standalone || nType > it_client) { - nType = 1; //di base e' standalone + nType = it_standalone; //di base e' standalone const bool bTestDataBase = GetBool("TestDatabase"); const bool bTestPrograms = GetBool("TestPrograms"); @@ -152,10 +152,10 @@ int CampoIniFile::GetInstallationTypeNumber() const //se la directory dei dati e' condivisa in scrittura e' un server (almeno al 99%) const wxString strStudy = Get("Study"); if (IsSharedDirectory(strStudy)) - nType = 2; //e' server + nType = it_server; //e' server } else //..senno' e' client - nType = 3; + nType = it_client; } return nType; } diff --git a/setup/utils.h b/setup/utils.h index d463450c7..5c0ebbfe1 100755 --- a/setup/utils.h +++ b/setup/utils.h @@ -1,6 +1,10 @@ #ifndef __UTILS_H #define __UTILS_H +// lista dei tipi di installazione 0=non si sa, 1=standalone, 2=server, 3=client +enum InstallationType { it_none, it_standalone, it_server, it_client, it_upgrade = 9 }; + +enum LurchMode {lm_none, lm_service, lm_autostart}; //////////////////////////////////////////////////////////////////////////////////////////// //Classe per la gestione dei files di configurazione tipo campo.ini class CampoIniFile : public wxFileConfig @@ -11,7 +15,7 @@ public: bool GetBool(const wxString strVariable) const; int GetInt (const wxString strVariable) const; bool Set(const wxString strVariable, const wxString strValue); - int GetInstallationTypeNumber() const; + InstallationType GetInstallationType() const; bool Set(const wxString strVariable, const int uValue); CampoIniFile(const wxString strIniPath, wxString strValue); diff --git a/setup/wizard.cpp b/setup/wizard.cpp index 8110267d6..f303feeff 100755 --- a/setup/wizard.cpp +++ b/setup/wizard.cpp @@ -2,7 +2,6 @@ #include "key.h" #include "wizard.h" -#include "utils.h" #define HGAP 4 #define VGAP 2 @@ -286,10 +285,10 @@ bool CampoWizardPage3::ForwardValidate() CampoIniFile CampoIni(strPrgPath + "/campo.ini", "Main"); //cerca il tipo dell'installazione - int nType = CampoIni.GetInstallationTypeNumber(); + InstallationType nType = CampoIni.GetInstallationType(); //se risulta un client... - if (nType == 3) + if (nType == it_client) { CampoIniFile InstallIni(strPrgPath + "/install.ini", "Main"); wxString strDiskPath = InstallIni.Get("DiskPath"); @@ -316,7 +315,7 @@ bool CampoWizardPage3::ForwardValidate() //setta alla pagina riassuntiva i valori della pagina attuale... GetWizard().SetDestinationPath(strPrgPath); //va alla pagina riassuntiva GetWizard().SetPrgLocPath(strPrgPath); //questo serve solo per la creazione del link sul desktop! - GetWizard().SetInstallationType(3); //e' un aggiornamento!! + GetWizard().SetInstallationType(it_upgrade); //e' un aggiornamento!! GetWizard().SetDesktopShortcut(false); //e' sempre un aggiornamento! } else //resetta il path in caso si scelga nuova installazione dopo aver scelto aggiornamento @@ -368,19 +367,17 @@ CampoWizardPage3::CampoWizardPage3(wxWizard* parent) : CampoWizardPage(parent) { //controlla il tipo di installazione rilevata (Standalone,Server,Client) CampoIniFile iniCampo(strPath + "/campo.ini", "Main"); - const int nType = iniCampo.GetInstallationTypeNumber(); + const InstallationType nType = iniCampo.GetInstallationType(); switch (nType) { - case 1: - strPath << " (Standard)"; - break; - case 2: + case it_server: strPath << " (Server)"; break; - case 3: + case it_client: strPath << " (Client)"; break; default: + strPath << " (Standard)"; break; } asCampi.Add(strPath); @@ -388,7 +385,7 @@ CampoWizardPage3::CampoWizardPage3(wxWizard* parent) : CampoWizardPage(parent) //..sulla stessa macchina if (prechecked < 0) { - if (nType == 1 || nType == 2) + if (nType == it_standalone || nType == it_server) prechecked = i; } } //if(CheckPrgDir(strPath)... @@ -740,8 +737,9 @@ public: bool CampoWizardPage5::ForwardValidate() { - const unsigned int type = m_pRadioBox->GetSelection(); - GetWizard().SetInstallationType(type); + // controlla il tipo di installazione! + const int nType = m_pRadioBox->GetSelection() + 1; + GetWizard().SetInstallationType((InstallationType)nType); return true; } @@ -969,10 +967,11 @@ bool CampoWizardPage7::ForwardValidate() //..e loro modalita' di esecuzione if (bInstAuth || bInstDict) { - GetWizard().SetSrvAutostartMode(m_pRadioBox->GetSelection()); + int nType = m_pRadioBox->GetSelection(); + GetWizard().SetSrvAutostartMode((LurchMode)nType); } else - GetWizard().SetSrvAutostartMode(-1); + GetWizard().SetSrvAutostartMode(lm_none); return true; } @@ -1311,7 +1310,7 @@ CampoWizardPage9::CampoWizardPage9(wxWizard* parent) : CampoWizardPage(parent) /**********************************************************************************************************/ class CampoWizardPage10 : public CampoWizardPage { - unsigned int _uInstallType; + InstallationType _uInstallType; wxString _strInstallType; wxString _strPrgLocPath; wxString _strPrgNetPath; @@ -1337,7 +1336,7 @@ bool CampoWizardPage10::TransferDataToWindow() _uInstallType = cw.GetInstallationType(); switch (_uInstallType) { - case 1: //server + case it_server: //server _strInstallType = "Server"; _strPrgLocPath = cw.GetPrgLocPath(); _strDataPath = cw.GetDataPath(); @@ -1346,7 +1345,7 @@ bool CampoWizardPage10::TransferDataToWindow() if (!_strSrvAuth.IsEmpty() || !_strSrvDict.IsEmpty()) _iSrvAutostartMode = cw.GetSrvAutostartMode(); break; - case 2: //client + case it_client: //client _strInstallType = "Client"; _strPrgLocPath = cw.GetPrgLocPath(); _strPrgNetPath = cw.GetPrgNetPath(); @@ -1354,7 +1353,7 @@ bool CampoWizardPage10::TransferDataToWindow() _strSrvAuth = cw.GetSrvAuth(); _strSrvDict = cw.GetSrvDict(); break; - case 3: //aggiornamento + case it_upgrade: //aggiornamento _strInstallType = ""; _strPrgLocPath = cw.GetDestinationPath(); _strDataPath = cw.GetDataPath(); @@ -1384,7 +1383,7 @@ bool CampoWizardPage10::TransferDataToWindow() wxString strBody; //Aggiornamento - if (_uInstallType == 3) + if (_uInstallType == it_upgrade) { strTitle += wxT("AGGIORNAMENTO: riepilogo configurazione"); @@ -1537,21 +1536,21 @@ const wxString& CampoWizard::GetDestinationPath() const return _strDestinationPath; } -void CampoWizard::SetInstallationType(const unsigned int type) +void CampoWizard::SetInstallationType(const InstallationType nType) { - _uInstallationType = type; + _uInstallationType = nType; //in base al tipo di installazione spara l'utente alla pagina corretta switch (_uInstallationType) { - case 1: //server + case it_server: //server wxWizardPageSimple::Chain(m_pPage[4], m_pPage[6]); //manda l'utente alla pagina server wxWizardPageSimple::Chain(m_pPage[6], m_pPage[8]); //dal server alla pagina riassuntiva break; - case 2: //client + case it_client: //client wxWizardPageSimple::Chain(m_pPage[4], m_pPage[7]); //manda l'utente alla pagina client wxWizardPageSimple::Chain(m_pPage[7], m_pPage[8]); //dal client alla pagina riassuntiva break; - case 3: //aggiornamento installazione precedente + case it_upgrade: //aggiornamento installazione precedente wxWizardPageSimple::Chain(m_pPage[3], m_pPage[8]); //manda l'utente alla pagina riassuntiva break; default: //standard @@ -1569,7 +1568,7 @@ void CampoWizard::SetInstallationType(const unsigned int type) } } -const unsigned int CampoWizard::GetInstallationType() const +const InstallationType CampoWizard::GetInstallationType() const { return _uInstallationType; } @@ -1654,12 +1653,12 @@ const wxString& CampoWizard::GetSrvDict() const return _strSrvDict; } -void CampoWizard::SetSrvAutostartMode(const int iSrvAutostartMode) +void CampoWizard::SetSrvAutostartMode(const LurchMode iSrvAutostartMode) { _iSrvAutostartMode = iSrvAutostartMode; } -const int CampoWizard::GetSrvAutostartMode() const +const LurchMode CampoWizard::GetSrvAutostartMode() const { return _iSrvAutostartMode; } diff --git a/setup/wizard.h b/setup/wizard.h index 04396cd41..fd8f37859 100755 --- a/setup/wizard.h +++ b/setup/wizard.h @@ -1,6 +1,8 @@ #ifndef __WIZARD_H #define __WIZARD_H +#include "utils.h" + /////////////////////////////////////////////////////////// // CampoWizardPage /////////////////////////////////////////////////////////// @@ -12,7 +14,7 @@ class CampoWizard : public wxWizard CampoWizardPage* m_pPage[m_nPages]; wxString _strDestinationPath; //path di aggiornamento/installazione - unsigned int _uInstallationType; //tipo di installazione selezionata (standard,server,client,aggiornamento) + InstallationType _uInstallationType; //tipo di installazione selezionata (standard,server,client,aggiornamento) unsigned int _uDongleType; //tipo di chiave di protezione (hardlock,eutron,server) wxString _strPrgLocPath; //path programmi in locale @@ -26,7 +28,7 @@ class CampoWizard : public wxWizard bool _bInstUseDict; //installa/usa server diction wxString _strSrvDict; //nome server diction - unsigned int _iSrvAutostartMode; //tipologia di esecuzione dei server + LurchMode _iSrvAutostartMode; //tipologia di esecuzione dei server bool _bDesktopShortcut; //crea il link sul desktop protected: @@ -47,8 +49,8 @@ public: //metodi per il passaggio tra le finestre dei parametri di installazione! void SetDestinationPath(const wxString& strPath); const wxString& GetDestinationPath() const; - void SetInstallationType(const unsigned int uType); - const unsigned int GetInstallationType() const; + void SetInstallationType(const InstallationType uType); + const InstallationType GetInstallationType() const; void SetDongleType(const unsigned int uType); const unsigned int GetDongleType() const; @@ -74,8 +76,8 @@ public: void SetSrvDict(const wxString& strSrvDict); const wxString& GetSrvDict() const; - void SetSrvAutostartMode(const int iSrvAutostartMode); - const int GetSrvAutostartMode() const; + void SetSrvAutostartMode(const LurchMode iSrvAutostartMode); + const LurchMode GetSrvAutostartMode() const; void SetDesktopShortcut(const bool bDesktopShortcut); const bool GetDesktopShortcut() const;