3a770ee656
Files correlati : Ricompilazione Demo : [ ] Commento : Riportata la versione 01.05 patch 648 git-svn-id: svn://10.65.10.50/trunk@8633 c028cbd2-c16b-5b4b-a496-9718f37d4682
787 lines
19 KiB
C++
Executable File
787 lines
19 KiB
C++
Executable File
#include <colors.h>
|
|
#include <modaut.h>
|
|
#include <msksheet.h>
|
|
#include <prefix.h>
|
|
#include <relapp.h>
|
|
#include <utility.h>
|
|
#include <tree.h>
|
|
#include <urldefid.h>
|
|
|
|
#include "ba1.h"
|
|
#include "ba1500.h"
|
|
#include "ba0100a.h"
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// Menu item
|
|
///////////////////////////////////////////////////////////
|
|
|
|
class TMenu_item : public TString
|
|
{
|
|
TString _cmd;
|
|
|
|
public:
|
|
TObject* dup() const { return new TMenu_item(*this); }
|
|
|
|
const TString& cmd() const { return _cmd; }
|
|
TString& cmd() { return _cmd; }
|
|
|
|
TMenu_item(const char* line);
|
|
virtual ~TMenu_item() { }
|
|
};
|
|
|
|
TMenu_item::TMenu_item(const char* line)
|
|
{
|
|
TToken_string ts(line, ',');
|
|
set(ts.get(0)); trim();
|
|
if (operator[](0) == '"')
|
|
{ ltrim(1); rtrim(1); }
|
|
|
|
_cmd = ts.get(); _cmd.trim();
|
|
if (_cmd[0] == '"')
|
|
{ _cmd.ltrim(1); _cmd.rtrim(1); }
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// Sottomenu (lista di menu items)
|
|
///////////////////////////////////////////////////////////
|
|
|
|
class TSubmenu : public TString
|
|
{
|
|
TArray _child;
|
|
int _module;
|
|
|
|
public:
|
|
TMenu_item& operator[](int c) { return (TMenu_item&)*_child.objptr(c); }
|
|
TMenu_item& add_child(const char* line);
|
|
|
|
int items() const { return _child.items(); }
|
|
int module() const { return _module; }
|
|
void set_module(int m) { _module = m; }
|
|
|
|
TSubmenu& operator=(const char* str) { set(str); return *this; }
|
|
TSubmenu& operator=(const TSubmenu& str) { set(str); _module = str._module; return *this; }
|
|
|
|
TSubmenu() : _module(0) { }
|
|
virtual ~TSubmenu() { }
|
|
};
|
|
|
|
TMenu_item& TSubmenu::add_child(const char* line)
|
|
{
|
|
TMenu_item* item = new TMenu_item(line);
|
|
_child.add(item, -1);
|
|
return *item;
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// Nodo dell'albero del menu principale
|
|
///////////////////////////////////////////////////////////
|
|
|
|
class TMenu_node : public TString
|
|
{
|
|
TMenu_item* _item;
|
|
int _module;
|
|
|
|
public:
|
|
const TString& command() const;
|
|
int module() const { return _module; }
|
|
|
|
TMenu_node(TMenu_item* i, int module = 0);
|
|
TMenu_node(const char* str);
|
|
};
|
|
|
|
const TString& TMenu_node::command() const
|
|
{
|
|
if (_item)
|
|
return _item->cmd();
|
|
return EMPTY_STRING;
|
|
}
|
|
|
|
TMenu_node::TMenu_node(TMenu_item* i, int module)
|
|
: _item(i), _module(module)
|
|
{
|
|
set(*i);
|
|
}
|
|
|
|
TMenu_node::TMenu_node(const char* str)
|
|
: _item(NULL), _module(0)
|
|
{
|
|
set(str);
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// Menu tree (albero di menu nodes)
|
|
///////////////////////////////////////////////////////////
|
|
|
|
class TMenu : public TObject_tree
|
|
{
|
|
TAssoc_array _submenu; // Insieme dei sottomenu
|
|
TAssoc_array _prop; // Proprieta' dei singoli programmi
|
|
|
|
protected:
|
|
virtual bool add_son(TObject* son);
|
|
virtual bool get_description(TString& desc) const;
|
|
virtual TImage* image(bool selected) const;
|
|
|
|
protected:
|
|
TSubmenu& get_submenu(const char* name);
|
|
TSubmenu& add_submenu(const char* para, int parent_module);
|
|
void import(const char* filename, TString& first);
|
|
|
|
public:
|
|
virtual bool enabled() const;
|
|
|
|
TAssoc_array& properties() { return _prop; }
|
|
TString_array& properties(const char* cmd);
|
|
const TString_array* find_properties(const char* cmd) const;
|
|
|
|
TMenu();
|
|
virtual ~TMenu() { }
|
|
};
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// Main app
|
|
///////////////////////////////////////////////////////////
|
|
|
|
class TSet_user_passwd : public TRelation_application
|
|
{
|
|
protected:
|
|
TMask* _msk;
|
|
// TMenu* _tree;
|
|
TRelation* _rel;
|
|
TInformazione_moduli* _im;
|
|
|
|
protected:
|
|
virtual bool user_create();
|
|
virtual bool user_destroy();
|
|
virtual TMask* get_mask(int mode) { return _msk;}
|
|
virtual bool changing_mask(int mode) { return FALSE;}
|
|
virtual TRelation* get_relation() const { return _rel;}
|
|
virtual int read(TMask& m);
|
|
|
|
virtual void init_query_mode(TMask& m);
|
|
virtual void init_modify_mode(TMask& m);
|
|
virtual void init_insert_mode(TMask& m) {
|
|
build_sheet(NULL);
|
|
}
|
|
|
|
protected:
|
|
virtual void put_in_record(const TMask& m);
|
|
virtual int write(const TMask& m);
|
|
virtual int rewrite(const TMask& m);
|
|
|
|
TSheet_field& sheet_field() { return _msk->sfield(F_MODULI); }
|
|
void build_sheet(const TRectype* r);
|
|
void enable_aut();
|
|
|
|
static bool password_handler(TMask_field& f, KEY key);
|
|
public:
|
|
bool user_has_module(int mod);
|
|
|
|
TSet_user_passwd() : _msk(NULL), _rel(NULL) , _im(NULL) {}
|
|
};
|
|
|
|
|
|
class TSet_users : public TSet_user_passwd
|
|
{
|
|
TMenu* _tree;
|
|
protected:
|
|
virtual bool user_create();
|
|
virtual bool user_destroy();
|
|
virtual TMask* get_mask(int mode) { return _msk;}
|
|
virtual bool changing_mask(int mode) { return FALSE;}
|
|
virtual TRelation* get_relation() const { return _rel;}
|
|
virtual int read(TMask& m);
|
|
virtual bool remove();
|
|
|
|
virtual void init_query_mode(TMask& m) { enable_aut();}
|
|
virtual void init_insert_mode(TMask& m) { build_sheet(NULL); }
|
|
virtual void init_modify_mode(TMask& m) { enable_aut();}
|
|
|
|
protected:
|
|
// TSheet_field& sheet_field() { return _msk->sfield(F_MODULI); }
|
|
// void build_sheet(const TRectype* r);
|
|
void build_tree(const TRectype* r);
|
|
// void enable_aut();
|
|
virtual void put_in_record(const TMask& m);
|
|
|
|
static bool user_handler(TMask_field& f, KEY key);
|
|
static bool group_handler(TMask_field& f, KEY key);
|
|
// static bool password_handler(TMask_field& f, KEY key);
|
|
static bool k_notify(TSheet_field & f, int r, KEY k);
|
|
static bool tree_handler(TMask_field& f, KEY key);
|
|
static bool p_notify(TSheet_field & f, int r, KEY k);
|
|
|
|
public:
|
|
// bool user_has_module(int mod);
|
|
|
|
TSet_users() : TSet_user_passwd() , _tree(NULL) {}
|
|
};
|
|
|
|
inline TSet_users& app() { return (TSet_users&)main_app(); }
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// Menu tree implementation
|
|
///////////////////////////////////////////////////////////
|
|
|
|
const TString_array* TMenu::find_properties(const char* cmd) const
|
|
{
|
|
const TString_array* arr = (const TString_array*)_prop.objptr(cmd);
|
|
return arr;
|
|
}
|
|
|
|
TString_array& TMenu::properties(const char* cmd)
|
|
{
|
|
TString_array* arr = (TString_array*)_prop.objptr(cmd);
|
|
if (arr == NULL)
|
|
{
|
|
arr = new TString_array;
|
|
_prop.add(cmd, arr);
|
|
}
|
|
return *arr;
|
|
}
|
|
|
|
bool TMenu::add_son(TObject* son)
|
|
{
|
|
if (goto_firstson())
|
|
{
|
|
while (goto_rbrother());
|
|
return add_rbrother(son);
|
|
}
|
|
return TObject_tree::add_son(son);
|
|
}
|
|
|
|
bool TMenu::get_description(TString& desc) const
|
|
{
|
|
TMenu_node* node = (TMenu_node*)curr_node();
|
|
if (node) desc = *node;
|
|
return node != NULL;
|
|
}
|
|
|
|
bool TMenu::enabled() const
|
|
{
|
|
TMenu_node* node = (TMenu_node*)curr_node();
|
|
const int mod = node->module();
|
|
return app().user_has_module(mod);
|
|
}
|
|
|
|
TImage* TMenu::image(bool selected) const
|
|
{
|
|
TMenu_node* node = (TMenu_node*)curr_node();
|
|
if (!has_son())
|
|
{
|
|
const TString& cmd = node->command();
|
|
if (cmd.not_empty())
|
|
{
|
|
const TString_array* prop = find_properties(cmd);
|
|
if (prop)
|
|
{
|
|
TString80 action;
|
|
FOR_EACH_ARRAY_ROW_BACK(*prop, r, row)
|
|
{
|
|
row->get(1, action);
|
|
if (action == "Negato")
|
|
return get_res_image(BMP_STOP);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return TObject_tree::image(selected);
|
|
}
|
|
|
|
TSubmenu& TMenu::get_submenu(const char* name)
|
|
{
|
|
TSubmenu* sub = (TSubmenu*)_submenu.objptr(name);
|
|
if (sub == NULL)
|
|
{
|
|
sub = new TSubmenu;
|
|
_submenu.add(name, sub);
|
|
}
|
|
return *sub;
|
|
}
|
|
|
|
|
|
void TMenu::import(const char* filename, TString& first)
|
|
{
|
|
TSubmenu* sub;
|
|
TScanner scan(filename);
|
|
first.cut(0);
|
|
while (scan.good())
|
|
{
|
|
TString& line = scan.line();
|
|
if (line[0] == '[')
|
|
{
|
|
if (first.empty())
|
|
first = line;
|
|
sub = &get_submenu(line);
|
|
} else
|
|
if (line.compare("Caption", 7, TRUE) == 0)
|
|
{
|
|
CHECK(sub, "Invalid menu file");
|
|
const int equal = line.find('=');
|
|
CHECK(equal > 0, "Invalid menu Caption");
|
|
line.ltrim(equal+1);
|
|
line.strip("\"");
|
|
*sub = line;
|
|
} else
|
|
if (line.compare("Module", 6, TRUE) == 0)
|
|
{
|
|
CHECK(sub, "Invalid menu file");
|
|
const int equal = line.find('=');
|
|
CHECK(equal > 0, "Invalid menu Module");
|
|
sub->set_module(atoi(line.mid(equal+1)));
|
|
} else
|
|
if (line.compare("Item", 4, TRUE) == 0)
|
|
{
|
|
CHECK(sub, "Invalid menu file");
|
|
const int equal = line.find('=');
|
|
CHECK(equal > 0, "Invalid menu Item");
|
|
line.ltrim(equal+1);
|
|
line.trim();
|
|
const int bracket = line.rfind('<');
|
|
if (bracket > 0)
|
|
{
|
|
TString16 name = line.mid(bracket+1);
|
|
name.strip("< >");
|
|
if (fexist(name))
|
|
{
|
|
import(name, name);
|
|
TMenu_item& child = sub->add_child(line);
|
|
child.cmd() = name;
|
|
}
|
|
}
|
|
else
|
|
sub->add_child(line);
|
|
}
|
|
}
|
|
}
|
|
|
|
TSubmenu& TMenu::add_submenu(const char* para, int parent_module)
|
|
{
|
|
TSubmenu& sub = get_submenu(para);
|
|
int module = sub.module();
|
|
if (module == 0)
|
|
module = parent_module;
|
|
TString id; curr_id(id);
|
|
for (int i = 0; i < sub.items(); i++)
|
|
{
|
|
goto_node(id);
|
|
add_son(new TMenu_node(&sub[i], module));
|
|
if (sub[i].cmd()[0] == '[')
|
|
add_submenu(sub[i].cmd(), module);
|
|
}
|
|
return sub;
|
|
}
|
|
|
|
TMenu::TMenu()
|
|
{
|
|
TString root;
|
|
import("baprassi.men", root);
|
|
add_son(new TMenu_node("Menu Principale"));
|
|
add_submenu(root, 0);
|
|
goto_root();
|
|
expand();
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// Main application
|
|
///////////////////////////////////////////////////////////
|
|
|
|
bool TSet_users::user_handler(TMask_field& f, KEY key)
|
|
{
|
|
if (!f.mask().query_mode() || !f.to_check(key))
|
|
return TRUE;
|
|
const bool ok = f.get().find(' ') < 0;
|
|
if (!ok)
|
|
return f.error_box("Il nome dell'utente non deve contenere spazi");
|
|
return ok;
|
|
}
|
|
|
|
bool TSet_users::group_handler(TMask_field& f, KEY key)
|
|
{
|
|
if (key == K_TAB && f.focusdirty())
|
|
{
|
|
TMask& m = f.mask();
|
|
const TString& gruppo = m.get(F_GROUPNAME);
|
|
TEdit_field& ef = (TEdit_field&)f;
|
|
TRectype& rec = ef.browse()->cursor()->curr();
|
|
if (rec.get("USERNAME") != gruppo)
|
|
{
|
|
rec.put("USERNAME", gruppo);
|
|
ef.browse()->cursor()->read();
|
|
}
|
|
app().build_sheet(&rec);
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
bool TSet_user_passwd::password_handler(TMask_field& f, KEY key)
|
|
{
|
|
if (f.mask().query_mode() || key != K_ENTER) return TRUE;
|
|
const bool ok = f.get().len() > 3 && f.get().find(' ') < 0;
|
|
|
|
if (!ok) return f.error_box("La password deve essere lunga almeno 4 caratteri e non contenere spazi");
|
|
return ok;
|
|
}
|
|
|
|
bool TSet_users::tree_handler(TMask_field& f, KEY key)
|
|
{
|
|
TTree_field& tf = (TTree_field&)f;
|
|
TMenu* menu = (TMenu*)tf.tree();
|
|
const TMenu_node* node = (const TMenu_node*)(menu ? menu->curr_node() : NULL);
|
|
if (node)
|
|
{
|
|
if (key == K_SPACE || key == K_ENTER)
|
|
{
|
|
TMask& m = f.mask();
|
|
TSheet_field& sf = m.sfield(F_PROPERTIES);
|
|
|
|
const TString& old = m.get(F_APPLICAT);
|
|
if (old.not_empty())
|
|
{
|
|
menu->properties(old) = sf.rows_array();
|
|
|
|
const TString16 mod = old.left(2);
|
|
TString_array& mprop = menu->properties(mod);
|
|
if (m.get_bool(F_NOWRITE))
|
|
{
|
|
if (mprop.items() == 0)
|
|
{
|
|
TToken_string* ts = new TToken_string("S|Scrittura|0", sf.separator());
|
|
ts->replace('|', sf.separator());
|
|
mprop.add(ts);
|
|
}
|
|
}
|
|
else
|
|
mprop.destroy();
|
|
|
|
sf.destroy();
|
|
m.reset(F_APPLICAT);
|
|
m.reset(F_NOWRITE); m.disable(F_NOWRITE);
|
|
}
|
|
|
|
if (menu->enabled())
|
|
{
|
|
const TString& cmd = node->command();
|
|
if (cmd[0] != '[')
|
|
{
|
|
m.set(F_APPLICAT, cmd);
|
|
const TString_array* prop = menu->find_properties(cmd);
|
|
if (prop)
|
|
{
|
|
sf.rows_array() = *prop;
|
|
FOR_EACH_SHEET_ROW(sf, r, n)
|
|
sf.check_row(r);
|
|
sf.force_update();
|
|
}
|
|
const TString16 mod = cmd.left(2);
|
|
const TString_array* mprop = menu->find_properties(mod);
|
|
m.enable(F_NOWRITE);
|
|
m.set(F_NOWRITE, mprop && mprop->items() ? "X" : "");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
bool TSet_users::p_notify(TSheet_field& f, int r, KEY k)
|
|
{
|
|
switch(k)
|
|
{
|
|
case K_INS:
|
|
{
|
|
TMask& m = f.mask();
|
|
if (m.get(F_APPLICAT).empty())
|
|
return error_box("Nessun programma selezionato");
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
void TSet_user_passwd::build_sheet(const TRectype* r)
|
|
{
|
|
TString autstr;
|
|
TSheet_field& sf = sheet_field();
|
|
if (r != NULL)
|
|
{
|
|
autstr = r->get("AUTSTR");
|
|
}
|
|
const int l = autstr.len();
|
|
sf.destroy();
|
|
|
|
TString d;
|
|
for (int i = 0; i < ENDAUT; i++)
|
|
{
|
|
d = _im->get_description_by_order(i);
|
|
if (d.trim().empty())
|
|
continue;
|
|
TToken_string& riga = sf.row(i);
|
|
riga = d;
|
|
const int module = _im->get_module_by_order(i);
|
|
if (r!= NULL && module<l && autstr[module]=='X')
|
|
riga.add("X");
|
|
else
|
|
{
|
|
riga.add(" ");
|
|
}
|
|
riga.add(module);
|
|
}
|
|
enable_aut();
|
|
sf.force_update();
|
|
}
|
|
|
|
void TSet_users::build_tree(const TRectype* r)
|
|
{
|
|
_tree->properties().destroy();
|
|
|
|
if (r)
|
|
{
|
|
TToken_string prop_field(r->get("PERMISSION"), '\n');
|
|
TToken_string pro("",SAFE_PIPE_CHR),row("",SAFE_PIPE_CHR);
|
|
TString app;
|
|
FOR_EACH_TOKEN(prop_field, tok)
|
|
{
|
|
pro = tok;
|
|
pro.get(0, app);
|
|
app.trim();
|
|
if (!app.empty())
|
|
{
|
|
TString_array& prop = _tree->properties(app);
|
|
row = pro.get(1);
|
|
row.add(pro.get());
|
|
row.add(pro.get());
|
|
prop.add(row);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// mostra le abilitazioni
|
|
void TSet_user_passwd::enable_aut()
|
|
{
|
|
const bool prassi = _msk->get(F_USER) == ::dongle().administrator();
|
|
const int uns = _im->unassigned();
|
|
TSheet_field& sf = sheet_field();
|
|
const int itms = sf.items();
|
|
for (int i = 0; i < itms; i++)
|
|
{
|
|
const int module = _im->get_module_by_order(i+uns);
|
|
TToken_string& riga = sf.row(i);
|
|
if (module == BAAUT || module == MUAUT)
|
|
{
|
|
sf.disable_cell(i,1);
|
|
riga.add("X",1);
|
|
}
|
|
else
|
|
{
|
|
sf.enable_cell(i,1,!prassi && has_module(module, CHK_DONGLE));
|
|
if (prassi) riga.add("X",1);
|
|
}
|
|
}
|
|
}
|
|
|
|
bool TSet_user_passwd::user_has_module(int mod)
|
|
{
|
|
bool yes = mod <= 0;
|
|
if (!yes)
|
|
{
|
|
const int idx = _im->get_index(mod);
|
|
if (idx >= 0)
|
|
{
|
|
TSheet_field& sf = sheet_field();
|
|
yes = *sf.cell(idx, 1) > ' ';
|
|
}
|
|
}
|
|
return yes;
|
|
}
|
|
|
|
bool TSet_users::k_notify(TSheet_field& f, int r, KEY k)
|
|
{
|
|
if (k == K_INS)
|
|
return FALSE;
|
|
return TRUE;
|
|
}
|
|
|
|
bool TSet_user_passwd::user_create()
|
|
{
|
|
bool superuser = user() == ::dongle().administrator();
|
|
_rel = new TRelation(LF_USER);
|
|
|
|
_im = new TInformazione_moduli;
|
|
|
|
_msk = new TMask("ba1400a") ;
|
|
_msk->first_focus(F_USER);
|
|
_msk->set_handler(F_PASSWORD, password_handler);
|
|
|
|
sheet_field().enable(superuser);
|
|
_msk->enable_page(1, superuser);
|
|
_msk->enable(-G_SUPERUSER, superuser);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
bool TSet_users::user_create()
|
|
{
|
|
TSet_user_passwd::user_create();
|
|
|
|
_msk->set_handler(F_USER, user_handler);
|
|
_msk->set_handler(F_GROUPNAME, group_handler);
|
|
TSheet_field& sf = sheet_field();
|
|
sf.set_notify(k_notify);
|
|
|
|
_tree = new TMenu;
|
|
_msk->set_handler(F_PERMESSI, tree_handler);
|
|
_msk->tfield(F_PERMESSI).set_tree(_tree);
|
|
_msk->sfield(F_PROPERTIES).set_notify(p_notify);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
int TSet_users::read(TMask& m)
|
|
{
|
|
TRelation_application::read(m);
|
|
const TRectype& r = get_relation()->curr();
|
|
build_sheet(&r);
|
|
|
|
const TString16 pwd = decode(r.get("PASSWORD"));
|
|
m.set(F_PASSWORD, pwd);
|
|
m.set(F_TEST, pwd);
|
|
|
|
build_tree(&r);
|
|
|
|
return NOERR;
|
|
}
|
|
|
|
|
|
void TSet_user_passwd::put_in_record(const TMask& m)
|
|
{
|
|
const TString16 s = encode(m.get(F_PASSWORD));
|
|
TRectype& r = get_relation()->curr();
|
|
if (_msk->get(F_USER) == user())
|
|
r.put("PASSWORD", s);
|
|
else
|
|
error_box("Impossibile cambiare la password di altri utenti");
|
|
}
|
|
|
|
void TSet_users::put_in_record(const TMask& m)
|
|
{
|
|
TString autstr(ENDAUT, ' ');
|
|
TSheet_field& sf = sheet_field();
|
|
FOR_EACH_SHEET_ROW(sf, i, riga)
|
|
{
|
|
const char c = riga->get(1)[0];
|
|
const int module = riga->get_int();
|
|
if (c == 'X')
|
|
autstr[module] = c;
|
|
}
|
|
|
|
const TString16 s = encode(m.get(F_PASSWORD));
|
|
TRectype& r = get_relation()->curr();
|
|
r.put("PASSWORD", s);
|
|
r.put("AUTSTR", autstr);
|
|
|
|
TToken_string prop_field(256, '\n');
|
|
TAssoc_array& prop = _tree->properties();
|
|
TString prg;
|
|
FOR_EACH_ASSOC_OBJECT(prop, hash, key, obj)
|
|
{
|
|
TString_array& arr = *(TString_array*)obj;
|
|
prg = key;
|
|
prg << m.sfield(F_PROPERTIES).separator();
|
|
FOR_EACH_ARRAY_ROW(arr, r, row)
|
|
{
|
|
row->insert(prg, 0);
|
|
prop_field.add(*row);
|
|
}
|
|
}
|
|
r.put("PERMISSION", prop_field);
|
|
}
|
|
|
|
int TSet_user_passwd::write(const TMask& m)
|
|
{
|
|
put_in_record(m);
|
|
return TRelation_application::write(m);
|
|
}
|
|
|
|
int TSet_user_passwd::rewrite(const TMask& m)
|
|
{
|
|
put_in_record(m);
|
|
return TRelation_application::rewrite(m);
|
|
}
|
|
|
|
bool TSet_users::remove()
|
|
{
|
|
const bool ok = TRelation_application::remove();
|
|
if (ok)
|
|
{
|
|
const TString16 u = get_relation()->curr().get("USERNAME");
|
|
TFilename file = firm2dir(-1); // Directory dati
|
|
file.add("config"); // Directory configurazioni
|
|
file.add(u); // Nome utente
|
|
file.ext("ini"); // Estensione
|
|
::remove(file);
|
|
}
|
|
return ok;
|
|
}
|
|
|
|
bool TSet_user_passwd::user_destroy()
|
|
{
|
|
if (_msk != NULL) delete _msk;
|
|
if (_rel != NULL) delete _rel;
|
|
if (_im != NULL) delete _im;
|
|
return TRUE;
|
|
}
|
|
bool TSet_users::user_destroy()
|
|
{
|
|
TSet_user_passwd::user_destroy();
|
|
if (_tree != NULL) delete _tree;
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
int TSet_user_passwd::read(TMask& m)
|
|
{
|
|
TRelation_application::read(m);
|
|
const TRectype& r = get_relation()->curr();
|
|
build_sheet(&r);
|
|
|
|
const TString16 pwd =decode(r.get("PASSWORD"));
|
|
m.set(F_PASSWORD, pwd);
|
|
m.set(F_TEST, pwd);
|
|
|
|
return NOERR;
|
|
}
|
|
|
|
void TSet_user_passwd::init_query_mode(TMask& m)
|
|
{
|
|
enable_aut();
|
|
_msk->set(F_USER,user());
|
|
_msk->send_key(K_AUTO_ENTER,0);
|
|
_msk->disable(DLG_FINDREC);
|
|
_msk->disable(DLG_DELREC);
|
|
}
|
|
|
|
void TSet_user_passwd::init_modify_mode(TMask& m)
|
|
{
|
|
enable_aut();
|
|
_msk->disable(DLG_FINDREC);
|
|
_msk->disable(DLG_DELREC);
|
|
}
|
|
|
|
int ba1400(int argc, char** argv)
|
|
{
|
|
if (user() == ::dongle().administrator())
|
|
{
|
|
TSet_users a ;
|
|
a.run(argc, argv, "Configurazione utenti");
|
|
} else {
|
|
TSet_user_passwd a ;
|
|
a.run(argc, argv, "Configurazione utenti");
|
|
}
|
|
return 0;
|
|
}
|