Patch level :nopatch
Files correlati : Ricompilazione Demo : [ ] Commento :programma aggiornamento programmatori esterni git-svn-id: svn://10.65.10.50/trunk@16860 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
39d707513b
commit
d56e6cbb81
BIN
setup/Transfer.ico
Executable file
BIN
setup/Transfer.ico
Executable file
Binary file not shown.
After Width: | Height: | Size: 9.4 KiB |
214
setup/update.cpp
Executable file
214
setup/update.cpp
Executable file
@ -0,0 +1,214 @@
|
||||
//Il sorgente va scritto in notazione ungherese.
|
||||
//Le variabili seguono la seguente regola: 'acronimo tipo'+'nome variabile cammellata'
|
||||
//Es. wxArrayString 'as' + 'AcceptRefuse' -> asAcceptRefuse
|
||||
#include "wxinc.h"
|
||||
#include "utils.h"
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// UpdateFrame
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class UpdateFrame : public wxFrame
|
||||
{
|
||||
protected:
|
||||
DECLARE_EVENT_TABLE();
|
||||
virtual void OnErase(wxEraseEvent& e);
|
||||
public:
|
||||
UpdateFrame();
|
||||
};
|
||||
|
||||
BEGIN_EVENT_TABLE(UpdateFrame, wxFrame)
|
||||
EVT_ERASE_BACKGROUND(UpdateFrame::OnErase)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
void UpdateFrame::OnErase(wxEraseEvent& e)
|
||||
{
|
||||
//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()/10;
|
||||
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("Update");
|
||||
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);
|
||||
}
|
||||
|
||||
UpdateFrame::UpdateFrame()
|
||||
: wxFrame(NULL, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0)
|
||||
{
|
||||
ShowFullScreen(true);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// UpdateExternal
|
||||
///////////////////////////////////////////////////////////
|
||||
//classe principale, ovvero applicazione
|
||||
class UpdateExternal : public wxApp
|
||||
{
|
||||
UpdateFrame* m_pMainFrame;
|
||||
wxLocale m_locale;
|
||||
wxString m_strSetupPath;
|
||||
|
||||
protected:
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
//metodi principali dell'applicazione
|
||||
void OnTimer(wxTimerEvent& e);
|
||||
|
||||
//metodi di utility per i vari modi di aggiornamento
|
||||
void CopyDir(const wxString& strSourcePath, const wxString& strDestPath, const wxString strModule) const;
|
||||
bool CheckAndCopyFile(const wxString& FilesListI, wxString strFileCurr) const;
|
||||
|
||||
public:
|
||||
virtual bool OnInit();
|
||||
};
|
||||
|
||||
IMPLEMENT_APP(UpdateExternal)
|
||||
|
||||
BEGIN_EVENT_TABLE(UpdateExternal, wxApp)
|
||||
EVT_TIMER(883, OnTimer)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// Metodi di utility per i vari tipi di aggiornamento
|
||||
//----------------------------------------------------------------
|
||||
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();
|
||||
if (strName1 == "syinst1")
|
||||
return -1;
|
||||
if (strName2 == "syinst1")
|
||||
return 1;
|
||||
|
||||
return strName1.CompareTo(strName2);
|
||||
}
|
||||
|
||||
|
||||
bool UpdateExternal::CheckAndCopyFile(const wxString& FilesListI, wxString strFileCurr) const
|
||||
{
|
||||
bool ok = true;
|
||||
strFileCurr.MakeLower(); //minuscolizzazione di sicurezza
|
||||
const wxFileName strFileName(strFileCurr);
|
||||
|
||||
//NON copiare i sorgenti cocco!!
|
||||
const wxString strExt = strFileName.GetExt();
|
||||
if (strExt != "cpp" && strExt != "c" && strExt != "src" && strFileCurr.Find("\\cvs\\") < 0 )
|
||||
{
|
||||
//eventuali sottodirectory le crea (solo se hanno un nome)
|
||||
const wxString strDir = strFileName.GetPath();
|
||||
if (!strDir.IsEmpty() && !wxDirExists(strDir))
|
||||
{
|
||||
for (size_t d = 0; d < strFileName.GetDirCount(); d++)
|
||||
{
|
||||
wxString strCartellina = strFileName.GetVolume() + ":";
|
||||
for (size_t e = 0; e <= d; e++)
|
||||
{
|
||||
strCartellina << "\\" << strFileName.GetDirs()[e];
|
||||
}
|
||||
if (!wxDirExists(strCartellina))
|
||||
wxMkdir(strCartellina);
|
||||
}
|
||||
}
|
||||
|
||||
//solo i files piu' nuovi vanno copiati
|
||||
bool bCopia = !::wxFileName::FileExists(strFileCurr);
|
||||
if (!bCopia)
|
||||
{
|
||||
time_t t_local = ::wxFileModificationTime(FilesListI);
|
||||
time_t t_remote = ::wxFileModificationTime(strFileCurr);
|
||||
bCopia = t_local > t_remote;
|
||||
}
|
||||
if (bCopia)
|
||||
ok = CopiaFile(FilesListI, strFileCurr);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
//metodo per copiare una directory e tutti i files che contiene
|
||||
void UpdateExternal::CopyDir(const wxString& strSrc, const wxString& strDest, const wxString strModule) const
|
||||
{
|
||||
wxArrayString asList;
|
||||
const size_t uFilesToCopy = wxDir::GetAllFiles(strSrc + strModule, &asList);
|
||||
wxString strFileCurr;
|
||||
const size_t nPathLenght = strSrc.Len();
|
||||
CampoProgressDialog pi("Copia files...", (int)uFilesToCopy);
|
||||
for (size_t i = 0; i < uFilesToCopy; i++)
|
||||
{
|
||||
if (!pi.Update((int)i, asList[i]))
|
||||
break;
|
||||
|
||||
asList[i].Lower();
|
||||
strFileCurr = strDest;
|
||||
strFileCurr += asList[i].Mid(nPathLenght);
|
||||
|
||||
if (!strFileCurr.IsEmpty())
|
||||
{
|
||||
if (!CheckAndCopyFile(asList[i], strFileCurr))
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//metodo principale che sceglie la modalita' di lancio del programma
|
||||
void UpdateExternal::OnTimer(wxTimerEvent& WXUNUSED(e))
|
||||
{
|
||||
//copia dei files sulla dir di destinazione
|
||||
const wxString strDestPath = "Z:\\";
|
||||
const wxString strSrcPath = "C:\\U\\Luca\\R_10_00\\";
|
||||
|
||||
CopyDir(strSrcPath, strDestPath, "include");
|
||||
CopyDir(strSrcPath, strDestPath, "lib");
|
||||
CopyDir(strSrcPath, strDestPath, "ba");
|
||||
CopyDir(strSrcPath, strDestPath, "cg");
|
||||
CopyDir(strSrcPath, strDestPath, "ve");
|
||||
|
||||
m_pMainFrame->Destroy();
|
||||
}
|
||||
|
||||
|
||||
bool UpdateExternal::OnInit()
|
||||
{
|
||||
wxInitAllImageHandlers();
|
||||
m_locale.Init();
|
||||
|
||||
m_pMainFrame = new UpdateFrame;
|
||||
SetTopWindow(m_pMainFrame);
|
||||
|
||||
wxTimerEvent e(883);
|
||||
AddPendingEvent(e);
|
||||
|
||||
return true;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user