Corretta la gestione degli utenti e delle connessioni per la versione Terminal Server

git-svn-id: svn://10.65.10.50/trunk@11924 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
alex 2004-03-31 12:48:16 +00:00
parent 3234b3f1d9
commit 5e88c2707b
8 changed files with 96 additions and 60 deletions

View File

@ -22,6 +22,7 @@
#include "ba0.h"
#include "ba0101.h"
#include "ba0102.h"
#include "ba0100.h"
#include "ba0100a.h"
#include "ba0400a.h"
@ -45,13 +46,13 @@
class TMenu_application : public TSkeleton_application
{
const char* _name;
TMenu _menu;
int _tree_view;
TString_array _preferred;
TMask* _mask;
static int _last_button;
static bool _find_button;
@ -66,7 +67,7 @@ protected: // TApplication
protected:
void deconnect_user();
virtual void main_loop();
void test_temp();
void load_menu();
int do_level();
@ -85,7 +86,7 @@ protected:
bool choose_colors();
bool choose_editors();
bool choose_study();
void load_preferences();
void save_preferences();
void update_preferred_tree();
@ -96,7 +97,7 @@ protected:
bool test_programs();
bool test_network();
public:
public:
static bool tree_find_handler(TMask_field& f, KEY k);
static bool tree_shrink_handler(TMask_field& f, KEY k);
@ -548,7 +549,7 @@ bool TMenu_application::menu_find_handler(TMask_field&f, KEY k)
if (app()._menu.find_string(v))
{
f.set_focusdirty(FALSE);
return f.mask().stop_run(K_F9);
return m.stop_run(K_F9);
}
else
{
@ -592,7 +593,7 @@ int TMenu_application::do_level()
ef.set_handler(menu_find_handler);
const bool top = _menu.at_top();
TButton_field& bf = mask.add_button(DLG_QUIT, 0, PR("Fine"), -12, -1, bwidth, 2);
mask.add_button(DLG_QUIT, 0, PR("Fine"), -12, -1, bwidth, 2);
if (!top)
mask.add_button(DLG_CANCEL, 0, TR("Menu precedente"), -22, -1, bwidth, 2);
@ -765,8 +766,8 @@ bool TMenu_application::check_user()
if (ok)
{
dongle().logout();
user() = utente;
dongle().logout();
ok = get_serial_number() >= 0;
if (!ok)
error_box(TR("Probabilmente è stato superato il numero massimo di utenti"));
@ -1046,7 +1047,9 @@ HIDDEN bool browse_file_handler(TMask_field& f, KEY k)
{
FILE_SPEC fs; memset(&fs, 0, sizeof(FILE_SPEC));
xvt_fsys_convert_str_to_dir(".", &fs.dir);
#ifdef WIN32
strcpy(fs.type, "EXE");
#endif
strcpy(fs.name, f.get());
strcpy(fs.creator, "MENU");
@ -1069,10 +1072,13 @@ HIDDEN bool browse_file_handler(TMask_field& f, KEY k)
if (infile.not_empty())
{
TFilename outfile;
if (*infile.ext() == '\0')
infile.ext("exe");
if (!infile.search_in_path(outfile))
ok = error_box("Il programma %s non esiste!", (const char*)infile);
{
if (*infile.ext() == '\0')
infile.ext("exe");
if (!infile.search_in_path(outfile))
ok = error_box("Il programma %s non esiste!", (const char*)infile);
}
}
}
@ -1141,7 +1147,7 @@ HIDDEN int dir_sort(const TObject** d1, const TObject** d2)
{
const TString& s1 = (const TString&)**d1;
const TString& s2 = (const TString&)**d2;
return stricmp(s1, s2);
return xvt_str_compare_ignoring_case(s1, s2);
}
HIDDEN bool study_handler(TMask_field& f, KEY k)
@ -1317,7 +1323,8 @@ bool TMenu_application::explore_handler(TMask_field& f, KEY k)
void TMenu_application::update_preferred()
{
MENU_ITEM* mm = xvt_menu_get_tree(TASK_WIN);
for (MENU_ITEM* mi = mm; mi != NULL && mi->tag != 0 && mi->tag != PREFERRED_MENU; mi++);
MENU_ITEM* mi;
for (mi = mm; mi != NULL && mi->tag != 0 && mi->tag != PREFERRED_MENU; mi++);
if (mi == NULL || mi->tag <= 0 || mi->child == NULL)
{
NFCHECK("Can't find Preferiti Menu");
@ -1410,7 +1417,8 @@ void TMenu_application::load_preferences()
void TMenu_application::save_preferences()
{
TConfig cfg(CONFIG_GUI, "ba0");
for (int i = 0; i < _preferred.items(); i++)
int i;
for (i = 0; i < _preferred.items(); i++)
cfg.set("Preferred", _preferred.row(i), NULL, TRUE, i);
cfg.set("Preferred", "", NULL, TRUE, i);
cfg.set("TreeView", _tree_view);
@ -1584,7 +1592,7 @@ int TMenu_application::do_tree()
tree_fld.set_tree(&tree);
tree_fld.set_handler(tree_handler);
TMask_field& sf = mask.add_static(DLG_NULL, 0, PR("Cerca"), -2, 0);
mask.add_static(DLG_NULL, 0, PR("Cerca"), -2, 0);
TEdit_field& ef = mask.add_string(DLG_USER, 0, "", -2, 1, 50, "", bwidth);
ef.set_handler(tree_find_handler);
@ -1592,7 +1600,7 @@ int TMenu_application::do_tree()
TButton_field& mf = mask.add_button(201, 0, PR("Menu Principale"), -1, 2, bwidth, 2);
mf.set_handler(tree_shrink_handler);
TButton_field& bf = mask.add_button(DLG_QUIT, 0, PR("Fine"), -56, -1, bwidth/2, 2);
mask.add_button(DLG_QUIT, 0, PR("Fine"), -56, -1, bwidth/2, 2);
mask.first_focus(DLG_TREE);
KEY key = mask.run();
@ -1625,7 +1633,7 @@ int TMenu_application::do_explore()
TEdit_field& ef = mask.add_string(DLG_USER, 0, PR("Cerca "), 11, -4, 50);
ef.set_handler(tree_find_handler);
TButton_field& bf = mask.add_button(DLG_QUIT, 0, "", -12, -2, 18, 2);
mask.add_button(DLG_QUIT, 0, "", -12, -2, 18, 2);
TButton_field& mp = mask.add_button(201, 0, PR("Menu Principale"), -22, -2, 18, 2);
mp.set_handler(tree_shrink_handler);

View File

@ -3,7 +3,7 @@
#define F_USERDESC 103
#define F_GROUP 104
#define F_GROUPNAME 105
#define F_TEST 106
#define F_TESTS 106
#define F_APPLICAT 107
#define F_NOWRITE 108

View File

@ -10,6 +10,7 @@
#include "ba0100a.h"
#include "ba0101.h"
#include "ba0100.h"
///////////////////////////////////////////////////////////
// Menu management
@ -62,7 +63,8 @@ static int get_next_int(const char* s, int from, int& val)
return -1;
const char* start = NULL;
for (int i = from; s[i]; i++)
int i = 0;
for (i = from; s[i]; i++)
{
if (start == NULL)
{
@ -102,17 +104,25 @@ public:
///////////////////////////////////////////////////////////
TMenuitem::TMenuitem(TSubmenu* sm)
: _submenu(sm), _exist(-1), _firm(FALSE),
_password(FALSE), _reloadmenu(FALSE),
_color(NORMAL_COLOR), _icon(0)
: _submenu(sm), _icon(0),_color(NORMAL_COLOR), _exist(-1),
_firm(FALSE), _password(FALSE), _reloadmenu(FALSE)
{ }
TMenuitem::TMenuitem(const TMenuitem& mi)
: _submenu(mi._submenu), _exist(mi._exist), _firm(mi._firm),
_password(mi._password), _reloadmenu(mi._reloadmenu),
_color(mi._color), _icon(mi._icon), _enabled(mi._enabled),
_caption(mi._caption), _action(mi._action), _type(mi._type)
{ }
TMenuitem::TMenuitem(const TMenuitem& mi)
{
_submenu = mi._submenu;
_exist = mi._exist;
_firm = mi._firm;
_password = mi._password;
_reloadmenu = mi._reloadmenu;
_color = mi._color;
_icon = mi._icon;
_enabled = mi._enabled;
_caption = mi._caption;
_action = mi._action;
_type = mi._type;
}
TMenu& TMenuitem::menu() const
@ -192,14 +202,21 @@ bool TMenuitem::enabled() const
{
const int endname = _action.find(' ');
TFilename name(endname > 0 ? _action.left(endname) : _action);
const char* ext[] = { "exe", "pif", "com", "bat", NULL };
for (int e = 0; ext[e]; e++)
if (name.exist())
yes = TRUE;
else
{
name.ext(ext[e]);
if (name.exist())
break;
}
yes = ext[e] != NULL;
const char* ext[] = { "exe", "pif", "com", "bat", NULL };
int e;
for (e = 0; ext[e]; e++)
{
name.ext(ext[e]);
if (name.exist())
break;
}
yes = ext[e] != NULL;
}
}
((TMenuitem*)this)->_exist = yes;
}
@ -242,16 +259,16 @@ bool TMenuitem::perform_program() const
}
if (!ok) error_box("Password di servizio errata!\nAccesso negato.");
}
if (_firm && main_app().get_firm() == 0)
#ifdef _DEMO_
ok = menu().set_firm(1);
#else
#else
ok = menu().set_firm(0);
#endif
if (ok)
{
{
TCurrency::force_cache_update(); // Chiude cache valute
prefix().set(NULL); // Chiude prefix
TExternal_app a(_action);
@ -309,7 +326,7 @@ bool TMenuitem::perform() const
///////////////////////////////////////////////////////////
TSubmenu::TSubmenu(TMenu* menu, const char* name)
: _menu(menu), _name(name), _enabled(TRUE), _firm(FALSE), _items(12)
: _menu(menu), _name(name), _items(12), _enabled(TRUE), _firm(FALSE)
{
}
@ -560,7 +577,10 @@ TSubmenu* TMenu::find_string(const TString& str)
}
restart();
for (TSubmenu* sm = (TSubmenu*)get(); sm; sm = (TSubmenu*)get())
TSubmenu * sm;
for (sm = (TSubmenu*)get(); sm; sm = (TSubmenu*)get())
{
if (sm->enabled() && !_ignore_list.is_key(sm->name()))
{
@ -585,7 +605,8 @@ TSubmenu* TMenu::find_string(const TString& str)
TSubmenu* TMenu::find_parent(const TSubmenu& sub)
{
restart();
for (TSubmenu* sm = (TSubmenu*)get(); sm; sm = (TSubmenu*)get())
TSubmenu* sm;
for (sm = (TSubmenu*)get(); sm; sm = (TSubmenu*)get())
{
for (int i = sm->items()-1; i >= 0; i--)
{

View File

@ -31,12 +31,13 @@ class TMenuitem : public TObject
TString _caption, _action;
int _icon;
char _type;
COLOR _color;
int _exist : 2;
bool _enabled : 2;
bool _firm : 2;
bool _password : 2;
bool _reloadmenu : 2;
char _exist : 2;
char _enabled : 2;
char _firm : 2;
char _password : 2;
char _reloadmenu : 2;
protected:
bool perform_submenu() const;

View File

@ -363,7 +363,7 @@ TObject* TMenulist_images::key2obj(const char* key)
const int w = image.width();
const int h = image.height();
const int radius = min(w, h) / 4;
const clock_t start_timer = clock();
// const clock_t start_timer = clock();
for (int y = h-1; y >= 0; y--)
{
for (int x = w-1; x >= 0; x--)
@ -383,7 +383,7 @@ TObject* TMenulist_images::key2obj(const char* key)
}
}
}
const clock_t stop_timer = clock()-start_timer;
// const clock_t stop_timer = clock()-start_timer;
RCT rct; xvt_vobj_get_client_rect(_win, &rct);
const double ratiox = double(rct.right) / image.width();
@ -465,11 +465,11 @@ void TMenulist_window::draw_item(int i)
const int left = col * width / MENU_COLS;
const int right = (col+1) * width / MENU_COLS;
const int top = row * height / MENU_ROWS;
const int bottom = (row+1) * height / MENU_ROWS;
// const int bottom = (row+1) * height / MENU_ROWS;
const int maxchars = (right-left)/CHARX - 1;
const int cx = (left+right)/2;
const int cy = (top+bottom)/2;
// const int cy = (top+bottom)/2; verificare
const int ico = item.enabled() ? item.icon() : 0;
const int ix = cx-16;
@ -585,7 +585,7 @@ void TMenulist_window::handler(WINDOW win, EVENT* ep)
RCT rct; xvt_vobj_get_client_rect(win, &rct);
const int row = ep->v.mouse.where.v * MENU_ROWS / rct.bottom;
const int col = ep->v.mouse.where.h * MENU_COLS / rct.right;
const index = row * MENU_COLS + col;
const int index = row * MENU_COLS + col;
if (ep->v.mouse.button > 0) // Tasto destro
{
if (index < _sorted.items())

View File

@ -155,7 +155,7 @@ XVT_FNTID xvt_default_font(bool bold)
#ifdef WIN32
font_ser_desc = "01\\Courier\\0\\10\\WIN01/-13/0/0/0/400/0/0/0/0/1/2/1/49/Courier";
#else
font_ser_desc = "01\\Courier\\0\\10\\WIN01/12/0/0/0/400/0/0/0/0/1/2/1/49/Courier";
font_ser_desc = "01\\Courier\\0\\10\\WIN01/10/0/0/0/400/0/0/0/0/1/2/1/49/Courier";
#endif
xvt_font_deserialize(DEF_FONT, (char *)(const char *) font_ser_desc);
xvt_font_map_using_default(DEF_FONT);

View File

@ -442,14 +442,16 @@ bool TDongle::eutron_login(bool test_all_keys)
bool TDongle::network_login(bool test_all_keys)
{
if (network())
if (network() && ok())
rpc_UserLogout();
TConfig ini(CONFIG_INSTALL, "Server");
const char* server = ini.get("Dongle");
const char* guest = "******";
const TString16 appname = main_app().name();
const char* utente = (!main_app().is_running() && appname == "ba0100") ? guest : (const char *) user();
// const char* guest = "******";
// const TString16 appname = main_app().name();
// const char* utente = (!main_app().is_running() && appname == "ba0100") ? guest : (const char *) user();
const char* appname = main_app().name();
const char* utente = user();
const bool ok = rpc_UserLogin(server, utente, "******", appname);
if (ok)

View File

@ -261,9 +261,12 @@ bool rpc_UserLogin(const char* server, const char* user,
if (_connection)
{
TString16 password;
CreatePassword(password);
_rpc_call.format("UserLogin(%s,%s,%s)", user, (const char*)password, application);
const int session = xvt_sys_get_session_id();
_rpc_call.format("UserLogin(%s,%s,%s,%d)", user, (const char*)password, application, session);
long answer = 0;
bool connected = _client->RequestInteger(_connection, _rpc_call, answer) != 0;
if (connected)
@ -303,7 +306,8 @@ bool rpc_UserLogout()
{
if (_connection)
{
_rpc_call.format("UserLogout(%s)", (const char*)user());
const int session = xvt_sys_get_session_id();
_rpc_call.format("UserLogout(%s, %d)", (const char*)user(), session);
rpc_Call(_rpc_call);
_client->RemoveConnection(_connection);
_connection = 0;