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
This commit is contained in:
guy 2007-04-03 11:06:56 +00:00
parent daaf63f06f
commit 1a28a590a0
8 changed files with 149 additions and 148 deletions

View File

@ -9,7 +9,6 @@
#include <dongle.h> #include <dongle.h>
#include <modaut.h> #include <modaut.h>
#include <execp.h> #include <execp.h>
#include <lffiles.h>
#include <recarray.h> #include <recarray.h>
#include <relation.h> #include <relation.h>
#include <msksheet.h> #include <msksheet.h>
@ -62,7 +61,7 @@ protected: // TApplication
virtual void on_firm_change(); virtual void on_firm_change();
virtual bool test_assistance_year() const; virtual bool test_assistance_year() const;
const TString& ask_user_password(); bool ask_user_password(TString& utente);
protected: protected:
void deconnect_user(); 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, TPicture_mask::TPicture_mask(const char* name, int dx, int dy,
const TSubmenu& submenu, int x, int y) 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); set_current(submenu);
TFilename logoname; TFilename logoname;
const char* const ext[] = { "jpg", "png", "gif", "bmp", NULL }; const char* const ext[] = { "jpg", "png", "gif", "bmp", NULL };
for (int i = 0; ext[i]; i++) for (int i = 0; ext[i]; i++)
{ {
logoname = "logo"; logoname = "logo."; logoname << ext[i];
logoname << '.' << ext[i];
if (logoname.custom_path()) if (logoname.custom_path())
break; break;
} }
TImage logo(logoname); TImage logo(logoname);
@ -455,10 +452,15 @@ void TExplorer_mask::draw_spider(int mode, const PNT& mouse) const
xvt_dwin_draw_oval(w, &rct); xvt_dwin_draw_oval(w, &rct);
} }
// Disegno la boccuccia aperta se gli occhi sono incrociati // Disegno la boccuccia aperta se il mouse e' vicino
xvt_dwin_set_std_cbrush(w, abs(mouse.h-p0.h) <= 2 ? TL_BRUSH_WHITE : TL_BRUSH_BLACK); 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_rect_set(&rct, p0.h-eye, p0.v, p0.h+eye, p0.v+eye);
xvt_dwin_draw_oval(w, &rct); 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(); _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 // Disabilita le voci di personalizzazione
int mi; int mi;
for (mi = 2; mi <= 7; mi++) for (mi = 2; mi <= 7; mi++)
@ -972,7 +973,6 @@ const TString& TMenu_application::ask_user_password()
TLocalisamfile& users = e.browse()->cursor()->file(); TLocalisamfile& users = e.browse()->cursor()->file();
TString pwd; TString pwd;
bool ok = false;
for (int i = 0; i < 3 && !ok; i++) for (int i = 0; i < 3 && !ok; i++)
{ {
if (utente.not_empty() && utente != dongle().administrator()) if (utente.not_empty() && utente != dongle().administrator())
@ -980,7 +980,6 @@ const TString& TMenu_application::ask_user_password()
m.set(F_USER, utente); m.set(F_USER, utente);
m.first_focus(F_PASSWORD); m.first_focus(F_PASSWORD);
} }
if (m.run() == K_ESC) if (m.run() == K_ESC)
break; break;
@ -1013,7 +1012,7 @@ const TString& TMenu_application::ask_user_password()
if (ok) if (ok)
{ {
if (users.get_bool("CONNECTED")) if (users.get_bool(USR_CONNECTED))
{ {
ok = yesno_box("%s\n%s", ok = yesno_box("%s\n%s",
TR("L'utente risulta essere già collegato"), 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"); TConfig studio_ini(CONFIG_STUDIO, "Main");
const long expiration = studio_ini.get_long("PasswordExpiration"); const long expiration = studio_ini.get_long("PasswordExpiration");
@ -1050,7 +1049,7 @@ const TString& TMenu_application::ask_user_password()
} }
if (runba) 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; user() = utente;
TExternal_app app("ba1 -3"); TExternal_app app("ba1 -3");
app.run(); app.run();
@ -1059,84 +1058,75 @@ const TString& TMenu_application::ask_user_password()
} }
} }
if (!ok)
utente.cut(0);
// Abilita le voci di personalizzazione // Abilita le voci di personalizzazione
for (mi = 2; mi <= 7; mi++) for (mi = 2; mi <= 7; mi++)
enable_menu_item(MENU_ITEM(mi)); enable_menu_item(MENU_ITEM(mi));
#endif
return get_tmp_string() = utente; return ok;
} }
bool TMenu_application::check_user() bool TMenu_application::check_user()
{ {
bool ok = false; bool ok = dongle().type() == _no_dongle;
#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();
}
if (!ok) if (!ok)
{ {
utente = ask_user_password(); TString utente = user();
ok = utente.full();
}
if (ok) if (_mask == NULL) // Primo login della sessione;
{
const TString& autstr = cache().get(LF_USER, dongle().administrator(), USR_AUTSTR);
if (autstr == "CONVERTING")
{ {
TString msg; msg << TR("E' in corso una conversione archivi") << ":\n"; TConfig campo_ini(CONFIG_INSTALL, "Main");
if (utente == dongle().administrator()) const bool use_system_user = campo_ini.get_bool("AutoLogin");
{ if (use_system_user)
msg << TR("Si desidera continuare ugualmente?"); ok = !cache().get(LF_USER, utente).empty();
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"));
} }
if (!ok)
ok = ask_user_password(utente);
if (ok) if (ok)
{ {
TLocalisamfile users(LF_USER); const TString& autstr = cache().get(LF_USER, dongle().administrator(), USR_AUTSTR);
users.put("USERNAME", utente); if (autstr == "CONVERTING")
if (users.read(_isequal, _lock) == NOERR)
{ {
users.put("CONNECTED", "X"); TString msg; msg << TR("E' in corso una conversione archivi") << ":\n";
users.rewrite(); 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 if (ok)
TConfig campo_ini(CONFIG_INSTALL, "Main"); {
campo_ini.set("User", utente); dongle().logout();
} user() = utente;
} ok = get_serial_number() >= 0;
#else if (!ok)
ok = true; error_box(TR("Probabilmente è stato superato il numero massimo di utenti"));
#endif }
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) if (ok)
{ {
customize_colors(); // Aggiorna set di colori 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 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 , 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("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 , 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 , 7);
w.add_static(DLG_NULL, 0 , TR("Il numero di registrazioni è stato limitato ad un migliaio.") , 1 , 9);
w.add_button(DLG_OK, 0, "", -11, -1, 10, 2); w.add_button(DLG_OK, 0, "", -11, -1, 10, 2);
w.run(); w.run();
} }
#endif
if (!check_user()) if (!check_user())
return false; return false;
@ -1730,9 +1718,8 @@ void TMenu_application::update_preferred_tree()
if (sm != NULL) if (sm != NULL)
{ {
const int num = node.get_int(1); 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))); pref->add(new TMenuitem(sm->item(num)));
} }
} }
} }
@ -2036,11 +2023,11 @@ int ba0100(int argc, char** argv)
{ {
TConfig campo_ini(CONFIG_INSTALL, "Main"); TConfig campo_ini(CONFIG_INSTALL, "Main");
const bool su = campo_ini.get_bool("AutoLogin"); 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); xvt_sys_get_user_name(u.get_buffer(), u.size()+1);
u.upper(); u.upper();
if (u == "ADMINISTRATOR") // Converti amministratore if (u.compare("Administrator", -1, true) == 0) // Converti amministratore
u = dongle().administrator(); u = dongle().administrator();
} }
if (u.blank()) if (u.blank())
@ -2052,7 +2039,6 @@ int ba0100(int argc, char** argv)
TFilename menu = (argc < 2) ? MEN_FILE : argv[1]; TFilename menu = (argc < 2) ? MEN_FILE : argv[1];
if (menu.custom_path()) if (menu.custom_path())
{ {
TMenu_application *ma = new TMenu_application(menu); TMenu_application *ma = new TMenu_application(menu);
ma->run(argc, argv, TR("Menu Principale")); 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); error_box(FR("Non esiste il menu %s"), (const char*)menu);
return 0; return 0;
} }

View File

@ -1,17 +1,19 @@
#define F_USER 101 #define F_USER 151
#define F_PASSWORD 102 #define F_PASSWORD 152
#define F_USERDESC 103 #define F_USERDESC 153
#define F_GROUP 104 #define F_GROUP 154
#define F_GROUPNAME 105 #define F_GROUPNAME 155
#define F_PROVA 106 #define F_PROVA 156
#define F_APPLICAT 107 #define F_DATAPWD 157
#define F_NOWRITE 108 #define F_DATASCAD 158
#define F_APPLICAT 159
#define F_NOWRITE 160
#define F_MODULI 150 #define F_MODULI 170
#define F_PERMESSI 151 #define F_PERMESSI 171
#define F_PROPERTIES 152 #define F_PROPERTIES 172
#define G_SUPERUSER 33 #define G_SUPERUSER 33
#define F_BASE 200 #define F_BASE 200
#define F_74 201 #define F_74 201

View File

@ -1,23 +1,22 @@
#include "ba0100a.h" #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 BEGIN
PROMPT 4 1 "Utente " PROMPT 1 1 "Utente "
FLAGS "U"
USE LF_USER SELECT ISGROUP!="X" USE LF_USER SELECT ISGROUP!="X"
INPUT USERNAME F_USER INPUT USERNAME F_USER
DISPLAY "Utente@8" USERNAME DISPLAY "Utente@16" USERNAME
DISPLAY "Gruppo@8" GROUPNAME DISPLAY "Gruppo@16" GROUPNAME
DISPLAY "Descrizione@50" USERDESC DISPLAY "Descrizione@50" USERDESC
OUTPUT F_USER USERNAME OUTPUT F_USER USERNAME
CHECKTYPE SEARCH CHECKTYPE SEARCH
END END
STRING F_PASSWORD 8 10 STRING F_PASSWORD 32 16
BEGIN BEGIN
PROMPT 4 3 "Password " PROMPT 1 3 "Password "
FLAGS "*" FLAGS "*"
END END

View File

@ -2,7 +2,6 @@
#include <mask.h> #include <mask.h>
#include <statbar.h> #include <statbar.h>
#include <urldefid.h> #include <urldefid.h>
#include <utility.h>
#include "ba0102.h" #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); 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) if (i == 0 && _can_go_back)
str = "(..)"; str = "(..)";
@ -793,12 +792,11 @@ bool TMenulist_window::on_key(KEY k)
void TMenulist_window::synchronize_buddy_tree() const void TMenulist_window::synchronize_buddy_tree() const
{ {
TMask& m = owner().mask(); 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 (f->is_kind_of(CLASS_TREE_FIELD))
if (mf.is_kind_of(CLASS_TREE_FIELD)) {
{ TTree_field& tf = (TTree_field&)*f;
TTree_field& tf = (TTree_field&)mf;
synchronize_tree_field(tf); synchronize_tree_field(tf);
break; break;
} }

View File

@ -1,16 +1,9 @@
// Includo stdio senno' dice che ridefinisco FILE
#include <stdio.h>
#include <incstr.h>
#include <applicat.h> #include <applicat.h>
#include <diction.h>
#include <expr.h> #include <expr.h>
#include <isam.h> #include <isam.h>
#include <msksheet.h> #include <msksheet.h>
#include <prefix.h>
#include <progind.h> #include <progind.h>
#include <utility.h> #include <utility.h>
#include <validate.h>
#include "ba1100.h" #include "ba1100.h"
@ -129,21 +122,18 @@ TRec_sheet::~TRec_sheet()
} }
bool TRec_sheet::check_key_expr(int key, const char * key_expr) bool TRec_sheet::check_key_expr(int key, const char * key_expr)
{ {
TExpression expr("", _strexpr); TExpression expr("", _strexpr);
return expr.set(key_expr, _strexpr); return expr.set(key_expr, _strexpr);
} }
HIDDEN bool len_handler(TMask_field& f, KEY key) HIDDEN bool len_handler(TMask_field& f, KEY key)
{ {
const int len = atoi(f.get()); const int len = atoi(f.get());
if (len < 0)
if (len < 0) return FALSE; return false;
const int typef = atoi(f.mask().get(FLD_TIPO)); const int typef = atoi(f.mask().get(FLD_TIPO));
switch (typef) switch (typef)
{ {
case _alfafld: case _alfafld:
@ -172,7 +162,7 @@ bool TRec_sheet::fld_notify(TSheet_field& f, int r, KEY k)
if (k == K_CTRL + K_INS) if (k == K_CTRL + K_INS)
{ {
TToken_string & row = f.row(r); TToken_string & row = f.row(r);
row.add("1", f.cid2index(FLD_TIPO)); row.add(1, f.cid2index(FLD_TIPO));
} }
return TRUE; return TRUE;
} }

View File

@ -169,6 +169,7 @@ protected:
virtual void init_insert_mode(TMask& m) { build_sheet(NULL); } virtual void init_insert_mode(TMask& m) { build_sheet(NULL); }
protected: protected:
void save_password(const TMask& m, TRectype& r) const;
virtual void put_in_record(const TMask& m); virtual void put_in_record(const TMask& m);
virtual int write(const TMask& m); virtual int write(const TMask& m);
virtual int rewrite(const TMask& m); virtual int rewrite(const TMask& m);

View File

@ -1,14 +1,19 @@
#include "ba0100a.h" #include "ba0100a.h"
TOOLBAR "" 0 20 0 2 TOOLBAR "" 0 -2 0 2
#include <toolbar.h> #include <toolbar.h>
ENDPAGE ENDPAGE
PAGE "Gestione utenti" -1 -1 35 7 PAGE "Gestione utenti" -1 -1 35 7
LIST F_GROUP 1 8 GROUPBOX DLG_NULL 78 5
BEGIN BEGIN
PROMPT 1 1 "" PROMPT 1 0 "@bDati"
END
RADIO F_GROUP 1 23
BEGIN
PROMPT 2 0 ""
ITEM " |Utente" ITEM " |Utente"
MESSAGE SHOW,3@ MESSAGE SHOW,3@
ITEM "X|Gruppo" ITEM "X|Gruppo"
@ -18,29 +23,30 @@ BEGIN
KEY 1 KEY 1
END END
STRING F_USER 8 STRING F_USER 16
BEGIN BEGIN
PROMPT 15 1 "" PROMPT 20 1 ""
FLAGS "U" FLAGS "U"
USE LF_USER USE LF_USER
INPUT USERNAME F_USER INPUT USERNAME F_USER
DISPLAY "Utente@8" USERNAME DISPLAY "Utente@32" USERNAME
DISPLAY "Gruppo@8" GROUPNAME
DISPLAY "Descrizione@50" USERDESC DISPLAY "Descrizione@50" USERDESC
DISPLAY "Gruppo@32" GROUPNAME
OUTPUT F_USER USERNAME OUTPUT F_USER USERNAME
KEY 1 KEY 1
CHECKTYPE REQUIRED CHECKTYPE REQUIRED
FIELD USERNAME FIELD USERNAME
END END
STRING F_GROUPNAME 8 STRING F_GROUPNAME 16
BEGIN BEGIN
PROMPT 32 1 "Gruppo di appartenenza " PROMPT 20 2 ""
FLAGS "U" FLAGS "U"
USE LF_USER SELECT ISGROUP="X" USE LF_USER SELECT ISGROUP="X"
INPUT USERNAME F_GROUP INPUT USERNAME F_GROUP
DISPLAY "Gruppo@8" USERNAME DISPLAY "Codice@32" USERNAME
DISPLAY "Descrizione@50" USERDESC DISPLAY "Descrizione@50" USERDESC
DISPLAY "Gruppo@32" GROUPNAME
OUTPUT F_GROUP USERNAME OUTPUT F_GROUP USERNAME
CHECKTYPE NORMAL CHECKTYPE NORMAL
FIELD GROUPNAME FIELD GROUPNAME
@ -49,30 +55,50 @@ END
STRING F_USERDESC 50 STRING F_USERDESC 50
BEGIN BEGIN
PROMPT 1 2 "Descrizione " PROMPT 2 3 "Descrizione "
FIELD USERDESC FIELD USERDESC
GROUP G_SUPERUSER GROUP G_SUPERUSER
END END
STRING F_PASSWORD 8 GROUPBOX DLG_NULL 78 4
BEGIN BEGIN
PROMPT 1 3 "Password " PROMPT 1 5 "@bSicurezza"
END
STRING F_PASSWORD 16
BEGIN
PROMPT 2 6 "Password "
FLAGS "*" FLAGS "*"
GROUP 3 GROUP 3
END END
STRING F_PROVA 8 STRING F_PROVA 16
BEGIN BEGIN
PROMPT 32 3 "Prova " PROMPT 2 7 "Controllo password "
FLAGS "*" FLAGS "*"
STR_EXPR #F_PROVA=#F_PASSWORD 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 GROUP 3
END END
SPREADSHEET F_MODULI 78 SPREADSHEET F_MODULI 78
BEGIN BEGIN
PROMPT 0 5 "Moduli" PROMPT 0 9 "Moduli"
ITEM "Modulo@40" ITEM "Modulo@40"
ITEM "Abilitato" ITEM "Abilitato"
ITEM "Codice" ITEM "Codice"

View File

@ -1,14 +1,13 @@
#include <xinclude.h> #include "ba8300.h"
#include <statbar.h> #include "ba8301.h"
#include <colors.h> #include <colors.h>
#include <diction.h> #include <diction.h>
#include <image.h>
#include <reprint.h> #include <reprint.h>
#include <defmask.h> #include <defmask.h>
#include "ba8300.h" #include <xinclude.h>
#include "ba8301.h" #include <statbar.h>
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// TReport_tree // TReport_tree