1997-10-30 15:13:59 +00:00
|
|
|
|
#include <dos.h>
|
|
|
|
|
|
1997-12-04 14:07:49 +00:00
|
|
|
|
#define XVT_INCL_NATIVE
|
1997-10-30 15:13:59 +00:00
|
|
|
|
#include <applicat.h>
|
|
|
|
|
#include <colors.h>
|
|
|
|
|
#include <execp.h>
|
|
|
|
|
#include <progind.h>
|
1997-12-04 14:07:49 +00:00
|
|
|
|
#include <sheet.h>
|
1997-10-30 15:13:59 +00:00
|
|
|
|
#include <utility.h>
|
|
|
|
|
|
|
|
|
|
#include "ba1.h"
|
1997-12-15 15:11:40 +00:00
|
|
|
|
#include "ba1500.h"
|
1997-10-30 15:13:59 +00:00
|
|
|
|
#include "ba1600.h"
|
|
|
|
|
#include "ba1700a.h"
|
|
|
|
|
|
1997-12-15 15:11:40 +00:00
|
|
|
|
HIDDEN int compare_version(const char* v1, const char* v2)
|
1997-10-30 15:13:59 +00:00
|
|
|
|
{
|
|
|
|
|
TString16 ver1(v1), ver2(v2);
|
|
|
|
|
ver1.trim();
|
|
|
|
|
if (ver1.len() == 4)
|
|
|
|
|
ver1.insert((v1[0] == '9') ? "19" : "20", 0);
|
|
|
|
|
ver2.trim();
|
|
|
|
|
if (ver2.len() == 4)
|
|
|
|
|
ver2.insert((v2[0] == '9') ? "19" : "20", 0);
|
|
|
|
|
return ver1.compare(ver2, -1, TRUE);
|
|
|
|
|
}
|
|
|
|
|
|
1997-12-15 15:11:40 +00:00
|
|
|
|
HIDDEN word version2year(const char* v)
|
|
|
|
|
{
|
|
|
|
|
TString16 ver(v);
|
|
|
|
|
if (ver.len() == 4)
|
|
|
|
|
ver.insert((v[0] == '9') ? "19" : "20", 0);
|
|
|
|
|
ver.cut(4);
|
|
|
|
|
return atoi(ver);
|
|
|
|
|
}
|
|
|
|
|
|
1997-10-30 15:13:59 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Maschera principale
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
1997-12-04 14:07:49 +00:00
|
|
|
|
class TInstaller_mask : public TArray_sheet
|
1997-10-30 15:13:59 +00:00
|
|
|
|
{
|
1997-12-04 14:07:49 +00:00
|
|
|
|
static TInstaller_mask* _curr_mask;
|
1997-12-17 13:40:59 +00:00
|
|
|
|
word _year_assist;
|
1997-12-04 14:07:49 +00:00
|
|
|
|
|
|
|
|
|
protected: // TSheet
|
1997-12-15 15:11:40 +00:00
|
|
|
|
virtual bool on_key(KEY key);
|
1997-12-04 14:07:49 +00:00
|
|
|
|
|
1997-10-30 15:13:59 +00:00
|
|
|
|
protected:
|
|
|
|
|
static bool path_handler(TMask_field& fld, KEY key);
|
|
|
|
|
static bool sheet_notify(TSheet_field& s, int r, KEY k);
|
|
|
|
|
static bool install_handler(TMask_field& fld, KEY key);
|
|
|
|
|
|
1997-12-04 14:07:49 +00:00
|
|
|
|
bool add_module(TConfig& ini, const TString& module);
|
1997-10-30 15:13:59 +00:00
|
|
|
|
void update_version();
|
1997-12-15 15:11:40 +00:00
|
|
|
|
|
|
|
|
|
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);
|
1997-12-04 14:07:49 +00:00
|
|
|
|
void install_selection();
|
1997-10-30 15:13:59 +00:00
|
|
|
|
|
1997-12-15 15:11:40 +00:00
|
|
|
|
bool do_process(TToken_string& commands) const;
|
1997-10-30 15:13:59 +00:00
|
|
|
|
bool pre_process(TInstall_ini& ini, const char* module) const;
|
|
|
|
|
bool post_process(TInstall_ini& ini, const char* module) const;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
bool autoload();
|
|
|
|
|
bool install(const TString& module);
|
|
|
|
|
|
|
|
|
|
TInstaller_mask();
|
1997-12-04 14:07:49 +00:00
|
|
|
|
virtual ~TInstaller_mask();
|
1997-10-30 15:13:59 +00:00
|
|
|
|
};
|
|
|
|
|
|
1997-12-04 14:07:49 +00:00
|
|
|
|
TInstaller_mask* TInstaller_mask::_curr_mask = NULL;
|
|
|
|
|
|
1997-10-30 15:13:59 +00:00
|
|
|
|
// Copia nello sheet i dati di un modulo prendendoli da un .ini
|
1997-12-04 14:07:49 +00:00
|
|
|
|
bool TInstaller_mask::add_module(TConfig& ini, const TString& module)
|
1997-10-30 15:13:59 +00:00
|
|
|
|
{
|
|
|
|
|
bool ok = ini.set_paragraph(module);
|
|
|
|
|
if (ok)
|
|
|
|
|
{
|
1997-12-04 14:07:49 +00:00
|
|
|
|
TToken_string row;
|
|
|
|
|
row = " "; // Not selected
|
|
|
|
|
row.add(ini.get("Descrizione"));
|
1997-10-30 15:13:59 +00:00
|
|
|
|
row.add(module);
|
|
|
|
|
row.add(ini.get("Versione"));
|
|
|
|
|
row.add(ini.get("Data"));
|
1997-12-04 14:07:49 +00:00
|
|
|
|
add(row);
|
1997-10-30 15:13:59 +00:00
|
|
|
|
}
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TInstaller_mask::update_version()
|
|
|
|
|
{
|
|
|
|
|
TInstall_ini ini;
|
1997-11-06 10:05:56 +00:00
|
|
|
|
|
1997-12-04 14:07:49 +00:00
|
|
|
|
TString_array& array = rows_array();
|
|
|
|
|
FOR_EACH_ARRAY_ROW_BACK(array, m, row)
|
1997-10-30 15:13:59 +00:00
|
|
|
|
{
|
1997-12-04 14:07:49 +00:00
|
|
|
|
const TString16 module = row->get(2);
|
1997-10-30 15:13:59 +00:00
|
|
|
|
ini.set_paragraph(module);
|
|
|
|
|
|
1997-12-04 14:07:49 +00:00
|
|
|
|
const TString16 newver = row->get(3);
|
1997-11-06 15:05:42 +00:00
|
|
|
|
const TString16 oldver = ini.get("Versione");
|
1997-12-04 14:07:49 +00:00
|
|
|
|
row->add(oldver, 5);
|
|
|
|
|
row->add(ini.get("Data"), 6);
|
1997-10-30 15:13:59 +00:00
|
|
|
|
}
|
1997-12-04 14:07:49 +00:00
|
|
|
|
force_update();
|
1997-10-30 15:13:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Cerca nel percorso specificato sulla maschera tutti i possibili files .ini
|
|
|
|
|
// utilizzabili per un'installazione e li inserisce nello spreadsheet
|
|
|
|
|
bool TInstaller_mask::autoload()
|
|
|
|
|
{
|
|
|
|
|
const TString& path = get(F_PATH);
|
|
|
|
|
if (!fexist(path))
|
|
|
|
|
return error_box("Specificare un percorso valido");
|
|
|
|
|
|
|
|
|
|
TWait_cursor hourglass;
|
1997-12-04 14:07:49 +00:00
|
|
|
|
destroy();
|
1997-10-30 15:13:59 +00:00
|
|
|
|
|
|
|
|
|
TFilename ininame;
|
|
|
|
|
ininame = path;
|
|
|
|
|
ininame.add(TInstall_ini::default_name());
|
|
|
|
|
|
|
|
|
|
TString_array modules;
|
|
|
|
|
|
|
|
|
|
if (fexist(ininame))
|
|
|
|
|
{
|
|
|
|
|
TInstall_ini ini(ininame);
|
|
|
|
|
ini.list_paragraphs(modules);
|
1997-11-06 15:05:42 +00:00
|
|
|
|
|
1997-12-15 15:11:40 +00:00
|
|
|
|
FOR_EACH_ARRAY_ROW(modules, i, row)
|
1997-10-30 15:13:59 +00:00
|
|
|
|
{
|
1997-11-06 15:05:42 +00:00
|
|
|
|
const TString& module = *row;
|
1997-12-15 15:11:40 +00:00
|
|
|
|
if (module.len() == 2)
|
1997-10-30 15:13:59 +00:00
|
|
|
|
add_module(ini, module);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ininame = path;
|
|
|
|
|
ininame.add("??inst.ini");
|
1997-11-06 15:05:42 +00:00
|
|
|
|
list_files(ininame, modules);
|
1997-12-15 15:11:40 +00:00
|
|
|
|
FOR_EACH_ARRAY_ROW(modules, m, row)
|
1997-10-30 15:13:59 +00:00
|
|
|
|
{
|
1997-11-06 15:05:42 +00:00
|
|
|
|
TString& ininame = *row;
|
1997-10-30 15:13:59 +00:00
|
|
|
|
ininame.lower();
|
|
|
|
|
const int pos = ininame.find("inst.ini");
|
|
|
|
|
CHECKS(pos > 2, "Invalid installation configuration: ", (const char*)ininame);
|
|
|
|
|
const TString16 module = ininame.mid(pos-2, 2);
|
|
|
|
|
TConfig ini(ininame, module);
|
|
|
|
|
add_module(ini, module);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1997-12-04 14:07:49 +00:00
|
|
|
|
rows_array().sort();
|
|
|
|
|
const bool ok = items() > 0;
|
1997-10-30 15:13:59 +00:00
|
|
|
|
if (ok)
|
|
|
|
|
update_version();
|
|
|
|
|
else
|
1997-12-04 14:07:49 +00:00
|
|
|
|
error_box("Non e' stato trovato nessun modulo da installare\n"
|
|
|
|
|
"in %s", (const char*)path);
|
1997-10-30 15:13:59 +00:00
|
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
1997-12-15 15:11:40 +00:00
|
|
|
|
bool TInstaller_mask::do_process(TToken_string& commands) const
|
1997-10-30 15:13:59 +00:00
|
|
|
|
{
|
|
|
|
|
bool ok = TRUE;
|
|
|
|
|
TFilename cmd;
|
|
|
|
|
for (const char* c = commands.get(0); c && ok; c = commands.get())
|
|
|
|
|
{
|
|
|
|
|
cmd = c;
|
|
|
|
|
if (!cmd.blank())
|
|
|
|
|
{
|
|
|
|
|
TWait_cursor hourglass;
|
|
|
|
|
TExternal_app app(cmd);
|
|
|
|
|
ok = app.run() == 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TInstaller_mask::pre_process(TInstall_ini& ini, const char* module) const
|
1997-11-06 10:05:56 +00:00
|
|
|
|
{
|
1997-12-17 13:40:59 +00:00
|
|
|
|
TAuto_token_string commands(ini.get("PreProcess", module));
|
|
|
|
|
bool ok = do_process(commands);
|
1997-11-06 10:05:56 +00:00
|
|
|
|
return ok;
|
1997-10-30 15:13:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TInstaller_mask::post_process(TInstall_ini& ini, const char* module) const
|
|
|
|
|
{
|
|
|
|
|
TAuto_token_string commands(ini.get("PostProcess", module));
|
|
|
|
|
return do_process(commands);
|
|
|
|
|
}
|
|
|
|
|
|
1997-12-15 15:11:40 +00:00
|
|
|
|
bool TInstaller_mask::can_install(const char* module, TInstall_ini& ini)
|
|
|
|
|
{
|
|
|
|
|
TInstall_ini curini;
|
|
|
|
|
if (curini.demo() != ini.demo())
|
|
|
|
|
{
|
|
|
|
|
TString msg;
|
|
|
|
|
msg << "Attenzione: Non e' possibile installare la versione ";
|
|
|
|
|
msg << (ini.demo() ? "dimostrativa" : "normale");
|
|
|
|
|
msg << " nella cartella della versione ";
|
|
|
|
|
msg << (curini.demo() ? "dimostrativa" : "normale");
|
|
|
|
|
return error_box(msg);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const TString& version = ini.version(module);
|
1997-12-17 13:40:59 +00:00
|
|
|
|
const word year = version2year(version);
|
1997-12-15 15:11:40 +00:00
|
|
|
|
if (year < 1997)
|
|
|
|
|
return error_box("Il modulo '%s' non ha una versione valida.", module);
|
|
|
|
|
|
1997-12-17 13:40:59 +00:00
|
|
|
|
if (year > _year_assist)
|
|
|
|
|
return error_box("Per installare la versione %s del modulo '%s'\n"
|
|
|
|
|
"occorre il contratto di assistenza per l'anno %d.",
|
|
|
|
|
(const char*)version, module, year);
|
1997-12-15 15:11:40 +00:00
|
|
|
|
|
|
|
|
|
TAuto_token_string altri(ini.get("Moduli", module));
|
|
|
|
|
if (stricmp(module, "ba") != 0 && altri.get_pos("ba") < 0)
|
|
|
|
|
altri.add("ba"); // La base e' obbligatoria per tutti
|
|
|
|
|
|
|
|
|
|
bool ok = TRUE;
|
|
|
|
|
TString submodule;
|
|
|
|
|
for (const char* mod = altri.get(0); mod && ok; mod = altri.get())
|
|
|
|
|
{
|
|
|
|
|
submodule = mod;
|
|
|
|
|
if (submodule.len() == 2)
|
|
|
|
|
{
|
|
|
|
|
if (curini.get("Versione", submodule).empty())
|
|
|
|
|
{
|
|
|
|
|
TString msg;
|
1997-12-17 13:40:59 +00:00
|
|
|
|
msg << "L'installazione del modulo '" << module
|
|
|
|
|
<< "'\nrichiede la presenza del modulo '" << submodule
|
|
|
|
|
<< "':\nSi desidera procedere alla sua installazione?";
|
1997-12-15 15:11:40 +00:00
|
|
|
|
ok = yesno_box(msg);
|
|
|
|
|
if (ok)
|
|
|
|
|
ok = install(submodule);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TInstaller_mask::move_file(const TFilename& file, const char* dir) const
|
|
|
|
|
{
|
|
|
|
|
TFilename dest(dir);
|
|
|
|
|
dest.add(file.name());
|
|
|
|
|
|
|
|
|
|
const long filesize = fsize(file);
|
|
|
|
|
|
|
|
|
|
bool space_ok = FALSE;
|
|
|
|
|
while (!space_ok)
|
|
|
|
|
{
|
|
|
|
|
int disk = 0;
|
|
|
|
|
if (dest[1] == ':')
|
|
|
|
|
{
|
|
|
|
|
const char letter = toupper(dest[0]);
|
|
|
|
|
disk = 'A' - letter + 1;
|
|
|
|
|
}
|
|
|
|
|
struct _diskfree_t drive;
|
|
|
|
|
_dos_getdiskfree(disk, &drive);
|
|
|
|
|
|
|
|
|
|
const unsigned requested_clusters = unsigned(filesize / drive.sectors_per_cluster / drive.bytes_per_sector) + 1;
|
|
|
|
|
space_ok = requested_clusters <= drive.avail_clusters;
|
|
|
|
|
if (!space_ok)
|
|
|
|
|
{
|
|
|
|
|
TString msg;
|
|
|
|
|
msg << "Lo spazio sull'unita' e' insufficiente";
|
|
|
|
|
if (GetDriveType(disk-1) == DRIVE_REMOVABLE)
|
|
|
|
|
{
|
|
|
|
|
msg << ":\nInserire un nuovo disco e ritentare?";
|
|
|
|
|
if (!yesno_box(msg))
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return error_box(msg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool write_ok = TRUE;
|
|
|
|
|
bool user_abort = FALSE;
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
write_ok = ::fcopy(file, dest);
|
|
|
|
|
if (write_ok)
|
|
|
|
|
::remove(file);
|
|
|
|
|
else
|
|
|
|
|
{
|
1997-12-17 13:40:59 +00:00
|
|
|
|
if (!yesno_box("Errore di copia del file %s.\nSi desidera riprovare?",
|
1997-12-15 15:11:40 +00:00
|
|
|
|
(const char*)file));
|
|
|
|
|
user_abort = TRUE;
|
|
|
|
|
}
|
|
|
|
|
} while (!write_ok && !user_abort);
|
|
|
|
|
|
|
|
|
|
return write_ok;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TInstaller_mask::move_module(const TString& module, TInstall_ini& ini, bool update) const
|
|
|
|
|
{
|
|
|
|
|
bool ok = TRUE;
|
1997-12-17 13:40:59 +00:00
|
|
|
|
|
|
|
|
|
TFilename src; src.tempdir();
|
|
|
|
|
const TFilename tempdir(src);
|
|
|
|
|
|
1997-12-15 15:11:40 +00:00
|
|
|
|
TString_array list;
|
|
|
|
|
ini.build_list(module, list);
|
|
|
|
|
FOR_EACH_ARRAY_ROW(list, f, file)
|
|
|
|
|
{
|
1997-12-17 13:40:59 +00:00
|
|
|
|
src = tempdir;
|
1997-12-15 15:11:40 +00:00
|
|
|
|
src.add(file->get(0));
|
|
|
|
|
if (update)
|
|
|
|
|
{
|
|
|
|
|
const bool move_ok = move_file(src, ".");
|
|
|
|
|
if (!move_ok)
|
|
|
|
|
ok = update = FALSE;
|
|
|
|
|
}
|
|
|
|
|
if (!update)
|
|
|
|
|
::remove(src);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (update)
|
|
|
|
|
ini.export_paragraph(module, ini.default_name());
|
|
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
1997-10-30 15:13:59 +00:00
|
|
|
|
bool TInstaller_mask::install(const TString& module)
|
|
|
|
|
{
|
|
|
|
|
bool ok = FALSE;
|
|
|
|
|
|
|
|
|
|
const TString& path = get(F_PATH);
|
|
|
|
|
TFilename ininame = path;
|
|
|
|
|
ininame.add(module);
|
|
|
|
|
ininame << "inst.ini";
|
|
|
|
|
|
|
|
|
|
if (fexist(ininame))
|
|
|
|
|
{
|
|
|
|
|
TInstall_ini ini(ininame);
|
1997-12-15 15:11:40 +00:00
|
|
|
|
|
|
|
|
|
if (!can_install(module, ini))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
1997-10-30 15:13:59 +00:00
|
|
|
|
const int dischi = ini.get_int("Dischi", module);
|
|
|
|
|
ok = dischi > 0;
|
1997-11-06 10:05:56 +00:00
|
|
|
|
if (!ok)
|
|
|
|
|
{
|
|
|
|
|
return error_box("Impossibile determinare il numero dei dischetti");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ok = pre_process(ini, module);
|
|
|
|
|
if (!ok) return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
1997-10-30 15:13:59 +00:00
|
|
|
|
TProgind pi(dischi, "Decompressione in corso...", FALSE, TRUE);
|
1997-12-15 15:11:40 +00:00
|
|
|
|
TFilename tempdir; tempdir.tempdir();
|
1997-10-30 15:13:59 +00:00
|
|
|
|
|
|
|
|
|
TFilename cmdline;
|
|
|
|
|
for (int d = 1; d <= dischi && ok; d++)
|
|
|
|
|
{
|
1997-11-06 10:05:56 +00:00
|
|
|
|
cmdline = path;
|
1997-10-30 15:13:59 +00:00
|
|
|
|
cmdline.add(module);
|
1997-11-06 10:05:56 +00:00
|
|
|
|
cmdline << "inst" << d;
|
1997-10-30 15:13:59 +00:00
|
|
|
|
cmdline.ext("zip");
|
|
|
|
|
|
|
|
|
|
ok = fexist(cmdline);
|
|
|
|
|
while (!ok)
|
|
|
|
|
{
|
|
|
|
|
message_box("Inserire il disco %d di %d del modulo\n%s",
|
|
|
|
|
d, dischi, (const char*)ini.get("Descrizione"));
|
|
|
|
|
ok = fexist(cmdline);
|
|
|
|
|
if (!ok)
|
|
|
|
|
{
|
1997-11-06 10:05:56 +00:00
|
|
|
|
if (!yesno_box("Impossibile trovare %s\nSi desidera riprovare?",
|
1997-10-30 15:13:59 +00:00
|
|
|
|
(const char*)cmdline))
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ok)
|
|
|
|
|
{
|
|
|
|
|
struct _diskfree_t drive;
|
|
|
|
|
_dos_getdiskfree(0, &drive);
|
1997-12-15 15:11:40 +00:00
|
|
|
|
const long required = fsize(cmdline) * (dischi-d+1) * 4;
|
1997-10-30 15:13:59 +00:00
|
|
|
|
const unsigned requested_clusters = unsigned(required / drive.sectors_per_cluster / drive.bytes_per_sector) + 1;
|
|
|
|
|
if (requested_clusters >= drive.avail_clusters)
|
|
|
|
|
{
|
|
|
|
|
ok = yesno_box("Lo spazio su disco potrebbe essere insufficiente:\n"
|
|
|
|
|
"Si desidera continuare ugualmente?");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ok)
|
|
|
|
|
{
|
|
|
|
|
TWait_cursor hourglass;
|
|
|
|
|
cmdline.insert("unzip.pif -o ", 0);
|
1997-12-17 13:40:59 +00:00
|
|
|
|
cmdline << " -d " << tempdir;
|
1997-12-15 15:11:40 +00:00
|
|
|
|
|
1997-10-30 15:13:59 +00:00
|
|
|
|
TExternal_app app(cmdline);
|
|
|
|
|
ok = app.run(FALSE, FALSE, FALSE, FALSE) == 0;
|
|
|
|
|
pi.addstatus(1);
|
|
|
|
|
}
|
1997-12-15 15:11:40 +00:00
|
|
|
|
}
|
1997-10-30 15:13:59 +00:00
|
|
|
|
if (ok)
|
1997-12-15 15:11:40 +00:00
|
|
|
|
{
|
|
|
|
|
pi.set_text("Aggiornamento in corso...");
|
|
|
|
|
ok = move_module(module, ini, TRUE);
|
|
|
|
|
|
|
|
|
|
TAuto_token_string altri(ini.get("Moduli", module));
|
|
|
|
|
FOR_EACH_TOKEN(altri, mod)
|
|
|
|
|
{
|
|
|
|
|
const TString16 submod = mod;
|
|
|
|
|
if (submod.len() > 2) // sposta sottomoduli esterni
|
|
|
|
|
{
|
|
|
|
|
bool upd = ok;
|
|
|
|
|
if (ok)
|
|
|
|
|
{
|
|
|
|
|
TInstall_ini curini;
|
|
|
|
|
const TString16 curver = curini.version(submod);
|
|
|
|
|
const TString16 reqver = ini.version(submod);
|
1998-01-20 15:04:34 +00:00
|
|
|
|
int distance =compare_version(reqver, curver) ;
|
|
|
|
|
upd = distance> 0;
|
1997-12-15 15:11:40 +00:00
|
|
|
|
if (!upd)
|
|
|
|
|
{
|
1998-01-20 15:04:34 +00:00
|
|
|
|
if (distance==0)
|
|
|
|
|
upd= yesno_box("Il sottomodulo '%s' versione %s <20> gi<67> installato.\n"
|
|
|
|
|
"Confermi la sovrascrittura?",
|
|
|
|
|
(const char*)submod, (const char*)reqver);
|
|
|
|
|
else
|
|
|
|
|
warning_box("Il sottomodulo '%s' e' aggiornato alla versione %s:\n"
|
|
|
|
|
"l'installazione della versione %s non verra' effettuata.",
|
1997-12-15 15:11:40 +00:00
|
|
|
|
(const char*)submod, (const char*)curver, (const char*)reqver);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ok &= move_module(submod, ini, upd);
|
|
|
|
|
}
|
|
|
|
|
}
|
1997-10-30 15:13:59 +00:00
|
|
|
|
}
|
1997-12-15 15:11:40 +00:00
|
|
|
|
if (ok)
|
|
|
|
|
ok = post_process(ini, module);
|
1997-10-30 15:13:59 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ininame = path;
|
|
|
|
|
ininame.add(TInstall_ini::default_name());
|
|
|
|
|
ok = fexist(ininame);
|
|
|
|
|
if (ok)
|
|
|
|
|
{
|
|
|
|
|
TInstall_ini ini(ininame);
|
1997-12-15 15:11:40 +00:00
|
|
|
|
if (!can_install(module, ini))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
1997-10-30 15:13:59 +00:00
|
|
|
|
TString_array list;
|
1997-12-17 13:40:59 +00:00
|
|
|
|
const int files = ini.build_complete_list(module, list);
|
1997-10-30 15:13:59 +00:00
|
|
|
|
if (files > 0)
|
|
|
|
|
{
|
1997-11-06 10:05:56 +00:00
|
|
|
|
ok = pre_process(ini, module);
|
|
|
|
|
|
|
|
|
|
if (ok)
|
1997-10-30 15:13:59 +00:00
|
|
|
|
{
|
1997-11-06 10:05:56 +00:00
|
|
|
|
TProgind pi(files, "Copia in corso...", FALSE, TRUE);
|
|
|
|
|
TFilename src, dst;
|
|
|
|
|
for (int f = 0; f < files && ok; f++)
|
|
|
|
|
{
|
|
|
|
|
pi.addstatus(1);
|
|
|
|
|
dst = list.row(f).get(0);
|
|
|
|
|
src = path;
|
|
|
|
|
src.add(dst);
|
|
|
|
|
ok = fcopy(src, dst);
|
|
|
|
|
}
|
1997-10-30 15:13:59 +00:00
|
|
|
|
}
|
1997-11-06 10:05:56 +00:00
|
|
|
|
|
1997-10-30 15:13:59 +00:00
|
|
|
|
if (ok)
|
|
|
|
|
{
|
1997-11-11 12:03:20 +00:00
|
|
|
|
ini.export_module_paragraphs(module, ini.default_name());
|
1997-12-15 15:11:40 +00:00
|
|
|
|
ok = post_process(ini, module);
|
1997-10-30 15:13:59 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ok)
|
|
|
|
|
{
|
|
|
|
|
TInstall_ini ini;
|
|
|
|
|
ini.set("DiskPath", path);
|
|
|
|
|
ini.set("Data", TDate(TODAY), module);
|
1997-12-15 15:11:40 +00:00
|
|
|
|
ini.update_prices(ininame);
|
1997-10-30 15:13:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
1997-12-15 15:11:40 +00:00
|
|
|
|
// Non spostare nell'if precedente: permettere l'aggiornamento del .ini
|
1997-11-06 10:05:56 +00:00
|
|
|
|
if (ok)
|
|
|
|
|
update_version();
|
|
|
|
|
|
1997-10-30 15:13:59 +00:00
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TInstaller_mask::path_handler(TMask_field& fld, KEY key)
|
|
|
|
|
{
|
|
|
|
|
bool ok = TRUE;
|
|
|
|
|
if (key == K_TAB && fld.focusdirty())
|
|
|
|
|
{
|
|
|
|
|
TString path = fld.get();
|
|
|
|
|
if (path.len() == 2 && isalpha(path[0]) && path[1] == ':')
|
|
|
|
|
{
|
|
|
|
|
path << SLASH;
|
|
|
|
|
fld.set(path);
|
|
|
|
|
}
|
|
|
|
|
if (fexist(path))
|
1997-12-04 14:07:49 +00:00
|
|
|
|
_curr_mask->autoload();
|
1997-10-30 15:13:59 +00:00
|
|
|
|
else
|
|
|
|
|
ok = fld.error_box("Specificare un percorso valido");
|
|
|
|
|
}
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1997-12-04 14:07:49 +00:00
|
|
|
|
void TInstaller_mask::install_selection()
|
|
|
|
|
{
|
|
|
|
|
TString_array& arr = rows_array();
|
|
|
|
|
FOR_EACH_ARRAY_ROW(arr, r, row) if (checked(r))
|
|
|
|
|
{
|
|
|
|
|
const TString modulo = row->get(2);
|
|
|
|
|
const TString newver = row->get(3);
|
1997-12-15 15:11:40 +00:00
|
|
|
|
const TString oldver = row->get(5);
|
|
|
|
|
|
|
|
|
|
if (version2year(newver) < 1997)
|
|
|
|
|
{
|
|
|
|
|
error_box("Il modulo '%s' non ha una versione valida.", (const char*)modulo);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
1997-10-30 15:13:59 +00:00
|
|
|
|
|
1997-12-04 14:07:49 +00:00
|
|
|
|
bool ok = TRUE;
|
1997-10-30 15:13:59 +00:00
|
|
|
|
const int cmp = compare_version(oldver, newver);
|
|
|
|
|
if (cmp < 0)
|
|
|
|
|
ok = yesno_box("Si desidera installare la versione %s?", (const char*)newver);
|
|
|
|
|
if (cmp == 0)
|
|
|
|
|
ok = yesno_box("Si desidera reinstallare la versione %s?", (const char*)newver);
|
|
|
|
|
if (cmp > 0)
|
|
|
|
|
ok = yesno_box("Si desidera ritornare alla versione %s?\n"
|
|
|
|
|
"Attenzione: non e' garantito il corretto\n"
|
|
|
|
|
"funzionamento di tutti i programmi!", (const char*)oldver);
|
|
|
|
|
if (ok)
|
1997-12-04 14:07:49 +00:00
|
|
|
|
install(modulo);
|
1997-10-30 15:13:59 +00:00
|
|
|
|
}
|
1997-12-04 14:07:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TInstaller_mask::install_handler(TMask_field& fld, KEY key)
|
|
|
|
|
{
|
|
|
|
|
if (key == K_SPACE)
|
1997-12-17 13:40:59 +00:00
|
|
|
|
{
|
|
|
|
|
if (_curr_mask->items() == 1)
|
|
|
|
|
_curr_mask->check(0);
|
1997-12-04 14:07:49 +00:00
|
|
|
|
if (_curr_mask->one_checked())
|
|
|
|
|
_curr_mask->install_selection();
|
|
|
|
|
else
|
|
|
|
|
error_box("Selezionare uno piu' moduli da installare.");
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TInstaller_mask::on_key(KEY key)
|
|
|
|
|
{
|
|
|
|
|
bool ok = TRUE;
|
|
|
|
|
if (key == K_CTRL+'N')
|
|
|
|
|
autoload();
|
|
|
|
|
else
|
|
|
|
|
ok = TArray_sheet::on_key(key);
|
|
|
|
|
return ok;
|
1997-10-30 15:13:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TInstaller_mask::TInstaller_mask()
|
1997-12-04 14:07:49 +00:00
|
|
|
|
: TArray_sheet(0, 0, 0, 0, "Installazione",
|
|
|
|
|
"@1|Modulo@30|Cod.|Versione\nda installare@13|Data\nRilascio@10|Versione\nInstallata@10|Data\nInstallazione@13",
|
|
|
|
|
0x18, 3)
|
|
|
|
|
{
|
|
|
|
|
_curr_mask = this;
|
|
|
|
|
|
|
|
|
|
add_string(F_PATH, 0, "Percorso da cui installare ", 1, 1, 50);
|
|
|
|
|
add_string(F_CURPATH, 0, "Percorso in cui installare ", 1, 2, 50, "D");
|
|
|
|
|
add_button(F_INSTALL, "Installa", '\0'); // NON mettere 'I'
|
|
|
|
|
|
1997-10-30 15:13:59 +00:00
|
|
|
|
set_handler(F_PATH, path_handler);
|
1997-12-04 14:07:49 +00:00
|
|
|
|
set_handler(F_INSTALL, install_handler);
|
1997-10-30 15:13:59 +00:00
|
|
|
|
|
1997-12-17 13:40:59 +00:00
|
|
|
|
TDongle dongle; dongle.login(); dongle.logout();
|
|
|
|
|
_year_assist = dongle.year_assist();
|
|
|
|
|
|
1997-10-30 15:13:59 +00:00
|
|
|
|
TInstall_ini ini;
|
|
|
|
|
TFilename path = ini.get("DiskPath");
|
|
|
|
|
set(F_PATH, path);
|
|
|
|
|
|
|
|
|
|
const char lettera = toupper(path[0]);
|
|
|
|
|
const bool floppy = (path.len() > 1) && path[1] == ':' &&
|
1997-12-04 14:07:49 +00:00
|
|
|
|
GetDriveType(lettera - 'A') == DRIVE_REMOVABLE;
|
1997-10-30 15:13:59 +00:00
|
|
|
|
if (path.not_empty() && !floppy)
|
|
|
|
|
autoload();
|
|
|
|
|
|
|
|
|
|
DIRECTORY dir;
|
|
|
|
|
xvt_fsys_get_dir(&dir);
|
|
|
|
|
xvt_fsys_convert_dir_to_str(&dir, path.get_buffer(), path.size());
|
|
|
|
|
set(F_CURPATH, path);
|
|
|
|
|
}
|
|
|
|
|
|
1997-12-04 14:07:49 +00:00
|
|
|
|
TInstaller_mask::~TInstaller_mask()
|
|
|
|
|
{
|
|
|
|
|
_curr_mask = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
1997-10-30 15:13:59 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Programma principale
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
class TInstaller : public TSkeleton_application
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
virtual bool use_files() const { return FALSE; }
|
|
|
|
|
virtual void main_loop();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void TInstaller::main_loop()
|
|
|
|
|
{
|
|
|
|
|
TInstaller_mask m;
|
|
|
|
|
m.load();
|
|
|
|
|
m.run();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int ba1700(int argc, char* argv[])
|
|
|
|
|
{
|
|
|
|
|
TInstaller app;
|
|
|
|
|
app.run(argc, argv, "Installer");
|
|
|
|
|
return 0;
|
|
|
|
|
}
|