From 66a85ef23087a76111a577fe0fbe237b6375989d Mon Sep 17 00:00:00 2001 From: guy Date: Mon, 26 May 2003 13:00:26 +0000 Subject: [PATCH] Patch level : 2.0 476 Files correlati : ba0.exe ba1.exe ba0200a.msk Ricompilazione Demo : [ ] Commento : ba0, ba0200a.msk: aggiunta la possibilita' di escludere le immagini di sfondo per velocizzare navigazione menu su macchhine lente o in teleassistenza ba1, ba0close: aggiunto il supporto per l'aggiornamento delle DLL git-svn-id: svn://10.65.10.50/trunk@11186 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- ba/ba0100.cpp | 23 ++++++--- ba/ba0101.cpp | 7 +++ ba/ba0101.h | 5 +- ba/ba0102.cpp | 5 +- ba/ba0200a.uml | 9 +++- ba/ba0close.cpp | 125 ++++++++++++++++---------------------------- ba/ba1100.cpp | 2 +- ba/ba1200.cpp | 2 + ba/ba1300.cpp | 2 +- ba/ba1700.cpp | 135 +++++++++++++++++++++++++++++------------------- 10 files changed, 164 insertions(+), 151 deletions(-) diff --git a/ba/ba0100.cpp b/ba/ba0100.cpp index a10c4fb56..1662d7def 100755 --- a/ba/ba0100.cpp +++ b/ba/ba0100.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -136,6 +137,9 @@ bool TPicture_mask::stop_run(KEY key) void TPicture_mask::update() { + if (!ADVANCED_GRAPHICS) + return; + TImage& image = _submenu->image(); if (image.ok()) { @@ -341,8 +345,9 @@ TColor_mask::TColor_mask() { TConfig color(CONFIG_USER, "Colors"); _color = color.list_variables(); - set(213, color.get_bool("Campi3D") ? "X" : ""); - set(215, color.get_bool("SmallIcons") ? "X" : ""); + set(213, CAMPI_SCAVATI ? "X" : ""); + set(215, ADVANCED_GRAPHICS ? "X" : ""); + set(216, SMALL_ICONS ? "X" : ""); } PNT TColor_mask::log2dev(long x, long y) const @@ -430,7 +435,8 @@ void TColor_mask::save_colors() FOR_EACH_ASSOC_STRING(_color, obj, key, str) colors.set(key, str); colors.set("Campi3D", get_bool(213) ? "X" : ""); - colors.set("SmallIcons", get_bool(215) ? "X" : ""); + colors.set("AdvancedGraphics", get_bool(215) ? "X" : ""); + colors.set("SmallIcons", get_bool(216) ? "X" : ""); } COLOR TColor_mask::get_color_entry(const char* name) const @@ -942,12 +948,13 @@ bool TMenu_application::destroy() users.rewrite(); } - // ba0 / 1 substitute: serve per installare anche i file menu ed installatore che erano in esecuzione - TFilename ba0exfile("ba0.ex_"),ba1exfile("ba1.ex_"); - if (ba0exfile.exist()||ba1exfile.exist()) + TString_array list; + list_files("*.ex_", list); + list_files("*.dl_", list); + if (list.items() > 0) { - TExternal_app ba0epilogue("ba0close.exe"); - ba0epilogue.run(TRUE,TRUE,TRUE); // run asynchronous... + TExternal_app ba0close("ba0close.exe"); + ba0close.run(TRUE,TRUE,TRUE); // run asynchronous... } return TRUE; } diff --git a/ba/ba0101.cpp b/ba/ba0101.cpp index 0dcfc82be..f855dbf98 100755 --- a/ba/ba0101.cpp +++ b/ba/ba0101.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -442,6 +443,7 @@ bool TMenu::read(const char* name, TString& root) // Menu /////////////////////////////////////////////////////////// + bool TMenu::read(const char* name) { TString root; @@ -672,3 +674,8 @@ bool TMenu::is_dangerous(const char* mod) return _dangerous.get_pos(code) >= 0; } +TMenu::TMenu() : _current(NULL), _item(0) +{ } + +TMenu::~TMenu() +{ } diff --git a/ba/ba0101.h b/ba/ba0101.h index 8111247ec..a4da0a308 100755 --- a/ba/ba0101.h +++ b/ba/ba0101.h @@ -157,9 +157,8 @@ public: void set_dangerous_modules(const TToken_string& mod) { _dangerous = mod; } - TMenu() : _current(NULL), _item(0) { } - TMenu(const char* name) { read(name); } - virtual ~TMenu() { } + TMenu(); + virtual ~TMenu(); }; diff --git a/ba/ba0102.cpp b/ba/ba0102.cpp index ec87b7b16..fdb973752 100755 --- a/ba/ba0102.cpp +++ b/ba/ba0102.cpp @@ -499,8 +499,9 @@ void TMenulist_window::draw_item(int i) } void TMenulist_window::update() -{ - TImage* img = _images.image(_image_name); // Delay time before clearing +{ + const bool db = _tree != NULL && ADVANCED_GRAPHICS; + TImage* img = db ? _images.image(_image_name) : NULL; // Delay time before clearing TField_window::update(); if (_tree == NULL) diff --git a/ba/ba0200a.uml b/ba/ba0200a.uml index d6b530527..32c6f7078 100755 --- a/ba/ba0200a.uml +++ b/ba/ba0200a.uml @@ -93,12 +93,17 @@ END BOOLEAN 213 BEGIN - PROMPT 38 13 "Campi 3D" + PROMPT 36 13 "Campi 3D" END BOOLEAN 215 BEGIN - PROMPT 38 14 "Icone piccole" + PROMPT 36 14 "Grafica avanzata" +END + +BOOLEAN 216 +BEGIN + PROMPT 36 15 "Icone piccole" END BUTTON 214 12 2 diff --git a/ba/ba0close.cpp b/ba/ba0close.cpp index 32090d8fb..8c3faf59b 100755 --- a/ba/ba0close.cpp +++ b/ba/ba0close.cpp @@ -1,87 +1,52 @@ -#include -#include -#include -#include -#include #include -typedef unsigned char bool ; -#define FALSE 0 -#define TRUE 1 +#include -int main(int argc, char** argv); -bool fcopy(const char* orig, const char* dest); -bool fexist(const char* file); -int update_file(const char *from, const char * to); - -bool fexist( - const char* file) // @parm Nome del file di cui contrallarne l'esistenza -{ - int err = access(file, 0); - return err == 0; -} - -bool fcopy( - const char* orig, // @parm Nome del file di origine - const char* dest) // @parm Nome del file di destinazione - // file

in coda al file

(default FALSE) - - // @comm Nel caso vengano ravvisati degli errori durante l'operazione vengono - // creati dei box di comunicazione che indicano la causa del problema -{ - - // Copia il file su se stesso? - if (stricmp(orig, dest) == 0) - return TRUE; // Or FALSE? - - FILE* i = fopen(orig, "rb"); - if (!i) return fprintf(stderr,"Impossibile leggere il file %s", orig); - - FILE* o = fopen(dest, "wb"); - if (!o) - { - fclose(i); - return fprintf(stderr,"Impossibile scrivere il file ", dest); - } - - const word size = 16*1024; - unsigned char * buffer=new unsigned char[size]; - - bool ok = TRUE; - while (ok) - { - const word letti = fread(buffer, 1, size, i); - ok = fwrite(buffer, 1, letti, o) == letti; - if (letti < size) break; - } - - if (!ok) fprintf(stderr,"Errore di scrittura: probabile disco pieno!"); - - fclose(o); - fclose(i); - delete buffer; - return ok; -} - -int update_file(const char *from, const char * to) -{ - int r=0; - - if (fexist(from)) - { - if (fcopy(from,to)) - r=remove(from); - } - return r; -} - -int PASCAL WinMain(HINSTANCE _this, HINSTANCE _prev , LPSTR _cmd,int _mode) +int PASCAL WinMain(HINSTANCE, HINSTANCE , LPSTR, int) { - int r=0; - char ba1exe[]="ba1.exe",ba1ex[]="ba1.ex_"; - char ba0exe[]="ba0.exe",ba0ex[]="ba0.ex_"; + ::Sleep(1000); // Apetta un secondo che termini ba0.exe + + WIN32_FIND_DATA data; + HANDLE hHandle = ::FindFirstFile("*.??_", &data); + BOOL bRunning = hHandle != INVALID_HANDLE_VALUE; + while (bRunning) + { + const char* newext = NULL; + const char* oldpath = data.cFileName; + + char drive[_MAX_DRIVE], path[_MAX_PATH], fname[_MAX_FNAME], ext[_MAX_EXT]; + _splitpath(oldpath, drive, path, fname, ext); + + if (stricmp(ext, ".ex_") == 0) + newext = ".exe"; else + if (stricmp(ext, ".dl_") == 0) + newext = ".dll"; + + if (newext != NULL) + { + char newpath[_MAX_PATH]; + _makepath(newpath, drive, path, fname, newext); + if (::CopyFile(oldpath, newpath, FALSE)) + { + ::DeleteFile(oldpath); + } + else + { + char msg[512]; + LPVOID lpMsgBuf; + FormatMessage( + FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language + (LPTSTR) &lpMsgBuf, 0, NULL); + sprintf(msg, "Impossibile ridenominare il file %s in %s:\n%s", + oldpath, newpath, lpMsgBuf); + ::LocalFree(lpMsgBuf); + ::MessageBox(NULL, msg, "Errore", MB_ICONERROR | MB_OK); + } + } + + bRunning = ::FindNextFile(hHandle, &data); + } - update_file(ba1ex,ba1exe); - update_file(ba0ex,ba0exe); return 0; } diff --git a/ba/ba1100.cpp b/ba/ba1100.cpp index ebca84de9..c772e936a 100755 --- a/ba/ba1100.cpp +++ b/ba/ba1100.cpp @@ -1,5 +1,5 @@ -#include #include +#include #include #include #include diff --git a/ba/ba1200.cpp b/ba/ba1200.cpp index c02d4d3f7..135af2771 100755 --- a/ba/ba1200.cpp +++ b/ba/ba1200.cpp @@ -1,3 +1,5 @@ +#include + #include #include #include diff --git a/ba/ba1300.cpp b/ba/ba1300.cpp index c1946df86..a773f5fa6 100755 --- a/ba/ba1300.cpp +++ b/ba/ba1300.cpp @@ -136,7 +136,7 @@ void TPackFiles_application::main_loop() f_name = d.name(); f_name.ext("dbf"); retry = FALSE; - present = access(f_name,0) == 0; + present = f_name.exist(); do { status = NOERR; diff --git a/ba/ba1700.cpp b/ba/ba1700.cpp index 62a8ea527..f9d20e62f 100755 --- a/ba/ba1700.cpp +++ b/ba/ba1700.cpp @@ -1,3 +1,5 @@ +#include + #include #include #include @@ -80,7 +82,10 @@ class TInstaller_mask : public TArray_sheet { static TInstaller_mask* _curr_mask; bool _installed; // Flag per verificare se almeno un modulo e' stato installato - enum {NONE, NEW_MENU, NEW_MENUPRG, NEW_INSTALLER} _reboot_program; + + enum { NONE = 0, NEW_MENU = 1, NEW_MENUPRG = 2, NEW_INSTALLER = 4, NEW_DLL = 8 }; + int _reboot_program; + protected: // TSheet virtual bool on_key(KEY key); static bool quit_handler(TMask_field& f, KEY k); @@ -98,7 +103,8 @@ protected: int precheck_modules(bool only_newer=TRUE); void update_version(); - bool move_file(const TFilename& fromdir, const TFilename& file, const char* dir) const; + int needs_underscore(const TFilename& file) const; + bool move_file(const TFilename& file, const char* dir) const; bool move_module(const TString& module, TInstall_ini& ini, bool update) const; bool can_install(const char* module, TInstall_ini& ini); @@ -526,24 +532,47 @@ bool TInstaller_mask::can_install(const char* module, TInstall_ini& ini) return ok; } +int TInstaller_mask::needs_underscore(const TFilename& file) const +{ + char fname[_MAX_FNAME], ext[_MAX_EXT]; + xvt_fsys_parse_pathname(file, NULL, NULL, fname, ext, NULL); + + int underscore = NONE; + if (xvt_str_compare_ignoring_case(ext, ".exe") == 0) + { + if (xvt_str_compare_ignoring_case(fname, "ba0") == 0) + underscore = NEW_MENUPRG; else + if (xvt_str_compare_ignoring_case(fname, "ba1") == 0) + underscore = NEW_INSTALLER; + } + else + { + if (xvt_str_compare_ignoring_case(ext, ".dll") == 0) + underscore = NEW_DLL; + } + return underscore; +} + + // sposta il file dal direttorio temporaneo a quello passato come destinazione // from: direttorio di partenza // file: nome del file con path completo da spostare (può includere sottodirettori) // todir: direttorio destinazione (si assume che esista già) -bool TInstaller_mask::move_file(const TFilename& from, const TFilename& file, const char* todir) const +bool TInstaller_mask::move_file(const TFilename& file, const char* todir) const { - TFilename dest(todir); - const char *fname=file.mid(from.len()+1); - if (stricmp(fname,"ba0.exe")==0) - dest.add("BA0.EX_"); - else if (stricmp(fname,"ba1.exe")==0) - dest.add("BA1.EX_"); - else - dest.add(fname); + char fname[_MAX_FNAME], ext[_MAX_EXT]; + xvt_fsys_parse_pathname(file, NULL, NULL, fname, ext, NULL); + const int underscore = needs_underscore(file); + if (underscore) + ext[2] = '_'; + + TFilename dest(todir); + dest.add(fname); + dest.ext(ext); if (!dest.exist()) { - TToken_string dirs((const char * )(dest.path()),'\\'); + TToken_string dirs(dest.path(), SLASH); // file contains non existent subdir specification ? TFilename subdir; for (int c=0; c < dirs.items()-1; c++) @@ -566,7 +595,7 @@ bool TInstaller_mask::move_file(const TFilename& from, const TFilename& file, co if (!space_ok) { TString msg; - msg << TR("Lo spazio sull'unita' e' insufficiente"); + msg << TR("Lo spazio sull'unita' di destinazione e' insufficiente"); if (xvt_fsys_is_removable_drive(dest)) { msg << TR(":\nInserire un nuovo disco e ritentare?"); @@ -590,9 +619,13 @@ bool TInstaller_mask::move_file(const TFilename& from, const TFilename& file, co (const char*)file); } while (!write_ok && user_retry); - if (write_ok && strcmp(dest.ext(),"men")==0) - ((TInstaller_mask *)this)->_reboot_program=NEW_MENU; - + if (write_ok) + { + int rp = underscore; + if (rp == NONE && xvt_str_compare_ignoring_case(ext, ".men")==0) + rp = NEW_MENU; + (int&)_reboot_program |= rp; // Skip const! + } return write_ok; } @@ -612,7 +645,7 @@ bool TInstaller_mask::move_module(const TString& module, TInstall_ini& ini, bool src.add(file->get(0)); if (update) { - const bool move_ok = move_file(tempdir, src, dst); + const bool move_ok = move_file(src, dst); if (!move_ok) ok = update = FALSE; } @@ -891,9 +924,7 @@ bool TInstaller_mask::install(const TString& module, int patchlevel) if (ok) { - msg.cut(0); - msg << TR("Copia del modulo '"); - msg << module << TR("' in corso ..."); + msg.cut(0) << TR("Copia del modulo ") << module; TProgind pi(files, msg, TRUE, TRUE); TFilename src, dst; for (int f = 0; f < files && ok; f++) @@ -903,11 +934,17 @@ bool TInstaller_mask::install(const TString& module, int patchlevel) dst.lower(); src = path; src.add(dst); - if (dst=="ba1.exe") - dst="ba1.ex_"; - if (dst=="ba0.exe") - dst="ba0.ex_"; + const int underscore = needs_underscore(dst); + if (underscore) + { + dst.rtrim(1); + dst << '_'; + } ok = fcopy(src, dst); + + if (ok && underscore != NONE) + _reboot_program |= underscore; + cancelled = pi.iscancelled(); } ok &= !cancelled; @@ -1223,36 +1260,23 @@ TInstaller_mask::TInstaller_mask() TInstaller_mask::~TInstaller_mask() { _curr_mask = NULL; - TString msg; - TFilename ba0exfile("ba0.ex_"),ba1exfile("ba1.ex_"); + if (_reboot_program != NONE) + { + TString msg; + msg << TR("Sono stati aggiornati i seguenti elementi:") < '\n'; + + if (_reboot_program & NEW_MENU) + msg << TR("voci di menu;"); + if (_reboot_program & NEW_MENUPRG) + msg << TR("navigatore dei menu;"); + if (_reboot_program & NEW_INSTALLER) + msg << TR("installatore"); + if (_reboot_program & NEW_DLL) + msg << TR("librerie di base;"); - switch (_reboot_program) - { - case NEW_MENU: - msg << TR("sono stati aggiornati i menu"); - default: - if (ba0exfile.exist()) - { - if (!msg.blank()) - msg << TR(" e "); - else - msg << TR("e' stato "); - msg << TR("aggiornato il navigatore dei menu"); - } - if (ba1exfile.exist()) - { - if (!msg.blank()) - msg << TR(" e "); - else - msg << TR("e' stato "); - msg << TR("aggiornato l'installatore"); - } - } - if (!msg.empty()) - { - msg.insert(TR("Attenzione:")); - msg << TR(".\nE' necessario uscire e rientrare dal programma"); + msg.rtrim(1); + msg << '\n' << TR("E' necessario uscire e rientrare dal programma."); warning_box(msg); } } @@ -1367,14 +1391,17 @@ void TExtendedInstaller::main_loop() _m = NULL; } -#define PROGNAME "Installer" int ba1700(int argc, char* argv[]) { + const char* const PROGNAME = "Installazione moduli"; + if (user() != ::dongle().administrator()) { TInstaller app; app.run(argc, argv, PROGNAME); - } else { + } + else + { TExtendedInstaller app; app.run(argc, argv, PROGNAME); }