ba1500.cpp Gestione del nome del produttore del software

ba1500a.*     Aggiornata maschera per gestire produttore
ba1600.cpp    Aggiunta 'marcatura' degli exe con anno e versione
ba1600.h      Aggiunto metodo version_info
ba1700.cpp    Tolta richiesta di conferma su installazione


git-svn-id: svn://10.65.10.50/trunk@6043 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1998-01-28 08:53:28 +00:00
parent c09ac8f7a7
commit 02858f2975
6 changed files with 126 additions and 11 deletions

View File

@ -45,8 +45,8 @@ void TDongle::garble(word k[4]) const
K_EYE(_port, k, HLBLOCK);
HL_OFF(_port);
INT_ON();
#else
HL_CODE(EYECAST k, 1);
#else
HL_CODE(EYECAST k, 1); // HLBLOCK = 1
#endif
#endif // _DEMO_
@ -133,7 +133,7 @@ bool TDongle::login(bool test_all_keys)
if (data[0] == 0x3283) // chiave programmatori !!
{
#ifdef DBG
// _type = _aga_key; // eliminato perché giudicato troppo pericoloso
_type = _aga_key; // eliminato perché giudicato troppo pericoloso
// se la DBG version arriva nelle mani di qualcuno
// ci inchiappetta tutti i programmi senza darci una lira!
@ -532,6 +532,7 @@ protected:
static bool assist_handler(TMask_field& fld, KEY key);
static bool print_handler(TMask_field& fld, KEY key);
static bool aggiorna_listino_handler(TMask_field& fld, KEY key);
static bool aga_handler(TMask_field& fld, KEY key);
protected:
void print_request();
@ -846,6 +847,24 @@ bool TAttivazione_moduli::print_handler(TMask_field& fld, KEY key)
return TRUE;
}
bool TAttivazione_moduli::aga_handler(TMask_field& fld, KEY key)
{
if (key == K_SPACE)
{
TMask mask("Produttore", 1, 54, 5);
mask.add_string(DLG_USER, 0, "", 1, 1, 50);
mask.add_button(DLG_OK, 0, "", -12, -1, 10, 2);
mask.add_button(DLG_CANCEL, 0, "", -22, -1, 10, 2);
TConfig ini("install.ini", "Main");
mask.set(DLG_USER, ::decode(ini.get("Producer")));
if (mask.run() == K_ENTER)
ini.set("Producer", ::encode(mask.get(DLG_USER)));
}
return TRUE;
}
void TAttivazione_moduli::generate_key()
{
word ud[4];
@ -1315,6 +1334,11 @@ bool TAttivazione_moduli::create()
_msk->set_handler(F_CHANGEUSERS, change_users_handler);
_msk->set_handler(F_CHANGEASSIST, change_assist_handler);
_msk->set_handler(F_PRINT, print_handler);
if (_dongle.type() == TDongle::_aga_key)
{
_msk->show(F_AGA);
_msk->set_handler(F_AGA, aga_handler);
}
TSheet_field& sf = _msk->sfield(F_MODULI);
sf.set_notify(k_notify);

View File

@ -16,6 +16,7 @@
#define F_ASSIST 216
#define F_CHANGEASSIST 217
#define F_PRINT 218
#define F_AGA 219
#define F_NOMEMOD 101
#define F_ENABLE 102

View File

@ -79,6 +79,12 @@ BEGIN
FLAGS "U"
END
BUTTON F_AGA 14
BEGID
PROMPT 1 4 "Produttore"
FLAGS "H"
END
SPREADSHEET F_MODULI 78
BEGIN
PROMPT 1 5 "Moduli"

View File

@ -143,11 +143,31 @@ int TInstall_ini::patch(const char* module)
return patch;
}
void TInstall_ini::version_info(const char* module,
int& year, int& release,
int& tag, int& patchlevel)
{
TString ver = version(module);
if (ver[0] == '9')
ver.insert("19", 0);
year = atoi(ver.left(4));
if (year == 0)
main_app().get_version_info(year, release, tag, patchlevel);
else
{
release = atoi(ver.mid(4,2));
if (release == 0)
release++;
tag = atoi(ver.mid(6,2));
patchlevel = patch(module);
}
}
bool TInstall_ini::update_prices(const char* from)
{
CHECK(fexist(from), "Can't find listino prezzi");
TConfig from_ini(from);
from_ini.write_protect();
from_ini.write_protect();
const TDate curr_date = get("Listino","Main");
const TDate from_date = from_ini.get("Listino","Main");
if (from_date < curr_date)
@ -683,6 +703,10 @@ protected:
bool zip_module(const TString& module, bool agg, int patch_level) const;
const TFilename& build_export_path(TFilename& path) const;
long find_signature(const TFilename& filename, const char* signature) const;
bool set_version_info(const TFilename& filename,
TInstall_ini& ini, const char* module) const;
public:
void load();
@ -1048,6 +1072,58 @@ int TFascicolator_mask::split_file(const TFilename& archive, long size) const
return disks;
}
long TFascicolator_mask::find_signature(const TFilename& filename, const char* signature) const
{
bool found = FALSE;
long position = -1;
int compare = 0;
ifstream infile(filename, ios::nocreate | ios::in | ios::binary);
for (int car = infile.get(); car != EOF; car = infile.get())
{
if (car == signature[compare])
{
if (compare == 0)
position = infile.tellg()-1;
compare++;
if (signature[compare] == '\0')
{
found = TRUE;
break;
}
}
else
{
compare = 0;
infile.seekg(position+1, ios::beg);
}
}
return found ? position : -1;
}
bool TFascicolator_mask::set_version_info(const TFilename& filename,
TInstall_ini& ini, const char* module) const
{
bool ok = FALSE;
TString80 str = "Don't cry for me "; str << "Argentina.";
long position = find_signature(filename, str);
if (position > 0)
{
ofstream outfile(filename, ios::out || ios::nocreate | ios::binary);
position += str.len();
outfile.seekp(position);
if (outfile.good())
{
int year, release, tag, patch, checksum;
ini.version_info(module, year, release, tag, patch);
checksum = year + release + tag + patch;
str.format("%04d.%02d.%02d.%03d.%04d", year, release, tag, patch, checksum);
outfile.write(str, str.len());
ok = outfile.good();
}
}
return ok;
}
bool TFascicolator_mask::zip_module(const TString& main_module, bool agg, int patch_level) const
{
TString_array arr;
@ -1083,7 +1159,7 @@ bool TFascicolator_mask::zip_module(const TString& main_module, bool agg, int pa
ofstream fileh(filelist);
TProgind pi(arr.items(), msg, TRUE, TRUE);
TString cmd(120);
TFilename cmd;
FOR_EACH_ARRAY_ROW_BACK(arr, i, row)
{
@ -1094,9 +1170,18 @@ bool TFascicolator_mask::zip_module(const TString& main_module, bool agg, int pa
break;
}
cmd = row->get(0);
// Se non trovo anche uno solo dei files nella lista, è un casino
if (!fexist(cmd))
if (cmd.exist())
{
if (stricmp(cmd.ext(), "exe") == 0)
{
TString16 submod = row->get(2);
submod.cut(2);
set_version_info(cmd, ini, submod);
}
}
else
{
// Se non trovo anche uno solo dei files nella lista, è un casino
TString msg(128);
msg << "Impossibile aprire il file " << cmd << ". Interrompere?";
if (yesno_box(msg))

View File

@ -19,7 +19,8 @@ public:
bool demo() { return get_bool("Demo", "Main"); }
const TString& version(const char* module);
int patch(const char* module);
void version_info(const char* module,
int& year, int& release, int& tag, int& patch);
bool update_prices(const char* src_ini);
void prices(const char* module, word users, real& full, real& manut);

View File

@ -175,8 +175,8 @@ bool TInstaller_mask::autoload()
if (fexist(ininame))
{
TInstall_ini ini(ininame);
ini.list_paragraphs(modules);
FOR_EACH_ARRAY_ROW(modules, i, row)
{
const TString& module = *row;
@ -614,8 +614,6 @@ void TInstaller_mask::install_selection()
bool ok = TRUE;
const int cmp = compare_version(oldver, oldpatch, newver, newpatch);
if (cmp < 0)
ok = yesno_box("Si desidera installare la versione %s.%d?", (const char*)newver, newpatch);
if (cmp == 0)
ok = yesno_box("Si desidera reinstallare la versione %s.%d?", (const char*)newver, newpatch);
if (cmp > 0)