diff --git a/ba/ba0100.cpp b/ba/ba0100.cpp index c6cbe0e7a..fc31aacac 100755 --- a/ba/ba0100.cpp +++ b/ba/ba0100.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -67,6 +68,8 @@ protected: int do_explore(); int do_outlook(); + int get_user_status(const char* usr) const; + bool set_user_status(const char* usr, int status) const; bool check_user(); static bool menu_item_handler(TMask_field& f, KEY k); @@ -840,6 +843,61 @@ bool TMenu_application::ask_user_password(TString& utente) return ok; } +// Testa stato utente: 0 inesistente; 1 = esiste; 2 connesso; 4 conversione in corso +// ATTENZIONE: non usare mai cache() in ba0! +int TMenu_application::get_user_status(const char* usr) const +{ + CHECK(usr && *usr, "Utente nullo"); + + int status = 0; + if (prefix_valid()) + { + TLocalisamfile utonti(LF_USER); + utonti.put(USR_USERNAME, usr); + status = utonti.read() == NOERR; + if (status) + { + if (utonti.get_bool(USR_CONNECTED)) + status |= 2; + if (dongle().administrator() == usr && utonti.get(USR_AUTSTR) == "CONVERTING") + status |= 4; + } + } + else + { + // Senza file aperti questo e' il massimo che posso fare + status = dongle().administrator() == usr; + } + + return status; +} + +bool TMenu_application::set_user_status(const char* usr, int status) const +{ + CHECK(usr && *usr, "Utente nullo"); + + bool ok = false; + if (prefix_valid()) + { + TLocalisamfile utonti(LF_USER); + utonti.put(USR_USERNAME, usr); + if (utonti.read(_isequal, _lock) == NOERR) + { + utonti.put(USR_CONNECTED, status & 2 ? "X" : ""); + ok = utonti.rewrite() == NOERR; + } + } + if (status & 2) + { + // Memorizza utente per riproporlo la prossima volta + TConfig campo_ini(CONFIG_INSTALL, "Main"); + campo_ini.set("User", usr); + } + + return ok; +} + + bool TMenu_application::check_user() { bool ok = dongle().type() == _no_dongle; @@ -886,20 +944,7 @@ bool TMenu_application::check_user() } if (ok) - { - TLocalisamfile users(LF_USER); - users.put("USERNAME", utente); - if (users.read(_isequal, _lock) == NOERR) - { - users.put("CONNECTED", "X"); - users.rewrite(); - } - - // Memorizza l'ultimo utente per riproporlo la prossima volta - TConfig campo_ini(CONFIG_INSTALL, "Main"); - campo_ini.set("User", utente); - } - } + set_user_status(utente, 3); // Esistente e connesso (1 | 2 = 3) } if (ok) @@ -1142,17 +1187,8 @@ bool TMenu_application::user_create() void TMenu_application::deconnect_user() { - if (prefix_valid()) - { - TLocalisamfile users(LF_USER); - users.put("USERNAME", user()); - const int err = users.read(_isequal, _lock); - if (err == NOERR) - { - users.zero("CONNECTED"); - users.rewrite(); - } - } + if (get_user_status(user()) & 2) // Se e' connesso + set_user_status(user(), 1); // Sconnettilo } bool TMenu_application::destroy() @@ -1368,8 +1404,10 @@ HIDDEN bool study_handler(TMask_field& f, KEY k) bool TMenu_application::choose_study() { - disable_menu_item(MENU_ITEM(4)); - + // Disbilita le voci di personalizzazione + int mi; + for (mi = 2; mi <= 7; mi++) + disable_menu_item(MENU_ITEM(mi)); TMask m(TR("Scelta studio"), 1, 62, 4); m.add_button(DLG_OK, 0, "", -12, -1, 10, 2); @@ -1392,8 +1430,9 @@ bool TMenu_application::choose_study() stop_run(); // Termina applicazione } - enable_menu_item(MENU_ITEM(4)); - + // Abilita le voci di personalizzazione + for (mi = 2; mi <= 7; mi++) + enable_menu_item(MENU_ITEM(mi)); return ok; } diff --git a/ba/ba0101.cpp b/ba/ba0101.cpp index af0d4eb3a..6effe4cb5 100755 --- a/ba/ba0101.cpp +++ b/ba/ba0101.cpp @@ -307,13 +307,12 @@ bool TMenuitem::perform_program() const if (submenu().menu().mask_mode() == 3) a.run(true, 3, false); //e' un programma asincrono else + { a.run(false, 3); //e' un programma sincrono - } - - prefix().set("DEF"); // Aggiorna prefix - printer_destroy(); // Forza rilettura parametri della stampante } + } + } return ok; } @@ -362,11 +361,8 @@ void TSubmenu::read(TScanner& scanner) } else if (line.starts_with("Module", true)) { - const int equal = line.find('='); - if (equal > 0) - { bool disable = true; - TToken_string mod(line.mid(equal+1, -1), ','); + TToken_string mod(line.after('='), ','); mod.strip_spaces(); FOR_EACH_TOKEN(mod, cod) { @@ -640,6 +636,21 @@ bool TMenu::perform() return ok; } +//setta la trasparenza alle immagini con i 4 corner-pixel di colore uguale +bool TMenu::can_be_transparent(const TImage& i) const +{ + const int w = i.width()-1; + const int h = i.height()-1; + const COLOR col = i.get_pixel(0,0); + if (i.get_pixel(w,0) != col) + return false; + if (i.get_pixel(w,h) != col) + return false; + if (i.get_pixel(0,h) != col) + return false; + return true; +} + TImage& TMenu::image(const char* name) { TTimed_image* img = (TTimed_image*)_images.objptr(name); diff --git a/ba/ba0102.cpp b/ba/ba0102.cpp index 3d86119b6..a8bf2e8fb 100755 --- a/ba/ba0102.cpp +++ b/ba/ba0102.cpp @@ -508,7 +508,7 @@ void TMenulist_window::draw_item(int i) if (item.is_submenu()) { xvt_dwin_draw_icon(win(), ix, iy, 10202); - if ( ico > 0) + if (ico > 0) xvt_dwin_draw_icon(win(), ix, iy+4, ico); } else @@ -702,7 +702,7 @@ void TMenulist_window::handler(WINDOW w, EVENT* ep) if (index < _sorted.items()) { const TMenuitem& mi = (const TMenuitem&)_sorted[index]; - message_box(mi.action()); + message_box("%s\n%s", (const char*)mi.submenu().name(), (const char*)mi.action()); } else { diff --git a/ba/ba1100.cpp b/ba/ba1100.cpp index e5b33c084..056fbc91b 100755 --- a/ba/ba1100.cpp +++ b/ba/ba1100.cpp @@ -1,5 +1,6 @@ #include "ba1.h" #include "ba1100.h" +#include "ba1103.h" #include #include @@ -274,7 +275,7 @@ void TManutenzione_app::print() int i; - for (i = 2 ; !pi->iscancelled() && i <= items; i++) + for (i = LF_USER ; !pi->iscancelled() && i <= items; i++) { d.get(i); if (d.len() > 0) @@ -875,7 +876,7 @@ void TManutenzione_app::update_dir() int i; - for (i = 2; i <= update_items; i++) + for (i = LF_USER; i <= update_items; i++) { p.addstatus(1); @@ -1347,7 +1348,7 @@ void TManutenzione_app::load_des(const int maxfdir) TProgind p(items ? items : 1, s, false, true); p.setstatus(1); - for (int i = 2; i <= items; i++) + for (int i = LF_USER; i <= items; i++) { p.addstatus(1); d.get(i, _nolock, _nordir, _sysdirop); @@ -1523,6 +1524,9 @@ void TManutenzione_app::update() } utenti.close(); close_history(); + + send_campo_xml(); // Spedisce situazione via ftp + end_wait(); } diff --git a/ba/ba1103.cpp b/ba/ba1103.cpp new file mode 100755 index 000000000..83a5f7af4 --- /dev/null +++ b/ba/ba1103.cpp @@ -0,0 +1,217 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "ba1103.h" + +#include +#include +#include + +/////////////////////////////////////////////////////////// +// TFirm_isamfile +// Prossimamente nelle migliori librerie: +// praticamente un TLocalisamfile di un ditta qualsiasi, +// normalmente diversa dalla corrente. +/////////////////////////////////////////////////////////// + +class TFirm_isamfile : public TIsamtempfile +{ +protected: + static const TString& build_file_name(int logicnum, long firm); + +public: + TFirm_isamfile(int logicnum, long firm = -1); +}; + +const TString& TFirm_isamfile::build_file_name(int logicnum, long codditta) +{ + // Se codditta < 0 allora usa la ditta corrente; + // Se codditta = 0 allora usa i dati comuni + if (codditta < 0) + codditta = main_app().get_firm(); + TFilename path = firm2dir(codditta); + path.add(logic2table(logicnum)); + path.lower(); path.ext("dbf"); + if (!path.exist() && codditta > 0) + { + NFCHECK(path, "Impossibile aprire ", (const char*)path); + path = firm2dir(0L); + path.add(logic2table(logicnum)); + path.lower(); path.ext("dbf"); + } + path.insert("%"); + return get_tmp_string() = path; +} + +TFirm_isamfile::TFirm_isamfile(int lf, long codditta) + : TIsamtempfile(lf, build_file_name(lf, codditta), false, false) +{ } + +/////////////////////////////////////////////////////////// +// Utilities +/////////////////////////////////////////////////////////// + +// Costruisce il nome del file xml locale o remoto +static void build_xml_filename(TFilename& name, bool remote) +{ + const long n = dongle().number(); + name.format("%05ld", n); + if (n == 0) // Le chiavi di sviluppo sono tutte 0, uso il nome della stazione + { + char host[80]; + xvt_sys_get_host_name(host, sizeof(host)); + name << host; + name.replace(' ', '_'); + } + if (remote) + { + const TDate oggi(TODAY); + name << '_' << oggi.date2ansi(); + } + name.ext("xml"); +} + +// Cerca un tag figlio e se non lo trova lo crea. Opzionalmente lo svuota anche. +static TXmlItem& find_or_create_child(TXmlItem& root, const char* tag, bool reset = false) +{ + TXmlItem* pitem = root.FindFirstChild(tag); + if (pitem == NULL) + pitem = &root.AddChild(tag); + else + { + if (reset) + { + pitem->Destroy(); + pitem->SetTag(tag); + } + } + return *pitem; +} + +static const TString& get_last(long codditta, int lf, const char* field) +{ + TFirm_isamfile file(lf, codditta); + if (file.last() == NOERR) + return file.get(field); + return EMPTY_STRING; +} + +static int is_active_firm(long codditta) +{ + if (main_app().get_firm() == codditta) + return 2; + + if (prefix().exist(codditta)) + { + int anno = 0; + if (dongle().active(CGAUT)) + { + const TDate datareg = get_last(codditta, LF_MOV, MOV_DATAREG); + anno = datareg.year(); + } + + if (anno == 0 && dongle().active(VEAUT)) + anno = atoi(get_last(codditta, LF_DOC, DOC_ANNO)); + + if (anno > 0) + { + const TDate oggi(TODAY); + const int annoscorso = oggi.year()-1; + const int annoprossimo = annoscorso+2; + if (anno >= annoscorso && anno <= annoprossimo) + return 1; + } + } + + return 0; +} + +// Salva o aggiorna il file xml coi dati di installazione +bool save_campo_xml() +{ + TFilename filename; build_xml_filename(filename, false); + + TXmlItem root; + if (!root.Load(filename)) + root.SetTag("Campo"); + + if (prefix_valid()) + { + TXmlItem& study = find_or_create_child(root, "study", true); + TRecordset* recset = create_recordset("USE NDITTE"); + for (bool ok = recset->move_first(); ok; ok = recset->move_next()) + { + const long codditta = recset->get(NDT_CODDITTA).as_int(); + const int flag = is_active_firm(codditta); + if (flag != 0) + { + TXmlItem& firm = study.AddChild("firm"); + firm.SetAttr(NDT_CODDITTA, codditta); + firm.SetAttr(NDT_RAGSOC, recset->get(NDT_RAGSOC).as_string()); + firm.SetAttr("Current", flag == 2); + } + } + delete recset; + } + + TXmlItem& study = find_or_create_child(root, "study"); + char host[_MAX_PATH]; + xvt_sys_get_host_name(host, sizeof(host)); + study.SetAttr("Host", host); + study.SetAttr("DataPath", firm2dir(-1)); + study.SetAttr("ExePath", main_app().argv(0)); + + const TDongle& d = dongle(); + TXmlItem& chiavetta = find_or_create_child(root, "dongle", true); + chiavetta.SetAttr("Number", d.number()); + chiavetta.SetAttr("Users", d.max_users()); + chiavetta.SetAttr("Year", d.year_assist()); + chiavetta.SetAttr("Update", d.last_update().string()); + + TConfig ini("install.ini", "Main"); + for (word m = 1; m < ENDAUT; m++) if (d.active(m)) + { + const TString4 name = d.module_code2name(m); + const TString& version = ini.get("Versione", name); + if (version.full()) + { + TXmlItem& module = chiavetta.AddChild("module"); + module.SetAttr("Code", name); + module.SetAttr("Version", version); + module.SetAttr("Patch", ini.get("Patch")); + } + } + + root.Save(filename); + return filename.exist(); +} + +// Aggiorna il file xml coi dati di installazione e lo spedisce qua +bool send_campo_xml() +{ + bool ok = false; + if (save_campo_xml()) + { + if (xvt_net_get_status() & 0x7) + { + TSocketClient aga; + CONNID id = aga.QueryConnection("21", "www.aga.it"); + if (id > 0) + { + TFilename local, remote; + build_xml_filename(local, false); + build_xml_filename(remote, true); + ok = aga.FtpSendFile(id, remote, local, "attivazioni", "viagra"); + aga.RemoveConnection(id); + } + } + } + return ok; +} diff --git a/ba/ba1103.h b/ba/ba1103.h new file mode 100755 index 000000000..27d54c8eb --- /dev/null +++ b/ba/ba1103.h @@ -0,0 +1,6 @@ +#ifndef __BA1103_H +#define __BA1103_H + +bool send_campo_xml(); + +#endif diff --git a/ba/ba1500.cpp b/ba/ba1500.cpp index 0b77b6596..b49cad288 100755 --- a/ba/ba1500.cpp +++ b/ba/ba1500.cpp @@ -198,6 +198,11 @@ class TAttivazione_moduli : public TSkeleton_application word _serno; word _wanted_users, _wanted_assist; +private: + void garble_dongle(word k[4]) const; + const TString& garble_md5(const char* strin) const; + const TString& garble_md5(long numin) const; + protected: virtual bool create() ; virtual bool destroy() ; @@ -205,10 +210,9 @@ protected: virtual bool use_files() const { return false; } virtual bool test_assistance_year() const; - void garble(word k[4]) const; - void garble(word n, TString& str) const; - void garble_user(word u, TString& str) const; - void garble_year(word u, TString& str) const; + void garble_module(word n, TString& str1, TString& str2) const; + void garble_users(word u, TString& str1, TString& str2) const; + void garble_year(word year, TString& str1, TString& str2) const; word& serno() { return _serno; } @@ -224,9 +228,6 @@ protected: static void keyext(const TString & s, word * v); static void encode_second_key(); -// static bool user_hnd(TMask_field& f, KEY k); -// static bool decode_hnd(TMask_field& f, KEY k); -// static bool activate_hnd(TMask_field& f, KEY k); static bool date_hnd(TMask_field& f, KEY k); static bool serno_hnd(TMask_field& f, KEY k); @@ -440,12 +441,12 @@ int TAttivazione_moduli::build_sheet(bool on) return nmod; } -void TAttivazione_moduli::garble(word k[4]) const +void TAttivazione_moduli::garble_dongle(word k[4]) const { ::dongle().garble(k); } -void TAttivazione_moduli::garble(word n, TString& str) const +void TAttivazione_moduli::garble_module(word n, TString& str1, TString& str2) const { const TDate today(_msk->get(F_DT)); const long val = today.date2julian(); @@ -455,11 +456,31 @@ void TAttivazione_moduli::garble(word n, TString& str) const data[1] = word(val >> 16); data[2] = n; data[3] = word(val & 0xFFFF); - garble(data); - str.format("%04X%04X", data[0], data[1]); + garble_dongle(data); + str1.format("%04X%04X", data[0], data[1]); + + str2 = ::dongle().module_code2name(n); + str2.upper(); + str2 = garble_md5(str2); } -void TAttivazione_moduli::garble_user(word u, TString& str) const +const TString& TAttivazione_moduli::garble_md5(const char* strin) const +{ + const TDate today(_msk->get(F_DT)); + TString80 chiaro, cifrato; + chiaro.format("%8ld%d%s", today.date2ansi(), _msk->get_int(F_SN), strin); + xvt_str_md5(chiaro, cifrato.get_buffer(32)); + cifrato.upper(); + return cifrato.right(8); +} + +const TString& TAttivazione_moduli::garble_md5(long numin) const +{ + TString16 strin; strin.format("%ld", numin); + return garble_md5(strin); +} + +void TAttivazione_moduli::garble_users(word u, TString& str1, TString& str2) const { const TDate today(_msk->get(F_DT)); const long val = today.date2julian(); @@ -469,11 +490,13 @@ void TAttivazione_moduli::garble_user(word u, TString& str) const data[1] = word(val >> 16); data[2] = word(_msk->get_int(F_SN)); data[3] = word(val & 0xFFFF); - garble(data); - str.format("%04X%04X", data[0], data[1]); + garble_dongle(data); + str1.format("%04X%04X", data[0], data[1]); + + str2 = garble_md5(u); } -void TAttivazione_moduli::garble_year(word y, TString& str) const +void TAttivazione_moduli::garble_year(word y, TString& str1, TString& str2) const { const TDate today(_msk->get(F_DT)); const long val = today.date2julian(); @@ -483,8 +506,10 @@ void TAttivazione_moduli::garble_year(word y, TString& str) const data[1] = word(val >> 16); data[2] = y; data[3] = word(val & 0xFFFF); - garble(data); - str.format("%04X%04X", data[0], data[1]); + garble_dongle(data); + str1.format("%04X%04X", data[0], data[1]); + + str2 = garble_md5(y); } void TAttivazione_moduli::build_key_column() @@ -492,14 +517,14 @@ void TAttivazione_moduli::build_key_column() TSheet_field& sf = _msk->sfield(F_MODULI); sf.enable_column(F_KEY, false); - TString16 tmp; + TString8 tmp1, tmp2; FOR_EACH_SHEET_ROW_BACK(sf, i, riga) { if (!sf.cell_disabled(i, 1)) { int module = riga->get_int(2); - garble(module, tmp); - riga->add(tmp, 3); + garble_module(module, tmp1, tmp2); + riga->add(tmp1, 3); } } sf.force_update(); @@ -514,7 +539,7 @@ bool TAttivazione_moduli::burn_dongle() bool ok = din.type() == _user_dongle; if (ok) { - TString16 str, key; + TString16 key; TSheet_field& sf = _msk->sfield(F_MODULI); FOR_EACH_SHEET_ROW(sf, i, riga) @@ -523,8 +548,9 @@ bool TAttivazione_moduli::burn_dongle() if (key.not_empty()) { const int module = riga->get_int(2); - garble(module, str); - const bool good = key == str; + TString8 str1, str2; + garble_module(module, str1, str2); + const bool good = (key == str1) || (key == str2); if (good) { if (!din.active(module) && @@ -561,9 +587,9 @@ bool TAttivazione_moduli::maxuser_handler(TMask_field& fld, KEY key) const int utenti = atoi(fld.get()); if (utenti > 0 && utenti < 10000) { - TString16 str; - app().garble_user(utenti, str); - fld.mask().set(102, str); + TString8 str1, str2; + app().garble_users(utenti, str1, str2); + fld.mask().set(102, str1); } else ok = fld.error_box(TR("Numero di utenti errato")); @@ -595,7 +621,7 @@ bool TAttivazione_moduli::change_users_handler(TMask_field& fld, KEY key) const int utenti = m.get_int(101); if (dongle.type() == _user_dongle) { - if (utenti > 0 && utenti < 10000) + if (utenti > 0 && utenti < 1000) { if (m.field(102).empty()) { @@ -606,9 +632,9 @@ bool TAttivazione_moduli::change_users_handler(TMask_field& fld, KEY key) } else { - TString16 str; - app().garble_user(utenti, str); - if (str == m.get(102)) + TString8 str1, str2; + app().garble_users(utenti, str1, str2); + if ((m.get(102) == str1) || (m.get(102) == str2)) { dongle.set_max_users(utenti); fld.mask().set(F_USERS, utenti); @@ -627,17 +653,20 @@ bool TAttivazione_moduli::change_users_handler(TMask_field& fld, KEY key) return true; } +#define YEAR_MIN 2007 +#define YEAR_MAX 2777 + bool TAttivazione_moduli::assist_handler(TMask_field& fld, KEY key) { bool ok = true; if (key == K_TAB && fld.focusdirty()) { const int year = atoi(fld.get()); - if (year >= 1997 && year <= 2997) + if (year >= YEAR_MIN && year <= YEAR_MAX) { - TString16 str; - app().garble_year(year, str); - fld.mask().set(102, str); + TString16 str1, str2; + app().garble_year(year, str1, str2); + fld.mask().set(102, str1); } else ok = fld.error_box(TR("Anno errato")); @@ -669,7 +698,7 @@ bool TAttivazione_moduli::change_assist_handler(TMask_field& fld, KEY key) word year = m.get_int(101); if (dongle.type() == _user_dongle) { - if (year >= 1997 && year <= 2997) + if (year >= YEAR_MIN && year <= YEAR_MAX) { if (m.field(102).empty()) { @@ -679,13 +708,11 @@ bool TAttivazione_moduli::change_assist_handler(TMask_field& fld, KEY key) } else { - TString16 str; - app().garble_year(year, str); - bool ok = str == m.get(102); + TString16 str1, str2; + app().garble_year(year, str1, str2); + bool ok = (m.get(102) == str1) || (m.get(102) == str2); if (ok) { - if (year <= 1997) - year = 0; dongle.set_year_assist(year); fld.mask().set(F_ASSIST, year); } @@ -751,32 +778,9 @@ void TAttivazione_moduli::init_mask() const int nmod = build_sheet(); const TDongle& d = ::dongle(); if (d.hardware() == _dongle_hardlock) - { -/* - word ud[4]; - d.read_words(48, 4, ud); - _msk->set(F_K2, format("%04X%04X%04X%04X", ud[0], ud[1], ud[2], ud[3])); - - ud[0] = d.number(); - ud[1] = K1 | (nmod & LBYTEMASK); - long& l = (long&)ud[2]; - l = oggi.year()*10000L + oggi.month()*100L + oggi.day(); - - garble(ud); - _msk->set(F_K1, format("%04X%04X%04X%04X", ud[0], ud[1], ud[2], ud[3])); -*/ _msk->set_caption(TR("Attivazione HARDLOCK")); - } else - { -/* - _msk->hide(F_K1); - _msk->hide(F_K2); - _msk->hide(F_K3); - _msk->hide(F_K4); -*/ _msk->set_caption(TR("Attivazione EUTRON")); - } _msk->set(F_SN, d.number()); _msk->set(F_DT, oggi); @@ -784,93 +788,10 @@ void TAttivazione_moduli::init_mask() _msk->set(F_ASSIST, d.year_assist()); } -/* - -#define BITTEST(w,p) (((w) & (0x0001 << (p))) != 0) -#define BITSET(w,p,v) ((v) ? ((w) |= (0x0001 << (p))) : ((w) &= (~(0x0001 << (p))))) -#define K1 0x4500 -#define LBYTEMASK 0x00FF -#define UBYTEMASK 0xFF00 - -inline int hexdigit(char c) -{ return c >= 'A' ? (c - 'A' + 10) : (c - '0'); } - -void TAttivazione_moduli::keyext(const TString& s, word * val) -{ - for (int i = 0 ; i < 4; i++) - { - const int off = i * 4; - word & l = val[i]; - - l = 0; - for (int j = 0; j < 4; j++) - l = l * 16 + hexdigit(s[off + j]); - } -} - -bool TAttivazione_moduli::user_hnd(TMask_field & f, KEY k) -{ - const TString16 k4(f.get()); - if (!f.to_check(k) || k4.empty()) - return true; - - TMask & m = f.mask(); - word ud1[4], ud2[4]; - const TString16 k3(m.get(F_K3)); - - keyext(k3, ud1); - keyext(k4, ud2); - - app().garble(ud1); - const long & l = (long &) ud1[0]; - TDate d(l), d1(TODAY); - - d.addmonth(3); - if (d < d1) - { - f.error_box(TR("Data non valida")); - return k != K_ENTER; - } - if ((ud1[2] & UBYTEMASK) != K1 || ud1[3] != app().serno()) - { - f.error_box(TR("Primo codice errato")); - return k != K_ENTER; - } - - app().garble(ud2); - for (int i = 0; i < 4; i++) ud2[i] ^= app().serno(); - if (ud2[3] != 0) - { - f.error_box(TR("Secondo codice errato")); - return k != K_ENTER; - } - TSheet_field& sf = (TSheet_field&) m.field(F_MODULI); - const int un = app()._im->unassigned(); - for (i = un; i < MAX_AUT; i++) - { - const int af = app()._im->get_module_by_order(i) - 1; - if (af < 0) continue; - TToken_string& tt = sf.row(i-un); - tt.add(BITTEST(ud2[af / 16], af % 16) ? "X" : " ", 1); - } - if (k == K_ENTER) - { - keyext(k4, ud2); - if (::dongle().write_words(48, 4, ud2)) - message_box(TR("Programmazione effettuata con successo")); - } - else - sf.force_update(); - return true; -} -*/ - bool TAttivazione_moduli::serno_hnd(TMask_field& f, KEY k) { if (k == K_TAB && f.focusdirty()) - { app().build_key_column(); - } return true; } @@ -894,92 +815,6 @@ bool TAttivazione_moduli::date_hnd(TMask_field& f, KEY k) return true; } -/* -void TAttivazione_moduli::encode_second_key() -{ - TMask * m = app()._msk; - word ud1[4], ud2[4]; - int nmod = 0; - - for (int i = 0; i < 4; i++) ud2[i] = 0; - TSheet_field& sf = (TSheet_field&) m->field(F_MODULI); - const int un = app()._im->unassigned(); - for (i = un; i < MAX_AUT; i++) - { - const int af = app()._im->get_module_by_order(i) -1; - if (af < 0) continue; - TToken_string& tt = sf.row(i-un); - if (tt.get(1)[0] == 'X') - { - BITSET(ud2[af / 16], af % 16, true); - nmod++; - } - } - for (i = 0; i < 4; i++) ud2[i] ^= app().serno(); - - const TDate d(m->get(F_DT)); - long & l = (long &) ud1[0]; - - l = d.year()*10000L + d.month()*100L + d.day(); - ud1[2] = K1 | (nmod & UBYTEMASK); - ud1[3] = app().serno(); - - app().garble(ud1); - m->set(F_K3, format("%04X%04X%04X%04X", ud1[0], ud1[1], ud1[2], ud1[3])); - - app().garble(ud2); - m->set(F_K4, format("%04X%04X%04X%04X", ud2[0], ud2[1], ud2[2], ud2[3])); -} - -bool TAttivazione_moduli::decode_hnd(TMask_field & f, KEY k) -{ - const TString16 k2(f.get()); - if (!f.to_check(k) || k2.empty()) - return true; - - TMask& m = f.mask(); - word ud1[4], ud2[4]; - const TString16 k1(m.get(F_K1)); - - keyext(k1, ud1); - keyext(k2, ud2); - - app().garble(ud1); - long & l = (long &) ud1[2]; - const TDate d(l); - app().serno() = ud1[0]; - if ((ud1[1] & UBYTEMASK) != K1) - return f.error_box(TR("Primo codice errato")); - - app().garble(ud2); - for (int i = 0; i < 4; i++) ud2[i] ^= app().serno(); - if (ud2[3] != 0) - return f.error_box(TR("Secondo codice errato")); - m.set(F_SN, app().serno()); - m.set(F_DT, d); - m.set(F_K3,k1); - m.set(F_K4,k2); - TSheet_field& sf = (TSheet_field&) m.field(F_MODULI); - const int un = app()._im->unassigned(); - for (i = un; i < MAX_AUT; i++) - { - const int af = app()._im->get_module_by_order(i) -1; - if (af < 0) continue; - TToken_string& tt = sf.row(i-un); - tt.add(BITTEST(ud2[af / 16], af % 16) ? "X" : " ", 1); - } - encode_second_key(); - sf.force_update(); - return true; -} - -bool TAttivazione_moduli::activate_hnd(TMask_field & f, KEY k) -{ - encode_second_key(); - return true; -} -*/ - bool TAttivazione_moduli::k_notify(TSheet_field& f, int r, KEY k) { if (k == K_INS || k == K_DEL) @@ -1211,8 +1046,9 @@ void TAttivazione_moduli::print_answer() str.format(FR("Variazione del numero utenti da %u a %u"), ::dongle().max_users(), _wanted_users); descr.set(str); - garble_user(_wanted_users, str); - codice.set(str); + TString8 str1, str2; + garble_users(_wanted_users, str1, str2); + codice.set(str1); form.print(-1); } if (_wanted_assist != 0) @@ -1221,8 +1057,9 @@ void TAttivazione_moduli::print_answer() num.set(str); str.format(FR("Contratto di assistenza per l'anno %u"), _wanted_assist); descr.set(str); - garble_year(_wanted_assist, str); - codice.set(str); + TString8 str1, str2; + garble_year(_wanted_assist, str1, str2); + codice.set(str1); form.print(-1); } } @@ -1346,6 +1183,9 @@ bool TAttivazione_moduli::create() if (!ok) return false; + if (::dongle().hardware() == _dongle_network) + return error_box(TR("Questo programma non puo' funzionare mentre e' in funzione il server di autorizzazioni")); + ok = TApplication::test_assistance_year(); #ifdef DBG // Backdoor nascosta per la cifratura del dninst.zip @@ -1396,29 +1236,12 @@ bool TAttivazione_moduli::create() _msk->enable(F_DT); _msk->set_handler(F_DT, date_hnd); case _developer_dongle: -/* - if (::dongle().hardware() == _dongle_hardlock) - { - _msk->disable(F_K1); - _msk->disable(F_K2); - _msk->set_handler(F_K4, user_hnd); - } -*/ init_mask(); - _serno=_msk->get_int(F_SN); sf.enable_column(F_ENABLE, serno() != 0); sf.enable_column(F_KEY, serno() != 0); break; case _aga_dongle: - /* - if (::dongle().hardware() == _dongle_hardlock) - { - _msk->set_handler(F_K2, decode_hnd); - _msk->disable(F_K3); - _msk->disable(F_K4); - sf.sheet_mask().field(F_ENABLE).set_handler(activate_hnd); - }*/ _msk->set_handler(F_SN, serno_hnd); _msk->enable(F_SN); init_mask(); @@ -1456,9 +1279,9 @@ int ba1500(int argc, char** argv) if (user() == ::dongle().administrator()) { TAttivazione_moduli a ; - a.run(argc, argv, FR("Attivazione moduli")); + a.run(argc, argv, TR("Attivazione moduli")); } else error_box(FR("L'utente %s non e' abilitato all'esecuzione di questo programma"), (const char*)user()); return 0; -} \ No newline at end of file +} diff --git a/ba/ba1700.cpp b/ba/ba1700.cpp index 767305d26..5fc7d349e 100755 --- a/ba/ba1700.cpp +++ b/ba/ba1700.cpp @@ -81,10 +81,7 @@ static int compare_modules(const TObject** o1, const TObject** o2) bool is_internet_path(const TString& addr) { - if (addr.compare("www.", 4, true) == 0) - return true; - - if (addr.compare("http:", 5, true) == 0) + if (addr.starts_with("www.", true) || addr.starts_with("http:", true)) return true; int a1, a2, a3, a4; diff --git a/ba/ba4500.h b/ba/ba4500.h index a32ecfa57..f89e832b6 100755 --- a/ba/ba4500.h +++ b/ba/ba4500.h @@ -136,5 +136,6 @@ #define FLD_AT1_CODDITTAH 198 #define FLD_AT1_CODATTH 199 #define F_ATTPREV 200 +#define F_CODATECO 201 #endif // __BA4500_H diff --git a/ba/ba4500a.uml b/ba/ba4500a.uml index b78234d54..b6837a064 100755 --- a/ba/ba4500a.uml +++ b/ba/ba4500a.uml @@ -104,48 +104,12 @@ BEGIN HELP "Nome dell'attivita'" END -NUMBER FLD_AT1_OLDCODATT 4 +STRING F_CODATECO 6 BEGIN - PROMPT 1 6 "Vecchio codice " - FIELD LF_ATTIV->OLDCODATT + PROMPT 1 6 "Codice attivitą ATECO " + FIELD LF_ATTIV->CODATECO FLAGS "RZ" - USE %OIS - INPUT CODTAB[1,4] FLD_AT1_OLDCODATT - INPUT CODTAB[5,] FLD_AT1_SUBCOD - DISPLAY "Codice" CODTAB[1,4] - DISPLAY "Subcodice" CODTAB[5,] - DISPLAY "Attivita'@50" S0 - OUTPUT FLD_AT1_OLDCODATT CODTAB[1,4] - OUTPUT FLD_AT1_SUBCOD CODTAB[5,] - OUTPUT FLD_AT1_OLDCODATT_OLDATT_DESCR S0 - HELP "Vecchio codice attivita'" - CHECKTYPE NORMAL - WARNING "Attivita' assente" -END - -STRING FLD_AT1_SUBCOD 1 -BEGIN - PROMPT 25 6 "Subcodice " - FIELD LF_ATTIV->SUBCOD - FLAGS "U" - COPY ALL FLD_AT1_OLDCODATT - HELP "Subcodice del vecchio codice attivita'" - CHECKTYPE NORMAL - WARNING "Attivita' assente" -END - -STRING FLD_AT1_OLDCODATT_OLDATT_DESCR 50 -BEGIN - PROMPT 1 7 "Nome " - USE %OIS KEY 2 - INPUT S0 FLD_AT1_OLDCODATT_OLDATT_DESCR - DISPLAY "Attivita'@50" S0 - DISPLAY "Codice" CODTAB[1,4] - DISPLAY "Subcodice" CODTAB[5,] - COPY OUTPUT FLD_AT1_OLDCODATT - HELP "Vecchio codice attivita'" - CHECKTYPE NORMAL - WARNING "Attivita' assente" + CHECKTYPE REQUIRED END DATE FLD_AT1_DATAISCIVA @@ -487,6 +451,50 @@ BEGIN HELP "Indicare se vengono tenuti scritture parziali" END +NUMBER FLD_AT1_OLDCODATT 4 +BEGIN + PROMPT 1 18 "Vecchio codice " + FIELD LF_ATTIV->OLDCODATT + FLAGS "RZ" + USE %OIS + INPUT CODTAB[1,4] FLD_AT1_OLDCODATT + INPUT CODTAB[5,] FLD_AT1_SUBCOD + DISPLAY "Codice" CODTAB[1,4] + DISPLAY "Subcodice" CODTAB[5,] + DISPLAY "Attivita'@50" S0 + OUTPUT FLD_AT1_OLDCODATT CODTAB[1,4] + OUTPUT FLD_AT1_SUBCOD CODTAB[5,] + OUTPUT FLD_AT1_OLDCODATT_OLDATT_DESCR S0 + HELP "Vecchio codice attivita'" + CHECKTYPE NORMAL + WARNING "Attivita' assente" +END + +STRING FLD_AT1_SUBCOD 1 +BEGIN + PROMPT 25 18 "Subcodice " + FIELD LF_ATTIV->SUBCOD + FLAGS "U" + COPY ALL FLD_AT1_OLDCODATT + HELP "Subcodice del vecchio codice attivita'" + CHECKTYPE NORMAL + WARNING "Attivita' assente" +END + +STRING FLD_AT1_OLDCODATT_OLDATT_DESCR 50 +BEGIN + PROMPT 1 19 "Nome " + USE %OIS KEY 2 + INPUT S0 FLD_AT1_OLDCODATT_OLDATT_DESCR + DISPLAY "Attivita'@50" S0 + DISPLAY "Codice" CODTAB[1,4] + DISPLAY "Subcodice" CODTAB[5,] + COPY OUTPUT FLD_AT1_OLDCODATT + HELP "Vecchio codice attivita'" + CHECKTYPE NORMAL + WARNING "Attivita' assente" +END + ENDPAGE ENDMASK diff --git a/ba/ba8300.cpp b/ba/ba8300.cpp index edb70fd8e..7df491455 100755 --- a/ba/ba8300.cpp +++ b/ba/ba8300.cpp @@ -458,7 +458,7 @@ bool TReport_mask::select_query() bool TReport_mask::get_rep_path(TFilename& path) const { const TString& name = get(F_CODICE); - const bool ok = name.not_empty(); + const bool ok = name.full(); if (ok) { path = name; diff --git a/ba/ba8300b.uml b/ba/ba8300b.uml index ad0be4359..7092b6251 100755 --- a/ba/ba8300b.uml +++ b/ba/ba8300b.uml @@ -163,6 +163,7 @@ BEGIN ITEM "1|Sottile" ITEM "2|Normale" ITEM "3|Spesso" + ITEM "4|Molto spesso" END STRING F_RADIUS 4 diff --git a/ba/ba8300c.uml b/ba/ba8300c.uml index 8e67300e8..a94c40d38 100755 --- a/ba/ba8300c.uml +++ b/ba/ba8300c.uml @@ -150,6 +150,7 @@ BEGIN ITEM "1|Sottile" ITEM "2|Normale" ITEM "3|Spesso" + ITEM "4|Molto spesso" END STRING F_RADIUS 4 diff --git a/ba/ba8300d.uml b/ba/ba8300d.uml index 5fbf88804..0afed0b30 100755 --- a/ba/ba8300d.uml +++ b/ba/ba8300d.uml @@ -34,6 +34,16 @@ BEGIN PROMPT 26 2 "Raggruppa piu' pagine in un foglio" END +BOOLEAN F_PAGE_SPLIT +BEGIN + PROMPT 26 1 "Suddividi una pagina su piu' fogli" +END + +BOOLEAN F_PAGE_MERGE +BEGIN + PROMPT 26 2 "Raggruppa piu' pagine in un foglio" +END + NUMBER F_DY 2 BEGIN PROMPT 26 3 "Linee per pollice " diff --git a/ba/ba8301.cpp b/ba/ba8301.cpp index b3747c011..42c13479a 100755 --- a/ba/ba8301.cpp +++ b/ba/ba8301.cpp @@ -1595,7 +1595,7 @@ void TReport_window::draw_grid() for (int i = x/k; i > 0; i--) { - set_pen(i%10 ? MAKE_COLOR(232,232,255) : MAKE_COLOR(255,192,255)); + set_pen(i%10 ? XVT_MAKE_COLOR(232,232,255) : XVT_MAKE_COLOR(255,192,255)); line(0, i*k, x, i*k); line(i*k, 0, i*k, y <= 0 ? x : y); } @@ -1802,8 +1802,8 @@ void TReport_window::draw_bg() void TReport_window::update() { clear(COLOR_WHITE); - draw_grid(); // Disegna griglia draw_bg(); + draw_grid(); // Disegna griglia const TRectangle rect_riga(0,0,1000,100); RCT rct_riga; TWindow::log2dev(rect_riga, rct_riga); diff --git a/ba/bainst31.cpp b/ba/bainst31.cpp index 94b8a91cf..a83acf150 100755 --- a/ba/bainst31.cpp +++ b/ba/bainst31.cpp @@ -1,5 +1,4 @@ #include -#include #include "bainstlib.h" diff --git a/ba/batbtrb.h b/ba/batbtrb.h index 399876663..f368ea474 100755 --- a/ba/batbtrb.h +++ b/ba/batbtrb.h @@ -3,6 +3,10 @@ #define F_CODICE 101 #define F_DESCR 102 #define F_SEZIONE 103 +#define F_GRUPPO 104 +#define F_CONTO 105 +#define F_SOTTOC 106 +#define F_DESCRC 107 diff --git a/ba/batbtrb.uml b/ba/batbtrb.uml index 15bc0fa85..f44312da9 100755 --- a/ba/batbtrb.uml +++ b/ba/batbtrb.uml @@ -8,7 +8,7 @@ ENDPAGE PAGE "Tabella Codici Tributo" -1 -1 78 8 -GROUPBOX DLG_NULL 75 7 +GROUPBOX DLG_NULL 75 6 BEGIN PROMPT 1 0 "" FLAGS "R" @@ -46,7 +46,7 @@ END LIST F_SEZIONE 1 50 BEGIN - PROMPT 4 5 "Sezione " + PROMPT 4 6 "Sezione " ITEM "E|Erario" ITEM "I|INPS" ITEM "R|Regioni" @@ -55,6 +55,52 @@ BEGIN FIELD S6 END +NUMBER F_GRUPPO 3 +BEGIN + PROMPT 4 8 "Conto " + FIELD I0 + CHECKTYPE NORMAL +END + +NUMBER F_CONTO 3 +BEGIN + PROMPT 23 8 "" + FIELD I1 + CHECKTYPE NORMAL +END + +NUMBER F_SOTTOC 6 +BEGIN + PROMPT 30 8 "" + FIELD I2 + USE LF_PCON KEY 1 SELECT SOTTOCONTO!="" + INPUT GRUPPO F_GRUPPO + INPUT CONTO F_CONTO + INPUT SOTTOCONTO F_SOTTOC + DISPLAY "Gruppo" GRUPPO + DISPLAY "Conto" CONTO + DISPLAY "Sottoconto" SOTTOCONTO + DISPLAY "Descrizione@50" DESCR + OUTPUT F_GRUPPO GRUPPO + OUTPUT F_CONTO CONTO + OUTPUT F_SOTTOC SOTTOCONTO + OUTPUT F_DESCRC DESCR + CHECKTYPE NORMAL +END + +STRING F_DESCRC 50 +BEGIN + PROMPT 4 9 "Descrizione " + USE LF_PCON KEY 2 + INPUT DESCR F_DESCRC + DISPLAY "Descrizione@50" DESCR + DISPLAY "Gruppo" GRUPPO + DISPLAY "Conto" CONTO + DISPLAY "Sottoconto" SOTTOCONTO + COPY OUTPUT F_SOTTOC + CHECKTYPE NORMAL +END + ENDPAGE ENDMASK diff --git a/ba/f10.dir b/ba/f10.dir index 560575a8b..7201eb4a0 100755 --- a/ba/f10.dir +++ b/ba/f10.dir @@ -1,3 +1,3 @@ 10 1 -%attiv|0|0|203|0|Attivita'|#9|| +%attiv|0|0|209|0|Attivita'|#9|| diff --git a/ba/f10.trr b/ba/f10.trr index 85b25e386..4e40b6ec9 100755 --- a/ba/f10.trr +++ b/ba/f10.trr @@ -1,5 +1,5 @@ 10 -31 +32 CODDITTA|3|5|0| CODATT|1|5|0| ATTPREV|8|1|0| @@ -31,5 +31,6 @@ MEDCONV|8|1|0| ATTLAVDIP|8|1|0| ART74_4|8|1|0| TIPOATT|1|1|0| +CODATECO|1|6|0|Codice Attivitą ATECO 2007 1 CODDITTA+CODATT|