Migliorata gestione utenti

git-svn-id: svn://10.65.10.50/trunk@570 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1994-11-08 16:50:04 +00:00
parent 2b8789a8e4
commit 7ab438abb8
5 changed files with 656 additions and 666 deletions

View File

@ -1,6 +1,6 @@
#include "ba0100a.h" #include "ba0100a.h"
PAGE "Configurazione utente" -1 -1 35 7 PAGE "Selezione utente" -1 -1 35 7
STRING F_USER 8 STRING F_USER 8
BEGIN BEGIN

View File

@ -1,44 +1,35 @@
#include <xvt.h> #include <xvt.h>
#include <applicat.h> #include <applicat.h>
#include <stdtypes.h>
#include <checks.h> #include <checks.h>
#include "ba1.h" #include "ba1.h"
#define usage "Errore - uso : ba1 [-{0|1|2|3|4}]" #define usage "Errore - uso : ba1 [-{0|1|2|3|4}]"
int main(int argc,char** argv) int main(int argc,char** argv)
{ {
int rt = 0 ; TApplication::check_parameters(argc, argv);
check_parameters(argc, argv); const int r = (argc > 1) ? atoi(&argv[1][1]) : 0;
if (argc == 1) switch (r)
rt = ba1100(argc,argv); {
else case 0:
if (argc >= 2) ba1100(argc,argv); break;
{ case 1:
const int r = (argc > 1) ? atoi(&argv[1][1]) : -1; ba1200(argc,argv); break;
case 2:
ba1300(argc,argv); break;
case 3:
ba1400(argc,argv); break;
case 4:
ba1500(argc,argv); break;
default:
error_box(usage); break;
}
switch (r) return 0;
{
case 0:
rt = ba1100(argc,argv); break;
case 1:
rt = ba1200(argc,argv); break;
case 2:
rt = ba1300(argc,argv); break;
case 3:
rt = ba1400(argc,argv); break;
case 4:
rt = ba1500(argc,argv); break;
default:
error_box(usage); break;
}
}
else fatal_box(usage);
return rt;
} }

View File

@ -1,12 +1,12 @@
#include <relapp.h> #include <relapp.h>
#include <stdtypes.h> #include <stdtypes.h>
#include <lffiles.h>
#include <modaut.h> #include <modaut.h>
#include <utility.h> #include <utility.h>
#include "ba1.h" #include "ba1.h"
#include "ba0100a.h" #include "ba0100a.h"
class set_users : public TRelation_application class TSet_users : public TRelation_application
{ {
TMask* _msk; TMask* _msk;
TRelation* _rel; TRelation* _rel;
@ -27,11 +27,10 @@ class set_users : public TRelation_application
public: public:
set_users() {} TSet_users() : _msk(NULL), _rel(NULL) {}
virtual ~set_users() {}
}; };
bool set_users::password_handler(TMask_field& f, KEY key) bool TSet_users::password_handler(TMask_field& f, KEY key)
{ {
if (f.mask().mode() == MODE_QUERY || key != K_ENTER) return TRUE; if (f.mask().mode() == MODE_QUERY || key != K_ENTER) return TRUE;
@ -40,7 +39,7 @@ bool set_users::password_handler(TMask_field& f, KEY key)
return ok; return ok;
} }
void set_users::enable_aut(TMask& m) void TSet_users::enable_aut(TMask& m)
{ {
const bool prassi = (m.get(F_USER) == "PRASSI"); const bool prassi = (m.get(F_USER) == "PRASSI");
@ -58,11 +57,10 @@ void set_users::enable_aut(TMask& m)
} }
} }
bool set_users::user_create() bool TSet_users::user_create()
{ {
const TString16 u(user()); if (user() != "PRASSI")
return error_box("Utente non abilitato all'uso di questo programma");
if (u != "PRASSI") return FALSE;
_msk = new TMask("ba1400a") ; _msk = new TMask("ba1400a") ;
_rel = new TRelation(LF_USER); _rel = new TRelation(LF_USER);
_msk->field(F_MU).disable(); _msk->field(F_MU).disable();
@ -70,7 +68,7 @@ bool set_users::user_create()
return TRUE; return TRUE;
} }
int set_users::read(TMask& m) int TSet_users::read(TMask& m)
{ {
TRelation_application::read(m); TRelation_application::read(m);
@ -80,7 +78,7 @@ int set_users::read(TMask& m)
return NOERR; return NOERR;
} }
int set_users::write(const TMask& m) int TSet_users::write(const TMask& m)
{ {
TRelation *r = get_relation(); TRelation *r = get_relation();
@ -90,7 +88,7 @@ int set_users::write(const TMask& m)
return TRelation_application::write(m); return TRelation_application::write(m);
} }
int set_users::rewrite(const TMask& m) int TSet_users::rewrite(const TMask& m)
{ {
TRelation *r = get_relation(); TRelation *r = get_relation();
@ -100,16 +98,17 @@ int set_users::rewrite(const TMask& m)
return TRelation_application::rewrite(m); return TRelation_application::rewrite(m);
} }
bool set_users::user_destroy()
bool TSet_users::user_destroy()
{ {
delete _msk; if (_msk != NULL) delete _msk;
delete _rel; if (_rel != NULL) delete _rel;
return TRUE; return TRUE;
} }
int ba1400(int argc, char* argv[]) int ba1400(int argc, char** argv)
{ {
set_users a ; TSet_users a ;
a.run(argc, argv, "Configurazione utenti"); a.run(argc, argv, "Configurazione utenti");
return 0; return 0;
} }

View File

@ -4,7 +4,7 @@ TOOLBAR "" 0 20 0 2
#include <toolbar.h> #include <toolbar.h>
ENDPAGE ENDPAGE
PAGE "Selezione utente" -1 -1 35 7 PAGE "Gestione utenti" -1 -1 35 7
STRING F_USER 8 STRING F_USER 8
BEGIN BEGIN
@ -113,4 +113,3 @@ END
ENDPAGE ENDPAGE
ENDMASK ENDMASK

View File

@ -4,9 +4,11 @@
#include <utility.h> #include <utility.h>
#include <urldefid.h> #include <urldefid.h>
#include <extcdecl.h> #include <extcdecl.h>
#include "ba1.h" #include "ba1.h"
#include "ba0100a.h" #include "ba0100a.h"
#include "ba1500a.h" #include "ba1500a.h"
#define USERADR 26952 #define USERADR 26952
#define AGAADR 26953 #define AGAADR 26953
#define PRASSIADR 26954 #define PRASSIADR 26954
@ -20,9 +22,10 @@ enum kt { _user_key, _aga_key, _prassi_key};
#define BITTEST(w,p) (((w) & (0x0001 << (p))) != 0) #define BITTEST(w,p) (((w) & (0x0001 << (p))) != 0)
#define BITSET(w,p,v) ((v) ? ((w) |= (0x0001 << (p))) : ((w) &= (~(0x0001 << (p))))) #define BITSET(w,p,v) ((v) ? ((w) |= (0x0001 << (p))) : ((w) &= (~(0x0001 << (p)))))
class att_moduli : public TApplication class TAttivazione_moduli : public TApplication
{ {
TMask* _msk; TMask* _msk;
kt _key_type; kt _key_type;
word _serno; word _serno;
word _port; word _port;
@ -31,22 +34,24 @@ class att_moduli : public TApplication
virtual bool destroy() ; virtual bool destroy() ;
bool menu(MENU_TAG); bool menu(MENU_TAG);
void generate_key(); void generate_key();
void keyext(const TString16 & s, word * v);
static void keyext(const TString & s, word * v);
static bool user_hnd(TMask_field & f, KEY k); static bool user_hnd(TMask_field & f, KEY k);
static bool decode_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 activate_hnd(TMask_field & f, KEY k);
public: public:
att_moduli() { _key_type = _user_key;} TAttivazione_moduli() : _msk(NULL) { _key_type = _user_key;}
virtual ~att_moduli() {}
}; };
void att_moduli::generate_key()
{
word ud[4];
bool ok;
HIDDEN TAttivazione_moduli& app() { return (TAttivazione_moduli &) main_app(); }
void TAttivazione_moduli::generate_key()
{
#if XVT_OS == XVT_OS_SCOUNIX #if XVT_OS == XVT_OS_SCOUNIX
word ud[4];
INT_OFF(); INT_OFF();
HL_ON(_port, USERADR); HL_ON(_port, USERADR);
ud[0] = HL_RD(_port, 48); ud[0] = HL_RD(_port, 48);
@ -56,11 +61,13 @@ void att_moduli::generate_key()
HL_OFF(_port); HL_OFF(_port);
INT_ON(); INT_ON();
#else #else
int ud[4];
HL_READ(48, &ud[0]); HL_READ(48, &ud[0]);
HL_READ(49, &ud[1]); HL_READ(49, &ud[1]);
HL_READ(50, &ud[2]); HL_READ(50, &ud[2]);
HL_READ(51, &ud[3]); HL_READ(51, &ud[3]);
#endif #endif
int nmod = 0; int nmod = 0;
_msk->set(F_K2, format("%04X%04X%04X%04X", ud[0], ud[1], ud[2], ud[3])); _msk->set(F_K2, format("%04X%04X%04X%04X", ud[0], ud[1], ud[2], ud[3]));
@ -85,7 +92,7 @@ void att_moduli::generate_key()
#if XVT_OS == XVT_OS_SCOUNIX #if XVT_OS == XVT_OS_SCOUNIX
INT_OFF(); INT_OFF();
HL_ON(_port, ModAd); HL_ON(_port, ModAd);
ok = K_EYE(_port, (unsigned char *) ud, HLBLOCK); K_EYE(_port, (unsigned char *) ud, HLBLOCK);
HL_OFF(_port); HL_OFF(_port);
INT_ON(); INT_ON();
#else #else
@ -107,7 +114,7 @@ int hexdigit(char c)
return i; return i;
} }
void att_moduli::keyext(const TString16 & s, word * val) void TAttivazione_moduli::keyext(const TString& s, word * val)
{ {
for (int i = 0 ; i < 4; i++) for (int i = 0 ; i < 4; i++)
{ {
@ -120,14 +127,12 @@ void att_moduli::keyext(const TString16 & s, word * val)
} }
} }
bool att_moduli::user_hnd(TMask_field & f, KEY k) bool TAttivazione_moduli::user_hnd(TMask_field & f, KEY k)
{ {
const TString16 k4(f.get()); const TString16 k4(f.get());
if (!f.to_check(k) || k4.empty()) return TRUE; if (!f.to_check(k) || k4.empty()) return TRUE;
att_moduli & app = (att_moduli &) main_app();
TMask & m = f.mask(); TMask & m = f.mask();
word ud1[4], ud2[4], port = app._port; word ud1[4], ud2[4], port = app()._port;
BOOLEAN ok;
const TString16 k3(m.get(F_K3)); const TString16 k3(m.get(F_K3));
keyext(k3, ud1); keyext(k3, ud1);
@ -135,7 +140,7 @@ bool att_moduli::user_hnd(TMask_field & f, KEY k)
#if XVT_OS == XVT_OS_SCOUNIX #if XVT_OS == XVT_OS_SCOUNIX
INT_OFF(); INT_OFF();
HL_ON(port, ModAd); HL_ON(port, ModAd);
ok = K_EYE(port, (unsigned char *) ud1, HLBLOCK); K_EYE(port, (unsigned char *) ud1, HLBLOCK);
HL_OFF(port); HL_OFF(port);
INT_ON(); INT_ON();
#else #else
@ -147,7 +152,7 @@ bool att_moduli::user_hnd(TMask_field & f, KEY k)
d.addmonth(3); d.addmonth(3);
if (d < d1) if (d < d1)
return f.error_box("data non valida"); return f.error_box("data non valida");
if ((ud1[2] & UBYTEMASK) != K1 || ud1[3] != app._serno) if ((ud1[2] & UBYTEMASK) != K1 || ud1[3] != app()._serno)
return f.error_box("primo codice errato"); return f.error_box("primo codice errato");
#if XVT_OS == XVT_OS_SCOUNIX #if XVT_OS == XVT_OS_SCOUNIX
INT_OFF(); INT_OFF();
@ -158,7 +163,7 @@ bool att_moduli::user_hnd(TMask_field & f, KEY k)
#else #else
HL_CODE(EYECAST ud2, HLBLOCK); HL_CODE(EYECAST ud2, HLBLOCK);
#endif #endif
for (int i = 0; i < 4; i++) ud2[i] ^= app._serno; for (int i = 0; i < 4; i++) ud2[i] ^= app()._serno;
if (ud2[3] != 0) if (ud2[3] != 0)
return f.error_box("secondo codice errato"); return f.error_box("secondo codice errato");
for (i = 1; i < MAXAUT; i++) for (i = 1; i < MAXAUT; i++)
@ -192,14 +197,12 @@ bool att_moduli::user_hnd(TMask_field & f, KEY k)
return TRUE; return TRUE;
} }
bool att_moduli::decode_hnd(TMask_field & f, KEY k) bool TAttivazione_moduli::decode_hnd(TMask_field & f, KEY k)
{ {
const TString16 k2(f.get()); const TString16 k2(f.get());
if (!f.to_check(k) || k2.empty()) return TRUE; if (!f.to_check(k) || k2.empty()) return TRUE;
att_moduli & app = (att_moduli &) main_app();
TMask & m = f.mask(); TMask & m = f.mask();
word ud1[4], ud2[4], port = app._port; word ud1[4], ud2[4], port = app()._port;
BOOLEAN ok;
const TString16 k1(m.get(F_K1)); const TString16 k1(m.get(F_K1));
keyext(k1, ud1); keyext(k1, ud1);
@ -207,7 +210,7 @@ bool att_moduli::decode_hnd(TMask_field & f, KEY k)
#if XVT_OS == XVT_OS_SCOUNIX #if XVT_OS == XVT_OS_SCOUNIX
INT_OFF(); INT_OFF();
HL_ON(port, USERADR); HL_ON(port, USERADR);
ok = K_EYE(port, (unsigned char *) ud1, HLBLOCK); K_EYE(port, (unsigned char *) ud1, HLBLOCK);
HL_OFF(port); HL_OFF(port);
INT_ON(); INT_ON();
#else #else
@ -215,22 +218,22 @@ bool att_moduli::decode_hnd(TMask_field & f, KEY k)
#endif #endif
long & l = (long &) ud1[2]; long & l = (long &) ud1[2];
const TDate d(l); const TDate d(l);
app._serno = ud1[0]; app()._serno = ud1[0];
if ((ud1[1] & UBYTEMASK) != K1) if ((ud1[1] & UBYTEMASK) != K1)
return f.error_box("primo codice errato"); return f.error_box("primo codice errato");
#if XVT_OS == XVT_OS_SCOUNIX #if XVT_OS == XVT_OS_SCOUNIX
INT_OFF(); INT_OFF();
HL_ON(port, USERADR); HL_ON(port, USERADR);
ok = K_EYE(port, (unsigned char *) ud2, HLBLOCK); K_EYE(port, (unsigned char *) ud2, HLBLOCK);
HL_OFF(port); HL_OFF(port);
INT_ON(); INT_ON();
#else #else
HL_CODE(EYECAST ud2, HLBLOCK); HL_CODE(EYECAST ud2, HLBLOCK);
#endif #endif
for (int i = 0; i < 4; i++) ud2[i] ^= app._serno; for (int i = 0; i < 4; i++) ud2[i] ^= app()._serno;
if (ud2[3] != 0) if (ud2[3] != 0)
return f.error_box("secondo codice errato"); return f.error_box("secondo codice errato");
m.set(F_SN, app._serno); m.set(F_SN, app()._serno);
m.set(F_DT, d.string()); m.set(F_DT, d.string());
for (i = 1; i < MAXAUT; i++) for (i = 1; i < MAXAUT; i++)
{ {
@ -243,13 +246,11 @@ bool att_moduli::decode_hnd(TMask_field & f, KEY k)
return TRUE; return TRUE;
} }
bool att_moduli::activate_hnd(TMask_field & f, KEY k) bool TAttivazione_moduli::activate_hnd(TMask_field & f, KEY k)
{ {
if (!f.to_check(k)) return TRUE; if (!f.to_check(k)) return TRUE;
att_moduli & app = (att_moduli &) main_app();
TMask & m = f.mask(); TMask & m = f.mask();
word ud1[4], ud2[4], port = app._port; word ud1[4], ud2[4], port = app()._port;
BOOLEAN ok;
int nmod = 0; int nmod = 0;
for (int i = 0; i < 4; i++) ud2[i] = 0; for (int i = 0; i < 4; i++) ud2[i] = 0;
@ -264,19 +265,19 @@ bool att_moduli::activate_hnd(TMask_field & f, KEY k)
nmod++; nmod++;
} }
} }
for (i = 0; i < 4; i++) ud2[i] ^= app._serno; for (i = 0; i < 4; i++) ud2[i] ^= app()._serno;
const TDate d(m.get(F_DT)); const TDate d(m.get(F_DT));
long & l = (long &) ud1[0]; long & l = (long &) ud1[0];
l = (long) d; l = (long) d;
ud1[2] = K1 | (nmod & UBYTEMASK); ud1[2] = K1 | (nmod & UBYTEMASK);
ud1[3] = app._serno; ud1[3] = app()._serno;
#if XVT_OS == XVT_OS_SCOUNIX #if XVT_OS == XVT_OS_SCOUNIX
INT_OFF(); INT_OFF();
HL_ON(port, ModAd); HL_ON(port, ModAd);
ok = K_EYE(port, (unsigned char *) ud1, HLBLOCK); K_EYE(port, (unsigned char *) ud1, HLBLOCK);
ok = K_EYE(port, (unsigned char *) ud2, HLBLOCK); K_EYE(port, (unsigned char *) ud2, HLBLOCK);
HL_OFF(port); HL_OFF(port);
INT_ON(); INT_ON();
#else #else
@ -288,11 +289,11 @@ bool att_moduli::activate_hnd(TMask_field & f, KEY k)
return TRUE; return TRUE;
} }
bool att_moduli::create() bool TAttivazione_moduli::create()
{ {
const TString16 u(user()); if (user() != "PRASSI")
return error_box("Utente non abilitato all'uso di questo programma");
if (u != "PRASSI") return FALSE;
_msk = new TMask("ba1500a") ; _msk = new TMask("ba1500a") ;
#if XVT_OS == XVT_OS_SCOUNIX #if XVT_OS == XVT_OS_SCOUNIX
if (Hl_Port(AGAADR) != 0) if (Hl_Port(AGAADR) != 0)
@ -351,21 +352,21 @@ dispatch_e_menu(BAR_ITEM(1));
return TRUE; return TRUE;
} }
bool att_moduli::destroy() bool TAttivazione_moduli::destroy()
{ {
delete _msk; if (_msk != NULL) delete _msk;
return TRUE; return TRUE;
} }
bool att_moduli::menu(MENU_TAG) bool TAttivazione_moduli::menu(MENU_TAG)
{ {
_msk->run(); _msk->run();
return FALSE; return FALSE;
} }
int ba1500(int argc, char* argv[]) int ba1500(int argc, char** argv)
{ {
att_moduli a ; TAttivazione_moduli a ;
a.run(argc, argv, "Attivazione moduli"); a.run(argc, argv, "Attivazione moduli");
return 0; return 0;
} }