2007-07-25 10:43:05 +00:00
//Il sorgente va scritto in notazione ungherese.
//Le variabili seguono la seguente regola: 'acronimo tipo'+'nome variabile cammellata'
//Es. wxArrayString 'as' + 'AcceptRefuse' -> asAcceptRefuse
2007-07-23 15:01:38 +00:00
# include "wxinc.h"
# include <wx/dir.h>
# include <wx/fileconf.h>
# include <wx/filepicker.h>
2007-07-25 10:43:05 +00:00
# include <wx/gbsizer.h>
2007-07-23 15:01:38 +00:00
# include <wx/html/htmlwin.h>
# include <wx/mimetype.h>
# include <wx/radiobox.h>
# include <wx/txtstrm.h>
# include <wx/wfstream.h>
# include <wx/wizard.h>
# ifdef WIN32
# include <shlobj.h>
# endif
extern " C "
{
# include "../xvaga/hlapi_c.h"
# include "../xvaga/skeylink.h"
}
2007-07-25 10:43:05 +00:00
# define HGAP 4
# define VGAP 2
2007-07-23 15:01:38 +00:00
///////////////////////////////////////////////////////////
// Utilities
///////////////////////////////////////////////////////////
2007-08-09 10:33:02 +00:00
bool ErrorBox ( const wxString str )
2007-07-23 15:01:38 +00:00
{
2007-07-25 14:33:55 +00:00
wxMessageBox ( str , APPNAME , wxOK | wxICON_ERROR ) ;
return false ;
2007-07-23 15:01:38 +00:00
}
2007-08-09 10:33:02 +00:00
bool WarningBox ( const wxString str )
2007-07-23 15:01:38 +00:00
{
2007-07-25 14:33:55 +00:00
wxMessageBox ( str , APPNAME , wxOK | wxICON_EXCLAMATION ) ;
return false ;
2007-07-23 15:01:38 +00:00
}
wxString GetDefaultDestination ( )
{
wxString strDest ;
//scelta della directory di installazione di default
# ifdef WIN32
TCHAR strFolder [ MAX_PATH ] ;
: : SHGetFolderPath ( NULL , CSIDL_PROGRAM_FILES , NULL , SHGFP_TYPE_CURRENT , strFolder ) ;
strDest = strFolder ;
# endif
if ( strDest . IsEmpty ( ) )
{
// Forse <20> la cartella base dove <20> installato Word?
wxFileType * pDoc = wxTheMimeTypesManager - > GetFileTypeFromExtension ( wxT ( " doc " ) ) ;
if ( pDoc ! = NULL )
{
wxFileName strFilename = pDoc - > GetOpenCommand ( wxT ( " pippo.doc " ) ) ;
while ( strFilename . GetDirCount ( ) > 1 )
strFilename . RemoveLastDir ( ) ;
strDest = strFilename . GetPath ( ) . After ( ' " ' ) ;
if ( strDest . StartsWith ( wxT ( " C \\ " ) ) )
strDest = wxT ( " C: " ) + strDest . Mid ( 1 ) ;
}
}
return strDest ;
}
2007-08-08 09:24:19 +00:00
class CampoDirCopier : public wxDirTraverser
2007-07-23 15:01:38 +00:00
{
wxString m_strSrc , m_strDst ;
protected :
virtual wxDirTraverseResult OnDir ( const wxString & dirname ) ;
virtual wxDirTraverseResult OnFile ( const wxString & filename ) ;
public :
void RenameDLL ( const wxString & strDLL , bool bOpenGL ) const ;
bool Copy ( const wxString & src , const wxString & dst , bool bOpenGL ) ;
} ;
2007-08-08 09:24:19 +00:00
wxDirTraverseResult CampoDirCopier : : OnDir ( const wxString & dirname )
2007-07-23 15:01:38 +00:00
{
return wxDIR_CONTINUE ;
}
2007-08-08 09:24:19 +00:00
wxDirTraverseResult CampoDirCopier : : OnFile ( const wxString & filename )
2007-07-23 15:01:38 +00:00
{
wxFileName strSource ( filename ) ;
strSource . MakeRelativeTo ( m_strSrc ) ;
wxString str = m_strDst ;
str + = strSource . GetPathSeparator ( ) ;
str + = strSource . GetFullPath ( ) ;
wxFileName strDest ( str ) ;
if ( ! strDest . DirExists ( ) )
strDest . Mkdir ( ) ;
: : wxCopyFile ( filename , str ) ;
return wxDIR_CONTINUE ;
}
2007-08-08 09:24:19 +00:00
void CampoDirCopier : : RenameDLL ( const wxString & strDLL , bool bOpenGL ) const
2007-07-23 15:01:38 +00:00
{
wxFileName file1 ( m_strDst , strDLL ) ;
file1 . SetExt ( bOpenGL ? wxT ( " dll " ) : wxT ( " old " ) ) ;
if ( file1 . FileExists ( ) )
{
wxFileName file2 ( file1 ) ;
file2 . SetExt ( bOpenGL ? wxT ( " old " ) : wxT ( " dll " ) ) ;
wxRename ( file1 . GetFullPath ( ) , file2 . GetFullPath ( ) ) ;
}
}
2007-08-08 09:24:19 +00:00
bool CampoDirCopier : : Copy ( const wxString & src , const wxString & dst , bool bOpenGL )
2007-07-23 15:01:38 +00:00
{
wxBusyCursor hourglass ;
m_strSrc = src ;
m_strDst = dst ;
if ( ! wxDirExists ( m_strDst ) ) // Utile precauzione
wxMkdir ( m_strDst ) ;
wxDir dir ( m_strSrc ) ;
dir . Traverse ( * this ) ;
RenameDLL ( wxT ( " OpenGL32.dll " ) , bOpenGL ) ;
RenameDLL ( wxT ( " glu32.dll " ) , bOpenGL ) ;
return true ;
}
# ifdef WIN32
# endif
///////////////////////////////////////////////////////////
// CampoWizardPage
///////////////////////////////////////////////////////////
2007-07-23 15:38:10 +00:00
class CampoWizardPage ; //predefinizione di CampoWizardPage (magia nera!!)
//predefinizione pure della CampoWizard con tutti i suoi metodi per poterlo usare nel metodo GetWizard (magia nerissima!!)
class CampoWizard : public wxWizard
{
2007-07-25 14:33:55 +00:00
enum { m_nPages = 10 } ;
2007-07-23 15:38:10 +00:00
CampoWizardPage * m_pPage [ m_nPages ] ;
2007-07-31 10:11:16 +00:00
2007-07-31 11:16:04 +00:00
wxString _strDestinationPath ; //path di aggiornamento/installazione
2007-08-06 13:44:24 +00:00
unsigned int _uInstallationType ; //tipo di installazione selezionata (standard,server,client...)
2007-07-31 10:11:16 +00:00
wxString _strPrgLocPath ; //path programmi in locale
wxString _strPrgNetPath ; //path programmi in remoto (server prg dir per client)
wxString _strDataPath ; //path dati
wxString _strAuthSrv ; //nome server authoriz
wxString _strDictSrv ; //nome server diction
2007-07-31 11:16:04 +00:00
bool _bInstDemoData ; //installa dati dimostrativi
2007-07-31 10:11:16 +00:00
bool _bInstUseAuth ; //installa/usa server authoriz
2007-07-31 11:16:04 +00:00
wxString _strSrvAuth ; //server authoriz
2007-07-31 10:11:16 +00:00
bool _bInstUseDict ; //installa/usa server diction
2007-07-31 11:16:04 +00:00
wxString _strSrvDict ; //server diction
2007-08-08 09:24:19 +00:00
2007-08-08 14:26:35 +00:00
unsigned int _iSrvAutostartMode ; //tipologia di esecuzione dei server
2007-08-08 09:24:19 +00:00
bool _bDesktopShortcut ; //crea il link sul desktop
2007-07-23 15:38:10 +00:00
protected :
2007-07-26 14:00:16 +00:00
DECLARE_EVENT_TABLE ( ) ;
2007-07-23 15:38:10 +00:00
int Pages ( ) const { return m_nPages ; }
CampoWizardPage * Page ( int p ) const { return m_pPage [ p ] ; }
2007-07-26 14:00:16 +00:00
void OnNext ( wxCommandEvent & e ) ;
2007-07-23 15:38:10 +00:00
public :
bool Run ( ) ;
wxString Get ( wxWindowID id ) const ;
int GetSelection ( wxWindowID id ) const ;
bool GetBool ( wxWindowID id ) const ;
2007-07-31 11:16:04 +00:00
//metodi per il passaggio tra le finestre dei parametri di installazione!
2007-07-23 15:38:10 +00:00
void SetDestinationPath ( const wxString & path ) ;
const wxString & GetDestinationPath ( ) const ;
2007-07-24 15:44:05 +00:00
void SetInstallationType ( const unsigned int type ) ;
const unsigned int GetInstallationType ( ) const ;
2007-07-23 15:38:10 +00:00
2007-07-31 10:11:16 +00:00
void SetPrgLocPath ( const wxString & strPrgLocPath ) ;
const wxString & GetPrgLocPath ( ) const ;
void SetPrgNetPath ( const wxString & strPrgNetPath ) ;
const wxString & GetPrgNetPath ( ) const ;
void SetDataPath ( const wxString & strDataPath ) ;
const wxString & GetDataPath ( ) const ;
2007-07-31 11:16:04 +00:00
void SetInstDemoData ( const bool bInstDemoData ) ;
const bool GetInstDemoData ( ) const ;
void SetInstUseAuth ( const bool bInstUseAuth ) ;
const bool GetInstUseAuth ( ) const ;
void SetSrvAuth ( const wxString & strSrvAuth ) ;
const wxString & GetSrvAuth ( ) const ;
void SetInstUseDict ( const bool bInstUseDict ) ;
const bool GetInstUseDict ( ) const ;
void SetSrvDict ( const wxString & strSrvDict ) ;
const wxString & GetSrvDict ( ) const ;
2007-08-08 14:26:35 +00:00
void SetSrvAutostartMode ( const int iSrvAutostartMode ) ;
2007-08-08 14:19:12 +00:00
const int GetSrvAutostartMode ( ) const ;
2007-08-08 09:24:19 +00:00
void SetDesktopShortcut ( const bool bDesktopShortcut ) ;
const bool GetDesktopShortcut ( ) const ;
2007-07-23 15:38:10 +00:00
CampoWizard ( wxWindow * pParent ) ;
} ;
2007-07-23 15:01:38 +00:00
2007-08-03 10:59:50 +00:00
////////////////////////////////////////////////////////////////////////////////////////////
//Classe per la gestione dei files di configurazione tipo campo.ini
class CampoIniFile : public wxFileConfig
{
protected :
public :
wxString Get ( const wxString strVariable ) const ;
bool GetBool ( const wxString strVariable ) const ;
CampoIniFile ( const wxString strIniPath , const wxString strParagraph ) ;
} ;
CampoIniFile : : CampoIniFile ( const wxString strIniPath , const wxString strParagraph )
2007-08-09 10:33:02 +00:00
: wxFileConfig ( wxEmptyString , wxEmptyString , wxEmptyString , strIniPath ,
wxCONFIG_USE_GLOBAL_FILE | wxCONFIG_USE_NO_ESCAPE_CHARACTERS )
2007-08-03 10:59:50 +00:00
{
if ( ! strParagraph . IsEmpty ( ) )
SetPath ( strParagraph ) ;
}
2007-07-26 14:00:16 +00:00
2007-08-03 10:59:50 +00:00
wxString CampoIniFile : : Get ( const wxString strVariable ) const
{
return Read ( strVariable ) ;
}
2007-07-26 14:00:16 +00:00
2007-08-03 10:59:50 +00:00
bool CampoIniFile : : GetBool ( const wxString strVariable ) const
{
wxString strBool = Get ( strVariable ) ;
return strBool = = " X " | | strBool = = " Y " ;
}
////////////////////////////////////////////////////////////////////////////////////////////
2007-07-25 10:43:05 +00:00
//Campo wizard page (pagina generica del programma, di cui saranno figlie le singole pagine)
2007-07-23 15:01:38 +00:00
class CampoWizardPage : public wxWizardPageSimple
{
wxHtmlWindow * m_pText ;
protected :
2007-07-23 15:38:10 +00:00
CampoWizard & GetWizard ( ) const { return * ( CampoWizard * ) GetParent ( ) ; }
2007-07-23 15:01:38 +00:00
void SetHTMLText ( const wxString strTitle , const wxString strBody ) ;
void SetHTMLPage ( const wxString strFile ) ;
2007-08-03 10:59:50 +00:00
wxString Bold ( const wxString strStr ) const ;
2007-07-25 10:43:05 +00:00
void AddLabel ( wxSizer * pSizer , const wxChar * label ) ;
void AddLabel ( wxGridBagSizer * pSizer , const wxChar * label , unsigned int row , unsigned int column ) ;
2007-08-03 10:59:50 +00:00
bool CheckDataDir ( wxString & strDataPath ) const ;
2007-07-23 15:01:38 +00:00
public :
2007-07-26 14:00:16 +00:00
virtual bool ForwardValidate ( ) { return true ; }
2007-07-23 15:01:38 +00:00
wxString Get ( wxWindowID id ) const ;
2007-07-31 11:16:04 +00:00
bool GetBool ( wxWindowID id ) const ;
2007-07-23 15:01:38 +00:00
bool Set ( wxWindowID id , const wxString & str ) ;
2007-08-08 10:08:54 +00:00
bool Set ( wxWindowID id , const bool bul ) ;
2007-07-23 15:01:38 +00:00
int GetSelection ( wxWindowID id ) const ;
CampoWizardPage ( wxWizard * parent ) ;
} ;
wxString CampoWizardPage : : Get ( wxWindowID id ) const
{
wxWindow * pWnd = FindWindowById ( id ) ;
return pWnd ? pWnd - > GetLabel ( ) : wxEmptyString ;
}
2007-07-31 11:16:04 +00:00
bool CampoWizardPage : : GetBool ( wxWindowID id ) const
{
wxCheckBox * pWnd = ( wxCheckBox * ) FindWindowById ( id ) ;
return pWnd ! = NULL & & pWnd - > IsChecked ( ) ;
}
2007-07-23 15:01:38 +00:00
bool CampoWizardPage : : Set ( wxWindowID id , const wxString & str )
{
wxWindow * pWnd = FindWindowById ( id ) ;
if ( pWnd )
pWnd - > SetLabel ( str ) ;
return ( pWnd ! = NULL ) ;
}
2007-08-08 10:08:54 +00:00
bool CampoWizardPage : : Set ( wxWindowID id , const bool bul )
{
wxCheckBox * pWnd = ( wxCheckBox * ) FindWindowById ( id ) ;
if ( pWnd )
pWnd - > SetValue ( bul ) ;
return ( pWnd ! = NULL ) ;
}
2007-07-23 15:01:38 +00:00
int CampoWizardPage : : GetSelection ( wxWindowID id ) const
{
int n = - 1 ;
wxWindow * pWnd = FindWindowById ( id ) ;
if ( pWnd )
{
wxChoice * pList = ( wxChoice * ) pWnd ;
n = pList - > GetSelection ( ) ;
}
return n ;
}
void CampoWizardPage : : SetHTMLPage ( const wxString strFile )
{
m_pText - > LoadPage ( strFile ) ;
}
2007-07-23 15:38:10 +00:00
//parte html della finestra standard
2007-07-23 15:01:38 +00:00
void CampoWizardPage : : SetHTMLText ( wxString strTitle , wxString strBody )
{
2007-08-03 10:59:50 +00:00
wxString strAppName = wxT ( " <i> " ) ; strAppName + = Bold ( APPNAME ) ; strAppName + = wxT ( " </i> " ) ;
2007-07-23 15:01:38 +00:00
strTitle . Replace ( wxT ( " APPNAME " ) , strAppName ) ;
strBody . Replace ( wxT ( " APPNAME " ) , strAppName ) ;
wxString str ;
str + = wxT ( " <html><body> " ) ;
str + = wxT ( " <p align=center><b> " ) ; str + = strTitle ; str + = wxT ( " </b></p> " ) ;
str + = wxT ( " <hr> " ) ;
str + = wxT ( " <div align=justify> " ) ; str + = strBody ; str + = wxT ( " </div> " ) ;
str + = wxT ( " </body></html> " ) ;
m_pText - > SetPage ( str ) ;
}
2007-08-03 10:59:50 +00:00
wxString CampoWizardPage : : Bold ( const wxString strStr ) const
{
wxString strBold ;
strBold < < " <b> " < < strStr < < " </b> " ;
return strBold ;
}
2007-07-25 10:43:05 +00:00
//metodo per aggiungere i prompt agli oggetti contenuti nelle GridSize e similia
void CampoWizardPage : : AddLabel ( wxSizer * pSizer , const wxChar * label )
{
pSizer - > Add ( new wxStaticText ( this , wxID_ANY , label ) , 0 , wxALL | wxALIGN_CENTER_VERTICAL ) ;
}
void CampoWizardPage : : AddLabel ( wxGridBagSizer * pSizer , const wxChar * label , unsigned int row , unsigned int column )
{
pSizer - > Add ( new wxStaticText ( this , wxID_ANY , label ) , wxGBPosition ( row , column ) ) ;
}
2007-08-03 10:59:50 +00:00
//metodo per il controllo della validita' di un'area dati
bool CampoWizardPage : : CheckDataDir ( wxString & strDataPath ) const
{
wxDir dirDataPath ( strDataPath ) ;
bool ok_data = false ;
//deve esistere non vuota, e contenere la sottodirectory "com" con i dati comuni
if ( dirDataPath . Exists ( strDataPath ) & & dirDataPath . HasSubDirs ( " com " ) )
{
strDataPath < < " /com " ;
wxFileName fnFileToCheck ( strDataPath , " tabcom " ) ;
fnFileToCheck . SetExt ( " dbf " ) ;
if ( fnFileToCheck . FileExists ( ) )
ok_data = true ;
}
return ok_data ;
}
2007-07-23 15:38:10 +00:00
//costruttore della finestra standard
2007-07-23 15:01:38 +00:00
CampoWizardPage : : CampoWizardPage ( wxWizard * parent )
: wxWizardPageSimple ( parent )
{
wxBoxSizer * pSizer = new wxBoxSizer ( wxVERTICAL ) ;
m_pText = new wxHtmlWindow ( this , 100 , wxDefaultPosition , wxSize ( 512 , 256 ) ) ;
pSizer - > Add ( m_pText , 0 , wxALL , 0 ) ;
pSizer - > AddSpacer ( 5 ) ;
SetSizer ( pSizer ) ;
}
/**********************************************************************************************************/
/* 1 Pagina di benvenuto */
/**********************************************************************************************************/
class CampoWizardPage1 : public CampoWizardPage
{
public :
CampoWizardPage1 ( wxWizard * parent ) ;
} ;
CampoWizardPage1 : : CampoWizardPage1 ( wxWizard * parent ) : CampoWizardPage ( parent )
{
//contenuto della prima schermata (pagina benvenuto)
wxString strTitle = wxT ( " Benvenuti in <b>APPNAME</b> " ) ;
2007-07-24 15:44:05 +00:00
wxString strBody = wxT ( " <p>Questo programma vi guider<65> passo a passo nell'installazione / aggiornamento del software.</p> " ) ;
2007-08-03 10:59:50 +00:00
strBody + = wxT ( " <p><u><b>Leggere attentamente le istruzioni</u> che saranno visualizzate nelle finestre di questo programma di installazione!</b></p> " ) ;
2007-07-31 10:11:16 +00:00
strBody + = wxT ( " <p>Prima di proseguire con l'installazione / aggiornamento <u>assicurarsi di avere effettuato il login a Windows con un utente di tipo 'Amministratore' di sistema.</u></p> " ) ;
2007-07-23 15:01:38 +00:00
SetHTMLText ( strTitle , strBody ) ;
}
/**********************************************************************************************************/
/* 2 Pagina con la scelta di Aggiornamento / Tipo Installazione */
/**********************************************************************************************************/
class CampoWizardPage2 : public CampoWizardPage
{
wxRadioBox * m_pRadioBox ;
protected :
2007-07-26 14:00:16 +00:00
virtual bool ForwardValidate ( ) ;
2007-07-23 15:01:38 +00:00
public :
CampoWizardPage2 ( wxWizard * parent ) ;
} ;
2007-07-26 14:00:16 +00:00
bool CampoWizardPage2 : : ForwardValidate ( )
2007-07-23 15:01:38 +00:00
{
2007-08-03 10:59:50 +00:00
const int iLastRow = m_pRadioBox - > GetRowCount ( ) - 1 ;
const int iSelectedRow = m_pRadioBox - > GetSelection ( ) ;
wxString strPrgPath ;
wxString strStudy ;
wxString strSrvAuth ;
wxString strSrvDict ;
2007-08-06 13:44:24 +00:00
//analizza il campo.ini dell'installazione selezionata (si usa < perche' l'ultima row e' la nuova installazione!)
2007-08-03 10:59:50 +00:00
if ( iSelectedRow < iLastRow )
{
strPrgPath = m_pRadioBox - > GetStringSelection ( ) ;
CampoIniFile CampoIni ( strPrgPath + " /campo.ini " , " Main " ) ;
const bool bTestDatabase = CampoIni . GetBool ( " TestDatabase " ) ;
2007-07-23 15:01:38 +00:00
2007-08-03 10:59:50 +00:00
//non si puo' aggiornare un client da cd!! va fatto dal programma
const bool bTestPrograms = CampoIni . GetBool ( " TestPrograms " ) ;
if ( bTestPrograms )
{
CampoIniFile InstallIni ( strPrgPath + " /install.ini " , " Main " ) ;
wxString strDiskPath = InstallIni . Get ( " DiskPath " ) ;
wxString strMsg = " Per aggiornare questa stazione di lavoro e' necessario aggiornare prima il Server di " ;
strMsg < < APPNAME < < " in " < < strDiskPath < < " ! \n " ;
strMsg < < " Questa stazione di lavoro si aggiornera' automaticamente alla prima esecuzione del programma " < < APPNAME ;
return ErrorBox ( strMsg ) ;
}
strStudy = CampoIni . Get ( " Study " ) ;
CampoIniFile CampoServerIni ( strPrgPath + " /campo.ini " , " Server " ) ;
strSrvAuth = CampoServerIni . Get ( " Dongle " ) ;
strSrvDict = CampoServerIni . Get ( " Dictionary " ) ;
2007-07-23 15:01:38 +00:00
2007-08-03 10:59:50 +00:00
if ( ! CheckDataDir ( strStudy ) )
return ErrorBox ( " La cartella indicata come area dati NON e' valida! \n Interrompere l'installazione e selezionare un'area dati valida \n con il programma Campo " ) ;
GetWizard ( ) . SetDataPath ( strStudy ) ;
if ( ! strSrvAuth . IsEmpty ( ) )
GetWizard ( ) . SetSrvAuth ( strSrvAuth ) ;
if ( ! strSrvDict . IsEmpty ( ) )
GetWizard ( ) . SetSrvDict ( strSrvDict ) ;
2007-07-26 14:43:09 +00:00
2007-08-06 13:44:24 +00:00
//setta alla pagina riassuntiva i valori della pagina attuale...
GetWizard ( ) . SetDestinationPath ( strPrgPath ) ; //va alla pagina riassuntiva
2007-08-08 09:24:19 +00:00
GetWizard ( ) . SetPrgLocPath ( strPrgPath ) ; //questo serve solo per la creazione del link sul desktop!
2007-08-06 13:44:24 +00:00
GetWizard ( ) . SetInstallationType ( 3 ) ; //e' un aggiornamento!!
2007-08-08 10:08:54 +00:00
GetWizard ( ) . SetDesktopShortcut ( false ) ;
2007-08-06 13:44:24 +00:00
}
else //resetta il path in caso si scelga nuova installazione dopo aver scelto aggiornamento
{
GetWizard ( ) . SetDestinationPath ( " " ) ;
2007-08-08 10:08:54 +00:00
GetWizard ( ) . SetDesktopShortcut ( true ) ;
2007-08-06 13:44:24 +00:00
}
2007-07-23 15:01:38 +00:00
return true ;
}
CampoWizardPage2 : : CampoWizardPage2 ( wxWizard * parent ) : CampoWizardPage ( parent )
{
//deve cercare campo.stp
2007-08-03 10:59:50 +00:00
CampoIniFile campo_stp ( " C: \\ campo.stp " , " " ) ;
2007-07-23 15:01:38 +00:00
wxString group ;
long index ;
const wxString program = " Program " ;
2007-07-24 15:44:05 +00:00
wxArrayString asGroups , asCampi ;
2007-07-23 15:01:38 +00:00
//cerca se esiste campo.stp;se lo trova cerca quelle che sono le installazioni valide;se ne trova..
2007-07-24 15:44:05 +00:00
//..le aggiunge ad un array di stringhe (asCampi) da cui genera un radiobutton di scelte
2007-07-23 15:01:38 +00:00
for ( bool ok = campo_stp . GetFirstGroup ( group , index ) ; ok ; ok = campo_stp . GetNextGroup ( group , index ) )
{
2007-07-24 15:44:05 +00:00
asGroups . Add ( group ) ;
2007-07-23 15:01:38 +00:00
}
int prechecked = - 1 ;
2007-07-24 15:44:05 +00:00
for ( unsigned int i = 0 ; i < asGroups . GetCount ( ) ; i + + )
2007-07-23 15:01:38 +00:00
{
2007-08-03 10:59:50 +00:00
CampoIniFile campo_stp ( " C: \\ campo.stp " , asGroups [ i ] ) ;
wxString path = campo_stp . Get ( program ) ;
2007-07-23 15:01:38 +00:00
//sono installazioni valide quelle che presentano la coppia di files campo.ini e campo.aut (senza..
//..questi 2 soggetti il programma non parte)
wxString campo_ini = path ;
2007-07-26 14:00:16 +00:00
campo_ini < < " /campo.ini " ;
2007-07-23 15:01:38 +00:00
wxString campo_aut = path ;
2007-07-26 14:00:16 +00:00
campo_aut < < " /campo.aut " ;
2007-07-23 15:01:38 +00:00
if ( wxFileName : : FileExists ( campo_ini ) & & wxFileName : : FileExists ( campo_aut ) )
{
2007-07-24 15:44:05 +00:00
asCampi . Add ( path ) ;
2007-07-23 15:01:38 +00:00
//cerca l'eventuale installazione server se ci sono piu' installazioni sulla stessa macchina
if ( prechecked < 0 )
{
2007-08-03 10:59:50 +00:00
CampoIniFile ini ( campo_ini , " Main " ) ;
if ( ini . GetBool ( " TestDatabase " ) & & ! ini . GetBool ( " TestPrograms " ) )
2007-07-23 15:01:38 +00:00
prechecked = i ;
}
}
}
2007-07-24 15:44:05 +00:00
wxString strTitle , strBody ;
2007-07-23 15:01:38 +00:00
//se non ci sono delle installazioni da aggiornare propone solo installazioni..
2007-07-24 15:44:05 +00:00
if ( asCampi . IsEmpty ( ) )
2007-07-23 15:01:38 +00:00
{
2007-07-24 15:44:05 +00:00
strTitle + = wxT ( " Scelta Installazione " ) ;
strBody + = wxT ( " <p>E' possibile <b>INSTALLARE <i>Campo</i></b> in un nuovo direttorio.</p> " ) ;
2007-07-23 15:01:38 +00:00
2007-07-24 15:44:05 +00:00
asCampi . Add ( " Nuova installazione " ) ; //voce di nuova installazione!
2007-07-23 15:01:38 +00:00
m_pRadioBox = new wxRadioBox ( this , 201 , " Installazione del software " , wxDefaultPosition ,
2007-07-24 15:44:05 +00:00
wxDefaultSize , asCampi , 0 , wxRA_SPECIFY_ROWS ) ;
2007-07-23 15:01:38 +00:00
}
//..senno' propone di aggiornare
else
{
2007-07-24 15:44:05 +00:00
strTitle + = wxT ( " Scelta Aggiornamento / Installazione " ) ;
strBody + = wxT ( " <p>E' possibile <b>AGGIORNARE (scelta consigliata)</b> una installazione di <b><i>Campo</i></b> gia' presente oppure <b>INSTALLARE</b> in un nuovo direttorio.</p> " ) ;
2007-07-26 14:43:09 +00:00
strBody + = wxT ( " <p>Selezionare l'opzione desiderata nel riquadro sottostante. In caso di piu' di una installazione " ) ;
strBody + = wxT ( " presente sara' preselezionata la eventuale installazione di tipo <b>Server</b>, in quanto <u>deve essere aggiornata per prima</u>! " ) ;
2007-08-03 10:59:50 +00:00
strBody + = wxT ( " <p>In questo caso procedere all'aggiornamento di tale installazione Server e <u>aggiornare successivamente le postazioni client " ) ;
strBody + = wxT ( " lanciando il programma <b><i>Campo</i></b> su di esse</u></p> " ) ;
2007-07-23 15:01:38 +00:00
//radiobutton con le scelte aggiornamento
2007-07-24 15:44:05 +00:00
asCampi . Add ( " Nuova installazione " ) ;
2007-07-23 15:01:38 +00:00
m_pRadioBox = new wxRadioBox ( this , 201 , " Selezionare l'installazione da aggiornare (consigliato) o Nuova installazione " , wxDefaultPosition ,
2007-07-24 15:44:05 +00:00
wxDefaultSize , asCampi , 0 , wxRA_SPECIFY_ROWS ) ;
2007-07-23 15:01:38 +00:00
if ( prechecked > 0 )
m_pRadioBox - > SetSelection ( prechecked ) ;
}
2007-07-24 15:44:05 +00:00
strBody + = wxT ( " <p>Prima di proseguire accertarsi che non vi sia alcuna sessione di <b><i>Campo</i></b> attiva! " ) ;
strBody + = wxT ( " Terminare quindi le eventuali sessioni di <b><i>Campo</i></b> attive e proseguire.</p> " ) ;
SetHTMLText ( strTitle , strBody ) ;
2007-07-23 15:01:38 +00:00
GetSizer ( ) - > Add ( m_pRadioBox ) ;
}
/**********************************************************************************************************/
// 3 Pagina con Accetta / Rifiuta la licenza
//*********************************************************************************************************/
class CampoWizardPage3 : public CampoWizardPage
{
protected :
2007-07-26 14:00:16 +00:00
virtual bool ForwardValidate ( ) ;
2007-07-23 15:01:38 +00:00
public :
CampoWizardPage3 ( wxWizard * parent ) ;
} ;
2007-07-26 14:00:16 +00:00
bool CampoWizardPage3 : : ForwardValidate ( )
2007-07-23 15:01:38 +00:00
{
if ( GetSelection ( 301 ) = = 1 )
2007-07-25 14:33:55 +00:00
return ErrorBox ( " Impossibile proseguire se non si accetta la licenza sul software!! " ) ;
2007-07-23 15:01:38 +00:00
return true ;
}
CampoWizardPage3 : : CampoWizardPage3 ( wxWizard * parent ) : CampoWizardPage ( parent )
{
SetHTMLPage ( " licenza.htm " ) ;
//radiobutton Accetta / Rifiuta
2007-07-24 15:44:05 +00:00
wxArrayString asAccRef ;
asAccRef . Add ( " Accetta " ) ;
asAccRef . Add ( " Rifiuta " ) ;
2007-07-23 15:01:38 +00:00
wxRadioBox * radio_box = new wxRadioBox ( this , 301 , " Selezionare 'Accetta' per proseguire con l'installazione, 'Rifiuta' per terminare l'installazione " , wxDefaultPosition ,
2007-07-24 15:44:05 +00:00
wxDefaultSize , asAccRef , 0 , wxRA_SPECIFY_COLS ) ;
2007-07-23 15:01:38 +00:00
radio_box - > SetSelection ( 1 ) ;
GetSizer ( ) - > Add ( radio_box ) ;
}
/**********************************************************************************************************/
/* 4 Pagina con la gestione della chiave di protezione */
/**********************************************************************************************************/
class CampoWizardPage4 : public CampoWizardPage
{
int _dongle_type ;
wxButton * _butt_HL ;
wxButton * _butt_EU ;
protected :
DECLARE_EVENT_TABLE ( ) ;
void OnHLPick ( wxCommandEvent & e ) ;
void OnEUPick ( wxCommandEvent & e ) ;
int DongleTest ( ) ;
int ThisYear ( ) ;
wxString DecodeString ( const wxString & data ) ;
int VersionYear ( ) ;
void BuildKey ( char * key ) ;
bool HardlockGarble ( unsigned short * data ) ;
unsigned short HardlockLogin ( int & year ) ;
void EncodeEutronPassword ( char * str ) ;
unsigned short EutronLogin ( int & year ) ;
public :
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 ( 401 , OnHLPick )
EVT_BUTTON ( 402 , OnEUPick )
END_EVENT_TABLE ( )
void CampoWizardPage4 : : OnHLPick ( wxCommandEvent & e )
{
2007-08-08 15:24:46 +00:00
wxString path ( " ../chiavi/hardlock/hldrv32.exe " ) ;
2007-07-23 15:01:38 +00:00
wxExecute ( path , wxEXEC_SYNC ) ;
}
void CampoWizardPage4 : : OnEUPick ( wxCommandEvent & e )
{
2007-08-08 15:24:46 +00:00
wxString path ( " ../chiavi/eutron/sdi.exe " ) ;
2007-07-23 15:01:38 +00:00
wxExecute ( path , wxEXEC_SYNC ) ;
}
///////////////////////////////
// Gestione chiave Hardlock //
///////////////////////////////
bool CampoWizardPage4 : : HardlockGarble ( unsigned short * data )
{
HL_CODE ( data , 1 ) ;
return true ;
}
unsigned short CampoWizardPage4 : : HardlockLogin ( int & year )
{
unsigned short serno = 0xFFFF ;
unsigned char REFKEY [ 16 ] = " CAMPOKEY " ;
unsigned char VERKEY [ 16 ] = " <EFBFBD> pو<EFBFBD> c<EFBFBD> <" ;
if ( HL_LOGIN ( 26952 , LOCAL_DEVICE , REFKEY , VERKEY ) = = STATUS_OK )
{
unsigned short eprom [ 64 ] ; memset ( eprom , 0 , sizeof ( eprom ) ) ;
HL_READBL ( ( unsigned char * ) eprom ) ;
unsigned short data [ 4 ] ;
memcpy ( data , eprom , sizeof ( data ) ) ;
HardlockGarble ( data ) ;
if ( data [ 0 ] = = 0xFAE8 )
serno = data [ 1 ] ;
else
serno = 0 ;
memcpy ( data , & eprom [ 60 ] , sizeof ( data ) ) ;
if ( HardlockGarble ( data ) )
year = ( int ) data [ 0 ] ;
}
return serno ;
}
///////////////////////////////
// Gestione chiave Eutron //
///////////////////////////////
void CampoWizardPage4 : : EncodeEutronPassword ( char * str )
{
const char * const key = " QSECOFR- " ;
char tmp [ 16 ] ;
int i ;
for ( i = 0 ; str [ i ] ; i + + )
tmp [ i ] = str [ i ] + ( i < 8 ? key [ i ] : str [ i - 8 ] ) ;
tmp [ i ] = ' \0 ' ;
strcpy ( str , tmp ) ;
}
unsigned short CampoWizardPage4 : : EutronLogin ( int & year )
{
unsigned short serno = 0xFFFF ;
const char * const login [ 2 ] = { " AGA.CAMPO " , " 25EBAI " } ;
for ( int i = 0 ; i < 2 ; i + + )
{
KEY_NET eutron_key ;
memset ( & eutron_key , 0 , sizeof ( KEY_NET ) ) ;
eutron_key . net_command = NET_KEY_OPEN ;
eutron_key . command = LOCATING_MODE ;
const char * const chiaro = login [ i ] ;
char cifrato [ 16 ] ;
strcpy ( cifrato , chiaro ) ;
EncodeEutronPassword ( cifrato ) ;
memset ( eutron_key . label , 0 , LABEL_LENGTH ) ;
strcpy ( ( char * ) eutron_key . label , chiaro ) ;
memset ( eutron_key . password , 0 , PASSWORD_LENGTH ) ;
strcpy ( ( char * ) eutron_key . password , cifrato ) ;
smartlink ( & eutron_key ) ;
if ( eutron_key . status = = ST_OK )
{
eutron_key . net_command = NET_KEY_ACCESS ;
eutron_key . command = BLOCK_READING_MODE ;
short * pointer = ( short * ) ( & eutron_key . data [ 0 ] ) ;
short * number = ( short * ) ( & eutron_key . data [ 2 ] ) ;
* pointer = 0 ; // Posizione in cui leggere
* number = 8 ; // Words da leggere
smartlink ( & eutron_key ) ;
if ( eutron_key . status = = ST_OK )
{
serno = ( unsigned short ) atol ( ( const char * ) eutron_key . data + 4 ) ;
if ( i = = 0 )
{
const unsigned short y = * ( unsigned short * ) ( eutron_key . data + 12 ) ;
if ( y > 2000 & & y < 3000 )
year = y ;
}
else
year = ThisYear ( ) ;
break ;
}
}
}
return serno ;
}
/////////////////////////////////////////////////////////
// Metodi generici per le chiavi ed i relativi codici //
/////////////////////////////////////////////////////////
void CampoWizardPage4 : : BuildKey ( char * key )
{
for ( int i = 0 ; i < 8 ; i + + )
key [ i ] = ' A ' + rand ( ) % 26 ;
}
int CampoWizardPage4 : : ThisYear ( )
{
int anno = 2006 ;
time_t lt ;
if ( time ( & lt ) = = 0 )
{
struct tm * timeloc = localtime ( & lt ) ;
if ( timeloc ! = NULL )
anno = timeloc - > tm_year + 1900 ;
}
return anno ;
}
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 ) , " ./program/zip/install.ini " ) ;
ver [ 4 ] = ' \0 ' ;
return atoi ( ver ) ;
}
int CampoWizardPage4 : : DongleTest ( )
{
_dongle_type = 0 ;
int yearKey = 0 ;
unsigned int serno = HardlockLogin ( yearKey ) ;
if ( serno = = 0xFFFF )
{
serno = EutronLogin ( yearKey ) ;
if ( serno ! = 0xFFFF )
_dongle_type = 2 ; //chiave eutron
}
else
_dongle_type = 1 ; //chiave hardlock
if ( serno = = 0 ) // Chiave di sviluppo
return _dongle_type ;
if ( serno = = 0xFFFF ) // Chiave inesistente o invisibile = Prima installazione o demo
return _dongle_type ;
const int verYear = VersionYear ( ) ;
if ( yearKey < verYear ) // Chiave gi<67> programmata con assistenza pagata
{
bool ok = false ;
wxFileInputStream file ( " ./program/zip/dninst.zip " ) ;
if ( file . IsOk ( ) )
{
wxTextInputStream keys ( file ) ;
wxString line = keys . ReadLine ( ) ;
srand ( 883 ) ;
DecodeString ( line ) ;
const int ass_year = atoi ( line ) ;
if ( ass_year > yearKey ) // Non devo abbassare l'anno di assistenza!
{
srand ( ass_year ) ;
while ( ! file . Eof ( ) )
{
line = keys . ReadLine ( ) ;
line = DecodeString ( line ) ;
unsigned int sn = ( unsigned int ) atol ( line ) ;
if ( sn = = serno | | line [ 0 ] = = ' * ' )
{
ok = true ;
break ;
}
}
if ( ok )
{
const int n = ass_year % 10 ;
const int y = ( ass_year / 1000 ) * 1000 + ( ass_year % 1000 ) / 10 ;
line . Printf ( " Il contratto di manutenzione %d/%d verr<72> attivato automaticamente " , y , n ) ;
WarningBox ( line ) ;
}
else
{
line . Printf ( " <EFBFBD> necessario contattare l'assistenza tecnica\n "
" per l'abilitazione del contratto di manutenzione %d " , verYear ) ;
WarningBox ( line ) ;
}
}
}
else
{
ErrorBox ( " Impossibile verificare il contratto di manutenzione " ) ;
}
}
return _dongle_type ;
}
CampoWizardPage4 : : CampoWizardPage4 ( wxWizard * parent ) : CampoWizardPage ( parent )
{
_dongle_type = DongleTest ( ) ; //controlla se la chiave c'e' ed eventualmente quale e'
wxString strTitle = wxT ( " Controllo della chiave hardware di protezione " ) ;
wxString strBody = wxT ( " <p>La versione commerciale del software richiede l'installazione e la presenza della chiave hardware di protezione</p> " ) ;
switch ( _dongle_type )
{
case 1 :
strBody + = wxT ( " <p>E' stata rilevata una chiave tipo <b>Hardlock</b>:</p> " ) ;
strBody + = wxT ( " <p align=center><img src= \" hardlock.gif \" /></p> " ) ;
2007-07-24 15:44:05 +00:00
strBody + = wxT ( " <p>Si puo' procedere con l'installazione /aggiornamento del software <b><i>Campo</i></b>. Premere il pulsante \" Next \" .</p> " ) ;
2007-07-23 15:01:38 +00:00
break ;
case 2 :
strBody + = wxT ( " <p>E' stata rilevata una chiave tipo <b>Eutron</b>:</p> " ) ;
strBody + = wxT ( " <p align=center><img src= \" eutron.gif \" /></p> " ) ;
2007-07-24 15:44:05 +00:00
strBody + = wxT ( " <p>Si puo' procedere con l'installazione /aggiornamento del software <b><i>Campo</i></b>. Premere il pulsante \" Next \" .</p> " ) ;
2007-07-23 15:01:38 +00:00
break ;
//case 3: e' il caso del server di chiavi;la DongleTest() per ora non lo fa
//break;
default :
strBody + = wxT ( " <p><b>Non e' stata rilevata alcuna chiave hardware installata !</b></p> " ) ;
strBody + = wxT ( " <p>Per procedere all'installazione dei driver della chiave hardware collegata al computer premere il bottone corrispondente alla tipologia della chiave stessa.</p> " ) ;
strBody + = wxT ( " <p>Se si desidera proseguire nell'installazione del software senza installare la chiave hardware cliccare su \" Next \" .</p> " ) ;
strBody + = wxT ( " <p>Quest'ultima procedura e' consigliata solo in caso di installazione tipo <b>Client</b> di rete senza chiave propria, ma che utilizza un server di autorizzazioni gia' installato e funzionante in rete.</p> " ) ;
//procedura per la costruzione dei bottoni e delle immagini per l'installazione dei driver di chiave
//"griglia" contenitrice degli oggetti
wxBoxSizer * butt_box = new wxBoxSizer ( wxHORIZONTAL ) ;
GetSizer ( ) - > Add ( butt_box , 0 , wxALIGN_CENTER_HORIZONTAL , 0 ) ;
//Hardlock img e button
wxBitmap bmp_HL ( " hardlock.gif " , wxBITMAP_TYPE_GIF ) ;
wxStaticBitmap * s_bmp_HL = new wxStaticBitmap ( this , wxID_ANY , bmp_HL ) ;
butt_box - > Add ( s_bmp_HL , 0 , wxALIGN_CENTER_HORIZONTAL | wxALL , 8 ) ;
_butt_HL = new wxButton ( this , 401 , " Hardlock " , wxDefaultPosition , wxSize ( 100 , 50 ) ) ;
butt_box - > Add ( _butt_HL , 0 , wxALIGN_CENTER_HORIZONTAL | wxALL , 8 ) ;
//spaziatore centrale
butt_box - > AddSpacer ( 24 ) ;
//Eutron img e button
_butt_EU = new wxButton ( this , 402 , " Eutron " , wxDefaultPosition , wxSize ( 100 , 50 ) ) ;
butt_box - > Add ( _butt_EU , 0 , wxALIGN_CENTER_HORIZONTAL | wxALL , 8 ) ;
wxBitmap bmp_EU ( " eutron.gif " , wxBITMAP_TYPE_GIF ) ;
wxStaticBitmap * s_bmp_EU = new wxStaticBitmap ( this , wxID_ANY , bmp_EU ) ;
butt_box - > Add ( s_bmp_EU , 0 , wxALIGN_CENTER_HORIZONTAL | wxALL , 8 ) ;
break ;
}
SetHTMLText ( strTitle , strBody ) ;
}
/**********************************************************************************************************/
2007-07-24 15:44:05 +00:00
// 5 Scelta tipo installazione
2007-07-23 15:01:38 +00:00
/**********************************************************************************************************/
class CampoWizardPage5 : public CampoWizardPage
{
2007-07-24 15:44:05 +00:00
wxRadioBox * m_pRadioBox ;
2007-07-23 15:01:38 +00:00
protected :
2007-07-26 14:00:16 +00:00
virtual bool ForwardValidate ( ) ;
2007-07-24 15:44:05 +00:00
2007-07-23 15:01:38 +00:00
public :
CampoWizardPage5 ( wxWizard * parent ) ;
} ;
2007-07-24 15:44:05 +00:00
2007-07-26 14:00:16 +00:00
bool CampoWizardPage5 : : ForwardValidate ( )
2007-07-24 15:44:05 +00:00
{
const unsigned int type = m_pRadioBox - > GetSelection ( ) ;
GetWizard ( ) . SetInstallationType ( type ) ;
return true ;
}
2007-07-23 15:01:38 +00:00
CampoWizardPage5 : : CampoWizardPage5 ( wxWizard * parent ) : CampoWizardPage ( parent )
{
2007-07-24 15:44:05 +00:00
//Istruzioni per l'uso!
wxString strTitle = wxT ( " Scelta del tipo di installazione " ) ;
wxString strBody = wxT ( " <p><b>Standard (scelta consigliata)</b>. Installazione su postazione singola, con programmi e dati sul disco locale del computer</p> " ) ;
strBody + = wxT ( " <p><b>Installazioni di rete</b> (per utenti esperti)</p> " ) ;
strBody + = wxT ( " <p><b>Server</b>: 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 <b><i>Campo</i></b> e' necessario sia presente un unica postazione di tipo server, " ) ;
strBody + = wxT ( " e deve essere installata per prima!</p> " ) ;
strBody + = wxT ( " <p><b>Client</b>: Computer in rete sul quale e' presente una copia dei programmi ma non l'area dati. " ) ;
strBody + = wxT ( " I client possono essere installati solo dopo l'installazione del server!</p> " ) ;
2007-07-23 15:01:38 +00:00
SetHTMLText ( strTitle , strBody ) ;
2007-07-24 15:44:05 +00:00
//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
m_pRadioBox - > SetSelection ( 0 ) ;
GetSizer ( ) - > Add ( m_pRadioBox ) ;
2007-07-23 15:01:38 +00:00
}
2007-07-24 15:44:05 +00:00
/**********************************************************************************************************/
// 6 Installazione standard
/**********************************************************************************************************/
2007-07-23 15:01:38 +00:00
class CampoWizardPage6 : public CampoWizardPage
{
protected :
2007-07-25 10:43:05 +00:00
DECLARE_EVENT_TABLE ( ) ;
void OnDirPick ( wxCommandEvent & e ) ;
2007-07-26 14:00:16 +00:00
virtual bool ForwardValidate ( ) ;
2007-07-25 10:43:05 +00:00
2007-07-23 15:01:38 +00:00
public :
CampoWizardPage6 ( wxWizard * parent ) ;
} ;
2007-07-25 10:43:05 +00:00
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 ) ;
}
}
2007-07-25 14:33:55 +00:00
//metodo per il controllo dell'area dati;se la directory indicata non e' vuota non puoi usarla ne' crearla
2007-07-26 14:00:16 +00:00
bool CampoWizardPage6 : : ForwardValidate ( )
2007-07-25 14:33:55 +00:00
{
2007-07-31 10:11:16 +00:00
//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 e' valida! Selezionarne un'altra! " ) ;
const wxString strDataPath = Get ( 603 ) ;
wxDir dirDataPath ( strDataPath ) ;
if ( dirDataPath . Exists ( strDataPath ) & & ( dirDataPath . HasFiles ( ) | | dirDataPath . HasSubDirs ( ) ) )
2007-07-25 14:33:55 +00:00
return ErrorBox ( " La cartella indicata per la creazione dell'area dati non e' vuota! Selezionarne un'altra! " ) ;
2007-07-31 11:16:04 +00:00
//setta alla pagina riassuntiva i valori della pagina attuale...
2007-07-31 10:11:16 +00:00
GetWizard ( ) . SetPrgLocPath ( strPrgLocPath ) ;
GetWizard ( ) . SetDataPath ( strDataPath ) ;
2007-07-31 11:16:04 +00:00
//...e pure quegli stupidi datidemo che nessuno ha mai installato!!
const bool bInstDemoData = GetBool ( 605 ) ;
GetWizard ( ) . SetInstDemoData ( bInstDemoData ) ;
2007-07-25 14:33:55 +00:00
return true ;
}
2007-07-23 15:01:38 +00:00
CampoWizardPage6 : : CampoWizardPage6 ( wxWizard * parent ) : CampoWizardPage ( parent )
{
2007-07-24 15:44:05 +00:00
wxString strTitle = wxT ( " Installazione di tipo Standard " ) ;
2007-07-25 10:43:05 +00:00
wxString strBody = wxT ( " <p>Digitare nel campo <b>'Cartella programma'</b> il percorso completo della cartella dove si desidera installare il programma. " ) ;
2007-07-26 09:15:04 +00:00
strBody + = wxT ( " Il percorso di default (consigliato) e' <i>C: \\ Campo</i> </p> " ) ;
2007-07-25 10:43:05 +00:00
strBody + = wxT ( " <p>Digitare nel campo <b>'Cartella Dati'</b> il percorso completo della cartella dove si desidera installare l'area dati. " ) ;
2007-07-26 09:15:04 +00:00
strBody + = wxT ( " Il percorso di default (consigliato) e' <i>C: \\ Campo \\ dati</i> </p> " ) ;
2007-07-25 14:33:55 +00:00
strBody + = wxT ( " <p><b>Dati dimostrativi:</b> area dati precompilata per esemplificare il funzionamento del software. " ) ;
strBody + = wxT ( " Di norma <b>NON</b> vanno caricati nel caso di una normale installazione!</p> " ) ;
2007-07-23 15:01:38 +00:00
SetHTMLText ( strTitle , strBody ) ;
2007-07-25 10:43:05 +00:00
//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 ;
2007-07-26 09:15:04 +00:00
wxTextCtrl * tcPrgPath = new wxTextCtrl ( this , 601 , strPath , wxDefaultPosition , wxSize ( 320 , - 1 ) ) ;
2007-07-25 10:43:05 +00:00
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
2007-07-26 14:00:16 +00:00
strPath + = " /dati " ;
2007-07-26 09:15:04 +00:00
wxTextCtrl * tcDataPath = new wxTextCtrl ( this , 603 , strPath , wxDefaultPosition , wxSize ( 320 , - 1 ) ) ;
2007-07-25 10:43:05 +00:00
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 ) ) ;
2007-07-25 14:33:55 +00:00
//terza riga della griglia
wxCheckBox * chDataDemo = new wxCheckBox ( this , 605 , wxT ( " Carica i dati dimostrativi " ) ) ;
chDataDemo - > SetValue ( false ) ;
2007-07-25 15:10:45 +00:00
gbsSizer - > Add ( chDataDemo , wxGBPosition ( 2 , 1 ) ) ;
2007-07-23 15:01:38 +00:00
}
2007-07-25 10:43:05 +00:00
2007-07-24 15:44:05 +00:00
/**********************************************************************************************************/
// 7 Installazione server
/**********************************************************************************************************/
2007-07-23 15:01:38 +00:00
class CampoWizardPage7 : public CampoWizardPage
{
2007-08-08 14:19:12 +00:00
wxRadioBox * m_pRadioBox ;
2007-07-23 15:01:38 +00:00
protected :
2007-07-26 09:15:04 +00:00
DECLARE_EVENT_TABLE ( ) ;
2007-07-26 14:00:16 +00:00
virtual bool ForwardValidate ( ) ;
void OnDirPick ( wxCommandEvent & e ) ;
2007-07-26 09:15:04 +00:00
void OnSrvClick ( wxCommandEvent & e ) ;
2007-07-25 15:10:45 +00:00
2007-07-23 15:01:38 +00:00
public :
CampoWizardPage7 ( wxWizard * parent ) ;
} ;
2007-07-25 15:10:45 +00:00
2007-07-26 09:15:04 +00:00
BEGIN_EVENT_TABLE ( CampoWizardPage7 , CampoWizardPage )
2007-07-26 14:00:16 +00:00
EVT_BUTTON ( 702 , OnDirPick )
EVT_BUTTON ( 704 , OnDirPick )
2007-07-26 09:15:04 +00:00
EVT_CHECKBOX ( 705 , OnSrvClick )
EVT_CHECKBOX ( 707 , OnSrvClick )
END_EVENT_TABLE ( )
2007-07-26 14:00:16 +00:00
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 ) ;
}
}
2007-07-26 09:15:04 +00:00
void CampoWizardPage7 : : OnSrvClick ( wxCommandEvent & e )
{
2007-08-08 14:19:12 +00:00
//nome del server
2007-07-26 09:15:04 +00:00
wxWindow * pWnd = FindWindowById ( e . GetId ( ) + 1 ) ;
if ( pWnd )
pWnd - > Enable ( e . IsChecked ( ) ) ;
2007-08-08 14:19:12 +00:00
//tipo installazione server
pWnd = FindWindowById ( 709 ) ;
if ( pWnd )
pWnd - > Enable ( GetBool ( 705 ) | | GetBool ( 707 ) ) ;
2007-07-26 09:15:04 +00:00
}
2007-07-26 14:00:16 +00:00
bool CampoWizardPage7 : : ForwardValidate ( )
2007-07-25 15:10:45 +00:00
{
2007-07-31 10:11:16 +00:00
//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 e' 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 ( ) ) )
2007-07-26 14:00:16 +00:00
return ErrorBox ( " La cartella indicata per la creazione dell'area dati non e' vuota! Selezionarne un'altra! " ) ;
2007-07-31 11:16:04 +00:00
//setta alla pagina riassuntiva i valori della pagina attuale...
2007-07-31 10:11:16 +00:00
GetWizard ( ) . SetPrgLocPath ( strPrgLocPath ) ;
GetWizard ( ) . SetDataPath ( strDataPath ) ;
2007-07-31 11:16:04 +00:00
//...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 ) ;
}
2007-08-06 09:40:05 +00:00
else
GetWizard ( ) . SetSrvAuth ( " " ) ;
2007-07-31 11:16:04 +00:00
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 ) ;
}
2007-08-06 09:40:05 +00:00
else
GetWizard ( ) . SetSrvDict ( " " ) ;
2007-07-31 10:11:16 +00:00
2007-08-08 14:19:12 +00:00
//..e loro modalita' di esecuzione
if ( bInstAuth | | bInstDict )
{
GetWizard ( ) . SetSrvAutostartMode ( m_pRadioBox - > GetSelection ( ) ) ;
}
else
GetWizard ( ) . SetSrvAutostartMode ( - 1 ) ;
2007-07-25 15:10:45 +00:00
return true ;
}
2007-07-23 15:01:38 +00:00
CampoWizardPage7 : : CampoWizardPage7 ( wxWizard * parent ) : CampoWizardPage ( parent )
{
2007-07-24 15:44:05 +00:00
wxString strTitle = wxT ( " Installazione di tipo Server " ) ;
2007-07-25 14:33:55 +00:00
wxString strBody = wxT ( " <p>Digitare nel campo <b>'Cartella programma'</b> il percorso completo della cartella dove si desidera installare il programma. " ) ;
2007-07-26 14:00:16 +00:00
strBody + = wxT ( " Il percorso consigliato e' <i>C: \\ Campo</i> </p> " ) ;
strBody + = wxT ( " <p>Digitare nel campo <b>'Cartella dati'</b> il percorso completo della cartella dove si desidera installare l'area dati. " ) ;
strBody + = wxT ( " Il percorso consigliato e' <i>C: \\ Campo \\ dati</i> </p> " ) ;
strBody + = wxT ( " <p>Le cartelle del programma e dei dati <b><u>dovranno essere condivise in modalita' lettura/scrittura</u></b> agli utenti di sistema e di rete che utilizzeranno il software <b><i>Campo</i></b>. " ) ;
2007-07-25 14:33:55 +00:00
strBody + = wxT ( " In mancanza di tale condivisione nessun client potra' accedere al server!</p> " ) ;
2007-07-25 15:10:45 +00:00
strBody + = wxT ( " <p><b>Gestore autorizzazioni:</b> e' il software che permette di gestire una chiave di protezione hardware multiutenza condivisa in rete. " ) ;
strBody + = wxT ( " Installando tale software e' necessario specificare il computer su cui e' montata la chiave di protezione multiutenza. " ) ;
2007-08-06 13:44:24 +00:00
strBody + = wxT ( " Viene di default proposto il computer su cui si sta eseguendo l'installazione di APPNAME (localhost).</p> " ) ;
strBody + = wxT ( " <p><b>Gestore dizionari:</b> e' il software che permette di utilizzare APPNAME 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 APPNAME (localhost).</p> " ) ;
2007-08-08 14:19:12 +00:00
strBody + = wxT ( " <p><b>Modalita' di esecuzione programmi di gestione</b><br> " ) ;
strBody + = wxT ( " <u>Come servizi:</u> i programmi di gestione vengono eseguiti come servizi di Windows; questa e' la modalita' consigliata ed e' obbligatoria in caso di installazione con Windows 2003<br> " ) ;
strBody + = wxT ( " <u>Nel menu esecuzione automatica:</u> i programmi di gestione vengono eseguiti automaticamente al primo accesso di un utente al server di APPNAME; usare questa modalita' solo nell'impossibilita' di utilizzare la precedente</p> " ) ;
2007-07-23 15:01:38 +00:00
SetHTMLText ( strTitle , strBody ) ;
2007-07-25 14:33:55 +00:00
//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 ;
2007-07-26 09:15:04 +00:00
wxTextCtrl * tcPrgPath = new wxTextCtrl ( this , 701 , strPath , wxDefaultPosition , wxSize ( 320 , - 1 ) ) ;
2007-07-25 14:33:55 +00:00
gbsSizer - > Add ( tcPrgPath , wxGBPosition ( 0 , 1 ) ) ;
//bottone 'sfoglia'
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
2007-07-26 14:00:16 +00:00
strPath + = " /dati " ;
2007-07-26 09:15:04 +00:00
wxTextCtrl * tcDataPath = new wxTextCtrl ( this , 703 , strPath , wxDefaultPosition , wxSize ( 320 , - 1 ) ) ;
2007-07-25 14:33:55 +00:00
gbsSizer - > Add ( tcDataPath , wxGBPosition ( 1 , 1 ) ) ;
//bottone 'sfoglia'
wxButton * bDataButton = new wxButton ( this , 704 , wxT ( " Sfoglia " ) , wxDefaultPosition , wxSize ( 48 , - 1 ) ) ;
gbsSizer - > Add ( bDataButton , wxGBPosition ( 1 , 2 ) ) ;
2007-07-25 15:10:45 +00:00
//terza riga della griglia
//check installa authoriz
wxCheckBox * chAuthoriz = new wxCheckBox ( this , 705 , wxT ( " Installa il gestore delle autorizzazioni " ) ) ;
chAuthoriz - > SetValue ( false ) ;
gbsSizer - > Add ( chAuthoriz , wxGBPosition ( 2 , 1 ) ) ;
//server authoriz
2007-07-26 09:15:04 +00:00
wxTextCtrl * tcAuthoriz = new wxTextCtrl ( this , 706 , " localhost " , wxDefaultPosition , wxSize ( 96 , - 1 ) ) ;
tcAuthoriz - > Disable ( ) ;
2007-07-25 15:10:45 +00:00
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 ) ) ;
2007-07-26 09:15:04 +00:00
//server diction
wxTextCtrl * tcDiction = new wxTextCtrl ( this , 708 , " localhost " , wxDefaultPosition , wxSize ( 96 , - 1 ) ) ;
tcDiction - > Disable ( ) ;
gbsSizer - > Add ( tcDiction , wxGBPosition ( 3 , 2 ) ) ;
2007-08-08 14:19:12 +00:00
//quinta riga della griglia
//radiobutton con i tipi di installazione
wxArrayString asInstType ;
asInstType . Add ( " Come servizi (consigliato) " ) ;
asInstType . Add ( " Nel menu esecuzione automatica " ) ;
m_pRadioBox = new wxRadioBox ( this , 709 , " Modalita' 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 ) ) ;
2007-07-23 15:01:38 +00:00
}
2007-07-31 10:11:16 +00:00
2007-07-23 15:01:38 +00:00
/**********************************************************************************************************/
2007-07-24 15:44:05 +00:00
// 8 Installazione client
2007-07-23 15:01:38 +00:00
/**********************************************************************************************************/
class CampoWizardPage8 : public CampoWizardPage
{
2007-07-24 15:44:05 +00:00
protected :
2007-07-26 14:00:16 +00:00
DECLARE_EVENT_TABLE ( ) ;
virtual bool ForwardValidate ( ) ;
void OnDirPick ( wxCommandEvent & e ) ;
void OnSrvClick ( wxCommandEvent & e ) ;
2007-07-24 15:44:05 +00:00
public :
CampoWizardPage8 ( wxWizard * parent ) ;
} ;
2007-07-26 09:15:04 +00:00
2007-07-26 14:00:16 +00:00
BEGIN_EVENT_TABLE ( CampoWizardPage8 , CampoWizardPage )
EVT_BUTTON ( 802 , OnDirPick )
EVT_BUTTON ( 804 , OnDirPick )
EVT_BUTTON ( 806 , OnDirPick )
EVT_CHECKBOX ( 807 , OnSrvClick )
EVT_CHECKBOX ( 809 , 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 : : ForwardValidate ( )
{
2007-07-31 10:11:16 +00:00
//controllo esistenza directory vuota per i programmi in locale
const wxString strPrgLocPath = Get ( 801 ) ;
wxDir dirPrgLocPath ( strPrgLocPath ) ;
if ( dirPrgLocPath . Exists ( strPrgLocPath ) & & ( dirPrgLocPath . HasFiles ( ) | | dirPrgLocPath . HasSubDirs ( ) ) )
return ErrorBox ( " La cartella selezionata per l'installazione dei programmi NON e' valida! Selezionarne un'altra! " ) ;
//controllo esistenza directory e programmi sul server
const wxString strPrgNetPath = Get ( 803 ) ;
wxDir dirPrgPath ( strPrgNetPath ) ;
2007-07-26 14:00:16 +00:00
bool ok_prg = false ;
//deve esistere non vuota, e contenere almeno campo.ini,install.ini,campo.aut,ba0.exe
2007-07-31 10:11:16 +00:00
if ( dirPrgPath . Exists ( strPrgNetPath ) & & dirPrgPath . HasFiles ( ) & & dirPrgPath . HasSubDirs ( ) )
2007-07-26 14:00:16 +00:00
{
2007-07-31 10:11:16 +00:00
wxFileName fnFileToCheck ( strPrgNetPath , " campo " ) ;
2007-07-26 14:00:16 +00:00
fnFileToCheck . SetExt ( " ini " ) ;
if ( fnFileToCheck . FileExists ( ) )
{
fnFileToCheck . SetName ( " install " ) ;
fnFileToCheck . SetExt ( " ini " ) ;
if ( fnFileToCheck . FileExists ( ) )
{
fnFileToCheck . SetName ( " campo " ) ;
fnFileToCheck . SetExt ( " aut " ) ;
if ( fnFileToCheck . FileExists ( ) )
{
fnFileToCheck . SetName ( " ba0 " ) ;
fnFileToCheck . SetExt ( " exe " ) ;
if ( fnFileToCheck . FileExists ( ) )
{
ok_prg = true ;
}
}
}
}
}
if ( ! ok_prg )
return ErrorBox ( " La cartella selezionata come origine dei programmi NON e' valida! " ) ;
//controllo esistenza dati sul server
wxString strDataPath = Get ( 805 ) ;
2007-08-03 10:59:50 +00:00
if ( ! CheckDataDir ( strDataPath ) )
2007-07-26 14:00:16 +00:00
return ErrorBox ( " La cartella selezionata come area dati NON e' valida! " ) ;
2007-07-31 10:11:16 +00:00
//setta alla pagina riassuntiva i valori della pagina attuale
GetWizard ( ) . SetPrgLocPath ( strPrgLocPath ) ;
GetWizard ( ) . SetPrgNetPath ( strPrgNetPath ) ;
GetWizard ( ) . SetDataPath ( strDataPath ) ;
2007-07-31 11:16:04 +00:00
//...compresi eventuali stupidi servers!
const bool bUseAuth = GetBool ( 807 ) ;
if ( bUseAuth )
{
GetWizard ( ) . SetInstUseAuth ( bUseAuth ) ;
const wxString strSrvAuth = Get ( 808 ) ;
if ( strSrvAuth . IsEmpty ( ) )
2007-08-08 14:19:12 +00:00
return ErrorBox ( " Specificare il computer gestore delle autorizzazioni! " ) ;
2007-07-31 11:16:04 +00:00
GetWizard ( ) . SetSrvAuth ( strSrvAuth ) ;
}
2007-08-06 09:40:05 +00:00
else
GetWizard ( ) . SetSrvAuth ( " " ) ;
2007-07-31 11:16:04 +00:00
const bool bUseDict = GetBool ( 809 ) ;
if ( bUseDict )
{
GetWizard ( ) . SetInstUseDict ( bUseDict ) ;
const wxString strSrvDict = Get ( 810 ) ;
if ( strSrvDict . IsEmpty ( ) )
2007-08-08 14:19:12 +00:00
return ErrorBox ( " Specificare il computer gestore dei dizionari! " ) ;
2007-07-31 11:16:04 +00:00
GetWizard ( ) . SetSrvDict ( strSrvDict ) ;
}
2007-08-06 09:40:05 +00:00
else
GetWizard ( ) . SetSrvDict ( " " ) ;
2007-07-31 11:16:04 +00:00
2007-07-26 14:00:16 +00:00
return true ;
}
2007-07-24 15:44:05 +00:00
CampoWizardPage8 : : CampoWizardPage8 ( wxWizard * parent ) : CampoWizardPage ( parent )
{
wxString strTitle = wxT ( " Installazione di tipo Client " ) ;
2007-07-26 09:15:04 +00:00
wxString strBody = wxT ( " <p>Digitare nel campo <b>'Cartella locale programma'</b> il percorso completo della cartella dove si desidera installare il programma. " ) ;
2007-07-26 14:00:16 +00:00
strBody + = wxT ( " Il percorso consigliato e' <i>C: \\ Campo</i> </p> " ) ;
strBody + = wxT ( " <p>Digitare nel campo <b>'Cartella remota origine programmi'</b> 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.</p> " ) ;
strBody + = wxT ( " <p>Digitare nel campo <b>'Cartella remota dati da utilizzare'</b> il percorso completo della cartella di rete dove sono i dati. " ) ;
strBody + = wxT ( " E' la cartella dei dati condivisa dal server precedentemente installato.</p> " ) ;
2007-08-08 14:19:12 +00:00
strBody + = wxT ( " <p><b>Gestore autorizzazioni:</b> e' il computer gestore di una chiave di protezione hardware multiutenza condivisa in rete. " ) ;
strBody + = wxT ( " Generalmente e' il computer che agente da server di APPNAME e su cui <u>deve essere montata la chiave di protezione multiutenza.</u></p> " ) ;
strBody + = wxT ( " <p><b>Gestore dizionari:</b> e' il computer gestore dei dizionari di APPNAME in lingue diverse dall'italiano. " ) ;
strBody + = wxT ( " Generalmente e' il computer che agente da server di APPNAME.</p> " ) ;
2007-07-24 15:44:05 +00:00
SetHTMLText ( strTitle , strBody ) ;
2007-07-26 09:15:04 +00:00
//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 ( 320 , - 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
strPath = " Z: \\ " ;
strPath + = APPNAME ;
wxTextCtrl * tcSrcPrgPath = new wxTextCtrl ( this , 803 , strPath , wxDefaultPosition , wxSize ( 320 , - 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
2007-07-26 14:00:16 +00:00
strPath + = " /dati " ;
2007-07-26 09:15:04 +00:00
wxTextCtrl * tcDataPath = new wxTextCtrl ( this , 805 , strPath , wxDefaultPosition , wxSize ( 320 , - 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 ) ) ;
2007-07-26 14:00:16 +00:00
//quarta riga della griglia
//check usa authoriz
wxCheckBox * chAuthoriz = new wxCheckBox ( this , 807 , wxT ( " Utilizza il gestore delle autorizzazioni " ) ) ;
chAuthoriz - > SetValue ( false ) ;
gbsSizer - > Add ( chAuthoriz , wxGBPosition ( 3 , 1 ) ) ;
//quale e' il server authoriz
wxTextCtrl * tcAuthoriz = new wxTextCtrl ( this , 808 , " nomeserverautorizzazioni " , wxDefaultPosition , wxSize ( 96 , - 1 ) ) ;
tcAuthoriz - > Disable ( ) ;
gbsSizer - > Add ( tcAuthoriz , wxGBPosition ( 3 , 2 ) ) ;
//quarta riga della griglia
//check usa diction
wxCheckBox * chDictionary = new wxCheckBox ( this , 809 , wxT ( " Utilizza il gestore dei dizionari " ) ) ;
chDictionary - > SetValue ( false ) ;
gbsSizer - > Add ( chDictionary , wxGBPosition ( 4 , 1 ) ) ;
//quale e' il server diction
wxTextCtrl * tcDiction = new wxTextCtrl ( this , 810 , " nomeserverdizionario " , wxDefaultPosition , wxSize ( 96 , - 1 ) ) ;
tcDiction - > Disable ( ) ;
gbsSizer - > Add ( tcDiction , wxGBPosition ( 4 , 2 ) ) ;
2007-07-24 15:44:05 +00:00
}
2007-08-08 10:08:54 +00:00
2007-07-24 15:44:05 +00:00
/**********************************************************************************************************/
2007-08-08 14:19:12 +00:00
// 9 pagina con la creazione icona sul desktop e lanciatore del lerch
2007-07-24 15:44:05 +00:00
/**********************************************************************************************************/
class CampoWizardPage9 : public CampoWizardPage
2007-08-08 10:08:54 +00:00
{
protected :
virtual bool TransferDataToWindow ( ) ;
virtual bool ForwardValidate ( ) ;
public :
CampoWizardPage9 ( wxWizard * parent ) ;
} ;
bool CampoWizardPage9 : : TransferDataToWindow ( )
{
return Set ( 901 , GetWizard ( ) . GetDesktopShortcut ( ) ) ;
}
bool CampoWizardPage9 : : ForwardValidate ( )
{
const bool bDesktopShortcut = GetBool ( 901 ) ;
GetWizard ( ) . SetDesktopShortcut ( bDesktopShortcut ) ;
return true ;
}
CampoWizardPage9 : : CampoWizardPage9 ( wxWizard * parent ) : CampoWizardPage ( parent )
{
wxString strTitle = wxT ( " Collegamenti " ) ;
wxString strBody ;
2007-08-08 14:19:12 +00:00
strBody + = wxT ( " <p>E' possibile creare l'icona di APPNAME sul desktop </p> " ) ;
2007-08-08 10:08:54 +00:00
SetHTMLText ( strTitle , strBody ) ;
wxCheckBox * pIcon = new wxCheckBox ( this , 901 , wxT ( " Creare l'icona sul desktop " ) ) ;
GetSizer ( ) - > Add ( pIcon , 0 , wxALL , 0 ) ;
GetSizer ( ) - > AddSpacer ( 5 ) ;
//wxCheckBox* pLink = new wxCheckBox(this, 1002, wxT("Associare i file .caz al programma"));
//pLink->SetValue(true);
//GetSizer()->Add(pLink, 0, wxALL, 0);
}
/**********************************************************************************************************/
// 10 pagina con la selezione di destinazione
/**********************************************************************************************************/
class CampoWizardPage10 : public CampoWizardPage
2007-07-24 15:44:05 +00:00
{
2007-08-03 10:59:50 +00:00
unsigned int _uInstallType ;
2007-08-06 13:44:24 +00:00
wxString _strInstallType ;
2007-08-03 10:59:50 +00:00
wxString _strPrgLocPath ;
wxString _strPrgNetPath ;
wxString _strDataPath ;
wxString _strSrvAuth ;
wxString _strSrvDict ;
2007-08-08 14:26:35 +00:00
unsigned int _iSrvAutostartMode ;
2007-08-03 10:59:50 +00:00
bool _bInstDemoData ;
2007-08-08 10:08:54 +00:00
bool _bDesktopShortcut ;
2007-08-03 10:59:50 +00:00
2007-07-23 15:01:38 +00:00
protected :
2007-07-26 14:43:09 +00:00
virtual bool TransferDataToWindow ( ) ;
2007-07-23 15:01:38 +00:00
public :
2007-08-08 10:08:54 +00:00
CampoWizardPage10 ( wxWizard * parent ) ;
2007-07-23 15:01:38 +00:00
} ;
2007-08-08 10:08:54 +00:00
bool CampoWizardPage10 : : TransferDataToWindow ( )
2007-07-26 14:43:09 +00:00
{
2007-07-31 10:11:16 +00:00
CampoWizard & cw = GetWizard ( ) ;
2007-08-03 10:59:50 +00:00
_uInstallType = cw . GetInstallationType ( ) ;
switch ( _uInstallType )
2007-07-31 10:11:16 +00:00
{
case 1 : //server
2007-08-06 13:44:24 +00:00
_strInstallType = " Server " ;
2007-08-03 10:59:50 +00:00
_strPrgLocPath = cw . GetPrgLocPath ( ) ;
_strDataPath = cw . GetDataPath ( ) ;
_strSrvAuth = cw . GetSrvAuth ( ) ;
_strSrvDict = cw . GetSrvDict ( ) ;
2007-08-08 14:26:35 +00:00
_iSrvAutostartMode = cw . GetSrvAutostartMode ( ) ;
2007-07-31 10:11:16 +00:00
break ;
case 2 : //client
2007-08-06 13:44:24 +00:00
_strInstallType = " Client " ;
2007-08-03 10:59:50 +00:00
_strPrgLocPath = cw . GetPrgLocPath ( ) ;
_strPrgNetPath = cw . GetPrgNetPath ( ) ;
_strDataPath = cw . GetDataPath ( ) ;
_strSrvAuth = cw . GetSrvAuth ( ) ;
_strSrvDict = cw . GetSrvDict ( ) ;
2007-07-31 10:11:16 +00:00
break ;
case 3 : //aggiornamento
2007-08-06 13:44:24 +00:00
_strInstallType = " " ;
2007-08-03 10:59:50 +00:00
_strPrgLocPath = cw . GetDestinationPath ( ) ;
_strDataPath = cw . GetDataPath ( ) ;
_strSrvAuth = cw . GetSrvAuth ( ) ;
_strSrvDict = cw . GetSrvDict ( ) ;
2007-07-31 10:11:16 +00:00
break ;
default : //standard
2007-08-06 13:44:24 +00:00
_strInstallType = " Standard " ;
2007-08-03 10:59:50 +00:00
_strPrgLocPath = cw . GetPrgLocPath ( ) ;
_strDataPath = cw . GetDataPath ( ) ;
_bInstDemoData = cw . GetInstDemoData ( ) ;
2007-07-31 10:11:16 +00:00
break ;
}
2007-08-08 10:08:54 +00:00
//questo vale per tutti
_bDesktopShortcut = cw . GetDesktopShortcut ( ) ;
2007-08-03 10:59:50 +00:00
//se installazione o aggiornamento cambia sia il titolo che i contenuti
wxString strTitle ;
wxString strBody ;
//Aggiornamento
if ( _uInstallType = = 3 )
{
2007-08-06 13:44:24 +00:00
strTitle + = wxT ( " AGGIORNAMENTO: riepilogo configurazione " ) ;
2007-08-03 10:59:50 +00:00
strBody = wxT ( " <p>Cartella programma da aggiornare: " ) ;
strBody + = wxT ( Bold ( _strPrgLocPath ) + " </p> " ) ;
strBody + = wxT ( " <p>Cartella dati in uso: " ) ;
strBody + = wxT ( Bold ( _strDataPath ) + " </p> " ) ;
}
else //Installazione
{
2007-08-06 13:44:24 +00:00
strTitle + = wxT ( " INSTALLAZIONE: riepilogo configurazione " ) ;
2007-08-03 10:59:50 +00:00
2007-08-06 13:44:24 +00:00
strBody = wxT ( " <p>Tipo installazione selezionata: " ) ;
strBody + = wxT ( Bold ( _strInstallType ) + " </p> " ) ;
strBody + = wxT ( " <p>Cartella dove installare il programma: " ) ;
2007-08-03 10:59:50 +00:00
strBody + = wxT ( Bold ( _strPrgLocPath ) + " </p> " ) ;
if ( _uInstallType = = 2 )
{
2007-08-06 13:44:24 +00:00
strBody + = wxT ( " <p>Cartella di origine dei files del programma: " ) ;
2007-08-03 10:59:50 +00:00
strBody + = wxT ( Bold ( _strPrgNetPath ) + " </p> " ) ;
}
strBody + = wxT ( " <p>Cartella dati da creare: " ) ;
strBody + = wxT ( Bold ( _strDataPath ) + " </p> " ) ;
}
2007-08-08 14:19:12 +00:00
//installazione servers...
2007-08-03 10:59:50 +00:00
if ( ! _strSrvAuth . IsEmpty ( ) )
{
strBody + = wxT ( " <p>Computer gestore delle autorizzazioni: " ) ;
strBody + = wxT ( Bold ( _strSrvAuth ) + " </p> " ) ;
}
if ( ! _strSrvDict . IsEmpty ( ) )
{
strBody + = wxT ( " <p>Computer gestore dei dizionari: " ) ;
strBody + = wxT ( Bold ( _strSrvDict ) + " </p> " ) ;
}
2007-08-08 14:19:12 +00:00
//...e loro modalita' di lancio (solo installazione server!)
2007-08-08 14:26:35 +00:00
if ( _uInstallType = = 1 & & _iSrvAutostartMode > = 0 )
2007-08-08 14:19:12 +00:00
{
strBody + = wxT ( " <p>Modalita' di esecuzione dei programmi di gestione: " ) ;
2007-08-08 14:26:35 +00:00
if ( _iSrvAutostartMode = = 0 )
2007-08-08 14:19:12 +00:00
strBody + = wxT ( Bold ( " Come servizi " ) + " </p> " ) ;
else
strBody + = wxT ( Bold ( " Nel menu esecuzione automatica " ) + " </p> " ) ;
}
2007-08-06 09:40:05 +00:00
//installazione dati demo (solo in postazione singola)
if ( _uInstallType = = 0 & & _bInstDemoData )
2007-08-03 10:59:50 +00:00
strBody + = wxT ( " <p>Installazione area dati dimostrativa</p> " ) ;
2007-08-08 10:08:54 +00:00
if ( _bDesktopShortcut )
2007-08-08 14:19:12 +00:00
strBody + = wxT ( " <p>Creazione dell' icona sul desktop</p> " ) ;
2007-08-08 10:08:54 +00:00
2007-08-03 10:59:50 +00:00
SetHTMLText ( strTitle , strBody ) ;
2007-07-26 14:43:09 +00:00
return true ;
}
2007-07-24 15:44:05 +00:00
CampoWizardPage10 : : CampoWizardPage10 ( wxWizard * parent ) : CampoWizardPage ( parent )
2007-07-23 15:01:38 +00:00
{
}
2007-08-08 10:08:54 +00:00
2007-07-23 15:01:38 +00:00
///////////////////////////////////////////////////////////
// CampoWizard
///////////////////////////////////////////////////////////
2007-07-23 15:38:10 +00:00
//la dichiarazione della classe e' prima in quanto alcuni suoi metodi sono usati da altre classi scritte piu' su
2007-07-26 14:00:16 +00:00
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 ( ) ;
}
2007-07-23 15:01:38 +00:00
bool CampoWizard : : Run ( )
{ return RunWizard ( Page ( 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 ( ) ;
}
2007-07-31 11:16:04 +00:00
//lunga litania di metodi per gettare e settare i valori tra le pagine
2007-07-23 15:01:38 +00:00
void CampoWizard : : SetDestinationPath ( const wxString & path )
{
2007-07-31 10:11:16 +00:00
_strDestinationPath = path ;
2007-07-23 15:01:38 +00:00
//Se il path di destinazione e' vuoto -> nuova installazione, senno' e' un aggiornamento della installazione..
2007-07-31 10:11:16 +00:00
//..che sta in _strDestinationPath
if ( _strDestinationPath . IsEmpty ( ) )
2007-07-23 15:01:38 +00:00
{
2007-08-06 13:44:24 +00:00
wxWizardPageSimple : : Chain ( m_pPage [ 3 ] , m_pPage [ 4 ] ) ; //installazione nuova
2007-07-23 15:01:38 +00:00
}
else
{
2007-08-06 13:44:24 +00:00
wxWizardPageSimple : : Chain ( m_pPage [ 3 ] , m_pPage [ 8 ] ) ; //aggiornamento
2007-07-23 15:01:38 +00:00
}
}
const wxString & CampoWizard : : GetDestinationPath ( ) const
{
2007-07-31 10:11:16 +00:00
return _strDestinationPath ;
2007-07-23 15:01:38 +00:00
}
2007-07-24 15:44:05 +00:00
void CampoWizard : : SetInstallationType ( const unsigned int type )
{
2007-08-06 13:44:24 +00:00
_uInstallationType = type ;
2007-07-24 15:44:05 +00:00
//in base al tipo di installazione spara l'utente alla pagina corretta
2007-08-06 13:44:24 +00:00
switch ( _uInstallationType )
2007-07-24 15:44:05 +00:00
{
case 1 : //server
2007-07-25 14:33:55 +00:00
wxWizardPageSimple : : Chain ( m_pPage [ 4 ] , m_pPage [ 6 ] ) ; //manda l'utente alla pagina server
2007-08-06 13:44:24 +00:00
wxWizardPageSimple : : Chain ( m_pPage [ 6 ] , m_pPage [ 8 ] ) ; //dal server alla pagina riassuntiva
2007-07-24 15:44:05 +00:00
break ;
case 2 : //client
2007-08-06 13:44:24 +00:00
wxWizardPageSimple : : Chain ( m_pPage [ 4 ] , m_pPage [ 7 ] ) ; //manda l'utente alla pagina client
wxWizardPageSimple : : Chain ( m_pPage [ 7 ] , m_pPage [ 8 ] ) ; //dal client alla pagina riassuntiva
break ;
case 3 : //aggiornamento installazione precedente
wxWizardPageSimple : : Chain ( m_pPage [ 3 ] , m_pPage [ 8 ] ) ; //manda l'utente alla pagina riassuntiva
2007-07-24 15:44:05 +00:00
break ;
default : //standard
2007-08-06 13:44:24 +00:00
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
2007-07-24 15:44:05 +00:00
break ;
}
}
const unsigned int CampoWizard : : GetInstallationType ( ) const
{
2007-08-06 13:44:24 +00:00
return _uInstallationType ;
2007-07-31 10:11:16 +00:00
}
void CampoWizard : : SetPrgLocPath ( const wxString & strPrgLocPath )
{
_strPrgLocPath = strPrgLocPath ;
}
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 ;
2007-07-24 15:44:05 +00:00
}
2007-07-31 11:16:04 +00:00
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 ;
}
2007-08-08 14:26:35 +00:00
void CampoWizard : : SetSrvAutostartMode ( const int iSrvAutostartMode )
2007-08-08 14:19:12 +00:00
{
2007-08-08 14:26:35 +00:00
_iSrvAutostartMode = iSrvAutostartMode ;
2007-08-08 14:19:12 +00:00
}
const int CampoWizard : : GetSrvAutostartMode ( ) const
{
2007-08-08 14:26:35 +00:00
return _iSrvAutostartMode ;
2007-08-08 14:19:12 +00:00
}
2007-07-31 11:16:04 +00:00
void CampoWizard : : SetInstDemoData ( const bool bInstDemoData )
{
_bInstDemoData = bInstDemoData ;
}
const bool CampoWizard : : GetInstDemoData ( ) const
{
return _bInstDemoData ;
}
2007-08-08 09:24:19 +00:00
void CampoWizard : : SetDesktopShortcut ( const bool bDesktopShortcut )
{
_bDesktopShortcut = bDesktopShortcut ;
}
const bool CampoWizard : : GetDesktopShortcut ( ) const
{
return _bDesktopShortcut ;
}
2007-07-31 11:16:04 +00:00
//...fine litania metodi di passaggio valori tra le finestre
2007-07-23 15:01:38 +00:00
CampoWizard : : CampoWizard ( wxWindow * pParent )
{
2007-08-06 09:40:05 +00:00
//resettatore dei booleans (che senno' prendono valore casuale ad ogni esecuzione)
2007-08-08 10:08:54 +00:00
_bInstDemoData = false ; //installa dati dimostrativi
2007-08-06 09:40:05 +00:00
_bInstUseAuth = false ; //installa/usa server authoriz
_bInstUseDict = false ; //installa/usa server diction
2007-08-08 10:08:54 +00:00
_bDesktopShortcut = false ; //creazione link sul desktop
2007-08-06 09:40:05 +00:00
2007-07-23 15:01:38 +00:00
wxBitmap bitmap ;
wxString strName = wxT ( " logo.gif " ) ;
bitmap . LoadFile ( strName , wxBITMAP_TYPE_GIF ) ;
Create ( pParent , wxID_ANY , APPNAME , bitmap ) ;
2007-07-25 14:33:55 +00:00
m_pPage [ 0 ] = new CampoWizardPage1 ( this ) ; //benvenuto con logo
m_pPage [ 1 ] = new CampoWizardPage2 ( this ) ; //scelta aggiornamento/tipo installazione
m_pPage [ 2 ] = new CampoWizardPage3 ( this ) ; //licenza
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
2007-08-08 10:08:54 +00:00
m_pPage [ 8 ] = new CampoWizardPage9 ( this ) ; //creazione icona sul desktop e in start/programmi/campo
m_pPage [ 9 ] = new CampoWizardPage10 ( this ) ; //riassuntino installazione
2007-07-25 14:33:55 +00:00
2007-07-23 15:01:38 +00:00
for ( int p = 1 ; p < m_nPages ; p + + )
2007-07-25 14:33:55 +00:00
wxWizardPageSimple : : Chain ( m_pPage [ p - 1 ] , m_pPage [ p ] ) ;
2007-07-23 15:01:38 +00:00
GetPageAreaSizer ( ) - > Add ( m_pPage [ 0 ] ) ;
}
2007-08-08 09:24:19 +00:00
2007-07-23 15:01:38 +00:00
///////////////////////////////////////////////////////////
2007-08-08 09:24:19 +00:00
// CampoFrame
2007-07-23 15:01:38 +00:00
///////////////////////////////////////////////////////////
2007-08-08 09:24:19 +00:00
class CampoFrame : public wxFrame
2007-07-23 15:01:38 +00:00
{
protected :
DECLARE_EVENT_TABLE ( ) ;
virtual void OnErase ( wxEraseEvent & e ) ;
public :
2007-08-08 09:24:19 +00:00
CampoFrame ( ) ;
2007-07-23 15:01:38 +00:00
} ;
2007-08-08 09:24:19 +00:00
BEGIN_EVENT_TABLE ( CampoFrame , wxFrame )
EVT_ERASE_BACKGROUND ( CampoFrame : : OnErase )
2007-07-23 15:01:38 +00:00
END_EVENT_TABLE ( )
2007-08-08 09:24:19 +00:00
void CampoFrame : : OnErase ( wxEraseEvent & e )
2007-07-23 15:01:38 +00:00
{
//preparazione background
wxDC & dc = * e . GetDC ( ) ;
const wxRect rect = GetClientSize ( ) ;
wxColour c0 = wxSystemSettings : : GetColour ( wxSYS_COLOUR_3DLIGHT ) ;
wxColour c1 = wxSystemSettings : : GetColour ( wxSYS_COLOUR_3DFACE ) ;
wxColour c2 = wxSystemSettings : : GetColour ( wxSYS_COLOUR_3DDKSHADOW ) ;
wxRect rect1 = rect ; rect1 . SetBottom ( rect . GetBottom ( ) / 2 ) ;
dc . GradientFillLinear ( rect1 , c0 , c1 , wxSOUTH ) ;
wxRect rect2 = rect ; rect2 . SetTop ( rect . GetBottom ( ) / 2 ) ;
dc . GradientFillLinear ( rect2 , c1 , c2 , wxDOWN ) ;
const int nHeight = rect . GetHeight ( ) / 8 ;
wxFont * pFont = wxTheFontList - > FindOrCreateFont ( nHeight , wxFONTFAMILY_SWISS , wxFONTSTYLE_ITALIC ,
wxFONTWEIGHT_BOLD ) ;
dc . SetFont ( * pFont ) ;
dc . SetBackgroundMode ( wxTRANSPARENT ) ;
const int k = nHeight / 16 + 1 ;
dc . SetTextForeground ( c2 ) ;
dc . DrawText ( APPNAME , k , k ) ;
dc . SetTextForeground ( c1 ) ;
dc . DrawText ( APPNAME , k / 2 , k / 2 ) ;
int w , h ;
const wxString strSetup = wxT ( " Setup " ) ;
dc . GetTextExtent ( strSetup , & w , & h ) ;
dc . SetTextForeground ( c2 ) ;
dc . DrawText ( strSetup , rect . GetRight ( ) - w - k / 2 , rect . GetHeight ( ) - h - k / 2 ) ;
dc . SetTextForeground ( c1 ) ;
dc . DrawText ( strSetup , rect . GetRight ( ) - w - k , rect . GetHeight ( ) - h - k ) ;
}
2007-08-08 09:24:19 +00:00
CampoFrame : : CampoFrame ( )
2007-07-23 15:01:38 +00:00
: wxFrame ( NULL , wxID_ANY , wxEmptyString , wxDefaultPosition , wxDefaultSize , 0 )
{
ShowFullScreen ( true ) ;
}
///////////////////////////////////////////////////////////
2007-08-08 09:24:19 +00:00
// CampoSetup
2007-07-23 15:01:38 +00:00
///////////////////////////////////////////////////////////
2007-08-08 09:24:19 +00:00
//classe principale, ovvero applicazione
class CampoSetup : public wxApp
2007-07-23 15:01:38 +00:00
{
2007-08-08 09:24:19 +00:00
CampoFrame * m_pMainFrame ;
2007-07-23 15:01:38 +00:00
wxLocale m_locale ;
2007-08-09 10:33:02 +00:00
private :
bool WriteRegistryKey ( HKEY hBaseKey , const wxString strKey , const wxString & strValue ) const ;
wxString ReadRegistryKey ( HKEY hBaseKey , const wxString strKey ) const ;
2007-07-23 15:01:38 +00:00
protected :
DECLARE_EVENT_TABLE ( )
void OnTimer ( wxTimerEvent & e ) ;
2007-08-08 15:24:46 +00:00
bool CreateIcon ( unsigned int csidl , const wxFileName & strExeFile ) const ;
bool CreateAutostartMode ( const int iSrvAutostartMode , const wxString & strPath ) ;
2007-08-09 10:33:02 +00:00
void AssociateExtension ( const wxFileName & strExeFile , const wxString strExt ) ;
wxString ReadRootRegistryKey ( const wxString strKey ) const ;
wxString ReadLocalMachineRegistryKey ( const wxString strKey ) const ;
bool WriteRootRegistryKey ( const wxString strKey , const wxString & strValue ) const ;
bool WriteLocalMachineRegistryKey ( const wxString strKey , const wxString & strValue ) const ;
2007-07-23 15:01:38 +00:00
public :
virtual bool OnInit ( ) ;
} ;
2007-08-08 09:24:19 +00:00
IMPLEMENT_APP ( CampoSetup )
2007-07-23 15:01:38 +00:00
2007-08-08 09:24:19 +00:00
BEGIN_EVENT_TABLE ( CampoSetup , wxApp )
2007-07-23 15:01:38 +00:00
EVT_TIMER ( 883 , OnTimer )
END_EVENT_TABLE ( )
2007-08-09 10:33:02 +00:00
//metodi di lettura/scrittura registry di windows (fantastici!)
wxString CampoSetup : : ReadRegistryKey ( HKEY hBaseKey , const wxString strKey ) const
{
wxString strValue ;
HKEY hKey = NULL ;
wxString strPath , strName ;
wxFileName : : SplitPath ( strKey , & strPath , & strName , NULL ) ;
bool ok = : : RegOpenKeyEx ( hBaseKey , strPath , 0 , KEY_READ , & hKey ) = = ERROR_SUCCESS ;
if ( ok )
{
BYTE buff [ 512 ] ;
DWORD type = REG_SZ ;
DWORD dw = sizeof ( buff ) ;
ok = : : RegQueryValueEx ( hKey , strName , NULL , & type , buff , & dw ) = = ERROR_SUCCESS ;
if ( ok )
strValue = buff ;
: : RegCloseKey ( hKey ) ;
}
return strValue ;
}
wxString CampoSetup : : ReadRootRegistryKey ( const wxString strKey ) const
{
return ReadRegistryKey ( HKEY_CLASSES_ROOT , strKey ) ;
}
wxString CampoSetup : : ReadLocalMachineRegistryKey ( const wxString strKey ) const
{
return ReadRegistryKey ( HKEY_LOCAL_MACHINE , strKey ) ;
}
bool CampoSetup : : WriteRegistryKey ( HKEY hBaseKey , const wxString strKey , const wxString & strValue ) const
{
HKEY hKey = NULL ;
DWORD dw = 0 ;
bool ok = : : RegCreateKeyEx ( hBaseKey , strKey , 0 , REG_NONE ,
REG_OPTION_NON_VOLATILE , KEY_WRITE | KEY_READ , NULL , & hKey , & dw ) = = ERROR_SUCCESS ;
if ( ok )
{
ok = : : RegSetValueEx ( hKey , NULL , 0 , REG_SZ ,
( BYTE * ) ( const wxChar * ) strValue , DWORD ( 2 * strValue . Len ( ) + 2 ) ) = = ERROR_SUCCESS ;
: : RegCloseKey ( hKey ) ;
}
return ok ;
}
bool CampoSetup : : WriteRootRegistryKey ( const wxString strKey , const wxString & strValue ) const
{
return WriteRegistryKey ( HKEY_CLASSES_ROOT , strKey , strValue ) ;
}
bool CampoSetup : : WriteLocalMachineRegistryKey ( const wxString strKey , const wxString & strValue ) const
{
return WriteRegistryKey ( HKEY_LOCAL_MACHINE , strKey , strValue ) ;
}
void CampoSetup : : AssociateExtension ( const wxFileName & strExeFile , const wxString strExt )
{
// Register icon and application
WriteRootRegistryKey ( strExt , APPNAME ) ;
wxString str = strExeFile . GetFullPath ( ) ; str + = wxT ( " ,0 " ) ;
WriteRootRegistryKey ( wxT ( " Campo \\ DefaultIcon " ) , str ) ;
str = strExeFile . GetFullPath ( ) ; str + = wxT ( " \" %1 \" " ) ;
WriteRootRegistryKey ( wxT ( " Campo \\ shell \\ open \\ command " ) , str ) ;
}
2007-08-08 15:24:46 +00:00
bool CampoSetup : : CreateAutostartMode ( const int iSrvAutostartMode , const wxString & strPath )
{
switch ( iSrvAutostartMode )
{
2007-08-09 10:33:02 +00:00
//esecuzione server come servizi (magia!)
case 0 :
{
wxString strValue = ReadLocalMachineRegistryKey ( " SOFTWARE \\ Jasc \\ Paint Shop Pro 8 \\ Installer \\ InstallDirectory " ) ;
if ( strValue . IsEmpty ( ) )
{
const wxString strCreateService = " ./setup/instsrv.exe lerch ./setup/srvany.exe " ;
wxExecute ( strCreateService , wxEXEC_SYNC ) ;
}
}
break ;
2007-08-08 15:24:46 +00:00
//link nella cartella esecuzione automatica
case 1 :
{
const wxFileName strExe ( strPath , wxT ( " /servers/lerch.exe " ) ) ;
CreateIcon ( CSIDL_COMMON_STARTUP , strPath ) ;
}
break ;
default :
break ;
}
return true ;
}
bool CampoSetup : : CreateIcon ( unsigned int csidl , const wxFileName & strExeFile ) const
{
//csidl = CSIDL_COMMON_DESKTOPDIRECTORY = desktop
//csidl = CSIDL_COMMON_STARTUP = all users esecuzione automatica
TCHAR szDesktopPath [ MAX_PATH ] = wxT ( " " ) ;
HRESULT hres = : : SHGetFolderPath ( NULL , csidl , NULL , SHGFP_TYPE_CURRENT , szDesktopPath ) ;
if ( szDesktopPath [ 0 ] ! = ' \0 ' )
{
CoInitialize ( NULL ) ;
// Get a pointer to the IShellLink interface.
IShellLink * psl ;
hres = CoCreateInstance ( CLSID_ShellLink , NULL ,
CLSCTX_INPROC_SERVER , IID_IShellLink , ( void * * ) & psl ) ;
if ( SUCCEEDED ( hres ) )
{
IPersistFile * ppf ;
// Set the path to the shortcut target and add the description.
psl - > SetPath ( strExeFile . GetFullPath ( ) ) ;
psl - > SetWorkingDirectory ( strExeFile . GetPath ( ) ) ;
psl - > SetDescription ( APPNAME ) ;
// Query IShellLink for the IPersistFile interface for saving the
// shortcut in persistent storage.
hres = psl - > QueryInterface ( IID_IPersistFile , ( void * * ) & ppf ) ;
if ( SUCCEEDED ( hres ) )
{
wxFileName strLnk ( szDesktopPath , wxT ( " Campo.lnk " ) ) ;
// Save the link by calling IPersistFile::Save.
wxString stringa = strLnk . GetFullPath ( ) ;
wchar_t buff [ _MAX_PATH ] ;
memset ( buff , 0 , sizeof ( buff ) ) ;
wxConvLocal . MB2WC ( buff , stringa , stringa . Len ( ) ) ;
hres = ppf - > Save ( buff , true ) ;
ppf - > Release ( ) ;
}
psl - > Release ( ) ;
}
CoUninitialize ( ) ;
}
return true ;
}
2007-08-08 09:24:19 +00:00
void CampoSetup : : OnTimer ( wxTimerEvent & WXUNUSED ( e ) )
2007-07-23 15:01:38 +00:00
{
CampoWizard * pWizard = new CampoWizard ( m_pMainFrame ) ;
2007-08-08 09:24:19 +00:00
2007-07-23 15:01:38 +00:00
if ( pWizard - > Run ( ) )
{
wxFileName strPath = argv [ 0 ] ;
strPath . SetCwd ( ) ;
2007-08-08 09:24:19 +00:00
const wxString & strDest = pWizard - > GetPrgLocPath ( ) ;
2007-07-23 15:01:38 +00:00
const wxFileName strExe ( strDest , wxT ( " ba0.exe " ) ) ;
2007-08-08 09:24:19 +00:00
const bool bDesktopShortcut = pWizard - > GetDesktopShortcut ( ) ;
if ( bDesktopShortcut )
2007-08-08 14:19:12 +00:00
CreateIcon ( CSIDL_COMMON_DESKTOPDIRECTORY , strExe ) ;
//solo se installa campo server
const unsigned int uInstallationType = pWizard - > GetInstallationType ( ) ;
//se sta installando campo in postazione server e deve installare un gestore di servizi
if ( uInstallationType = = 1 )
{
const bool bInstallLerch = pWizard - > GetInstUseAuth ( ) | pWizard - > GetInstUseDict ( ) ;
if ( bInstallLerch )
{
2007-08-08 14:26:35 +00:00
const int iSrvAutostartMode = pWizard - > GetSrvAutostartMode ( ) ;
2007-08-08 15:24:46 +00:00
CreateAutostartMode ( iSrvAutostartMode , strDest ) ;
2007-08-08 14:19:12 +00:00
}
}
2007-08-08 09:24:19 +00:00
//questo e' un esempio di associazione automatica di estensione file
//if (pWizard->GetBool(bAssocExtension))
// AssociateExtension(strExe, wxT(".caz"));
2007-07-23 15:01:38 +00:00
}
pWizard - > Destroy ( ) ;
: : wxMessageBox ( wxT ( " Installazione terminata " ) , APPNAME , wxOK | wxICON_INFORMATION ) ;
m_pMainFrame - > Destroy ( ) ;
}
2007-08-08 09:24:19 +00:00
bool CampoSetup : : OnInit ( )
2007-07-23 15:01:38 +00:00
{
wxInitAllImageHandlers ( ) ;
m_locale . Init ( ) ;
2007-08-08 09:24:19 +00:00
m_pMainFrame = new CampoFrame ;
2007-07-23 15:01:38 +00:00
SetTopWindow ( m_pMainFrame ) ;
wxTimerEvent e ( 883 ) ;
AddPendingEvent ( e ) ;
return true ;
}