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

git-svn-id: svn://10.65.10.50/trunk@11925 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
alex 2004-03-31 12:57:12 +00:00
parent 5e88c2707b
commit f5b07fd56f
7 changed files with 87 additions and 31 deletions

View File

@ -16,6 +16,7 @@
#include <sys/types.h>
#include <mntent.h>
#include <sys/vfs.h>
#include <unistd.h>
wxString OsLinux_File2App(const char* filename)
{
@ -245,3 +246,23 @@ void OsLinux_SetCaptionStyle(wxWindow * w, bool set)
}
int OsLinux_GetSessionId()
{
char s[80];
strcpy(s, getenv("DISPLAY"));
char * p = strchr(s, ':');
if (p == NULL)
p = s;
else
p++;
char * e = strchr(p, '.');
if (e != NULL)
*e = '\0';
return atoi(p);
}

View File

@ -21,4 +21,5 @@ void OsLinux_GetFileSys(const char* path, char * dev, char * dir, char * type);
bool OsLinux_IsNetworkDrive(const char * path);
int64_t OsLinux_GetDiskFreeSpace(const char * path);
void OsLinux_SetCaptionStyle(wxWindow * w, bool set);
int OsLinux_GetSessionId();

View File

@ -3,6 +3,7 @@
#include "wx/paper.h"
#include "oswin32.h"
#include "aclapi.h"
#include "xvt_menu.h"
#include "xvt_help.h"
@ -803,3 +804,19 @@ bool OsWin32_Speak(const char* text, bool async)
#endif
int OsWin32_GetSessionId()
{
char str[32];
xvt_sys_get_user_name(str, sizeof(str));
unsigned short h = 0;
for (const char* s = str; *s; s++)
{
h = (h << 2) + *s;
const unsigned short i = h & 0xC000;
if (i) h = (h ^ (i >> 12)) & 0x3FFF;
}
return (int) h;
}

View File

@ -33,6 +33,7 @@ bool OsWin32_SL_ReadBlock(unsigned short reg, unsigned short size, unsigned shor
bool OsWin32_SL_WriteBlock(unsigned short reg, unsigned short size, const unsigned short* data);
BOOL OsWin32_SpoolRow(const char* pData, unsigned int cbBytes, unsigned int hPrnDC);
int OsWin32_GetSessionId();
#ifdef SPEECH_API
bool OsWin32_InitializeSpeech();

View File

@ -3663,7 +3663,7 @@ BOOLEAN xvt_sys_get_host_name(char* name, int maxlen)
BOOLEAN xvt_sys_get_user_name(char* name, int maxlen)
{
wxString str = wxGetUserId();
str.MakeUpper();
// str.MakeUpper();
const int len = str.Length();
strncpy(name, str, maxlen);
name[maxlen-1] = '\0';
@ -3704,6 +3704,12 @@ TIconizeTaskThread::TIconizeTaskThread()
long xvt_sys_execute(const char* cmdline, BOOLEAN sync, BOOLEAN iconizetask)
{
long exitcode = 0;
wxString cmd(cmdline);
#ifdef LINUX
if (isalpha(cmd[0u]))
cmd = "./" + cmd;
#endif
if (sync)
{
@ -3716,7 +3722,7 @@ long xvt_sys_execute(const char* cmdline, BOOLEAN sync, BOOLEAN iconizetask)
it = new TIconizeTaskThread();
__bChildRunning = true;
exitcode = wxExecute(cmdline, wxEXEC_SYNC);
exitcode = wxExecute(cmd, wxEXEC_SYNC);
__bChildRunning = false;
wxFrame* frame = (wxFrame*)_task_win;
@ -3726,10 +3732,10 @@ long xvt_sys_execute(const char* cmdline, BOOLEAN sync, BOOLEAN iconizetask)
frame->Raise();
}
else
exitcode = wxExecute(cmdline, wxEXEC_SYNC);
exitcode = wxExecute(cmd, wxEXEC_SYNC);
}
else
exitcode = wxExecute(cmdline, wxEXEC_ASYNC);
exitcode = wxExecute(cmd, wxEXEC_ASYNC);
return exitcode;
}
@ -3882,6 +3888,15 @@ unsigned int xvt_sys_load_icon(const char* file)
return id;
}
int xvt_sys_get_session_id()
{
#ifdef WIN32
return OsWin32_GetSessionId();
#else
return OsLinux_GetSessionId();
#endif
}
unsigned long xvt_sys_get_free_memory()
{
unsigned long mem = ::wxGetFreeMemory();

View File

@ -289,6 +289,7 @@ XVTDLL int xvt_sys_get_profile_string(const char* file, const char* paragra
const char* defval, char* value, int maxsize);
XVTDLL BOOLEAN xvt_sys_set_profile_string(const char* file, const char* paragraph, const char* name,
const char* value);
XVTDLL int xvt_sys_get_session_id();
XVTDLL unsigned long xvt_sys_get_free_memory();
XVTDLL unsigned long xvt_sys_get_free_memory_kb();
XVTDLL int xvt_sys_get_os_version();

View File

@ -776,9 +776,11 @@ const char* xvt_fsys_get_campo_ini()
char exedir[_MAX_PATH], path[_MAX_PATH];
// Nelle installazioni sfigate con programmi in rete cerca di stabilire il percorso locale di Campo.ini
DIRECTORY dir;
char username[32];
xvt_fsys_get_default_dir(&dir);
xvt_fsys_convert_dir_to_str(&dir, exedir, sizeof(exedir));
xvt_sys_get_user_name(username, sizeof(username));
#ifdef WIN32
if (xvt_fsys_is_network_drive(exedir))
{
@ -795,34 +797,32 @@ const char* xvt_fsys_get_campo_ini()
}
}
}
if (xvt_sys_get_os_version() < XVT_OS_WINDOWS_NT)
*username = '\0';
#endif
if (!bFound)
{
#ifdef LINUX
char ininame[32];
sprintf(ininame, "campo%u", getuid());
xvt_fsys_build_pathname(path, NULL, exedir, ininame, "ini", NULL);
#else
xvt_fsys_build_pathname(path, NULL, exedir, "campo", "ini", NULL);
#endif
if (!xvt_fsys_file_exists(path))
{
#ifdef LINUX
char pathstd[_MAX_PATH];
xvt_fsys_build_pathname(pathstd, NULL, exedir, "campo", "ini", NULL);
if (!xvt_fsys_file_exists(pathstd))
{
#endif
char msg[256];
sprintf(msg, "Impossibile aprire '%s'", (const char *)path);
xvt_dm_post_fatal_exit(msg);
#ifdef LINUX
}
else
wxCopyFile(pathstd, path);
#endif
}
}
if (!bFound)
{
char ininame[_MAX_FNAME];
if (xvt_str_compare_ignoring_case(username, "ADMIN") == 0)
*username = '\0';
sprintf(ininame, "campo%s", username);
xvt_fsys_build_pathname(path, NULL, exedir, ininame, "ini", NULL);
if (!xvt_fsys_file_exists(path) && *username > ' ')
{
char pathstd[_MAX_PATH];
xvt_fsys_build_pathname(pathstd, NULL, exedir, "campo", "ini", NULL);
if (xvt_fsys_file_exists(pathstd))
wxCopyFile(pathstd, path);
}
}
if (!xvt_fsys_file_exists(path))
{
char msg[256];
sprintf(msg, "Impossibile aprire '%s'", (const char *)path);
xvt_dm_post_fatal_exit(msg);
}
prawin = xvt_str_duplicate(path);
}
return prawin;