7ea86be014af6961b5a5d4a2aa25dcb0eed2fc45
[public/netxms.git] / src / console / win32 / globals.h
1 /*
2 ** NetXMS - Network Management System
3 ** Client Library
4 ** Copyright (C) 2004 Victor Kirhenshtein
5 **
6 ** This program is free software; you can redistribute it and/or modify
7 ** it under the terms of the GNU General Public License as published by
8 ** the Free Software Foundation; either version 2 of the License, or
9 ** (at your option) any later version.
10 **
11 ** This program is distributed in the hope that it will be useful,
12 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ** GNU General Public License for more details.
15 **
16 ** You should have received a copy of the GNU General Public License
17 ** along with this program; if not, write to the Free Software
18 ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 **
20 ** $module: globals.h
21 **
22 **/
23
24 #ifndef _globals_h_
25 #define _globals_h_
26
27
28 //
29 // Application object declaration
30 //
31
32 class CConsoleApp;
33 extern CConsoleApp theApp;
34
35
36 //
37 // Constants
38 //
39
40 #define MAX_SERVER_NAME_LEN 64
41 #define MAX_LOGIN_NAME_LEN 64
42 #define MAX_PASSWORD_LEN 64
43 #define MAX_INTERFACE_TYPE 32
44 #define MAX_WND_PARAM_LEN 32768
45
46 #define TOOLBOX_X_MARGIN 5
47 #define TOOLBOX_Y_MARGIN 5
48
49 #define OBJTOOL_MENU_FIRST_ID 4000
50 #define OBJTOOL_MENU_LAST_ID 4999
51
52 #define NXCON_ALARM_SOUND_KEY _T("Software\\NetXMS\\NetXMS Console\\AlarmSounds")
53
54
55 //
56 // Window classes
57 //
58
59 #define WNDC_LAST_VALUES 1
60 #define WNDC_GRAPH 2
61 #define WNDC_DCI_DATA 3
62 #define WNDC_NETWORK_SUMMARY 4
63 #define WNDC_ALARM_BROWSER 5
64 #define WNDC_EVENT_BROWSER 6
65 #define WNDC_OBJECT_BROWSER 7
66 #define WNDC_SYSLOG_BROWSER 8
67 #define WNDC_TRAP_LOG_BROWSER 9
68 #define WNDC_CONTROL_PANEL 10
69
70
71 //
72 // User interface options
73 //
74
75 #define UI_OPT_EXPAND_CTRLPANEL 0x0001
76 #define UI_OPT_SHOW_GRID 0x0002
77
78
79 //
80 // Other options
81 //
82
83 #define OPT_MATCH_SERVER_VERSION 0x00010000
84 #define OPT_DONT_CACHE_OBJECTS 0x00020000
85 #define OPT_ENCRYPT_CONNECTION 0x00040000
86 #define OPT_CLEAR_OBJECT_CACHE 0x00080000
87
88
89 //
90 // Transparent color for images in rule list
91 //
92
93 #define PSYM_MASK_COLOR RGB(255, 255, 255)
94
95
96 //
97 // Custom windows messages
98 //
99
100 #define NXCM_REQUEST_COMPLETED (WM_USER + 101)
101 #define NXCM_CLOSE_STATUS_DLG (WM_USER + 102)
102 #define NXCM_OBJECT_CHANGE (WM_USER + 103)
103 #define NXCM_FIND_OBJECT (WM_USER + 104)
104 #define NXCM_EDITBOX_EVENT (WM_USER + 105)
105 #define NXCM_SET_INFO_TEXT (WM_USER + 106)
106 #define NXCM_USERDB_CHANGE (WM_USER + 107)
107 #define NXCM_STATE_CHANGE (WM_USER + 108)
108 #define NXCM_ALARM_UPDATE (WM_USER + 109)
109 #define NXCM_POLLER_MESSAGE (WM_USER + 110)
110 #define NXCM_START_DEPLOYMENT (WM_USER + 111)
111 #define NXCM_DEPLOYMENT_INFO (WM_USER + 112)
112 #define NXCM_DEPLOYMENT_FINISHED (WM_USER + 113)
113 #define NXCM_GET_SAVE_INFO (WM_USER + 114)
114 #define NXCM_TABLE_DATA (WM_USER + 115)
115 #define NXCM_NETXMS_EVENT (WM_USER + 116)
116 #define NXCM_SYSLOG_RECORD (WM_USER + 117)
117 #define NXCM_UPDATE_EVENT_LIST (WM_USER + 118)
118 #define NXCM_UPDATE_OBJECT_TOOLS (WM_USER + 119)
119 #define NXCM_UPDATE_GRAPH_POINT (WM_USER + 120)
120 #define NXCM_TRAP_LOG_RECORD (WM_USER + 121)
121 #define NXCM_SUBMAP_CHANGE (WM_USER + 122)
122 #define NXCM_CHANGE_PASSWORD (WM_USER + 123)
123
124
125 //
126 // Timestamp formats
127 //
128
129 #define TS_LONG_DATE_TIME 0
130 #define TS_LONG_TIME 1
131 #define TS_DAY_AND_MONTH 2
132 #define TS_MONTH 3
133
134
135 //
136 // Subdirectories and files in working directory
137 //
138
139 #define WORKDIR_MIBCACHE _T("\\MIBCache")
140 #define WORKDIR_IMAGECACHE _T("\\ImageCache")
141 #define WORKDIR_BKIMAGECACHE _T("\\BkImageCache")
142 #define WORKFILE_OBJECTCACHE _T("\\objects.cache.")
143
144
145 //
146 // libnxcl object index structure
147 //
148
149 struct NXC_OBJECT_INDEX
150 {
151 DWORD dwKey;
152 NXC_OBJECT *pObject;
153 };
154
155
156 //
157 // Request parameters structure
158 //
159
160 struct RqData
161 {
162 HWND hWnd;
163 DWORD (* pFunc)(...);
164 DWORD dwNumParams;
165 void *pArg1;
166 void *pArg2;
167 void *pArg3;
168 void *pArg4;
169 void *pArg5;
170 void *pArg6;
171 void *pArg7;
172 };
173
174
175 //
176 // Code translation structure
177 //
178
179 struct CODE_TO_TEXT
180 {
181 int iCode;
182 char *pszText;
183 };
184
185
186 //
187 // Default image table
188 //
189
190 struct DEF_IMG
191 {
192 DWORD dwObjectClass;
193 DWORD dwImageId;
194 int iImageIndex;
195 };
196
197
198 //
199 // Package deployment startup info
200 //
201
202 struct DEPLOYMENT_JOB
203 {
204 DWORD dwPkgId;
205 DWORD dwNumObjects;
206 DWORD *pdwObjectList;
207 HWND hWnd;
208 DWORD *pdwRqId;
209 };
210
211
212 //
213 // Window state saving information
214 //
215
216 struct WINDOW_SAVE_INFO
217 {
218 int iWndClass;
219 WINDOWPLACEMENT placement;
220 TCHAR szParameters[MAX_WND_PARAM_LEN];
221 };
222
223
224 //
225 // DCI information
226 //
227
228 class DCIInfo
229 {
230 // Attributes
231 public:
232 DWORD m_dwNodeId;
233 DWORD m_dwItemId;
234 int m_iSource;
235 int m_iDataType;
236 TCHAR *m_pszParameter;
237 TCHAR *m_pszDescription;
238
239 // Methods
240 public:
241 DCIInfo();
242 DCIInfo(DWORD dwNodeId, NXC_DCI *pItem);
243 ~DCIInfo();
244 };
245
246
247 //
248 // Communication functions
249 //
250
251 DWORD DoLogin(BOOL bClearCache);
252 DWORD DoRequest(DWORD (* pFunc)(void), char *pszInfoText);
253 DWORD DoRequestArg1(void *pFunc, void *pArg1, char *pszInfoText);
254 DWORD DoRequestArg2(void *pFunc, void *pArg1, void *pArg2, char *pszInfoText);
255 DWORD DoRequestArg3(void *pFunc, void *pArg1, void *pArg2, void *pArg3, char *pszInfoText);
256 DWORD DoRequestArg4(void *pFunc, void *pArg1, void *pArg2, void *pArg3, void *pArg4, char *pszInfoText);
257 DWORD DoRequestArg5(void *pFunc, void *pArg1, void *pArg2, void *pArg3, void *pArg4,
258 void *pArg5, char *pszInfoText);
259 DWORD DoRequestArg6(void *pFunc, void *pArg1, void *pArg2, void *pArg3, void *pArg4,
260 void *pArg5, void *pArg6, char *pszInfoText);
261 DWORD DoRequestArg7(void *pFunc, void *pArg1, void *pArg2, void *pArg3, void *pArg4,
262 void *pArg5, void *pArg6, void *pArg7, char *pszInfoText);
263 DWORD WINAPI PollerThread(void *pArg);
264
265
266 //
267 // Drawing functions
268 //
269
270 void DrawPieChart(CDC &dc, RECT *pRect, int iNumElements, DWORD *pdwValues, COLORREF *pColors);
271 void Draw3dRect(HDC hDC, LPRECT pRect, COLORREF rgbTop, COLORREF rgbBottom);
272
273
274 //
275 // Image and image list functions
276 //
277
278 void CreateObjectImageList(void);
279 int ImageIdToIndex(DWORD dwImageId);
280 int GetObjectImageIndex(NXC_OBJECT *pObject);
281 int GetClassDefaultImageIndex(int iClass);
282 CImageList *CreateEventImageList(void);
283 void LoadBitmapIntoList(CImageList *pImageList, UINT nIDResource, COLORREF rgbMaskColor);
284 HBITMAP LoadPicture(TCHAR *pszFile, int nScaleFactor);
285
286
287 //
288 // MIB functions
289 //
290
291 void BuildOIDString(SNMP_MIBObject *pNode, char *pszBuffer);
292 char *BuildSymbolicOIDString(SNMP_MIBObject *pNode, DWORD dwInstance);
293
294
295 //
296 // Utility functions
297 //
298
299 char *FormatTimeStamp(DWORD dwTimeStamp, char *pszBuffer, int iType);
300 CSize GetWindowSize(CWnd *pWnd);
301 void SelectListViewItem(CListCtrl *pListCtrl, int iItem);
302 const char *CodeToText(int iCode, CODE_TO_TEXT *pTranslator, const char *pszDefaultText = "Unknown");
303 char *TranslateUNIXText(const char *pszText);
304 void RestoreMDIChildPlacement(CMDIChildWnd *pWnd, WINDOWPLACEMENT *pwp);
305 BOOL IsButtonChecked(CDialog *pWnd, int nCtrl);
306 BOOL ExtractWindowParam(TCHAR *pszStr, TCHAR *pszParam, TCHAR *pszBuffer, int iSize);
307 long ExtractWindowParamLong(TCHAR *pszStr, TCHAR *pszParam, long nDefault);
308 DWORD ExtractWindowParamULong(TCHAR *pszStr, TCHAR *pszParam, DWORD dwDefault);
309 void CopyMenuItems(CMenu *pDst, CMenu *pSrc);
310 TCHAR **CopyStringList(TCHAR **ppList, DWORD dwSize);
311 void DestroyStringList(TCHAR **ppList, DWORD dwSize);
312 HTREEITEM FindTreeCtrlItem(CTreeCtrl &ctrl, HTREEITEM hRoot, TCHAR *pszText);
313 HTREEITEM FindTreeCtrlItemEx(CTreeCtrl &ctrl, HTREEITEM hRoot, DWORD dwData);
314
315
316 //
317 // Object tools functions
318 //
319
320 DWORD LoadObjectTools(void);
321 CMenu *CreateToolsSubmenu(NXC_OBJECT *pObject, TCHAR *pszCurrPath, DWORD *pdwStart);
322
323
324 //
325 // Action functions
326 //
327
328 NXC_ACTION *FindActionById(DWORD dwActionId);
329 void UpdateActions(DWORD dwCode, NXC_ACTION *pAction);
330
331
332 //
333 // Variables
334 //
335
336 extern NXC_SESSION g_hSession;
337 extern DWORD g_dwOptions;
338 extern DWORD g_dwMaxLogRecords;
339 extern TCHAR g_szServer[];
340 extern TCHAR g_szLogin[];
341 extern TCHAR g_szPassword[];
342 extern TCHAR g_szWorkDir[];
343 extern TCHAR *g_szStatusText[];
344 extern TCHAR *g_szStatusTextSmall[];
345 extern TCHAR *g_szActionType[];
346 extern TCHAR *g_szServiceType[];
347 extern TCHAR *g_szDeploymentStatus[];
348 extern TCHAR *g_szToolType[];
349 extern TCHAR *g_szToolColFmt[];
350 extern TCHAR *g_szSyslogSeverity[];
351 extern TCHAR *g_szSyslogFacility[];
352 extern COLORREF g_statusColorTable[];
353 extern char *g_szObjectClass[];
354 extern char *g_szInterfaceTypes[];
355 extern TCHAR *g_pszItemOrigin[];
356 extern TCHAR *g_pszItemOriginLong[];
357 extern TCHAR *g_pszItemDataType[];
358 extern char *g_pszItemStatus[];
359 extern char *g_pszThresholdOperation[];
360 extern char *g_pszThresholdOperationLong[];
361 extern char *g_pszThresholdFunction[];
362 extern char *g_pszThresholdFunctionLong[];
363 extern CODE_TO_TEXT g_ctSnmpMibStatus[];
364 extern CODE_TO_TEXT g_ctSnmpMibAccess[];
365 extern CODE_TO_TEXT g_ctSnmpMibType[];
366 extern NXC_IMAGE_LIST *g_pSrvImageList;
367 extern CImageList *g_pObjectSmallImageList;
368 extern CImageList *g_pObjectNormalImageList;
369 extern DWORD g_dwDefImgListSize;
370 extern DEF_IMG *g_pDefImgList;
371 extern DWORD g_dwNumActions;
372 extern NXC_ACTION *g_pActionList;
373 extern HANDLE g_mutexActionListAccess;
374 extern NXC_CC_LIST *g_pCCList;
375 extern CODE_TO_TEXT g_ctNodeType[];
376 extern DWORD g_dwNumObjectTools;
377 extern NXC_OBJECT_TOOL *g_pObjectToolList;
378 extern SNMP_MIBObject *g_pMIBRoot;
379 extern ALARM_SOUND_CFG g_soundCfg;
380 extern CFont g_fontCode;
381
382
383 //
384 // Lock/unlock access to action list
385 //
386
387 inline void LockActions(void)
388 {
389 WaitForSingleObject(g_mutexActionListAccess, INFINITE);
390 }
391
392 inline void UnlockActions(void)
393 {
394 ReleaseMutex(g_mutexActionListAccess);
395 }
396
397 #endif