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:
luca 2007-09-19 14:47:17 +00:00
parent fc720f99ec
commit 47aedad7c5

View File

@ -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
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,7 +1487,16 @@ bool CampoWizardPage10::TransferDataToWindow()
else //Installazione
{
strTitle += wxT("INSTALLAZIONE: riepilogo configurazione");
//DEMO (aaarrgh!)
if (cw.GetInstDemoVersion())
{
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: ");
@ -1443,6 +1509,7 @@ bool CampoWizardPage10::TransferDataToWindow()
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
//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,7 +2327,60 @@ void CampoSetup::OnTimer(wxTimerEvent& WXUNUSED(e))
if (m_pWizard->Run())
{
//e' una DEMO o una versione normale?
const bool bInstallDemoVersion = m_pWizard->GetInstDemoVersion();
// 0) INSTALLAZIONE VERSIONE DEMO (SIETE PAZZI?)
//----------------------------------------------
if (bInstallDemoVersion)
{
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");
CheckAndMakeDir(strDataPath, "dati");
CheckAndMakeDir(strHelpPath, "help");
//copia della campodemo sull'hard disk in c:\campodemo
wxArrayString asDemoList;
const wxString strSrc = GetSourceDir("campodemo");
const size_t uFilesToCopy = wxDir::GetAllFiles(strSrc, &asDemoList);
wxString strFileCurr;
const size_t nPathLenght = strSrc.Len();
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, asDemoList[i]))
break;
asDemoList[i].Lower();
strFileCurr = strPrgLocPath;
strFileCurr += asDemoList[i].Mid(nPathLenght);
if (!strFileCurr.IsEmpty())
{
if (!CopyFilesAndDirs(asDemoList[i], strFileCurr, false))
break;
}
}
//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");
}
//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
@ -2239,7 +2421,7 @@ void CampoSetup::OnTimer(wxTimerEvent& WXUNUSED(e))
//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();
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);
@ -2263,10 +2445,10 @@ void CampoSetup::OnTimer(wxTimerEvent& WXUNUSED(e))
}
else
{
//che fare con i servers? copiare la directory..potrebbe servire
//che fare con i servers? copiare la directory...
if (asFilesList[i].Lower().Find("\\servers\\") > 0)
{
if (bInstallLurch)
if (bInstallLurch) //..ma solo se devi installare i servers
{
strFileCurr = strPrgLocPath;
strFileCurr += "\\servers";
@ -2283,32 +2465,10 @@ void CampoSetup::OnTimer(wxTimerEvent& WXUNUSED(e))
//..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);
//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...
@ -2337,23 +2497,10 @@ void CampoSetup::OnTimer(wxTimerEvent& WXUNUSED(e))
if (!strFileCurr.IsEmpty())
{
strFileCurr.MakeLower();
const wxFileName strFileName(strFileCurr);
const wxString strDir = strFileName.GetPath();
if (!strDir.IsEmpty() && !wxDirExists(strDir))
wxMkdir(strDir);
if(!wxCopyFile(asDataList[i], strFileCurr))
{
wxString strErr = "Impossibile copiare il file ";
strErr += asDataList[i];
strErr += " in ";
strErr += strFileCurr;
strErr += "\nInstallazione interrotta!";
ErrorBox(strErr);
//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...
@ -2430,10 +2577,12 @@ void CampoSetup::OnTimer(wxTimerEvent& WXUNUSED(e))
// 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);
{
const wxFileName strExe(strPrgLocPath, wxT("ba0.exe"));
CreateIcon(CSIDL_COMMON_DESKTOPDIRECTORY, strExe, "Campo");
}
// 9) AGGIORNAMENTO CAMPO.STP
@ -2458,10 +2607,12 @@ void CampoSetup::OnTimer(wxTimerEvent& WXUNUSED(e))
// 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!)
//lanciare ba1.exe -6 in uscita
wxSetWorkingDirectory(strPrgLocPath);
wxExecute("ba1 -6 /uADMIN");
}
} //if (m_pWizard->Run())...
m_pWizard->Destroy();