From 515a9d9daf32c569795d1ee42fb789c0193b8efc Mon Sep 17 00:00:00 2001 From: guy Date: Tue, 9 Feb 2010 10:14:58 +0000 Subject: [PATCH] Patch level : 10.0 Files correlati : xvaga.dll Ricompilazione Demo : [ ] Commento : Aggiunto supporto per chiavi hardlock in Win 2003, Vista, 2008, 7 Aggiunto supporto per start/kill sottoprocessi git-svn-id: svn://10.65.10.50/trunk@20085 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- xvaga/fastapi.h | 89 +++++++++++++++++++------- xvaga/hlapi_c.h | 5 +- xvaga/oswin32.cpp | 28 -------- xvaga/xvaga.cpp | 156 ++++++++++++++++++++++++++------------------- xvaga/xvapp.cpp | 7 +- xvaga/xvt.h | 18 +++--- xvaga/xvt_type.h | 6 ++ xvaga/xvtctl.cpp | 17 ++--- xvaga/xvtdm.cpp | 25 ++++++-- xvaga/xvtextra.cpp | 19 +----- xvaga/xvtwin.cpp | 26 ++++++-- xvaga/xvtwin.h | 5 ++ 12 files changed, 236 insertions(+), 165 deletions(-) diff --git a/xvaga/fastapi.h b/xvaga/fastapi.h index fa554511d..8af877e48 100755 --- a/xvaga/fastapi.h +++ b/xvaga/fastapi.h @@ -11,36 +11,42 @@ /** Revision history **/ /** ---------------- *** $Log: not supported by cvs2svn $ -*** Revision 1.2 2002/05/31 07:02:15 guy -*** Patch level : MAIN TRUNK -*** Files correlati : -*** Ricompilazione Demo : [ ] -*** Commento : +*** Revision 1.52 2003/04/30 12:21:14 chris +*** fix structure packing for Borland *** -*** Allineato main trunk alla versione a 32 bit. +*** Revision 1.51 2003/02/24 08:00:28 werner +*** Added RUS-Flag: DISABLE_TS_CHECK for Terminal Server detection *** -*** Revision 1.1.2.1 2002/05/30 13:42:20 guy -*** Patch level : 2.0 nopatch -*** Files correlati : fastapi.h -*** Ricompilazione Demo : [ ] -*** Commento : -*** Sarà d'uopo includere anch'esso, va là! +*** Revision 1.50 2003/01/30 09:48:13 axel +*** added functions API_GETHLSADDR 108, API_GETHLSTEXT 109 +*** added error NO_LOCAL_FUNCTION 61 +*** +*** Revision 1.49 2002/08/23 10:47:10 axel +*** added API_READ_HLS, API_CALC_HLS and NO_REMOTE_FUNCTION +*** (used for detecting HL-Server Hardlock licenses) +*** +*** Revision 1.48 2002/08/22 16:15:27 alex +*** added define _AKS_QT_APPLICATION_ if you want to compile with Qt, +*** because slots from lic structure is a Qt keyword +*** +*** Revision 1.47 2002/03/18 13:24:34 chris +*** Win64 changes *** *** Revision 1.46 2000/12/19 16:37:41 chris *** detect MacOS X -*** +*** *** Revision 1.45 2000/07/30 22:22:17 chris *** ia64 detection -*** +*** *** Revision 1.44 2000/07/10 09:45:09 chris *** Module2 field -*** +*** *** Revision 1.43 2000/05/25 14:11:43 chris *** added some HASP stuff -*** +*** *** Revision 1.42 2000/03/21 14:18:28 chris *** HL_SIS and HL_LIS structure definitions -*** +*** *** Revision 1.41 2000/02/18 14:04:44 chris *** fixed pascal define for CygWin & MingW32 *** @@ -225,9 +231,15 @@ #endif #endif +#ifdef __BORLANDC__ + #pragma pack(1) +#endif + #if defined(WINNT) || defined(__WIN32__) || defined(_WIN32) - #ifndef __386__ /* Watcom doesnt like it */ - #define __386__ + #if !defined(_WIN64) && !defined(WIN64) + #ifndef __386__ /* Watcom doesnt like it */ + #define __386__ + #endif #endif #ifdef DLL #define CALL_ __stdcall @@ -236,6 +248,15 @@ #endif #endif +#if defined(_WIN64) || defined(WIN64) + #ifndef __64BIT__ + #define __64BIT__ + #endif + #define DATAFAR_ + #define FAR_ + #define pascal __stdcall +#endif + #ifdef DOS386 /* Symantec C */ #define __386__ #pragma pack(2) @@ -326,8 +347,12 @@ /* -------------------------------- */ #ifdef __64BIT__ typedef unsigned int Long; +#if !defined(_WIN64) && !defined(WIN64) typedef unsigned long Int64; #else +typedef unsigned __int64 Int64; /* stupid Windows convention */ +#endif +#else typedef unsigned long Long; #endif #ifndef __BCPLUSPLUS__ @@ -490,7 +515,11 @@ typedef _PACKED struct ALIGN_ { Long num_slots; Word glob_exp_date; Word res2; /* filler to make size multiple of 4 bytes */ +#ifdef __AKS_QT_APPLICATION__ + HL_SIS slot[1]; /* slots is a keyword in Qt application, renamed array */ +#else HL_SIS slots[1]; + #endif } ALIGN_GCC HL_LIS; #ifdef UNIX32 @@ -501,6 +530,10 @@ typedef _PACKED struct ALIGN_ { #pragma pack() #endif +#ifdef __BORLANDC__ + #pragma pack(1) +#endif + #ifdef _MSC_VER #if _MSC_VER >= 900 #pragma pack(pop,_fastapi_h_) @@ -549,9 +582,17 @@ typedef _PACKED struct ALIGN_ { /* -------------- */ /* LM functions : */ /* -------------- */ -#define API_LMINIT 40 /* LM compatible API_INIT replacement */ -#define API_LMPING 41 /* checks if LM dongle and slot is available */ -#define API_LMINFO 42 /* info about currently used LIMA */ +#define API_LMINIT 40 /* LM compatible API_INIT replacement */ +#define API_LMPING 41 /* checks if LM dongle and slot is available */ +#define API_LMINFO 42 /* info about currently used LIMA */ + +#define API_READ_HLS 78 /* get number of licences for USB server HL */ +#define API_CALC_HLS 79 /* calculate num of licenses for parallel server HL */ + + +#define API_GETHLSADDR 108 /* get addr struc of currently used HLS */ +#define API_GETHLSTEXT 109 /* get text addr of currently used HLS */ + /* --------------- */ /* RUS functions : */ @@ -588,6 +629,7 @@ typedef _PACKED struct ALIGN_ { /* RUS flags: */ /* ---------- */ #define FORCE_RUS 1 /* Enable RUS init without VK */ +#define DISABLE_TS_CHECK 2 /* Disable Terminal Server Detection */ #define FORCE_ALF_CREATE 1 /* Force creation of ALF file in HLM_WRITELICENSE */ /* ------------------ */ @@ -643,6 +685,9 @@ typedef _PACKED struct ALIGN_ { #define RUS_INVALID_RTB 39 /* Invalid updated data (RTB) */ #define RUS_RTB_EXPIRED 40 /* Update data (RTB) has expired. */ #define RUS_SERIAL_MISMATCH 41 /* Update data serial does not match */ +#define NO_REMOTE_FUNCTION 60 /* function is available locally only */ +#define NO_LOCAL_FUNCTION 61 /* function is available remotely only */ + #define TOO_MANY_USERS 256 /* Login table full (remote) */ #define SELECT_DOWN 257 /* Printer not On-line */ #define NO_SERIALID 258 /* Serial ID not readable or n/a */ diff --git a/xvaga/hlapi_c.h b/xvaga/hlapi_c.h index 068f5c712..73c910791 100755 --- a/xvaga/hlapi_c.h +++ b/xvaga/hlapi_c.h @@ -1,4 +1,4 @@ -/* $Id: hlapi_c.h,v 1.1 2003-04-30 15:43:50 guy Exp $ */ +/* $Id: hlapi_c.h,v 1.2 2010-02-09 10:14:58 guy Exp $ */ #include "fastapi.h" @@ -30,6 +30,9 @@ RET_ FAR_ CALL_ HL_VERSION (void); RET_ FAR_ CALL_ HL_HLSVERS (void); RET_ FAR_ CALL_ HL_SELECT (HL_API DATAFAR_ *hl_ptr); RET_ FAR_ CALL_ HL_READID (Word DATAFAR_ *IDLow, Word DATAFAR_ *IDHigh); +RET_ FAR_ CALL_ HL_SERVERLICENSES (Word DATAFAR_ *Value); +RET_ FAR_ CALL_ HL_SERVERADDR (char *text, Long *textsize); + /* ---------------- */ /* Hardlock RUS API */ diff --git a/xvaga/oswin32.cpp b/xvaga/oswin32.cpp index 3b54a4ebf..743101f49 100755 --- a/xvaga/oswin32.cpp +++ b/xvaga/oswin32.cpp @@ -655,34 +655,6 @@ long OsWin32_CloseChildren(unsigned int parent) return n; } -static BOOL CALLBACK CloseSiblingProc(HWND hwnd, LPARAM lParam) -{ - if (hwnd != (HWND)lParam) - { - if (!::IsWindowVisible(hwnd)) - { - char str[256]; - ::GetClassName(hwnd, str, sizeof(str)); - if (strcmp(str, "wxWindowClassNR") == 0) - { - ::GetWindowText(hwnd, str, sizeof(str)); - if (str[0] == '\0') - { - OsWin32_CloseChildren((UINT)hwnd); - CloseChildrenProc(hwnd, 0L); - } - } - } - } - return TRUE; -} - -void OsWin32_CloseSiblings(unsigned int WXUNUSED(parent)) -{ - // NON FUNZIONA!!!!!!!!!!!!!!!!!!!!!!!!!!! - // ::EnumWindows(CloseSiblingProc, parent); -} - /////////////////////////////////////////////////////////// // Hardlock Support /////////////////////////////////////////////////////////// diff --git a/xvaga/xvaga.cpp b/xvaga/xvaga.cpp index 14a397822..aed7cbe4e 100755 --- a/xvaga/xvaga.cpp +++ b/xvaga/xvaga.cpp @@ -29,7 +29,7 @@ #endif -#ifdef WIN32 +#ifdef __WXMSW__ #include "oswin32.h" #include "XFont.h" #else @@ -63,8 +63,8 @@ void _AssertBox(bool test, const char* func, const char* file, int line) if (display) { wxString strMessage; - strMessage.Printf("Sorry, the application passed some invalid parameters to\nfunction %s in file %s at line %d .", - func, file, line); + strMessage.Printf("Sorry, the application passed some invalid parameters to\n" + "function %s in file %s at line %d.", func, file, line); xvt_dm_post_error(strMessage); } } @@ -92,7 +92,7 @@ XVTDLL void xvt_app_pre_create(void) ::wxInitAllImageHandlers(); xvtart_Init(); -#ifdef WIN32 +#ifdef __WXMSW__ if (::wxDisplayDepth() >= 32 && wxTheApp->GetComCtl32Version() >= 600) wxSystemOptions::SetOption(wxT("msw.remap"), 2); else @@ -353,7 +353,7 @@ void xvt_debug_printf(const char* fmt, ...) BOOLEAN xvt_dongle_hl_crypt(unsigned short* data) // Array di 4 words (8 bytes) { -#ifdef WIN32 +#ifdef __WXMSW__ return OsWin32_HL_Crypt(data); #else return OsLinux_HL_Crypt(data); @@ -362,7 +362,7 @@ BOOLEAN xvt_dongle_hl_crypt(unsigned short* data) // Array di 4 words (8 bytes) BOOLEAN xvt_dongle_hl_login(unsigned short address, const unsigned char* label, const unsigned char* password) { -#ifdef WIN32 +#ifdef __WXMSW__ return OsWin32_HL_Login(address, label, password); #else return OsLinux_HL_Login(address, label, password); @@ -371,7 +371,7 @@ BOOLEAN xvt_dongle_hl_login(unsigned short address, const unsigned char* label, BOOLEAN xvt_dongle_hl_logout() { -#ifdef WIN32 +#ifdef __WXMSW__ return OsWin32_HL_Logout(); #else return OsLinux_HL_Logout(); @@ -380,7 +380,7 @@ BOOLEAN xvt_dongle_hl_logout() BOOLEAN xvt_dongle_hl_read(unsigned short reg, unsigned short* data) { -#ifdef WIN32 +#ifdef __WXMSW__ return OsWin32_HL_Read(reg, data); #else return OsLinux_HL_Read(reg, data); @@ -389,7 +389,7 @@ BOOLEAN xvt_dongle_hl_read(unsigned short reg, unsigned short* data) BOOLEAN xvt_dongle_hl_read_block(unsigned char* data) { -#ifdef WIN32 +#ifdef __WXMSW__ return OsWin32_HL_ReadBlock(data); #else return OsLinux_HL_ReadBlock(data); @@ -398,7 +398,7 @@ BOOLEAN xvt_dongle_hl_read_block(unsigned char* data) BOOLEAN xvt_dongle_hl_write(unsigned short reg, unsigned short data) { -#ifdef WIN32 +#ifdef __WXMSW__ return OsWin32_HL_Write(reg, data); #else return OsLinux_HL_Write(reg, data); @@ -407,7 +407,7 @@ BOOLEAN xvt_dongle_hl_write(unsigned short reg, unsigned short data) BOOLEAN xvt_dongle_sl_crypt(unsigned short* data) { -#ifdef WIN32 +#ifdef __WXMSW__ return OsWin32_SL_Crypt(data); #else return OsLinux_SL_Crypt(data); @@ -416,7 +416,7 @@ BOOLEAN xvt_dongle_sl_crypt(unsigned short* data) BOOLEAN xvt_dongle_sl_login(const unsigned char* label, const unsigned char* password) { -#ifdef WIN32 +#ifdef __WXMSW__ return OsWin32_SL_Login(label, password); #else return OsLinux_SL_Login(label, password); @@ -425,7 +425,7 @@ BOOLEAN xvt_dongle_sl_login(const unsigned char* label, const unsigned char* pas BOOLEAN xvt_dongle_sl_logout() { -#ifdef WIN32 +#ifdef __WXMSW__ return OsWin32_SL_Logout(); #else return OsLinux_SL_Logout(); @@ -434,7 +434,7 @@ BOOLEAN xvt_dongle_sl_logout() BOOLEAN xvt_dongle_sl_read_block(unsigned short reg, unsigned short size, unsigned short* data) { -#ifdef WIN32 +#ifdef __WXMSW__ return OsWin32_SL_ReadBlock(reg, size, data); #else return OsLinux_SL_ReadBlock(reg, size, data); @@ -443,7 +443,7 @@ BOOLEAN xvt_dongle_sl_read_block(unsigned short reg, unsigned short size, unsign BOOLEAN xvt_dongle_sl_write_block(unsigned short reg, unsigned short size, const unsigned short* data) { -#ifdef WIN32 +#ifdef __WXMSW__ return OsWin32_SL_WriteBlock(reg, size, data); #else return OsLinux_SL_WriteBlock(reg, size, data); @@ -510,7 +510,7 @@ class TXVT_IMAGE : public wxImage int m_nDepth; bool m_bDirty; -#ifdef WIN32 +#ifdef __WXMSW__ HBITMAP m_bitmap; #else wxBitmap* m_bitmap; @@ -523,7 +523,7 @@ public: const wxImage& Image() const { return *this; } wxImage& Image() { m_bDirty = true; return *this; } -#ifdef WIN32 +#ifdef __WXMSW__ HBITMAP Bitmap(wxDC& dc); #else const wxBitmap& Bitmap(wxDC& dc); @@ -557,8 +557,7 @@ void TXVT_IMAGE::SetPixel(int x, int y, COLOR color) m_bDirty = true; } - -#ifdef WIN32 +#ifdef __WXMSW__ HBITMAP TXVT_IMAGE::Bitmap(wxDC& dc) { @@ -591,7 +590,7 @@ const wxBitmap& TXVT_IMAGE::Bitmap(wxDC& dc) void TXVT_IMAGE::Destroy() { if (m_bitmap != NULL) -#ifdef WIN32 +#ifdef __WXMSW__ ::DeleteObject(m_bitmap); #else delete m_bitmap; @@ -677,7 +676,7 @@ const wxFont& TFontId::Font(wxDC* dc, WINDOW win) const const wxSize ppi = dc->GetPPI(); if (dc != lastDC || ppi != lastPPI) { -#ifdef WIN32 +#ifdef __WXMSW__ const char* const DEFAULT_FONT_NAME = "Courier New"; #else const char* const DEFAULT_FONT_NAME = "Courier"; @@ -707,7 +706,7 @@ const wxFont& TFontId::Font(wxDC* dc, WINDOW win) const if (nBest == 0) nBest = nMax; -#ifdef WIN32 +#ifdef __WXMSW__ // Pezza per cercare di ovviare a dimensioni assurde calcolate dai sistemi Win * // Praticamente succede che il Courier 70 sia piu' piccolo del Curier 60 // Per cui una volta candidata una dimensione (nBest) tramite le righe precedenti @@ -877,7 +876,7 @@ static wxRect ComputeRect(const wxRect& rct, int h, int v, int k) static void DrawImageOnDC(wxDC& dc, TXVT_IMAGE* image, const wxRect& dst, const wxRect& src) { -#ifdef WIN32 +#ifdef __WXMSW__ if (!OsWin32_DrawBitmap(image->Bitmap(dc), dc, dst, src)) { const int k = 4; @@ -978,7 +977,7 @@ void xvt_dwin_draw_roundrect(WINDOW win, const RCT *rctp, int oval_width, int ov void xvt_dwin_draw_dotted_rect(WINDOW win, RCT *rctp) { -#ifdef WIN32 +#ifdef __WXMSW__ static int can_draw_dots = -1; if (can_draw_dots < 0) can_draw_dots = xvt_sys_get_os_version() >= XVT_WS_WIN_NT; @@ -1491,7 +1490,7 @@ void xvt_font_unmap(XVT_FNTID font_id) BOOLEAN xvt_fsys_build_pathname(char* mbs, const char* volname, const char* dirname, const char* leafroot, const char* leafext, const char* /* leafvers */) { -#ifdef WIN32 +#ifdef __WXMSW__ _makepath(mbs, volname, dirname, leafroot, leafext); #else *mbs = '\0'; @@ -1530,7 +1529,7 @@ BOOLEAN xvt_fsys_parse_pathname(const char* mbs, char* volname, char* dirname, c else { wxStrcpy(volname, volume); -#ifdef WIN32 +#ifdef __WXMSW__ if (volname[0] != '\0' && volname[1] == '\0') wxStrcat(volname, ":"); #endif @@ -1653,7 +1652,7 @@ BOOLEAN xvt_fsys_is_removable_drive(const char* path) if (path && *path) { -#ifdef WIN32 +#ifdef __WXMSW__ const wxString strRoot = get_disk_root(path); yes = ::GetDriveType(strRoot) == DRIVE_REMOVABLE; #else @@ -1674,7 +1673,7 @@ BOOLEAN xvt_fsys_is_network_drive(const char* path) yes = TRUE; else { -#ifdef WIN32 +#ifdef __WXMSW__ const wxString strRoot = get_disk_root(path); yes = ::GetDriveType(strRoot) == DRIVE_REMOTE; #else @@ -1692,7 +1691,7 @@ BOOLEAN xvt_fsys_is_fixed_drive(const char* path) { if (!wxIsPathSeparator(path[0]) || !wxIsPathSeparator(path[1])) { -#ifdef WIN32 +#ifdef __WXMSW__ const wxString strRoot = get_disk_root(path); yes = ::GetDriveType(strRoot) == DRIVE_FIXED; #else @@ -1810,7 +1809,7 @@ SLIST xvt_fsys_list_files(const char *type, const char *pat, BOOLEAN dirs) wxString f = ::wxFindFirstFile(pat, flags); while (!f.IsEmpty()) { -#ifdef WIN32 +#ifdef __WXMSW__ if (f.StartsWith(".\\")) #else if (f.StartsWith("./")) @@ -1982,7 +1981,7 @@ COLOR xvt_image_get_pixel(XVT_IMAGE image, short x, short y) XVT_IMAGE xvt_image_read(const char* filenamep) { TXVT_IMAGE* i = NULL; -#ifdef WIN32 +#ifdef __WXMSW__ const wxString name = filenamep; #else wxString name; @@ -3005,7 +3004,7 @@ char* xvt_str_duplicate(const char* str) char* xvt_str_number_format(char* str, int size) { -#ifdef WIN32 +#ifdef __WXMSW__ OsWin32_NumberFormat(str, size); #else wxString txt; @@ -3120,7 +3119,7 @@ int xvt_net_get_status() void xvt_sys_beep(int severity) { -#ifdef WIN32 +#ifdef __WXMSW__ OsWin32_Beep(severity); #else wxBell(); @@ -3144,7 +3143,7 @@ BOOLEAN xvt_sys_get_user_name(char* name, int maxlen) } /////////////////////////////////////////////////////////// -// Process processing +// TIconizeTaskThread /////////////////////////////////////////////////////////// static bool __bChildRunning = false; @@ -3171,6 +3170,10 @@ TIconizeTaskThread::TIconizeTaskThread() Run(); } +/////////////////////////////////////////////////////////// +// Process processing +/////////////////////////////////////////////////////////// + long xvt_sys_execute(const char* cmdline, BOOLEAN sync, BOOLEAN iconizetask) { long exitcode = 0; @@ -3201,18 +3204,50 @@ long xvt_sys_execute(const char* cmdline, BOOLEAN sync, BOOLEAN iconizetask) _task_win->Raise(); } else - exitcode = wxExecute(cmd, wxEXEC_ASYNC); + { + if (_task_win != NULL && _task_win_handler != NULL) + { + wxProcess* p = new wxProcess(_task_win->GetEventHandler(), wxID_ANY); + exitcode = wxExecute(cmd, wxEXEC_ASYNC, p); + if (exitcode > 0) + { + XVT_EVENT e(E_PROCESS); + e.v.process.msg_id = E_CREATE; + e.v.process.pid = exitcode; + _task_win_handler((WINDOW)_task_win, &e); + } + else + delete p; + } + else + exitcode = wxExecute(cmd, wxEXEC_ASYNC); + } return exitcode; } +BOOLEAN xvt_sys_kill(long pid) +{ + BOOLEAN bKilled = wxProcess::Kill(pid, wxSIGTERM, wxKILL_CHILDREN) == wxKILL_OK; + if (!bKilled) + bKilled = wxProcess::Kill(pid, wxSIGKILL, wxKILL_CHILDREN) == wxKILL_OK; + if (bKilled && _task_win != NULL && _task_win_handler != NULL) + { + XVT_EVENT e(E_PROCESS); + e.v.process.msg_id = E_DESTROY; + e.v.process.pid = pid; + _task_win_handler((WINDOW)_task_win, &e); + } + return bKilled; +} + long xvt_sys_execute_in_window(const char* cmdline, WINDOW win) { const long inst = xvt_sys_execute(cmdline, FALSE, FALSE); if (inst > 0 && win != NULL_WIN) { CAST_WIN(win, w); -#ifdef WIN32 +#ifdef __WXMSW__ OsWin32_PlaceProcessInWindow(inst, "", (unsigned int)w.GetHandle()); #else OsLinux_PlaceProcessInWindow(inst, "", w.GetHandle()); @@ -3224,26 +3259,16 @@ long xvt_sys_execute_in_window(const char* cmdline, WINDOW win) long xvt_sys_close_children(WINDOW win) { long c = 0; -#ifdef WIN32 +#ifdef __WXMSW__ CAST_WIN(win, w); c = OsWin32_CloseChildren((unsigned int)w.GetHandle()); #endif return c; } -long xvt_sys_close_siblings(WINDOW win) -{ - long c = 0; // Non sto a perder tempo a contarli :-) -#ifdef WIN32 - CAST_WIN(win, w); - OsWin32_CloseSiblings((unsigned int)w.GetHandle()); -#endif - return c; -} - BOOLEAN xvt_sys_goto_url(const char* url, const char* action) { -#ifdef WIN32 +#ifdef __WXMSW__ if (action && *action && xvt_str_compare_ignoring_case(action, "open") != 0) return OsWin32_GotoUrl(url, action); #endif @@ -3270,17 +3295,20 @@ int xvt_sys_get_oem_string(const char* name, const char* defval, char* value, in long xvt_sys_get_oem_int(const char* name, long defval) { - wxString strFileName = _startup_dir + "/setup/oem.ini"; + static long _oem = -1; + if (_oem < 0) + _oem = xvt_sys_get_profile_int(_startup_dir+"/setup/oem.ini", "MAIN", "OEM", -1); + } const int oem = xvt_sys_get_profile_int(strFileName, "MAIN", "OEM", -1); - if (oem >= 0) + if (_oem >= 0) { if (wxStricmp(name, "OEM") != 0) { - wxString strPara; strPara << "OEM_" << oem; - defval = xvt_sys_get_profile_int(strFileName, strPara, name, defval); + wxString strPara; strPara << "OEM_" << _oem; + defval = xvt_sys_get_profile_int(_startup_dir+"/setup/oem.ini", strPara, name, defval); } else - defval = oem; + defval = _oem; } return defval; } @@ -3294,7 +3322,7 @@ int xvt_sys_get_profile_string(const char* file, const char* paragraph, const ch if (paragraph == NULL || *paragraph == '\0') paragraph = "Main"; -#ifdef WIN32 +#ifdef __WXMSW__ int len = ::GetPrivateProfileString(paragraph, name, defval, value, maxsize, file); #else wxFileConfig ini("", "", file, "", wxCONFIG_USE_LOCAL_FILE | wxCONFIG_USE_RELATIVE_PATH); @@ -3339,7 +3367,7 @@ BOOLEAN xvt_sys_set_profile_string(const char* file, const char* paragraph, cons if (paragraph == NULL || *paragraph == '\0') paragraph = "Main"; -#ifdef WIN32 +#ifdef __WXMSW__ return ::WritePrivateProfileString(paragraph, name, value, file); #else wxFileConfig ini("", "", file, "", wxCONFIG_USE_LOCAL_FILE | wxCONFIG_USE_RELATIVE_PATH); @@ -3357,7 +3385,7 @@ BOOLEAN xvt_sys_find_editor(const char* file, char* editor) { BOOLEAN ok = FALSE; -#ifdef WIN32 +#ifdef __WXMSW__ const wxString e = OsWin32_File2App(file); #else const wxString e = OsLinux_File2App(file); @@ -3372,7 +3400,7 @@ BOOLEAN xvt_sys_find_editor(const char* file, char* editor) int xvt_sys_get_session_id() { -#ifdef WIN32 +#ifdef __WXMSW__ return OsWin32_GetSessionId(); #else return OsLinux_GetSessionId(); @@ -3394,7 +3422,7 @@ unsigned long xvt_sys_get_free_memory_kb() int xvt_sys_get_os_version() { int os = 0; -#ifdef WIN32 +#ifdef __WXMSW__ int nVersion = 0; ::GetWinVer(NULL, 0, &nVersion); switch (nVersion) @@ -3440,7 +3468,7 @@ int xvt_sys_get_version(char* os_version, char* ptk_version, int maxsize) const int version = xvt_sys_get_os_version(); if (os_version && maxsize >= 8) { -#ifdef WIN32 +#ifdef __WXMSW__ if (version > XVT_WS_WIN_XP) // wxWidgets non sa descrivere i moderni sistemi Microsoft ::GetWinVer(os_version, maxsize, NULL); else @@ -3479,7 +3507,7 @@ void xvt_sys_searchenv(const char * filename, const char * varname, char * pathn void xvt_sys_search_env(const char * filename, const char * varname, char * pathname) { -#ifdef WIN32 +#ifdef __WXMSW__ _searchenv(filename, varname, pathname); #else const char * value = wxGetEnv(varname); @@ -3557,9 +3585,7 @@ BOOLEAN xvt_fsys_rename_file(const char *src_pathname, const char *dst_pathname) /////////////////////////////////////////////////////////// struct tm* xvt_time_now() -{ - return wxDateTime::GetTmNow(); -} +{ return wxDateTime::GetTmNow(); } long xvt_timer_create(WINDOW win, long interval) { @@ -4048,7 +4074,7 @@ WINDOW xvt_win_create(WIN_TYPE wtype, const RCT* rct_p, const char* title, int m w->_app_data = app_data; w->SetBackgroundStyle(wxBG_STYLE_CUSTOM); // Lo sfondo viene disegnato nella OnPaint -#ifdef WIN32 +#ifdef __WXMSW__ OsWin32_SetCaptionStyle(w->GetHWND(), style); #else OsLinux_SetCaptionStyle(w, style); @@ -4128,7 +4154,7 @@ long xvt_win_get_children_count(WINDOW parent_win) if (parent_win != NULL_WIN) { CAST_WIN(parent_win, w) -#ifdef WIN32 +#ifdef __WXMSW__ nCount = OsWin32_GetChildrenCount((unsigned int)w.GetHandle()); #else nCount = w.GetChildren().GetCount(); diff --git a/xvaga/xvapp.cpp b/xvaga/xvapp.cpp index 4f2b989d2..267d7d297 100755 --- a/xvaga/xvapp.cpp +++ b/xvaga/xvapp.cpp @@ -14,7 +14,7 @@ class TMainApp : public wxApp protected: virtual bool OnInit(); virtual int OnExit(); - virtual void OnTimer(wxTimerEvent& event); + void OnTimer(wxTimerEvent& evt); DECLARE_EVENT_TABLE() DECLARE_DYNAMIC_CLASS(TMainApp); @@ -30,7 +30,7 @@ BEGIN_EVENT_TABLE(TMainApp, wxApp) EVT_TIMER(TIMER_ID, TMainApp::OnTimer) END_EVENT_TABLE() -void TMainApp::OnTimer(wxTimerEvent& event) +void TMainApp::OnTimer(wxTimerEvent& evt) { xvt_app_pre_create(); xvt_main(argc, argv); @@ -38,10 +38,11 @@ void TMainApp::OnTimer(wxTimerEvent& event) bool TMainApp::OnInit() { - wxFileName strWrk = argv[0]; + const wxFileName strWrk = argv[0]; const wxString strApp = strWrk.GetName().Lower(); m_sic = new wxSingleInstanceChecker(strApp); + // Non eseguo direttamente xvt_main per dar modo al main event loop di partire wxTimerEvent evt(TIMER_ID); AddPendingEvent(evt); return true; diff --git a/xvaga/xvt.h b/xvaga/xvt.h index 21614b764..9c6f278ad 100755 --- a/xvaga/xvt.h +++ b/xvaga/xvt.h @@ -24,8 +24,6 @@ #define XVTDLL #endif -#define XVAGA 1 - #include #include #include @@ -383,11 +381,11 @@ XVTDLL BOOLEAN xvt_chr_is_alpha(int c); XVTDLL BOOLEAN xvt_chr_is_alnum(int c); // System calls by XVAGA -XVTDLL void xvt_sys_beep(int severity); -XVTDLL long xvt_sys_execute(const char* cmdline, BOOLEAN sync, BOOLEAN iconizetask); -XVTDLL long xvt_sys_execute_in_window(const char* cmdline, WINDOW win); -XVTDLL long xvt_sys_close_children(WINDOW win); -XVTDLL long xvt_sys_close_siblings(WINDOW win); +XVTDLL void xvt_sys_beep(int severity); +XVTDLL long xvt_sys_close_children(WINDOW win); +XVTDLL long xvt_sys_execute(const char* cmdline, BOOLEAN sync, BOOLEAN iconizetask); +XVTDLL long xvt_sys_execute_in_window(const char* cmdline, WINDOW win); +XVTDLL BOOLEAN xvt_sys_kill(long pid); typedef XVT_CALLCONV_TYPEDEF(int, XVT_MULTITHREAD_CALLBACK, (void* pCaller, void* pData, int i, int tot) ); XVTDLL BOOLEAN xvt_sys_multithread(XVT_MULTITHREAD_CALLBACK callback, void* pCaller, void* pData, int tot, const char* msg); @@ -419,9 +417,9 @@ XVTDLL BOOLEAN xvt_sys_set_env(const char* varname, const char* value); XVTDLL void xvt_sys_sorry_box(const char* func, const char* file, int line); XVTDLL void xvt_sys_deprecated_box(const char* oldfunc, const char* file, const char* newfunc); -XVTDLL struct tm* xvt_time_now(); -XVTDLL long xvt_timer_create(WINDOW win, long interval); -XVTDLL void xvt_timer_destroy(long id); +XVTDLL struct tm* xvt_time_now(); +XVTDLL long xvt_timer_create(WINDOW win, long interval); +XVTDLL void xvt_timer_destroy(long id); XVTDLL WINDOW xvt_trayicon_create(WINDOW owner, short icon, const char* tooltip); XVTDLL void xvt_trayicon_destroy(WINDOW tray); diff --git a/xvaga/xvt_type.h b/xvaga/xvt_type.h index f874739ed..bd4076090 100755 --- a/xvaga/xvt_type.h +++ b/xvaga/xvt_type.h @@ -389,6 +389,7 @@ E_QUIT, /* application shutdown request */ E_HELP, /* help invoked */ E_USER, /* user defined */ E_CXO, /* cxo event */ +E_PROCESS, /* child process terminated */ } EVENT_TYPE; @@ -449,6 +450,11 @@ typedef struct s_event { long msg_id; /* CXO message id - Unique to each CXO */ void * ptr; /* message data pointer */ } cxo; + struct s_process { /* E_PROCESS */ + long pid; /* PID of started/terminated process */ + int msg_id; /* 0=started; 1=stopped */ + int exit_code; + } process; } v; } EVENT, *EVENT_PTR; diff --git a/xvaga/xvtctl.cpp b/xvaga/xvtctl.cpp index 4eb4ec370..792632694 100755 --- a/xvaga/xvtctl.cpp +++ b/xvaga/xvtctl.cpp @@ -17,7 +17,7 @@ static wxBitmap Image2Bitmap(XVT_IMAGE image, int maxx, int maxy, BOOLEAN trans) { - if (image == NULL) + if (image == NULL || !((wxImage*)image)->IsOk()) return wxNullBitmap; wxImage img = *(wxImage*)image; @@ -2220,13 +2220,14 @@ void TwxPropertyGrid::SetColors(const XVT_COLOR_COMPONENT* colors) CAST_COLOR(colors[i].color, rgb); switch(colors[i].type) { - case XVT_COLOR_BACKGROUND: SetCellBackgroundColour(rgb); break; - case XVT_COLOR_FOREGROUND: SetCellTextColour(rgb); SetCaptionForegroundColour(rgb); break; - case XVT_COLOR_HIGHLIGHT : SetSelectionBackground(rgb); break; - case XVT_COLOR_SELECT : SetSelectionForeground(rgb); break; - case XVT_COLOR_BLEND : SetCaptionBackgroundColour(rgb); SetMarginColour(rgb); break; - case XVT_COLOR_TROUGH : SetEmptySpaceColour(rgb); break; - default : break; + case XVT_COLOR_BACKGROUND : SetCellBackgroundColour(rgb); break; + case XVT_COLOR_FOREGROUND : SetCellTextColour(rgb); break; + case XVT_COLOR_HIGHLIGHT : SetSelectionBackground(rgb); break; + case XVT_COLOR_SELECT : SetSelectionForeground(rgb); break; + case XVT_COLOR_BLEND : SetCaptionBackgroundColour(rgb); SetMarginColour(rgb); break; + case XVT_COLOR_TROUGH : SetEmptySpaceColour(rgb); break; + case XVT_COLOR_CAPTIONTEXT: SetCaptionForegroundColour(rgb); break; + default : break; } } } diff --git a/xvaga/xvtdm.cpp b/xvaga/xvtdm.cpp index 629b41cb2..28a39cb78 100755 --- a/xvaga/xvtdm.cpp +++ b/xvaga/xvtdm.cpp @@ -10,6 +10,10 @@ #include #include +#ifdef __WXMSW__ +#include "oswin32.h" +#endif + /////////////////////////////////////////////////////////// // TMessageBox /////////////////////////////////////////////////////////// @@ -21,7 +25,7 @@ class TMessageBox : public wxDialog protected: void OnButton(wxCommandEvent& evt); void OnTimeout(wxTimerEvent& evt); - void AddButton(wxSizer* sz, int id); + void AddButton(wxSizer* sz, wxWindowID id); DECLARE_EVENT_TABLE() public: @@ -60,7 +64,7 @@ void TMessageBox::OnTimeout(wxTimerEvent& WXUNUSED(evt)) EndModal(wxCANCEL); } -void TMessageBox::AddButton(wxSizer* sz, int id) +void TMessageBox::AddButton(wxSizer* sz, wxWindowID id) { const wxSize szButt(64,-1); sz->Add(new wxButton(this, id, wxEmptyString, wxDefaultPosition, szButt), 0, wxALL, 4); @@ -286,9 +290,14 @@ TPopUpBox::TPopUpBox(wxWindow* pParent, const wxString& msg, int nStyle, int nTi static void _PopUpBox(const wxString& msg, int nStyle, int nTimeout = 4) { - const int oem = xvt_sys_get_oem_int("OEM", -1); wxWindow* pFrame = wxTheApp->GetTopWindow(); - if (oem == 0 && pFrame != NULL) + bool bCanPopUp = pFrame != NULL && xvt_sys_get_oem_int("OEM", -1) == 0; +#ifdef __WXMSW__ + if (bCanPopUp) + bCanPopUp = !OsWin32_IsWindowsServer(); // Animazioni non consigliabili in TS +#endif + + if (bCanPopUp) { xvt_sys_beep(nStyle & wxICON_ERROR ? 2 : 1); TPopUpBox dlg(pFrame, msg, nStyle, nTimeout <= 0 ? 4 : nTimeout); @@ -358,9 +367,7 @@ void xvt_dm_speech_enable(int mode) } int xvt_dm_speech_enabled(void) -{ - return m_nSpeechMode; -} +{ return m_nSpeechMode; } /////////////////////////////////////////////////////////// // Common dialogs @@ -536,9 +543,13 @@ void xvt_dm_post_error(const char *fmt) void xvt_dm_post_fatal_exit(const char *fmt) { +/* xvt_dm_post_speech(fmt, 1, TRUE); wxLogFatalError(fmt); xvt_dm_post_speech("OK", 7, TRUE); +*/ + _MessageBox(fmt, wxOK | wxICON_HAND, 10); + abort(); } static wxString MakeFileName(const wxChar* name, const wxChar* ext) diff --git a/xvaga/xvtextra.cpp b/xvaga/xvtextra.cpp index 99014e861..5a138af55 100755 --- a/xvaga/xvtextra.cpp +++ b/xvaga/xvtextra.cpp @@ -644,12 +644,7 @@ WINDOW xvt_print_create_win(PRINT_RCD* precp, const char* title) void xvt_print_destroy(PRINT_RCD* precp) { if (precp != NULL) - { -#ifndef NDEBUG - -#endif delete precp; - } } RCT* xvt_print_get_next_band(void) @@ -713,7 +708,7 @@ int xvt_print_get_name(const PRINT_RCD* precp, char* name, int sz_s) if (!xvt_print_is_valid(precp)) return 0; -#ifdef WIN32 +#ifdef __WXMSW__ wxString n = ((const char*)precp) + 4; if (n.Length() >= 30) { @@ -1017,17 +1012,9 @@ BOOLEAN xvt_print_set_default_device(const char* name) BOOLEAN xvt_print_get_default_device(char* name, int namesize) { -/* - wxString strName, strPort; - const BOOLEAN ok = wxGetDefaultDeviceName(strName, strPort); - if (ok) - wxStrncpy(name, strName, namesize); - else - *name = '\0'; -*/ bool ok = FALSE; -#ifdef WIN32 +#ifdef __WXMSW__ ok = ::GetProfileString ("windows", "device", ",,,", name, namesize) != 0; #else *name = '\0'; @@ -1073,7 +1060,7 @@ BOOLEAN xvt_print_get_default_device(char* name, int namesize) int xvt_fsys_get_campo_stp_value(const char* name, char* value, int valsize) { BOOLEAN bFound = FALSE; -#ifdef WIN32 +#ifdef __WXMSW__ const char* const stpfile = "c:/campo.stp"; int p; DIRECTORY dir; diff --git a/xvaga/xvtwin.cpp b/xvaga/xvtwin.cpp index ffe13e38d..4298eb88a 100755 --- a/xvaga/xvtwin.cpp +++ b/xvaga/xvtwin.cpp @@ -8,6 +8,7 @@ #include #include //#include +#include #include #include #include @@ -369,7 +370,8 @@ void TDC::SetClippingBox(const RCT* pRct) { if (pRct != NULL) { - const wxRect rct = RCT2Rect(pRct); + // Normalizza posizione e dimensioni invece di limitarsi a fare _clip=*pRct + const wxRect rct = RCT2Rect(pRct); Rect2RCT(rct, &_clip); } else @@ -381,7 +383,8 @@ void TDC::SetClippingBox(const RCT* pRct) bool TDC::GetClippingBox(RCT* pRct) const { - *pRct = _clip; + if (pRct != NULL) + *pRct = _clip; return _clip.right > _clip.left; } @@ -985,6 +988,7 @@ BEGIN_EVENT_TABLE(TTaskWin, wxFrame) EVT_PAINT(TTaskWin::OnPaint) EVT_SIZE(TTaskWin::OnSize) EVT_END_SESSION(TTaskWin::OnClose) + EVT_END_PROCESS(wxID_ANY, TTaskWin::OnEndProcess) END_EVENT_TABLE() void TTaskWin::OnClose(wxCloseEvent& evt) @@ -992,7 +996,7 @@ void TTaskWin::OnClose(wxCloseEvent& evt) if (evt.CanVeto()) { XVT_EVENT e(E_CLOSE); - int veto = _task_win_handler((WINDOW)this, &e); + const int veto = _task_win_handler((WINDOW)this, &e); evt.Veto(veto != 0); } else @@ -1036,6 +1040,19 @@ void TTaskWin::OnSize(wxSizeEvent& evt) _task_win_handler((WINDOW)this, &e); } +void TTaskWin::OnEndProcess(wxProcessEvent& evt) +{ + if (_task_win_handler != NULL) + { + XVT_EVENT e(E_PROCESS); + e.v.process.msg_id = E_DESTROY; + e.v.process.pid = evt.GetPid(); + e.v.process.exit_code = evt.GetExitCode(); + _task_win_handler((WINDOW)this, &e); + delete evt.GetEventObject(); // delete wxProcess + } +} + void TTaskWin::SetMenuTree(const MENU_ITEM* tree) { wxMenuBar* bar = GetMenuBar(); @@ -1150,8 +1167,7 @@ TTaskWin::TTaskWin(wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style) : wxFrame(NULL, id, title, pos, size, style), m_menu(NULL), m_pOldBar(NULL), m_MenuOwner(NULL), m_xcc(NULL) { - const wxIcon ico = xvtart_GetIconResource(ICON_RSRC); - SetIcon(ico); + SetIcon(xvtart_GetIconResource(ICON_RSRC)); _nice_windows.Put((WINDOW)this, this); } diff --git a/xvaga/xvtwin.h b/xvaga/xvtwin.h index 59b50d81e..23a167ad8 100755 --- a/xvaga/xvtwin.h +++ b/xvaga/xvtwin.h @@ -1,6 +1,10 @@ #ifndef __XVTWIN_H #define __XVTWIN_H +#ifndef _WX_PROCESSH__ +#include +#endif + class TFontId : public wxObject { wxString m_strFace; @@ -200,6 +204,7 @@ protected: virtual void OnClose(wxCloseEvent& e); virtual void OnMenu(wxCommandEvent& e); virtual void OnSize(wxSizeEvent& e); + void OnEndProcess(wxProcessEvent& evt); public: virtual void OnPaint(wxPaintEvent& e);