Patch level :
Files correlati : Ricompilazione Demo : [ ] Commento : git-svn-id: svn://10.65.10.50/trunk@15631 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
fc720f99ec
commit
47aedad7c5
683
setup/Setup.cpp
683
setup/Setup.cpp
@ -76,6 +76,7 @@ class CampoWizard : public wxWizard
|
||||
wxString _strDataPath; //path dati (creare o usare)
|
||||
|
||||
bool _bInstDemoData; //installa dati dimostrativi
|
||||
bool _bInstDemoVersion; //installa versione demo
|
||||
bool _bInstUseAuth; //installa/usa server authoriz
|
||||
wxString _strSrvAuth; //nome server authoriz
|
||||
bool _bInstUseDict; //installa/usa server diction
|
||||
@ -115,6 +116,8 @@ public:
|
||||
|
||||
void SetInstDemoData(const bool bInstDemoData);
|
||||
const bool GetInstDemoData() const;
|
||||
void SetInstDemoVersion(const bool bInstDemoVersion);
|
||||
const bool GetInstDemoVersion() const;
|
||||
|
||||
void SetInstUseAuth(const bool bInstUseAuth);
|
||||
const bool GetInstUseAuth() const;
|
||||
@ -377,11 +380,26 @@ class CampoWizardPage3 : public CampoWizardPage
|
||||
|
||||
protected:
|
||||
virtual bool ForwardValidate();
|
||||
bool LocalDongleTest() const;
|
||||
|
||||
public:
|
||||
CampoWizardPage3(wxWizard* parent);
|
||||
};
|
||||
|
||||
//metodo per cercare se c'e' una chiave fisicamente collegata (serve per abilitare l'installazione demo)
|
||||
bool CampoWizardPage3::LocalDongleTest() const
|
||||
{
|
||||
unsigned short serno = 0xFFFF;
|
||||
int yearKey = 0;
|
||||
|
||||
serno = HardlockLogin(yearKey);
|
||||
if (serno == 0xFFFF)
|
||||
serno = EutronLogin(yearKey);
|
||||
|
||||
return serno != 0xFFFF && yearKey > 0;
|
||||
}
|
||||
|
||||
|
||||
bool CampoWizardPage3::ForwardValidate()
|
||||
{
|
||||
const int iLastRow = m_pRadioBox->GetRowCount() - 1;
|
||||
@ -433,8 +451,21 @@ bool CampoWizardPage3::ForwardValidate()
|
||||
}
|
||||
else //resetta il path in caso si scelga nuova installazione dopo aver scelto aggiornamento
|
||||
{
|
||||
//continuiamo a sconsigliare l'installazione DEMO, ma ognuno fa come crede...
|
||||
if (GetBool(302))
|
||||
{
|
||||
const wxString strPrgDemoPath = "c:/campodemo";
|
||||
wxDir dirPrgDemoPath(strPrgDemoPath);
|
||||
if (dirPrgDemoPath.Exists(strPrgDemoPath) && (dirPrgDemoPath.HasFiles() || dirPrgDemoPath.HasSubDirs()))
|
||||
return ErrorBox("Impossibile installare la versione DEMO!\nLa cartella c:/campodemo NON e' vuota!");
|
||||
|
||||
GetWizard().SetInstDemoVersion(true);
|
||||
}
|
||||
|
||||
//questo lo fa in ogni caso!
|
||||
GetWizard().SetDestinationPath("");
|
||||
GetWizard().SetDesktopShortcut(true);
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -511,8 +542,25 @@ CampoWizardPage3::CampoWizardPage3(wxWizard* parent) : CampoWizardPage(parent)
|
||||
|
||||
strBody += wxT("<p>Prima di proseguire accertarsi che non vi sia alcuna sessione di <b><i>APPNAME</i></b> attiva! ");
|
||||
strBody += wxT("Terminare quindi le eventuali sessioni di <b><i>APPNAME</i></b> attive e proseguire.</p>");
|
||||
SetHTMLText(strTitle, strBody);
|
||||
|
||||
GetSizer()->Add(m_pRadioBox);
|
||||
|
||||
//se NON ci sono installazioni gia' presenti e NON c'e' alcuna chiave collegata -> puo' installare la DEMO
|
||||
if (asCampi.GetCount() == 1 && !LocalDongleTest())
|
||||
{
|
||||
//checkbox per installare la DEMO (non fatelo, vi prego!!!)
|
||||
wxCheckBox* chDemoPrg = new wxCheckBox(this, 302, wxT("Installare la versione DEMO"));
|
||||
chDemoPrg->SetValue(false);
|
||||
GetSizer()->AddSpacer(16);
|
||||
GetSizer()->Add(chDemoPrg);
|
||||
|
||||
strBody += wxT("<p>E' possibile anche installare la versione <b>DEMO di <i>APPNAME</i></b>. <u>Questa versione e' a scopo puramente ");
|
||||
strBody += wxT("dimostrativo e <b>NON</b> va di norma installata! Non e' utilizzabile come la versione normale</u> in quanto limitata nel ");
|
||||
strBody += wxT("numero e nella data delle registrazioni e nel tempo di uso giornaliero (max 2 ore). La cartella di installazione della ");
|
||||
strBody += wxT("versione dimostrativa e' C:/campodemo e dispone di un'area dati parzialmente precompilata.</p>");
|
||||
}
|
||||
|
||||
SetHTMLText(strTitle, strBody);
|
||||
}
|
||||
|
||||
|
||||
@ -1363,6 +1411,7 @@ class CampoWizardPage10 : public CampoWizardPage
|
||||
wxString _strSrvDict;
|
||||
unsigned int _iSrvAutostartMode;
|
||||
bool _bInstDemoData;
|
||||
bool _bInstDemoVersion;
|
||||
bool _bDesktopShortcut;
|
||||
|
||||
protected:
|
||||
@ -1404,10 +1453,18 @@ bool CampoWizardPage10::TransferDataToWindow()
|
||||
_strSrvDict = cw.GetSrvDict();
|
||||
break;
|
||||
default: //standard
|
||||
_strInstallType = "Standard";
|
||||
_strPrgLocPath = cw.GetPrgLocPath();
|
||||
_strDataPath = cw.GetDataPath();
|
||||
_bInstDemoData = cw.GetInstDemoData();
|
||||
if (cw.GetInstDemoVersion())
|
||||
{
|
||||
_strInstallType = "DEMO";
|
||||
_strPrgLocPath = "c:/campodemo";
|
||||
}
|
||||
else
|
||||
{
|
||||
_strInstallType = "Standard";
|
||||
_strPrgLocPath = cw.GetPrgLocPath();
|
||||
_strDataPath = cw.GetDataPath();
|
||||
_bInstDemoData = cw.GetInstDemoData();
|
||||
}
|
||||
break;
|
||||
}
|
||||
//questo vale per tutti
|
||||
@ -1430,18 +1487,28 @@ bool CampoWizardPage10::TransferDataToWindow()
|
||||
else //Installazione
|
||||
{
|
||||
strTitle += wxT("INSTALLAZIONE: riepilogo configurazione");
|
||||
|
||||
strBody = wxT("<p>Tipo installazione selezionata: ");
|
||||
strBody += wxT(Bold(_strInstallType) + "</p>");
|
||||
strBody += wxT("<p>Cartella dove installare il programma: ");
|
||||
strBody += wxT(Bold(_strPrgLocPath) + "</p>");
|
||||
if (_uInstallType == 2)
|
||||
//DEMO (aaarrgh!)
|
||||
if (cw.GetInstDemoVersion())
|
||||
{
|
||||
strBody += wxT("<p>Cartella di origine dei files del programma: ");
|
||||
strBody += wxT(Bold(_strPrgNetPath) + "</p>");
|
||||
strBody = wxT("<p>Tipo installazione selezionata: ");
|
||||
strBody += wxT("<b>DEMO</b></p>");
|
||||
strBody += wxT("<p>Cartella dove installare il programma: ");
|
||||
strBody += wxT("<b>C:/campodemo</b></p>");
|
||||
}
|
||||
else //tutte le altre
|
||||
{
|
||||
strBody = wxT("<p>Tipo installazione selezionata: ");
|
||||
strBody += wxT(Bold(_strInstallType) + "</p>");
|
||||
strBody += wxT("<p>Cartella dove installare il programma: ");
|
||||
strBody += wxT(Bold(_strPrgLocPath) + "</p>");
|
||||
if (_uInstallType == 2)
|
||||
{
|
||||
strBody += wxT("<p>Cartella di origine dei files del programma: ");
|
||||
strBody += wxT(Bold(_strPrgNetPath) + "</p>");
|
||||
}
|
||||
strBody += wxT("<p>Cartella dati da creare: ");
|
||||
strBody += wxT(Bold(_strDataPath) + "</p>");
|
||||
}
|
||||
strBody += wxT("<p>Cartella dati da creare: ");
|
||||
strBody += wxT(Bold(_strDataPath) + "</p>");
|
||||
}
|
||||
//installazione servers...
|
||||
if (!_strSrvAuth.IsEmpty())
|
||||
@ -1539,7 +1606,10 @@ void CampoWizard::SetDestinationPath(const wxString& path)
|
||||
//..che sta in _strDestinationPath
|
||||
if (_strDestinationPath.IsEmpty())
|
||||
{
|
||||
wxWizardPageSimple::Chain(m_pPage[3], m_pPage[4]); //installazione nuova
|
||||
if (GetInstDemoVersion())
|
||||
wxWizardPageSimple::Chain(m_pPage[2], m_pPage[8]); //installazione DEMO
|
||||
else
|
||||
wxWizardPageSimple::Chain(m_pPage[3], m_pPage[4]); //installazione nuova normale
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1570,8 +1640,16 @@ void CampoWizard::SetInstallationType(const unsigned int type)
|
||||
wxWizardPageSimple::Chain(m_pPage[3], m_pPage[8]); //manda l'utente alla pagina riassuntiva
|
||||
break;
|
||||
default: //standard
|
||||
wxWizardPageSimple::Chain(m_pPage[4], m_pPage[5]); //manda l'utente alla pagina standard
|
||||
wxWizardPageSimple::Chain(m_pPage[5], m_pPage[8]); //dalla standard alla pagina riassuntiva
|
||||
//if demo
|
||||
if (GetInstDemoVersion())
|
||||
{
|
||||
wxWizardPageSimple::Chain(m_pPage[2], m_pPage[8]); //manda l'utente alla pagina riassuntiva senza controllo chiave
|
||||
}
|
||||
else
|
||||
{
|
||||
wxWizardPageSimple::Chain(m_pPage[4], m_pPage[5]); //manda l'utente alla pagina standard
|
||||
wxWizardPageSimple::Chain(m_pPage[5], m_pPage[8]); //dalla standard alla pagina riassuntiva
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1681,6 +1759,16 @@ const bool CampoWizard::GetInstDemoData() const
|
||||
return _bInstDemoData;
|
||||
}
|
||||
|
||||
void CampoWizard::SetInstDemoVersion(const bool bInstDemoVersion)
|
||||
{
|
||||
_bInstDemoVersion = bInstDemoVersion;
|
||||
}
|
||||
|
||||
const bool CampoWizard::GetInstDemoVersion() const
|
||||
{
|
||||
return _bInstDemoVersion;
|
||||
}
|
||||
|
||||
void CampoWizard::SetDesktopShortcut(const bool bDesktopShortcut)
|
||||
{
|
||||
_bDesktopShortcut = bDesktopShortcut;
|
||||
@ -1698,6 +1786,7 @@ CampoWizard::CampoWizard(wxWindow* pParent)
|
||||
{
|
||||
//resettatore dei booleans (che senno' prendono valore casuale ad ogni esecuzione)
|
||||
_bInstDemoData = false; //installa dati dimostrativi
|
||||
_bInstDemoVersion = false; //installa versione demo
|
||||
_bInstUseAuth = false; //installa/usa server authoriz
|
||||
_bInstUseDict = false; //installa/usa server diction
|
||||
_bDesktopShortcut = false; //creazione link sul desktop
|
||||
@ -1813,7 +1902,7 @@ private:
|
||||
protected:
|
||||
DECLARE_EVENT_TABLE()
|
||||
void OnTimer(wxTimerEvent& e);
|
||||
bool CreateIcon(unsigned int csidl, const wxFileName& strExeFile) const;
|
||||
bool CreateIcon(unsigned int csidl, const wxFileName& strExeFile, const wxString& strLinkName) const;
|
||||
bool CreateAutostartMode(const int iSrvAutostartMode, const wxString& strPath);
|
||||
void AssociateExtension(const wxFileName& strExeFile, const wxString strExt);
|
||||
|
||||
@ -1827,6 +1916,7 @@ protected:
|
||||
size_t GetZipList(const char* strZipFile, wxArrayString& aFiles) const;
|
||||
const wxString GetSourceDir(const wxString strDirName) const;
|
||||
void UnzipSystem(const wxString& strPrgLocPath) const;
|
||||
bool CopyFilesAndDirs(const wxString& FilesListI, wxString strFileCurr, const bool bIni) const;
|
||||
|
||||
public:
|
||||
virtual bool OnInit();
|
||||
@ -1968,7 +2058,7 @@ bool CampoSetup::CreateAutostartMode(const int iSrvAutostartMode, const wxString
|
||||
//link nella cartella esecuzione automatica
|
||||
case 1:
|
||||
{
|
||||
CreateIcon(CSIDL_COMMON_STARTUP, strExe);
|
||||
CreateIcon(CSIDL_COMMON_STARTUP, strExe, "lurch");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -1977,7 +2067,7 @@ bool CampoSetup::CreateAutostartMode(const int iSrvAutostartMode, const wxString
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CampoSetup::CreateIcon(unsigned int csidl, const wxFileName& strExeFile) const
|
||||
bool CampoSetup::CreateIcon(unsigned int csidl, const wxFileName& strExeFile, const wxString& strLinkName) const
|
||||
{
|
||||
//csidl = CSIDL_COMMON_DESKTOPDIRECTORY = desktop
|
||||
//csidl = CSIDL_COMMON_STARTUP = all users esecuzione automatica
|
||||
@ -2005,17 +2095,15 @@ bool CampoSetup::CreateIcon(unsigned int csidl, const wxFileName& strExeFile) co
|
||||
|
||||
if (SUCCEEDED(hres))
|
||||
{
|
||||
wxFileName strLnk;
|
||||
if (csidl == CSIDL_COMMON_STARTUP)
|
||||
strLnk.Assign(strDesktopPath, wxT("Lurch.lnk"));
|
||||
else
|
||||
strLnk.Assign(strDesktopPath, wxT("Campo.lnk"));
|
||||
wxFileName fnLnk;
|
||||
wxString strName = strLinkName + ".lnk";
|
||||
fnLnk.Assign(strDesktopPath, strName);
|
||||
|
||||
// Save the link by calling IPersistFile::Save.
|
||||
wxString stringa = strLnk.GetFullPath();
|
||||
wxString strPath = fnLnk.GetFullPath();
|
||||
wchar_t buff[_MAX_PATH];
|
||||
memset(buff, 0, sizeof(buff));
|
||||
wxConvLocal.MB2WC(buff, stringa, stringa.Len());
|
||||
wxConvLocal.MB2WC(buff, strPath, strPath.Len());
|
||||
hres = ppf->Save(buff, true);
|
||||
ppf->Release();
|
||||
}
|
||||
@ -2185,6 +2273,47 @@ void CampoSetup::UnzipSystem(const wxString& strPrgLocPath) const
|
||||
}
|
||||
}
|
||||
|
||||
bool CampoSetup::CopyFilesAndDirs(const wxString& FilesListI, wxString strFileCurr, const bool bIni) const
|
||||
{
|
||||
bool ok = true;
|
||||
|
||||
strFileCurr.MakeLower(); //minuscolizzazione di sicurezza
|
||||
const wxFileName strFileName(strFileCurr);
|
||||
|
||||
//i files .ini vanno trattati con i guanti (se esistono gia' non vanno copiati!!!)
|
||||
//parte da eseguire solo in caso sia indicata la trattazione degli ini (bIni true)
|
||||
if (bIni)
|
||||
{
|
||||
if (strFileName.GetExt() == "ini")
|
||||
{
|
||||
const wxString strName = strFileName.GetName();
|
||||
//campo.ini e install.ini vanno lasciati stare se esistono (aggiornamento)!!!
|
||||
if ((strName == "campo" || strName == "install") && strFileName.FileExists())
|
||||
ok = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (ok)
|
||||
{
|
||||
//eventuali sottodirectory le crea (solo se hanno un nome)
|
||||
const wxString strDir = strFileName.GetPath();
|
||||
if (!strDir.IsEmpty() && !wxDirExists(strDir))
|
||||
wxMkdir(strDir);
|
||||
|
||||
if(!wxCopyFile(FilesListI, strFileCurr))
|
||||
{
|
||||
wxString strErr = "Impossibile copiare il file ";
|
||||
strErr += FilesListI;
|
||||
strErr += " in ";
|
||||
strErr += strFileCurr;
|
||||
strErr += "\nInstallazione interrotta!";
|
||||
ErrorBox(strErr);
|
||||
ok = false;
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
//metodo principale dell'applicazione che gestisce l'ordine degli eventi nella installazione vera e propria
|
||||
void CampoSetup::OnTimer(wxTimerEvent& WXUNUSED(e))
|
||||
{
|
||||
@ -2198,270 +2327,292 @@ void CampoSetup::OnTimer(wxTimerEvent& WXUNUSED(e))
|
||||
|
||||
if (m_pWizard->Run())
|
||||
{
|
||||
//e' una DEMO o una versione normale?
|
||||
const bool bInstallDemoVersion = m_pWizard->GetInstDemoVersion();
|
||||
|
||||
// 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;
|
||||
//installazione servers? solo per server di campo
|
||||
const bool bInstallLurch = uInstallationType == 1 && (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());
|
||||
//installazione datidemo? (oddio speriamo di no!; comunque vale solo per installazione standard)
|
||||
const bool bInstallDemoData = uInstallationType == 0 && m_pWizard->GetInstDemoData();
|
||||
//cartelle selezionate dall'utente
|
||||
const wxString& strPrgLocPath = m_pWizard->GetPrgLocPath();
|
||||
const wxString& strDataPath = m_pWizard->GetDataPath();
|
||||
|
||||
//se nuova installazione deve anche creare la directory di destinazione
|
||||
if (bNewInstallation)
|
||||
// 0) INSTALLAZIONE VERSIONE DEMO (SIETE PAZZI?)
|
||||
//----------------------------------------------
|
||||
if (bInstallDemoVersion)
|
||||
{
|
||||
//creazione della directory dei programmi (compreso l'intero albero directory)
|
||||
const wxString& strPrgLocPath = "c:/campodemo";
|
||||
const wxString& strDataPath = strPrgLocPath + "/dati";
|
||||
const wxString& strHelpPath = strPrgLocPath + "/htmlhelp";
|
||||
//creazione delle directories necessarie alla installazione DEMO
|
||||
CheckAndMakeDir(strPrgLocPath, "programmi");
|
||||
//creazione della directory dei dati (compreso l'intero albero directory)
|
||||
CheckAndMakeDir(strDataPath, "dati");
|
||||
}
|
||||
|
||||
CheckAndMakeDir(strHelpPath, "help");
|
||||
|
||||
// 2) COPIA DEI FILES DI INSTALLAZIONE DALLA CARTELLA CAMPO (E SUBDIRS) (SU CD) ALLA CARTELLA DESTINAZIONE
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
//copia del contenuto della cartella campo nella cartella di destinazione (installaz/aggiornam)
|
||||
//per prima cosa cerca la cartella dei files sorgente...
|
||||
wxArrayString asFilesList;
|
||||
wxFileName strSourcePath(m_strSetupPath, "*.*");
|
||||
strSourcePath.AppendDir("..");
|
||||
strSourcePath.MakeAbsolute();
|
||||
//stringa inutile al programma ma decisiva per il programmatore
|
||||
const wxString strSrc = strSourcePath.GetPath();
|
||||
//..contando anche quanti sono e memorizzandoli in un array asFileList
|
||||
const size_t uFilesToCopy = wxDir::GetAllFiles(strSrc, &asFilesList);
|
||||
//copia della campodemo sull'hard disk in c:\campodemo
|
||||
wxArrayString asDemoList;
|
||||
const wxString strSrc = GetSourceDir("campodemo");
|
||||
|
||||
//per ogni file da copiare controlla i path sorgente e destinazione(problema con sottodirectory tipo dati)
|
||||
wxString strFileCurr;
|
||||
const size_t nPathLenght = strSourcePath.GetPath().Len();
|
||||
//progress bar
|
||||
wxProgressDialog pi("Installazione Dati e Programmi di base...", "", (int)uFilesToCopy, NULL, wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_CAN_ABORT);
|
||||
|
||||
for (size_t i = 0; i < uFilesToCopy; i++)
|
||||
{
|
||||
//aggiorna la progind
|
||||
if (!pi.Update((int)i, asFilesList[i]))
|
||||
break;
|
||||
//files dei dati standard! solo in caso di nuova installazione!!
|
||||
if (asFilesList[i].Lower().Find("\\dati\\") > 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
|
||||
{
|
||||
//che fare con i servers? copiare la directory..potrebbe servire
|
||||
if (asFilesList[i].Lower().Find("\\servers\\") > 0)
|
||||
{
|
||||
if (bInstallLurch)
|
||||
{
|
||||
strFileCurr = strPrgLocPath;
|
||||
strFileCurr += "\\servers";
|
||||
strFileCurr += asFilesList[i].Mid(nPathLenght + 8);
|
||||
}
|
||||
}
|
||||
else //files dei programmi
|
||||
{
|
||||
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())
|
||||
{
|
||||
strFileCurr.MakeLower(); //minuscolizzazione di sicurezza
|
||||
const wxFileName strFileName(strFileCurr);
|
||||
|
||||
//i files .ini vanno trattati con i guanti (se esistono gia' non vanno copiati!!!)
|
||||
if (strFileName.GetExt() == "ini")
|
||||
{
|
||||
const wxString strName = strFileName.GetName();
|
||||
//campo.ini e install.ini vanno lasciati stare se esistono (aggiornamento)!!!
|
||||
if ((strName == "campo" || strName == "install") && strFileName.FileExists())
|
||||
continue;
|
||||
}
|
||||
//eventuali sottodirectory le crea (solo se hanno un nome)
|
||||
const wxString strDir = strFileName.GetPath();
|
||||
if (!strDir.IsEmpty() && !wxDirExists(strDir))
|
||||
wxMkdir(strDir);
|
||||
|
||||
if(!wxCopyFile(asFilesList[i], strFileCurr))
|
||||
{
|
||||
wxString strErr = "Impossibile copiare il file ";
|
||||
strErr += asFilesList[i];
|
||||
strErr += " in ";
|
||||
strErr += strFileCurr;
|
||||
strErr += "\nInstallazione interrotta!";
|
||||
ErrorBox(strErr);
|
||||
break;
|
||||
}
|
||||
} //if (!strFileCurr.IsEmpty()..
|
||||
} //for(size_t...
|
||||
|
||||
// 3) INSTALLAZIONE DATI DEMO
|
||||
//---------------------------
|
||||
//installazione dei dati dimostrativi (che schifo!).Non si puo' fare in aggiornamento!
|
||||
if (bInstallDemoData && uInstallationType < 3)
|
||||
{
|
||||
//trova la cartella datidemo da copiare
|
||||
wxArrayString asDataList;
|
||||
const wxString strSrc = GetSourceDir("datidemo");
|
||||
//conta i files da copiare e si lancia nell'operazione di copiatura...
|
||||
//Vale quanto detto per l'installazione dell'area dati
|
||||
const size_t uFilesToCopy = wxDir::GetAllFiles(strSrc, &asDataList);
|
||||
const size_t uFilesToCopy = wxDir::GetAllFiles(strSrc, &asDemoList);
|
||||
wxString strFileCurr;
|
||||
const size_t nPathLenght = strSrc.Len();
|
||||
wxProgressDialog pi("Installazione Dati Demo...", "", (int)uFilesToCopy, NULL, wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_CAN_ABORT);
|
||||
wxProgressDialog pi("Installazione Versione Demo...", "", (int)uFilesToCopy, NULL, wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_CAN_ABORT);
|
||||
for (size_t i = 0; i < uFilesToCopy; i++)
|
||||
{
|
||||
if (!pi.Update((int)i, asDataList[i]))
|
||||
if (!pi.Update((int)i, asDemoList[i]))
|
||||
break;
|
||||
|
||||
asDataList[i].Lower();
|
||||
strFileCurr = strDataPath;
|
||||
strFileCurr += asDataList[i].Mid(nPathLenght);
|
||||
asDemoList[i].Lower();
|
||||
strFileCurr = strPrgLocPath;
|
||||
strFileCurr += asDemoList[i].Mid(nPathLenght);
|
||||
|
||||
if (!strFileCurr.IsEmpty())
|
||||
{
|
||||
strFileCurr.MakeLower();
|
||||
const wxFileName strFileName(strFileCurr);
|
||||
if (!CopyFilesAndDirs(asDemoList[i], strFileCurr, false))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const wxString strDir = strFileName.GetPath();
|
||||
if (!strDir.IsEmpty() && !wxDirExists(strDir))
|
||||
wxMkdir(strDir);
|
||||
//icona sul desktop
|
||||
const bool bDesktopShortcut = m_pWizard->GetDesktopShortcut();
|
||||
if (bDesktopShortcut)
|
||||
{
|
||||
const wxFileName strExe("c:/campodemo", wxT("ba0.exe"));
|
||||
CreateIcon(CSIDL_COMMON_DESKTOPDIRECTORY, strExe, "CampoDEMO");
|
||||
}
|
||||
|
||||
if(!wxCopyFile(asDataList[i], strFileCurr))
|
||||
//lanciare ba0.exe in uscita
|
||||
wxSetWorkingDirectory(strPrgLocPath);
|
||||
wxExecute("ba0");
|
||||
|
||||
}
|
||||
else //tutti i casi normali (std,server,client,aggiornamento)
|
||||
{
|
||||
// 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;
|
||||
//installazione servers? solo per server di campo
|
||||
const bool bInstallLurch = uInstallationType == 1 && (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());
|
||||
//installazione datidemo? (oddio speriamo di no!; comunque vale solo per installazione standard)
|
||||
const bool bInstallDemoData = uInstallationType == 0 && m_pWizard->GetInstDemoData();
|
||||
//cartelle selezionate dall'utente
|
||||
const wxString& strPrgLocPath = m_pWizard->GetPrgLocPath();
|
||||
const wxString& strDataPath = m_pWizard->GetDataPath();
|
||||
|
||||
//se nuova installazione deve anche creare la directory di destinazione
|
||||
if (bNewInstallation)
|
||||
{
|
||||
//creazione della directory dei programmi (compreso l'intero albero directory)
|
||||
CheckAndMakeDir(strPrgLocPath, "programmi");
|
||||
//creazione della directory dei dati (compreso l'intero albero directory)
|
||||
CheckAndMakeDir(strDataPath, "dati");
|
||||
}
|
||||
|
||||
|
||||
// 2) COPIA DEI FILES DI INSTALLAZIONE DALLA CARTELLA CAMPO (E SUBDIRS) (SU CD) ALLA CARTELLA DESTINAZIONE
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
//copia del contenuto della cartella campo nella cartella di destinazione (installaz/aggiornam)
|
||||
//per prima cosa cerca la cartella dei files sorgente...
|
||||
wxArrayString asFilesList;
|
||||
wxFileName strSourcePath(m_strSetupPath, "*.*");
|
||||
strSourcePath.AppendDir("..");
|
||||
strSourcePath.MakeAbsolute();
|
||||
//stringa inutile al programma ma decisiva per il programmatore
|
||||
const wxString strSrc = strSourcePath.GetPath();
|
||||
//..contando anche quanti sono e memorizzandoli in un array asFileList
|
||||
const size_t uFilesToCopy = wxDir::GetAllFiles(strSrc, &asFilesList);
|
||||
|
||||
//per ogni file da copiare controlla i path sorgente e destinazione(problema con sottodirectory tipo dati)
|
||||
wxString strFileCurr;
|
||||
const size_t nPathLenght = strSrc.Len();
|
||||
//progress bar
|
||||
wxProgressDialog pi("Installazione Dati e Programmi di base...", "", (int)uFilesToCopy, NULL, wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_CAN_ABORT);
|
||||
|
||||
for (size_t i = 0; i < uFilesToCopy; i++)
|
||||
{
|
||||
//aggiorna la progind
|
||||
if (!pi.Update((int)i, asFilesList[i]))
|
||||
break;
|
||||
//files dei dati standard! solo in caso di nuova installazione!!
|
||||
if (asFilesList[i].Lower().Find("\\dati\\") > 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)
|
||||
{
|
||||
wxString strErr = "Impossibile copiare il file ";
|
||||
strErr += asDataList[i];
|
||||
strErr += " in ";
|
||||
strErr += strFileCurr;
|
||||
strErr += "\nInstallazione interrotta!";
|
||||
ErrorBox(strErr);
|
||||
strFileCurr = strDataPath;
|
||||
strFileCurr += asFilesList[i].Mid(nPathLenght + 5);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//che fare con i servers? copiare la directory...
|
||||
if (asFilesList[i].Lower().Find("\\servers\\") > 0)
|
||||
{
|
||||
if (bInstallLurch) //..ma solo se devi installare i servers
|
||||
{
|
||||
strFileCurr = strPrgLocPath;
|
||||
strFileCurr += "\\servers";
|
||||
strFileCurr += asFilesList[i].Mid(nPathLenght + 8);
|
||||
}
|
||||
}
|
||||
else //files dei programmi
|
||||
{
|
||||
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())
|
||||
{
|
||||
//eventuali sottodirectory le crea (solo se hanno un nome) e poi copia fisicamente i files
|
||||
//se un file non si copia interrompe l'installazione con un ErrorBox
|
||||
if (!CopyFilesAndDirs(asFilesList[i], strFileCurr, true))
|
||||
break;
|
||||
} //if (!strFileCurr.IsEmpty()..
|
||||
} //for(size_t...
|
||||
|
||||
// 3) INSTALLAZIONE DATI DEMO
|
||||
//---------------------------
|
||||
//installazione dei dati dimostrativi (che schifo!).Non si puo' fare in aggiornamento!
|
||||
if (bInstallDemoData && uInstallationType < 3)
|
||||
{
|
||||
//trova la cartella datidemo da copiare
|
||||
wxArrayString asDataList;
|
||||
const wxString strSrc = GetSourceDir("datidemo");
|
||||
//conta i files da copiare e si lancia nell'operazione di copiatura...
|
||||
//Vale quanto detto per l'installazione dell'area dati
|
||||
const size_t uFilesToCopy = wxDir::GetAllFiles(strSrc, &asDataList);
|
||||
wxString strFileCurr;
|
||||
const size_t nPathLenght = strSrc.Len();
|
||||
wxProgressDialog pi("Installazione Dati Demo...", "", (int)uFilesToCopy, NULL, wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_CAN_ABORT);
|
||||
for (size_t i = 0; i < uFilesToCopy; i++)
|
||||
{
|
||||
if (!pi.Update((int)i, asDataList[i]))
|
||||
break;
|
||||
|
||||
asDataList[i].Lower();
|
||||
strFileCurr = strDataPath;
|
||||
strFileCurr += asDataList[i].Mid(nPathLenght);
|
||||
|
||||
if (!strFileCurr.IsEmpty())
|
||||
{
|
||||
//eventuali sottodirectory le crea (solo se hanno un nome) e poi copia fisicamente i files
|
||||
//se un file non si copia interrompe l'installazione con un ErrorBox
|
||||
if (!CopyFilesAndDirs(asDataList[i], strFileCurr, false))
|
||||
break;
|
||||
} //if (!strFileCurr.IsEmpty()..
|
||||
} //for (size_t i = 0...
|
||||
} //if(bInstallDemoData...
|
||||
|
||||
|
||||
// 4) COMPILAZIONE CAMPO.INI CON CONFIGURAZIONE NUOVA INSTALLAZIONE
|
||||
//-----------------------------------------------------------------
|
||||
//adesso deve compilare il campo.ini se nuova installazione..
|
||||
if (bNewInstallation)
|
||||
{
|
||||
{ //parentesi necessaria per la scrittura immediata (non cancellare! serve per debug)
|
||||
//paragrafo [Main]
|
||||
CampoIniFile CampoIniMain(strPrgLocPath + "/campo.ini", "Main");
|
||||
const unsigned int uDongleType = m_pWizard->GetDongleType();
|
||||
CampoIniMain.Set("Donglehw", uDongleType);
|
||||
CampoIniMain.Set("Study", strDataPath);
|
||||
CampoIniMain.Set("Firm", "com");
|
||||
//client o non client?
|
||||
if (uInstallationType == 2) //client
|
||||
{
|
||||
CampoIniMain.Set("TestDatabase", "N");
|
||||
CampoIniMain.Set("TestPrograms", "X");
|
||||
}
|
||||
else //altri (standard,server)
|
||||
{
|
||||
CampoIniMain.Set("TestDatabase", "X");
|
||||
CampoIniMain.Set("TestPrograms", "N");
|
||||
}
|
||||
}
|
||||
//paragrafo [Server]
|
||||
if (bInstallLurch || bUseLurch)
|
||||
{
|
||||
CampoIniFile CampoIniSrv(strPrgLocPath + "/campo.ini", "Server");
|
||||
CampoIniSrv.Set("Dongle", m_pWizard->GetSrvAuth());
|
||||
CampoIniSrv.Set("Dictionary", m_pWizard->GetSrvDict());
|
||||
}
|
||||
} //if(bNewInstallation...
|
||||
|
||||
|
||||
// 5) COMPILAZIONE\AGGIORNAMENTO INSTALL.INI CON DISKPATH
|
||||
//-------------------------------------------------------
|
||||
//..e modificare comunque l'install.ini aggiornando eventualmente l'origine dei programmi
|
||||
//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
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 6) CREAZIONE AUTOSTART DEI SERVERS (SE CI SONO)
|
||||
//------------------------------------------------
|
||||
//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();
|
||||
CreateAutostartMode(iSrvAutostartMode, strPrgLocPath);
|
||||
}
|
||||
|
||||
|
||||
// 7) AGGIORNAMENTO DEL MODULO SY CON EVENTUALI PATCH PRESENTI IN PROGRAM DEL CD E AGGIORNAMENTO INSTALL.INI
|
||||
//----------------------------------------------------------------------------------------------------------
|
||||
//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);
|
||||
|
||||
|
||||
// 8) CREAZIONE DELL'ICONA SUL DESKTOP
|
||||
//------------------------------------
|
||||
const bool bDesktopShortcut = m_pWizard->GetDesktopShortcut();
|
||||
if (bDesktopShortcut)
|
||||
{
|
||||
const wxFileName strExe(strPrgLocPath, wxT("ba0.exe"));
|
||||
CreateIcon(CSIDL_COMMON_DESKTOPDIRECTORY, strExe, "Campo");
|
||||
}
|
||||
|
||||
|
||||
// 9) AGGIORNAMENTO CAMPO.STP
|
||||
//---------------------------
|
||||
if (bNewInstallation)
|
||||
{
|
||||
//deve aggiungere la nuova installazione al campo.stp
|
||||
for (int i = 1;; i++)
|
||||
{
|
||||
wxString strGroup;
|
||||
strGroup << i;
|
||||
CampoIniFile CampoStp("C:\\campo.stp", strGroup);
|
||||
wxString strPath = CampoStp.Get("Program");
|
||||
if (strPath.IsEmpty())
|
||||
{
|
||||
CampoStp.Set("Program", strPrgLocPath);
|
||||
break;
|
||||
}
|
||||
} //if (!strFileCurr.IsEmpty()..
|
||||
} //for (size_t i = 0...
|
||||
} //if(bInstallDemoData...
|
||||
|
||||
|
||||
// 4) COMPILAZIONE CAMPO.INI CON CONFIGURAZIONE NUOVA INSTALLAZIONE
|
||||
//-----------------------------------------------------------------
|
||||
//adesso deve compilare il campo.ini se nuova installazione..
|
||||
if (bNewInstallation)
|
||||
{
|
||||
{ //parentesi necessaria per la scrittura immediata (non cancellare! serve per debug)
|
||||
//paragrafo [Main]
|
||||
CampoIniFile CampoIniMain(strPrgLocPath + "/campo.ini", "Main");
|
||||
const unsigned int uDongleType = m_pWizard->GetDongleType();
|
||||
CampoIniMain.Set("Donglehw", uDongleType);
|
||||
CampoIniMain.Set("Study", strDataPath);
|
||||
CampoIniMain.Set("Firm", "com");
|
||||
//client o non client?
|
||||
if (uInstallationType == 2) //client
|
||||
{
|
||||
CampoIniMain.Set("TestDatabase", "N");
|
||||
CampoIniMain.Set("TestPrograms", "X");
|
||||
}
|
||||
else //altri (standard,server)
|
||||
{
|
||||
CampoIniMain.Set("TestDatabase", "X");
|
||||
CampoIniMain.Set("TestPrograms", "N");
|
||||
}
|
||||
}
|
||||
//paragrafo [Server]
|
||||
if (bInstallLurch || bUseLurch)
|
||||
{
|
||||
CampoIniFile CampoIniSrv(strPrgLocPath + "/campo.ini", "Server");
|
||||
CampoIniSrv.Set("Dongle", m_pWizard->GetSrvAuth());
|
||||
CampoIniSrv.Set("Dictionary", m_pWizard->GetSrvDict());
|
||||
}
|
||||
} //if(bNewInstallation...
|
||||
|
||||
|
||||
// 10) CHIUDE IL SETUP LANCIANDO BA1 -6 PER INSTALLAZIONE MODULI
|
||||
//-------------------------------------------------------------
|
||||
//lanciare ba1.exe -6 in uscita
|
||||
wxSetWorkingDirectory(strPrgLocPath);
|
||||
wxExecute("ba1 -6 /uADMIN");
|
||||
|
||||
// 5) COMPILAZIONE\AGGIORNAMENTO INSTALL.INI CON DISKPATH
|
||||
//-------------------------------------------------------
|
||||
//..e modificare comunque l'install.ini aggiornando eventualmente l'origine dei programmi
|
||||
//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
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 6) CREAZIONE AUTOSTART DEI SERVERS (SE CI SONO)
|
||||
//------------------------------------------------
|
||||
//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();
|
||||
CreateAutostartMode(iSrvAutostartMode, strPrgLocPath);
|
||||
}
|
||||
|
||||
|
||||
// 7) AGGIORNAMENTO DEL MODULO SY CON EVENTUALI PATCH PRESENTI IN PROGRAM DEL CD E AGGIORNAMENTO INSTALL.INI
|
||||
//----------------------------------------------------------------------------------------------------------
|
||||
//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);
|
||||
|
||||
|
||||
// 8) CREAZIONE DELL'ICONA SUL DESKTOP
|
||||
//------------------------------------
|
||||
const wxFileName strExe(strPrgLocPath, wxT("ba0.exe"));
|
||||
const bool bDesktopShortcut = m_pWizard->GetDesktopShortcut();
|
||||
if (bDesktopShortcut)
|
||||
CreateIcon(CSIDL_COMMON_DESKTOPDIRECTORY, strExe);
|
||||
|
||||
|
||||
// 9) AGGIORNAMENTO CAMPO.STP
|
||||
//---------------------------
|
||||
if (bNewInstallation)
|
||||
{
|
||||
//deve aggiungere la nuova installazione al campo.stp
|
||||
for (int i = 1;; i++)
|
||||
{
|
||||
wxString strGroup;
|
||||
strGroup << i;
|
||||
CampoIniFile CampoStp("C:\\campo.stp", strGroup);
|
||||
wxString strPath = CampoStp.Get("Program");
|
||||
if (strPath.IsEmpty())
|
||||
{
|
||||
CampoStp.Set("Program", strPrgLocPath);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 10) CHIUDE IL SETUP LANCIANDO BA1 -6 PER INSTALLAZIONE MODULI
|
||||
//-------------------------------------------------------------
|
||||
//lanciare ba1.exe -6 in uscita (non va qui! e' solo per ricordarsi di farlo!)
|
||||
wxSetWorkingDirectory(strPrgLocPath);
|
||||
wxExecute("ba1 -6 /uADMIN");
|
||||
|
||||
} //if (m_pWizard->Run())...
|
||||
m_pWizard->Destroy();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user