blob: b7603f3778447c21cd659cadf376f8d4bbf18e26 [file] [log] [blame]
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +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//
19// OptionsDialog.h
20//
21
22#ifndef __OPTIONSDIALOG_H__
23#define __OPTIONSDIALOG_H__
24
25#include "TXDialog.h"
26#include "TXLabel.h"
27#include "TXEntry.h"
28#include "TXButton.h"
29#include "TXCheckbox.h"
30#include "parameters.h"
31
Adam Tkace3cb0c32010-09-15 14:12:38 +000032#define SECOND_COL_XPAD 350
33
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +000034class OptionsDialogCallback {
35public:
36 virtual void setOptions() = 0;
37 virtual void getOptions() = 0;
38};
39
40class OptionsDialog : public TXDialog, public TXButtonCallback,
41 public TXCheckboxCallback, public TXEntryCallback {
42public:
43 OptionsDialog(Display* dpy, OptionsDialogCallback* cb_)
Pierre Ossmanfa4b3ac2010-09-30 09:06:51 +000044 : TXDialog(dpy, 450, 450, _("VNC Viewer: Connection Options")), cb(cb_),
Adam Tkace3cb0c32010-09-15 14:12:38 +000045
46 /* Encoding and color level */
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +000047 formatAndEnc(dpy, _("Encoding and Color Level:"), this),
48 inputs(dpy, _("Inputs:"), this),
49 misc(dpy, _("Misc:"), this),
50 autoSelect(dpy, _("Auto select"), this, false, this),
51 fullColour(dpy, _("Full (all available colors)"), this, true, this),
52 mediumColour(dpy, _("Medium (256 colors)"), this, true, this),
53 lowColour(dpy, _("Low (64 colors)"), this, true, this),
54 veryLowColour(dpy, _("Very low (8 colors)"), this, true, this),
55 tight(dpy, "Tight", this, true, this),
56 zrle(dpy, "ZRLE", this, true, this),
57 hextile(dpy, "Hextile", this, true, this),
58 raw(dpy, "Raw", this, true, this),
Adam Tkace3cb0c32010-09-15 14:12:38 +000059
60 /* Compression */
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +000061 customCompressLevel(dpy, _("Custom compression level:"), this, false, this),
62 compressLevel(dpy, this, this, false, 30),
63 compressLevelLabel(dpy, _("level (1=fast, 9=best)"), this),
64 noJpeg(dpy, _("Allow JPEG compression:"), this, false, this),
65 qualityLevel(dpy, this, this, false, 30),
66 qualityLevelLabel(dpy, _("quality (1=poor, 9=best)"), this),
Adam Tkace3cb0c32010-09-15 14:12:38 +000067
68 /* Inputs */
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +000069 viewOnly(dpy, _("View only (ignore mouse & keyboard)"), this, false, this),
70 acceptClipboard(dpy, _("Accept clipboard from server"), this, false, this),
71 sendClipboard(dpy, _("Send clipboard to server"), this, false, this),
72 sendPrimary(dpy, _("Send primary selection & cut buffer as clipboard"),
73 this, false, this),
Adam Tkace3cb0c32010-09-15 14:12:38 +000074
75 /* Misc */
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +000076 shared(dpy, _("Shared (don't disconnect other viewers)"), this, false,this),
77 fullScreen(dpy, _("Full-screen mode"), this, false, this),
78 useLocalCursor(dpy, _("Render cursor locally"), this, false, this),
79 dotWhenNoCursor(dpy, _("Show dot when no cursor"), this, false, this),
80 okButton(dpy, _("OK"), this, this, 60),
Pierre Ossmanfa4b3ac2010-09-30 09:06:51 +000081 cancelButton(dpy, _("Cancel"), this, this, 60)
Adam Tkace3cb0c32010-09-15 14:12:38 +000082
Pierre Ossmanfa4b3ac2010-09-30 09:06:51 +000083#ifdef HAVE_GNUTLS
84 ,
Adam Tkace3cb0c32010-09-15 14:12:38 +000085 /* Security */
86 security(dpy, _("Security:"), this),
87 secVeNCrypt(dpy, _("Extended encryption and authentication methods (VeNCrypt)"),
88 this, false, this),
89
90 /* Encryption */
91 encryption(dpy, _("Session encryption:"), this),
92 encNone(dpy, _("None"), this, false, this),
93 encTLS(dpy, _("TLS with anonymous certificates"), this, false, this),
94 encX509(dpy, _("TLS with X509 certificates"), this, false, this),
95 cacert(dpy, _("Path to X509 CA certificate"), this),
96 ca(dpy, this, this, false, 350),
97 crlcert(dpy, _("Path to X509 CRL file"), this),
98 crl(dpy, this, this, false, 350),
99
100 /* Authentication */
101 authentication(dpy, _("Authentication:"), this),
102 secNone(dpy, _("None"), this, false, this),
103 secVnc(dpy, _("Standard VNC (insecure without encryption)"),
104 this, false, this),
105 secPlain(dpy, _("Username and password (insecure without encryption)"),
106 this, false, this)
Pierre Ossmanfa4b3ac2010-09-30 09:06:51 +0000107#endif
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +0000108 {
Adam Tkace3cb0c32010-09-15 14:12:38 +0000109 /* Render the first collumn */
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +0000110 int y = yPad;
111 formatAndEnc.move(xPad, y);
112 y += formatAndEnc.height();
113 autoSelect.move(xPad, y);
114 int x2 = xPad + autoSelect.width() + xPad*5;
115 y += autoSelect.height();
116 tight.move(xPad, y);
117 fullColour.move(x2, y);
118 y += tight.height();
119 zrle.move(xPad, y);
120 mediumColour.move(x2, y);
121 y += zrle.height();
122 hextile.move(xPad, y);
123 lowColour.move(x2, y);
124 y += hextile.height();
125 raw.move(xPad, y);
126 veryLowColour.move(x2, y);
127 y += raw.height() + yPad*2;
128
129 customCompressLevel.move(xPad, y);
130 y += customCompressLevel.height();
131 compressLevel.move(xPad*10, y);
132 compressLevelLabel.move(xPad*20, y);
133 y += compressLevel.height();
134
135 noJpeg.move(xPad, y);
136 y += noJpeg.height();
137 qualityLevel.move(xPad*10, y);
138 qualityLevelLabel.move(xPad*20, y);
139 y += qualityLevel.height();
140
141 y += yPad*4;
142 inputs.move(xPad, y);
143 y += inputs.height();
144 viewOnly.move(xPad, y);
145 y += viewOnly.height();
146 acceptClipboard.move(xPad, y);
147 y += acceptClipboard.height();
148 sendClipboard.move(xPad, y);
149 y += sendClipboard.height();
150 sendPrimary.move(xPad, y);
151 y += sendPrimary.height();
152
153 y += yPad*4;
154 misc.move(xPad, y);
155 y += misc.height();
156 shared.move(xPad, y);
157 y += shared.height();
158 fullScreen.move(xPad, y);
159 y += fullScreen.height();
160 useLocalCursor.move(xPad, y);
161 y += useLocalCursor.height();
162 dotWhenNoCursor.move(xPad, y);
163 y += dotWhenNoCursor.height();
164
Pierre Ossmanfa4b3ac2010-09-30 09:06:51 +0000165#ifdef HAVE_GNUTLS
Adam Tkace3cb0c32010-09-15 14:12:38 +0000166 /* Render the second collumn */
167 y = yPad;
168 xPad += SECOND_COL_XPAD;
Pierre Ossmanfa4b3ac2010-09-30 09:06:51 +0000169 resize(750, height());
Adam Tkace3cb0c32010-09-15 14:12:38 +0000170
171 security.move(xPad, y);
172 y += security.height();
173 secVeNCrypt.move(xPad, y);
174 y += secVeNCrypt.height();
175
176 encryption.move(xPad, y);
177 y += encryption.height();
178 encNone.move(xPad, y);
179 y += encNone.height();
180 encTLS.move(xPad, y);
181 y += encTLS.height();
182 encX509.move(xPad, y);
183 y += encX509.height();
184 cacert.move(xPad, y);
185 y += cacert.height();
186 ca.move(xPad, y);
187 y += ca.height();
188 crlcert.move(xPad, y);
189 y += crlcert.height();
190 crl.move(xPad, y);
191 y += crl.height();
192
193 authentication.move(xPad, y);
194 y += authentication.height();
195 secNone.move(xPad, y);
196 y += secNone.height();
197 secVnc.move(xPad, y);
198 y += secVnc.height();
199 secPlain.move(xPad, y);
200 y += secPlain.height();
Pierre Ossmanfa4b3ac2010-09-30 09:06:51 +0000201#endif
202
203 /* Render "OK" and "Cancel" buttons */
204 okButton.move(width() - xPad*12 - cancelButton.width() - okButton.width(),
205 height() - yPad*4 - okButton.height());
206 cancelButton.move(width() - xPad*6 - cancelButton.width(),
207 height() - yPad*4 - cancelButton.height());
Adam Tkace3cb0c32010-09-15 14:12:38 +0000208
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +0000209 setBorderWidth(1);
210 }
211
212 virtual void initDialog() {
213 if (cb) cb->setOptions();
214 tight.disabled(autoSelect.checked());
215 zrle.disabled(autoSelect.checked());
216 hextile.disabled(autoSelect.checked());
217 raw.disabled(autoSelect.checked());
218 fullColour.disabled(autoSelect.checked());
219 mediumColour.disabled(autoSelect.checked());
220 lowColour.disabled(autoSelect.checked());
221 veryLowColour.disabled(autoSelect.checked());
222 sendPrimary.disabled(!sendClipboard.checked());
223 dotWhenNoCursor.disabled(!useLocalCursor.checked());
224 compressLevel.disabled(!customCompressLevel.checked());
Pierre Ossman78b23592009-03-12 12:25:11 +0000225 qualityLevel.disabled(autoSelect.checked() || !noJpeg.checked());
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +0000226 }
227
228 virtual void takeFocus(Time time) {
229 //XSetInputFocus(dpy, entry.win, RevertToParent, time);
230 }
231
232 virtual void buttonActivate(TXButton* b) {
233 if (b == &okButton) {
234 if (cb) cb->getOptions();
235 unmap();
236 } else if (b == &cancelButton) {
237 unmap();
238 }
239 }
240
241 virtual void checkboxSelect(TXCheckbox* checkbox) {
242 if (checkbox == &autoSelect) {
243 tight.disabled(autoSelect.checked());
244 zrle.disabled(autoSelect.checked());
245 hextile.disabled(autoSelect.checked());
246 raw.disabled(autoSelect.checked());
247 fullColour.disabled(autoSelect.checked());
248 mediumColour.disabled(autoSelect.checked());
249 lowColour.disabled(autoSelect.checked());
250 veryLowColour.disabled(autoSelect.checked());
Pierre Ossman78b23592009-03-12 12:25:11 +0000251 qualityLevel.disabled(autoSelect.checked() || !noJpeg.checked());
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +0000252 } else if (checkbox == &fullColour || checkbox == &mediumColour ||
253 checkbox == &lowColour || checkbox == &veryLowColour) {
254 fullColour.checked(checkbox == &fullColour);
255 mediumColour.checked(checkbox == &mediumColour);
256 lowColour.checked(checkbox == &lowColour);
257 veryLowColour.checked(checkbox == &veryLowColour);
258 } else if (checkbox == &tight || checkbox == &zrle || checkbox == &hextile || checkbox == &raw) {
259 tight.checked(checkbox == &tight);
260 zrle.checked(checkbox == &zrle);
261 hextile.checked(checkbox == &hextile);
262 raw.checked(checkbox == &raw);
263 } else if (checkbox == &sendClipboard) {
264 sendPrimary.disabled(!sendClipboard.checked());
265 } else if (checkbox == &useLocalCursor) {
266 dotWhenNoCursor.disabled(!useLocalCursor.checked());
267 } else if (checkbox == &customCompressLevel) {
268 compressLevel.disabled(!customCompressLevel.checked());
269 } else if (checkbox == &noJpeg) {
Pierre Ossman78b23592009-03-12 12:25:11 +0000270 qualityLevel.disabled(autoSelect.checked() || !noJpeg.checked());
Pierre Ossmanfa4b3ac2010-09-30 09:06:51 +0000271#ifdef HAVE_GNUTLS
Adam Tkacb7bafc52010-09-15 14:13:17 +0000272 } else if (checkbox == &secVeNCrypt) {
273 encTLS.checked(false);
274 encTLS.disabled(!secVeNCrypt.checked());
275 encX509.checked(false);
276 encX509.disabled(!secVeNCrypt.checked());
277 secPlain.checked(false);
278 secPlain.disabled(!secVeNCrypt.checked());
Pierre Ossmanfa4b3ac2010-09-30 09:06:51 +0000279#endif
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +0000280 }
281 }
282
283 virtual void entryCallback(TXEntry* e, Detail detail, Time time) {
284 }
285
286 OptionsDialogCallback* cb;
287 TXLabel formatAndEnc, inputs, misc;
288 TXCheckbox autoSelect;
289 TXCheckbox fullColour, mediumColour, lowColour, veryLowColour;
290 TXCheckbox tight, zrle, hextile, raw;
291
292 TXCheckbox customCompressLevel; TXEntry compressLevel; TXLabel compressLevelLabel;
293 TXCheckbox noJpeg; TXEntry qualityLevel; TXLabel qualityLevelLabel;
294
295 TXCheckbox viewOnly, acceptClipboard, sendClipboard, sendPrimary;
296 TXCheckbox shared, fullScreen, useLocalCursor, dotWhenNoCursor;
297 TXButton okButton, cancelButton;
Adam Tkace3cb0c32010-09-15 14:12:38 +0000298
Pierre Ossmanfa4b3ac2010-09-30 09:06:51 +0000299#ifdef HAVE_GNUTLS
Adam Tkace3cb0c32010-09-15 14:12:38 +0000300 TXLabel security;
301 TXCheckbox secVeNCrypt;
302
303 TXLabel encryption;
304 TXCheckbox encNone, encTLS, encX509;
305 TXLabel cacert; TXEntry ca; TXLabel crlcert; TXEntry crl;
306
307 TXLabel authentication;
308 TXCheckbox secNone, secVnc, secPlain;
Pierre Ossmanfa4b3ac2010-09-30 09:06:51 +0000309#endif
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +0000310};
311
312#endif