blob: 3c8fcb48c974c5d4ebde7f6b8231cb3c501c28c0 [file] [log] [blame]
Pierre Ossmand463b572011-05-16 12:04:43 +00001/* Copyright 2011 Pierre Ossman <ossman@cendio.se> for Cendio AB
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
Peter Åstrandc359f362011-08-23 12:04:46 +000019#ifdef HAVE_CONFIG_H
20#include <config.h>
21#endif
22
Pierre Ossman61fd4862011-05-16 12:46:51 +000023#include <stdlib.h>
24
Pierre Ossmand463b572011-05-16 12:04:43 +000025#include <list>
26
Pierre Ossmand463b572011-05-16 12:04:43 +000027#include <rdr/types.h>
28#include <rfb/encodings.h>
29
30#ifdef HAVE_GNUTLS
31#include <rfb/Security.h>
32#include <rfb/SecurityClient.h>
33#include <rfb/CSecurityTLS.h>
34#endif
35
36#include "OptionsDialog.h"
37#include "fltk_layout.h"
38#include "i18n.h"
Martin Koegler498ef462011-09-04 07:04:43 +000039#include "menukey.h"
Pierre Ossmand463b572011-05-16 12:04:43 +000040#include "parameters.h"
41
DRCb65bb932011-06-24 03:17:00 +000042#include <FL/Fl_Tabs.H>
43#include <FL/Fl_Button.H>
Pierre Ossman769963f2014-01-20 14:43:52 +010044#include <FL/Fl_Check_Button.H>
DRCb65bb932011-06-24 03:17:00 +000045#include <FL/Fl_Return_Button.H>
Pierre Ossman769963f2014-01-20 14:43:52 +010046#include <FL/Fl_Round_Button.H>
47#include <FL/Fl_Int_Input.H>
48#include <FL/Fl_Choice.H>
DRCb65bb932011-06-24 03:17:00 +000049
Pierre Ossmand463b572011-05-16 12:04:43 +000050using namespace std;
51using namespace rdr;
52using namespace rfb;
53
Pierre Ossman0c41e1d2011-05-17 09:36:04 +000054std::map<OptionsCallback*, void*> OptionsDialog::callbacks;
55
Pierre Ossmand463b572011-05-16 12:04:43 +000056OptionsDialog::OptionsDialog()
57 : Fl_Window(450, 450, _("VNC Viewer: Connection Options"))
58{
59 int x, y;
60 Fl_Button *button;
61
62 Fl_Tabs *tabs = new Fl_Tabs(OUTER_MARGIN, OUTER_MARGIN,
63 w() - OUTER_MARGIN*2,
64 h() - OUTER_MARGIN*2 - INNER_MARGIN - BUTTON_HEIGHT);
65
66 {
67 int tx, ty, tw, th;
68
69 tabs->client_area(tx, ty, tw, th, TABS_HEIGHT);
70
71 createCompressionPage(tx, ty, tw, th);
72 createSecurityPage(tx, ty, tw, th);
73 createInputPage(tx, ty, tw, th);
Pierre Ossman1c2189b2012-07-05 09:23:03 +000074 createScreenPage(tx, ty, tw, th);
Pierre Ossmand463b572011-05-16 12:04:43 +000075 createMiscPage(tx, ty, tw, th);
76 }
77
78 tabs->end();
79
80 x = w() - BUTTON_WIDTH * 2 - INNER_MARGIN - OUTER_MARGIN;
81 y = h() - BUTTON_HEIGHT - OUTER_MARGIN;
82
83 button = new Fl_Button(x, y, BUTTON_WIDTH, BUTTON_HEIGHT, _("Cancel"));
84 button->callback(this->handleCancel, this);
85
86 x += BUTTON_WIDTH + INNER_MARGIN;
87
88 button = new Fl_Return_Button(x, y, BUTTON_WIDTH, BUTTON_HEIGHT, _("OK"));
89 button->callback(this->handleOK, this);
90
91 callback(this->handleCancel, this);
92
93 set_modal();
94}
95
96
97OptionsDialog::~OptionsDialog()
98{
99}
100
101
102void OptionsDialog::showDialog(void)
103{
104 static OptionsDialog *dialog = NULL;
105
106 if (!dialog)
107 dialog = new OptionsDialog();
108
109 if (dialog->shown())
110 return;
111
112 dialog->show();
113}
114
115
Pierre Ossman0c41e1d2011-05-17 09:36:04 +0000116void OptionsDialog::addCallback(OptionsCallback *cb, void *data)
117{
118 callbacks[cb] = data;
119}
120
121
122void OptionsDialog::removeCallback(OptionsCallback *cb)
123{
124 callbacks.erase(cb);
125}
126
127
Pierre Ossmand463b572011-05-16 12:04:43 +0000128void OptionsDialog::show(void)
129{
Pierre Ossman33a233b2011-09-30 12:21:58 +0000130 /* show() gets called for raise events as well */
131 if (!shown())
132 loadOptions();
Pierre Ossmand463b572011-05-16 12:04:43 +0000133
134 Fl_Window::show();
135}
136
137
138void OptionsDialog::loadOptions(void)
139{
140 /* Compression */
141 autoselectCheckbox->value(autoSelect);
142
143 int encNum = encodingNum(preferredEncoding);
144
145 switch (encNum) {
146 case encodingTight:
147 tightButton->setonly();
148 break;
149 case encodingZRLE:
150 zrleButton->setonly();
151 break;
152 case encodingHextile:
153 hextileButton->setonly();
154 break;
155 case encodingRaw:
156 rawButton->setonly();
157 break;
158 }
159
160 if (fullColour)
161 fullcolorCheckbox->setonly();
162 else {
163 switch (lowColourLevel) {
164 case 0:
Pierre Ossmancf836f22011-07-14 14:34:09 +0000165 verylowcolorCheckbox->setonly();
Pierre Ossmand463b572011-05-16 12:04:43 +0000166 break;
167 case 1:
168 lowcolorCheckbox->setonly();
169 break;
170 case 2:
Pierre Ossmancf836f22011-07-14 14:34:09 +0000171 mediumcolorCheckbox->setonly();
Pierre Ossmand463b572011-05-16 12:04:43 +0000172 break;
173 }
174 }
175
176 char digit[2] = "0";
177
178 compressionCheckbox->value(customCompressLevel);
179 jpegCheckbox->value(!noJpeg);
180 digit[0] = '0' + compressLevel;
181 compressionInput->value(digit);
182 digit[0] = '0' + qualityLevel;
183 jpegInput->value(digit);
184
185 handleAutoselect(autoselectCheckbox, this);
186 handleCompression(compressionCheckbox, this);
187 handleJpeg(jpegCheckbox, this);
188
189#ifdef HAVE_GNUTLS
190 /* Security */
191 Security security(SecurityClient::secTypes);
192
193 list<U8> secTypes;
194 list<U8>::iterator iter;
195
196 list<U32> secTypesExt;
197 list<U32>::iterator iterExt;
198
Pierre Ossmand463b572011-05-16 12:04:43 +0000199 encNoneCheckbox->value(false);
200 encTLSCheckbox->value(false);
201 encX509Checkbox->value(false);
202
203 authNoneCheckbox->value(false);
204 authVncCheckbox->value(false);
205 authPlainCheckbox->value(false);
206
207 secTypes = security.GetEnabledSecTypes();
208 for (iter = secTypes.begin(); iter != secTypes.end(); ++iter) {
209 switch (*iter) {
Pierre Ossmand463b572011-05-16 12:04:43 +0000210 case secTypeNone:
211 encNoneCheckbox->value(true);
212 authNoneCheckbox->value(true);
213 break;
214 case secTypeVncAuth:
215 encNoneCheckbox->value(true);
216 authVncCheckbox->value(true);
217 break;
218 }
219 }
220
221 secTypesExt = security.GetEnabledExtSecTypes();
222 for (iterExt = secTypesExt.begin(); iterExt != secTypesExt.end(); ++iterExt) {
223 switch (*iterExt) {
224 case secTypePlain:
225 encNoneCheckbox->value(true);
226 authPlainCheckbox->value(true);
227 break;
228 case secTypeTLSNone:
229 encTLSCheckbox->value(true);
230 authNoneCheckbox->value(true);
231 break;
232 case secTypeTLSVnc:
233 encTLSCheckbox->value(true);
234 authVncCheckbox->value(true);
235 break;
236 case secTypeTLSPlain:
237 encTLSCheckbox->value(true);
238 authPlainCheckbox->value(true);
239 break;
240 case secTypeX509None:
241 encX509Checkbox->value(true);
242 authNoneCheckbox->value(true);
243 break;
244 case secTypeX509Vnc:
245 encX509Checkbox->value(true);
246 authVncCheckbox->value(true);
247 break;
248 case secTypeX509Plain:
249 encX509Checkbox->value(true);
250 authPlainCheckbox->value(true);
251 break;
252 }
253 }
254
Pierre Ossman3d2a84b2014-09-17 16:45:35 +0200255 caInput->value(CSecurityTLS::X509CA);
256 crlInput->value(CSecurityTLS::X509CRL);
Pierre Ossmand463b572011-05-16 12:04:43 +0000257
Pierre Ossmand463b572011-05-16 12:04:43 +0000258 handleX509(encX509Checkbox, this);
259#endif
260
261 /* Input */
Pierre Ossman4e7271e2011-05-24 12:47:12 +0000262 const char *menuKeyBuf;
263
Pierre Ossmand463b572011-05-16 12:04:43 +0000264 viewOnlyCheckbox->value(viewOnly);
265 acceptClipboardCheckbox->value(acceptClipboard);
266 sendClipboardCheckbox->value(sendClipboard);
267 sendPrimaryCheckbox->value(sendPrimary);
Pierre Ossman407a5c32011-05-26 14:48:29 +0000268 systemKeysCheckbox->value(fullscreenSystemKeys);
Pierre Ossmand463b572011-05-16 12:04:43 +0000269
Pierre Ossman4e7271e2011-05-24 12:47:12 +0000270 menuKeyChoice->value(0);
271
272 menuKeyBuf = menuKey;
Martin Koegler498ef462011-09-04 07:04:43 +0000273 for (int i = 0; i < getMenuKeySymbolCount(); i++)
274 if (!strcmp(getMenuKeySymbols()[i].name, menuKeyBuf))
275 menuKeyChoice->value(i + 1);
Pierre Ossman4e7271e2011-05-24 12:47:12 +0000276
Pierre Ossman1c2189b2012-07-05 09:23:03 +0000277 /* Screen */
Pierre Ossman9ff733a2012-07-05 11:01:23 +0000278 int width, height;
279
280 if (sscanf(desktopSize.getValueStr(), "%dx%d", &width, &height) != 2) {
281 desktopSizeCheckbox->value(false);
282 desktopWidthInput->value("1024");
283 desktopHeightInput->value("768");
284 } else {
285 char buf[32];
286 desktopSizeCheckbox->value(true);
287 snprintf(buf, sizeof(buf), "%d", width);
288 desktopWidthInput->value(buf);
289 snprintf(buf, sizeof(buf), "%d", height);
290 desktopHeightInput->value(buf);
291 }
Pierre Ossman99197012012-07-05 11:06:18 +0000292 remoteResizeCheckbox->value(remoteResize);
Pierre Ossman1c2189b2012-07-05 09:23:03 +0000293 fullScreenCheckbox->value(fullScreen);
Pierre Ossmanaae38912012-07-13 11:22:55 +0000294 fullScreenAllMonitorsCheckbox->value(fullScreenAllMonitors);
Pierre Ossman1c2189b2012-07-05 09:23:03 +0000295
Pierre Ossman9ff733a2012-07-05 11:01:23 +0000296 handleDesktopSize(desktopSizeCheckbox, this);
297
Pierre Ossmand463b572011-05-16 12:04:43 +0000298 /* Misc. */
299 sharedCheckbox->value(shared);
Pierre Ossmand463b572011-05-16 12:04:43 +0000300 dotCursorCheckbox->value(dotWhenNoCursor);
301}
302
303
304void OptionsDialog::storeOptions(void)
305{
Pierre Ossman61fd4862011-05-16 12:46:51 +0000306 /* Compression */
307 autoSelect.setParam(autoselectCheckbox->value());
308
309 if (tightButton->value())
310 preferredEncoding.setParam(encodingName(encodingTight));
311 else if (zrleButton->value())
312 preferredEncoding.setParam(encodingName(encodingZRLE));
313 else if (hextileButton->value())
314 preferredEncoding.setParam(encodingName(encodingHextile));
315 else if (rawButton->value())
316 preferredEncoding.setParam(encodingName(encodingRaw));
317
318 fullColour.setParam(fullcolorCheckbox->value());
Pierre Ossmancf836f22011-07-14 14:34:09 +0000319 if (verylowcolorCheckbox->value())
Pierre Ossman61fd4862011-05-16 12:46:51 +0000320 lowColourLevel.setParam(0);
321 else if (lowcolorCheckbox->value())
322 lowColourLevel.setParam(1);
Pierre Ossmancf836f22011-07-14 14:34:09 +0000323 else if (mediumcolorCheckbox->value())
Pierre Ossman61fd4862011-05-16 12:46:51 +0000324 lowColourLevel.setParam(2);
325
326 customCompressLevel.setParam(compressionCheckbox->value());
327 noJpeg.setParam(!jpegCheckbox->value());
328 compressLevel.setParam(atoi(compressionInput->value()));
329 qualityLevel.setParam(atoi(jpegInput->value()));
330
331#ifdef HAVE_GNUTLS
332 /* Security */
333 Security security;
334
335 /* Process security types which don't use encryption */
336 if (encNoneCheckbox->value()) {
337 if (authNoneCheckbox->value())
338 security.EnableSecType(secTypeNone);
339 if (authVncCheckbox->value())
340 security.EnableSecType(secTypeVncAuth);
Pierre Ossmanc1764bd2011-09-30 12:26:25 +0000341 if (authPlainCheckbox->value())
342 security.EnableSecType(secTypePlain);
Pierre Ossman61fd4862011-05-16 12:46:51 +0000343 }
344
Pierre Ossmanc1764bd2011-09-30 12:26:25 +0000345 /* Process security types which use TLS encryption */
346 if (encTLSCheckbox->value()) {
347 if (authNoneCheckbox->value())
348 security.EnableSecType(secTypeTLSNone);
349 if (authVncCheckbox->value())
350 security.EnableSecType(secTypeTLSVnc);
351 if (authPlainCheckbox->value())
352 security.EnableSecType(secTypeTLSPlain);
353 }
Pierre Ossman61fd4862011-05-16 12:46:51 +0000354
Pierre Ossmanc1764bd2011-09-30 12:26:25 +0000355 /* Process security types which use X509 encryption */
356 if (encX509Checkbox->value()) {
357 if (authNoneCheckbox->value())
358 security.EnableSecType(secTypeX509None);
359 if (authVncCheckbox->value())
360 security.EnableSecType(secTypeX509Vnc);
361 if (authPlainCheckbox->value())
362 security.EnableSecType(secTypeX509Plain);
Pierre Ossman61fd4862011-05-16 12:46:51 +0000363 }
364
Pierre Ossman5535fe62011-09-30 12:11:52 +0000365 SecurityClient::secTypes.setParam(security.ToString());
366
Pierre Ossman3d2a84b2014-09-17 16:45:35 +0200367 CSecurityTLS::X509CA.setParam(caInput->value());
368 CSecurityTLS::X509CRL.setParam(crlInput->value());
Pierre Ossman61fd4862011-05-16 12:46:51 +0000369#endif
370
371 /* Input */
372 viewOnly.setParam(viewOnlyCheckbox->value());
373 acceptClipboard.setParam(acceptClipboardCheckbox->value());
374 sendClipboard.setParam(sendClipboardCheckbox->value());
375 sendPrimary.setParam(sendPrimaryCheckbox->value());
Pierre Ossman407a5c32011-05-26 14:48:29 +0000376 fullscreenSystemKeys.setParam(systemKeysCheckbox->value());
Pierre Ossman61fd4862011-05-16 12:46:51 +0000377
Pierre Ossman4e7271e2011-05-24 12:47:12 +0000378 if (menuKeyChoice->value() == 0)
379 menuKey.setParam("");
380 else {
Martin Koegler498ef462011-09-04 07:04:43 +0000381 menuKey.setParam(menuKeyChoice->text());
Pierre Ossman4e7271e2011-05-24 12:47:12 +0000382 }
383
Pierre Ossman1c2189b2012-07-05 09:23:03 +0000384 /* Screen */
Pierre Ossman9ff733a2012-07-05 11:01:23 +0000385 int width, height;
386
387 if (desktopSizeCheckbox->value() &&
388 (sscanf(desktopWidthInput->value(), "%d", &width) == 1) &&
389 (sscanf(desktopHeightInput->value(), "%d", &height) == 1)) {
390 char buf[64];
391 snprintf(buf, sizeof(buf), "%dx%d", width, height);
392 desktopSize.setParam(buf);
393 } else {
394 desktopSize.setParam("");
395 }
Pierre Ossman99197012012-07-05 11:06:18 +0000396 remoteResize.setParam(remoteResizeCheckbox->value());
Pierre Ossman1c2189b2012-07-05 09:23:03 +0000397 fullScreen.setParam(fullScreenCheckbox->value());
Pierre Ossmanaae38912012-07-13 11:22:55 +0000398 fullScreenAllMonitors.setParam(fullScreenAllMonitorsCheckbox->value());
Pierre Ossman1c2189b2012-07-05 09:23:03 +0000399
Pierre Ossman61fd4862011-05-16 12:46:51 +0000400 /* Misc. */
401 shared.setParam(sharedCheckbox->value());
Pierre Ossman61fd4862011-05-16 12:46:51 +0000402 dotWhenNoCursor.setParam(dotCursorCheckbox->value());
Pierre Ossman0c41e1d2011-05-17 09:36:04 +0000403
404 std::map<OptionsCallback*, void*>::const_iterator iter;
405
406 for (iter = callbacks.begin();iter != callbacks.end();++iter)
407 iter->first(iter->second);
Pierre Ossmand463b572011-05-16 12:04:43 +0000408}
409
410
411void OptionsDialog::createCompressionPage(int tx, int ty, int tw, int th)
412{
413 Fl_Group *group = new Fl_Group(tx, ty, tw, th, _("Compression"));
414
415 int orig_tx, orig_ty;
416 int half_width, full_width;
Pierre Ossmaneb955322015-03-03 16:10:53 +0100417 int height;
Pierre Ossmand463b572011-05-16 12:04:43 +0000418
419 tx += OUTER_MARGIN;
420 ty += OUTER_MARGIN;
421
422 full_width = tw - OUTER_MARGIN * 2;
423 half_width = (full_width - INNER_MARGIN) / 2;
424
425 /* AutoSelect checkbox */
426 autoselectCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
427 CHECK_MIN_WIDTH,
428 CHECK_HEIGHT,
429 _("Auto select")));
430 autoselectCheckbox->callback(handleAutoselect, this);
431 ty += CHECK_HEIGHT + INNER_MARGIN;
432
433 /* Two columns */
434 orig_tx = tx;
435 orig_ty = ty;
436
437 /* VNC encoding box */
438 ty += GROUP_LABEL_OFFSET;
439 height = GROUP_MARGIN * 2 + TIGHT_MARGIN * 3 + RADIO_HEIGHT * 4;
440 encodingGroup = new Fl_Group(tx, ty, half_width, height,
441 _("Preferred encoding"));
442 encodingGroup->box(FL_ENGRAVED_BOX);
443 encodingGroup->align(FL_ALIGN_LEFT | FL_ALIGN_TOP);
444
445 {
446 tx += GROUP_MARGIN;
447 ty += GROUP_MARGIN;
448
Pierre Ossmand463b572011-05-16 12:04:43 +0000449 tightButton = new Fl_Round_Button(LBLRIGHT(tx, ty,
450 RADIO_MIN_WIDTH,
451 RADIO_HEIGHT,
Peter Åstrand4c446002011-08-15 12:33:06 +0000452 "Tight"));
Pierre Ossmand463b572011-05-16 12:04:43 +0000453 tightButton->type(FL_RADIO_BUTTON);
454 ty += RADIO_HEIGHT + TIGHT_MARGIN;
455
456 zrleButton = new Fl_Round_Button(LBLRIGHT(tx, ty,
457 RADIO_MIN_WIDTH,
458 RADIO_HEIGHT,
Peter Åstrand4c446002011-08-15 12:33:06 +0000459 "ZRLE"));
Pierre Ossmand463b572011-05-16 12:04:43 +0000460 zrleButton->type(FL_RADIO_BUTTON);
461 ty += RADIO_HEIGHT + TIGHT_MARGIN;
462
463 hextileButton = new Fl_Round_Button(LBLRIGHT(tx, ty,
464 RADIO_MIN_WIDTH,
465 RADIO_HEIGHT,
Peter Åstrand4c446002011-08-15 12:33:06 +0000466 "Hextile"));
Pierre Ossmand463b572011-05-16 12:04:43 +0000467 hextileButton->type(FL_RADIO_BUTTON);
468 ty += RADIO_HEIGHT + TIGHT_MARGIN;
469
470 rawButton = new Fl_Round_Button(LBLRIGHT(tx, ty,
471 RADIO_MIN_WIDTH,
472 RADIO_HEIGHT,
Peter Åstrand4c446002011-08-15 12:33:06 +0000473 "Raw"));
Pierre Ossmand463b572011-05-16 12:04:43 +0000474 rawButton->type(FL_RADIO_BUTTON);
475 ty += RADIO_HEIGHT + TIGHT_MARGIN;
476 }
477
478 ty += GROUP_MARGIN - TIGHT_MARGIN;
479
480 encodingGroup->end();
481
482 /* Second column */
483 tx = orig_tx + half_width + INNER_MARGIN;
484 ty = orig_ty;
485
486 /* Color box */
487 ty += GROUP_LABEL_OFFSET;
488 height = GROUP_MARGIN * 2 + TIGHT_MARGIN * 3 + RADIO_HEIGHT * 4;
489 colorlevelGroup = new Fl_Group(tx, ty, half_width, height, _("Color level"));
490 colorlevelGroup->box(FL_ENGRAVED_BOX);
491 colorlevelGroup->align(FL_ALIGN_LEFT | FL_ALIGN_TOP);
492
493 {
494 tx += GROUP_MARGIN;
495 ty += GROUP_MARGIN;
496
Pierre Ossmand463b572011-05-16 12:04:43 +0000497 fullcolorCheckbox = new Fl_Round_Button(LBLRIGHT(tx, ty,
498 RADIO_MIN_WIDTH,
499 RADIO_HEIGHT,
500 _("Full (all available colors)")));
501 fullcolorCheckbox->type(FL_RADIO_BUTTON);
502 ty += RADIO_HEIGHT + TIGHT_MARGIN;
503
504 mediumcolorCheckbox = new Fl_Round_Button(LBLRIGHT(tx, ty,
505 RADIO_MIN_WIDTH,
506 RADIO_HEIGHT,
507 _("Medium (256 colors)")));
508 mediumcolorCheckbox->type(FL_RADIO_BUTTON);
509 ty += RADIO_HEIGHT + TIGHT_MARGIN;
510
511 lowcolorCheckbox = new Fl_Round_Button(LBLRIGHT(tx, ty,
512 RADIO_MIN_WIDTH,
513 RADIO_HEIGHT,
514 _("Low (64 colors)")));
515 lowcolorCheckbox->type(FL_RADIO_BUTTON);
516 ty += RADIO_HEIGHT + TIGHT_MARGIN;
517
518 verylowcolorCheckbox = new Fl_Round_Button(LBLRIGHT(tx, ty,
519 RADIO_MIN_WIDTH,
520 RADIO_HEIGHT,
521 _("Very low (8 colors)")));
522 verylowcolorCheckbox->type(FL_RADIO_BUTTON);
523 ty += RADIO_HEIGHT + TIGHT_MARGIN;
524 }
525
526 ty += GROUP_MARGIN - TIGHT_MARGIN;
527
528 colorlevelGroup->end();
529
530 /* Back to normal */
531 tx = orig_tx;
532 ty += INNER_MARGIN;
533
534 /* Checkboxes */
535 compressionCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
536 CHECK_MIN_WIDTH,
537 CHECK_HEIGHT,
538 _("Custom compression level:")));
539 compressionCheckbox->callback(handleCompression, this);
540 ty += CHECK_HEIGHT + TIGHT_MARGIN;
541
542 compressionInput = new Fl_Int_Input(tx + INDENT, ty,
543 INPUT_HEIGHT, INPUT_HEIGHT,
DRCba7bc512011-08-17 02:30:34 +0000544 _("level (1=fast, 6=best [4-6 are rarely useful])"));
Pierre Ossmand463b572011-05-16 12:04:43 +0000545 compressionInput->align(FL_ALIGN_RIGHT);
546 ty += INPUT_HEIGHT + INNER_MARGIN;
547
548 jpegCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
549 CHECK_MIN_WIDTH,
550 CHECK_HEIGHT,
551 _("Allow JPEG compression:")));
552 jpegCheckbox->callback(handleJpeg, this);
553 ty += CHECK_HEIGHT + TIGHT_MARGIN;
554
555 jpegInput = new Fl_Int_Input(tx + INDENT, ty,
556 INPUT_HEIGHT, INPUT_HEIGHT,
DRC41036ed2011-08-23 20:36:50 +0000557 _("quality (0=poor, 9=best)"));
Pierre Ossmand463b572011-05-16 12:04:43 +0000558 jpegInput->align(FL_ALIGN_RIGHT);
559 ty += INPUT_HEIGHT + INNER_MARGIN;
560
561 group->end();
562}
563
564
565void OptionsDialog::createSecurityPage(int tx, int ty, int tw, int th)
566{
567#ifdef HAVE_GNUTLS
568 Fl_Group *group = new Fl_Group(tx, ty, tw, th, _("Security"));
569
570 int orig_tx;
571 int width, height;
572
573 tx += OUTER_MARGIN;
574 ty += OUTER_MARGIN;
575
576 width = tw - OUTER_MARGIN * 2;
577
578 orig_tx = tx;
579
Pierre Ossmand463b572011-05-16 12:04:43 +0000580 /* Encryption */
581 ty += GROUP_LABEL_OFFSET;
582 height = GROUP_MARGIN * 2 + TIGHT_MARGIN * 4 + CHECK_HEIGHT * 3 + (INPUT_LABEL_OFFSET + INPUT_HEIGHT) * 2;
583 encryptionGroup = new Fl_Group(tx, ty, width, height, _("Encryption"));
584 encryptionGroup->box(FL_ENGRAVED_BOX);
585 encryptionGroup->align(FL_ALIGN_LEFT | FL_ALIGN_TOP);
586
587 {
588 tx += GROUP_MARGIN;
589 ty += GROUP_MARGIN;
590
591 encNoneCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
592 CHECK_MIN_WIDTH,
593 CHECK_HEIGHT,
594 _("None")));
595 ty += CHECK_HEIGHT + TIGHT_MARGIN;
596
597 encTLSCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
598 CHECK_MIN_WIDTH,
599 CHECK_HEIGHT,
600 _("TLS with anonymous certificates")));
601 ty += CHECK_HEIGHT + TIGHT_MARGIN;
602
603 encX509Checkbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
604 CHECK_MIN_WIDTH,
605 CHECK_HEIGHT,
606 _("TLS with X509 certificates")));
607 encX509Checkbox->callback(handleX509, this);
608 ty += CHECK_HEIGHT + TIGHT_MARGIN;
609
610 ty += INPUT_LABEL_OFFSET;
611 caInput = new Fl_Input(tx + INDENT, ty,
612 width - GROUP_MARGIN*2 - INDENT, INPUT_HEIGHT,
613 _("Path to X509 CA certificate"));
614 caInput->align(FL_ALIGN_LEFT | FL_ALIGN_TOP);
615 ty += INPUT_HEIGHT + TIGHT_MARGIN;
616
617 ty += INPUT_LABEL_OFFSET;
618 crlInput = new Fl_Input(tx + INDENT, ty,
619 width - GROUP_MARGIN*2 - INDENT, INPUT_HEIGHT,
620 _("Path to X509 CRL file"));
621 crlInput->align(FL_ALIGN_LEFT | FL_ALIGN_TOP);
622 ty += INPUT_HEIGHT + TIGHT_MARGIN;
623 }
624
625 ty += GROUP_MARGIN - TIGHT_MARGIN;
626
627 encryptionGroup->end();
628
629 /* Back to normal */
630 tx = orig_tx;
631 ty += INNER_MARGIN;
632
633 /* Authentication */
Pierre Ossmand463b572011-05-16 12:04:43 +0000634 ty += GROUP_LABEL_OFFSET;
635 height = GROUP_MARGIN * 2 + TIGHT_MARGIN * 2 + CHECK_HEIGHT * 3;
636 authenticationGroup = new Fl_Group(tx, ty, width, height, _("Authentication"));
637 authenticationGroup->box(FL_ENGRAVED_BOX);
638 authenticationGroup->align(FL_ALIGN_LEFT | FL_ALIGN_TOP);
639
640 {
641 tx += GROUP_MARGIN;
642 ty += GROUP_MARGIN;
643
644 authNoneCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
645 CHECK_MIN_WIDTH,
646 CHECK_HEIGHT,
647 _("None")));
648 ty += CHECK_HEIGHT + TIGHT_MARGIN;
649
650 authVncCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
651 CHECK_MIN_WIDTH,
652 CHECK_HEIGHT,
653 _("Standard VNC (insecure without encryption)")));
654 ty += CHECK_HEIGHT + TIGHT_MARGIN;
655
656 authPlainCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
657 CHECK_MIN_WIDTH,
658 CHECK_HEIGHT,
659 _("Username and password (insecure without encryption)")));
660 ty += CHECK_HEIGHT + TIGHT_MARGIN;
661 }
662
663 ty += GROUP_MARGIN - TIGHT_MARGIN;
664
665 authenticationGroup->end();
666
667 /* Back to normal */
668 tx = orig_tx;
669 ty += INNER_MARGIN;
670
671 group->end();
672#endif
673}
674
675
676void OptionsDialog::createInputPage(int tx, int ty, int tw, int th)
677{
678 Fl_Group *group = new Fl_Group(tx, ty, tw, th, _("Input"));
679
680 tx += OUTER_MARGIN;
681 ty += OUTER_MARGIN;
682
683 viewOnlyCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
684 CHECK_MIN_WIDTH,
685 CHECK_HEIGHT,
686 _("View only (ignore mouse and keyboard)")));
687 ty += CHECK_HEIGHT + TIGHT_MARGIN;
688
689 acceptClipboardCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
690 CHECK_MIN_WIDTH,
691 CHECK_HEIGHT,
692 _("Accept clipboard from server")));
693 ty += CHECK_HEIGHT + TIGHT_MARGIN;
694
695 sendClipboardCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
696 CHECK_MIN_WIDTH,
697 CHECK_HEIGHT,
698 _("Send clipboard to server")));
699 ty += CHECK_HEIGHT + TIGHT_MARGIN;
700
701 sendPrimaryCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
702 CHECK_MIN_WIDTH,
703 CHECK_HEIGHT,
704 _("Send primary selection and cut buffer as clipboard")));
705 ty += CHECK_HEIGHT + TIGHT_MARGIN;
706
Pierre Ossman407a5c32011-05-26 14:48:29 +0000707 systemKeysCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
708 CHECK_MIN_WIDTH,
709 CHECK_HEIGHT,
710 _("Pass system keys directly to server (full screen)")));
711 ty += CHECK_HEIGHT + TIGHT_MARGIN;
712
Pierre Ossman4e7271e2011-05-24 12:47:12 +0000713 menuKeyChoice = new Fl_Choice(LBLLEFT(tx, ty, 150, CHOICE_HEIGHT, _("Menu key")));
714
Pierre Ossman245c8022015-02-25 11:27:49 +0100715 fltk_menu_add(menuKeyChoice, _("None"), 0, NULL, (void*)0, FL_MENU_DIVIDER);
Martin Koegler498ef462011-09-04 07:04:43 +0000716 for (int i = 0; i < getMenuKeySymbolCount(); i++)
Pierre Ossman245c8022015-02-25 11:27:49 +0100717 fltk_menu_add(menuKeyChoice, getMenuKeySymbols()[i].name, 0, NULL, 0, 0);
Pierre Ossman4e7271e2011-05-24 12:47:12 +0000718
719 ty += CHOICE_HEIGHT + TIGHT_MARGIN;
720
Pierre Ossmand463b572011-05-16 12:04:43 +0000721 group->end();
722}
723
724
Pierre Ossman1c2189b2012-07-05 09:23:03 +0000725void OptionsDialog::createScreenPage(int tx, int ty, int tw, int th)
726{
Pierre Ossman9ff733a2012-07-05 11:01:23 +0000727 int x;
728
Pierre Ossman1c2189b2012-07-05 09:23:03 +0000729 Fl_Group *group = new Fl_Group(tx, ty, tw, th, _("Screen"));
730
731 tx += OUTER_MARGIN;
732 ty += OUTER_MARGIN;
733
Pierre Ossman9ff733a2012-07-05 11:01:23 +0000734 desktopSizeCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
735 CHECK_MIN_WIDTH,
736 CHECK_HEIGHT,
737 _("Resize remote session on connect")));
738 desktopSizeCheckbox->callback(handleDesktopSize, this);
739 ty += CHECK_HEIGHT + TIGHT_MARGIN;
740
741 desktopWidthInput = new Fl_Int_Input(tx + INDENT, ty, 50, INPUT_HEIGHT);
742 x = desktopWidthInput->x() + desktopWidthInput->w() + \
743 gui_str_len("x") + 3 * 2;
744 desktopHeightInput = new Fl_Int_Input(x, ty, 50, INPUT_HEIGHT, "x");
745 ty += INPUT_HEIGHT + TIGHT_MARGIN;
746
Pierre Ossman99197012012-07-05 11:06:18 +0000747 remoteResizeCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
748 CHECK_MIN_WIDTH,
749 CHECK_HEIGHT,
750 _("Resize remote session to the local window")));
751 ty += CHECK_HEIGHT + TIGHT_MARGIN;
752
Pierre Ossman1c2189b2012-07-05 09:23:03 +0000753 fullScreenCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
754 CHECK_MIN_WIDTH,
755 CHECK_HEIGHT,
756 _("Full-screen mode")));
757 ty += CHECK_HEIGHT + TIGHT_MARGIN;
758
Pierre Ossmanaae38912012-07-13 11:22:55 +0000759 fullScreenAllMonitorsCheckbox = new Fl_Check_Button(LBLRIGHT(tx + INDENT, ty,
760 CHECK_MIN_WIDTH,
761 CHECK_HEIGHT,
762 _("Enable full-screen mode over all monitors")));
763 ty += CHECK_HEIGHT + TIGHT_MARGIN;
764
Pierre Ossman1c2189b2012-07-05 09:23:03 +0000765 group->end();
766}
767
768
Pierre Ossmand463b572011-05-16 12:04:43 +0000769void OptionsDialog::createMiscPage(int tx, int ty, int tw, int th)
770{
771 Fl_Group *group = new Fl_Group(tx, ty, tw, th, _("Misc."));
772
773 tx += OUTER_MARGIN;
774 ty += OUTER_MARGIN;
775
776 sharedCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
777 CHECK_MIN_WIDTH,
778 CHECK_HEIGHT,
779 _("Shared (don't disconnect other viewers)")));
780 ty += CHECK_HEIGHT + TIGHT_MARGIN;
781
Pierre Ossmand463b572011-05-16 12:04:43 +0000782 dotCursorCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
783 CHECK_MIN_WIDTH,
784 CHECK_HEIGHT,
785 _("Show dot when no cursor")));
786 ty += CHECK_HEIGHT + TIGHT_MARGIN;
787
788 group->end();
789}
790
791
792void OptionsDialog::handleAutoselect(Fl_Widget *widget, void *data)
793{
794 OptionsDialog *dialog = (OptionsDialog*)data;
795
796 if (dialog->autoselectCheckbox->value()) {
797 dialog->encodingGroup->deactivate();
798 dialog->colorlevelGroup->deactivate();
799 } else {
800 dialog->encodingGroup->activate();
801 dialog->colorlevelGroup->activate();
802 }
803
804 // JPEG setting is also affected by autoselection
805 dialog->handleJpeg(dialog->jpegCheckbox, dialog);
806}
807
808
809void OptionsDialog::handleCompression(Fl_Widget *widget, void *data)
810{
811 OptionsDialog *dialog = (OptionsDialog*)data;
812
813 if (dialog->compressionCheckbox->value())
814 dialog->compressionInput->activate();
815 else
816 dialog->compressionInput->deactivate();
817}
818
819
820void OptionsDialog::handleJpeg(Fl_Widget *widget, void *data)
821{
822 OptionsDialog *dialog = (OptionsDialog*)data;
823
824 if (dialog->jpegCheckbox->value() &&
825 !dialog->autoselectCheckbox->value())
826 dialog->jpegInput->activate();
827 else
828 dialog->jpegInput->deactivate();
829}
830
831
Pierre Ossmand463b572011-05-16 12:04:43 +0000832void OptionsDialog::handleX509(Fl_Widget *widget, void *data)
833{
834 OptionsDialog *dialog = (OptionsDialog*)data;
835
836 if (dialog->encX509Checkbox->value()) {
837 dialog->caInput->activate();
838 dialog->crlInput->activate();
839 } else {
840 dialog->caInput->deactivate();
841 dialog->crlInput->deactivate();
842 }
843}
844
845
Pierre Ossman9ff733a2012-07-05 11:01:23 +0000846void OptionsDialog::handleDesktopSize(Fl_Widget *widget, void *data)
847{
848 OptionsDialog *dialog = (OptionsDialog*)data;
849
850 if (dialog->desktopSizeCheckbox->value()) {
851 dialog->desktopWidthInput->activate();
852 dialog->desktopHeightInput->activate();
853 } else {
854 dialog->desktopWidthInput->deactivate();
855 dialog->desktopHeightInput->deactivate();
856 }
857}
858
Pierre Ossmand463b572011-05-16 12:04:43 +0000859void OptionsDialog::handleCancel(Fl_Widget *widget, void *data)
860{
861 OptionsDialog *dialog = (OptionsDialog*)data;
862
863 dialog->hide();
864}
865
866
867void OptionsDialog::handleOK(Fl_Widget *widget, void *data)
868{
869 OptionsDialog *dialog = (OptionsDialog*)data;
870
871 dialog->hide();
872
873 dialog->storeOptions();
874}