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"
PAGE "Configurazione utente" -1 -1 35 7
PAGE "Selezione utente" -1 -1 35 7
STRING F_USER 8
BEGIN

View File

@ -1,44 +1,35 @@
#include <xvt.h>
#include <applicat.h>
#include <stdtypes.h>
#include <checks.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 rt = 0 ;
TApplication::check_parameters(argc, argv);
check_parameters(argc, argv);
const int r = (argc > 1) ? atoi(&argv[1][1]) : 0;
if (argc == 1)
rt = ba1100(argc,argv);
else
if (argc >= 2)
{
const int r = (argc > 1) ? atoi(&argv[1][1]) : -1;
switch (r)
{
case 0:
ba1100(argc,argv); break;
case 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)
{
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;
return 0;
}

View File

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

View File

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

View File

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