#include "wxinc.h" #include "key.h" #include "wizard.h" #define HGAP 4 #define VGAP 2 //////////////////////////////////////////////////////////////////////////////////////////// //Campo wizard page (pagina generica del programma, di cui saranno figlie le singole pagine) class CampoWizardPage : public wxWizardPageSimple { protected: wxHtmlWindow* m_pText; CampoWizard& GetWizard() const {return *(CampoWizard*)GetParent();} void SetHTMLText(const wxString strTitle, const wxString strBody); void SetHTMLPage(const wxString strFile); wxString Bold(const wxString strStr) const; void AddLabel(wxSizer* pSizer, const wxChar* label); void AddLabel(wxGridBagSizer* pSizer, const wxChar* label, unsigned int row, unsigned int column); bool CheckDataDir(wxString strDataPath) const; void CheckCustomDir(const wxString strCustomPath, const wxString& strPrgPath, wxArrayString& asPersonalizedFiles) const; bool CheckPrgDir(const wxString& strPrgPath) const; wxControl* FindControlById(wxWindowID id) const; public: virtual bool ForwardValidate() { return true; } wxString Get(wxWindowID id) const; bool GetBool(wxWindowID id) const; bool Set(wxWindowID id, const wxString& str); bool Set(wxWindowID id, bool bOk); int GetSelection(wxWindowID id) const; CampoWizardPage(wxWizard* parent); }; wxControl* CampoWizardPage::FindControlById(wxWindowID id) const { wxWindow* pWnd = FindWindowById(id, this); return wxDynamicCast(pWnd, wxControl); } wxString CampoWizardPage::Get(wxWindowID id) const { wxControl* pWnd = FindControlById(id); if (pWnd != NULL) { wxTextCtrl* pText = wxDynamicCast(pWnd, wxTextCtrl); if (pText != NULL) return pText->GetValue(); } return pWnd ? pWnd->GetLabelText() : wxEmptyString; } bool CampoWizardPage::GetBool(wxWindowID id) const { wxCheckBox* pWnd = wxDynamicCast(FindControlById(id), wxCheckBox); return pWnd != NULL && pWnd->GetValue(); } bool CampoWizardPage::Set(wxWindowID id, const wxString& str) { wxControl* pWnd = FindControlById(id); if (pWnd) { wxTextCtrl* pText = wxDynamicCast(pWnd, wxTextCtrl); if (pText != NULL) pText->ChangeValue(str); else pText->SetLabel(str); } return (pWnd != NULL); } bool CampoWizardPage::Set(wxWindowID id, const bool bul) { wxCheckBox* pWnd = wxDynamicCast(FindControlById(id), wxCheckBox); if (pWnd) pWnd->SetValue(bul); return (pWnd != NULL); } int CampoWizardPage::GetSelection(wxWindowID id) const { int n = -1; wxWindow* pWnd = FindControlById(id); if (pWnd) { wxChoice* pList = wxDynamicCast(pWnd, wxChoice); if (pList != NULL) n = pList->GetSelection(); else { wxRadioBox* pRadio = wxDynamicCast(pWnd, wxRadioBox); if (pRadio != NULL) n = pRadio->GetSelection(); } } return n; } void CampoWizardPage::SetHTMLPage(const wxString strFile) { m_pText->LoadPage(strFile); } //parte html della finestra standard void CampoWizardPage::SetHTMLText(wxString strTitle, wxString strBody) { wxString strAppNameFull = wxT(""); strAppNameFull += Bold(PRODUCT); strAppNameFull += wxT(""); wxString strAppName = APPNAME; strTitle.Replace(wxT("PRODUCT"), strAppNameFull); strBody.Replace(wxT("PRODUCT"), strAppNameFull); strTitle.Replace(wxT("APPNAME"), strAppName); strBody.Replace(wxT("APPNAME"), strAppName); wxString str; str += wxT("
"); str += wxT(""); str += strTitle; str += wxT("
"); str += wxT("Questo programma vi guiderà passo a passo nell'installazione / aggiornamento del software.
"); strBody += wxT("LEGGERE ATTENTAMENTE LE ISTRUZIONI che saranno visualizzate nelle finestre di questo programma di installazione!
"); strBody += wxT("Prima di proseguire con l'installazione / aggiornamento assicurarsi:
"); strBody += wxT("1) di avere effettuato il login a Windows con un utente di tipo 'Amministratore' di sistema.
"); strBody += wxT("2) di avere terminato ogni altro programma in funzione
"); strBody += wxT("In caso di aggiornamento assicurarsi inoltre:
"); strBody += wxT("3) di avere effettuato un backup di sicurezza dei dati.
"); strBody += wxT("4) che il programma PRODUCT NON sia in funzione.
"); strBody += wxT("5) che l'eventuale gestore dei servizi di PRODUCT, se presente, NON sia in funzione.
"); SetHTMLText(strTitle, strBody); //mette a video una stringa con la data di realizzazione di setup.exe wxString strSetupVersion = __TIMESTAMP__; //testo con giornodataora wxSize szSizer = m_pText->GetSize(); szSizer.y = -1; wxStaticText* stText = new wxStaticText (this, wxID_ANY, strSetupVersion, wxDefaultPosition, szSizer, wxALIGN_RIGHT); GetSizer()->Add(stText); } /**********************************************************************************************************/ // 2 Pagina con Accetta / Rifiuta la licenza //*********************************************************************************************************/ class CampoWizardPage2 : public CampoWizardPage { protected: virtual bool ForwardValidate(); public: CampoWizardPage2(wxWizard* parent); }; bool CampoWizardPage2::ForwardValidate() { if (GetSelection(201) == 1) return ErrorBox("Impossibile proseguire se non si accetta la licenza sul software!!"); return true; } CampoWizardPage2::CampoWizardPage2(wxWizard* parent) : CampoWizardPage(parent) { //nome del file di licenza settato in html e recuperato con apposita mitica funzione SetHTMLPage(Licence()); //radiobutton Accetta / Rifiuta wxArrayString asAccRef; asAccRef.Add("Accetta"); asAccRef.Add("Rifiuta"); wxRadioBox* radio_box = new wxRadioBox(this, 201, "Selezionare 'Accetta' per proseguire con l'installazione, 'Rifiuta' per terminare l'installazione", wxDefaultPosition, wxDefaultSize, asAccRef, 0, wxRA_SPECIFY_COLS); radio_box->SetSelection(1); GetSizer()->Add(radio_box); } /**********************************************************************************************************/ /* 3 Pagina con la scelta di Aggiornamento / Tipo Installazione */ /**********************************************************************************************************/ class CampoWizardPage3 : public CampoWizardPage { wxRadioBox* m_pRadioBox; 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 { const wxString ssa = wxFindFirstFile("*.ssa"); return !ssa.IsEmpty(); } bool CampoWizardPage3::ForwardValidate() { const int iLastRow = m_pRadioBox->GetRowCount() - 1; const int iSelectedRow = m_pRadioBox->GetSelection(); wxString strPrgPath; wxString strSrvAuth; wxString strSrvDict; //AGGIORNAMENTO //------------- //analizza il campo.ini dell'installazione selezionata (si usa < perche' l'ultima row è la nuova installazione!) if (iSelectedRow < iLastRow) { strPrgPath = m_pRadioBox->GetStringSelection().BeforeLast('('); strPrgPath.Trim(); CampoIniFile CampoIni(strPrgPath + "/campo.ini", "Main"); //cerca il tipo dell'installazione InstallationType nType = CampoIni.GetInstallationType(); //se risulta un client... if (nType == it_client) { CampoIniFile InstallIni(strPrgPath + "/install.ini", "Main"); wxString strDiskPath = InstallIni.Get("DiskPath"); wxString strMsg = "Per aggiornare questa stazione di lavoro è necessario aggiornare prima il Server di "; strMsg << PRODUCT << " in " << strDiskPath << " !\n"; strMsg << "Questa stazione di lavoro si aggiornerà automaticamente alla prima esecuzione del programma " << PRODUCT; return ErrorBox(strMsg); } wxString strStudy = CampoIni.Get("Study"); { CampoIniFile CampoServerIni(strPrgPath + "/campo.ini", "Server"); strSrvAuth = CampoServerIni.Get("Dongle"); strSrvDict = CampoServerIni.Get("Dictionary"); } //controlla l'area dati e le eventuali custom directory area dati bool bDataOk = false; //controlla anche se l'installazione è in remoto con dati in locale (errore! è il caso in cui si abbia un.. //..server remoto con il campo.ini scazzato che indica una dir locale del server!! const int nDriveType = ::GetDriveType(strPrgPath.Left(3)); const bool bRemoteDestination = nDriveType == DRIVE_REMOTE; if (bRemoteDestination) { const bool bRemoteStudy = ::GetDriveType(strStudy.Left(3)) == DRIVE_REMOTE; if (!bRemoteStudy) strStudy[0] = strPrgPath[0]; bDataOk = CheckDataDir(strStudy); //se anche cambiando il drive (lo mette = a quello dei programmi perchè statisticamente è ok) la directory.. //..contenente i dati è farlocca, lo chiede all'utonto if (!bDataOk) { wxDirDialog dirD(this, "Selezionare la cartella contenente i dati", strStudy, wxDD_DEFAULT_STYLE|wxDD_DIR_MUST_EXIST); if (dirD.ShowModal() == wxID_OK) { strStudy = dirD.GetPath(); bDataOk = CheckDataDir(strStudy); } } //se riesce a trovare la corretta directory dei dati la setta nel campo.ini onde non ripetere tutto 'sto casino.. //..ogni volta che deve accedervi if (bDataOk) CampoIni.Set("Study", strStudy); } else bDataOk = CheckDataDir(strStudy); //se la directory dei dati è definitivamente farlocca (o l'utonto mente spudoratamente) allora errore! if (!bDataOk) return ErrorBox("La cartella indicata come area dati NON è valida!\nInterrompere l'installazione e selezionare un'area dati valida\nper il programma"); //custom directories wxArrayString asPersonalizedFiles; //a) custom di studio CheckCustomDir(strStudy + "custom", strPrgPath, asPersonalizedFiles); //b) custom di ditta wxDir dirStudy(strStudy); wxString strDir; //deve farsi un giro sulle sole directory che abbiano nome lungo 6 caratteri (sono le ditte) for (bool ok = dirStudy.GetFirst(&strDir, wxT("??????"), wxDIR_DIRS); ok; ok = dirStudy.GetNext(&strDir)) { strDir.MakeLower(); if (strDir.EndsWith("a") && atol(strDir) > 0) CheckCustomDir(strStudy + strDir + "/custom", strPrgPath, asPersonalizedFiles); } //c) custom locale CheckCustomDir(strPrgPath + "/custom", strPrgPath, asPersonalizedFiles); //se ci sono files personalizzati pericolosi avverte l'utente ed interrompe l'aggiornamento!! if (asPersonalizedFiles.GetCount() > 0) { //finestra con la lista dei files personalizzati wxDialog dlgList(NULL, wxID_ANY, wxString("Lista files personalizzati"), wxDefaultPosition); wxBoxSizer* pSizer = new wxBoxSizer(wxVERTICAL); //testo con il fatale annuncio per l'utonto wxStaticText* stText = new wxStaticText (&dlgList, 100, "Sono presenti personalizzazioni create per una " "precedente versione del programma.\nE' necessario richiedere l'intervento dell'assistenza tecnica" ".\nImpossibile proseguire l'aggiornamento! Salvare la lista e ANNULLARE l'aggiornamento"); pSizer->Add(stText, 0, wxALL, 5); //lista dei file pericolosi wxListBox* lbList = new wxListBox(&dlgList, 101, wxDefaultPosition, wxSize(480, 320), asPersonalizedFiles); pSizer->Add(lbList, 0, wxALL, 5); //bottone di conferma wxButton* buOk = new wxButton(&dlgList, wxID_OK, "Salva lista", wxDefaultPosition, wxSize(96,-1)); pSizer->Add(buOk, 0, wxALL|wxALIGN_CENTRE, 5); dlgList.SetSizerAndFit(pSizer); dlgList.Centre(); dlgList.ShowModal(); //finestra per il salvataggio della lista in un file di testo wxFileDialog fdSave(NULL, "Selezionare la cartella dove salvare la lista", wxEmptyString, "listapers.txt", "*.txt", wxFD_SAVE|wxFD_OVERWRITE_PROMPT); if (fdSave.ShowModal() == wxID_OK) { const wxString strFileName = fdSave.GetPath(); wxTextFile tfLista(strFileName); //aggiunge i files della lista al file di testo for (size_t i = 0; i < asPersonalizedFiles.GetCount(); i++) tfLista.AddLine(asPersonalizedFiles[i]); //scrive 'sto benedetto file di testo! tfLista.Write(); } //blocca l'aggiornamento return false; } //se ha superato i severi controlli prosegue GetWizard().SetDataPath(strStudy); if (!strSrvAuth.IsEmpty()) GetWizard().SetSrvAuth(strSrvAuth); if (!strSrvDict.IsEmpty()) GetWizard().SetSrvDict(strSrvDict); //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(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 { //NUOVA INSTALLAZIONE //------------------- //questo lo fa in ogni caso! GetWizard().SetDestinationPath(""); GetWizard().SetDesktopShortcut(true); } return true; } CampoWizardPage3::CampoWizardPage3(wxWizard* parent) : CampoWizardPage(parent) { //deve cercare campo.stp CampoIniFile iniCampoStp("C:\\campo.stp", ""); wxString strGroup; long nIndex; const wxString strProgram = "Program"; wxArrayString asGroups, asCampi; //cerca se esiste campo.stp;se lo trova cerca quelle che sono le installazioni valide;se ne trova.. //..le aggiunge ad un array di stringhe (asCampi) da cui genera un radiobutton di scelte for (bool ok = iniCampoStp.GetFirstGroup(strGroup, nIndex); ok; ok = iniCampoStp.GetNextGroup(strGroup, nIndex)) { asGroups.Add(strGroup); } int prechecked = -1; for (int i = 0; i < (int)asGroups.GetCount(); i++) { CampoIniFile iniCampoStp("C:\\campo.stp", asGroups[i]); wxString strPath = iniCampoStp.Get(strProgram); //sono installazioni valide quelle che passano il vaglio della CheckPrgdir, metodo che testa l'integrità.. //..di una cartella programmi di campo if (CheckPrgDir(strPath)) { //controlla il tipo di installazione rilevata (Standalone,Server,Client) CampoIniFile iniCampo(strPath + "/campo.ini", "Main"); const InstallationType nType = iniCampo.GetInstallationType(); switch (nType) { case it_server: strPath << " (Server)"; break; case it_client: strPath << " (Client)"; break; default: strPath << " (Standard)"; break; } asCampi.Add(strPath); //prechecca l'eventuale installazione server o standalone se ci sono piu' installazioni.. //..sulla stessa macchina if (prechecked < 0) { if (nType == it_standalone || nType == it_server) prechecked = i; } } //if(CheckPrgDir(strPath)... else //se una installazione su campo.stp non è buona cancella la voce da campo.stp stesso.. //..per non fare casini in futuro { wxString strGroup = "/"; strGroup += asGroups[i]; iniCampoStp.DeleteGroup(strGroup); } } //for(unsigned int i=0... wxString strTitle, strBody; //se non ci sono delle installazioni da aggiornare propone solo installazioni.. if (asCampi.IsEmpty()) { strTitle += wxT("Scelta Installazione"); strBody += wxT("E' possibile INSTALLARE PRODUCT in una nuova cartella.
"); asCampi.Add("Nuova installazione"); //voce di nuova installazione! m_pRadioBox = new wxRadioBox(this, 301, "Installazione del software", wxDefaultPosition, wxDefaultSize, asCampi, 0, wxRA_SPECIFY_ROWS); } //..senno' propone di aggiornare else { strTitle += wxT("Scelta Aggiornamento / Installazione"); strBody += wxT("E' possibile AGGIORNARE (scelta consigliata) una installazione di PRODUCT già presente oppure INSTALLARE in una nuova cartella.
"); strBody += wxT("Selezionare l'opzione desiderata nel riquadro sottostante. In caso di più d'una installazione presente sul computer "); strBody += wxT("sarà preselezionata la eventuale installazione di tipo Server o Standard, in quanto deve essere aggiornata per prima! "); strBody += wxT("
In questo caso procedere all'aggiornamento di tale installazione Server e aggiornare successivamente le postazioni client "); strBody += wxT("lanciando il programma PRODUCT su di esse
"); //radiobutton con le scelte aggiornamento 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) m_pRadioBox->SetSelection(prechecked); } GetSizer()->Add(m_pRadioBox); SetHTMLText(strTitle, strBody); } /**********************************************************************************************************/ /* 4 Pagina con la gestione della chiave di protezione */ /**********************************************************************************************************/ class CampoWizardPage4 : public CampoWizardPage { protected: DECLARE_EVENT_TABLE(); void OnHLPick(wxCommandEvent& e); void OnEUPick(wxCommandEvent& e); void OnSRPick(wxCommandEvent& e); void OnSSAPick(wxCommandEvent& e); virtual bool ForwardValidate(); virtual bool TransferDataToWindow(); wxString DecodeString(const wxString& data); int VersionYear(); void BuildKey(char* key); public: int DongleTest(unsigned short& serno); CampoWizardPage4(wxWizard* parent); }; //metodi per la gestione dei bottoni per l'esecuzione dei programmi di installazione delle chiavi BEGIN_EVENT_TABLE(CampoWizardPage4, CampoWizardPage) EVT_BUTTON(403, OnSRPick) EVT_BUTTON(405, OnSSAPick) END_EVENT_TABLE() void CampoWizardPage4::OnHLPick(wxCommandEvent& e) { wxString path("../../chiavi/hardlock/hldrv32.exe"); wxExecute(path, wxEXEC_SYNC); } void CampoWizardPage4::OnEUPick(wxCommandEvent& e) { wxString path("../../chiavi/eutron/sdi.exe"); wxExecute(path, wxEXEC_SYNC); } void CampoWizardPage4::OnSRPick(wxCommandEvent& e) { static bool bSemaforo = false; if (!bSemaforo) { bSemaforo = true; wxBusyCursor hourglass; wxString strSrvName; int year = 0; unsigned short serno = ServerLogin(year, strSrvName); if (!strSrvName.IsEmpty()) Set(404, strSrvName); bSemaforo = false; } } static wxString GetSetupDir() { TCHAR str[_MAX_PATH]; ::GetModuleFileName(NULL, str, _MAX_PATH); wxFileName n(str); n.MakeAbsolute(); return n.GetPath(); } void CampoWizardPage4::OnSSAPick(wxCommandEvent& e) { wxString strSSA = wxFindFirstFile("*.ssa"); if (strSSA.IsEmpty()) { wxString path = GetSetupDir(); path += "\\SSAGetInfo.exe"; const long err = wxExecute(path, wxEXEC_SYNC); if (err >= 0) { path = GetSetupDir(); path += "\\*.ssax"; strSSA = wxFindFirstFile(path); if (wxFileName::FileExists(strSSA)) { wxString msg = _T("Spedire il file \""); msg += strSSA; msg += _T("\" ad \"abilitazioni_software@sirio-is.it\" per ottenere la licenza da copiare nella cartella di destinazione."); WarningBox(msg); } else ErrorBox(_T("Non è stato possibile generare il file di richiesta licenza ") + strSSA); } else ErrorBox(_T("Impossibile eseguire ") + path); } else MessageBox(_T("Chiave sofwtare rilevata ") + strSSA); } bool CampoWizardPage4::ForwardValidate() { //per poter proseguire deve aver trovato una chiave o un server! GetWizard().SetSrvAuth(Get(404)); unsigned short serno = 0xFFFF; int nDongleType = DongleTest(serno); if (nDongleType == 0) { if (wxDirExists("c:/campodemo")) return ErrorBox(wxT("Non è stata rilevata alcuna chiave di protezione e la versione DEMO è già presente in C:\\CampoDemo")); //return ErrorBox("Per proseguire è NECESSARIO installare una chiave locale o collegarsi ad una chiave di rete!"); kazzone const bool bDemo = YesNoBox("Non è stata rilevata alcuna chiave di protezione locale e/o di rete!\n" "E' possibile installare solo la versione DEMO del software!\n" "Proseguire con installazione DEMO?"); if (bDemo) { GetWizard().SetInstDemoVersion(true); const wxString strPrgDemo = "c:/campodemo"; GetWizard().SetPrgLocPath(strPrgDemo); GetWizard().SetDataPath(strPrgDemo + "/datidemo"); GetWizard().SetInstallationType(it_standalone); } else return false; } else { GetWizard().SetInstDemoVersion(false); GetWizard().SetInstallationType(it_none); GetWizard().SetPrgLocPath(wxEmptyString); GetWizard().SetDataPath(wxEmptyString); } return true; } bool CampoWizardPage4::TransferDataToWindow() { FindWindowById(403)->Disable(); FindWindowById(404)->Disable(); FindWindowById(405)->Disable(); //controlla preventivamente se la chiave c'e' ed eventualmente quale è (hardlock,eutron,server di chiavi) unsigned short serno = 0xFFFF; const int nDongleType = DongleTest(serno); GetWizard().SetDongleType(nDongleType); wxString strTitle = wxT("Controllo della chiave software di protezione"); wxString strBody = wxT("La versione commerciale del software richiede l'installazione e la presenza della chiave software di protezione
"); switch (nDongleType) { case 3: strBody += wxT("E' stato rilevata una chiave remota condivisa in rete con il servizio di gestione autorizzazioni:
"); strBody += wxT("Si puo' procedere con l'installazione /aggiornamento del software PRODUCT. Premere il pulsante \"Avanti\".
"); Set(404, GetWizard().GetSrvAuth()); break; case 4: strBody += wxT("E' stata rilevata la chiave #SERNO di tipo SSA:
"); strBody += wxT("Si puo' procedere con l'installazione /aggiornamento del software PRODUCT. Premere il pulsante \"Avanti\".
"); break; default: strBody += wxT("Non è stata rilevata alcuna chiave software installata sul computer!
"); strBody += wxT("Per procedere all'installazione della chiave, copiare il file con estensione '.ssa' ricevuto da Sirio nella cartella di destinazione.
"); strBody += wxT("Se si utilizza una chiave remota, digitare il nome del computer "); strBody += wxT("(o l'indirizzo IP) su cui è installato e attivo il gestore di autorizzazioni. "); FindWindowById(403)->Enable(); FindWindowById(404)->Enable(); FindWindowById(405)->Enable(); break; } if (strBody.Find("#SERNO") > 0) { wxString sn; sn << serno; strBody.Replace("#SERNO", sn); } SetHTMLText(strTitle, strBody); return true; } void CampoWizardPage4::BuildKey(char* key) { for (int i = 0; i < 8; i++) key[i] = 'A'+ rand()%26; } wxString CampoWizardPage4::DecodeString(const wxString& data) { char key[8] = ""; BuildKey(key); char tmp[256]; int i; for (i = 0; data[i]; i++) tmp[i] = data[i] - (i < 8 ? key[i] : tmp[i - 8]); tmp[i] = '\0'; return tmp; } int CampoWizardPage4::VersionYear() { char ver[32]; ::GetPrivateProfileString("ba", "Versione", "", ver, sizeof(ver), "../install.ini"); ver[4] = '\0'; return atoi(ver); } int CampoWizardPage4::DongleTest(unsigned short& serno) { int dongle_type = 0; int yearKey = 0; serno = 0xFFFF; wxString strSrvName = GetWizard().GetSrvAuth(); //nome del server di autorizzazioni (se c'e') if (!strSrvName.IsEmpty()) { serno = ServerLogin(yearKey, strSrvName); if (serno != 0xFFFF) dongle_type = 3; //chiave remota } if (serno == 0xFFFF) { serno = DongleLogin(yearKey); if (serno != 0xFFFF) dongle_type = 4; //chiave software } return dongle_type; } CampoWizardPage4::CampoWizardPage4(wxWizard* parent) : CampoWizardPage(parent) { //procedura per la costruzione dei bottoni e delle immagini per l'installazione dei driver di chiave //"griglia" contenitrice degli oggetti //griglia per sistemare i campi wxGridBagSizer* gbsButtSizer = new wxGridBagSizer(VGAP, HGAP); GetSizer()->Add(gbsButtSizer); //terza riga della griglia //SSA label AddLabel(gbsButtSizer, "Installa licenza software", 2, 0); //SSA image wxBitmap bmp_SSA("ssa.gif", wxBITMAP_TYPE_GIF); wxStaticBitmap* s_bmp_SSA = new wxStaticBitmap(this, wxID_ANY, bmp_SSA); gbsButtSizer->Add(s_bmp_SSA, wxGBPosition(2, 1)); //bottone Eutron wxButton* bSSAButton = new wxButton(this, 405, wxT("SSA"), wxDefaultPosition, wxSize(64, -1)); gbsButtSizer->Add(bSSAButton, wxGBPosition(2, 2), wxDefaultSpan, wxALIGN_CENTER_VERTICAL); //ultima riga della griglia //Server label AddLabel(gbsButtSizer, "Nome o indirizzo IP del server di autorizzazioni", 3, 0); //nome Server wxTextCtrl* tcSrvName = new wxTextCtrl(this, 404, "", wxDefaultPosition, wxSize(128,-1)); gbsButtSizer->Add(tcSrvName, wxGBPosition(3, 1)); //bottone Eutron wxButton* bSrvButton = new wxButton(this, 403, wxT("Cerca"), wxDefaultPosition, wxSize(64, -1)); gbsButtSizer->Add(bSrvButton, wxGBPosition(3, 2), wxDefaultSpan, wxALIGN_CENTER_VERTICAL); } /**********************************************************************************************************/ // 5 Scelta tipo installazione /**********************************************************************************************************/ class CampoWizardPage5 : public CampoWizardPage { wxRadioBox* m_pRadioBox; protected: virtual bool ForwardValidate(); public: CampoWizardPage5(wxWizard* parent); }; bool CampoWizardPage5::ForwardValidate() { // controlla il tipo di installazione! InstallationType nType = InstallationType(m_pRadioBox->GetSelection() + 1); GetWizard().SetInstallationType(nType); return true; } CampoWizardPage5::CampoWizardPage5(wxWizard* parent) : CampoWizardPage(parent) { //chiede al sistema la versione di windows int nVersion = 0; bool bIsServer = false; ::GetWinVer(NULL, 0, nVersion, bIsServer); //Istruzioni per l'uso! wxString strTitle = wxT("Scelta del tipo di installazione"); wxString strBody; strBody = wxT("
Standard (scelta consigliata). Installazione su postazione singola, con programmi e dati sul disco locale del computer
"); strBody += wxT("Installazioni di rete (per utenti esperti)
"); strBody += wxT("Server: Computer in rete sul quale sono presenti una copia, utilizzata o meno, dei programmi (server programmi) e l’area dati (server dati). "); strBody += wxT("In una installazione in rete di PRODUCT è necessario sia presente un unica postazione di tipo server, "); strBody += wxT("e deve essere installata per prima!
"); strBody += wxT("Client: Computer in rete sul quale è presente una copia dei programmi ma non l'area dati. "); strBody += wxT("I client possono essere installati solo dopo l'installazione del server!
"); //sistema multissesione remoto (win2003srv etc.) if (nVersion == W2003 || nVersion == W2008) { strBody += wxT(""); strBody += wxT("E' stata rilevata una versione di Windows che consente sessioni remote (es. Windows 2008 Server)
"); strBody += wxT("Questa versione di Windows supporta un ulteriore tipo di installazione di PRODUCT:
"); strBody += wxT("Terminal Server: L'installazione è unica e viene utilizzata dagli utenti di sistema quando aprono una sessione sul server."); strBody += wxT("In questo caso e' necessario scegliere l'installazione Server ed installare il gestore delle autorizzazioni!"); strBody += wxT("ATTENZIONE! Selezionare l'installazione tipo Terminal Server solo se necessario!
"); } SetHTMLText(strTitle, strBody); //radiobutton con i tipi di installazione wxArrayString asInstType; asInstType.Add("Standard"); asInstType.Add("Server"); asInstType.Add("Client"); m_pRadioBox = new wxRadioBox(this, 501, "Selezionare il tipo di installazione", wxDefaultPosition, wxDefaultSize, asInstType, 0, wxRA_SPECIFY_ROWS); //setta il default a Standard GetSizer()->Add(m_pRadioBox); } /**********************************************************************************************************/ // 6 Installazione standard /**********************************************************************************************************/ class CampoWizardPage6 : public CampoWizardPage { protected: DECLARE_EVENT_TABLE(); void OnDirPick(wxCommandEvent& e); virtual bool ForwardValidate(); public: CampoWizardPage6(wxWizard* parent); }; BEGIN_EVENT_TABLE(CampoWizardPage6, CampoWizardPage) EVT_BUTTON(602, OnDirPick) EVT_BUTTON(604, OnDirPick) END_EVENT_TABLE() void CampoWizardPage6::OnDirPick(wxCommandEvent& e) { const wxWindowID wiTargetField = e.GetId() - 1; wxString strPath = Get(wiTargetField); wxDirDialog dlg(this, wxDirSelectorPromptStr, strPath, wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST); if (dlg.ShowModal() == wxID_OK) { strPath = dlg.GetPath(); Set(wiTargetField, strPath); } } //metodo per il controllo dell'area dati;se la directory indicata non è vuota non puoi usarla ne' crearla bool CampoWizardPage6::ForwardValidate() { //controllo esistenza directory vuota per i programmi in locale const wxString strPrgLocPath = Get(601); wxDir dirPrgLocPath(strPrgLocPath); if (dirPrgLocPath.Exists(Get(601)) && (dirPrgLocPath.HasFiles() || dirPrgLocPath.HasSubDirs())) return ErrorBox("La cartella selezionata per l'installazione dei programmi NON è valida! Selezionarne un'altra!"); const wxString strDataPath = Get(603); wxDir dirDataPath(strDataPath); if (dirDataPath.Exists(strDataPath) && (dirDataPath.HasFiles() || dirDataPath.HasSubDirs())) return ErrorBox("La cartella indicata per la creazione dell'area dati non è vuota! Selezionarne un'altra!"); //setta alla pagina riassuntiva i valori della pagina attuale... GetWizard().SetPrgLocPath(strPrgLocPath); GetWizard().SetDataPath(strDataPath); //...e pure quegli stupidi datidemo che nessuno ha mai installato!! const bool bInstDemoData = GetBool(605); GetWizard().SetInstDemoData(bInstDemoData); return true; } CampoWizardPage6::CampoWizardPage6(wxWizard* parent) : CampoWizardPage(parent) { wxString strTitle = wxT("Installazione di tipo Standard"); wxString strBody = wxT("Digitare nel campo 'Cartella programma' il percorso completo della cartella dove si desidera installare il programma. "); strBody += wxT("Il percorso di default (consigliato) è C:\\APPNAME
"); strBody += wxT("Digitare nel campo 'Cartella Dati' il percorso completo della cartella dove si desidera installare l'area dati. "); strBody += wxT("Il percorso di default (consigliato) è C:\\APPNAME\\dati
"); /*strBody += wxT("Dati dimostrativi: area dati precompilata per installazioni di tipo dimostrativo del funzionamento del software. "); strBody += wxT("NON vanno caricati nel caso di una normale installazione!
");*/ SetHTMLText(strTitle, strBody); //griglia per sistemare i campi wxGridBagSizer* gbsSizer = new wxGridBagSizer(VGAP, HGAP); GetSizer()->Add(gbsSizer); //prima riga della griglia //prompt AddLabel(gbsSizer, "Cartella programmi", 0, 0); //campo testo wxString strPath; strPath = "C:\\"; strPath += APPNAME; wxTextCtrl* tcPrgPath = new wxTextCtrl(this, 601, strPath, wxDefaultPosition, wxSize(320,-1)); gbsSizer->Add(tcPrgPath, wxGBPosition(0, 1)); //bottone 'sfoglia' wxButton* bPrgButton = new wxButton(this, 602, wxT("Sfoglia"), wxDefaultPosition, wxSize(48, -1)); gbsSizer->Add(bPrgButton, wxGBPosition(0, 2)); //seconda riga della griglia //prompt AddLabel(gbsSizer, "Cartella dati", 1, 0); //campo testo strPath += "/dati"; wxTextCtrl* tcDataPath = new wxTextCtrl(this, 603, strPath, wxDefaultPosition, wxSize(320,-1)); gbsSizer->Add(tcDataPath, wxGBPosition(1, 1)); //bottone 'sfoglia' wxButton* bDataButton = new wxButton(this, 604, wxT("Sfoglia"), wxDefaultPosition, wxSize(48, -1)); gbsSizer->Add(bDataButton, wxGBPosition(1, 2)); //terza riga della griglia ***per ora i datidemo li installiamo solo con la demo (anzi,per sempre) /* wxCheckBox* chDataDemo = new wxCheckBox(this, 605, wxT("Carica i dati dimostrativi")); chDataDemo->SetValue(false); gbsSizer->Add(chDataDemo, wxGBPosition(2, 1));*/ } /**********************************************************************************************************/ // 7 Installazione server /**********************************************************************************************************/ class CampoWizardPage7 : public CampoWizardPage { wxRadioBox* m_pRadioBox; protected: DECLARE_EVENT_TABLE(); virtual bool ForwardValidate(); virtual bool TransferDataToWindow(); void OnDirPick(wxCommandEvent& e); void OnSrvClick(wxCommandEvent& e); public: CampoWizardPage7(wxWizard* parent); }; BEGIN_EVENT_TABLE(CampoWizardPage7, CampoWizardPage) EVT_BUTTON(702, OnDirPick) EVT_BUTTON(704, OnDirPick) EVT_CHECKBOX(705, OnSrvClick) EVT_CHECKBOX(707, OnSrvClick) END_EVENT_TABLE() void CampoWizardPage7::OnDirPick(wxCommandEvent& e) { const wxWindowID wiTargetField = e.GetId() - 1; wxString strPath = Get(wiTargetField); wxDirDialog dlg(this, wxDirSelectorPromptStr, strPath, wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST); if (dlg.ShowModal() == wxID_OK) { strPath = dlg.GetPath(); Set(wiTargetField, strPath); } } void CampoWizardPage7::OnSrvClick(wxCommandEvent& e) { //nome del server wxControl* pWnd = FindControlById(e.GetId() + 1); if (pWnd) pWnd->Enable(e.IsChecked()); //tipo installazione server pWnd = FindControlById(709); if (pWnd) pWnd->Enable(GetBool(705) || GetBool(707)); } bool CampoWizardPage7::TransferDataToWindow() { wxControl* pServer = FindControlById(705); if (pServer) { const unsigned int dt = GetWizard().GetDongleType(); const bool bEnabled = dt == 1 || dt == 2 || dt == 4; pServer->Enable(bEnabled); if (!bEnabled) Set(705, false); } return true; } bool CampoWizardPage7::ForwardValidate() { //controllo esistenza directory vuota per i programmi in locale const wxString strPrgLocPath = Get(701); wxDir dirPrgLocPath(strPrgLocPath); if (dirPrgLocPath.Exists(strPrgLocPath) && (dirPrgLocPath.HasFiles() || dirPrgLocPath.HasSubDirs())) return ErrorBox("La cartella selezionata per l'installazione dei programmi NON è valida! Selezionarne un'altra!"); //controllo della directory dell'area dati: deve essere nuova o vuota affinche' possa essere utilizzata!! const wxString strDataPath = Get(703); wxDir dirDataPath(strDataPath); if (dirDataPath.Exists(strDataPath) && (dirDataPath.HasFiles() || dirDataPath.HasSubDirs())) return ErrorBox("La cartella indicata per la creazione dell'area dati non è vuota! Selezionarne un'altra!"); //setta alla pagina riassuntiva i valori della pagina attuale... GetWizard().SetPrgLocPath(strPrgLocPath); GetWizard().SetDataPath(strDataPath); //...compresi eventuali stupidi servers! const bool bInstAuth = GetBool(705); if (bInstAuth) { GetWizard().SetInstUseAuth(bInstAuth); const wxString strSrvAuth = Get(706); if (strSrvAuth.IsEmpty()) return ErrorBox("Specificare il server gestore delle autorizzazioni!"); GetWizard().SetSrvAuth(strSrvAuth); } else GetWizard().SetSrvAuth(""); const bool bInstDict = GetBool(707); if (bInstDict) { GetWizard().SetInstUseDict(bInstDict); const wxString strSrvDict = Get(708); if (strSrvDict.IsEmpty()) return ErrorBox("Specificare il server gestore dei dizionari!"); GetWizard().SetSrvDict(strSrvDict); } else GetWizard().SetSrvDict(""); //..e loro modalità di esecuzione if (bInstAuth || bInstDict) { const int nType = m_pRadioBox->GetSelection() + 1; //+1 perchè 0 corrisponde a lm_none GetWizard().SetSrvAutostartMode((LurchMode)nType); } else GetWizard().SetSrvAutostartMode(lm_none); return true; } CampoWizardPage7::CampoWizardPage7(wxWizard* parent) : CampoWizardPage(parent) { //chiede al sistema la versione di windows int nVersion = 0; bool bIsServer = false; ::GetWinVer(NULL, 0, nVersion, bIsServer); wxString strTitle; wxString strBody; //installazione di tipo Server normale strTitle = wxT("Installazione di tipo Server"); strBody = wxT("Digitare nel campo 'Cartella programma' il percorso completo della cartella dove si desidera installare il programma. "); strBody += wxT("Il percorso consigliato è C:\\APPNAME
"); strBody += wxT("Digitare nel campo 'Cartella dati' il percorso completo della cartella dove si desidera installare l'area dati. "); strBody += wxT("Il percorso consigliato è C:\\APPNAME\\dati
"); strBody += wxT("Le cartelle del programma e dei dati dovranno essere condivise in modalità lettura/scrittura agli utenti di sistema e di rete che utilizzeranno il software PRODUCT. "); strBody += wxT("In mancanza di tale condivisione nessun client potrà accedere al server!
"); strBody += wxT("Gestore autorizzazioni: è il software che permette di gestire una chiave di protezione hardware multiutenza condivisa in rete. "); strBody += wxT("Installando tale software è necessario specificare il computer su cui è montata la chiave di protezione multiutenza."); strBody += wxT("Viene di default proposto il computer su cui si sta eseguendo l'installazione di PRODUCT (localhost).
"); strBody += wxT("Gestore dizionari: è il software che permette di utilizzare PRODUCT in lingue diverse dall'italiano. "); strBody += wxT("Per l'installazione di questo software viene di default proposto il computer su cui si sta eseguendo l'installazione di PRODUCT (localhost).
"); strBody += wxT("Modalità di esecuzione programmi di gestione
");
strBody += wxT("Come servizi: i programmi di gestione vengono eseguiti come servizi di Windows; questa è la modalità consigliata ed è obbligatoria in caso di installazione con Windows 2003/2008
");
strBody += wxT("Nel menu esecuzione automatica: i programmi di gestione vengono eseguiti automaticamente al primo accesso di un utente al server di PRODUCT; usare questa modalità solo nell'impossibilità di utilizzare la precedente
E' stata rilevata una versione di Windows che consente sessioni remote (es. Windows 2008 Server) ed è quindi possibile una installazione di questo tipo
"); strBody = wxT("Digitare nel campo 'Cartella programma' il percorso completo della cartella dove si desidera installare il programma. "); strBody += wxT("Il percorso consigliato è C:\\APPNAME
"); strBody += wxT("Digitare nel campo 'Cartella dati' il percorso completo della cartella dove si desidera installare l'area dati. "); strBody += wxT("Il percorso consigliato è C:\\APPNAME\\dati
"); strBody += wxT("Le cartelle del programma e dei dati dovranno essere accessibili in modalità lettura/scrittura agli utenti di sistema e di rete che utilizzeranno il software PRODUCT. "); strBody += wxT("In mancanza di tale modalità nessun utente potrà utilizzare il software PRODUCT !
"); strBody += wxT("Gestore autorizzazioni: è il software che permette di gestire una chiave di protezione hardware multiutenza condivisa in rete. "); strBody += wxT("E' necessario installare questo software specificando localhost come computer su cui è montata la chiave di protezione multiutenza.
"); strBody += wxT("Gestore dizionari: è il software che permette di utilizzare PRODUCT in lingue diverse dall'italiano. "); strBody += wxT("E' necessario installare questo software specificando localhost come computer su cui installare il servizio.
"); strBody += wxT("Modalità di esecuzione programmi di gestione: obbligatorio come servizi!
");
}
SetHTMLText(strTitle, strBody);
//griglia per sistemare i campi
wxGridBagSizer* gbsSizer = new wxGridBagSizer(VGAP, HGAP);
GetSizer()->Add(gbsSizer);
//prima riga della griglia
//prompt
AddLabel(gbsSizer, "Cartella programmi", 0, 0);
//campo testo
wxString strPath;
strPath = "C:\\";
strPath += APPNAME;
wxTextCtrl* tcPrgPath = new wxTextCtrl(this, 701, strPath, wxDefaultPosition, wxSize(320,-1));
gbsSizer->Add(tcPrgPath, wxGBPosition(0, 1));
//bottone 'sfoglià
wxButton* bPrgButton = new wxButton(this, 702, wxT("Sfoglia"), wxDefaultPosition, wxSize(48, -1));
gbsSizer->Add(bPrgButton, wxGBPosition(0, 2));
//seconda riga della griglia
//prompt
AddLabel(gbsSizer, "Cartella dati", 1, 0);
//campo testo
strPath += "/dati";
wxTextCtrl* tcDataPath = new wxTextCtrl(this, 703, strPath, wxDefaultPosition, wxSize(320,-1));
gbsSizer->Add(tcDataPath, wxGBPosition(1, 1));
//bottone 'sfoglià
wxButton* bDataButton = new wxButton(this, 704, wxT("Sfoglia"), wxDefaultPosition, wxSize(48, -1));
gbsSizer->Add(bDataButton, wxGBPosition(1, 2));
//terza riga della griglia
//check installa authoriz
wxCheckBox* chAuthoriz = new wxCheckBox(this, 705, wxT("Installa il gestore delle autorizzazioni"));
gbsSizer->Add(chAuthoriz, wxGBPosition(2, 1));
//server authoriz
wxTextCtrl* tcAuthoriz = new wxTextCtrl(this, 706, "localhost", wxDefaultPosition, wxSize(96,-1));
tcAuthoriz->Disable();
gbsSizer->Add(tcAuthoriz, wxGBPosition(2, 2));
//quarta riga della griglia
//check installa diction
wxCheckBox* chDictionary = new wxCheckBox(this, 707, wxT("Installa il gestore dei dizionari"));
chDictionary->SetValue(false);
gbsSizer->Add(chDictionary, wxGBPosition(3, 1));
//server diction
wxTextCtrl* tcDiction = new wxTextCtrl(this, 708, "localhost", wxDefaultPosition, wxSize(96,-1));
tcDiction->Disable();
gbsSizer->Add(tcDiction, wxGBPosition(3, 2));
//quinta riga della griglia
//radiobutton con i tipi di installazione
wxArrayString asInstType;
if (bIsServer /*nVersion == W2003 || nVersion == W2008*/)
{
asInstType.Add("Come servizi (obbligatorio)");
}
else
{
asInstType.Add("Come servizi (consigliato)");
asInstType.Add("Nel menu esecuzione automatica");
}
m_pRadioBox = new wxRadioBox(this, 709, "Modalità di esecuzione gestori", wxDefaultPosition,
wxDefaultSize, asInstType, 0, wxRA_SPECIFY_COLS);
//setta il default a "come servizio"
m_pRadioBox->SetSelection(0);
m_pRadioBox->Disable();
gbsSizer->Add(m_pRadioBox, wxGBPosition(4, 1));
}
/**********************************************************************************************************/
// 8 Installazione client
/**********************************************************************************************************/
class CampoWizardPage8 : public CampoWizardPage
{
protected:
DECLARE_EVENT_TABLE();
virtual bool ForwardValidate();
virtual bool TransferDataToWindow();
void OnDirPick(wxCommandEvent& e);
void OnSrvClick(wxCommandEvent& e);
public:
CampoWizardPage8(wxWizard* parent);
};
BEGIN_EVENT_TABLE(CampoWizardPage8, CampoWizardPage)
EVT_BUTTON(802, OnDirPick)
EVT_BUTTON(804, OnDirPick)
EVT_BUTTON(806, OnDirPick)
EVT_CHECKBOX(807, OnSrvClick)
END_EVENT_TABLE()
void CampoWizardPage8::OnDirPick(wxCommandEvent& e)
{
const wxWindowID wiTargetField = e.GetId() - 1;
wxString strPath = Get(wiTargetField);
wxDirDialog dlg(this, wxDirSelectorPromptStr, strPath,
wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST);
if (dlg.ShowModal() == wxID_OK)
{
strPath = dlg.GetPath();
Set(wiTargetField, strPath);
}
}
void CampoWizardPage8::OnSrvClick(wxCommandEvent& e)
{
wxWindow* pWnd = FindWindowById(e.GetId() + 1);
if (pWnd)
pWnd->Enable(e.IsChecked());
}
bool CampoWizardPage8::TransferDataToWindow()
{
bool bNoPrg = Get(803).IsEmpty();
bool bNoData = Get(805).IsEmpty();
if (bNoPrg || bNoData)
{
//cerca le unità condivise in rete
wxArrayString asList;
const size_t nShared = ListNetworkDisks(asList);
//se ne trova controlla se sono valide come directory di programmi e dati
for (size_t i = 0; i < nShared; i++)
{
wxString strWrk = asList[i];
if (!wxEndsWithPathSeparator(strWrk))
strWrk << wxFILE_SEP_PATH;
UINT nDriveType = ::GetDriveType(strWrk);
if (nDriveType == DRIVE_REMOTE)
{
if (bNoPrg && CheckPrgDir(strWrk))
{
bNoPrg = false;
Set(803, strWrk);
}
if (bNoData && CheckDataDir(strWrk))
{
bNoData = false;
Set(805, strWrk);
}
}
} //for(size_t...
} //if(noPrg...
return true;
}
bool CampoWizardPage8::ForwardValidate()
{
//controlli su directory selezionate
//1) directory di installazione programmi
const wxString strPrgLocPath = Get(801);
//la directory di installazione programmi deve essere su un disco locale (sei un client!)
UINT nPrgDriveType = ::GetDriveType(strPrgLocPath.Left(3));
if (nPrgDriveType != DRIVE_FIXED)
return ErrorBox("La cartella selezionata per l'installazione dei programmi deve trovarsi su un disco locale!");
//controllo esistenza directory vuota per i programmi in locale
wxDir dirPrgLocPath(strPrgLocPath);
if (dirPrgLocPath.Exists(strPrgLocPath) && (dirPrgLocPath.HasFiles() || dirPrgLocPath.HasSubDirs()))
return ErrorBox("La cartella selezionata per l'installazione dei programmi NON è valida! Selezionarne un'altra!");
//2) directory di origine dei programmi sul server
const wxString strPrgNetPath = Get(803);
//il server non puo' essere un cd o roba simile
UINT nPrgNetDriveType = ::GetDriveType(strPrgNetPath.Left(3));
if (nPrgNetDriveType != DRIVE_REMOTE)
return ErrorBox("Il server deve essere su un disco di rete!");
//il server deve contenere i programmi di Campo già installati correttamente
if (!CheckPrgDir(strPrgNetPath))
return ErrorBox("La cartella selezionata come origine dei programmi NON è valida!");
//3) directory dati sul server
const wxString strDataPath = Get(805);
//la cartella dei dati deve essere in remoto,senno' sei una postazione locale o un server
UINT nDataDriveType = ::GetDriveType(strDataPath.Left(3));
if (nDataDriveType != DRIVE_REMOTE)
return ErrorBox("La cartella dei dati deve trovarsi su un server remoto e non su un disco locale!");
//la cartella dei dati deve contenerli ed essere scrivibile
if (!CheckDataDir(strDataPath))
return ErrorBox("La cartella selezionata come area dati NON è valida o non accessibile in scrittura!");
//setta alla pagina riassuntiva i valori della pagina attuale
GetWizard().SetPrgLocPath(strPrgLocPath);
GetWizard().SetPrgNetPath(strPrgNetPath);
GetWizard().SetDataPath(strDataPath);
return true;
}
CampoWizardPage8::CampoWizardPage8(wxWizard* parent) : CampoWizardPage(parent)
{
wxString strTitle = wxT("Installazione di tipo Client");
wxString strBody = wxT("
Digitare nel campo 'Cartella locale programma' il percorso completo della cartella dove si desidera installare il programma. "); strBody += wxT("Il percorso consigliato è C:\\APPNAME
"); strBody += wxT("Il campo 'Cartella remota origine programmi' contiene il percorso completo della cartella di rete dove sono i files origine del programma. "); strBody += wxT("E' la cartella di programmi condivisa dal server precedentemente installato. Se condivisa e connessa correttamente viene rilevata automaticamente e proposta dal programma. "); strBody += wxT("Se non viene proposta automaticamente, digitare il percorso completo (es. Z:\\APPNAME)
"); strBody += wxT("Il campo 'Cartella remota dati da utilizzare' contiene il percorso completo della cartella di rete dove sono i dati. "); strBody += wxT("E' la cartella dei dati condivisa dal server precedentemente installato. Se condivisa e connessa correttamente viene rilevata automaticamente e proposta dal programma. "); strBody += wxT("Se non viene proposta automaticamente, digitare il percorso completo (es. Z:\\APPNAME\\Dati)
"); strBody += wxT("Gestore dizionari: è il computer gestore dei dizionari di PRODUCT in lingue diverse dall'italiano. Generalmente è il computer agente da server di PRODUCT in rete. "); strBody += wxT("Premere il bottone Cerca per attivare la ricerca automatica di tale computer. Qualora tale ricerca fallisse digitare il nome del computer gestore dei dizionari
"); SetHTMLText(strTitle, strBody); //griglia per sistemare i campi wxGridBagSizer* gbsSizer = new wxGridBagSizer(VGAP, HGAP); GetSizer()->Add(gbsSizer); //prima riga della griglia //prompt AddLabel(gbsSizer, "Cartella locale programma", 0, 0); //campo testo wxString strPath; strPath = "C:\\"; strPath += APPNAME; wxTextCtrl* tcDestPrgPath = new wxTextCtrl(this, 801, strPath, wxDefaultPosition, wxSize(256,-1)); gbsSizer->Add(tcDestPrgPath, wxGBPosition(0, 1)); //bottone 'sfoglia' wxButton* bDestPrgButton = new wxButton(this, 802, wxT("Sfoglia"), wxDefaultPosition, wxSize(48, -1)); gbsSizer->Add(bDestPrgButton, wxGBPosition(0, 2)); //seconda riga della griglia //prompt AddLabel(gbsSizer, "Cartella remota origine programmi", 1, 0); //campo testo wxTextCtrl* tcSrcPrgPath = new wxTextCtrl(this, 803, "", wxDefaultPosition, wxSize(256,-1)); gbsSizer->Add(tcSrcPrgPath, wxGBPosition(1, 1)); //bottone 'sfoglia' wxButton* bSrcPrgButton = new wxButton(this, 804, wxT("Sfoglia"), wxDefaultPosition, wxSize(48, -1)); gbsSizer->Add(bSrcPrgButton, wxGBPosition(1, 2)); //terza riga della griglia //prompt AddLabel(gbsSizer, "Cartella remota dati da utilizzare", 2, 0); //campo testo wxTextCtrl* tcDataPath = new wxTextCtrl(this, 805, "", wxDefaultPosition, wxSize(256,-1)); gbsSizer->Add(tcDataPath, wxGBPosition(2, 1)); //bottone 'sfoglia' wxButton* bDataButton = new wxButton(this, 806, wxT("Sfoglia"), wxDefaultPosition, wxSize(48, -1)); gbsSizer->Add(bDataButton, wxGBPosition(2, 2)); //terza riga della griglia //Server dizionari label AddLabel(gbsSizer, "Nome o indirizzo IP del server dei dizionari", 3, 0); //nome Server dizionari wxTextCtrl* tcSrvName = new wxTextCtrl(this, 807, "", wxDefaultPosition, wxSize(256,-1)); gbsSizer->Add(tcSrvName, wxGBPosition(3, 1)); //bottone Cerca wxButton* bSrvButton = new wxButton(this, 808, wxT("Cerca"), wxDefaultPosition, wxSize(48, -1)); gbsSizer->Add(bSrvButton, wxGBPosition(3, 2), wxDefaultSpan, wxALIGN_CENTER_VERTICAL); } /**********************************************************************************************************/ // 9 pagina con la creazione icona sul desktop, lanciatore del lurch /**********************************************************************************************************/ class CampoWizardPage9 : public CampoWizardPage { protected: virtual bool TransferDataToWindow(); virtual bool ForwardValidate(); public: CampoWizardPage9(wxWizard* parent); }; bool CampoWizardPage9::TransferDataToWindow() { //setta il checkbox del link Set(901, GetWizard().GetDesktopShortcut()); bool bInstDemoVersion = GetWizard().GetInstDemoVersion(); //..che c'è appena sopra di lui in program wxString strTitle = wxT("Collegamenti"); wxString strBody; strBody += wxT("E' possibile creare l'icona di PRODUCT sul desktop.
"); //è stato inopinatamente scelto di installare la DEMO if (bInstDemoVersion) { strBody += wxT("Si sta installando la versione DEMO di PRODUCT !!. Questa versione è a scopo puramente "); strBody += wxT("dimostrativo e NON va di norma installata! Non è utilizzabile come la versione normale in quanto limitata nel "); strBody += wxT("numero e nella data delle registrazioni. La cartella di installazione della "); strBody += wxT("versione dimostrativa è C:/CampoDemo e dispone di un'area dati precaricata.
"); } SetHTMLText(strTitle, strBody); return true; } bool CampoWizardPage9::ForwardValidate() { //link sul desktop const bool bDesktopShortcut = GetBool(901); GetWizard().SetDesktopShortcut(bDesktopShortcut); return true; } CampoWizardPage9::CampoWizardPage9(wxWizard* parent) : CampoWizardPage(parent) { wxCheckBox* pIcon = new wxCheckBox(this, 901, wxT("Creare l'icona sul desktop")); GetSizer()->Add(pIcon, 0, wxALL, 0); } /**********************************************************************************************************/ // 10 pagina con la selezione di destinazione /**********************************************************************************************************/ class CampoWizardPage10 : public CampoWizardPage { InstallationType _uInstallType; wxString _strInstallType; wxString _strPrgLocPath; wxString _strPrgNetPath; wxString _strDataPath; wxString _strSrvAuth; wxString _strSrvDict; unsigned int _iSrvAutostartMode; bool _bInstDemoData; bool _bInstDemoVersion; bool _bDesktopShortcut; protected: virtual bool TransferDataToWindow(); public: CampoWizardPage10(wxWizard* parent); }; bool CampoWizardPage10::TransferDataToWindow() { CampoWizard& cw = GetWizard(); _uInstallType = cw.GetInstallationType(); _bInstDemoVersion = cw.GetInstDemoVersion(); switch (_uInstallType) { case it_server: //server _strInstallType = "Server"; _strPrgLocPath = cw.GetPrgLocPath(); _strDataPath = cw.GetDataPath(); _strSrvAuth = cw.GetSrvAuth(); _strSrvDict = cw.GetSrvDict(); if (!_strSrvAuth.IsEmpty() || !_strSrvDict.IsEmpty()) _iSrvAutostartMode = cw.GetSrvAutostartMode(); break; case it_client: //client _strInstallType = "Client"; _strPrgLocPath = cw.GetPrgLocPath(); _strPrgNetPath = cw.GetPrgNetPath(); _strDataPath = cw.GetDataPath(); _strSrvAuth = cw.GetSrvAuth(); _strSrvDict = cw.GetSrvDict(); break; case it_upgrade: //aggiornamento _strInstallType = ""; _strPrgLocPath = cw.GetDestinationPath(); _strDataPath = cw.GetDataPath(); _strSrvAuth = cw.GetSrvAuth(); _strSrvDict = cw.GetSrvDict(); break; default: //standard if (_bInstDemoVersion) { _strInstallType = "DEMO"; _strPrgLocPath = "c:/campodemo"; _strDataPath = _strPrgLocPath + "/datidemo"; } else { _strInstallType = "Standard"; _strPrgLocPath = cw.GetPrgLocPath(); _strDataPath = cw.GetDataPath(); _bInstDemoData = cw.GetInstDemoData(); } break; } //questo vale per tutti _bDesktopShortcut = cw.GetDesktopShortcut(); //se installazione o aggiornamento cambia sia il titolo che i contenuti wxString strTitle; wxString strBody; //Aggiornamento if (_uInstallType == it_upgrade) { strTitle += wxT("AGGIORNAMENTO: riepilogo configurazione"); strBody = wxT("Cartella programma da aggiornare: "); strBody += wxT(Bold(_strPrgLocPath) + "
"); strBody += wxT("Cartella dati in uso: "); strBody += wxT(Bold(_strDataPath) + "
"); } else //Installazione { strTitle += wxT("INSTALLAZIONE: riepilogo configurazione"); //DEMO (aaarrgh!) if (_bInstDemoVersion) { strBody = wxT("Tipo installazione selezionata: "); strBody += wxT("DEMO
"); strBody += wxT("Cartella dove installare il programma DEMO: "); strBody += wxT("C:/campodemo
"); strBody += wxT("Cartella dati dimostrativi: "); strBody += wxT(Bold(_strDataPath) + "
"); } else //tutte le altre { strBody = wxT("Tipo installazione selezionata: "); strBody += wxT(Bold(_strInstallType) + "
"); strBody += wxT("Cartella dove installare il programma: "); strBody += wxT(Bold(_strPrgLocPath) + "
"); if (_uInstallType == it_client) { strBody += wxT("Cartella di origine dei files del programma: "); strBody += wxT(Bold(_strPrgNetPath) + "
"); strBody += wxT("Cartella dati da utilizzare: "); strBody += wxT(Bold(_strDataPath) + "
"); } else { strBody += wxT("Cartella dati da creare: "); strBody += wxT(Bold(_strDataPath) + "
"); } } } //installazione servers... if (!_strSrvAuth.IsEmpty()) { strBody += wxT("Computer gestore delle autorizzazioni: "); strBody += wxT(Bold(_strSrvAuth) + "
"); } if (!_strSrvDict.IsEmpty()) { strBody += wxT("Computer gestore dei dizionari: "); strBody += wxT(Bold(_strSrvDict) + "
"); } //...e loro modalità di lancio (solo installazione server!) if (_uInstallType == it_server && (!_strSrvAuth.IsEmpty() || !_strSrvDict.IsEmpty()) && _iSrvAutostartMode >= 0) { strBody += wxT("Modalità di esecuzione dei programmi di gestione: "); if (_iSrvAutostartMode == lm_service) strBody += wxT(Bold("Come servizi") + "
"); else strBody += wxT(Bold("Nel menu esecuzione automatica") + ""); } //installazione dati demo (solo in postazione singola; è obbligatoria in modalità DEMO, quindi niente scritta) if (_uInstallType == it_standalone && _bInstDemoData && !_bInstDemoVersion) strBody += wxT("Installazione area dati dimostrativa
"); if (_bDesktopShortcut) strBody += wxT("Creazione dell'icona sul desktop
"); SetHTMLText(strTitle, strBody); return true; } CampoWizardPage10::CampoWizardPage10(wxWizard* parent) : CampoWizardPage(parent) { } /////////////////////////////////////////////////////////// // CampoWizard /////////////////////////////////////////////////////////// //la dichiarazione della classe è prima in quanto alcuni suoi metodi sono usati da altre classi scritte piu' su BEGIN_EVENT_TABLE(CampoWizard, wxWizard) EVT_BUTTON(wxID_FORWARD, CampoWizard::OnNext) END_EVENT_TABLE() void CampoWizard::OnNext(wxCommandEvent& e) { CampoWizardPage* p = (CampoWizardPage*)GetCurrentPage(); if (p->ForwardValidate()) e.Skip(); } bool CampoWizard::Run() { return RunWizard(m_pPage[0]); } wxString CampoWizard::Get(wxWindowID id) const { wxWindow* pWnd = FindWindowById(id); return pWnd ? pWnd->GetLabel() : wxEmptyString; } int CampoWizard::GetSelection(wxWindowID id) const { int n = -1; wxWindow* pWnd = FindWindowById(id); if (pWnd) { wxChoice* pList = (wxChoice*)pWnd; n = pList->GetSelection(); } return n; } bool CampoWizard::GetBool(wxWindowID id) const { wxCheckBox* pWnd = (wxCheckBox*)FindWindowById(id); return pWnd != NULL && pWnd->IsChecked(); } void CampoWizard::Set(wxWindowID id, const wxString str) { wxWindow* pWnd = FindWindowById(id); if (pWnd != NULL) pWnd->SetLabel(str); } //lunga litania di metodi per gettare e settare i valori tra le pagine void CampoWizard::SetDestinationPath(const wxString& path) { _strDestinationPath = path; //Se il path di destinazione è vuoto -> nuova installazione, quindi lascia la concatenazione normale, //senno' è un aggiornamento della installazione che sta in _strDestinationPath if (!_strDestinationPath.IsEmpty()) { //aggiornamento CampoWizardPage4* page4 = (CampoWizardPage4*)m_pPage[3]; unsigned short serno = 0xFFFF; if (page4->DongleTest(serno) != 0) wxWizardPageSimple::Chain(m_pPage[2], m_pPage[8]); // chiave trovata else { wxWizardPageSimple::Chain(m_pPage[2], m_pPage[3]); // chiave NON trovata wxWizardPageSimple::Chain(m_pPage[3], m_pPage[8]); } } } const wxString& CampoWizard::GetDestinationPath() const { return _strDestinationPath; } void CampoWizard::SetInstallationType(const InstallationType nType) { _uInstallationType = nType; //in base al tipo di installazione spara l'utente alla pagina corretta switch (_uInstallationType) { 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 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 it_upgrade: //aggiornamento installazione precedente //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[3], m_pPage[8]); //manda l'utente alla pagina riassuntiva senza controllo chiave } else { wxWizardPageSimple::Chain(m_pPage[3], m_pPage[4]); //nel caso si sia trovata una chiave al secondo tentativo deve resettare 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; } } const InstallationType CampoWizard::GetInstallationType() const { return _uInstallationType; } void CampoWizard::SetPrgLocPath(const wxString& strPrgLocPath) { _strPrgLocPath = strPrgLocPath; } const unsigned int CampoWizard::GetDongleType() const { return _uDongleType; } void CampoWizard::SetDongleType(const unsigned int uType) { _uDongleType = uType; } const wxString& CampoWizard::GetPrgLocPath() const { return _strPrgLocPath; } void CampoWizard::SetPrgNetPath(const wxString& strPrgNetPath) { _strPrgNetPath = strPrgNetPath; } const wxString& CampoWizard::GetPrgNetPath() const { return _strPrgNetPath; } void CampoWizard::SetDataPath(const wxString& strDataPath) { _strDataPath = strDataPath; } const wxString& CampoWizard::GetDataPath() const { return _strDataPath; } void CampoWizard::SetInstUseAuth(const bool bInstUseAuth) { _bInstUseAuth = bInstUseAuth; } const bool CampoWizard::GetInstUseAuth() const { return _bInstUseAuth; } void CampoWizard::SetSrvAuth(const wxString& strSrvAuth) { _strSrvAuth = strSrvAuth; } const wxString& CampoWizard::GetSrvAuth() const { return _strSrvAuth; } void CampoWizard::SetInstUseDict(const bool bInstUseDict) { _bInstUseDict = bInstUseDict; } const bool CampoWizard::GetInstUseDict() const { return _bInstUseDict; } void CampoWizard::SetSrvDict(const wxString& strSrvDict) { _strSrvDict = strSrvDict; } const wxString& CampoWizard::GetSrvDict() const { return _strSrvDict; } void CampoWizard::SetSrvAutostartMode(const LurchMode iSrvAutostartMode) { _iSrvAutostartMode = iSrvAutostartMode; } const LurchMode CampoWizard::GetSrvAutostartMode() const { return _iSrvAutostartMode; } void CampoWizard::SetInstDemoData(const bool bInstDemoData) { _bInstDemoData = bInstDemoData; } 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; } const bool CampoWizard::GetDesktopShortcut() const { return _bDesktopShortcut; } //...fine litania metodi di passaggio valori tra le finestre 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 _iSrvAutostartMode = lm_none;//autostart dei servers _bDesktopShortcut = false; //creazione link sul desktop //nome del file di logo recuperato con apposito metodo e caricata immagine wxImage iLogo; iLogo.LoadFile(Logo(), wxBITMAP_TYPE_ANY); int nWidth = iLogo.GetWidth(); int nHeight = iLogo.GetHeight(); //se l'immagine è orizzontale frega troppo spazio allora la ruotiamo di soppiatto if (nWidth > (2 * nHeight)) { iLogo = iLogo.Rotate90(false); nWidth = iLogo.GetWidth(); nHeight = iLogo.GetHeight(); } const double nMaxWidth = 216; const double nMaxHeight = 600; const double dScaleX = nMaxWidth / nWidth; const double dScaleY = nMaxHeight / nHeight; const double dScale = dScaleX < dScaleY ? dScaleX : dScaleY; if (dScale < 1) { nHeight *= dScale; nWidth *= dScale; iLogo.Rescale(nWidth, nHeight, wxIMAGE_QUALITY_HIGH); } const wxBitmap bitmap(iLogo); Create(pParent, wxID_ANY, PRODUCT, bitmap); m_pPage[0] = new CampoWizardPage1(this); //benvenuto con logo m_pPage[1] = new CampoWizardPage2(this); //licenza m_pPage[2] = new CampoWizardPage3(this); //scelta aggiornamento/tipo installazione m_pPage[3] = new CampoWizardPage4(this); //test ed installazione chiavi m_pPage[4] = new CampoWizardPage5(this); //selezione tipo installazione m_pPage[5] = new CampoWizardPage6(this); //installazione standard m_pPage[6] = new CampoWizardPage7(this); //installazione server m_pPage[7] = new CampoWizardPage8(this); //installazione client m_pPage[8] = new CampoWizardPage9(this); //creazione icona sul desktop e in start/programmi/campo m_pPage[9] = new CampoWizardPage10(this); //riassuntino installazione for (int p = 1; p < m_nPages; p++) wxWizardPageSimple::Chain(m_pPage[p-1], m_pPage[p]); GetPageAreaSizer()->Add(m_pPage[0]); //bottoni di navigazione Set(wxID_FORWARD, _T("Avanti")); Set(wxID_BACKWARD, _T("Indietro")); Set(wxID_CANCEL, _T("Annulla")); }