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