blob: 9be82f3a69f8cde8a7b54778a0e31ec203a0811c [file] [log] [blame]
Constantin Kaplinsky7f8d7742006-05-11 05:29:14 +00001/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
2 *
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +00003 * 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>
Constantin Kaplinsky7f8d7742006-05-11 05:29:14 +000024#include <rfb_win32/WMPoller.h>
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +000025#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() {
Constantin Kaplinsky7f8d7742006-05-11 05:29:14 +000036 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());
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +000043 setItemChecked(IDC_POLLCONSOLES, rfb::win32::WMPoller::poll_console_windows);
Constantin Kaplinsky7f8d7742006-05-11 05:29:14 +000044 setItemChecked(IDC_CAPTUREBLT, osVersion.isPlatformNT &&
45 rfb::win32::DeviceFrameBuffer::useCaptureBlt);
46 enableItem(IDC_CAPTUREBLT, osVersion.isPlatformNT);
47 onCommand(IDC_USEHOOKS, 0);
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +000048 }
49 bool onCommand(int id, int cmd) {
50 switch (id) {
Constantin Kaplinsky7f8d7742006-05-11 05:29:14 +000051 case IDC_USEPOLLING:
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +000052 case IDC_USEHOOKS:
Constantin Kaplinsky7f8d7742006-05-11 05:29:14 +000053 case IDC_USEDRIVER:
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +000054 case IDC_POLLCONSOLES:
Constantin Kaplinsky7f8d7742006-05-11 05:29:14 +000055 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)) ||
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +000059 (rfb::win32::WMPoller::poll_console_windows != isItemChecked(IDC_POLLCONSOLES)) ||
Constantin Kaplinsky7f8d7742006-05-11 05:29:14 +000060 (rfb::win32::DeviceFrameBuffer::useCaptureBlt != isItemChecked(IDC_CAPTUREBLT)));
61 enableItem(IDC_POLLCONSOLES, isItemChecked(IDC_USEHOOKS));
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +000062 break;
63 }
64 return false;
65 }
66 bool onOk() {
Constantin Kaplinsky7f8d7742006-05-11 05:29:14 +000067 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);
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +000073 regKey.setBool(_T("PollConsoleWindows"), isItemChecked(IDC_POLLCONSOLES));
Constantin Kaplinsky7f8d7742006-05-11 05:29:14 +000074 regKey.setBool(_T("UseCaptureBlt"), isItemChecked(IDC_CAPTUREBLT));
75
76 // *** LEGACY compatibility ***
77 regKey.setBool(_T("UseHooks"), isItemChecked(IDC_USEHOOKS));
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +000078 return true;
79 }
80 protected:
81 RegKey regKey;
82 };
83
84 };
85
86};
87
Constantin Kaplinsky7f8d7742006-05-11 05:29:14 +000088#endif