From 1a28a590a081d1bf87a13fc282686a1298b464c7 Mon Sep 17 00:00:00 2001 From: guy Date: Tue, 3 Apr 2007 11:06:56 +0000 Subject: [PATCH] Patch level : 4.0 Files correlati : ba0 ba1 Ricompilazione Demo : [ ] Commento : Aggiunto supporto per scadenza password e nomi utenti lunghi (16 caratteri invece di solo 8) git-svn-id: svn://10.65.10.50/trunk@15170 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- ba/ba0100.cpp | 158 ++++++++++++++++++++++--------------------------- ba/ba0100a.h | 26 ++++---- ba/ba0100a.uml | 15 +++-- ba/ba0102.cpp | 12 ++-- ba/ba1101.cpp | 16 +---- ba/ba1400.cpp | 1 + ba/ba1400a.uml | 60 +++++++++++++------ ba/ba8301.cpp | 9 ++- 8 files changed, 149 insertions(+), 148 deletions(-) diff --git a/ba/ba0100.cpp b/ba/ba0100.cpp index b9d7ccd8a..27564c981 100755 --- a/ba/ba0100.cpp +++ b/ba/ba0100.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include @@ -62,7 +61,7 @@ protected: // TApplication virtual void on_firm_change(); virtual bool test_assistance_year() const; - const TString& ask_user_password(); + bool ask_user_password(TString& utente); protected: void deconnect_user(); @@ -259,17 +258,15 @@ void TPicture_mask::set_current(const TSubmenu& sm) TPicture_mask::TPicture_mask(const char* name, int dx, int dy, const TSubmenu& submenu, int x, int y) - : TMask(name, 1, dx, dy, x, y), _submenu(NULL), _logo(NULL) + : TMask(name, 1, dx, dy, x, y), _submenu(NULL), _logo(NULL) { set_current(submenu); TFilename logoname; const char* const ext[] = { "jpg", "png", "gif", "bmp", NULL }; for (int i = 0; ext[i]; i++) { - logoname = "logo"; - logoname << '.' << ext[i]; + logoname = "logo."; logoname << ext[i]; if (logoname.custom_path()) - break; } TImage logo(logoname); @@ -455,10 +452,15 @@ void TExplorer_mask::draw_spider(int mode, const PNT& mouse) const xvt_dwin_draw_oval(w, &rct); } - // Disegno la boccuccia aperta se gli occhi sono incrociati - xvt_dwin_set_std_cbrush(w, abs(mouse.h-p0.h) <= 2 ? TL_BRUSH_WHITE : TL_BRUSH_BLACK); + // Disegno la boccuccia aperta se il mouse e' vicino + const int dx = mouse.h-p0.h, dy = mouse.v-p0.v; + const bool vicino = dx*dx+dy*dy < 65536; + xvt_dwin_set_std_cbrush(w, vicino ? TL_BRUSH_WHITE : TL_BRUSH_BLACK); xvt_rect_set(&rct, p0.h-eye, p0.v, p0.h+eye, p0.v+eye); xvt_dwin_draw_oval(w, &rct); + + // Il puntatore del mouse diventa una mosca vicino al ragno + xvt_win_set_cursor(w, vicino ? 8883 : CURSOR_ARROW); } } @@ -945,11 +947,10 @@ void TMenu_application::reload_images() _menu.reload_images(); } -const TString& TMenu_application::ask_user_password() +bool TMenu_application::ask_user_password(TString& utente) { - TString16 utente = user(); + bool ok = false; -#ifndef _DEMO_ // Disabilita le voci di personalizzazione int mi; for (mi = 2; mi <= 7; mi++) @@ -972,7 +973,6 @@ const TString& TMenu_application::ask_user_password() TLocalisamfile& users = e.browse()->cursor()->file(); TString pwd; - bool ok = false; for (int i = 0; i < 3 && !ok; i++) { if (utente.not_empty() && utente != dongle().administrator()) @@ -980,7 +980,6 @@ const TString& TMenu_application::ask_user_password() m.set(F_USER, utente); m.first_focus(F_PASSWORD); } - if (m.run() == K_ESC) break; @@ -1013,7 +1012,7 @@ const TString& TMenu_application::ask_user_password() if (ok) { - if (users.get_bool("CONNECTED")) + if (users.get_bool(USR_CONNECTED)) { ok = yesno_box("%s\n%s", TR("L'utente risulta essere già collegato"), @@ -1027,7 +1026,7 @@ const TString& TMenu_application::ask_user_password() } } - if (ok && utente != dongle().administrator() && users.curr().exist(USR_DATAPWD)) + if (ok && users.curr().exist(USR_DATAPWD)) { TConfig studio_ini(CONFIG_STUDIO, "Main"); const long expiration = studio_ini.get_long("PasswordExpiration"); @@ -1050,7 +1049,7 @@ const TString& TMenu_application::ask_user_password() } if (runba) { - warning_box(TR("La password e' scaduta o vuota:\ne' necessario inserirne una nuova")); + warning_box(TR("E' necessario inserire una nuova password")); user() = utente; TExternal_app app("ba1 -3"); app.run(); @@ -1059,84 +1058,75 @@ const TString& TMenu_application::ask_user_password() } } - if (!ok) - utente.cut(0); - // Abilita le voci di personalizzazione for (mi = 2; mi <= 7; mi++) enable_menu_item(MENU_ITEM(mi)); -#endif - return get_tmp_string() = utente; + return ok; } bool TMenu_application::check_user() { - bool ok = false; - -#ifndef _DEMO_ - TString utente = user(); - - if (_mask == NULL) // Primo login della sessione; - { - TConfig campo_ini(CONFIG_INSTALL, "Main"); - const bool use_system_user = campo_ini.get_bool("AutoLogin"); - if (use_system_user) - ok = !cache().get(LF_USER, utente).empty(); - } - + bool ok = dongle().type() == _no_dongle; if (!ok) { - utente = ask_user_password(); - ok = utente.full(); - } + TString utente = user(); - if (ok) - { - const TString& autstr = cache().get(LF_USER, dongle().administrator(), USR_AUTSTR); - if (autstr == "CONVERTING") + if (_mask == NULL) // Primo login della sessione; { - TString msg; msg << TR("E' in corso una conversione archivi") << ":\n"; - if (utente == dongle().administrator()) - { - msg << TR("Si desidera continuare ugualmente?"); - ok = yesno_box(msg); - } - else - { - msg << TR("Accesso negato."); - ok = error_box(msg); - } - } - - if (ok) - { - dongle().logout(); - user() = utente; - ok = get_serial_number() >= 0; - if (!ok) - error_box(TR("Probabilmente è stato superato il numero massimo di utenti")); + TConfig campo_ini(CONFIG_INSTALL, "Main"); + const bool use_system_user = campo_ini.get_bool("AutoLogin"); + if (use_system_user) + ok = !cache().get(LF_USER, utente).empty(); } + + if (!ok) + ok = ask_user_password(utente); if (ok) { - TLocalisamfile users(LF_USER); - users.put("USERNAME", utente); - if (users.read(_isequal, _lock) == NOERR) + const TString& autstr = cache().get(LF_USER, dongle().administrator(), USR_AUTSTR); + if (autstr == "CONVERTING") { - users.put("CONNECTED", "X"); - users.rewrite(); + TString msg; msg << TR("E' in corso una conversione archivi") << ":\n"; + if (utente == dongle().administrator()) + { + msg << TR("Si desidera continuare ugualmente?"); + ok = yesno_box(msg); + } + else + { + msg << TR("Accesso negato."); + ok = error_box(msg); + } } - // Memorizza l'ultimo utente per riproporlo la prossima volta - TConfig campo_ini(CONFIG_INSTALL, "Main"); - campo_ini.set("User", utente); - } - } -#else - ok = true; -#endif + if (ok) + { + dongle().logout(); + user() = utente; + ok = get_serial_number() >= 0; + if (!ok) + error_box(TR("Probabilmente è stato superato il numero massimo di utenti")); + } + 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); + } + } + } + if (ok) { customize_colors(); // Aggiorna set di colori @@ -1277,18 +1267,16 @@ bool TMenu_application::user_create() { disable_menu_item(M_FILE_PRINT); // Questa voce di menu non serve per ora -#ifdef _DEMO_ + if (dongle().type() == _no_dongle) { - TMask w(TR("ATTENZIONE"), 1, 68, 12); + TMask w(TR("ATTENZIONE"), 1, 68, 10); w.add_static(DLG_NULL, 0 , PR("@bATTENZIONE") , 30 , 1); w.add_static(DLG_NULL, 0 , TR("Questo programma è in versione dimostrativa.") , 1 , 3); - w.add_static(DLG_NULL, 0 , TR("Non si possono memorizzare date con mese successivo a Marzo.") , 1 , 5); - w.add_static(DLG_NULL, 0 , TR("Il programma funziona circa per due ore ogni giorno.") , 1 , 7); - w.add_static(DLG_NULL, 0 , TR("Il numero di registrazioni è stato limitato ad un migliaio.") , 1 , 9); + w.add_static(DLG_NULL, 0 , TR("Il programma funziona circa per due ore ogni giorno.") , 1 , 5); + w.add_static(DLG_NULL, 0 , TR("Il numero di registrazioni è stato limitato ad un migliaio.") , 1 , 7); w.add_button(DLG_OK, 0, "", -11, -1, 10, 2); w.run(); } -#endif if (!check_user()) return false; @@ -1730,9 +1718,8 @@ void TMenu_application::update_preferred_tree() if (sm != NULL) { const int num = node.get_int(1); - if (num >= 0 && num < sm->items()) + if (num >= 0 && num < sm->items()) pref->add(new TMenuitem(sm->item(num))); - } } } @@ -2036,11 +2023,11 @@ int ba0100(int argc, char** argv) { TConfig campo_ini(CONFIG_INSTALL, "Main"); const bool su = campo_ini.get_bool("AutoLogin"); - if (su) // usa utente di windows + if (su) // usa utente di windows { xvt_sys_get_user_name(u.get_buffer(), u.size()+1); u.upper(); - if (u == "ADMINISTRATOR") // Converti amministratore + if (u.compare("Administrator", -1, true) == 0) // Converti amministratore u = dongle().administrator(); } if (u.blank()) @@ -2052,7 +2039,6 @@ int ba0100(int argc, char** argv) TFilename menu = (argc < 2) ? MEN_FILE : argv[1]; if (menu.custom_path()) - { TMenu_application *ma = new TMenu_application(menu); ma->run(argc, argv, TR("Menu Principale")); @@ -2062,4 +2048,4 @@ int ba0100(int argc, char** argv) error_box(FR("Non esiste il menu %s"), (const char*)menu); return 0; -} \ No newline at end of file +} diff --git a/ba/ba0100a.h b/ba/ba0100a.h index 922b8be41..cdf6c766e 100755 --- a/ba/ba0100a.h +++ b/ba/ba0100a.h @@ -1,17 +1,19 @@ -#define F_USER 101 -#define F_PASSWORD 102 -#define F_USERDESC 103 -#define F_GROUP 104 -#define F_GROUPNAME 105 -#define F_PROVA 106 -#define F_APPLICAT 107 -#define F_NOWRITE 108 +#define F_USER 151 +#define F_PASSWORD 152 +#define F_USERDESC 153 +#define F_GROUP 154 +#define F_GROUPNAME 155 +#define F_PROVA 156 +#define F_DATAPWD 157 +#define F_DATASCAD 158 +#define F_APPLICAT 159 +#define F_NOWRITE 160 -#define F_MODULI 150 -#define F_PERMESSI 151 -#define F_PROPERTIES 152 +#define F_MODULI 170 +#define F_PERMESSI 171 +#define F_PROPERTIES 172 -#define G_SUPERUSER 33 +#define G_SUPERUSER 33 #define F_BASE 200 #define F_74 201 diff --git a/ba/ba0100a.uml b/ba/ba0100a.uml index ac7586543..1759c872c 100755 --- a/ba/ba0100a.uml +++ b/ba/ba0100a.uml @@ -1,23 +1,22 @@ #include "ba0100a.h" -PAGE "Selezione utente" -1 -1 30 6 +PAGE "Selezione utente" -1 -1 28 6 -STRING F_USER 8 +STRING F_USER 32 16 BEGIN - PROMPT 4 1 "Utente " - FLAGS "U" + PROMPT 1 1 "Utente " USE LF_USER SELECT ISGROUP!="X" INPUT USERNAME F_USER - DISPLAY "Utente@8" USERNAME - DISPLAY "Gruppo@8" GROUPNAME + DISPLAY "Utente@16" USERNAME + DISPLAY "Gruppo@16" GROUPNAME DISPLAY "Descrizione@50" USERDESC OUTPUT F_USER USERNAME CHECKTYPE SEARCH END -STRING F_PASSWORD 8 10 +STRING F_PASSWORD 32 16 BEGIN - PROMPT 4 3 "Password " + PROMPT 1 3 "Password " FLAGS "*" END diff --git a/ba/ba0102.cpp b/ba/ba0102.cpp index ed38ad2d7..91820cb08 100755 --- a/ba/ba0102.cpp +++ b/ba/ba0102.cpp @@ -2,7 +2,6 @@ #include #include #include -#include #include "ba0102.h" @@ -511,7 +510,7 @@ void TMenulist_window::draw_item(int i) xvt_dwin_draw_icon(win(), ix, iy, ico > 0 ? ico : ICON_RSRC); } - TString str = item.caption(); + TString80 str = item.caption(); if (i == 0 && _can_go_back) str = "(..)"; @@ -793,12 +792,11 @@ bool TMenulist_window::on_key(KEY k) void TMenulist_window::synchronize_buddy_tree() const { TMask& m = owner().mask(); - for (int i = 0; i < m.fields(); i++) + FOR_EACH_MASK_FIELD(m, i, f) { - TMask_field& mf = m.fld(i); - if (mf.is_kind_of(CLASS_TREE_FIELD)) - { - TTree_field& tf = (TTree_field&)mf; + if (f->is_kind_of(CLASS_TREE_FIELD)) + { + TTree_field& tf = (TTree_field&)*f; synchronize_tree_field(tf); break; } diff --git a/ba/ba1101.cpp b/ba/ba1101.cpp index 1da6f6a72..10cabbc37 100755 --- a/ba/ba1101.cpp +++ b/ba/ba1101.cpp @@ -1,16 +1,9 @@ -// Includo stdio senno' dice che ridefinisco FILE -#include -#include - #include -#include #include #include #include -#include #include #include -#include #include "ba1100.h" @@ -129,21 +122,18 @@ TRec_sheet::~TRec_sheet() } bool TRec_sheet::check_key_expr(int key, const char * key_expr) - { TExpression expr("", _strexpr); return expr.set(key_expr, _strexpr); } HIDDEN bool len_handler(TMask_field& f, KEY key) - { const int len = atoi(f.get()); - - if (len < 0) return FALSE; + if (len < 0) + return false; const int typef = atoi(f.mask().get(FLD_TIPO)); - switch (typef) { case _alfafld: @@ -172,7 +162,7 @@ bool TRec_sheet::fld_notify(TSheet_field& f, int r, KEY k) if (k == K_CTRL + K_INS) { TToken_string & row = f.row(r); - row.add("1", f.cid2index(FLD_TIPO)); + row.add(1, f.cid2index(FLD_TIPO)); } return TRUE; } diff --git a/ba/ba1400.cpp b/ba/ba1400.cpp index 588c37bf8..c7bfd47bd 100755 --- a/ba/ba1400.cpp +++ b/ba/ba1400.cpp @@ -169,6 +169,7 @@ protected: virtual void init_insert_mode(TMask& m) { build_sheet(NULL); } protected: + void save_password(const TMask& m, TRectype& r) const; virtual void put_in_record(const TMask& m); virtual int write(const TMask& m); virtual int rewrite(const TMask& m); diff --git a/ba/ba1400a.uml b/ba/ba1400a.uml index 4de7cad9a..216c25cb0 100755 --- a/ba/ba1400a.uml +++ b/ba/ba1400a.uml @@ -1,14 +1,19 @@ #include "ba0100a.h" -TOOLBAR "" 0 20 0 2 +TOOLBAR "" 0 -2 0 2 #include ENDPAGE PAGE "Gestione utenti" -1 -1 35 7 -LIST F_GROUP 1 8 +GROUPBOX DLG_NULL 78 5 BEGIN - PROMPT 1 1 "" + PROMPT 1 0 "@bDati" +END + +RADIO F_GROUP 1 23 +BEGIN + PROMPT 2 0 "" ITEM " |Utente" MESSAGE SHOW,3@ ITEM "X|Gruppo" @@ -18,29 +23,30 @@ BEGIN KEY 1 END -STRING F_USER 8 +STRING F_USER 16 BEGIN - PROMPT 15 1 "" + PROMPT 20 1 "" FLAGS "U" USE LF_USER INPUT USERNAME F_USER - DISPLAY "Utente@8" USERNAME - DISPLAY "Gruppo@8" GROUPNAME + DISPLAY "Utente@32" USERNAME DISPLAY "Descrizione@50" USERDESC + DISPLAY "Gruppo@32" GROUPNAME OUTPUT F_USER USERNAME KEY 1 CHECKTYPE REQUIRED FIELD USERNAME END -STRING F_GROUPNAME 8 +STRING F_GROUPNAME 16 BEGIN - PROMPT 32 1 "Gruppo di appartenenza " + PROMPT 20 2 "" FLAGS "U" USE LF_USER SELECT ISGROUP="X" INPUT USERNAME F_GROUP - DISPLAY "Gruppo@8" USERNAME + DISPLAY "Codice@32" USERNAME DISPLAY "Descrizione@50" USERDESC + DISPLAY "Gruppo@32" GROUPNAME OUTPUT F_GROUP USERNAME CHECKTYPE NORMAL FIELD GROUPNAME @@ -49,30 +55,50 @@ END STRING F_USERDESC 50 BEGIN - PROMPT 1 2 "Descrizione " + PROMPT 2 3 "Descrizione " FIELD USERDESC GROUP G_SUPERUSER END -STRING F_PASSWORD 8 +GROUPBOX DLG_NULL 78 4 BEGIN - PROMPT 1 3 "Password " + PROMPT 1 5 "@bSicurezza" +END + +STRING F_PASSWORD 16 +BEGIN + PROMPT 2 6 "Password " FLAGS "*" GROUP 3 END -STRING F_PROVA 8 +STRING F_PROVA 16 BEGIN - PROMPT 32 3 "Prova " + PROMPT 2 7 "Controllo password " FLAGS "*" STR_EXPR #F_PROVA=#F_PASSWORD - WARNING "La password ed la sua prova devono coincidere" + WARNING "La password ed il suo controllo devono coincidere" + GROUP 3 +END + +DATE F_DATAPWD +BEGIN + PROMPT 55 6 "Inserimento " + FIELD DATAPWD + FLAGS "D" + GROUP 3 +END + +DATE F_DATASCAD +BEGIN + PROMPT 55 7 "Scadenza " + FLAGS "D" GROUP 3 END SPREADSHEET F_MODULI 78 BEGIN - PROMPT 0 5 "Moduli" + PROMPT 0 9 "Moduli" ITEM "Modulo@40" ITEM "Abilitato" ITEM "Codice" diff --git a/ba/ba8301.cpp b/ba/ba8301.cpp index 8078bfbab..01898fdab 100755 --- a/ba/ba8301.cpp +++ b/ba/ba8301.cpp @@ -1,14 +1,13 @@ -#include -#include +#include "ba8300.h" +#include "ba8301.h" #include #include -#include #include #include -#include "ba8300.h" -#include "ba8301.h" +#include +#include /////////////////////////////////////////////////////////// // TReport_tree