Implemented object caching on client side
[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
45 #define TOOLBOX_X_MARGIN 5
46 #define TOOLBOX_Y_MARGIN 5
47
48
49 //
50 // User interface options
51 //
52
53 #define UI_OPT_EXPAND_CTRLPANEL 0x0001
54 #define UI_OPT_SHOW_GRID 0x0002
55
56
57 //
58 // Transparent color for images in rule list
59 //
60
61 #define PSYM_MASK_COLOR RGB(255, 255, 255)
62
63
64 //
65 // Custom windows messages
66 //
67
68 #define WM_REQUEST_COMPLETED (WM_USER + 1)
69 #define WM_CLOSE_STATUS_DLG (WM_USER + 2)
70 #define WM_OBJECT_CHANGE (WM_USER + 3)
71 #define WM_FIND_OBJECT (WM_USER + 4)
72 #define WM_EDITBOX_EVENT (WM_USER + 5)
73 #define WM_SET_INFO_TEXT (WM_USER + 6)
74 #define WM_USERDB_CHANGE (WM_USER + 7)
75 #define WM_STATE_CHANGE (WM_USER + 8)
76 #define WM_ALARM_UPDATE (WM_USER + 9)
77 #define WM_POLLER_MESSAGE (WM_USER + 10)
78 #define WM_START_DEPLOYMENT (WM_USER + 11)
79 #define WM_DEPLOYMENT_INFO (WM_USER + 12)
80 #define WM_DEPLOYMENT_FINISHED (WM_USER + 13)
81
82
83 //
84 // Timestamp formats
85 //
86
87 #define TS_LONG_DATE_TIME 0
88 #define TS_LONG_TIME 1
89
90
91 //
92 // Subdirectories and files in working directory
93 //
94
95 #define WORKDIR_MIBCACHE _T("\\MIBCache")
96 #define WORKDIR_IMAGECACHE _T("\\ImageCache")
97 #define WORKFILE_OBJECTCACHE _T("\\objects.cache")
98
99
100 //
101 // Request parameters structure
102 //
103
104 struct RqData
105 {
106 HWND hWnd;
107 DWORD (* pFunc)(...);
108 DWORD dwNumParams;
109 void *pArg1;
110 void *pArg2;
111 void *pArg3;
112 void *pArg4;
113 void *pArg5;
114 void *pArg6;
115 void *pArg7;
116 };
117
118
119 //
120 // Code translation structure
121 //
122
123 struct CODE_TO_TEXT
124 {
125 int iCode;
126 char *pszText;
127 };
128
129
130 //
131 // Default image table
132 //
133
134 struct DEF_IMG
135 {
136 DWORD dwObjectClass;
137 DWORD dwImageId;
138 int iImageIndex;
139 };
140
141
142 //
143 // Package deployment startup info
144 //
145
146 struct DEPLOYMENT_JOB
147 {
148 DWORD dwPkgId;
149 DWORD dwNumObjects;
150 DWORD *pdwObjectList;
151 HWND hWnd;
152 DWORD *pdwRqId;
153 };
154
155
156 //
157 // Communication functions
158 //
159
160 DWORD DoLogin(void);
161 DWORD DoRequest(DWORD (* pFunc)(void), char *pszInfoText);
162 DWORD DoRequestArg1(void *pFunc, void *pArg1, char *pszInfoText);
163 DWORD DoRequestArg2(void *pFunc, void *pArg1, void *pArg2, char *pszInfoText);
164 DWORD DoRequestArg3(void *pFunc, void *pArg1, void *pArg2, void *pArg3, char *pszInfoText);
165 DWORD DoRequestArg4(void *pFunc, void *pArg1, void *pArg2, void *pArg3, void *pArg4, char *pszInfoText);
166 DWORD DoRequestArg5(void *pFunc, void *pArg1, void *pArg2, void *pArg3, void *pArg4,
167 void *pArg5, char *pszInfoText);
168 DWORD DoRequestArg6(void *pFunc, void *pArg1, void *pArg2, void *pArg3, void *pArg4,
169 void *pArg5, void *pArg6, char *pszInfoText);
170 DWORD DoRequestArg7(void *pFunc, void *pArg1, void *pArg2, void *pArg3, void *pArg4,
171 void *pArg5, void *pArg6, void *pArg7, char *pszInfoText);
172 DWORD WINAPI PollerThread(void *pArg);
173
174
175 //
176 // Drawing functions
177 //
178
179 void DrawPieChart(CDC &dc, RECT *pRect, int iNumElements, DWORD *pdwValues, COLORREF *pColors);
180 void Draw3dRect(HDC hDC, LPRECT pRect, COLORREF rgbTop, COLORREF rgbBottom);
181
182
183 //
184 // Image and image list functions
185 //
186
187 void CreateObjectImageList(void);
188 int ImageIdToIndex(DWORD dwImageId);
189 int GetObjectImageIndex(NXC_OBJECT *pObject);
190 CImageList *CreateEventImageList(void);
191 void LoadBitmapIntoList(CImageList *pImageList, UINT nIDResource, COLORREF rgbMaskColor);
192
193
194 //
195 // Utility functions
196 //
197
198 char *FormatTimeStamp(DWORD dwTimeStamp, char *pszBuffer, int iType);
199 CSize GetWindowSize(CWnd *pWnd);
200 void SelectListViewItem(CListCtrl *pListCtrl, int iItem);
201 const char *CodeToText(int iCode, CODE_TO_TEXT *pTranslator, const char *pszDefaultText = "Unknown");
202 char *TranslateUNIXText(const char *pszText);
203 void RestoreMDIChildPlacement(CMDIChildWnd *pWnd, WINDOWPLACEMENT *pwp);
204 void EnableDlgItem(CDialog *pWnd, int nCtrl, BOOL bEnable);
205
206
207 //
208 // MIB functions
209 //
210
211 BOOL CreateMIBTree(void);
212 void DestroyMIBTree(void);
213
214
215 //
216 // Action functions
217 //
218
219 NXC_ACTION *FindActionById(DWORD dwActionId);
220 void UpdateActions(DWORD dwCode, NXC_ACTION *pAction);
221
222
223 //
224 // Variables
225 //
226
227 extern NXC_SESSION g_hSession;
228 extern DWORD g_dwOptions;
229 extern char g_szServer[];
230 extern char g_szLogin[];
231 extern char g_szPassword[];
232 extern DWORD g_dwEncryptionMethod;
233 extern char g_szWorkDir[];
234 extern TCHAR *g_szStatusText[];
235 extern TCHAR *g_szStatusTextSmall[];
236 extern TCHAR *g_szActionType[];
237 extern TCHAR *g_szServiceType[];
238 extern TCHAR *g_szDeploymentStatus[];
239 extern COLORREF g_statusColorTable[];
240 extern char *g_szObjectClass[];
241 extern char *g_szInterfaceTypes[];
242 extern char *g_pszItemOrigin[];
243 extern char *g_pszItemOriginLong[];
244 extern char *g_pszItemDataType[];
245 extern char *g_pszItemStatus[];
246 extern char *g_pszThresholdOperation[];
247 extern char *g_pszThresholdOperationLong[];
248 extern char *g_pszThresholdFunction[];
249 extern char *g_pszThresholdFunctionLong[];
250 extern CODE_TO_TEXT g_ctSnmpMibStatus[];
251 extern CODE_TO_TEXT g_ctSnmpMibAccess[];
252 extern CODE_TO_TEXT g_ctSnmpMibType[];
253 extern NXC_IMAGE_LIST *g_pSrvImageList;
254 extern CImageList *g_pObjectSmallImageList;
255 extern CImageList *g_pObjectNormalImageList;
256 extern DWORD g_dwDefImgListSize;
257 extern DEF_IMG *g_pDefImgList;
258 extern DWORD g_dwNumActions;
259 extern NXC_ACTION *g_pActionList;
260 extern HANDLE g_mutexActionListAccess;
261 extern NXC_CC_LIST *g_pCCList;
262 extern CODE_TO_TEXT g_ctNodeType[];
263
264
265 //
266 // Lock/unlock access to action list
267 //
268
269 inline void LockActions(void)
270 {
271 WaitForSingleObject(g_mutexActionListAccess, INFINITE);
272 }
273
274 inline void UnlockActions(void)
275 {
276 ReleaseMutex(g_mutexActionListAccess);
277 }
278
279 #endif