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"
|
|
|
|
|
|
|
|
|
|
|
2007-11-21 10:37:43 +00:00
|
|
|
|
#include <wx/protocol/http.h>
|
2007-09-26 12:59:37 +00:00
|
|
|
|
#include <wx/snglinst.h>
|
|
|
|
|
|
2007-09-20 09:53:21 +00:00
|
|
|
|
#include "key.h"
|
|
|
|
|
#include "wizard.h"
|
|
|
|
|
#include "utils.h"
|
2007-08-08 09:24:19 +00:00
|
|
|
|
|
2015-06-17 07:15:42 +00:00
|
|
|
|
#include <shlobj.h>
|
|
|
|
|
|
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);
|
|
|
|
|
|
2014-09-22 13:58:30 +00:00
|
|
|
|
wxRect rect2 = rect; rect2.SetTop(rect1.GetBottom());
|
2007-07-23 15:01:38 +00:00
|
|
|
|
dc.GradientFillLinear(rect2, c1, c2, wxDOWN);
|
|
|
|
|
|
2009-01-19 10:27:20 +00:00
|
|
|
|
int nHeight = rect.GetHeight()/14;
|
|
|
|
|
wxFont* pFont = wxTheFontList->FindOrCreateFont(nHeight, wxFONTFAMILY_SWISS, wxFONTSTYLE_ITALIC, wxFONTWEIGHT_BOLD);
|
2007-07-23 15:01:38 +00:00
|
|
|
|
dc.SetFont(*pFont);
|
|
|
|
|
|
2015-06-17 07:15:42 +00:00
|
|
|
|
int w = 0, h = 0; dc.GetTextExtent(RESELLER, &w, &h);
|
2009-01-19 10:27:20 +00:00
|
|
|
|
while (w > rect.width)
|
|
|
|
|
{
|
|
|
|
|
nHeight = nHeight * rect.width / w;
|
|
|
|
|
pFont = wxTheFontList->FindOrCreateFont(nHeight, wxFONTFAMILY_SWISS, wxFONTSTYLE_ITALIC, wxFONTWEIGHT_BOLD);
|
|
|
|
|
dc.SetFont(*pFont);
|
|
|
|
|
dc.GetTextExtent(RESELLER, &w, &h);
|
|
|
|
|
}
|
|
|
|
|
|
2007-07-23 15:01:38 +00:00
|
|
|
|
const int k = nHeight / 16 + 1;
|
|
|
|
|
|
2015-06-17 07:15:42 +00:00
|
|
|
|
dc.SetBackgroundMode(wxTRANSPARENT);
|
2007-07-23 15:01:38 +00:00
|
|
|
|
dc.SetTextForeground(c2);
|
2009-01-19 10:27:20 +00:00
|
|
|
|
dc.DrawText(RESELLER, rect.GetRight()-w-k/2, rect.GetHeight()-h-k/2);
|
2007-07-23 15:01:38 +00:00
|
|
|
|
dc.SetTextForeground(c1);
|
2009-01-19 10:27:20 +00:00
|
|
|
|
dc.DrawText(RESELLER, rect.GetRight()-w-k, rect.GetHeight()-h-k);
|
2007-07-23 15:01:38 +00:00
|
|
|
|
|
|
|
|
|
dc.SetTextForeground(c2);
|
2009-01-19 10:27:20 +00:00
|
|
|
|
dc.DrawText(PRODUCT, k, k);
|
2007-07-23 15:01:38 +00:00
|
|
|
|
dc.SetTextForeground(c1);
|
2009-01-19 10:27:20 +00:00
|
|
|
|
dc.DrawText(PRODUCT, k/2, k/2);
|
2009-04-30 08:48:17 +00:00
|
|
|
|
|
|
|
|
|
wxFont* pSmallFont = wxTheFontList->FindOrCreateFont(nHeight/6, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_LIGHT);
|
|
|
|
|
dc.SetFont(*pSmallFont);
|
|
|
|
|
const wxString strTime = __TIMESTAMP__;
|
|
|
|
|
dc.GetTextExtent(strTime, &w, &h);
|
|
|
|
|
dc.SetTextForeground(c2);
|
|
|
|
|
dc.DrawText(strTime, rect.GetRight()-w, 0);
|
|
|
|
|
|
2007-07-23 15:01:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-06-17 07:15:42 +00:00
|
|
|
|
CampoFrame::CampoFrame() : wxFrame(NULL, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0)
|
2007-07-23 15:01:38 +00:00
|
|
|
|
{
|
|
|
|
|
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-09-17 14:20:41 +00:00
|
|
|
|
wxString m_strSetupPath;
|
2009-04-21 09:21:08 +00:00
|
|
|
|
bool m_bLurchWasRunning;
|
2007-07-23 15:01:38 +00:00
|
|
|
|
|
2007-09-14 11:07:04 +00:00
|
|
|
|
CampoWizard* m_pWizard;
|
|
|
|
|
|
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-08-20 15:50:49 +00:00
|
|
|
|
wxString GetFolderPath(unsigned int uPathID) const;
|
2007-08-09 10:33:02 +00:00
|
|
|
|
|
2007-07-23 15:01:38 +00:00
|
|
|
|
protected:
|
|
|
|
|
DECLARE_EVENT_TABLE()
|
2007-11-21 15:42:21 +00:00
|
|
|
|
|
|
|
|
|
//metodi principali dell'applicazione
|
2007-07-23 15:01:38 +00:00
|
|
|
|
void OnTimer(wxTimerEvent& e);
|
2007-11-21 10:37:43 +00:00
|
|
|
|
void DiskUpdate();
|
|
|
|
|
void InternetUpdate();
|
2007-09-20 14:29:11 +00:00
|
|
|
|
void ClientUpdate();
|
|
|
|
|
void NormalSetup();
|
2009-01-20 11:16:02 +00:00
|
|
|
|
bool SystemRunning(const wxString& strAppName, wxString strMsg) const;
|
2015-06-17 07:15:42 +00:00
|
|
|
|
int LurchRunning() const;
|
2014-09-22 13:58:30 +00:00
|
|
|
|
bool CampoIsRunning() const;
|
2007-09-20 14:29:11 +00:00
|
|
|
|
|
2007-11-21 15:42:21 +00:00
|
|
|
|
//metodi di interfaccia con Windows
|
2007-09-19 14:47:17 +00:00
|
|
|
|
bool CreateIcon(unsigned int csidl, const wxFileName& strExeFile, const wxString& strLinkName) const;
|
2007-08-09 10:33:02 +00:00
|
|
|
|
void AssociateExtension(const wxFileName& strExeFile, const wxString strExt);
|
2008-01-04 16:03:24 +00:00
|
|
|
|
//...per i servers
|
2014-09-22 13:58:30 +00:00
|
|
|
|
bool CreateAutostartLurch(const LurchMode iSrvAutostartMode, const wxString& strPath);
|
2008-01-07 11:29:42 +00:00
|
|
|
|
bool StopLurch() const;
|
|
|
|
|
bool StartLurch(const wxString& strPrgLocPath) const;
|
2009-04-21 09:21:08 +00:00
|
|
|
|
bool LurchWasRunning() const { return m_bLurchWasRunning; }
|
2014-09-22 13:58:30 +00:00
|
|
|
|
|
2007-11-21 15:42:21 +00:00
|
|
|
|
//metodi di interfaccia con il registry di Windows
|
2007-08-09 10:33:02 +00:00
|
|
|
|
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
|
|
|
|
|
2007-11-21 15:42:21 +00:00
|
|
|
|
//metodi di utility per i vari modi di aggiornamento
|
2007-09-17 14:20:41 +00:00
|
|
|
|
const wxString GetSourceDir(const wxString strDirName) const;
|
2012-07-02 13:07:32 +00:00
|
|
|
|
const wxString& GetSetupDir() const { return m_strSetupPath; }
|
2007-11-21 10:37:43 +00:00
|
|
|
|
void EmptyOutDir(const wxString& strDir) const;
|
|
|
|
|
bool UnzipModule(const wxString& strPrgLocPath, const wxString& strSrc, const wxString& strModule) const;
|
2007-12-17 16:36:30 +00:00
|
|
|
|
void CopyDir(const wxString& strSourceDir, const wxString& strDestDir) const;
|
2007-11-21 15:42:21 +00:00
|
|
|
|
bool CopyFilesAndDirs(const wxString& FilesListI, wxString strFileCurr, const bool bIni) const;
|
|
|
|
|
void UpdateInstallIni(const wxString strSourcePath, const wxString strDestPath, const wxString& strModule) const;
|
2007-11-21 10:37:43 +00:00
|
|
|
|
bool HTTPGet(const wxString& strLocalPath, const wxString& strWebPath) const;
|
2007-11-21 15:42:21 +00:00
|
|
|
|
|
|
|
|
|
//metodi di aggiornamento non standard (client, da disco e via web con installazione moduli)
|
|
|
|
|
int ClientUpdateModule(const wxString& strLocalPath, const wxString& strRemotePath, const wxString strModule) const;
|
|
|
|
|
bool DiskUpdateModule(const wxString& strLocalPath, const wxString& strWebPath, const wxString strModule) const;
|
2007-11-21 10:37:43 +00:00
|
|
|
|
bool InternetUpdateModule(const wxString& strLocalPath, const wxString& strWebPath, const wxString strModule) 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-11-21 15:42:21 +00:00
|
|
|
|
//----------------------------------------------------------------
|
|
|
|
|
// Metodi di lettura/scrittura registry di Windows (fantastici!)
|
|
|
|
|
//----------------------------------------------------------------
|
2007-08-09 10:33:02 +00:00
|
|
|
|
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;
|
2007-08-20 15:50:49 +00:00
|
|
|
|
//splitta la stringa in path e valore
|
|
|
|
|
wxString strPath, strName;
|
|
|
|
|
wxFileName::SplitPath(strKey, &strPath, &strName, NULL);
|
|
|
|
|
|
|
|
|
|
bool ok = ::RegCreateKeyEx(hBaseKey, strPath, 0, REG_NONE,
|
2007-08-09 10:33:02 +00:00
|
|
|
|
REG_OPTION_NON_VOLATILE, KEY_WRITE|KEY_READ, NULL, &hKey, &dw) == ERROR_SUCCESS;
|
|
|
|
|
if (ok)
|
|
|
|
|
{
|
2007-08-20 15:50:49 +00:00
|
|
|
|
ok = ::RegSetValueEx(hKey, strName, 0, REG_SZ,
|
|
|
|
|
(BYTE*)(const wxChar*)strValue, DWORD(2*strValue.Len()+2)) == ERROR_SUCCESS;
|
2007-08-09 10:33:02 +00:00
|
|
|
|
::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);
|
|
|
|
|
}
|
|
|
|
|
|
2007-11-21 15:42:21 +00:00
|
|
|
|
//----------------------------------
|
|
|
|
|
// Metodi di interfaccia con Windows
|
|
|
|
|
//----------------------------------
|
2007-08-20 15:50:49 +00:00
|
|
|
|
wxString CampoSetup::GetFolderPath(unsigned int uPathID) const
|
|
|
|
|
{
|
|
|
|
|
TCHAR szPath[MAX_PATH] = wxT("");
|
|
|
|
|
HRESULT hres = ::SHGetFolderPath(NULL, uPathID, NULL, SHGFP_TYPE_CURRENT, szPath);
|
|
|
|
|
return szPath;
|
|
|
|
|
}
|
|
|
|
|
|
2008-01-04 16:03:24 +00:00
|
|
|
|
|
2007-08-09 10:33:02 +00:00
|
|
|
|
void CampoSetup::AssociateExtension(const wxFileName& strExeFile, const wxString strExt)
|
|
|
|
|
{
|
|
|
|
|
// Register icon and application
|
|
|
|
|
WriteRootRegistryKey(strExt, APPNAME);
|
|
|
|
|
|
|
|
|
|
wxString str = strExeFile.GetFullPath(); str += wxT(",0");
|
2009-01-20 11:16:02 +00:00
|
|
|
|
WriteRootRegistryKey(APPNAME + wxT("\\DefaultIcon"), str);
|
2007-08-09 10:33:02 +00:00
|
|
|
|
|
|
|
|
|
str = strExeFile.GetFullPath(); str += wxT(" \"%1\"");
|
2009-01-20 11:16:02 +00:00
|
|
|
|
WriteRootRegistryKey(APPNAME + wxT("\\shell\\open\\command"), str);
|
2007-08-09 10:33:02 +00:00
|
|
|
|
}
|
2007-08-08 15:24:46 +00:00
|
|
|
|
|
2007-09-19 14:47:17 +00:00
|
|
|
|
bool CampoSetup::CreateIcon(unsigned int csidl, const wxFileName& strExeFile, const wxString& strLinkName) const
|
2007-08-08 15:24:46 +00:00
|
|
|
|
{
|
|
|
|
|
//csidl = CSIDL_COMMON_DESKTOPDIRECTORY = desktop
|
|
|
|
|
//csidl = CSIDL_COMMON_STARTUP = all users esecuzione automatica
|
2012-07-02 13:07:32 +00:00
|
|
|
|
const wxString strDesktopPath = GetFolderPath(csidl);
|
|
|
|
|
bool ok = wxDirExists(strDesktopPath);
|
|
|
|
|
if (ok)
|
2007-08-08 15:24:46 +00:00
|
|
|
|
{
|
2015-06-17 07:15:42 +00:00
|
|
|
|
::CoInitialize(NULL);
|
2007-08-08 15:24:46 +00:00
|
|
|
|
|
|
|
|
|
// Get a pointer to the IShellLink interface.
|
2015-06-17 07:15:42 +00:00
|
|
|
|
IShellLink* psl = NULL;
|
|
|
|
|
HRESULT hres = ::CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void**)&psl);
|
2007-08-08 15:24:46 +00:00
|
|
|
|
if (SUCCEEDED(hres))
|
2007-12-18 16:15:06 +00:00
|
|
|
|
{
|
2007-08-08 15:24:46 +00:00
|
|
|
|
// Set the path to the shortcut target and add the description.
|
|
|
|
|
psl->SetPath(strExeFile.GetFullPath());
|
|
|
|
|
psl->SetWorkingDirectory(strExeFile.GetPath());
|
2007-12-18 16:15:06 +00:00
|
|
|
|
psl->SetDescription(APPNAME);
|
|
|
|
|
|
|
|
|
|
//sceglie l'icona da quelle possibili legate al .exe in base al tipo di installazione
|
|
|
|
|
const InstallationType uInstallationType = m_pWizard->GetInstallationType();
|
2009-01-19 10:27:20 +00:00
|
|
|
|
|
|
|
|
|
//anche l'icona deve essere scelta in base al reseller
|
|
|
|
|
wxString strIcon = Icon();
|
|
|
|
|
//path completo del file icona, in modo da legarlo al link sul desktop;comincia con il path di Campo
|
|
|
|
|
wxString strPath = m_pWizard->GetPrgLocPath();
|
|
|
|
|
|
|
|
|
|
if (!strIcon.IsEmpty())
|
|
|
|
|
{
|
|
|
|
|
strPath += "/setup/"; //se esiste l'icona del reseller sta in setup
|
|
|
|
|
}
|
|
|
|
|
else
|
2007-12-18 16:15:06 +00:00
|
|
|
|
{
|
2009-01-19 10:27:20 +00:00
|
|
|
|
strPath += "/res/"; //se non trova l'icona del reseller prende quella standard in res
|
2007-12-18 16:15:06 +00:00
|
|
|
|
}
|
2007-08-08 15:24:46 +00:00
|
|
|
|
|
2009-11-10 10:22:16 +00:00
|
|
|
|
const int nPos = strIcon.Len() - 4;
|
2009-01-19 10:27:20 +00:00
|
|
|
|
switch (uInstallationType)
|
|
|
|
|
{
|
|
|
|
|
case it_server: strIcon.insert(nPos, "Srv"); break;
|
|
|
|
|
case it_client: strIcon.insert(nPos, "Cln"); break;
|
|
|
|
|
default: break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
strPath << strIcon;
|
|
|
|
|
psl->SetIconLocation(strPath, 0);
|
|
|
|
|
|
2007-08-08 15:24:46 +00:00
|
|
|
|
// Query IShellLink for the IPersistFile interface for saving the
|
2007-12-18 16:15:06 +00:00
|
|
|
|
// shortcut in persistent storage.
|
|
|
|
|
IPersistFile* ppf;
|
2007-08-08 15:24:46 +00:00
|
|
|
|
hres = psl->QueryInterface(IID_IPersistFile, (void**)&ppf);
|
|
|
|
|
|
|
|
|
|
if (SUCCEEDED(hres))
|
|
|
|
|
{
|
2007-09-19 14:47:17 +00:00
|
|
|
|
wxFileName fnLnk;
|
|
|
|
|
wxString strName = strLinkName + ".lnk";
|
|
|
|
|
fnLnk.Assign(strDesktopPath, strName);
|
2007-08-21 08:59:43 +00:00
|
|
|
|
|
2007-08-08 15:24:46 +00:00
|
|
|
|
// Save the link by calling IPersistFile::Save.
|
2007-09-19 14:47:17 +00:00
|
|
|
|
wxString strPath = fnLnk.GetFullPath();
|
2007-08-08 15:24:46 +00:00
|
|
|
|
wchar_t buff[_MAX_PATH];
|
2009-04-28 11:09:52 +00:00
|
|
|
|
wxConvLibc.ToWChar(buff, _MAX_PATH, strPath);
|
2007-08-08 15:24:46 +00:00
|
|
|
|
hres = ppf->Save(buff, true);
|
|
|
|
|
ppf->Release();
|
|
|
|
|
}
|
|
|
|
|
psl->Release();
|
2012-07-02 13:07:32 +00:00
|
|
|
|
|
|
|
|
|
if (FAILED(hres))
|
|
|
|
|
ok = ErrorBox(wxT("Impossibile creare l'icona del collegamento: eseguire l'installazione come amministratore"));
|
2007-08-08 15:24:46 +00:00
|
|
|
|
}
|
|
|
|
|
CoUninitialize();
|
|
|
|
|
}
|
2012-07-02 13:07:32 +00:00
|
|
|
|
|
|
|
|
|
return ok;
|
2007-08-08 15:24:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-09-05 15:21:08 +00:00
|
|
|
|
|
2008-01-04 16:03:24 +00:00
|
|
|
|
//-------------------------------------------
|
|
|
|
|
// ..per i servers di Campo
|
|
|
|
|
//-------------------------------------------
|
2008-01-07 11:29:42 +00:00
|
|
|
|
bool CampoSetup::StopLurch() const
|
2008-01-04 16:03:24 +00:00
|
|
|
|
{
|
2015-06-17 07:15:42 +00:00
|
|
|
|
const wxString strExecService = "Servers/SSAservice -stop";
|
|
|
|
|
return wxExecute(strExecService, wxEXEC_SYNC) > 0;
|
2008-01-04 16:03:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-01-07 11:29:42 +00:00
|
|
|
|
bool CampoSetup::StartLurch(const wxString& strPrgLocPath) const
|
2008-01-04 16:03:24 +00:00
|
|
|
|
{
|
2015-06-17 07:15:42 +00:00
|
|
|
|
const wxString strExecService = strPrgLocPath + "Servers/SSAservice -start";
|
|
|
|
|
return wxExecute(strExecService) > 0;
|
2008-01-04 16:03:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-09-22 13:58:30 +00:00
|
|
|
|
bool CampoSetup::CreateAutostartLurch(const LurchMode iSrvAutostartMode, const wxString& strPath)
|
2008-01-04 16:03:24 +00:00
|
|
|
|
{
|
2015-06-17 07:15:42 +00:00
|
|
|
|
if (LurchRunning())
|
|
|
|
|
StopLurch();
|
2008-01-04 16:03:24 +00:00
|
|
|
|
|
2015-06-17 07:15:42 +00:00
|
|
|
|
const wxString strCreateService = "Servers/SSAservice -install";
|
|
|
|
|
return wxExecute(strCreateService) > 0;
|
2008-01-04 16:03:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-11-21 15:42:21 +00:00
|
|
|
|
//----------------------------------------------------------------
|
|
|
|
|
// Metodi di utility per i vari tipi di aggiornamento
|
|
|
|
|
//----------------------------------------------------------------
|
2007-09-05 15:21:08 +00:00
|
|
|
|
static int PatchCompare(const wxString& first, const wxString& second)
|
|
|
|
|
{
|
|
|
|
|
const wxFileName fn1(first);
|
|
|
|
|
const wxFileName fn2(second);
|
|
|
|
|
const wxString strName1 = fn1.GetName().Lower();
|
|
|
|
|
const wxString strName2 = fn2.GetName().Lower();
|
2010-04-12 09:29:43 +00:00
|
|
|
|
if (strName1.Mid(2, 4) == "inst")
|
2007-09-05 15:21:08 +00:00
|
|
|
|
return -1;
|
2010-04-12 09:29:43 +00:00
|
|
|
|
if (strName2.Mid(2, 4) == "inst")
|
2007-09-05 15:21:08 +00:00
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
return strName1.CompareTo(strName2);
|
|
|
|
|
}
|
|
|
|
|
|
2007-09-17 14:20:41 +00:00
|
|
|
|
const wxString CampoSetup::GetSourceDir(const wxString strDirName) const
|
2007-09-05 15:21:08 +00:00
|
|
|
|
{
|
2012-07-02 13:07:32 +00:00
|
|
|
|
wxFileName strSourcePath(GetSetupDir(), "pippo.txt");
|
2007-09-17 14:20:41 +00:00
|
|
|
|
strSourcePath.AppendDir("..");
|
2007-09-05 15:21:08 +00:00
|
|
|
|
strSourcePath.AppendDir("..");
|
2007-09-17 14:20:41 +00:00
|
|
|
|
strSourcePath.AppendDir(strDirName);
|
2007-09-05 15:21:08 +00:00
|
|
|
|
strSourcePath.MakeAbsolute();
|
2007-09-17 14:20:41 +00:00
|
|
|
|
const wxString strSrc = strSourcePath.GetPath();
|
|
|
|
|
return strSrc;
|
|
|
|
|
}
|
|
|
|
|
|
2007-10-25 15:48:37 +00:00
|
|
|
|
//metodo per aggiornare il modulo SY in install.ini
|
2007-11-21 15:42:21 +00:00
|
|
|
|
void CampoSetup::UpdateInstallIni(const wxString strSourcePath, const wxString strDestPath, const wxString& strModule) const
|
2007-10-25 15:48:37 +00:00
|
|
|
|
{
|
|
|
|
|
for (int j = 0; j < 2; j++)
|
|
|
|
|
{
|
2007-11-21 15:42:21 +00:00
|
|
|
|
wxString strParagraph = strModule;
|
2007-10-25 15:48:37 +00:00
|
|
|
|
if (j > 0)
|
|
|
|
|
strParagraph << j;
|
|
|
|
|
CampoIniFile InstallIniSource(strSourcePath, strParagraph);
|
|
|
|
|
CampoIniFile InstallIniDest(strDestPath, strParagraph);
|
|
|
|
|
|
|
|
|
|
wxString strWrk;
|
|
|
|
|
long nIndex;
|
|
|
|
|
for (bool ok = InstallIniSource.GetFirstEntry(strWrk, nIndex); ok; ok = InstallIniSource.GetNextEntry(strWrk, nIndex))
|
|
|
|
|
{
|
|
|
|
|
InstallIniDest.Set(strWrk, InstallIniSource.Get(strWrk));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-11-21 10:37:43 +00:00
|
|
|
|
bool CampoSetup::UnzipModule(const wxString& strPrgLocPath, const wxString& strSrc, const wxString& strModule) const
|
2007-09-17 14:20:41 +00:00
|
|
|
|
{
|
2007-11-21 10:37:43 +00:00
|
|
|
|
bool ok = false;
|
2007-09-17 14:20:41 +00:00
|
|
|
|
wxArrayString asFilesList;
|
2015-06-17 07:15:42 +00:00
|
|
|
|
size_t uFilesToCopy = 0;
|
2007-09-05 15:21:08 +00:00
|
|
|
|
//..contando anche quanti sono e memorizzandoli in un array asFileList
|
2008-08-08 10:15:42 +00:00
|
|
|
|
if(wxDir::Exists(strSrc))
|
2007-09-05 15:55:53 +00:00
|
|
|
|
{
|
2008-08-08 10:15:42 +00:00
|
|
|
|
uFilesToCopy = wxDir::GetAllFiles(strSrc, &asFilesList, strModule+"*.zip");
|
|
|
|
|
if (uFilesToCopy > 0)
|
|
|
|
|
{
|
|
|
|
|
//ordina le patch per numero crescente ma mette davanti a tutte il pacco (sysinst1)
|
|
|
|
|
asFilesList.Sort(PatchCompare);
|
|
|
|
|
for (size_t i = 0; i < uFilesToCopy; i++)
|
|
|
|
|
UnzipFile(asFilesList[i] , strPrgLocPath);
|
2007-09-05 15:55:53 +00:00
|
|
|
|
|
2008-08-08 10:15:42 +00:00
|
|
|
|
//aggiorna l'install.ini in base al numero di patch e versione dell'ultimo file zip di sistema
|
|
|
|
|
//ci vuole un giro allucinogeno per trasformare il .zip in .ini e togliere quel cazzo di 1 in fondo
|
|
|
|
|
wxFileName strLastFile(asFilesList[uFilesToCopy - 1]); //zip con path completo
|
|
|
|
|
wxString strWrk = strLastFile.GetName();
|
|
|
|
|
strWrk.Truncate(strWrk.Len() - 1);
|
|
|
|
|
strLastFile.SetName(strWrk);
|
|
|
|
|
strLastFile.SetExt("ini");
|
|
|
|
|
strWrk = strLastFile.GetFullPath();
|
|
|
|
|
|
|
|
|
|
//adesso che ha trovato quello sporco ultimo .ini prende versione e patch e le copia nell'install.ini..
|
|
|
|
|
//..nella dir dei programmi; lo fa paragrafo x paragrafo ([sy],[sy1]..)
|
|
|
|
|
//potrebbe sembrare assurdo un for, ma e' per futuri sottomoduli con numero > 1
|
|
|
|
|
UpdateInstallIni(strWrk, strPrgLocPath + "/install.ini", strModule);
|
|
|
|
|
}
|
2007-08-22 14:55:00 +00:00
|
|
|
|
}
|
2009-08-06 09:42:51 +00:00
|
|
|
|
|
2008-01-07 11:29:42 +00:00
|
|
|
|
//Adesso puo' far ripartire il server di chiavi
|
2015-06-17 07:15:42 +00:00
|
|
|
|
if (strModule == "sr" && LurchWasRunning())
|
2008-01-07 11:29:42 +00:00
|
|
|
|
StartLurch(strPrgLocPath);
|
|
|
|
|
|
2007-11-21 10:37:43 +00:00
|
|
|
|
return uFilesToCopy > 0;
|
2007-08-22 14:55:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-09-19 14:47:17 +00:00
|
|
|
|
bool CampoSetup::CopyFilesAndDirs(const wxString& FilesListI, wxString strFileCurr, const bool bIni) const
|
|
|
|
|
{
|
|
|
|
|
bool ok = true;
|
|
|
|
|
|
2014-09-22 13:58:30 +00:00
|
|
|
|
//i files .ini vanno trattati con i guanti (se esistono gi<67> non vanno copiati!!!)
|
2007-09-19 14:47:17 +00:00
|
|
|
|
//parte da eseguire solo in caso sia indicata la trattazione degli ini (bIni true)
|
|
|
|
|
if (bIni)
|
|
|
|
|
{
|
2008-12-18 11:28:19 +00:00
|
|
|
|
strFileCurr.MakeLower(); //minuscolizzazione di sicurezza
|
|
|
|
|
const wxFileName strFileName(strFileCurr);
|
2007-09-19 14:47:17 +00:00
|
|
|
|
if (strFileName.GetExt() == "ini")
|
|
|
|
|
{
|
|
|
|
|
const wxString strName = strFileName.GetName();
|
|
|
|
|
//campo.ini e install.ini vanno lasciati stare se esistono (aggiornamento)!!!
|
|
|
|
|
if ((strName == "campo" || strName == "install") && strFileName.FileExists())
|
|
|
|
|
ok = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ok)
|
2007-12-17 16:36:30 +00:00
|
|
|
|
ok = CopiaFile(FilesListI, strFileCurr);
|
2008-12-18 11:28:19 +00:00
|
|
|
|
|
2007-09-19 14:47:17 +00:00
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
2007-12-13 14:49:46 +00:00
|
|
|
|
//metodo per copiare una directory e tutti i files che contiene
|
|
|
|
|
void CampoSetup::CopyDir(const wxString& strSourceDir, const wxString& strDestDir) const
|
|
|
|
|
{
|
2008-08-08 10:15:42 +00:00
|
|
|
|
if (wxDir::Exists(strSourceDir))
|
2007-12-13 14:49:46 +00:00
|
|
|
|
{
|
2008-08-08 10:15:42 +00:00
|
|
|
|
wxArrayString asFilesList;
|
2008-12-18 11:28:19 +00:00
|
|
|
|
const size_t uFilesToCopy = wxDir::GetAllFiles(strSourceDir, &asFilesList, "*.*");
|
2008-08-08 10:15:42 +00:00
|
|
|
|
const size_t uFrom = strSourceDir.Len();
|
|
|
|
|
for (size_t i = 0; i < uFilesToCopy; i++)
|
|
|
|
|
{
|
|
|
|
|
wxString strFileDest = strDestDir + asFilesList[i].Mid(uFrom);
|
|
|
|
|
CopiaFile(asFilesList[i], strFileDest);
|
|
|
|
|
}
|
2007-12-13 14:49:46 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-11-21 15:42:21 +00:00
|
|
|
|
//metodo per accoppare tutti i files di una directory
|
|
|
|
|
void CampoSetup::EmptyOutDir(const wxString& strDir) const
|
|
|
|
|
{
|
2008-07-11 08:49:54 +00:00
|
|
|
|
if (wxFileName::DirExists(strDir))
|
|
|
|
|
{
|
|
|
|
|
wxArrayString asFilesList;
|
|
|
|
|
const size_t uFilesToKill = wxDir::GetAllFiles(strDir, &asFilesList, "*.*");
|
|
|
|
|
for (size_t i = 0; i < uFilesToKill; i++)
|
|
|
|
|
::wxRemoveFile(asFilesList[i]);
|
|
|
|
|
}
|
2007-11-21 15:42:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-09-20 14:29:11 +00:00
|
|
|
|
|
2007-11-21 15:42:21 +00:00
|
|
|
|
//-----------------------------------------------------
|
|
|
|
|
// METODI BASSO LIVELLO PER AGGIORNAMENTI NON STANDARD
|
|
|
|
|
//-----------------------------------------------------
|
|
|
|
|
//----------------------------
|
|
|
|
|
// 1) AGGIORNAMENTO CLIENT
|
|
|
|
|
//----------------------------
|
|
|
|
|
//Aggiornatore client. Copia i files del programma da una directory remota su un server campo nella directory...
|
|
|
|
|
//...locale di campo
|
|
|
|
|
int CampoSetup::ClientUpdateModule(const wxString& strLocalPath, const wxString& strRemotePath, const wxString strModule) const
|
2007-07-23 15:01:38 +00:00
|
|
|
|
{
|
2007-09-20 14:29:11 +00:00
|
|
|
|
int nLocVer, nLocPatch, nRemVer, nRemPatch;
|
|
|
|
|
{
|
|
|
|
|
CampoIniFile iniLocalInstall(strLocalPath + "/install.ini", strModule);
|
|
|
|
|
nLocVer = iniLocalInstall.GetInt("Versione");
|
|
|
|
|
nLocPatch = iniLocalInstall.GetInt("Patch");
|
|
|
|
|
|
|
|
|
|
CampoIniFile iniRemoteInstall(strRemotePath + "/install.ini", strModule);
|
|
|
|
|
nRemVer = iniRemoteInstall.GetInt("Versione");
|
|
|
|
|
nRemPatch = iniRemoteInstall.GetInt("Patch");
|
|
|
|
|
}
|
|
|
|
|
int cmp = nLocVer - nRemVer;
|
|
|
|
|
if (cmp == 0)
|
|
|
|
|
cmp = nLocPatch - nRemPatch;
|
|
|
|
|
|
|
|
|
|
//il client e' piu' indietro e quindi va aggiornato!
|
|
|
|
|
if (cmp < 0)
|
|
|
|
|
{
|
|
|
|
|
bool bOk = true;
|
|
|
|
|
|
2007-12-06 11:40:20 +00:00
|
|
|
|
CampoProgressDialog pi("Aggiornamento elenco files dal server...", 100, m_pWizard);
|
2007-09-20 14:29:11 +00:00
|
|
|
|
|
|
|
|
|
wxArrayString asGroups;
|
|
|
|
|
{
|
|
|
|
|
wxString strGroup;
|
|
|
|
|
long nIndex;
|
|
|
|
|
CampoIniFile iniRemoteInstall(strRemotePath + "/install.ini", "");
|
|
|
|
|
for (bool ok = iniRemoteInstall.GetFirstGroup(strGroup, nIndex); ok; ok = iniRemoteInstall.GetNextGroup(strGroup, nIndex))
|
|
|
|
|
{
|
|
|
|
|
if(strGroup.Len() > 2 && strGroup.StartsWith(strModule))
|
|
|
|
|
asGroups.Add(strGroup);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//controlla tutti i sottomoduli del modulo [sy1],[sy2]...
|
|
|
|
|
for (size_t i = 0; i < asGroups.GetCount() && bOk; i++)
|
|
|
|
|
{
|
|
|
|
|
const wxString& strParagraph = asGroups[i];
|
|
|
|
|
CampoIniFile iniRemoteInstallModule(strRemotePath + "/install.ini", strParagraph);
|
2007-10-25 15:48:37 +00:00
|
|
|
|
|
|
|
|
|
//install.ini locale che deve essere aggiornato durante la copia dei files!
|
|
|
|
|
CampoIniFile iniLocalInstall(strLocalPath + "/install.ini", strParagraph);
|
|
|
|
|
|
2007-09-20 14:29:11 +00:00
|
|
|
|
//ogni file dell'elenco del sottomodulo corrente va copiato
|
|
|
|
|
for (int j = 0;; j++)
|
|
|
|
|
{
|
|
|
|
|
pi.Pulse(); //magica barra modello supercar!
|
|
|
|
|
|
2007-10-25 15:48:37 +00:00
|
|
|
|
const wxString strVarName = wxString::Format("File(%d)", j);
|
|
|
|
|
wxString strCurrFile = iniRemoteInstallModule.Get(strVarName);
|
2007-09-20 14:29:11 +00:00
|
|
|
|
if (strCurrFile.IsEmpty())
|
|
|
|
|
break;
|
2007-10-22 09:28:09 +00:00
|
|
|
|
|
|
|
|
|
strCurrFile = strCurrFile.BeforeFirst('|');
|
2007-09-20 14:29:11 +00:00
|
|
|
|
|
|
|
|
|
const wxString strSrcPath = strRemotePath + "/" + strCurrFile;
|
|
|
|
|
const wxString strDstPath = strLocalPath + "/" + strCurrFile;
|
|
|
|
|
|
|
|
|
|
//copia il file remoto di origine sul file locale di destinazione (overwrite=true di default)
|
2007-12-17 16:36:30 +00:00
|
|
|
|
if (!CopiaFile(strSrcPath, strDstPath))
|
2007-09-20 14:29:11 +00:00
|
|
|
|
{
|
2007-12-17 16:36:30 +00:00
|
|
|
|
wxString strError;
|
2007-09-20 14:29:11 +00:00
|
|
|
|
strError += "\nAssicurarsi che il client locale di ";
|
|
|
|
|
strError += APPNAME;
|
|
|
|
|
strError += " non sia in funzione.\n";
|
|
|
|
|
strError += "Assicurarsi che il server di ";
|
|
|
|
|
strError += APPNAME;
|
|
|
|
|
strError += " sia in funzione e raggiungibile in rete.\n";
|
|
|
|
|
strError += "Aggiornamento interrotto!";
|
|
|
|
|
ErrorBox(strError);
|
|
|
|
|
bOk = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//se ci sono zip deve scompattarli (per ora esiste solo res.zip)
|
2015-06-17 07:15:42 +00:00
|
|
|
|
if (strCurrFile.EndsWith("res.zip")) // Non confonderti con dninst.zip
|
2007-09-20 14:29:11 +00:00
|
|
|
|
{
|
|
|
|
|
UnzipFile(strDstPath, strLocalPath + "/res");
|
|
|
|
|
}
|
2007-10-25 15:48:37 +00:00
|
|
|
|
|
|
|
|
|
//se riesce la copia del file aggiorna l'install.ini sul file (se non lo facesse non comparirebbero...
|
|
|
|
|
//...eventuali nuovi files
|
|
|
|
|
iniLocalInstall.Set(strVarName, strCurrFile);
|
|
|
|
|
|
2007-09-20 14:29:11 +00:00
|
|
|
|
} //for(int j...
|
|
|
|
|
|
|
|
|
|
//una volta termiata la copia dei files del sottmodulo[i] scatta l'aggiornamento dell'install.ini locale...
|
|
|
|
|
//...al livello versione/patch appena copiate sempre del sottomodulo[i]
|
|
|
|
|
iniLocalInstall.Set("Versione", nRemVer);
|
|
|
|
|
iniLocalInstall.Set("Patch", nRemPatch);
|
|
|
|
|
|
|
|
|
|
} //for(int i...
|
|
|
|
|
|
|
|
|
|
//una volta termiata la copia dei files dell'intero modulo scatta l'aggiornamento dell'install.ini locale al..
|
|
|
|
|
//..livello versione/patch appena copiate
|
|
|
|
|
CampoIniFile iniLocalInstall(strLocalPath + "/install.ini", strModule);
|
|
|
|
|
iniLocalInstall.Set("Versione", nRemVer);
|
|
|
|
|
iniLocalInstall.Set("Patch", nRemPatch);
|
|
|
|
|
|
|
|
|
|
} //if(cmp<0...
|
|
|
|
|
|
|
|
|
|
return cmp;
|
|
|
|
|
}
|
|
|
|
|
|
2007-11-21 15:42:21 +00:00
|
|
|
|
|
|
|
|
|
//----------------------------
|
|
|
|
|
// 2) AGGIORNAMENTO DA DISCO
|
|
|
|
|
//----------------------------
|
|
|
|
|
//Aggiornatore da disco. Copia i files delle patch da una directory su disco in una directory di appoggio...
|
|
|
|
|
//...temporanea dove esegue lo scompattamento con destinazione la directory locale
|
|
|
|
|
bool CampoSetup::DiskUpdateModule(const wxString& strLocalPath, const wxString& strDiskPath, const wxString strModule) const
|
|
|
|
|
{
|
|
|
|
|
//puo' chiamare direttamente il metodo che scompatta tutte le patch del modulo a partire dal pacco iniziale...
|
2014-09-22 13:58:30 +00:00
|
|
|
|
//...fino all'ultima;il metodo le ordina gi<67> in modo crescente di numero d'ordine
|
2007-11-21 15:42:21 +00:00
|
|
|
|
return UnzipModule(strLocalPath, strDiskPath, strModule);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//-------------------------------
|
|
|
|
|
// 3) AGGIORNAMENTO DA INTERNET
|
|
|
|
|
//-------------------------------
|
2009-04-24 14:23:19 +00:00
|
|
|
|
bool CampoSetup::HTTPGet(const wxString& strLocalPath, const wxString& strWebSite) const
|
2007-11-21 10:37:43 +00:00
|
|
|
|
{
|
2009-04-24 14:23:19 +00:00
|
|
|
|
wxString strWebPath = strWebSite;
|
|
|
|
|
if (strWebPath.StartsWith("http://"))
|
|
|
|
|
strWebPath.Remove(0, 7);
|
2007-11-21 10:37:43 +00:00
|
|
|
|
int nSlash = strWebPath.First('/');
|
2009-04-24 14:23:19 +00:00
|
|
|
|
wxString strServer = strWebPath.Left(nSlash);
|
|
|
|
|
wxString strPath = strWebPath.Mid(nSlash);
|
2007-11-21 10:37:43 +00:00
|
|
|
|
|
|
|
|
|
wxHTTP http;
|
|
|
|
|
//connessione al server web con le patch
|
|
|
|
|
if (http.Connect(strServer))
|
|
|
|
|
{
|
|
|
|
|
wxInputStream* pStream = http.GetInputStream(strPath);
|
|
|
|
|
if (pStream != NULL)
|
|
|
|
|
{
|
|
|
|
|
//compila un file di testo temporaneo con l'elenco dei files che trova sul server
|
|
|
|
|
wxFileOutputStream fos(strLocalPath);
|
|
|
|
|
fos.Write(*pStream);
|
|
|
|
|
delete pStream;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2007-11-21 15:42:21 +00:00
|
|
|
|
//Aggiornatore via web. Copia i files delle patch da una directory web remota in una directory di appoggio...
|
|
|
|
|
//...temporanea dove esegue lo scompattamento con destinazione la directory locale
|
2007-11-21 10:37:43 +00:00
|
|
|
|
bool CampoSetup::InternetUpdateModule(const wxString& strLocalPath, const wxString& strWebPath, const wxString strModule) const
|
|
|
|
|
{
|
|
|
|
|
bool ok = false;
|
2015-06-17 07:15:42 +00:00
|
|
|
|
int nLocVer = 20911000, nLocPatch = 100; // Fingo la versione 10.0
|
2007-11-21 10:37:43 +00:00
|
|
|
|
{
|
|
|
|
|
CampoIniFile iniLocalInstall(strLocalPath + "/install.ini", strModule);
|
|
|
|
|
nLocVer = iniLocalInstall.GetInt("Versione");
|
|
|
|
|
nLocPatch = iniLocalInstall.GetInt("Patch");
|
|
|
|
|
}
|
|
|
|
|
|
2007-11-21 15:42:21 +00:00
|
|
|
|
//Svuota,elimina e ricrea una directory temporanea di appoggio ove mettere i files delle patch da scompattare
|
|
|
|
|
//E' necessaria questa operazione per non trovarsi ancora files di vecchie patch parcheggiati nella dir!
|
2007-11-21 10:37:43 +00:00
|
|
|
|
const wxString strTempDir = wxFileName::GetTempDir() + "/setup/";
|
2008-08-08 10:15:42 +00:00
|
|
|
|
if (wxDir::Exists(strTempDir))
|
|
|
|
|
{
|
|
|
|
|
EmptyOutDir(strTempDir); //deve svuotare la directory dai files per poterla eliminare!!!
|
|
|
|
|
::wxRmdir(strTempDir); //elimina la dir adesso vuota
|
|
|
|
|
}
|
2008-12-18 11:28:19 +00:00
|
|
|
|
CheckAndMakeDir(strTempDir, wxEmptyString); //la ricrea con i permessi dell'utente windows corrente!!
|
2007-11-21 10:37:43 +00:00
|
|
|
|
|
|
|
|
|
const wxString strTempFile = strTempDir + "httpdir.txt";
|
|
|
|
|
if (HTTPGet(strTempFile, strWebPath))
|
|
|
|
|
{
|
|
|
|
|
//partendo dal file temporaneo ne compila un secondo con i soli nomi dei file validi da scaricare
|
|
|
|
|
//i criteri di selezione sono il nome del modulo ed il livello patch
|
|
|
|
|
wxTextFile tfFilesList;
|
|
|
|
|
if (tfFilesList.Open((strTempFile)))
|
|
|
|
|
{
|
2007-12-06 11:40:20 +00:00
|
|
|
|
CampoProgressDialog pi("Aggiornamento elenco files dal server...", (int)tfFilesList.GetLineCount(), m_pWizard);
|
2007-11-21 10:37:43 +00:00
|
|
|
|
for (wxString strWrk = tfFilesList.GetFirstLine(); !tfFilesList.Eof(); strWrk = tfFilesList.GetNextLine())
|
|
|
|
|
{
|
|
|
|
|
int nPos = strWrk.Find("href");
|
|
|
|
|
if (nPos > 0)
|
|
|
|
|
{
|
|
|
|
|
wxString strHref = strWrk.Mid(nPos + 5, 16);
|
|
|
|
|
strHref = strHref.AfterFirst('"');
|
|
|
|
|
strHref = strHref.BeforeLast('"');
|
2008-09-09 10:47:13 +00:00
|
|
|
|
|
|
|
|
|
if (!pi.Update((int)tfFilesList.GetCurrentLine(), strHref))
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
//lavora solo con i files del modulo in questione
|
|
|
|
|
if (strHref.StartsWith(strModule))
|
2007-11-21 10:37:43 +00:00
|
|
|
|
{
|
2008-12-18 09:53:31 +00:00
|
|
|
|
const wxString strExt = strHref.Right(4).Lower();
|
2015-06-17 07:15:42 +00:00
|
|
|
|
if (strExt!=".ini" && strExt!=".zip")
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
const wxString strPatch = strHref.Mid(2, 4).Lower();
|
2008-09-09 10:47:13 +00:00
|
|
|
|
// 1) e' un pacco
|
|
|
|
|
//se e' un pacco devo sapere se e' piu' recente della installazione corrente (potrebbe essere un pacco nuovo..
|
|
|
|
|
//..ricompattato) oppure se e' piu' vecchio e non va toccato (e' ad esempio il pacco originale)
|
|
|
|
|
if (strPatch == "inst")
|
|
|
|
|
{
|
2008-12-18 09:53:31 +00:00
|
|
|
|
if (strExt == ".ini") //operazioni sull'ini x sapere versione e patch
|
2008-09-09 10:47:13 +00:00
|
|
|
|
{
|
|
|
|
|
HTTPGet(strTempDir+strHref, strWebPath+strHref);
|
|
|
|
|
CampoIniFile iniInst(strTempDir+strHref, strModule);
|
|
|
|
|
const int nRemoteVer = iniInst.GetInt("Versione");
|
|
|
|
|
const int nRemotePatch = iniInst.GetInt("Patch");
|
|
|
|
|
|
|
|
|
|
//se deve aggiornarsi con il pacco scarica pure lo zip cosi' e' a posto
|
|
|
|
|
if ((nRemoteVer > nLocVer) || ((nRemoteVer == nLocVer) && (nRemotePatch > nLocPatch)))
|
|
|
|
|
{
|
|
|
|
|
const int nDot = strHref.Find('.', true);
|
|
|
|
|
strHref = strHref.Left(nDot) + "1.zip";
|
|
|
|
|
HTTPGet(strTempDir+strHref, strWebPath+strHref);
|
|
|
|
|
}
|
|
|
|
|
else //se non deve aggiornarsi elimina l'ini in modo da non avere una mezza patch che farebbe incazzare l'unzipper
|
|
|
|
|
wxRemoveFile(strTempDir+strHref);
|
|
|
|
|
} //if(strHref.EndsWith("ini")...
|
|
|
|
|
} //if(strPatch == "inst")...
|
|
|
|
|
// 2) e' una patch
|
2008-12-18 09:53:31 +00:00
|
|
|
|
else //se invece e' una normale patch... else di if(strPatch=="inst"..
|
2008-09-09 10:47:13 +00:00
|
|
|
|
{
|
2008-12-18 09:53:31 +00:00
|
|
|
|
//controlla che sia pi<70> avanti del suo livello patch e che sia un file utile (servono solo .ini e .zip)
|
2015-06-17 07:15:42 +00:00
|
|
|
|
if (atoi(strPatch) > nLocPatch)
|
2008-09-09 10:47:13 +00:00
|
|
|
|
HTTPGet(strTempDir+strHref, strWebPath+strHref);
|
|
|
|
|
}
|
|
|
|
|
} //if(strHref.StartsWith(strModule))...
|
|
|
|
|
} //if(nPos>0)...
|
|
|
|
|
} //for(wxString strWrk = tf...
|
2007-11-21 10:37:43 +00:00
|
|
|
|
//chiude il file temporaneo
|
|
|
|
|
tfFilesList.Close();
|
|
|
|
|
} //if(tfFilesList...
|
|
|
|
|
|
|
|
|
|
//scompatta le patch di sistema e aggiorna l'install.ini locale
|
|
|
|
|
ok = UnzipModule(strLocalPath, strTempDir, strModule);
|
|
|
|
|
} //if(HTTPGet(...
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
2007-11-21 15:42:21 +00:00
|
|
|
|
//-----------------------------------------------------
|
|
|
|
|
// METODI ALTO LIVELLO PER AGGIORNAMENTI NON STANDARD
|
|
|
|
|
//-----------------------------------------------------
|
|
|
|
|
//---------------------------------------------------------------
|
|
|
|
|
// 1) metodo per l'aggiornamento dei client di rete in automatico
|
|
|
|
|
//---------------------------------------------------------------
|
|
|
|
|
void CampoSetup::ClientUpdate()
|
2007-11-21 10:37:43 +00:00
|
|
|
|
{
|
2012-07-02 13:07:32 +00:00
|
|
|
|
wxFileName fn(GetSetupDir());
|
2007-11-21 10:37:43 +00:00
|
|
|
|
fn.AppendDir("..");
|
|
|
|
|
fn.MakeAbsolute();
|
2008-12-03 11:10:55 +00:00
|
|
|
|
fn.SetFullName("install.ini");
|
2007-11-21 10:37:43 +00:00
|
|
|
|
const wxString strLocalPath = fn.GetPath();
|
2009-02-02 14:07:13 +00:00
|
|
|
|
|
2007-11-21 10:37:43 +00:00
|
|
|
|
wxString strRemotePath;
|
|
|
|
|
{
|
|
|
|
|
CampoIniFile iniLocalInstall(fn.GetFullPath(), "Main");
|
2007-11-21 15:42:21 +00:00
|
|
|
|
strRemotePath = iniLocalInstall.Get("DiskPath");
|
2007-11-21 10:37:43 +00:00
|
|
|
|
}
|
2008-01-04 16:03:24 +00:00
|
|
|
|
|
2007-11-21 15:42:21 +00:00
|
|
|
|
ClientUpdateModule(strLocalPath, strRemotePath, "sy");
|
2007-11-21 10:37:43 +00:00
|
|
|
|
|
|
|
|
|
wxSetWorkingDirectory(strLocalPath);
|
|
|
|
|
wxExecute("ba1 -6 /uADMIN");
|
|
|
|
|
}
|
2007-08-08 09:24:19 +00:00
|
|
|
|
|
2007-11-21 15:42:21 +00:00
|
|
|
|
//-----------------------------------------------------------------------------------------------
|
|
|
|
|
// 2) metodo per l'aggiornamento da disco attraverso il menu di Manutenzione/Installazione moduli
|
|
|
|
|
//-----------------------------------------------------------------------------------------------
|
|
|
|
|
void CampoSetup::DiskUpdate()
|
2007-09-20 14:29:11 +00:00
|
|
|
|
{
|
2012-07-02 13:07:32 +00:00
|
|
|
|
wxFileName fn(GetSetupDir());
|
2007-09-20 14:29:11 +00:00
|
|
|
|
fn.AppendDir("..");
|
|
|
|
|
fn.MakeAbsolute();
|
2008-12-03 11:10:55 +00:00
|
|
|
|
fn.SetFullName("install.ini");
|
2007-09-20 14:29:11 +00:00
|
|
|
|
const wxString strLocalPath = fn.GetPath();
|
2009-06-18 15:35:44 +00:00
|
|
|
|
|
2007-09-20 14:29:11 +00:00
|
|
|
|
wxString strRemotePath;
|
|
|
|
|
{
|
|
|
|
|
CampoIniFile iniLocalInstall(fn.GetFullPath(), "Main");
|
|
|
|
|
strRemotePath = iniLocalInstall.Get("DiskPath");
|
|
|
|
|
}
|
2008-01-04 16:03:24 +00:00
|
|
|
|
|
2010-04-12 09:29:43 +00:00
|
|
|
|
//aggiornamento dei moduli SY ed SR da disco
|
|
|
|
|
//il modulo SY va aggiornato comunque
|
2012-04-10 07:50:04 +00:00
|
|
|
|
#ifndef NDEBUG
|
2015-06-17 07:15:42 +00:00
|
|
|
|
strRemotePath = "c:/campo12/cd/program/";
|
|
|
|
|
DiskUpdateModule(strLocalPath, strRemotePath, "sc");
|
2012-04-10 07:50:04 +00:00
|
|
|
|
#else
|
2007-11-21 15:42:21 +00:00
|
|
|
|
DiskUpdateModule(strLocalPath, strRemotePath, "sy");
|
2010-04-12 09:29:43 +00:00
|
|
|
|
//il modulo SR va aggiornato solo se usato (si sta aggiornando il cpu con il gestore delle chiavi)
|
|
|
|
|
if (m_bLurchWasRunning)
|
|
|
|
|
DiskUpdateModule(strLocalPath, strRemotePath, "sr");
|
2012-04-10 07:50:04 +00:00
|
|
|
|
#endif
|
2007-09-20 14:29:11 +00:00
|
|
|
|
|
|
|
|
|
wxSetWorkingDirectory(strLocalPath);
|
|
|
|
|
wxExecute("ba1 -6 /uADMIN");
|
|
|
|
|
}
|
|
|
|
|
|
2007-11-21 10:37:43 +00:00
|
|
|
|
//----------------------------------------------------------------------------------------
|
2007-11-21 15:42:21 +00:00
|
|
|
|
// 3) metodo per l'aggiornamento via internet attraverso Manutenzione/Installazione moduli
|
2007-11-21 10:37:43 +00:00
|
|
|
|
//----------------------------------------------------------------------------------------
|
2007-11-21 15:42:21 +00:00
|
|
|
|
void CampoSetup::InternetUpdate()
|
2007-11-21 10:37:43 +00:00
|
|
|
|
{
|
2007-11-21 15:42:21 +00:00
|
|
|
|
//install.ini locale dove setup.exe e' in esecuzione
|
2012-07-02 13:07:32 +00:00
|
|
|
|
wxFileName fn(GetSetupDir());
|
2007-11-21 15:42:21 +00:00
|
|
|
|
fn.AppendDir("..");
|
|
|
|
|
fn.MakeAbsolute();
|
2008-12-03 11:10:55 +00:00
|
|
|
|
fn.SetFullName("install.ini");
|
2007-11-21 15:42:21 +00:00
|
|
|
|
const wxString strLocalPath = fn.GetPath();
|
|
|
|
|
|
|
|
|
|
//quale e' il path web da cui aggiornarmi?
|
|
|
|
|
wxString strRemotePath;
|
|
|
|
|
{
|
|
|
|
|
//Install.ini locale da cui leggere il path di dove sta il mio server web
|
|
|
|
|
CampoIniFile iniLocalInstall(fn.GetFullPath(), "Main");
|
|
|
|
|
strRemotePath = iniLocalInstall.Get("WebPath");
|
|
|
|
|
}
|
|
|
|
|
|
2008-01-04 16:03:24 +00:00
|
|
|
|
//aggiornamento dei moduli SY e SR via web
|
2010-04-12 09:29:43 +00:00
|
|
|
|
//il modulo SY va aggiornato comunque
|
2007-11-21 15:42:21 +00:00
|
|
|
|
InternetUpdateModule(strLocalPath, strRemotePath, "sy");
|
2010-04-12 09:29:43 +00:00
|
|
|
|
//il modulo SR va aggiornato solo se usato (si sta aggiornando il cpu con il gestore delle chiavi)
|
|
|
|
|
if (m_bLurchWasRunning)
|
|
|
|
|
InternetUpdateModule(strLocalPath, strRemotePath, "sr");
|
2007-11-21 15:42:21 +00:00
|
|
|
|
|
|
|
|
|
//lanciare ba1.exe -6 in uscita
|
|
|
|
|
wxSetWorkingDirectory(strLocalPath);
|
|
|
|
|
wxExecute("ba1 -6 /uADMIN");
|
2007-11-21 10:37:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-11-21 15:42:21 +00:00
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
|
//metodo per tutte le installazioni e gli aggiornamenti automatici in locale
|
|
|
|
|
//--------------------------------------------------------------------------
|
2007-09-20 14:29:11 +00:00
|
|
|
|
void CampoSetup::NormalSetup()
|
|
|
|
|
{
|
2007-12-03 14:22:50 +00:00
|
|
|
|
//creazione del CampoWizard, ovvero dell'insieme di finestre per gestire installazione/aggiornamento
|
2007-09-20 14:29:11 +00:00
|
|
|
|
m_pWizard = new CampoWizard(m_pMainFrame);
|
|
|
|
|
|
2007-09-14 11:07:04 +00:00
|
|
|
|
if (m_pWizard->Run())
|
2007-07-23 15:01:38 +00:00
|
|
|
|
{
|
2007-09-19 14:47:17 +00:00
|
|
|
|
//e' una DEMO o una versione normale?
|
|
|
|
|
const bool bInstallDemoVersion = m_pWizard->GetInstDemoVersion();
|
2007-07-23 15:01:38 +00:00
|
|
|
|
|
2010-03-11 15:28:12 +00:00
|
|
|
|
|
|
|
|
|
// 1) RACCOLTA PARAMETRI GENERALI INSTALLAZIONE (tipo,path,cartelle,servers,...)
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
//tipo di installazione/aggiornamento
|
|
|
|
|
const InstallationType uInstallationType = m_pWizard->GetInstallationType();
|
|
|
|
|
const bool bNewInstallation = uInstallationType != it_upgrade;
|
|
|
|
|
//installazione servers? solo per server di campo
|
|
|
|
|
const bool bInstallLurch = uInstallationType == it_server && (m_pWizard->GetInstUseAuth() || m_pWizard->GetInstUseDict()) && (!bInstallDemoVersion);
|
|
|
|
|
//uso servers? sarebbe solo per i client ma lo teniamo buono per tutti
|
|
|
|
|
const bool bUseLurch = uInstallationType != it_server && (!m_pWizard->GetSrvAuth().IsEmpty() || !m_pWizard->GetSrvDict().IsEmpty()) && (!bInstallDemoVersion);
|
|
|
|
|
//installazione datidemo? (oddio speriamo di no!; comunque vale solo per installazione standard)
|
|
|
|
|
const bool bInstallDemoData = uInstallationType == (it_standalone && m_pWizard->GetInstDemoData()) || (bInstallDemoVersion);
|
|
|
|
|
//cartelle selezionate dall'utente
|
|
|
|
|
const wxString& strPrgLocPath = m_pWizard->GetPrgLocPath();
|
|
|
|
|
const wxString& strDataPath = m_pWizard->GetDataPath();
|
|
|
|
|
|
|
|
|
|
//se nuova installazione deve anche creare la directory di destinazione
|
|
|
|
|
if (bNewInstallation)
|
2007-08-22 09:16:29 +00:00
|
|
|
|
{
|
2010-03-11 15:28:12 +00:00
|
|
|
|
//creazione della directory dei programmi (compreso l'intero albero directory)
|
2007-08-23 13:18:25 +00:00
|
|
|
|
CheckAndMakeDir(strPrgLocPath, "programmi");
|
2010-03-11 15:28:12 +00:00
|
|
|
|
//creazione della directory dei dati (compreso l'intero albero directory)
|
|
|
|
|
//un client NON installa i dati!! (senno' e' una installazione locale semplice)
|
|
|
|
|
if (uInstallationType != it_client)
|
|
|
|
|
CheckAndMakeDir(strDataPath, "dati");
|
2007-09-19 14:47:17 +00:00
|
|
|
|
}
|
2010-03-11 15:28:12 +00:00
|
|
|
|
|
2007-09-19 14:47:17 +00:00
|
|
|
|
|
2010-03-11 15:28:12 +00:00
|
|
|
|
// 2) COPIA DEI FILES DI INSTALLAZIONE DALLA CARTELLA CAMPO (E SUBDIRS) (SU CD) ALLA CARTELLA DESTINAZIONE
|
|
|
|
|
//--------------------------------------------------------------------------------------------------------
|
|
|
|
|
//copia del contenuto della cartella campo nella cartella di destinazione (installaz/aggiornam)
|
|
|
|
|
//per prima cosa cerca la cartella dei files sorgente...
|
|
|
|
|
wxArrayString asFilesList;
|
2012-07-02 13:07:32 +00:00
|
|
|
|
wxFileName strSourcePath(GetSetupDir(), "*.*");
|
2010-03-11 15:28:12 +00:00
|
|
|
|
strSourcePath.AppendDir("..");
|
|
|
|
|
strSourcePath.AppendDir("..");
|
|
|
|
|
strSourcePath.AppendDir("campo"); // NOME fisso della cartella del CD, non mettere APPNAME
|
|
|
|
|
strSourcePath.MakeAbsolute();
|
|
|
|
|
//stringa inutile al programma ma decisiva per il programmatore
|
|
|
|
|
const wxString strSrc = strSourcePath.GetPath();
|
|
|
|
|
//..contando anche quanti sono e memorizzandoli in un array asFileList
|
|
|
|
|
const size_t uFilesToCopy = wxDir::GetAllFiles(strSrc, &asFilesList);
|
|
|
|
|
|
|
|
|
|
const size_t nPathLenght = strSrc.Len();
|
|
|
|
|
//progress bar
|
|
|
|
|
CampoProgressDialog pi("Installazione Dati e Programmi di base...", (int)uFilesToCopy, m_pWizard);
|
|
|
|
|
|
|
|
|
|
for (size_t i = 0; i < uFilesToCopy; i++)
|
|
|
|
|
{
|
|
|
|
|
//per ogni file da copiare controlla i path sorgente e destinazione(problema con sottodirectory tipo..
|
|
|
|
|
//..dati); strFileCurr va lasciato qui perche' DEVE ESSERE AZZERATO ad ogni cambio file!!!!!!
|
|
|
|
|
wxString strFileCurr;
|
2007-10-25 15:48:37 +00:00
|
|
|
|
|
2010-03-11 15:28:12 +00:00
|
|
|
|
//controlla se il file corrente e' dentro una sottodirectory (tipo dati,servers,ecc...) oppure e' al..
|
|
|
|
|
//..primo livello (quindi e' un file di programma)
|
|
|
|
|
wxString strSourceFile = asFilesList[i].Lower();
|
|
|
|
|
NormalizeSlash(strSourceFile);
|
2009-02-04 16:28:37 +00:00
|
|
|
|
|
2010-03-11 15:28:12 +00:00
|
|
|
|
//e' in una subdir se la lunghezza del suo path prima dell'ultimo '/' e' > della lunghezza del path di root
|
|
|
|
|
const bool bIsSubDir = strSourceFile.Find('/', true) > (int)nPathLenght;
|
2007-10-25 15:48:37 +00:00
|
|
|
|
|
2010-03-11 15:28:12 +00:00
|
|
|
|
//2A) files con subdirectory
|
|
|
|
|
if (bIsSubDir)
|
|
|
|
|
{
|
|
|
|
|
//files dei dati standard! solo in caso di nuova installazione!! E NON installazione DEMO!!
|
|
|
|
|
if (strSourceFile.Find("/dati/") > 0)
|
2007-09-06 15:46:28 +00:00
|
|
|
|
{
|
2010-03-11 15:28:12 +00:00
|
|
|
|
//i DATI NON VANNO MAI installati in caso di aggiornamento!!!
|
|
|
|
|
//i DATI NON VANNO MAI installati in caso di installazione client!!!
|
|
|
|
|
//e nemmeno in caso si scelga di installare i dati demo (senno' sporca la dir dati e i datidemo non si installano)
|
2014-09-22 13:58:30 +00:00
|
|
|
|
//Ricordare che c'e' gi<67> stato il controllo nella Forward della pagina di selezione, quindi la cartella..
|
2010-03-11 15:28:12 +00:00
|
|
|
|
//..di destinazione e' comunque vuota
|
|
|
|
|
if (bNewInstallation && uInstallationType != it_client && !bInstallDemoData)
|
2007-09-06 15:46:28 +00:00
|
|
|
|
{
|
2010-03-11 15:28:12 +00:00
|
|
|
|
strFileCurr = strDataPath;
|
|
|
|
|
strFileCurr += asFilesList[i].Mid(nPathLenght + 5);
|
2014-09-22 13:58:30 +00:00
|
|
|
|
//Ulteriore controllo di sicurezza: se trova il file di destinazione gi<67> presente..
|
2010-03-11 15:28:12 +00:00
|
|
|
|
//..NON lo sovrascrive (lo mette vuoto cosi' non lo copia)
|
|
|
|
|
if (wxFileName::FileExists(strFileCurr))
|
|
|
|
|
strFileCurr = "";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
strFileCurr = "";
|
|
|
|
|
|
|
|
|
|
} else
|
|
|
|
|
if (strSourceFile.Find("/datidemo/") > 0)
|
|
|
|
|
{
|
|
|
|
|
//i DATIDEMO vanno copiati solo in caso di installazione DEMO o di installazione standalone con specifica..
|
|
|
|
|
//richiesta di installazione DATIDEMO
|
|
|
|
|
if (bInstallDemoData)
|
2007-09-19 14:47:17 +00:00
|
|
|
|
{
|
2010-03-11 15:28:12 +00:00
|
|
|
|
strFileCurr = strDataPath;
|
|
|
|
|
strFileCurr += asFilesList[i].Mid(nPathLenght + 9);
|
|
|
|
|
if (wxFileName::FileExists(strFileCurr))
|
|
|
|
|
strFileCurr = "";
|
2007-09-19 14:47:17 +00:00
|
|
|
|
}
|
2010-03-11 15:28:12 +00:00
|
|
|
|
else
|
|
|
|
|
strFileCurr = "";
|
|
|
|
|
|
|
|
|
|
} else
|
|
|
|
|
if (strSourceFile.Find("/servers/") > 0) //che fare con i servers? copiare la directory...
|
|
|
|
|
{
|
2010-04-12 09:29:43 +00:00
|
|
|
|
if (bInstallLurch && !bInstallDemoVersion) //..ma solo se devi installare i servers
|
2007-09-19 14:47:17 +00:00
|
|
|
|
{
|
|
|
|
|
strFileCurr = strPrgLocPath;
|
2010-03-11 15:28:12 +00:00
|
|
|
|
strFileCurr += "/servers";
|
|
|
|
|
strFileCurr += asFilesList[i].Mid(nPathLenght + 8);
|
2007-09-19 14:47:17 +00:00
|
|
|
|
}
|
2010-03-11 15:28:12 +00:00
|
|
|
|
else
|
|
|
|
|
strFileCurr = "";
|
2007-09-19 14:47:17 +00:00
|
|
|
|
}
|
2010-03-11 15:28:12 +00:00
|
|
|
|
else //files vari di altre subdirectory che si installano sempre (es. recdesc)
|
2007-10-25 15:48:37 +00:00
|
|
|
|
{
|
|
|
|
|
strFileCurr = strPrgLocPath;
|
|
|
|
|
strFileCurr += asFilesList[i].Mid(nPathLenght);
|
|
|
|
|
}
|
2010-03-11 15:28:12 +00:00
|
|
|
|
}
|
|
|
|
|
//2B) files senza subdirectory (programmi!)
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strFileCurr = strPrgLocPath;
|
|
|
|
|
strFileCurr += asFilesList[i].Mid(nPathLenght);
|
|
|
|
|
}
|
|
|
|
|
//copia i files nella cartella di destinazione (programmi,dati,cazzi e mazzi);se il nome del file..
|
|
|
|
|
//..di destinazione e' vuoto significa che non lo deve copiare!! (es. dati in aggiornamento)
|
|
|
|
|
if (!strFileCurr.IsEmpty())
|
|
|
|
|
{
|
|
|
|
|
//aggiorna la progind
|
|
|
|
|
if (!pi.Update((int)i, asFilesList[i]))
|
|
|
|
|
break;
|
|
|
|
|
//normalizza per sicurezza il nome (completo di path) del file (visto che ci sono metodi cui piace..
|
|
|
|
|
//..aggiungere / o \ a piacere..
|
|
|
|
|
NormalizeSlash(strFileCurr);
|
|
|
|
|
|
|
|
|
|
//eventuali sottodirectory le crea (solo se hanno un nome) e poi copia fisicamente i files
|
|
|
|
|
//se un file non si copia interrompe l'installazione con un ErrorBox
|
|
|
|
|
if (!CopyFilesAndDirs(asFilesList[i], strFileCurr, true))
|
|
|
|
|
break;
|
|
|
|
|
} //if (!strFileCurr.IsEmpty()..
|
|
|
|
|
} //for(size_t...
|
|
|
|
|
|
|
|
|
|
UpdateInstallIni(strSrc + "/install.ini", strPrgLocPath + "/install.ini", "sy");
|
|
|
|
|
if (bInstallLurch)
|
|
|
|
|
UpdateInstallIni(strSrc + "/install.ini", strPrgLocPath + "/install.ini", "sr");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 3) COPIA DELLA CARTELLA SETUP DA CD (PROGRAM\SETUP) A CARTELLA DI DESTINAZIONE
|
|
|
|
|
//-------------------------------------------------------------------------------
|
|
|
|
|
//Funziona tutto come al punto 2)! Cambiano solo i path (sorgente = program\setup, destinazione = destdir\setup)
|
|
|
|
|
wxArrayString asSetupFilesList;
|
2012-07-02 13:07:32 +00:00
|
|
|
|
wxFileName fnSetupSourcePath(GetSetupDir(), "*.*");
|
2010-03-11 15:28:12 +00:00
|
|
|
|
fnSetupSourcePath.MakeAbsolute();
|
|
|
|
|
|
|
|
|
|
const wxString strSetupSrc = fnSetupSourcePath.GetPath();
|
|
|
|
|
const wxString strSetupDst = strPrgLocPath + "/setup";
|
|
|
|
|
|
|
|
|
|
const size_t uSetupFilesToCopy = wxDir::GetAllFiles(strSetupSrc, &asSetupFilesList);
|
|
|
|
|
const size_t nSetupPathLenght = strSetupSrc.Len();
|
|
|
|
|
CampoProgressDialog po(_("Copia cartella Setup..."), (int)uSetupFilesToCopy, m_pWizard);
|
|
|
|
|
|
|
|
|
|
wxString strFileCurr;
|
|
|
|
|
|
|
|
|
|
for (size_t i = 0; i < uSetupFilesToCopy; i++)
|
|
|
|
|
{
|
|
|
|
|
wxString strSourceFile = asSetupFilesList[i].Lower();
|
|
|
|
|
NormalizeSlash(strSourceFile);
|
|
|
|
|
strFileCurr = strSetupDst;
|
|
|
|
|
strFileCurr += asSetupFilesList[i].Mid(nSetupPathLenght);
|
|
|
|
|
|
|
|
|
|
if (!strFileCurr.IsEmpty())
|
|
|
|
|
{
|
|
|
|
|
if (!po.Update((int)i, asSetupFilesList[i]))
|
|
|
|
|
break;
|
|
|
|
|
NormalizeSlash(strFileCurr);
|
|
|
|
|
|
|
|
|
|
if (!CopyFilesAndDirs(asSetupFilesList[i], strFileCurr, true))
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ?) INSTALLAZIONE DATI DEMO
|
|
|
|
|
//---------------------------
|
|
|
|
|
//installazione dei dati dimostrativi (che schifo!).Non si puo' fare in aggiornamento!
|
|
|
|
|
/* if (bInstallDemoData && uInstallationType < 3)
|
|
|
|
|
{
|
|
|
|
|
//trova la cartella datidemo da copiare
|
|
|
|
|
wxArrayString asDataList;
|
|
|
|
|
const wxString strSrc = GetSourceDir("datidemo");
|
|
|
|
|
//conta i files da copiare e si lancia nell'operazione di copiatura...
|
|
|
|
|
//Vale quanto detto per l'installazione dell'area dati
|
|
|
|
|
const size_t uFilesToCopy = wxDir::GetAllFiles(strSrc, &asDataList);
|
|
|
|
|
wxString strFileCurr;
|
|
|
|
|
const size_t nPathLenght = strSrc.Len();
|
|
|
|
|
CampoProgressDialog pi("Installazione Dati Demo...", (int)uFilesToCopy, m_pWizard);
|
|
|
|
|
for (size_t i = 0; i < uFilesToCopy; i++)
|
|
|
|
|
{
|
|
|
|
|
if (!pi.Update((int)i, asDataList[i]))
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
asDataList[i].Lower();
|
|
|
|
|
strFileCurr = strDataPath;
|
|
|
|
|
strFileCurr += asDataList[i].Mid(nPathLenght);
|
|
|
|
|
|
2007-09-19 14:47:17 +00:00
|
|
|
|
if (!strFileCurr.IsEmpty())
|
|
|
|
|
{
|
|
|
|
|
//eventuali sottodirectory le crea (solo se hanno un nome) e poi copia fisicamente i files
|
|
|
|
|
//se un file non si copia interrompe l'installazione con un ErrorBox
|
2010-03-11 15:28:12 +00:00
|
|
|
|
if (!CopyFilesAndDirs(asDataList[i], strFileCurr, false))
|
2007-09-19 14:47:17 +00:00
|
|
|
|
break;
|
2007-09-06 15:46:28 +00:00
|
|
|
|
} //if (!strFileCurr.IsEmpty()..
|
2010-03-11 15:28:12 +00:00
|
|
|
|
} //for (size_t i = 0...
|
|
|
|
|
} //if(bInstallDemoData... */
|
2007-10-25 15:48:37 +00:00
|
|
|
|
|
2007-09-19 14:47:17 +00:00
|
|
|
|
|
2010-03-11 15:28:12 +00:00
|
|
|
|
// 4) COMPILAZIONE CAMPO.INI CON CONFIGURAZIONE NUOVA INSTALLAZIONE
|
|
|
|
|
//-----------------------------------------------------------------
|
|
|
|
|
//adesso deve compilare il campo.ini se nuova installazione..
|
|
|
|
|
if (bNewInstallation)
|
|
|
|
|
{
|
|
|
|
|
{ //parentesi necessaria per la scrittura immediata (non cancellare! serve per debug)
|
|
|
|
|
//paragrafo [Main]
|
2007-09-28 10:22:37 +00:00
|
|
|
|
CampoIniFile CampoIniMain(strPrgLocPath + "/campo.ini", "Main");
|
2015-06-17 07:15:42 +00:00
|
|
|
|
const unsigned int uDongleType = m_pWizard->GetDongleType(); // 3 o 4 dopo la morte delle chiavi hw
|
2010-03-11 15:28:12 +00:00
|
|
|
|
CampoIniMain.Set("Donglehw", uDongleType);
|
|
|
|
|
CampoIniMain.Set("Study", strDataPath);
|
|
|
|
|
CampoIniMain.Set("Firm", "com");
|
|
|
|
|
//server,client o standalone?
|
|
|
|
|
CampoIniMain.Set("Type", uInstallationType);
|
2007-09-28 10:22:37 +00:00
|
|
|
|
}
|
2010-03-11 15:28:12 +00:00
|
|
|
|
//paragrafo [Server]
|
|
|
|
|
if (bInstallLurch || bUseLurch)
|
2009-01-19 17:25:12 +00:00
|
|
|
|
{
|
2010-03-11 15:28:12 +00:00
|
|
|
|
CampoIniFile CampoIniSrv(strPrgLocPath + "/campo.ini", "Server");
|
|
|
|
|
CampoIniSrv.Set("Dongle", m_pWizard->GetSrvAuth());
|
2015-06-17 07:15:42 +00:00
|
|
|
|
// CampoIniSrv.Set("Dictionary", m_pWizard->GetSrvDict());
|
2009-01-19 17:25:12 +00:00
|
|
|
|
}
|
2010-03-11 15:28:12 +00:00
|
|
|
|
} //if(bNewInstallation...
|
|
|
|
|
else //e' un aggiornamento! scrive il type
|
|
|
|
|
{
|
|
|
|
|
CampoIniFile CampoIniMain(strPrgLocPath + "/campo.ini", "Main");
|
|
|
|
|
//SOLO se sta aggiornando una versione antecedente alla 10.0 scrive la variabile Type nel campo.ini..
|
|
|
|
|
//..ovvero deve testare se Type = 0
|
|
|
|
|
if (CampoIniMain.GetInt("Type") == 0)
|
|
|
|
|
CampoIniMain.Set("Type", CampoIniMain.GetInstallationType());
|
|
|
|
|
}
|
2009-01-19 17:25:12 +00:00
|
|
|
|
|
2007-08-24 13:18:47 +00:00
|
|
|
|
|
2010-03-11 15:28:12 +00:00
|
|
|
|
// 5) COMPILAZIONE\AGGIORNAMENTO INSTALL.INI CON DISKPATH
|
|
|
|
|
//-------------------------------------------------------
|
|
|
|
|
//..e modificare comunque l'install.ini aggiornando eventualmente l'origine dei programmi
|
|
|
|
|
//parentesi necessaria per la scrittura immediata (non cancellare! serve per debug)
|
|
|
|
|
{
|
|
|
|
|
CampoIniFile CampoInstall(strPrgLocPath + "/install.ini", "Main");
|
|
|
|
|
if (uInstallationType == it_client) //client: directory origine sul server
|
|
|
|
|
CampoInstall.Set("DiskPath", m_pWizard->GetPrgNetPath());
|
|
|
|
|
else //e' il path assoluto dell'install.ini che sta in 'program' (es. D:\program)
|
2007-12-13 14:49:46 +00:00
|
|
|
|
{
|
2010-03-11 15:28:12 +00:00
|
|
|
|
const wxString strSrc = GetSourceDir("program");
|
|
|
|
|
CampoInstall.Set("DiskPath", strSrc);
|
2008-01-04 16:03:24 +00:00
|
|
|
|
}
|
2010-03-11 15:28:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 6) AGGIORNAMENTO DI ADMIN.INI CON IL TEMA DEL RESELLER
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
//carica il tema predefinito del reseller dentro l'admin.ini che sta in cartella programmi\dati\config..
|
|
|
|
|
//..in modo da vederli subito quando lancer<65> ba1 (e successivamente ba0)
|
|
|
|
|
if (bNewInstallation)
|
|
|
|
|
{
|
|
|
|
|
//file sorgente
|
|
|
|
|
const wxString strThemeFileName = Theme();
|
2012-07-02 13:07:32 +00:00
|
|
|
|
wxString strSrcThemePath = GetSetupDir();
|
2010-03-11 15:28:12 +00:00
|
|
|
|
strSrcThemePath << strThemeFileName;
|
|
|
|
|
CampoIniFile CampoTheme(strSrcThemePath, "Standard");
|
2008-01-04 16:03:24 +00:00
|
|
|
|
|
2010-03-11 15:28:12 +00:00
|
|
|
|
//file di destinazione
|
|
|
|
|
CampoIniFile CampoDestAdmin(strDataPath + "/config/admin.ini", "Colors");
|
2008-01-04 16:03:24 +00:00
|
|
|
|
|
2010-03-11 15:28:12 +00:00
|
|
|
|
//copia del tema standard nell'admin.ini di destinazione
|
|
|
|
|
long nIndex;
|
|
|
|
|
wxString strKey;
|
|
|
|
|
//ciclo su tutte le variabili del paragrafo di origine
|
|
|
|
|
for (bool ok = CampoTheme.GetFirstEntry(strKey, nIndex); ok; ok = CampoTheme.GetNextEntry(strKey, nIndex))
|
2008-01-04 16:03:24 +00:00
|
|
|
|
{
|
2010-03-11 15:28:12 +00:00
|
|
|
|
//copia nel corrispondente paragrafo di destinazione
|
|
|
|
|
CampoDestAdmin.Set(strKey, CampoTheme.Get(strKey));
|
2007-12-13 14:49:46 +00:00
|
|
|
|
}
|
2010-03-11 15:28:12 +00:00
|
|
|
|
}
|
2007-09-05 15:21:08 +00:00
|
|
|
|
|
2007-08-24 13:18:47 +00:00
|
|
|
|
|
2010-03-11 15:28:12 +00:00
|
|
|
|
// 7) AGGIORNAMENTO DEL MODULO SY CON EVENTUALI PATCH PRESENTI IN PROGRAM DEL CD E AGGIORNAMENTO INSTALL.INI
|
|
|
|
|
//----------------------------------------------------------------------------------------------------------
|
|
|
|
|
//procede poi al caricamento delle patch eventuali di sistema all'interno della dir 'program' e al..
|
|
|
|
|
//..conseguente riaggiornamento del livello versione/patch di SY ed SR in install.ini
|
|
|
|
|
const wxString strPrgCDPath = GetSourceDir("program");
|
|
|
|
|
if (wxFileName::DirExists(strPrgCDPath))
|
|
|
|
|
{
|
|
|
|
|
const wxString strSetupCDPath = strPrgCDPath + "/setup";
|
|
|
|
|
const wxString strSetupLocPath = strPrgLocPath + "/setup";
|
|
|
|
|
//Procedura di salvataggio del corrente OEM (reseller) del prg gi<67> installato; in questo modo anche..
|
|
|
|
|
//..mandando un CD AGA (che generalmente funziona!) ad un cliente di un distributore non AGA, il reseller..
|
|
|
|
|
//..a video non cambia. Per cambiare reseller si dovr<76> intervenire a mano sull'oem.ini cambiando il valore..
|
|
|
|
|
//..di OEM dopo l'installazione
|
|
|
|
|
const wxString strOemLocPath = strSetupLocPath + "/oem.ini";
|
|
|
|
|
CampoIniFile CampoIniOem(strOemLocPath, "MAIN");
|
|
|
|
|
const int nOldOem = CampoIniOem.GetInt("OEM");
|
|
|
|
|
//svuota proprio la directory setup in modo da non coservare files indesiderati
|
|
|
|
|
EmptyOutDir(strOemLocPath);
|
|
|
|
|
//copia la directory setup da CD a locale
|
|
|
|
|
CopyDir(strSetupCDPath, strSetupLocPath);
|
|
|
|
|
//rimette a posto la candela...cio<69>, il reseller
|
|
|
|
|
CampoIniOem.Set("OEM", nOldOem);
|
|
|
|
|
//..Fine dell'aggiornamento della cartella setup
|
|
|
|
|
|
2014-09-22 13:58:30 +00:00
|
|
|
|
//scompattamento dei moduli e delle patch che eventualmente trova su CD per quanto riguarda i moduli SY..
|
2010-04-12 09:29:43 +00:00
|
|
|
|
UnzipModule(strPrgLocPath, strPrgCDPath, wxString("sy"));
|
|
|
|
|
//..ed SR ma solo se richiesto in fase di installazione
|
|
|
|
|
if (bInstallLurch)
|
|
|
|
|
UnzipModule(strPrgLocPath, strPrgCDPath, wxString("sr"));
|
2010-03-11 15:28:12 +00:00
|
|
|
|
}
|
2007-10-18 11:13:15 +00:00
|
|
|
|
|
|
|
|
|
|
2010-03-11 15:28:12 +00:00
|
|
|
|
// 8) CREAZIONE AUTOSTART DEI SERVERS (SE CI SONO)
|
2014-09-22 13:58:30 +00:00
|
|
|
|
// ------------------------------------------------
|
|
|
|
|
// Se sta installando Campo in postazione server e deve installare un gestore di servizi,
|
|
|
|
|
// avvia la procedura della creazione dell'autostart(un casino).
|
|
|
|
|
// Questa procedura non puo' valere per l'aggiornamento, che agisce in modo diverso
|
2010-03-11 15:28:12 +00:00
|
|
|
|
if (bNewInstallation)
|
|
|
|
|
{
|
|
|
|
|
const LurchMode iSrvAutostartMode = m_pWizard->GetSrvAutostartMode();
|
|
|
|
|
if (iSrvAutostartMode != lm_none)
|
2015-06-17 07:15:42 +00:00
|
|
|
|
CreateAutostartLurch(iSrvAutostartMode, strPrgLocPath);
|
2010-03-11 15:28:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-09-05 15:55:53 +00:00
|
|
|
|
|
2010-03-11 15:28:12 +00:00
|
|
|
|
// 9) CREAZIONE DELL'ICONA SUL DESKTOP
|
|
|
|
|
//------------------------------------
|
|
|
|
|
const bool bDesktopShortcut = m_pWizard->GetDesktopShortcut();
|
|
|
|
|
if (bDesktopShortcut)
|
|
|
|
|
{
|
|
|
|
|
const wxFileName strExe(strPrgLocPath, wxT("ba0.exe"));
|
2007-09-06 09:49:40 +00:00
|
|
|
|
|
2010-03-11 15:28:12 +00:00
|
|
|
|
CampoIniFile CampoIniMain(strPrgLocPath + "/campo.ini", "Main");
|
|
|
|
|
InstallationType nInstType = CampoIniMain.GetInstallationType();
|
|
|
|
|
|
|
|
|
|
wxString strLnk = Product();
|
|
|
|
|
switch (nInstType)
|
2007-09-19 14:47:17 +00:00
|
|
|
|
{
|
2010-03-11 15:28:12 +00:00
|
|
|
|
case it_server: strLnk += " (Server)"; break;
|
|
|
|
|
case it_client: strLnk += " (Client)"; break;
|
|
|
|
|
default: break;
|
2007-09-06 11:05:56 +00:00
|
|
|
|
}
|
2007-09-06 15:46:28 +00:00
|
|
|
|
|
2010-03-11 15:28:12 +00:00
|
|
|
|
//crea comunque l'icona
|
|
|
|
|
CreateIcon(CSIDL_COMMON_DESKTOPDIRECTORY, strExe, strLnk);
|
|
|
|
|
}
|
2007-09-19 14:47:17 +00:00
|
|
|
|
|
2010-03-11 15:28:12 +00:00
|
|
|
|
|
|
|
|
|
// 10) AGGIORNAMENTO CAMPO.STP
|
|
|
|
|
//---------------------------
|
|
|
|
|
if (bNewInstallation)
|
|
|
|
|
{
|
|
|
|
|
//deve aggiungere la nuova installazione al campo.stp
|
2012-07-02 13:07:32 +00:00
|
|
|
|
for (int i = 1; ; i++)
|
2010-03-11 15:28:12 +00:00
|
|
|
|
{
|
|
|
|
|
wxString strGroup;
|
|
|
|
|
strGroup << i;
|
|
|
|
|
CampoIniFile CampoStp("C:\\campo.stp", strGroup);
|
2012-07-02 13:07:32 +00:00
|
|
|
|
const wxString strPath = CampoStp.Get("Program");
|
|
|
|
|
if (strPath.IsEmpty() || strPath.CmpNoCase(strPrgLocPath) == 0)
|
2010-03-11 15:28:12 +00:00
|
|
|
|
{
|
|
|
|
|
CampoStp.Set("Program", strPrgLocPath);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-09-19 14:47:17 +00:00
|
|
|
|
}
|
2010-03-11 15:28:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 11) CHIUDE IL SETUP LANCIANDO BA1 -6 PER INSTALLAZIONE MODULI
|
|
|
|
|
//-------------------------------------------------------------
|
|
|
|
|
//lanciare ba1.exe -6 in uscita
|
|
|
|
|
if (wxSetWorkingDirectory(strPrgLocPath))
|
|
|
|
|
wxExecute("ba1 -6 /uADMIN");
|
|
|
|
|
else
|
2012-07-02 13:07:32 +00:00
|
|
|
|
ErrorBox("Impossibile installare i moduli: cartella di destinazione irraggiungibile!");
|
2010-03-11 15:28:12 +00:00
|
|
|
|
|
2007-09-06 11:05:56 +00:00
|
|
|
|
|
2007-09-14 11:07:04 +00:00
|
|
|
|
} //if (m_pWizard->Run())...
|
|
|
|
|
m_pWizard->Destroy();
|
2007-09-26 12:59:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-12-05 12:11:20 +00:00
|
|
|
|
//------------------------------------------------------------------------------------------------------
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// Metodi per il controllo preventivo di eventuali cazzate in procinto di accadere
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////
|
2015-06-17 07:15:42 +00:00
|
|
|
|
|
2009-01-20 11:16:02 +00:00
|
|
|
|
bool CampoSetup::SystemRunning(const wxString& strAppName, wxString strMsg) const
|
2007-09-26 12:59:37 +00:00
|
|
|
|
{
|
2009-01-20 11:16:02 +00:00
|
|
|
|
strMsg.Replace(wxT("PRODUCT"), PRODUCT);
|
2010-12-23 09:19:03 +00:00
|
|
|
|
strMsg += "\nSi desidera ritentare?";
|
2009-01-20 11:16:02 +00:00
|
|
|
|
|
2010-12-23 09:19:03 +00:00
|
|
|
|
bool bRunning = false;
|
|
|
|
|
bool bRetry = true;
|
|
|
|
|
while (bRetry)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
2015-06-17 07:15:42 +00:00
|
|
|
|
for (i = 10; i > 0 && FindProcessId(strAppName); i--)
|
2010-12-23 09:19:03 +00:00
|
|
|
|
wxSleep(1);
|
2007-10-09 13:22:42 +00:00
|
|
|
|
|
2010-12-23 09:19:03 +00:00
|
|
|
|
bRetry = false;
|
|
|
|
|
bRunning = i <= 0;
|
|
|
|
|
if (bRunning && !strMsg.IsEmpty())
|
|
|
|
|
{
|
|
|
|
|
bRetry = YesNoBox(strMsg);
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-10-09 13:22:42 +00:00
|
|
|
|
|
2010-12-23 09:19:03 +00:00
|
|
|
|
return bRunning;
|
2007-09-26 12:59:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-07-23 15:01:38 +00:00
|
|
|
|
|
2015-06-17 07:15:42 +00:00
|
|
|
|
int CampoSetup::LurchRunning() const
|
2008-01-04 16:03:24 +00:00
|
|
|
|
{
|
2015-06-17 07:15:42 +00:00
|
|
|
|
//cerca SSAservice che funziona come servizio
|
|
|
|
|
int run = 0;
|
|
|
|
|
if (SystemRunning("SSAservice", wxEmptyString))
|
|
|
|
|
run |= 1;
|
|
|
|
|
if (!run)
|
2008-01-04 16:03:24 +00:00
|
|
|
|
{
|
2015-06-17 07:15:42 +00:00
|
|
|
|
//...se non lo trova cerca il solo Authoriz come programma...
|
|
|
|
|
if (SystemRunning("Authorization", wxEmptyString))
|
|
|
|
|
run |= 2;
|
2008-01-04 16:03:24 +00:00
|
|
|
|
}
|
2015-06-17 07:15:42 +00:00
|
|
|
|
return run;
|
2008-01-04 16:03:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-11-18 15:03:42 +00:00
|
|
|
|
|
2014-09-22 13:58:30 +00:00
|
|
|
|
bool CampoSetup::CampoIsRunning() const
|
2008-11-18 15:03:42 +00:00
|
|
|
|
{
|
|
|
|
|
//ricerca di campo.aut per avere la lista dei moduli
|
|
|
|
|
//prima tenta con aggiornamento da disco...
|
|
|
|
|
wxString strInstallPath = "../install.ini";
|
|
|
|
|
//...poi con aggiornamento da CD
|
|
|
|
|
if (!wxFileName::FileExists(strInstallPath))
|
|
|
|
|
strInstallPath = "../../campo/install.ini";
|
|
|
|
|
|
|
|
|
|
//fa un giro sull'install.ini alla ricerca di tutti i moduli (sono i paragrafi lunghi 2) installati (se aggiornamento..
|
|
|
|
|
//..da disco) o da installare (se sta installando da CD)
|
|
|
|
|
wxArrayString asModuli;
|
|
|
|
|
if (wxFileName::FileExists(strInstallPath))
|
|
|
|
|
{
|
|
|
|
|
wxString strModulo;
|
|
|
|
|
long nIndex;
|
|
|
|
|
CampoIniFile iniInstall(strInstallPath, strModulo);
|
|
|
|
|
for (bool ok = iniInstall.GetFirstGroup(strModulo, nIndex); ok; ok = iniInstall.GetNextGroup(strModulo, nIndex))
|
|
|
|
|
{
|
|
|
|
|
if (strModulo.Len() == 2)
|
|
|
|
|
asModuli.Add(strModulo); //aggiunge all'array tutti i moduli che trova in install.ini
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else //non trova nessun install.ini (non dovrebbe mai accadere) e tenta i moduli pi<70> importanti
|
|
|
|
|
{
|
|
|
|
|
asModuli.Add("ba");
|
|
|
|
|
asModuli.Add("cg");
|
|
|
|
|
asModuli.Add("ve");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//scandisce l'array dei moduli alla ricerca di un eventuale programma di campo ancora running a sua insaputa
|
|
|
|
|
wxString strAppName;
|
|
|
|
|
for (size_t i = 0; i < asModuli.GetCount(); i++)
|
|
|
|
|
{
|
|
|
|
|
for (size_t j = 0; j <= 9; j++)
|
|
|
|
|
{
|
|
|
|
|
strAppName = asModuli[i];
|
|
|
|
|
strAppName += ('0'+j);
|
|
|
|
|
wxSingleInstanceChecker sicProgram(strAppName);
|
|
|
|
|
if (sicProgram.IsAnotherRunning())
|
|
|
|
|
{
|
2015-06-17 07:15:42 +00:00
|
|
|
|
strAppName << " <20> in esecuzione! E' necessario terminarlo utilizzando la Gestione Attivit<69> di Windows.";
|
2008-11-18 15:03:42 +00:00
|
|
|
|
ErrorBox(strAppName);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false; //campo non sta andando
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-22 13:58:30 +00:00
|
|
|
|
//metodo principale che sceglie la modalit<69> di lancio del programma
|
2007-09-26 12:59:37 +00:00
|
|
|
|
void CampoSetup::OnTimer(wxTimerEvent& WXUNUSED(e))
|
|
|
|
|
{
|
2009-01-21 16:15:45 +00:00
|
|
|
|
//controllo di un eventuale setup gi<67> lanciato (tipico di utonti e della premiata ditta bib<69> & bib<69>)
|
2012-06-18 14:14:15 +00:00
|
|
|
|
wxSingleInstanceChecker sicSetup("SetCmpUp");
|
2009-01-21 16:15:45 +00:00
|
|
|
|
if (sicSetup.IsAnotherRunning())
|
|
|
|
|
{
|
|
|
|
|
wxString msg;
|
2012-06-18 14:14:15 +00:00
|
|
|
|
msg << "Un'installazione di " << PRODUCT << " <20> gi<67> in esecuzione!";
|
2009-01-21 16:15:45 +00:00
|
|
|
|
ErrorBox(msg);
|
|
|
|
|
m_pMainFrame->Destroy();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2007-09-26 12:59:37 +00:00
|
|
|
|
//controllo di eventuali Campo o servers attivi e conseguente interruzione dell'installazione
|
2015-06-17 07:15:42 +00:00
|
|
|
|
m_bLurchWasRunning = LurchRunning() != 0;
|
2009-04-21 09:21:08 +00:00
|
|
|
|
if (m_bLurchWasRunning)
|
2008-07-08 10:51:07 +00:00
|
|
|
|
{
|
2009-01-20 11:16:02 +00:00
|
|
|
|
wxString msg;
|
|
|
|
|
msg << "Per poter aggiornare/installare il programma " << PRODUCT
|
|
|
|
|
<< " deve temporaneamente essere disattivato il gestore delle licenze!\n"
|
|
|
|
|
<< "Prima di disattivare il gestore delle licenze accertarsi che tutti gli utenti spengano il programma!!\n"
|
|
|
|
|
<< "Proseguire con la disattivazione?";
|
|
|
|
|
if (YesNoBox(msg))
|
|
|
|
|
StopLurch();
|
2008-07-17 15:05:25 +00:00
|
|
|
|
else
|
2008-11-18 15:03:42 +00:00
|
|
|
|
{
|
|
|
|
|
m_pMainFrame->Destroy();
|
2008-07-17 15:05:25 +00:00
|
|
|
|
return;
|
2008-11-18 15:03:42 +00:00
|
|
|
|
}
|
2008-07-08 10:51:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-01-20 11:16:02 +00:00
|
|
|
|
if (SystemRunning("ba0", "Uscire dal programma PRODUCT prima di procedere con l'aggiornamento/installazione!") ||
|
|
|
|
|
SystemRunning("ba1", "Uscire dal programma di manutenzione di PRODUCT\n prima di procedere con l'aggiornamento/installazione!"))
|
2007-09-26 12:59:37 +00:00
|
|
|
|
{
|
|
|
|
|
m_pMainFrame->Destroy();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-22 13:58:30 +00:00
|
|
|
|
if (CampoIsRunning())
|
2008-11-18 15:03:42 +00:00
|
|
|
|
{
|
2009-01-20 11:16:02 +00:00
|
|
|
|
wxString msg;
|
|
|
|
|
msg << "Un applicativo di " << PRODUCT << " <20> ancora in esecuzione!\n"
|
|
|
|
|
<< "L'installazione sar<61> interrotta immediatamente";
|
|
|
|
|
ErrorBox(msg);
|
2008-11-18 15:03:42 +00:00
|
|
|
|
m_pMainFrame->Destroy();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2007-09-26 12:59:37 +00:00
|
|
|
|
//path del programma setup.exe in esecuzione; serve in seguito in quanto alcuni metodi (tipo la GetAllFiles)..
|
|
|
|
|
//..fanno perdere questo path
|
2008-12-10 16:59:04 +00:00
|
|
|
|
//attenzione!!! il path DEVE terminare con "\" senn<6E> in base al tipo di chiamata (-uw,-uc,-ud) i rispettivi..
|
|
|
|
|
//..metodi funzionano a casaccio!!!
|
2009-02-04 16:28:37 +00:00
|
|
|
|
const wxString strCommand = argv[1];
|
2007-09-26 12:59:37 +00:00
|
|
|
|
|
|
|
|
|
if (strCommand.IsEmpty())
|
2009-02-04 16:28:37 +00:00
|
|
|
|
{
|
2012-07-02 13:07:32 +00:00
|
|
|
|
TCHAR strFileName[260];
|
|
|
|
|
::GetModuleFileName(NULL, strFileName, 260);
|
2015-06-17 07:15:42 +00:00
|
|
|
|
|
2012-07-02 13:07:32 +00:00
|
|
|
|
wxFileName strPath(strFileName);
|
2009-02-04 16:28:37 +00:00
|
|
|
|
strPath.MakeAbsolute();
|
|
|
|
|
m_strSetupPath = strPath.GetPath();
|
|
|
|
|
if (!m_strSetupPath.EndsWith(wxT("\\")))
|
|
|
|
|
m_strSetupPath << '\\';
|
|
|
|
|
|
2012-07-02 13:07:32 +00:00
|
|
|
|
wxSetWorkingDirectory(m_strSetupPath);
|
|
|
|
|
|
2009-02-04 16:28:37 +00:00
|
|
|
|
//installazione normale da CD
|
2007-09-26 12:59:37 +00:00
|
|
|
|
NormalSetup();
|
2009-02-04 16:28:37 +00:00
|
|
|
|
}
|
2007-09-26 12:59:37 +00:00
|
|
|
|
else
|
2007-11-21 10:37:43 +00:00
|
|
|
|
{
|
2009-02-04 16:28:37 +00:00
|
|
|
|
//attenzione: modifica richiesta perch<63> la cartella di esecuzione di setup <20> diversa nel caso sia un..
|
|
|
|
|
//..aggiornamento o una installazione da CD
|
|
|
|
|
m_strSetupPath = wxGetCwd();
|
|
|
|
|
m_strSetupPath.MakeLower();
|
|
|
|
|
if (!m_strSetupPath.EndsWith("setup"))
|
|
|
|
|
{
|
2009-06-18 15:35:44 +00:00
|
|
|
|
if (!m_strSetupPath.EndsWith(wxT("\\")))
|
|
|
|
|
m_strSetupPath << '\\';
|
|
|
|
|
m_strSetupPath << "setup";
|
2009-02-04 16:28:37 +00:00
|
|
|
|
wxSetWorkingDirectory(m_strSetupPath);
|
|
|
|
|
}
|
|
|
|
|
if (!m_strSetupPath.EndsWith(wxT("\\")))
|
|
|
|
|
m_strSetupPath << '\\';
|
|
|
|
|
|
|
|
|
|
//aggiornamento da disco,client,web
|
2007-11-21 10:37:43 +00:00
|
|
|
|
if (strCommand == "-ud")
|
2012-04-10 07:50:04 +00:00
|
|
|
|
DiskUpdate(); else
|
2007-11-21 10:37:43 +00:00
|
|
|
|
if (strCommand == "-uc")
|
2012-04-10 07:50:04 +00:00
|
|
|
|
ClientUpdate(); else
|
2007-11-21 10:37:43 +00:00
|
|
|
|
if (strCommand == "-uw")
|
|
|
|
|
InternetUpdate();
|
|
|
|
|
}
|
2014-09-22 13:58:30 +00:00
|
|
|
|
// finestrina x chiudere a mano il programma (sconsigliata causa lancio ba1.exe)
|
|
|
|
|
// ::wxMessageBox(wxT("Installazione terminata"), APPNAME, wxOK | wxICON_INFORMATION);
|
2007-09-26 12:59:37 +00:00
|
|
|
|
m_pMainFrame->Destroy();
|
2007-07-23 15:01:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-09-26 12:59:37 +00:00
|
|
|
|
|
2007-08-08 09:24:19 +00:00
|
|
|
|
bool CampoSetup::OnInit()
|
2007-07-23 15:01:38 +00:00
|
|
|
|
{
|
|
|
|
|
wxInitAllImageHandlers();
|
|
|
|
|
m_locale.Init();
|
|
|
|
|
|
2008-09-09 10:47:13 +00:00
|
|
|
|
m_pWizard = NULL; //finestra di programma nulla;deve esistere solo per il NormalSetup dove viene inizializzata
|
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;
|
|
|
|
|
}
|