blob: 9be82f3a69f8cde8a7b54778a0e31ec203a0811c [file] [log] [blame]
Constantin Kaplinsky729598c2006-05-25 05:12:25 +00001/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
2 *
3 * This is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This software is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this software; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16 * USA.
17 */
18#ifndef WINVNCCONF_HOOKING
19#define WINVNCCONF_HOOKING
20
21#include <rfb_win32/Registry.h>
22#include <rfb_win32/Dialog.h>
23#include <rfb_win32/SDisplay.h>
24#include <rfb_win32/WMPoller.h>
25#include <rfb/ServerCore.h>
26
27namespace rfb {
28
29 namespace win32 {
30
31 class HookingPage : public PropSheetPage {
32 public:
33 HookingPage(const RegKey& rk)
34 : PropSheetPage(GetModuleHandle(0), MAKEINTRESOURCE(IDD_HOOKING)), regKey(rk) {}
35 void initDialog() {
36 setItemChecked(IDC_USEPOLLING, rfb::win32::SDisplay::updateMethod == 0);
37 setItemChecked(IDC_USEHOOKS, (rfb::win32::SDisplay::updateMethod == 1) &&
38 rfb::win32::SDisplay::areHooksAvailable());
39 enableItem(IDC_USEHOOKS, rfb::win32::SDisplay::areHooksAvailable());
40 setItemChecked(IDC_USEDRIVER, (rfb::win32::SDisplay::updateMethod == 2) &&
41 rfb::win32::SDisplay::isDriverAvailable());
42 enableItem(IDC_USEDRIVER, rfb::win32::SDisplay::isDriverAvailable());
43 setItemChecked(IDC_POLLCONSOLES, rfb::win32::WMPoller::poll_console_windows);
44 setItemChecked(IDC_CAPTUREBLT, osVersion.isPlatformNT &&
45 rfb::win32::DeviceFrameBuffer::useCaptureBlt);
46 enableItem(IDC_CAPTUREBLT, osVersion.isPlatformNT);
47 onCommand(IDC_USEHOOKS, 0);
48 }
49 bool onCommand(int id, int cmd) {
50 switch (id) {
51 case IDC_USEPOLLING:
52 case IDC_USEHOOKS:
53 case IDC_USEDRIVER:
54 case IDC_POLLCONSOLES:
55 case IDC_CAPTUREBLT:
56 setChanged(((rfb::win32::SDisplay::updateMethod == 0) != isItemChecked(IDC_USEPOLLING)) ||
57 ((rfb::win32::SDisplay::updateMethod == 1) != isItemChecked(IDC_USEHOOKS)) ||
58 ((rfb::win32::SDisplay::updateMethod == 2) != isItemChecked(IDC_USEDRIVER)) ||
59 (rfb::win32::WMPoller::poll_console_windows != isItemChecked(IDC_POLLCONSOLES)) ||
60 (rfb::win32::DeviceFrameBuffer::useCaptureBlt != isItemChecked(IDC_CAPTUREBLT)));
61 enableItem(IDC_POLLCONSOLES, isItemChecked(IDC_USEHOOKS));
62 break;
63 }
64 return false;
65 }
66 bool onOk() {
67 if (isItemChecked(IDC_USEPOLLING))
68 regKey.setInt(_T("UpdateMethod"), 0);
69 if (isItemChecked(IDC_USEHOOKS))
70 regKey.setInt(_T("UpdateMethod"), 1);
71 if (isItemChecked(IDC_USEDRIVER))
72 regKey.setInt(_T("UpdateMethod"), 2);
73 regKey.setBool(_T("PollConsoleWindows"), isItemChecked(IDC_POLLCONSOLES));
74 regKey.setBool(_T("UseCaptureBlt"), isItemChecked(IDC_CAPTUREBLT));
75
76 // *** LEGACY compatibility ***
77 regKey.setBool(_T("UseHooks"), isItemChecked(IDC_USEHOOKS));
78 return true;
79 }
80 protected:
81 RegKey regKey;
82 };
83
84 };
85
86};
87
88#endif