a20a86c25beb5efa05d854551101c749ddc1ca04
[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
53 //
54 // Window classes
55 //
56
57 #define WNDC_LAST_VALUES 1
58 #define WNDC_GRAPH 2
59 #define WNDC_DCI_DATA 3
60 #define WNDC_NETWORK_SUMMARY 4
61 #define WNDC_ALARM_BROWSER 5
62 #define WNDC_EVENT_BROWSER 6
63 #define WNDC_OBJECT_BROWSER 7
64 #define WNDC_SYSLOG_BROWSER 8
65
66
67 //
68 // User interface options
69 //
70
71 #define UI_OPT_EXPAND_CTRLPANEL 0x0001
72 #define UI_OPT_SHOW_GRID 0x0002
73
74
75 //
76 // Other options
77 //
78
79 #define OPT_MATCH_SERVER_VERSION 0x00010000
80 #define OPT_DONT_CACHE_OBJECTS 0x00020000
81 #define OPT_ENCRYPT_CONNECTION 0x00040000
82
83
84 //
85 // Transparent color for images in rule list
86 //
87
88 #define PSYM_MASK_COLOR RGB(255, 255, 255)
89
90
91 //
92 // Custom windows messages
93 //
94
95 #define WM_REQUEST_COMPLETED (WM_USER + 101)
96 #define WM_CLOSE_STATUS_DLG (WM_USER + 102)
97 #define WM_OBJECT_CHANGE (WM_USER + 103)
98 #define WM_FIND_OBJECT (WM_USER + 104)
99 #define WM_EDITBOX_EVENT (WM_USER + 105)
100 #define WM_SET_INFO_TEXT (WM_USER + 106)
101 #define WM_USERDB_CHANGE (WM_USER + 107)
102 #define WM_STATE_CHANGE (WM_USER + 108)
103 #define WM_ALARM_UPDATE (WM_USER + 109)
104 #define WM_POLLER_MESSAGE (WM_USER + 110)
105 #define WM_START_DEPLOYMENT (WM_USER + 111)
106 #define WM_DEPLOYMENT_INFO (WM_USER + 112)
107 #define WM_DEPLOYMENT_FINISHED (WM_USER + 113)
108 #define WM_GET_SAVE_INFO (WM_USER + 114)
109 #define WM_TABLE_DATA (WM_USER + 115)
110 #define WM_NETXMS_EVENT (WM_USER + 116)
111 #define WM_SYSLOG_RECORD (WM_USER + 117)
112 #define WM_UPDATE_EVENT_LIST (WM_USER + 118)
113
114
115 //
116 // Timestamp formats
117 //
118
119 #define TS_LONG_DATE_TIME 0
120 #define TS_LONG_TIME 1
121
122
123 //
124 // Subdirectories and files in working directory
125 //
126
127 #define WORKDIR_MIBCACHE _T("\\MIBCache")
128 #define WORKDIR_IMAGECACHE _T("\\ImageCache")
129 #define WORKFILE_OBJECTCACHE _T("\\objects.cache.")
130
131
132 //
133 // Request parameters structure
134 //
135
136 struct RqData
137 {
138 HWND hWnd;
139 DWORD (* pFunc)(...);
140 DWORD dwNumParams;
141 void *pArg1;
142 void *pArg2;
143 void *pArg3;
144 void *pArg4;
145 void *pArg5;
146 void *pArg6;
147 void *pArg7;
148 };
149
150
151 //
152 // Code translation structure
153 //
154
155 struct CODE_TO_TEXT
156 {
157 int iCode;
158 char *pszText;
159 };
160
161
162 //
163 // Default image table
164 //
165
166 struct DEF_IMG
167 {
168 DWORD dwObjectClass;
169 DWORD dwImageId;
170 int iImageIndex;
171 };
172
173
174 //
175 // Package deployment startup info
176 //
177
178 struct DEPLOYMENT_JOB
179 {
180 DWORD dwPkgId;
181 DWORD dwNumObjects;
182 DWORD *pdwObjectList;
183 HWND hWnd;
184 DWORD *pdwRqId;
185 };
186
187
188 //
189 // Window state saving information
190 //
191
192 struct WINDOW_SAVE_INFO
193 {
194 int iWndClass;
195 WINDOWPLACEMENT placement;
196 TCHAR szParameters[MAX_WND_PARAM_LEN];
197 };
198
199
200 //
201 // DCI information
202 //
203
204 class DCIInfo
205 {
206 // Attributes
207 public:
208 DWORD m_dwNodeId;
209 DWORD m_dwItemId;
210 int m_iSource;
211 int m_iDataType;
212 TCHAR *m_pszParameter;
213 TCHAR *m_pszDescription;
214
215 // Methods
216 public:
217 DCIInfo();
218 DCIInfo(DWORD dwNodeId, NXC_DCI *pItem);
219 ~DCIInfo();
220 };
221
222
223 //
224 // Communication functions
225 //
226
227 DWORD DoLogin(BOOL bClearCache);
228 DWORD DoRequest(DWORD (* pFunc)(void), char *pszInfoText);
229 DWORD DoRequestArg1(void *pFunc, void *pArg1, char *pszInfoText);
230 DWORD DoRequestArg2(void *pFunc, void *pArg1, void *pArg2, char *pszInfoText);
231 DWORD DoRequestArg3(void *pFunc, void *pArg1, void *pArg2, void *pArg3, char *pszInfoText);
232 DWORD DoRequestArg4(void *pFunc, void *pArg1, void *pArg2, void *pArg3, void *pArg4, char *pszInfoText);
233 DWORD DoRequestArg5(void *pFunc, void *pArg1, void *pArg2, void *pArg3, void *pArg4,
234 void *pArg5, char *pszInfoText);
235 DWORD DoRequestArg6(void *pFunc, void *pArg1, void *pArg2, void *pArg3, void *pArg4,
236 void *pArg5, void *pArg6, char *pszInfoText);
237 DWORD DoRequestArg7(void *pFunc, void *pArg1, void *pArg2, void *pArg3, void *pArg4,
238 void *pArg5, void *pArg6, void *pArg7, char *pszInfoText);
239 DWORD WINAPI PollerThread(void *pArg);
240
241
242 //
243 // Drawing functions
244 //
245
246 void DrawPieChart(CDC &dc, RECT *pRect, int iNumElements, DWORD *pdwValues, COLORREF *pColors);
247 void Draw3dRect(HDC hDC, LPRECT pRect, COLORREF rgbTop, COLORREF rgbBottom);
248
249
250 //
251 // Image and image list functions
252 //
253
254 void CreateObjectImageList(void);
255 int ImageIdToIndex(DWORD dwImageId);
256 int GetObjectImageIndex(NXC_OBJECT *pObject);
257 int GetClassDefaultImageIndex(int iClass);
258 CImageList *CreateEventImageList(void);
259 void LoadBitmapIntoList(CImageList *pImageList, UINT nIDResource, COLORREF rgbMaskColor);
260
261
262 //
263 // MIB functions
264 //
265
266 void BuildOIDString(SNMP_MIBObject *pNode, char *pszBuffer);
267 char *BuildSymbolicOIDString(SNMP_MIBObject *pNode, DWORD dwInstance);
268
269
270 //
271 // Utility functions
272 //
273
274 char *FormatTimeStamp(DWORD dwTimeStamp, char *pszBuffer, int iType);
275 CSize GetWindowSize(CWnd *pWnd);
276 void SelectListViewItem(CListCtrl *pListCtrl, int iItem);
277 const char *CodeToText(int iCode, CODE_TO_TEXT *pTranslator, const char *pszDefaultText = "Unknown");
278 char *TranslateUNIXText(const char *pszText);
279 void RestoreMDIChildPlacement(CMDIChildWnd *pWnd, WINDOWPLACEMENT *pwp);
280 void EnableDlgItem(CDialog *pWnd, int nCtrl, BOOL bEnable);
281 BOOL ExtractWindowParam(TCHAR *pszStr, TCHAR *pszParam, TCHAR *pszBuffer, int iSize);
282 long ExtractWindowParamLong(TCHAR *pszStr, TCHAR *pszParam, long nDefault);
283 DWORD ExtractWindowParamULong(TCHAR *pszStr, TCHAR *pszParam, DWORD dwDefault);
284 void CopyMenuItems(CMenu *pDst, CMenu *pSrc);
285 CMenu *CreateToolsSubmenu(TCHAR *pszCurrPath, DWORD *pdwStart);
286 TCHAR **CopyStringList(TCHAR **ppList, DWORD dwSize);
287 void DestroyStringList(TCHAR **ppList, DWORD dwSize);
288
289
290 //
291 // Action functions
292 //
293
294 NXC_ACTION *FindActionById(DWORD dwActionId);
295 void UpdateActions(DWORD dwCode, NXC_ACTION *pAction);
296
297
298 //
299 // Variables
300 //
301
302 extern NXC_SESSION g_hSession;
303 extern DWORD g_dwOptions;
304 extern DWORD g_dwMaxLogRecords;
305 extern TCHAR g_szServer[];
306 extern TCHAR g_szLogin[];
307 extern TCHAR g_szPassword[];
308 extern TCHAR g_szWorkDir[];
309 extern TCHAR *g_szStatusText[];
310 extern TCHAR *g_szStatusTextSmall[];
311 extern TCHAR *g_szActionType[];
312 extern TCHAR *g_szServiceType[];
313 extern TCHAR *g_szDeploymentStatus[];
314 extern TCHAR *g_szSyslogSeverity[];
315 extern TCHAR *g_szSyslogFacility[];
316 extern COLORREF g_statusColorTable[];
317 extern char *g_szObjectClass[];
318 extern char *g_szInterfaceTypes[];
319 extern TCHAR *g_pszItemOrigin[];
320 extern TCHAR *g_pszItemOriginLong[];
321 extern TCHAR *g_pszItemDataType[];
322 extern char *g_pszItemStatus[];
323 extern char *g_pszThresholdOperation[];
324 extern char *g_pszThresholdOperationLong[];
325 extern char *g_pszThresholdFunction[];
326 extern char *g_pszThresholdFunctionLong[];
327 extern CODE_TO_TEXT g_ctSnmpMibStatus[];
328 extern CODE_TO_TEXT g_ctSnmpMibAccess[];
329 extern CODE_TO_TEXT g_ctSnmpMibType[];
330 extern NXC_IMAGE_LIST *g_pSrvImageList;
331 extern CImageList *g_pObjectSmallImageList;
332 extern CImageList *g_pObjectNormalImageList;
333 extern DWORD g_dwDefImgListSize;
334 extern DEF_IMG *g_pDefImgList;
335 extern DWORD g_dwNumActions;
336 extern NXC_ACTION *g_pActionList;
337 extern HANDLE g_mutexActionListAccess;
338 extern NXC_CC_LIST *g_pCCList;
339 extern CODE_TO_TEXT g_ctNodeType[];
340 extern DWORD g_dwNumObjectTools;
341 extern NXC_OBJECT_TOOL *g_pObjectToolList;
342 extern CMenu *g_pObjectToolsMenu;
343 extern SNMP_MIBObject *g_pMIBRoot;
344
345
346 //
347 // Lock/unlock access to action list
348 //
349
350 inline void LockActions(void)
351 {
352 WaitForSingleObject(g_mutexActionListAccess, INFINITE);
353 }
354
355 inline void UnlockActions(void)
356 {
357 ReleaseMutex(g_mutexActionListAccess);
358 }
359
360 #endif