blob: 58f2fd7ee9f68972fd0e374cedbcf7a7b9264379 [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>
44#include <FL/Fl_Return_Button.H>
45
Pierre Ossmand463b572011-05-16 12:04:43 +000046using namespace std;
47using namespace rdr;
48using namespace rfb;
49
Pierre Ossman0c41e1d2011-05-17 09:36:04 +000050std::map<OptionsCallback*, void*> OptionsDialog::callbacks;
51
Pierre Ossmand463b572011-05-16 12:04:43 +000052OptionsDialog::OptionsDialog()
53 : Fl_Window(450, 450, _("VNC Viewer: Connection Options"))
54{
55 int x, y;
56 Fl_Button *button;
57
58 Fl_Tabs *tabs = new Fl_Tabs(OUTER_MARGIN, OUTER_MARGIN,
59 w() - OUTER_MARGIN*2,
60 h() - OUTER_MARGIN*2 - INNER_MARGIN - BUTTON_HEIGHT);
61
62 {
63 int tx, ty, tw, th;
64
65 tabs->client_area(tx, ty, tw, th, TABS_HEIGHT);
66
67 createCompressionPage(tx, ty, tw, th);
68 createSecurityPage(tx, ty, tw, th);
69 createInputPage(tx, ty, tw, th);
Pierre Ossman1c2189b2012-07-05 09:23:03 +000070 createScreenPage(tx, ty, tw, th);
Pierre Ossmand463b572011-05-16 12:04:43 +000071 createMiscPage(tx, ty, tw, th);
72 }
73
74 tabs->end();
75
76 x = w() - BUTTON_WIDTH * 2 - INNER_MARGIN - OUTER_MARGIN;
77 y = h() - BUTTON_HEIGHT - OUTER_MARGIN;
78
79 button = new Fl_Button(x, y, BUTTON_WIDTH, BUTTON_HEIGHT, _("Cancel"));
80 button->callback(this->handleCancel, this);
81
82 x += BUTTON_WIDTH + INNER_MARGIN;
83
84 button = new Fl_Return_Button(x, y, BUTTON_WIDTH, BUTTON_HEIGHT, _("OK"));
85 button->callback(this->handleOK, this);
86
87 callback(this->handleCancel, this);
88
89 set_modal();
90}
91
92
93OptionsDialog::~OptionsDialog()
94{
95}
96
97
98void OptionsDialog::showDialog(void)
99{
100 static OptionsDialog *dialog = NULL;
101
102 if (!dialog)
103 dialog = new OptionsDialog();
104
105 if (dialog->shown())
106 return;
107
108 dialog->show();
109}
110
111
Pierre Ossman0c41e1d2011-05-17 09:36:04 +0000112void OptionsDialog::addCallback(OptionsCallback *cb, void *data)
113{
114 callbacks[cb] = data;
115}
116
117
118void OptionsDialog::removeCallback(OptionsCallback *cb)
119{
120 callbacks.erase(cb);
121}
122
123
Pierre Ossmand463b572011-05-16 12:04:43 +0000124void OptionsDialog::show(void)
125{
Pierre Ossman33a233b2011-09-30 12:21:58 +0000126 /* show() gets called for raise events as well */
127 if (!shown())
128 loadOptions();
Pierre Ossmand463b572011-05-16 12:04:43 +0000129
130 Fl_Window::show();
131}
132
133
134void OptionsDialog::loadOptions(void)
135{
136 /* Compression */
137 autoselectCheckbox->value(autoSelect);
138
139 int encNum = encodingNum(preferredEncoding);
140
141 switch (encNum) {
142 case encodingTight:
143 tightButton->setonly();
144 break;
145 case encodingZRLE:
146 zrleButton->setonly();
147 break;
148 case encodingHextile:
149 hextileButton->setonly();
150 break;
151 case encodingRaw:
152 rawButton->setonly();
153 break;
154 }
155
156 if (fullColour)
157 fullcolorCheckbox->setonly();
158 else {
159 switch (lowColourLevel) {
160 case 0:
Pierre Ossmancf836f22011-07-14 14:34:09 +0000161 verylowcolorCheckbox->setonly();
Pierre Ossmand463b572011-05-16 12:04:43 +0000162 break;
163 case 1:
164 lowcolorCheckbox->setonly();
165 break;
166 case 2:
Pierre Ossmancf836f22011-07-14 14:34:09 +0000167 mediumcolorCheckbox->setonly();
Pierre Ossmand463b572011-05-16 12:04:43 +0000168 break;
169 }
170 }
171
172 char digit[2] = "0";
173
174 compressionCheckbox->value(customCompressLevel);
175 jpegCheckbox->value(!noJpeg);
176 digit[0] = '0' + compressLevel;
177 compressionInput->value(digit);
178 digit[0] = '0' + qualityLevel;
179 jpegInput->value(digit);
180
181 handleAutoselect(autoselectCheckbox, this);
182 handleCompression(compressionCheckbox, this);
183 handleJpeg(jpegCheckbox, this);
184
185#ifdef HAVE_GNUTLS
186 /* Security */
187 Security security(SecurityClient::secTypes);
188
189 list<U8> secTypes;
190 list<U8>::iterator iter;
191
192 list<U32> secTypesExt;
193 list<U32>::iterator iterExt;
194
Pierre Ossmand463b572011-05-16 12:04:43 +0000195 encNoneCheckbox->value(false);
196 encTLSCheckbox->value(false);
197 encX509Checkbox->value(false);
198
199 authNoneCheckbox->value(false);
200 authVncCheckbox->value(false);
201 authPlainCheckbox->value(false);
202
203 secTypes = security.GetEnabledSecTypes();
204 for (iter = secTypes.begin(); iter != secTypes.end(); ++iter) {
205 switch (*iter) {
Pierre Ossmand463b572011-05-16 12:04:43 +0000206 case secTypeNone:
207 encNoneCheckbox->value(true);
208 authNoneCheckbox->value(true);
209 break;
210 case secTypeVncAuth:
211 encNoneCheckbox->value(true);
212 authVncCheckbox->value(true);
213 break;
214 }
215 }
216
217 secTypesExt = security.GetEnabledExtSecTypes();
218 for (iterExt = secTypesExt.begin(); iterExt != secTypesExt.end(); ++iterExt) {
219 switch (*iterExt) {
220 case secTypePlain:
221 encNoneCheckbox->value(true);
222 authPlainCheckbox->value(true);
223 break;
224 case secTypeTLSNone:
225 encTLSCheckbox->value(true);
226 authNoneCheckbox->value(true);
227 break;
228 case secTypeTLSVnc:
229 encTLSCheckbox->value(true);
230 authVncCheckbox->value(true);
231 break;
232 case secTypeTLSPlain:
233 encTLSCheckbox->value(true);
234 authPlainCheckbox->value(true);
235 break;
236 case secTypeX509None:
237 encX509Checkbox->value(true);
238 authNoneCheckbox->value(true);
239 break;
240 case secTypeX509Vnc:
241 encX509Checkbox->value(true);
242 authVncCheckbox->value(true);
243 break;
244 case secTypeX509Plain:
245 encX509Checkbox->value(true);
246 authPlainCheckbox->value(true);
247 break;
248 }
249 }
250
251 caInput->value(CSecurityTLS::x509ca);
252 crlInput->value(CSecurityTLS::x509crl);
253
Pierre Ossmand463b572011-05-16 12:04:43 +0000254 handleX509(encX509Checkbox, this);
255#endif
256
257 /* Input */
Pierre Ossman4e7271e2011-05-24 12:47:12 +0000258 const char *menuKeyBuf;
259
Pierre Ossmand463b572011-05-16 12:04:43 +0000260 viewOnlyCheckbox->value(viewOnly);
261 acceptClipboardCheckbox->value(acceptClipboard);
262 sendClipboardCheckbox->value(sendClipboard);
263 sendPrimaryCheckbox->value(sendPrimary);
Pierre Ossman407a5c32011-05-26 14:48:29 +0000264 systemKeysCheckbox->value(fullscreenSystemKeys);
Pierre Ossmand463b572011-05-16 12:04:43 +0000265
Pierre Ossman4e7271e2011-05-24 12:47:12 +0000266 menuKeyChoice->value(0);
267
268 menuKeyBuf = menuKey;
Martin Koegler498ef462011-09-04 07:04:43 +0000269 for (int i = 0; i < getMenuKeySymbolCount(); i++)
270 if (!strcmp(getMenuKeySymbols()[i].name, menuKeyBuf))
271 menuKeyChoice->value(i + 1);
Pierre Ossman4e7271e2011-05-24 12:47:12 +0000272
Pierre Ossman1c2189b2012-07-05 09:23:03 +0000273 /* Screen */
274 fullScreenCheckbox->value(fullScreen);
275
Pierre Ossmand463b572011-05-16 12:04:43 +0000276 /* Misc. */
277 sharedCheckbox->value(shared);
Pierre Ossmand463b572011-05-16 12:04:43 +0000278 dotCursorCheckbox->value(dotWhenNoCursor);
279}
280
281
282void OptionsDialog::storeOptions(void)
283{
Pierre Ossman61fd4862011-05-16 12:46:51 +0000284 /* Compression */
285 autoSelect.setParam(autoselectCheckbox->value());
286
287 if (tightButton->value())
288 preferredEncoding.setParam(encodingName(encodingTight));
289 else if (zrleButton->value())
290 preferredEncoding.setParam(encodingName(encodingZRLE));
291 else if (hextileButton->value())
292 preferredEncoding.setParam(encodingName(encodingHextile));
293 else if (rawButton->value())
294 preferredEncoding.setParam(encodingName(encodingRaw));
295
296 fullColour.setParam(fullcolorCheckbox->value());
Pierre Ossmancf836f22011-07-14 14:34:09 +0000297 if (verylowcolorCheckbox->value())
Pierre Ossman61fd4862011-05-16 12:46:51 +0000298 lowColourLevel.setParam(0);
299 else if (lowcolorCheckbox->value())
300 lowColourLevel.setParam(1);
Pierre Ossmancf836f22011-07-14 14:34:09 +0000301 else if (mediumcolorCheckbox->value())
Pierre Ossman61fd4862011-05-16 12:46:51 +0000302 lowColourLevel.setParam(2);
303
304 customCompressLevel.setParam(compressionCheckbox->value());
305 noJpeg.setParam(!jpegCheckbox->value());
306 compressLevel.setParam(atoi(compressionInput->value()));
307 qualityLevel.setParam(atoi(jpegInput->value()));
308
309#ifdef HAVE_GNUTLS
310 /* Security */
311 Security security;
312
313 /* Process security types which don't use encryption */
314 if (encNoneCheckbox->value()) {
315 if (authNoneCheckbox->value())
316 security.EnableSecType(secTypeNone);
317 if (authVncCheckbox->value())
318 security.EnableSecType(secTypeVncAuth);
Pierre Ossmanc1764bd2011-09-30 12:26:25 +0000319 if (authPlainCheckbox->value())
320 security.EnableSecType(secTypePlain);
Pierre Ossman61fd4862011-05-16 12:46:51 +0000321 }
322
Pierre Ossmanc1764bd2011-09-30 12:26:25 +0000323 /* Process security types which use TLS encryption */
324 if (encTLSCheckbox->value()) {
325 if (authNoneCheckbox->value())
326 security.EnableSecType(secTypeTLSNone);
327 if (authVncCheckbox->value())
328 security.EnableSecType(secTypeTLSVnc);
329 if (authPlainCheckbox->value())
330 security.EnableSecType(secTypeTLSPlain);
331 }
Pierre Ossman61fd4862011-05-16 12:46:51 +0000332
Pierre Ossmanc1764bd2011-09-30 12:26:25 +0000333 /* Process security types which use X509 encryption */
334 if (encX509Checkbox->value()) {
335 if (authNoneCheckbox->value())
336 security.EnableSecType(secTypeX509None);
337 if (authVncCheckbox->value())
338 security.EnableSecType(secTypeX509Vnc);
339 if (authPlainCheckbox->value())
340 security.EnableSecType(secTypeX509Plain);
Pierre Ossman61fd4862011-05-16 12:46:51 +0000341 }
342
Pierre Ossman5535fe62011-09-30 12:11:52 +0000343 SecurityClient::secTypes.setParam(security.ToString());
344
Pierre Ossman61fd4862011-05-16 12:46:51 +0000345 CSecurityTLS::x509ca.setParam(caInput->value());
346 CSecurityTLS::x509crl.setParam(crlInput->value());
347#endif
348
349 /* Input */
350 viewOnly.setParam(viewOnlyCheckbox->value());
351 acceptClipboard.setParam(acceptClipboardCheckbox->value());
352 sendClipboard.setParam(sendClipboardCheckbox->value());
353 sendPrimary.setParam(sendPrimaryCheckbox->value());
Pierre Ossman407a5c32011-05-26 14:48:29 +0000354 fullscreenSystemKeys.setParam(systemKeysCheckbox->value());
Pierre Ossman61fd4862011-05-16 12:46:51 +0000355
Pierre Ossman4e7271e2011-05-24 12:47:12 +0000356 if (menuKeyChoice->value() == 0)
357 menuKey.setParam("");
358 else {
Martin Koegler498ef462011-09-04 07:04:43 +0000359 menuKey.setParam(menuKeyChoice->text());
Pierre Ossman4e7271e2011-05-24 12:47:12 +0000360 }
361
Pierre Ossman1c2189b2012-07-05 09:23:03 +0000362 /* Screen */
363 fullScreen.setParam(fullScreenCheckbox->value());
364
Pierre Ossman61fd4862011-05-16 12:46:51 +0000365 /* Misc. */
366 shared.setParam(sharedCheckbox->value());
Pierre Ossman61fd4862011-05-16 12:46:51 +0000367 dotWhenNoCursor.setParam(dotCursorCheckbox->value());
Pierre Ossman0c41e1d2011-05-17 09:36:04 +0000368
369 std::map<OptionsCallback*, void*>::const_iterator iter;
370
371 for (iter = callbacks.begin();iter != callbacks.end();++iter)
372 iter->first(iter->second);
Pierre Ossmand463b572011-05-16 12:04:43 +0000373}
374
375
376void OptionsDialog::createCompressionPage(int tx, int ty, int tw, int th)
377{
378 Fl_Group *group = new Fl_Group(tx, ty, tw, th, _("Compression"));
379
380 int orig_tx, orig_ty;
381 int half_width, full_width;
382 int width, height;
383
384 tx += OUTER_MARGIN;
385 ty += OUTER_MARGIN;
386
387 full_width = tw - OUTER_MARGIN * 2;
388 half_width = (full_width - INNER_MARGIN) / 2;
389
390 /* AutoSelect checkbox */
391 autoselectCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
392 CHECK_MIN_WIDTH,
393 CHECK_HEIGHT,
394 _("Auto select")));
395 autoselectCheckbox->callback(handleAutoselect, this);
396 ty += CHECK_HEIGHT + INNER_MARGIN;
397
398 /* Two columns */
399 orig_tx = tx;
400 orig_ty = ty;
401
402 /* VNC encoding box */
403 ty += GROUP_LABEL_OFFSET;
404 height = GROUP_MARGIN * 2 + TIGHT_MARGIN * 3 + RADIO_HEIGHT * 4;
405 encodingGroup = new Fl_Group(tx, ty, half_width, height,
406 _("Preferred encoding"));
407 encodingGroup->box(FL_ENGRAVED_BOX);
408 encodingGroup->align(FL_ALIGN_LEFT | FL_ALIGN_TOP);
409
410 {
411 tx += GROUP_MARGIN;
412 ty += GROUP_MARGIN;
413
414 width = encodingGroup->w() - GROUP_MARGIN * 2;
415
416 tightButton = new Fl_Round_Button(LBLRIGHT(tx, ty,
417 RADIO_MIN_WIDTH,
418 RADIO_HEIGHT,
Peter Åstrand4c446002011-08-15 12:33:06 +0000419 "Tight"));
Pierre Ossmand463b572011-05-16 12:04:43 +0000420 tightButton->type(FL_RADIO_BUTTON);
421 ty += RADIO_HEIGHT + TIGHT_MARGIN;
422
423 zrleButton = new Fl_Round_Button(LBLRIGHT(tx, ty,
424 RADIO_MIN_WIDTH,
425 RADIO_HEIGHT,
Peter Åstrand4c446002011-08-15 12:33:06 +0000426 "ZRLE"));
Pierre Ossmand463b572011-05-16 12:04:43 +0000427 zrleButton->type(FL_RADIO_BUTTON);
428 ty += RADIO_HEIGHT + TIGHT_MARGIN;
429
430 hextileButton = new Fl_Round_Button(LBLRIGHT(tx, ty,
431 RADIO_MIN_WIDTH,
432 RADIO_HEIGHT,
Peter Åstrand4c446002011-08-15 12:33:06 +0000433 "Hextile"));
Pierre Ossmand463b572011-05-16 12:04:43 +0000434 hextileButton->type(FL_RADIO_BUTTON);
435 ty += RADIO_HEIGHT + TIGHT_MARGIN;
436
437 rawButton = new Fl_Round_Button(LBLRIGHT(tx, ty,
438 RADIO_MIN_WIDTH,
439 RADIO_HEIGHT,
Peter Åstrand4c446002011-08-15 12:33:06 +0000440 "Raw"));
Pierre Ossmand463b572011-05-16 12:04:43 +0000441 rawButton->type(FL_RADIO_BUTTON);
442 ty += RADIO_HEIGHT + TIGHT_MARGIN;
443 }
444
445 ty += GROUP_MARGIN - TIGHT_MARGIN;
446
447 encodingGroup->end();
448
449 /* Second column */
450 tx = orig_tx + half_width + INNER_MARGIN;
451 ty = orig_ty;
452
453 /* Color box */
454 ty += GROUP_LABEL_OFFSET;
455 height = GROUP_MARGIN * 2 + TIGHT_MARGIN * 3 + RADIO_HEIGHT * 4;
456 colorlevelGroup = new Fl_Group(tx, ty, half_width, height, _("Color level"));
457 colorlevelGroup->box(FL_ENGRAVED_BOX);
458 colorlevelGroup->align(FL_ALIGN_LEFT | FL_ALIGN_TOP);
459
460 {
461 tx += GROUP_MARGIN;
462 ty += GROUP_MARGIN;
463
464 width = colorlevelGroup->w() - GROUP_MARGIN * 2;
465
466 fullcolorCheckbox = new Fl_Round_Button(LBLRIGHT(tx, ty,
467 RADIO_MIN_WIDTH,
468 RADIO_HEIGHT,
469 _("Full (all available colors)")));
470 fullcolorCheckbox->type(FL_RADIO_BUTTON);
471 ty += RADIO_HEIGHT + TIGHT_MARGIN;
472
473 mediumcolorCheckbox = new Fl_Round_Button(LBLRIGHT(tx, ty,
474 RADIO_MIN_WIDTH,
475 RADIO_HEIGHT,
476 _("Medium (256 colors)")));
477 mediumcolorCheckbox->type(FL_RADIO_BUTTON);
478 ty += RADIO_HEIGHT + TIGHT_MARGIN;
479
480 lowcolorCheckbox = new Fl_Round_Button(LBLRIGHT(tx, ty,
481 RADIO_MIN_WIDTH,
482 RADIO_HEIGHT,
483 _("Low (64 colors)")));
484 lowcolorCheckbox->type(FL_RADIO_BUTTON);
485 ty += RADIO_HEIGHT + TIGHT_MARGIN;
486
487 verylowcolorCheckbox = new Fl_Round_Button(LBLRIGHT(tx, ty,
488 RADIO_MIN_WIDTH,
489 RADIO_HEIGHT,
490 _("Very low (8 colors)")));
491 verylowcolorCheckbox->type(FL_RADIO_BUTTON);
492 ty += RADIO_HEIGHT + TIGHT_MARGIN;
493 }
494
495 ty += GROUP_MARGIN - TIGHT_MARGIN;
496
497 colorlevelGroup->end();
498
499 /* Back to normal */
500 tx = orig_tx;
501 ty += INNER_MARGIN;
502
503 /* Checkboxes */
504 compressionCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
505 CHECK_MIN_WIDTH,
506 CHECK_HEIGHT,
507 _("Custom compression level:")));
508 compressionCheckbox->callback(handleCompression, this);
509 ty += CHECK_HEIGHT + TIGHT_MARGIN;
510
511 compressionInput = new Fl_Int_Input(tx + INDENT, ty,
512 INPUT_HEIGHT, INPUT_HEIGHT,
DRCba7bc512011-08-17 02:30:34 +0000513 _("level (1=fast, 6=best [4-6 are rarely useful])"));
Pierre Ossmand463b572011-05-16 12:04:43 +0000514 compressionInput->align(FL_ALIGN_RIGHT);
515 ty += INPUT_HEIGHT + INNER_MARGIN;
516
517 jpegCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
518 CHECK_MIN_WIDTH,
519 CHECK_HEIGHT,
520 _("Allow JPEG compression:")));
521 jpegCheckbox->callback(handleJpeg, this);
522 ty += CHECK_HEIGHT + TIGHT_MARGIN;
523
524 jpegInput = new Fl_Int_Input(tx + INDENT, ty,
525 INPUT_HEIGHT, INPUT_HEIGHT,
DRC41036ed2011-08-23 20:36:50 +0000526 _("quality (0=poor, 9=best)"));
Pierre Ossmand463b572011-05-16 12:04:43 +0000527 jpegInput->align(FL_ALIGN_RIGHT);
528 ty += INPUT_HEIGHT + INNER_MARGIN;
529
530 group->end();
531}
532
533
534void OptionsDialog::createSecurityPage(int tx, int ty, int tw, int th)
535{
536#ifdef HAVE_GNUTLS
537 Fl_Group *group = new Fl_Group(tx, ty, tw, th, _("Security"));
538
539 int orig_tx;
540 int width, height;
541
542 tx += OUTER_MARGIN;
543 ty += OUTER_MARGIN;
544
545 width = tw - OUTER_MARGIN * 2;
546
547 orig_tx = tx;
548
Pierre Ossmand463b572011-05-16 12:04:43 +0000549 /* Encryption */
550 ty += GROUP_LABEL_OFFSET;
551 height = GROUP_MARGIN * 2 + TIGHT_MARGIN * 4 + CHECK_HEIGHT * 3 + (INPUT_LABEL_OFFSET + INPUT_HEIGHT) * 2;
552 encryptionGroup = new Fl_Group(tx, ty, width, height, _("Encryption"));
553 encryptionGroup->box(FL_ENGRAVED_BOX);
554 encryptionGroup->align(FL_ALIGN_LEFT | FL_ALIGN_TOP);
555
556 {
557 tx += GROUP_MARGIN;
558 ty += GROUP_MARGIN;
559
560 encNoneCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
561 CHECK_MIN_WIDTH,
562 CHECK_HEIGHT,
563 _("None")));
564 ty += CHECK_HEIGHT + TIGHT_MARGIN;
565
566 encTLSCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
567 CHECK_MIN_WIDTH,
568 CHECK_HEIGHT,
569 _("TLS with anonymous certificates")));
570 ty += CHECK_HEIGHT + TIGHT_MARGIN;
571
572 encX509Checkbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
573 CHECK_MIN_WIDTH,
574 CHECK_HEIGHT,
575 _("TLS with X509 certificates")));
576 encX509Checkbox->callback(handleX509, this);
577 ty += CHECK_HEIGHT + TIGHT_MARGIN;
578
579 ty += INPUT_LABEL_OFFSET;
580 caInput = new Fl_Input(tx + INDENT, ty,
581 width - GROUP_MARGIN*2 - INDENT, INPUT_HEIGHT,
582 _("Path to X509 CA certificate"));
583 caInput->align(FL_ALIGN_LEFT | FL_ALIGN_TOP);
584 ty += INPUT_HEIGHT + TIGHT_MARGIN;
585
586 ty += INPUT_LABEL_OFFSET;
587 crlInput = new Fl_Input(tx + INDENT, ty,
588 width - GROUP_MARGIN*2 - INDENT, INPUT_HEIGHT,
589 _("Path to X509 CRL file"));
590 crlInput->align(FL_ALIGN_LEFT | FL_ALIGN_TOP);
591 ty += INPUT_HEIGHT + TIGHT_MARGIN;
592 }
593
594 ty += GROUP_MARGIN - TIGHT_MARGIN;
595
596 encryptionGroup->end();
597
598 /* Back to normal */
599 tx = orig_tx;
600 ty += INNER_MARGIN;
601
602 /* Authentication */
Pierre Ossmand463b572011-05-16 12:04:43 +0000603 ty += GROUP_LABEL_OFFSET;
604 height = GROUP_MARGIN * 2 + TIGHT_MARGIN * 2 + CHECK_HEIGHT * 3;
605 authenticationGroup = new Fl_Group(tx, ty, width, height, _("Authentication"));
606 authenticationGroup->box(FL_ENGRAVED_BOX);
607 authenticationGroup->align(FL_ALIGN_LEFT | FL_ALIGN_TOP);
608
609 {
610 tx += GROUP_MARGIN;
611 ty += GROUP_MARGIN;
612
613 authNoneCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
614 CHECK_MIN_WIDTH,
615 CHECK_HEIGHT,
616 _("None")));
617 ty += CHECK_HEIGHT + TIGHT_MARGIN;
618
619 authVncCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
620 CHECK_MIN_WIDTH,
621 CHECK_HEIGHT,
622 _("Standard VNC (insecure without encryption)")));
623 ty += CHECK_HEIGHT + TIGHT_MARGIN;
624
625 authPlainCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
626 CHECK_MIN_WIDTH,
627 CHECK_HEIGHT,
628 _("Username and password (insecure without encryption)")));
629 ty += CHECK_HEIGHT + TIGHT_MARGIN;
630 }
631
632 ty += GROUP_MARGIN - TIGHT_MARGIN;
633
634 authenticationGroup->end();
635
636 /* Back to normal */
637 tx = orig_tx;
638 ty += INNER_MARGIN;
639
640 group->end();
641#endif
642}
643
644
645void OptionsDialog::createInputPage(int tx, int ty, int tw, int th)
646{
647 Fl_Group *group = new Fl_Group(tx, ty, tw, th, _("Input"));
648
649 tx += OUTER_MARGIN;
650 ty += OUTER_MARGIN;
651
652 viewOnlyCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
653 CHECK_MIN_WIDTH,
654 CHECK_HEIGHT,
655 _("View only (ignore mouse and keyboard)")));
656 ty += CHECK_HEIGHT + TIGHT_MARGIN;
657
658 acceptClipboardCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
659 CHECK_MIN_WIDTH,
660 CHECK_HEIGHT,
661 _("Accept clipboard from server")));
662 ty += CHECK_HEIGHT + TIGHT_MARGIN;
663
664 sendClipboardCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
665 CHECK_MIN_WIDTH,
666 CHECK_HEIGHT,
667 _("Send clipboard to server")));
668 ty += CHECK_HEIGHT + TIGHT_MARGIN;
669
670 sendPrimaryCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
671 CHECK_MIN_WIDTH,
672 CHECK_HEIGHT,
673 _("Send primary selection and cut buffer as clipboard")));
674 ty += CHECK_HEIGHT + TIGHT_MARGIN;
675
Pierre Ossman407a5c32011-05-26 14:48:29 +0000676 systemKeysCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
677 CHECK_MIN_WIDTH,
678 CHECK_HEIGHT,
679 _("Pass system keys directly to server (full screen)")));
680 ty += CHECK_HEIGHT + TIGHT_MARGIN;
681
Pierre Ossman4e7271e2011-05-24 12:47:12 +0000682 menuKeyChoice = new Fl_Choice(LBLLEFT(tx, ty, 150, CHOICE_HEIGHT, _("Menu key")));
683
684 menuKeyChoice->add(_("None"), 0, NULL, (void*)0, FL_MENU_DIVIDER);
Martin Koegler498ef462011-09-04 07:04:43 +0000685 for (int i = 0; i < getMenuKeySymbolCount(); i++)
686 menuKeyChoice->add(getMenuKeySymbols()[i].name, 0, NULL, 0, 0);
Pierre Ossman4e7271e2011-05-24 12:47:12 +0000687
688 ty += CHOICE_HEIGHT + TIGHT_MARGIN;
689
Pierre Ossmand463b572011-05-16 12:04:43 +0000690 group->end();
691}
692
693
Pierre Ossman1c2189b2012-07-05 09:23:03 +0000694void OptionsDialog::createScreenPage(int tx, int ty, int tw, int th)
695{
696 Fl_Group *group = new Fl_Group(tx, ty, tw, th, _("Screen"));
697
698 tx += OUTER_MARGIN;
699 ty += OUTER_MARGIN;
700
701 fullScreenCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
702 CHECK_MIN_WIDTH,
703 CHECK_HEIGHT,
704 _("Full-screen mode")));
705 ty += CHECK_HEIGHT + TIGHT_MARGIN;
706
707 group->end();
708}
709
710
Pierre Ossmand463b572011-05-16 12:04:43 +0000711void OptionsDialog::createMiscPage(int tx, int ty, int tw, int th)
712{
713 Fl_Group *group = new Fl_Group(tx, ty, tw, th, _("Misc."));
714
715 tx += OUTER_MARGIN;
716 ty += OUTER_MARGIN;
717
718 sharedCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
719 CHECK_MIN_WIDTH,
720 CHECK_HEIGHT,
721 _("Shared (don't disconnect other viewers)")));
722 ty += CHECK_HEIGHT + TIGHT_MARGIN;
723
Pierre Ossmand463b572011-05-16 12:04:43 +0000724 dotCursorCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
725 CHECK_MIN_WIDTH,
726 CHECK_HEIGHT,
727 _("Show dot when no cursor")));
728 ty += CHECK_HEIGHT + TIGHT_MARGIN;
729
730 group->end();
731}
732
733
734void OptionsDialog::handleAutoselect(Fl_Widget *widget, void *data)
735{
736 OptionsDialog *dialog = (OptionsDialog*)data;
737
738 if (dialog->autoselectCheckbox->value()) {
739 dialog->encodingGroup->deactivate();
740 dialog->colorlevelGroup->deactivate();
741 } else {
742 dialog->encodingGroup->activate();
743 dialog->colorlevelGroup->activate();
744 }
745
746 // JPEG setting is also affected by autoselection
747 dialog->handleJpeg(dialog->jpegCheckbox, dialog);
748}
749
750
751void OptionsDialog::handleCompression(Fl_Widget *widget, void *data)
752{
753 OptionsDialog *dialog = (OptionsDialog*)data;
754
755 if (dialog->compressionCheckbox->value())
756 dialog->compressionInput->activate();
757 else
758 dialog->compressionInput->deactivate();
759}
760
761
762void OptionsDialog::handleJpeg(Fl_Widget *widget, void *data)
763{
764 OptionsDialog *dialog = (OptionsDialog*)data;
765
766 if (dialog->jpegCheckbox->value() &&
767 !dialog->autoselectCheckbox->value())
768 dialog->jpegInput->activate();
769 else
770 dialog->jpegInput->deactivate();
771}
772
773
Pierre Ossmand463b572011-05-16 12:04:43 +0000774void OptionsDialog::handleX509(Fl_Widget *widget, void *data)
775{
776 OptionsDialog *dialog = (OptionsDialog*)data;
777
778 if (dialog->encX509Checkbox->value()) {
779 dialog->caInput->activate();
780 dialog->crlInput->activate();
781 } else {
782 dialog->caInput->deactivate();
783 dialog->crlInput->deactivate();
784 }
785}
786
787
788void OptionsDialog::handleCancel(Fl_Widget *widget, void *data)
789{
790 OptionsDialog *dialog = (OptionsDialog*)data;
791
792 dialog->hide();
793}
794
795
796void OptionsDialog::handleOK(Fl_Widget *widget, void *data)
797{
798 OptionsDialog *dialog = (OptionsDialog*)data;
799
800 dialog->hide();
801
802 dialog->storeOptions();
803}