From f5b07fd56fa53d16930c34a6c630c110cd138657 Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 31 Mar 2004 12:57:12 +0000 Subject: [PATCH] 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 --- xvaga/oslinux.cpp | 21 ++++++++++++++++++ xvaga/oslinux.h | 1 + xvaga/oswin32.cpp | 17 +++++++++++++++ xvaga/oswin32.h | 1 + xvaga/xvaga.cpp | 23 ++++++++++++++++---- xvaga/xvt.h | 1 + xvaga/xvtextra.cpp | 54 +++++++++++++++++++++++----------------------- 7 files changed, 87 insertions(+), 31 deletions(-) diff --git a/xvaga/oslinux.cpp b/xvaga/oslinux.cpp index 510b9c658..854341e7d 100755 --- a/xvaga/oslinux.cpp +++ b/xvaga/oslinux.cpp @@ -16,6 +16,7 @@ #include #include #include +#include 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); +} diff --git a/xvaga/oslinux.h b/xvaga/oslinux.h index c0944166d..83894af9a 100755 --- a/xvaga/oslinux.h +++ b/xvaga/oslinux.h @@ -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(); diff --git a/xvaga/oswin32.cpp b/xvaga/oswin32.cpp index 13519ed5f..5a0780344 100755 --- a/xvaga/oswin32.cpp +++ b/xvaga/oswin32.cpp @@ -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; +} + diff --git a/xvaga/oswin32.h b/xvaga/oswin32.h index ea9b5441d..c02daa013 100755 --- a/xvaga/oswin32.h +++ b/xvaga/oswin32.h @@ -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(); diff --git a/xvaga/xvaga.cpp b/xvaga/xvaga.cpp index a13ae3cda..d8a46b90b 100755 --- a/xvaga/xvaga.cpp +++ b/xvaga/xvaga.cpp @@ -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(); diff --git a/xvaga/xvt.h b/xvaga/xvt.h index 0540ff8b1..498072bc6 100755 --- a/xvaga/xvt.h +++ b/xvaga/xvt.h @@ -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(); diff --git a/xvaga/xvtextra.cpp b/xvaga/xvtextra.cpp index 7bc06ec3b..524a890bc 100755 --- a/xvaga/xvtextra.cpp +++ b/xvaga/xvtextra.cpp @@ -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;