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"
|
|
|
|
|
1998-01-29 13:42:30 +00:00
|
|
|
|
|
|
|
HIDDEN int noyes_box(const char* msg)
|
|
|
|
{
|
|
|
|
MessageBeep(MB_ICONQUESTION);
|
|
|
|
int r = MessageBox(GetFocus(), msg, "RICHIESTA",
|
|
|
|
MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2);
|
|
|
|
return r == IDYES;
|
|
|
|
}
|
|
|
|
|
1998-01-23 14:55:34 +00:00
|
|
|
HIDDEN int compare_version(const char* v1, int p1, const char* v2, int p2)
|
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);
|
1998-01-22 11:56:14 +00:00
|
|
|
|
|
|
|
int res = ver1.compare(ver2, -1, TRUE);
|
|
|
|
if (res == 0)
|
1998-01-23 14:55:34 +00:00
|
|
|
res = p1 - p2;
|
1998-01-22 11:56:14 +00:00
|
|
|
|
|
|
|
return res;
|
1997-10-30 15:13:59 +00:00
|
|
|
}
|
|
|
|
|
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;
|
1998-01-29 13:42:30 +00:00
|
|
|
bool _installed; // Flag per verificare se almeno un modulo e' stato installato
|
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);
|
|
|
|
|
1998-01-23 14:55:34 +00:00
|
|
|
bool add_module(TConfig& ini, const TString& module, bool patch);
|
1998-01-22 11:56:14 +00:00
|
|
|
int sort_modules();
|
1997-10-30 15:13:59 +00:00
|
|
|
void update_version();
|
1997-12-15 15:11:40 +00:00
|
|
|
|
1998-01-29 13:42:30 +00:00
|
|
|
bool move_file(const TFilename& fromdir, const TFilename& file, const char* dir) const;
|
1997-12-15 15:11:40 +00:00
|
|
|
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;
|
|
|
|
|
1998-01-29 13:42:30 +00:00
|
|
|
public:
|
|
|
|
bool installed() { return _installed;}
|
1997-10-30 15:13:59 +00:00
|
|
|
bool autoload();
|
1998-01-23 14:55:34 +00:00
|
|
|
bool install(const TString& module, int patch);
|
1997-10-30 15:13:59 +00:00
|
|
|
|
|
|
|
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
|
1998-01-23 14:55:34 +00:00
|
|
|
bool TInstaller_mask::add_module(TConfig& ini, const TString& module, bool patch)
|
1997-10-30 15:13:59 +00:00
|
|
|
{
|
1998-01-26 10:45:15 +00:00
|
|
|
ini.write_protect();
|
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"));
|
1998-01-22 11:56:14 +00:00
|
|
|
row.add(ini.get("Patch"));
|
1997-10-30 15:13:59 +00:00
|
|
|
row.add(ini.get("Data"));
|
1998-01-23 14:55:34 +00:00
|
|
|
row.add(patch ? "X" : " ", 9);
|
1997-12-04 14:07:49 +00:00
|
|
|
add(row);
|
1997-10-30 15:13:59 +00:00
|
|
|
}
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
1998-01-22 11:56:14 +00:00
|
|
|
static int compare_modules(const TObject** o1, const TObject** o2)
|
|
|
|
{
|
|
|
|
TToken_string& ts1 = *(TToken_string*)(*o1);
|
|
|
|
TToken_string& ts2 = *(TToken_string*)(*o2);
|
|
|
|
|
|
|
|
int res = 0;
|
1998-01-23 14:55:34 +00:00
|
|
|
for (int i = 2; i < 5 && res == 0; i++)
|
1998-01-22 11:56:14 +00:00
|
|
|
{
|
|
|
|
TString16 s1 = ts1.get(i);
|
|
|
|
const char* s2 = ts2.get(i);
|
|
|
|
res = s1.compare(s2);
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
int TInstaller_mask::sort_modules()
|
|
|
|
{
|
|
|
|
rows_array().TArray::sort(compare_modules);
|
|
|
|
|
1998-01-23 14:55:34 +00:00
|
|
|
TString16 dis;
|
1998-01-22 11:56:14 +00:00
|
|
|
const int tot = int(items());
|
|
|
|
for (int r = 0; r < tot; r++)
|
|
|
|
{
|
1998-01-23 14:55:34 +00:00
|
|
|
const bool patch = row(r).get_char(9) > ' ';
|
|
|
|
const char* mod = row(r).get(2);
|
|
|
|
if (patch)
|
|
|
|
{
|
|
|
|
if (dis == mod)
|
1998-01-22 11:56:14 +00:00
|
|
|
disable_row(r);
|
|
|
|
}
|
1998-01-23 14:55:34 +00:00
|
|
|
else
|
|
|
|
dis = mod;
|
1998-01-22 11:56:14 +00:00
|
|
|
}
|
|
|
|
return tot;
|
|
|
|
}
|
|
|
|
|
1997-10-30 15:13:59 +00:00
|
|
|
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");
|
1998-01-22 11:56:14 +00:00
|
|
|
row->add(oldver, 6);
|
|
|
|
row->add(ini.get("Patch"), 7);
|
|
|
|
row->add(ini.get("Data"), 8);
|
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);
|
1998-01-28 08:53:28 +00:00
|
|
|
|
1997-10-30 15:13:59 +00:00
|
|
|
ini.list_paragraphs(modules);
|
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)
|
1998-01-23 14:55:34 +00:00
|
|
|
add_module(ini, module, FALSE);
|
1997-10-30 15:13:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
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");
|
1998-01-22 11:56:14 +00:00
|
|
|
CHECKS(pos >= 2, "Invalid installation configuration: ", (const char*)ininame);
|
1997-10-30 15:13:59 +00:00
|
|
|
const TString16 module = ininame.mid(pos-2, 2);
|
|
|
|
TConfig ini(ininame, module);
|
1998-01-23 14:55:34 +00:00
|
|
|
add_module(ini, module, FALSE);
|
1997-10-30 15:13:59 +00:00
|
|
|
}
|
1998-01-22 11:56:14 +00:00
|
|
|
|
|
|
|
ininame = path;
|
1998-01-23 14:55:34 +00:00
|
|
|
ininame.add("??0???a.ini");
|
1998-01-22 11:56:14 +00:00
|
|
|
modules.destroy();
|
|
|
|
list_files(ininame, modules);
|
|
|
|
FOR_EACH_ARRAY_ROW(modules, am, arow)
|
|
|
|
{
|
|
|
|
TString& ininame = *arow;
|
|
|
|
ininame.lower();
|
|
|
|
const int pos = ininame.find("a.ini");
|
1998-01-23 14:55:34 +00:00
|
|
|
CHECKS(pos >= 6, "Invalid installation configuration: ", (const char*)ininame);
|
|
|
|
const TString16 module = ininame.mid(pos-6, 2);
|
1998-01-22 11:56:14 +00:00
|
|
|
TConfig ini(ininame, module);
|
1998-01-23 14:55:34 +00:00
|
|
|
add_module(ini, module, TRUE);
|
1998-01-22 11:56:14 +00:00
|
|
|
}
|
1997-10-30 15:13:59 +00:00
|
|
|
}
|
|
|
|
|
1998-01-22 11:56:14 +00:00
|
|
|
const bool ok = sort_modules() > 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)
|
1998-01-22 11:56:14 +00:00
|
|
|
ok = install(submodule, 0);
|
1997-12-15 15:11:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
1998-01-29 13:42:30 +00:00
|
|
|
// sposta il file dal direttorio temporaneo a quello passato come destinazione
|
|
|
|
bool TInstaller_mask::move_file(const TFilename& from, const TFilename& file, const char* dir) const
|
1997-12-15 15:11:40 +00:00
|
|
|
{
|
|
|
|
TFilename dest(dir);
|
1998-01-29 13:42:30 +00:00
|
|
|
dest.add(file.mid(from.len()));
|
1997-12-15 15:11:40 +00:00
|
|
|
|
|
|
|
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;
|
1998-01-29 13:42:30 +00:00
|
|
|
bool user_retry = FALSE;
|
1997-12-15 15:11:40 +00:00
|
|
|
do
|
|
|
|
{
|
|
|
|
write_ok = ::fcopy(file, dest);
|
|
|
|
if (write_ok)
|
|
|
|
::remove(file);
|
|
|
|
else
|
1998-01-29 13:42:30 +00:00
|
|
|
user_retry = yesno_box("Errore di copia del file %s.\nSi desidera ritentare?",
|
|
|
|
(const char*)file);
|
|
|
|
} while (!write_ok && user_retry);
|
1997-12-15 15:11:40 +00:00
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
1998-01-29 13:42:30 +00:00
|
|
|
const bool move_ok = move_file(tempdir, src, ".");
|
1997-12-15 15:11:40 +00:00
|
|
|
if (!move_ok)
|
|
|
|
ok = update = FALSE;
|
|
|
|
}
|
|
|
|
if (!update)
|
|
|
|
::remove(src);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (update)
|
|
|
|
ini.export_paragraph(module, ini.default_name());
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
1998-01-23 14:55:34 +00:00
|
|
|
bool TInstaller_mask::install(const TString& module, int patchlevel)
|
1997-10-30 15:13:59 +00:00
|
|
|
{
|
|
|
|
bool ok = FALSE;
|
|
|
|
|
|
|
|
const TString& path = get(F_PATH);
|
|
|
|
TFilename ininame = path;
|
|
|
|
ininame.add(module);
|
1998-01-22 11:56:14 +00:00
|
|
|
|
|
|
|
if (patchlevel > 0)
|
|
|
|
{
|
|
|
|
TString16 name;
|
1998-01-23 14:55:34 +00:00
|
|
|
name.format("%04da.ini", patchlevel);
|
1998-01-22 11:56:14 +00:00
|
|
|
ininame << name;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ininame << "inst.ini";
|
1997-10-30 15:13:59 +00:00
|
|
|
|
|
|
|
if (fexist(ininame))
|
|
|
|
{
|
|
|
|
TInstall_ini ini(ininame);
|
1997-12-15 15:11:40 +00:00
|
|
|
|
1998-01-26 10:45:15 +00:00
|
|
|
ini.write_protect();
|
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;
|
|
|
|
}
|
|
|
|
|
1998-01-23 14:55:34 +00:00
|
|
|
TString msg;
|
1998-01-29 13:42:30 +00:00
|
|
|
msg << "Decompressione del modulo '" << module << "' in corso...";
|
1998-01-23 14:55:34 +00:00
|
|
|
TProgind pi(dischi, msg, 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);
|
1998-01-23 14:55:34 +00:00
|
|
|
if (patchlevel > 0)
|
|
|
|
{
|
|
|
|
TString16 name;
|
|
|
|
name.format("%04da", patchlevel);
|
|
|
|
cmdline << name;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
cmdline << "inst";
|
|
|
|
cmdline << d << ".zip";
|
1997-10-30 15:13:59 +00:00
|
|
|
|
1998-01-23 14:55:34 +00:00
|
|
|
ok = cmdline.exist();
|
1997-10-30 15:13:59 +00:00
|
|
|
while (!ok)
|
|
|
|
{
|
1998-01-29 13:42:30 +00:00
|
|
|
message_box("Inserire il disco %d di %d del modulo\n'%s'",
|
1997-10-30 15:13:59 +00:00
|
|
|
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)
|
1998-01-23 14:55:34 +00:00
|
|
|
{
|
|
|
|
msg.cut(0);
|
1998-01-29 13:42:30 +00:00
|
|
|
msg << "Aggiornamento del modulo '" << module << "' in corso...";
|
1998-01-23 14:55:34 +00:00
|
|
|
pi.set_text(msg);
|
1997-12-15 15:11:40 +00:00
|
|
|
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);
|
1998-01-23 14:55:34 +00:00
|
|
|
const int curpatch = curini.patch(submod);
|
1997-12-15 15:11:40 +00:00
|
|
|
const TString16 reqver = ini.version(submod);
|
1998-01-23 14:55:34 +00:00
|
|
|
const int reqpatch = ini.patch(submod);
|
1998-01-22 11:56:14 +00:00
|
|
|
int distance = compare_version(reqver, reqpatch, curver, curpatch);
|
1998-01-20 15:04:34 +00:00
|
|
|
upd = distance> 0;
|
1998-01-23 14:55:34 +00:00
|
|
|
if (distance!=0)
|
|
|
|
warning_box("Il sottomodulo '%s' necessario a '%s' e' gia' aggiornato alla versione %s:\n"
|
1998-01-20 15:04:34 +00:00
|
|
|
"l'installazione della versione %s non verra' effettuata.",
|
1998-01-23 08:01:59 +00:00
|
|
|
(const char*)submod, (const char*)module, (const char*)curver, (const char*)reqver);
|
1997-12-15 15:11:40 +00:00
|
|
|
}
|
|
|
|
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);
|
1998-01-26 10:45:15 +00:00
|
|
|
ini.write_protect();
|
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())
|
|
|
|
{
|
1998-01-23 14:55:34 +00:00
|
|
|
TFilename path = fld.get();
|
1997-10-30 15:13:59 +00:00
|
|
|
if (path.len() == 2 && isalpha(path[0]) && path[1] == ':')
|
|
|
|
{
|
|
|
|
path << SLASH;
|
|
|
|
fld.set(path);
|
|
|
|
}
|
1998-01-23 14:55:34 +00:00
|
|
|
if (path.exist())
|
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);
|
1998-01-23 14:55:34 +00:00
|
|
|
const int newpatch = row->get_int(4);
|
1998-01-22 11:56:14 +00:00
|
|
|
const TString oldver = row->get(6);
|
1998-01-23 14:55:34 +00:00
|
|
|
const int oldpatch = row->get_int(7);
|
1997-12-15 15:11:40 +00:00
|
|
|
|
|
|
|
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;
|
1998-01-22 11:56:14 +00:00
|
|
|
const int cmp = compare_version(oldver, oldpatch, newver, newpatch);
|
1997-10-30 15:13:59 +00:00
|
|
|
if (cmp == 0)
|
1998-01-29 13:42:30 +00:00
|
|
|
ok = yesno_box("Si desidera reinstallare la versione %s.%d del modulo '%s' ?", (const char*)newver, newpatch, (const char*)modulo);
|
1997-10-30 15:13:59 +00:00
|
|
|
if (cmp > 0)
|
1998-01-29 13:42:30 +00:00
|
|
|
{
|
|
|
|
TString256 msg;
|
|
|
|
msg.format("Si desidera ritornare alla versione %s.%d del modulo '%s' ?\n"
|
1997-10-30 15:13:59 +00:00
|
|
|
"Attenzione: non e' garantito il corretto\n"
|
1998-01-29 13:42:30 +00:00
|
|
|
"funzionamento di tutti i programmi!", (const char*)newver, newpatch, (const char*)modulo);
|
|
|
|
ok = noyes_box(msg);
|
|
|
|
}
|
1997-10-30 15:13:59 +00:00
|
|
|
if (ok)
|
1998-01-23 14:55:34 +00:00
|
|
|
{
|
|
|
|
const bool is_patch = row->get_char(9) > ' ';
|
|
|
|
ok = install(modulo, is_patch ? newpatch : 0);
|
1998-01-29 13:42:30 +00:00
|
|
|
if (ok)
|
|
|
|
_installed = TRUE; // Setta il flag di almeno un modulo installato
|
1998-01-23 14:55:34 +00:00
|
|
|
if (!is_patch) // Se installo un modulo pricipale ...
|
|
|
|
{
|
|
|
|
// ... allora installo tutte le patches
|
|
|
|
for (int p = r+1; ok; p++)
|
|
|
|
{
|
|
|
|
if (row_disabled(p))
|
|
|
|
{
|
|
|
|
const int patchlevel = arr.row(p).get_int(4);
|
|
|
|
ok = install(modulo, patchlevel);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1998-01-22 11:56:14 +00:00
|
|
|
}
|
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",
|
1998-01-23 14:55:34 +00:00
|
|
|
"@1|Modulo@30|Cod.|Versione\nda installare@13|Livello\nPatch|Data\nRilascio@10|Versione\nInstallata@10|Livello\nPatch|Data\nInstallazione@13|Aggiornamento",
|
1997-12-04 14:07:49 +00:00
|
|
|
0x18, 3)
|
|
|
|
{
|
|
|
|
_curr_mask = this;
|
1998-01-29 13:42:30 +00:00
|
|
|
_installed = FALSE;
|
|
|
|
|
1997-12-04 14:07:49 +00:00
|
|
|
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();
|
1998-01-29 13:42:30 +00:00
|
|
|
if (m.installed()) // Almeno 1 modulo installato ?
|
|
|
|
{
|
|
|
|
// Lancia conversione: ba1 -0 -C -uPRASSI
|
|
|
|
TExternal_app conversion("ba1 -0 -C");
|
|
|
|
conversion.run();
|
|
|
|
}
|
1997-10-30 15:13:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int ba1700(int argc, char* argv[])
|
|
|
|
{
|
|
|
|
TInstaller app;
|
|
|
|
app.run(argc, argv, "Installer");
|
|
|
|
return 0;
|
|
|
|
}
|