- Bugfix in MsgWaitQueue destructor
authorVictor Kirhenshtein <victor@netxms.org>
Thu, 12 Aug 2004 13:24:24 +0000 (13:24 +0000)
committerVictor Kirhenshtein <victor@netxms.org>
Thu, 12 Aug 2004 13:24:24 +0000 (13:24 +0000)
- Start adding PNG support to console

14 files changed:
include/nxcscpapi.h
src/console/win32/LoginDialog.cpp
src/console/win32/LoginDialog.h
src/console/win32/ObjectBrowser.cpp
src/console/win32/StdAfx.h
src/console/win32/comm.cpp
src/console/win32/draw.cpp
src/console/win32/globals.cpp
src/console/win32/globals.h
src/console/win32/nxcon.clw
src/console/win32/nxcon.dsp
src/console/win32/nxcon.rc
src/console/win32/resource.h
src/console/win32/tools.cpp

index 6ff0a11..4457944 100644 (file)
@@ -120,14 +120,16 @@ typedef struct
 class LIBNXCSCP_EXPORTABLE MsgWaitQueue
 {
 private:
-   MUTEX m_hMutex;
+   MUTEX m_hMutexDataAccess;
+   MUTEX m_hMutexIsRunning;
    CONDITION m_hStopCondition;
    DWORD m_dwMsgHoldTime;
    DWORD m_dwNumElements;
    WAIT_QUEUE_ELEMENT *m_pElements;
+   BOOL m_bIsRunning;
 
-   void Lock(void) { MutexLock(m_hMutex, INFINITE); }
-   void Unlock(void) { MutexUnlock(m_hMutex); }
+   void Lock(void) { MutexLock(m_hMutexDataAccess, INFINITE); }
+   void Unlock(void) { MutexUnlock(m_hMutexDataAccess); }
    void HousekeeperThread(void);
    void *WaitForMessageInternal(WORD wIsBinary, WORD wCode, DWORD dwId, DWORD dwTimeOut);
    
index 3e474bc..3f2851e 100644 (file)
@@ -22,6 +22,7 @@ CLoginDialog::CLoginDialog(CWnd* pParent /*=NULL*/)
        m_szLogin = _T("");
        m_szPassword = _T("");
        m_szServer = _T("");
+       m_iEncryption = -1;
        //}}AFX_DATA_INIT
 }
 
@@ -36,6 +37,7 @@ void CLoginDialog::DoDataExchange(CDataExchange* pDX)
        DDV_MaxChars(pDX, m_szPassword, 64);
        DDX_Text(pDX, IDC_EDIT_SERVER, m_szServer);
        DDV_MaxChars(pDX, m_szServer, 64);
+       DDX_Radio(pDX, IDC_RADIO_CLEAR, m_iEncryption);
        //}}AFX_DATA_MAP
 }
 
index eb0130d..5c3d4d4 100644 (file)
@@ -22,6 +22,7 @@ public:
        CString m_szLogin;
        CString m_szPassword;
        CString m_szServer;
+       int             m_iEncryption;
        //}}AFX_DATA
 
 
index 8460e4c..7d8a0c3 100644 (file)
@@ -230,13 +230,14 @@ int CObjectBrowser::OnCreate(LPCREATESTRUCT lpCreateStruct)
 
    // Create image list
    m_pImageList = new CImageList;
-   m_pImageList->Create(16, 16, ILC_COLOR8 | ILC_MASK, 8, 8);
+   m_pImageList->Create(g_pObjectSmallImageList);
+/*   m_pImageList->Create(16, 16, ILC_COLOR8 | ILC_MASK, 8, 8);
    m_pImageList->Add(AfxGetApp()->LoadIcon(IDI_NETMAP));
    m_pImageList->Add(AfxGetApp()->LoadIcon(IDI_INTERFACE));
    m_pImageList->Add(AfxGetApp()->LoadIcon(IDI_NODE));
    m_pImageList->Add(AfxGetApp()->LoadIcon(IDI_SUBNET));
    m_pImageList->Add(AfxGetApp()->LoadIcon(IDI_SORT_UP));
-   m_pImageList->Add(AfxGetApp()->LoadIcon(IDI_SORT_DOWN));
+   m_pImageList->Add(AfxGetApp()->LoadIcon(IDI_SORT_DOWN));*/
    m_wndTreeCtrl.SetImageList(m_pImageList, TVSIL_NORMAL);
    m_wndListCtrl.SetImageList(m_pImageList, LVSIL_SMALL);
 
index d0dc577..bbe717a 100644 (file)
@@ -28,6 +28,8 @@
 #include <net-snmp/mib_api.h>
 #include <net-snmp/config_api.h>
 
+#include <ximage.h>
+
 //{{AFX_INSERT_LOCATION}}
 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
 
index 05a57c2..3415d20 100644 (file)
@@ -148,6 +148,8 @@ static DWORD WINAPI LoginThread(void *pArg)
       strcpy(szCacheDir, g_szWorkDir);
       strcat(szCacheDir, WORKDIR_IMAGECACHE);
       dwResult = NXCSyncImages(&g_pSrvImageList, szCacheDir);
+      if (dwResult == RCC_SUCCESS)
+         CreateObjectImageList();
    }
 
    // Disconnect if some of post-login operations was failed
index b957b13..f87396e 100644 (file)
@@ -18,7 +18,7 @@
 ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 **
 ** $module: draw.cpp
-** Various drawing functions
+** Various drawing and image functions
 **
 **/
 
@@ -156,3 +156,22 @@ void Draw3dRect(HDC hDC, LPRECT pRect, COLORREF rgbTop, COLORREF rgbBottom)
    // Cleanup
    SelectObject(hDC, hOldPen);
 }
+
+
+//
+// Load PNG image into memory as bitmap
+//
+
+HBITMAP LoadPNG(char *pszFileName, COLORREF *prgbMaskColor, int cx, int cy)
+{
+   CxImage image;
+   HBITMAP hBitmap = NULL;
+
+   if (image.Load(pszFileName, CXIMAGE_FORMAT_PNG))
+   {
+      image.Resample(cx, cy, 2);
+      hBitmap = image.MakeBitmap(AfxGetMainWnd()->GetDC()->m_hDC);
+      *prgbMaskColor = image.RGBQUADtoRGB(image.GetTransColor());
+   }
+   return hBitmap;
+}
index 9f7ee8e..1700cc6 100644 (file)
@@ -50,6 +50,14 @@ NXC_IMAGE_LIST *g_pSrvImageList = NULL;
 
 
 //
+// Image lists with object images
+//
+
+CImageList *g_pObjectSmallImageList = NULL;
+CImageList *g_pObjectNormalImageList = NULL;
+
+
+//
 // Global string constants
 //
 
index c4eb168..d251669 100644 (file)
@@ -112,6 +112,15 @@ void Draw3dRect(HDC hDC, LPRECT pRect, COLORREF rgbTop, COLORREF rgbBottom);
 
 
 //
+// Image functions
+//
+
+HBITMAP LoadPNG(char *pszFileName, COLORREF *prgbMaskColor, int cx, int cy);
+void CreateObjectImageList(void);
+DWORD ImageIdToIndex(DWORD dwImageId);
+
+
+//
 // Utility functions
 //
 
@@ -158,5 +167,7 @@ extern CODE_TO_TEXT g_ctSnmpMibStatus[];
 extern CODE_TO_TEXT g_ctSnmpMibAccess[];
 extern CODE_TO_TEXT g_ctSnmpMibType[];
 extern NXC_IMAGE_LIST *g_pSrvImageList;
+extern CImageList *g_pObjectSmallImageList;
+extern CImageList *g_pObjectNormalImageList;
 
 #endif
index 9287bfa..75926da 100644 (file)
@@ -2,7 +2,7 @@
 
 [General Info]
 Version=1
-LastClass=CRequestProcessingDlg
+LastClass=CLoginDialog
 LastTemplate=CDialog
 NewFileInclude1=#include "stdafx.h"
 NewFileInclude2=#include "nxcon.h"
@@ -16,9 +16,9 @@ Class7=CEventBrowser
 Class9=CMapView
 
 ResourceCount=60
-Resource1=IDD_OBJECT_GENERAL (English (U.S.))
+Resource1=IDR_MAINFRAME (English (U.S.))
 Resource2=IDD_USER_PROPERTIES
-Resource3=IDA_OBJECT_BROWSER (English (U.S.))
+Resource3=IDD_GROUP_PROPERTIES (English (U.S.))
 Resource4=IDM_CONTEXT
 Resource5=IDD_LOGIN
 Class2=CChildView
@@ -32,8 +32,8 @@ Resource7=IDD_OBJECT_CAPS
 Class12=CObjectBrowser
 Resource8=IDD_SELECT_EVENT
 Class13=CObjectPropDlg
-Resource9=IDD_REQUEST_PROCESSING (English (U.S.))
-Resource10=IDD_DCI_THRESHOLDS (English (U.S.))
+Resource9=IDD_SELECT_USER (English (U.S.))
+Resource10=IDD_OBJECT_CAPS (English (U.S.))
 Resource11=IDM_VIEW_SPECIFIC (English (U.S.))
 Resource12=IDR_CTRLPANEL (English (U.S.))
 Resource13=IDR_EVENTS (English (U.S.))
@@ -42,21 +42,21 @@ Resource15=IDR_OBJECTS (English (U.S.))
 Resource16=IDD_DUMMY (English (U.S.))
 Class14=CEventEditor
 Class15=CEditEventDlg
-Resource17=IDD_EDIT_EVENT (English (U.S.))
+Resource17=IDD_REQUEST_PROCESSING (English (U.S.))
 Class16=CDebugFrame
-Resource18=IDD_OBJECT_NODE_GENERAL (English (U.S.))
+Resource18=IDD_LOGIN (English (U.S.))
 Resource19=IDD_OBJECT_PROPERTIES (English (U.S.))
 Resource20=IDA_EPP
 Class17=CObjectPreview
-Resource21=IDD_GROUP_PROPERTIES (English (U.S.))
+Resource21=IDD_SELECT_OBJECT (English (U.S.))
 Class18=CToolBox
 Class19=CObjectInfoBox
 Class20=CObjectSearchBox
-Resource22=IDD_SELECT_USER (English (U.S.))
+Resource22=IDA_OBJECT_BROWSER (English (U.S.))
 Class21=CEditBox
 Class22=COPGeneral
 Class23=CNodePropsGeneral
-Resource23=IDD_DCI_COLLECTION (English (U.S.))
+Resource23=IDD_OBJECT_GENERAL (English (U.S.))
 Class24=CObjectPropCaps
 Class25=CObjectPropSheet
 Resource24=IDD_NEW_USER
@@ -66,9 +66,9 @@ Resource26=IDD_PROGRESS (English (U.S.))
 Resource27=IDD_ABOUTBOX
 Resource28=IDA_EPP (English (U.S.))
 Class27=CObjectPropsGeneral
-Resource29=IDD_MIB_BROWSER (English (U.S.))
+Resource29=IDD_DCI_THRESHOLDS (English (U.S.))
 Class28=CObjectPropsSecurity
-Resource30=IDD_LOGIN (English (U.S.))
+Resource30=IDD_SET_PASSWORD (English (U.S.))
 Resource31=IDD_SET_PASSWORD
 Resource32=IDD_THRESHOLD
 Class29=CUserSelectDlg
@@ -79,36 +79,36 @@ Class31=CNewUserDlg
 Resource35=IDD_DCI_THRESHOLDS
 Resource36=IDD_OBJECT_NODE_GENERAL
 Class32=CUserPropDlg
-Resource37=IDD_THRESHOLD (English (U.S.))
+Resource37=IDD_EDIT_RULE_COMMENT (English (U.S.))
 Resource38=IDD_EDIT_RULE_COMMENT
 Class33=CGroupPropDlg
 Resource39=IDD_OBJECT_SECURITY
 Resource40=IDD_GROUP_PROPERTIES
 Resource41=IDD_OBJECT_GENERAL
-Resource42=IDD_NEW_USER (English (U.S.))
+Resource42=IDA_MDI_DEFAULT (English (U.S.))
 Class34=CPasswordChangeDlg
 Class35=CNodeSummary
 Class36=CNetSummaryFrame
 Class37=CDataCollectionEditor
-Resource43=IDD_EDIT_RULE_COMMENT (English (U.S.))
+Resource43=IDD_MIB_BROWSER (English (U.S.))
 Class38=CDCIPropPage
-Resource44=IDA_MDI_DEFAULT (English (U.S.))
+Resource44=IDD_USER_PROPERTIES (English (U.S.))
 Class39=CDCIDataView
-Resource45=IDD_SELECT_OBJECT (English (U.S.))
+Resource45=IDD_EDIT_EVENT (English (U.S.))
 Class40=CGraph
 Class41=CGraphFrame
 Class42=CDCIThresholdsPage
-Resource46=IDD_SET_PASSWORD (English (U.S.))
+Resource46=IDD_THRESHOLD (English (U.S.))
 Resource47=IDA_OBJECT_BROWSER
 Resource48=IDD_DCI_COLLECTION
 Class43=CThresholdDlg
-Resource49=IDD_OBJECT_SECURITY (English (U.S.))
+Resource49=IDD_ABOUTBOX (English (U.S.))
 Resource50=IDA_MDI_DEFAULT
 Class44=CMIBBrowserDlg
 Class45=CEventPolicyEditor
 Class46=CRuleList
 Class47=CRuleHeader
-Resource51=IDD_ABOUTBOX (English (U.S.))
+Resource51=IDD_DCI_COLLECTION (English (U.S.))
 Resource52=IDM_VIEW_SPECIFIC
 Class48=CObjectSelDlg
 Resource53=IDR_MAINFRAME
@@ -117,9 +117,9 @@ Class49=CRuleCommentDlg
 Resource55=IDD_SELECT_OBJECT
 Class50=CEventSelDlg
 Resource56=IDD_REQUEST_PROCESSING
-Resource57=IDD_OBJECT_CAPS (English (U.S.))
-Resource58=IDD_USER_PROPERTIES (English (U.S.))
-Resource59=IDR_MAINFRAME (English (U.S.))
+Resource57=IDD_OBJECT_SECURITY (English (U.S.))
+Resource58=IDD_OBJECT_NODE_GENERAL (English (U.S.))
+Resource59=IDD_NEW_USER (English (U.S.))
 Resource60=IDD_SELECT_EVENT (English (U.S.))
 
 [CLS:CConsoleApp]
@@ -456,7 +456,7 @@ Control4=IDOK,button,1342373889
 [DLG:IDD_LOGIN (English (U.S.))]
 Type=1
 Class=CLoginDialog
-ControlCount=11
+ControlCount=15
 Control1=IDC_EDIT_SERVER,edit,1350631552
 Control2=IDC_EDIT_LOGIN,edit,1350631552
 Control3=IDC_EDIT_PASSWORD,edit,1350631584
@@ -468,6 +468,10 @@ Control8=IDC_STATIC,static,1342177296
 Control9=IDC_STATIC,static,1342308352
 Control10=IDC_STATIC,static,1342308352
 Control11=IDC_STATIC,static,1342308352
+Control12=IDC_STATIC,static,1342308352
+Control13=IDC_STATIC,static,1342177296
+Control14=IDC_RADIO_CLEAR,button,1342308361
+Control15=IDC_RADIO_BLOWFISH,button,1342177289
 
 [DLG:IDD_PROGRESS (English (U.S.))]
 Type=1
index 4fe1e16..c4bf402 100644 (file)
@@ -53,7 +53,7 @@ BSC32=bscmake.exe
 # ADD BSC32 /nologo
 LINK32=link.exe
 # ADD BASE LINK32 /nologo /subsystem:windows /machine:I386
-# ADD LINK32 libnxcl.lib libnetxms.lib libsnmp.lib /nologo /subsystem:windows /machine:I386 /libpath:"..\..\libnxcl\Release" /libpath:"..\..\libnetxms\Release"
+# ADD LINK32 libnxcl.lib libnetxms.lib libsnmp.lib cximage.lib /nologo /subsystem:windows /machine:I386 /libpath:"..\..\libnxcl\Release" /libpath:"..\..\libnetxms\Release"
 
 !ELSEIF  "$(CFG)" == "nxcon - Win32 Debug"
 
@@ -79,7 +79,7 @@ BSC32=bscmake.exe
 # ADD BSC32 /nologo
 LINK32=link.exe
 # ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 libnxcl.lib libnetxms.lib libsnmp.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept /libpath:"..\..\libnxcl\Debug" /libpath:"..\..\libnetxms\Debug"
+# ADD LINK32 libnxcl.lib libnetxms.lib libsnmp.lib cximage.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept /libpath:"..\..\libnxcl\Debug" /libpath:"..\..\libnetxms\Debug"
 # Begin Special Build Tool
 SOURCE="$(InputPath)"
 PostBuild_Cmds=copy Debug\nxcon.exe ..\..\..\bin
index 83cde33..5fd8c74 100644 (file)
@@ -451,24 +451,31 @@ BEGIN
     DEFPUSHBUTTON   "OK",IDOK,178,7,50,14,WS_GROUP
 END
 
-IDD_LOGIN DIALOG DISCARDABLE  0, 0, 215, 167
+IDD_LOGIN DIALOG DISCARDABLE  0, 0, 215, 205
 STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
 CAPTION "Connect to server"
 FONT 8, "MS Sans Serif"
 BEGIN
-    EDITTEXT        IDC_EDIT_SERVER,52,73,156,14,ES_AUTOHSCROLL
-    EDITTEXT        IDC_EDIT_LOGIN,52,96,156,14,ES_AUTOHSCROLL
-    EDITTEXT        IDC_EDIT_PASSWORD,52,119,156,14,ES_PASSWORD | 
+    EDITTEXT        IDC_EDIT_SERVER,52,71,156,14,ES_AUTOHSCROLL
+    EDITTEXT        IDC_EDIT_LOGIN,52,92,156,14,ES_AUTOHSCROLL
+    EDITTEXT        IDC_EDIT_PASSWORD,52,113,156,14,ES_PASSWORD | 
                     ES_AUTOHSCROLL
-    DEFPUSHBUTTON   "OK",IDOK,35,146,50,14
-    PUSHBUTTON      "&Quit",IDCANCEL,129,146,50,14
+    DEFPUSHBUTTON   "OK",IDOK,35,184,50,14
+    PUSHBUTTON      "&Quit",IDCANCEL,129,184,50,14
     CONTROL         142,IDC_STATIC,"Static",SS_BITMAP | SS_REALSIZEIMAGE,7,7,
                     201,44
     LTEXT           "Connect to server",IDC_STATIC,7,58,59,8
     CONTROL         "",IDC_STATIC,"Static",SS_ETCHEDHORZ,68,62,140,1
-    LTEXT           "User name:",IDC_STATIC,7,99,37,8
-    LTEXT           "Server:",IDC_STATIC,7,75,24,8
-    LTEXT           "Password:",IDC_STATIC,7,121,34,8
+    LTEXT           "User name:",IDC_STATIC,7,95,37,8
+    LTEXT           "Server:",IDC_STATIC,7,73,24,8
+    LTEXT           "Password:",IDC_STATIC,7,115,34,8
+    LTEXT           "Encryption",IDC_STATIC,7,137,37,8
+    CONTROL         "",IDC_STATIC,"Static",SS_ETCHEDHORZ,44,141,163,1
+    CONTROL         "&No encryption",IDC_RADIO_CLEAR,"Button",
+                    BS_AUTORADIOBUTTON | WS_GROUP,7,150,60,10
+    CONTROL         "Encrypt connection using &Blowfish algorithm",
+                    IDC_RADIO_BLOWFISH,"Button",BS_AUTORADIOBUTTON,7,164,154,
+                    10
 END
 
 IDD_EDIT_EVENT DIALOG DISCARDABLE  0, 0, 270, 190
@@ -905,7 +912,7 @@ BEGIN
         LEFTMARGIN, 7
         RIGHTMARGIN, 208
         TOPMARGIN, 7
-        BOTTOMMARGIN, 160
+        BOTTOMMARGIN, 198
     END
 
     IDD_EDIT_EVENT, DIALOG
index 962dc5b..976c98a 100644 (file)
 #define IDC_STATIC_TYPE                 1103
 #define IDC_EDIT_TEXT                   1104
 #define IDC_BITMAP                      1105
+#define IDC_RADIO_CLEAR                 1108
+#define IDC_RADIO_BLOWFISH              1109
 #define ID_VIEW_CONTROLPANEL            32771
 #define ID_VIEW_EVENTS                  32774
 #define ID_VIEW_MAP                     32776
 #define _APS_3D_CONTROLS                     1
 #define _APS_NEXT_RESOURCE_VALUE        194
 #define _APS_NEXT_COMMAND_VALUE         32864
-#define _APS_NEXT_CONTROL_VALUE         1106
+#define _APS_NEXT_CONTROL_VALUE         1110
 #define _APS_NEXT_SYMED_VALUE           119
 #endif
 #endif
index 3a98d91..32a1688 100644 (file)
@@ -224,3 +224,63 @@ void LoadBitmapIntoList(CImageList *pImageList, UINT nIDResource, COLORREF rgbMa
    bmp.LoadBitmap(nIDResource);
    pImageList->Add(&bmp, rgbMaskColor);
 }
+
+
+//
+// Find image's index in list by image id
+//
+
+DWORD ImageIdToIndex(DWORD dwImageId)
+{
+   DWORD i;
+
+   for(i = 0; i < g_pSrvImageList->dwNumImages; i++)
+      if (g_pSrvImageList->pImageList[i].dwId == dwImageId)
+         return i;
+   return 0;
+}
+
+
+//
+// Create image list with object images
+//
+
+void CreateObjectImageList(void)
+{
+   HBITMAP hBitmap;
+   DWORD i, dwPos;
+   char szFileName[MAX_PATH];
+   COLORREF rgbMaskColor;
+
+   // Create small (16x16) image list
+   if (g_pObjectSmallImageList != NULL)
+      delete g_pObjectSmallImageList;
+   g_pObjectSmallImageList = new CImageList;
+   g_pObjectSmallImageList->Create(16, 16, ILC_COLOR24 | ILC_MASK, 8, 8);
+
+   // Create normal (32x32) image list
+   if (g_pObjectNormalImageList != NULL)
+      delete g_pObjectNormalImageList;
+   g_pObjectNormalImageList = new CImageList;
+   g_pObjectNormalImageList->Create(32, 32, ILC_COLOR24 | ILC_MASK, 8, 8);
+
+   strcpy(szFileName, g_szWorkDir);
+   strcat(szFileName, WORKDIR_IMAGECACHE);
+   strcat(szFileName, "\\");
+   dwPos = strlen(szFileName);
+
+   for(i = 0; i < g_pSrvImageList->dwNumImages; i++)
+   {
+      sprintf(&szFileName[dwPos], "%d.png", g_pSrvImageList->pImageList[i].dwId);
+      
+      // Load 16x16 image
+      hBitmap = LoadPNG(szFileName, &rgbMaskColor, 16, 16);
+      if (hBitmap != NULL)
+         ImageList_AddMasked(g_pObjectSmallImageList->m_hImageList, hBitmap, rgbMaskColor);
+
+      // Load 32x32 image
+      hBitmap = LoadPNG(szFileName, &rgbMaskColor, 32, 32);
+      if (hBitmap != NULL)
+         ImageList_AddMasked(g_pObjectNormalImageList->m_hImageList, hBitmap, rgbMaskColor);
+   }
+}