ba0.cpp Abbassata finestra cambio studio

ba1500.cpp  Migliorata gestione dongle::login
ba1500.h    Aggiunto parametro alla dongle::login
ba1600.cpp  Corretta gestione files dei sottomoduli
ba1700.cpp  Migliorata installazione in due tempi


git-svn-id: svn://10.65.10.50/trunk@5764 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1997-12-17 13:40:59 +00:00
parent ebabab8c26
commit 412275444a
5 changed files with 84 additions and 67 deletions

View File

@ -1551,7 +1551,7 @@ HIDDEN bool study_handler(TMask_field& f, KEY k)
bool TMenu_application::choose_study()
{
TMask m("Scelta studio", 1, 60, 6);
TMask m("Scelta studio", 1, 60, 5);
m.add_button(DLG_OK, 0, "", -12, -1, 10, 2);
m.add_button(DLG_CANCEL, 0, "", -22, -1, 10, 2);
m.add_string(DLG_USER, 0, "Studio ", 1, 1, 50);

View File

@ -70,37 +70,44 @@ bool TDongle::already_programmed() const
return TRUE;
}
bool TDongle::login()
bool TDongle::login(bool test_all_keys)
{
bool ok = TRUE;
_type = _user_key;
#if XVT_OS == XVT_OS_SCOUNIX
if (Hl_Port(AGAADR) != 0)
_type = _aga_key;
else
if (Hl_Port(PRASSIADR) != 0)
_type = _prassi_key;
if (test_all_keys)
{
if (Hl_Port(AGAADR) != 0)
_type = _aga_key;
else
if (Hl_Port(PROCOMADR) != 0)
_type = _prcom_key;
if (Hl_Port(PRASSIADR) != 0)
_type = _prassi_key;
else
if (Hl_Port(PROCOMADR) != 0)
_type = _prcom_key;
}
_port = Hl_Port(USERADR);
#else
HL_LOGOUT();
if (HL_LOGIN(AGAADR, DONT_CARE, REFKEY, VERKEY) == STATUS_OK)
_type = _aga_key;
else
if (test_all_keys)
{
HL_LOGOUT();
if (HL_LOGIN(PRASSIADR, DONT_CARE, REFKEY, VERKEY) == STATUS_OK)
_type = _prassi_key;
if (HL_LOGIN(AGAADR, DONT_CARE, REFKEY, VERKEY) == STATUS_OK)
_type = _aga_key;
else
{
HL_LOGOUT();
if (HL_LOGIN(PROCOMADR, DONT_CARE, REFKEY, VERKEY) == STATUS_OK)
_type = _procom_key;
if (HL_LOGIN(PRASSIADR, DONT_CARE, REFKEY, VERKEY) == STATUS_OK)
_type = _prassi_key;
else
{
HL_LOGOUT();
if (HL_LOGIN(PROCOMADR, DONT_CARE, REFKEY, VERKEY) == STATUS_OK)
_type = _procom_key;
}
}
}
}
HL_LOGOUT();
ok = HL_LOGIN(USERADR, DONT_CARE, REFKEY, VERKEY) == STATUS_OK;
@ -1276,7 +1283,7 @@ void TAttivazione_moduli::print()
bool TAttivazione_moduli::create()
{
bool ok = _dongle.login();
bool ok = _dongle.login(TRUE);
if (!ok)
return FALSE;

View File

@ -29,7 +29,7 @@ protected:
public:
bool login();
bool login(bool test_all_keys = FALSE);
bool logout();
word number() const { return _serno; }

View File

@ -41,19 +41,24 @@ int TInstall_ini::build_list(const TString& module, TString_array& a,
sum->remove_all();
}
TAssoc_array& varlist = (TAssoc_array&)list_variables(paragraph);
TAssoc_array& varlist = list_variables(paragraph);
FOR_EACH_ASSOC_STRING(varlist, obj, key, str)
{
tmp = str; // Nome e aggiornamento
{
const bool is_file = strncmp(key, "File", 4) == 0;
tmp = str; // Nome e aggiornamento
// Quando creo il disco di aggiornamento salto tutti i file
// che non hanno il flag di aggiornamento settato
if (agg && tmp.get_char(1) != 'X')
if (agg && is_file && tmp.get_char(1) != 'X')
continue;
if (sum)
sum->set(key, tmp);
tmp.add(paragraph, 2); // Sottomodulo
tmp.lower();
a.add(tmp);
if (is_file)
{
tmp.add(paragraph, 2); // Sottomodulo
tmp.lower();
a.add(tmp);
}
}
if (module[2] != '\0')
@ -68,29 +73,33 @@ int TInstall_ini::build_list(const TString& module, TString_array& a,
int TInstall_ini::build_complete_list(const TString& module, TString_array& a,
const char* sommario, bool agg)
{
{
// Lista dei file appartenenti ai sottomoduli del modulo principale (0-9)
build_list(module, a, sommario, agg);
TAuto_token_string altri(get("Moduli", module));
FOR_EACH_TOKEN(altri, mod)
{
const TString submodule = mod;
export_paragraph(submodule, sommario);
const TString16 submodule = mod;
// Lista dei files apparteneti ai sottomoduli esterni (moduli esclusi!)
if (submodule.len() > 2)
build_list(submodule, a, sommario, agg);
}
return a.items();
}
void TInstall_ini::export_paragraph(const char* module, const char* summary)
{
CHECK(module && *module > ' ', "Can't export NULL module");
CHECK(summary && *summary > ' ', "Can't export to NULL .ini");
TConfig sum(summary, module);
sum.remove_all();
TAssoc_array& ass = (TAssoc_array&)list_variables(module);
TAssoc_array& ass = list_variables(module);
FOR_EACH_ASSOC_STRING(ass, obj, key, str)
sum.set(key, str);
}
void TInstall_ini::export_module_paragraphs(const char* module, const char* summary)
{
CHECK(summary && *summary, "NULL export ini");
TString mod;
for (int sub = -1; sub <= 9; sub++)
{
@ -103,7 +112,7 @@ void TInstall_ini::export_module_paragraphs(const char* module, const char* summ
const TString& TInstall_ini::version(const char* module)
{
CHECK(module && *module, "Can't get version of NULL module");
CHECK(module && *module > ' ', "Can't get version of NULL module");
const TString& ver = get("Versione", module);
if (ver.empty() && strlen(module) > 2)
{
@ -115,7 +124,8 @@ const TString& TInstall_ini::version(const char* module)
}
bool TInstall_ini::update_prices(const char* from)
{
{
CHECK(fexist(from), "Can't find listino prezzi");
TConfig from_ini(from);
const TDate curr_date = get("Main", "Listino");
const TDate from_date = from_ini.get("Main", "Listino");
@ -128,7 +138,7 @@ bool TInstall_ini::update_prices(const char* from)
from_ini.list_paragraphs(modules);
FOR_EACH_ARRAY_ROW_BACK(modules, r, row) if (row->len() == 2)
{
TAssoc_array& prices = (TAssoc_array&)from_ini.list_variables(*row);
TAssoc_array& prices = from_ini.list_variables(*row);
FOR_EACH_ASSOC_STRING(prices, obj, key, str)
{
const TFixed_string price(key);
@ -143,7 +153,7 @@ void TInstall_ini::prices(const char* module, word users,
real& full, real& assist)
{
word min_user = 0;
TAssoc_array& arr = (TAssoc_array&)list_variables(module);
TAssoc_array& arr = list_variables(module);
FOR_EACH_ASSOC_STRING(arr, obj, key, str)
{
const TFixed_string price(key);
@ -208,7 +218,7 @@ void TFconv_ini::export_module(const char* module, const char* summary)
FOR_EACH_ARRAY_ROW(paragraphs, p, para)
{
TAssoc_array& variables = (TAssoc_array&)list_variables(*para);
TAssoc_array& variables = list_variables(*para);
FOR_EACH_ASSOC_STRING(variables, obj, key, str)
{
const char* parenthesis = strchr(key, '(');
@ -943,7 +953,7 @@ bool TFascicolator_mask::move_file(const TFilename& file, const char* dir) const
::remove(file);
else
{
if (!yesno_box("Errore di scrittura del file %s.\nSi desidera riprovare?",
if (!yesno_box("Errore di copia del file %s.\nSi desidera riprovare?",
(const char*)file))
user_abort = TRUE;
}
@ -959,7 +969,8 @@ int TFascicolator_mask::split_file(const TFilename& archive, long size) const
int disks = 1;
if (size > 0L)
{
TFilename sommario(archive); sommario.ext("ini");
TFilename sommario(archive);
sommario.ext("ini");
size -= ::fsize(sommario);
const long minsize = 360*1024L;
if (size < minsize)

View File

@ -41,6 +41,7 @@ HIDDEN word version2year(const char* v)
class TInstaller_mask : public TArray_sheet
{
static TInstaller_mask* _curr_mask;
word _year_assist;
protected: // TSheet
virtual bool on_key(KEY key);
@ -184,14 +185,8 @@ bool TInstaller_mask::do_process(TToken_string& commands) const
bool TInstaller_mask::pre_process(TInstall_ini& ini, const char* module) const
{
bool ok = TRUE;
if (ok)
{
TAuto_token_string commands(ini.get("PreProcess", module));
ok = do_process(commands);
}
TAuto_token_string commands(ini.get("PreProcess", module));
bool ok = do_process(commands);
return ok;
}
@ -215,16 +210,14 @@ bool TInstaller_mask::can_install(const char* module, TInstall_ini& ini)
}
const TString& version = ini.version(module);
const word year = version2year(module);
const word year = version2year(version);
if (year < 1997)
return error_box("Il modulo '%s' non ha una versione valida.", module);
TDongle dongle; dongle.login(); dongle.logout();
if (year > dongle.year_assist())
return error_box("Per installare il modulo %s %s e' necessario\n"
"rinnovare il contratto di assistenza del %d.",
module, (const char*)version, year);
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);
TAuto_token_string altri(ini.get("Moduli", module));
if (stricmp(module, "ba") != 0 && altri.get_pos("ba") < 0)
@ -240,9 +233,9 @@ bool TInstaller_mask::can_install(const char* module, TInstall_ini& ini)
if (curini.get("Versione", submodule).empty())
{
TString msg;
msg << "L'installazione del modulo " << module
<< "\nrichiede la presenza del modulo " << submodule
<< ":\nSi desidera procedere alla sua installazione?";
msg << "L'installazione del modulo '" << module
<< "'\nrichiede la presenza del modulo '" << submodule
<< "':\nSi desidera procedere alla sua installazione?";
ok = yesno_box(msg);
if (ok)
ok = install(submodule);
@ -298,7 +291,7 @@ bool TInstaller_mask::move_file(const TFilename& file, const char* dir) const
::remove(file);
else
{
if (!yesno_box("Errore di scrittura del file %s.\nSi desidera riprovare?",
if (!yesno_box("Errore di copia del file %s.\nSi desidera riprovare?",
(const char*)file));
user_abort = TRUE;
}
@ -310,13 +303,15 @@ bool TInstaller_mask::move_file(const TFilename& file, const char* dir) const
bool TInstaller_mask::move_module(const TString& module, TInstall_ini& ini, bool update) const
{
bool ok = TRUE;
TFilename src;
TFilename src; src.tempdir();
const TFilename tempdir(src);
TString_array list;
ini.build_list(module, list);
FOR_EACH_ARRAY_ROW(list, f, file)
{
src.tempdir();
src = tempdir;
src.add(file->get(0));
if (update)
{
@ -404,7 +399,7 @@ bool TInstaller_mask::install(const TString& module)
{
TWait_cursor hourglass;
cmdline.insert("unzip.pif -o ", 0);
cmdline << ' ' << tempdir;
cmdline << " -d " << tempdir;
TExternal_app app(cmdline);
ok = app.run(FALSE, FALSE, FALSE, FALSE) == 0;
@ -431,9 +426,8 @@ bool TInstaller_mask::install(const TString& module)
upd = compare_version(reqver, curver) > 0;
if (!upd)
{
warning_box("La versione del sottomodulo %s (%s) e' piu' aggiornata\n"
"di quella che si desidera installare (%s):\n"
"L'aggiornamento del sottomodulo verra' ignorato.",
warning_box("Il sottomodulo '%s' e' aggiornato alla versione %s:\n"
"l'installazione della versione %s non vera' effettuata.",
(const char*)submod, (const char*)curver, (const char*)reqver);
}
}
@ -456,7 +450,7 @@ bool TInstaller_mask::install(const TString& module)
return FALSE;
TString_array list;
const int files = ini.build_list(module, list);
const int files = ini.build_complete_list(module, list);
if (files > 0)
{
ok = pre_process(ini, module);
@ -552,7 +546,9 @@ void TInstaller_mask::install_selection()
bool TInstaller_mask::install_handler(TMask_field& fld, KEY key)
{
if (key == K_SPACE)
{
{
if (_curr_mask->items() == 1)
_curr_mask->check(0);
if (_curr_mask->one_checked())
_curr_mask->install_selection();
else
@ -585,6 +581,9 @@ TInstaller_mask::TInstaller_mask()
set_handler(F_PATH, path_handler);
set_handler(F_INSTALL, install_handler);
TDongle dongle; dongle.login(); dongle.logout();
_year_assist = dongle.year_assist();
TInstall_ini ini;
TFilename path = ini.get("DiskPath");
set(F_PATH, path);