diff --git a/ba/ba1700.cpp b/ba/ba1700.cpp index 0cdd7b610..7938f2b26 100755 --- a/ba/ba1700.cpp +++ b/ba/ba1700.cpp @@ -122,10 +122,10 @@ protected: // TSheet virtual bool on_key(KEY key); static bool tutti_handler(TMask_field& f, KEY k); int get_module_number(const TString& module) const; - bool has_module(int modnumber) const; + bool should_precheck_module(int modnumber) const; bool is_zip_file(const TFilename& n) const; - void create_dirs(const char* path) const; + bool copy_file(const TFilename& src, const TFilename& dst) const; bool copy_tree(const char* src_study, const char* dst_study) const; int test_station_type() const; @@ -262,14 +262,35 @@ bool TInstaller_mask::add_header(TConfig& ini, const TString& module) return ok; } -bool TInstaller_mask::has_module(int modnumber) const +bool TInstaller_mask::should_precheck_module(int modnumber) const { - //se sei un server hai tutti i moduli da installare - if (station_type() == 2) - return dongle().shown(modnumber); + bool ok = modnumber == 0; + + if (!ok) + { + const TDongle& d = dongle(); + if (station_type() == 2) + { + //se sei un server hai tutti i moduli da installare + ok = d.shown(modnumber); + } + else + { + //senno' sei sfigato e ti installa solo i moduli sulla chiave + ok = d.active(modnumber); + if (!ok) // Se non hai un modulo ... potresti avere un suo modulo sottinteso + { + switch (modnumber) + { + case CAAUT: ok = d.active(CMAUT); break; // Se non hai l'analitica ritenta con le commesse + case TPAUT: ok = d.active(DCAUT); break; // Se non hai Pack ritenta con il CONAI + default: break; + } + } + } + } - //senno' sei sfigato e ti installa solo i moduli sulla chiave - return main_app().has_module(modnumber, CHK_DONGLE); + return ok; } //che tipo di installazione e'? @@ -316,7 +337,7 @@ int TInstaller_mask::precheck_modules(bool only_newer) currrelease = rigar.get(C_CURRRELEASE); currpatch = rigar.get_int(C_CURRPATCH); modnumber = get_module_number(cod_module); - if (modnumber >= 0 && has_module(modnumber) && + if (modnumber >= 0 && should_precheck_module(modnumber) && release.full() && ((release > currrelease) || (release == currrelease && (only_newer ? patchlevel > currpatch : patchlevel >= currpatch) )) @@ -721,31 +742,17 @@ bool TInstaller_mask::is_zip_file(const TFilename& n) const { bool yes = xvt_str_compare_ignoring_case(n.ext(), "zip") == 0 && xvt_str_compare_ignoring_case(n.name_only(), "dninst") != 0; -return yes; + return yes; } -void TInstaller_mask::create_dirs(const char* path) const +bool TInstaller_mask::copy_file(const TFilename& src, const TFilename& dst) const { - /* - TToken_string dirs(path, SLASH); - if (SLASH == '\\') - dirs.replace('/', SLASH); + bool ok = xvt_fsys_mkdir(dst.path()) != FALSE; + if (ok) + ok = ::fcopy(src, dst); else - dirs.replace('\\', SLASH); - - // file contains non existent subdir specification ? - TFilename subdir; - for (int c=0; c < dirs.items()-1; c++) - { - subdir.add(dirs.get(c)); - if (subdir.right(1) == ":" ) - subdir << SLASH; - if (!subdir.exist() ) - // build destination directory - make_dir(subdir); - } - */ - xvt_fsys_mkdir(path); // La nuova versione crea l'albero autonomamente + error_box(FR("Impossibile creare la cartella %s"), dst.path()); + return ok; } // sposta il file dal direttorio temporaneo a quello passato come destinazione @@ -759,16 +766,13 @@ bool TInstaller_mask::move_file(const TFilename& src, const TFilename& dst) cons dest << '_'; } - if (!dest.exist()) - create_dirs(dest.path()); - const bool is_zip = is_zip_file(src); const long filesize = fsize(src) * (is_zip ? 4 : 1); if (xvt_fsys_test_disk_free_space(dest.path(), filesize) == 0) return error_box(TR("Lo spazio disponibile e' insufficiente!")); - const bool write_ok = ::fcopy(src, dest); + const bool write_ok = copy_file(src, dest); if (write_ok && is_zip) aga_unzip(src, dest.path()); @@ -861,8 +865,7 @@ bool TInstaller_mask::copy_tree(const char* src_study, const char* dst_study) co dst = dst_study; dst.add(name); dst.add(src.name()); - create_dirs(dst); - fcopy(src, dst); + copy_file(src, dst); } } } @@ -1251,15 +1254,12 @@ bool TInstaller_mask::install(const TString& module, int patchlevel) src = path; src.add(dst); const int reboot = needs_reboot(dst); - if ((reboot & NEW_SYS) !=0 && dst.exist()) + if ((reboot & NEW_SYS)!=0 && dst.exist()) { dst.rtrim(1); dst << '_'; } - if (!dst.exist()) - create_dirs(dst.path()); - - ok = ::fcopy(src, dst); + ok = copy_file(src, dst); if (ok && is_zip_file(src)) aga_unzip(src, dst.path());