blob: 220ca9629abd8a9c6206584a46f243564de52382 [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"
39#include "parameters.h"
40
DRCb65bb932011-06-24 03:17:00 +000041#include <FL/Fl_Tabs.H>
42#include <FL/Fl_Button.H>
43#include <FL/Fl_Return_Button.H>
44
Pierre Ossmand463b572011-05-16 12:04:43 +000045using namespace std;
46using namespace rdr;
47using namespace rfb;
48
Pierre Ossman0c41e1d2011-05-17 09:36:04 +000049std::map<OptionsCallback*, void*> OptionsDialog::callbacks;
50
Pierre Ossmand463b572011-05-16 12:04:43 +000051OptionsDialog::OptionsDialog()
52 : Fl_Window(450, 450, _("VNC Viewer: Connection Options"))
53{
54 int x, y;
55 Fl_Button *button;
56
57 Fl_Tabs *tabs = new Fl_Tabs(OUTER_MARGIN, OUTER_MARGIN,
58 w() - OUTER_MARGIN*2,
59 h() - OUTER_MARGIN*2 - INNER_MARGIN - BUTTON_HEIGHT);
60
61 {
62 int tx, ty, tw, th;
63
64 tabs->client_area(tx, ty, tw, th, TABS_HEIGHT);
65
66 createCompressionPage(tx, ty, tw, th);
67 createSecurityPage(tx, ty, tw, th);
68 createInputPage(tx, ty, tw, th);
69 createMiscPage(tx, ty, tw, th);
70 }
71
72 tabs->end();
73
74 x = w() - BUTTON_WIDTH * 2 - INNER_MARGIN - OUTER_MARGIN;
75 y = h() - BUTTON_HEIGHT - OUTER_MARGIN;
76
77 button = new Fl_Button(x, y, BUTTON_WIDTH, BUTTON_HEIGHT, _("Cancel"));
78 button->callback(this->handleCancel, this);
79
80 x += BUTTON_WIDTH + INNER_MARGIN;
81
82 button = new Fl_Return_Button(x, y, BUTTON_WIDTH, BUTTON_HEIGHT, _("OK"));
83 button->callback(this->handleOK, this);
84
85 callback(this->handleCancel, this);
86
87 set_modal();
88}
89
90
91OptionsDialog::~OptionsDialog()
92{
93}
94
95
96void OptionsDialog::showDialog(void)
97{
98 static OptionsDialog *dialog = NULL;
99
100 if (!dialog)
101 dialog = new OptionsDialog();
102
103 if (dialog->shown())
104 return;
105
106 dialog->show();
107}
108
109
Pierre Ossman0c41e1d2011-05-17 09:36:04 +0000110void OptionsDialog::addCallback(OptionsCallback *cb, void *data)
111{
112 callbacks[cb] = data;
113}
114
115
116void OptionsDialog::removeCallback(OptionsCallback *cb)
117{
118 callbacks.erase(cb);
119}
120
121
Pierre Ossmand463b572011-05-16 12:04:43 +0000122void OptionsDialog::show(void)
123{
124 loadOptions();
125
126 Fl_Window::show();
127}
128
129
130void OptionsDialog::loadOptions(void)
131{
132 /* Compression */
133 autoselectCheckbox->value(autoSelect);
134
135 int encNum = encodingNum(preferredEncoding);
136
137 switch (encNum) {
138 case encodingTight:
139 tightButton->setonly();
140 break;
141 case encodingZRLE:
142 zrleButton->setonly();
143 break;
144 case encodingHextile:
145 hextileButton->setonly();
146 break;
147 case encodingRaw:
148 rawButton->setonly();
149 break;
150 }
151
152 if (fullColour)
153 fullcolorCheckbox->setonly();
154 else {
155 switch (lowColourLevel) {
156 case 0:
Pierre Ossmancf836f22011-07-14 14:34:09 +0000157 verylowcolorCheckbox->setonly();
Pierre Ossmand463b572011-05-16 12:04:43 +0000158 break;
159 case 1:
160 lowcolorCheckbox->setonly();
161 break;
162 case 2:
Pierre Ossmancf836f22011-07-14 14:34:09 +0000163 mediumcolorCheckbox->setonly();
Pierre Ossmand463b572011-05-16 12:04:43 +0000164 break;
165 }
166 }
167
168 char digit[2] = "0";
169
170 compressionCheckbox->value(customCompressLevel);
171 jpegCheckbox->value(!noJpeg);
172 digit[0] = '0' + compressLevel;
173 compressionInput->value(digit);
174 digit[0] = '0' + qualityLevel;
175 jpegInput->value(digit);
176
177 handleAutoselect(autoselectCheckbox, this);
178 handleCompression(compressionCheckbox, this);
179 handleJpeg(jpegCheckbox, this);
180
181#ifdef HAVE_GNUTLS
182 /* Security */
183 Security security(SecurityClient::secTypes);
184
185 list<U8> secTypes;
186 list<U8>::iterator iter;
187
188 list<U32> secTypesExt;
189 list<U32>::iterator iterExt;
190
191 vencryptCheckbox->value(false);
192
193 encNoneCheckbox->value(false);
194 encTLSCheckbox->value(false);
195 encX509Checkbox->value(false);
196
197 authNoneCheckbox->value(false);
198 authVncCheckbox->value(false);
199 authPlainCheckbox->value(false);
200
201 secTypes = security.GetEnabledSecTypes();
202 for (iter = secTypes.begin(); iter != secTypes.end(); ++iter) {
203 switch (*iter) {
204 case secTypeVeNCrypt:
205 vencryptCheckbox->value(true);
206 break;
207 case secTypeNone:
208 encNoneCheckbox->value(true);
209 authNoneCheckbox->value(true);
210 break;
211 case secTypeVncAuth:
212 encNoneCheckbox->value(true);
213 authVncCheckbox->value(true);
214 break;
215 }
216 }
217
218 secTypesExt = security.GetEnabledExtSecTypes();
219 for (iterExt = secTypesExt.begin(); iterExt != secTypesExt.end(); ++iterExt) {
220 switch (*iterExt) {
221 case secTypePlain:
222 encNoneCheckbox->value(true);
223 authPlainCheckbox->value(true);
224 break;
225 case secTypeTLSNone:
226 encTLSCheckbox->value(true);
227 authNoneCheckbox->value(true);
228 break;
229 case secTypeTLSVnc:
230 encTLSCheckbox->value(true);
231 authVncCheckbox->value(true);
232 break;
233 case secTypeTLSPlain:
234 encTLSCheckbox->value(true);
235 authPlainCheckbox->value(true);
236 break;
237 case secTypeX509None:
238 encX509Checkbox->value(true);
239 authNoneCheckbox->value(true);
240 break;
241 case secTypeX509Vnc:
242 encX509Checkbox->value(true);
243 authVncCheckbox->value(true);
244 break;
245 case secTypeX509Plain:
246 encX509Checkbox->value(true);
247 authPlainCheckbox->value(true);
248 break;
249 }
250 }
251
252 caInput->value(CSecurityTLS::x509ca);
253 crlInput->value(CSecurityTLS::x509crl);
254
255 handleVencrypt(vencryptCheckbox, this);
256 handleX509(encX509Checkbox, this);
257#endif
258
259 /* Input */
Pierre Ossman4e7271e2011-05-24 12:47:12 +0000260 const char *menuKeyBuf;
261
Pierre Ossmand463b572011-05-16 12:04:43 +0000262 viewOnlyCheckbox->value(viewOnly);
263 acceptClipboardCheckbox->value(acceptClipboard);
264 sendClipboardCheckbox->value(sendClipboard);
265 sendPrimaryCheckbox->value(sendPrimary);
Pierre Ossman407a5c32011-05-26 14:48:29 +0000266 systemKeysCheckbox->value(fullscreenSystemKeys);
Pierre Ossmand463b572011-05-16 12:04:43 +0000267
Pierre Ossman4e7271e2011-05-24 12:47:12 +0000268 menuKeyChoice->value(0);
269
270 menuKeyBuf = menuKey;
271 if (menuKeyBuf[0] == 'F') {
272 int num = atoi(menuKeyBuf+1);
273 if ((num >= 1) && (num <= 12))
274 menuKeyChoice->value(num);
275 }
276
Pierre Ossmand463b572011-05-16 12:04:43 +0000277 /* Misc. */
278 sharedCheckbox->value(shared);
279 fullScreenCheckbox->value(fullScreen);
Pierre Ossmand463b572011-05-16 12:04:43 +0000280 dotCursorCheckbox->value(dotWhenNoCursor);
281}
282
283
284void OptionsDialog::storeOptions(void)
285{
Pierre Ossman61fd4862011-05-16 12:46:51 +0000286 /* Compression */
287 autoSelect.setParam(autoselectCheckbox->value());
288
289 if (tightButton->value())
290 preferredEncoding.setParam(encodingName(encodingTight));
291 else if (zrleButton->value())
292 preferredEncoding.setParam(encodingName(encodingZRLE));
293 else if (hextileButton->value())
294 preferredEncoding.setParam(encodingName(encodingHextile));
295 else if (rawButton->value())
296 preferredEncoding.setParam(encodingName(encodingRaw));
297
298 fullColour.setParam(fullcolorCheckbox->value());
Pierre Ossmancf836f22011-07-14 14:34:09 +0000299 if (verylowcolorCheckbox->value())
Pierre Ossman61fd4862011-05-16 12:46:51 +0000300 lowColourLevel.setParam(0);
301 else if (lowcolorCheckbox->value())
302 lowColourLevel.setParam(1);
Pierre Ossmancf836f22011-07-14 14:34:09 +0000303 else if (mediumcolorCheckbox->value())
Pierre Ossman61fd4862011-05-16 12:46:51 +0000304 lowColourLevel.setParam(2);
305
306 customCompressLevel.setParam(compressionCheckbox->value());
307 noJpeg.setParam(!jpegCheckbox->value());
308 compressLevel.setParam(atoi(compressionInput->value()));
309 qualityLevel.setParam(atoi(jpegInput->value()));
310
311#ifdef HAVE_GNUTLS
312 /* Security */
313 Security security;
314
315 /* Process security types which don't use encryption */
316 if (encNoneCheckbox->value()) {
317 if (authNoneCheckbox->value())
318 security.EnableSecType(secTypeNone);
319 if (authVncCheckbox->value())
320 security.EnableSecType(secTypeVncAuth);
321
322 if (vencryptCheckbox->value()) {
323 if (authPlainCheckbox->value())
324 security.EnableSecType(secTypePlain);
325 }
326 }
327
328 if (vencryptCheckbox->value()) {
329 /* Process security types which use TLS encryption */
330 if (encTLSCheckbox->value()) {
331 if (authNoneCheckbox->value())
332 security.EnableSecType(secTypeTLSNone);
333 if (authVncCheckbox->value())
334 security.EnableSecType(secTypeTLSVnc);
335 if (authPlainCheckbox->value())
336 security.EnableSecType(secTypeTLSPlain);
337 }
338
339 /* Process security types which use X509 encryption */
340 if (encX509Checkbox->value()) {
341 if (authNoneCheckbox->value())
342 security.EnableSecType(secTypeX509None);
343 if (authVncCheckbox->value())
344 security.EnableSecType(secTypeX509Vnc);
345 if (authPlainCheckbox->value())
346 security.EnableSecType(secTypeX509Plain);
347 }
348 }
349
350 CSecurityTLS::x509ca.setParam(caInput->value());
351 CSecurityTLS::x509crl.setParam(crlInput->value());
352#endif
353
354 /* Input */
355 viewOnly.setParam(viewOnlyCheckbox->value());
356 acceptClipboard.setParam(acceptClipboardCheckbox->value());
357 sendClipboard.setParam(sendClipboardCheckbox->value());
358 sendPrimary.setParam(sendPrimaryCheckbox->value());
Pierre Ossman407a5c32011-05-26 14:48:29 +0000359 fullscreenSystemKeys.setParam(systemKeysCheckbox->value());
Pierre Ossman61fd4862011-05-16 12:46:51 +0000360
Pierre Ossman4e7271e2011-05-24 12:47:12 +0000361 if (menuKeyChoice->value() == 0)
362 menuKey.setParam("");
363 else {
364 char buf[16];
365 sprintf(buf, "F%d", menuKeyChoice->value());
366 menuKey.setParam(buf);
367 }
368
Pierre Ossman61fd4862011-05-16 12:46:51 +0000369 /* Misc. */
370 shared.setParam(sharedCheckbox->value());
371 fullScreen.setParam(fullScreenCheckbox->value());
Pierre Ossman61fd4862011-05-16 12:46:51 +0000372 dotWhenNoCursor.setParam(dotCursorCheckbox->value());
Pierre Ossman0c41e1d2011-05-17 09:36:04 +0000373
374 std::map<OptionsCallback*, void*>::const_iterator iter;
375
376 for (iter = callbacks.begin();iter != callbacks.end();++iter)
377 iter->first(iter->second);
Pierre Ossmand463b572011-05-16 12:04:43 +0000378}
379
380
381void OptionsDialog::createCompressionPage(int tx, int ty, int tw, int th)
382{
383 Fl_Group *group = new Fl_Group(tx, ty, tw, th, _("Compression"));
384
385 int orig_tx, orig_ty;
386 int half_width, full_width;
387 int width, height;
388
389 tx += OUTER_MARGIN;
390 ty += OUTER_MARGIN;
391
392 full_width = tw - OUTER_MARGIN * 2;
393 half_width = (full_width - INNER_MARGIN) / 2;
394
395 /* AutoSelect checkbox */
396 autoselectCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
397 CHECK_MIN_WIDTH,
398 CHECK_HEIGHT,
399 _("Auto select")));
400 autoselectCheckbox->callback(handleAutoselect, this);
401 ty += CHECK_HEIGHT + INNER_MARGIN;
402
403 /* Two columns */
404 orig_tx = tx;
405 orig_ty = ty;
406
407 /* VNC encoding box */
408 ty += GROUP_LABEL_OFFSET;
409 height = GROUP_MARGIN * 2 + TIGHT_MARGIN * 3 + RADIO_HEIGHT * 4;
410 encodingGroup = new Fl_Group(tx, ty, half_width, height,
411 _("Preferred encoding"));
412 encodingGroup->box(FL_ENGRAVED_BOX);
413 encodingGroup->align(FL_ALIGN_LEFT | FL_ALIGN_TOP);
414
415 {
416 tx += GROUP_MARGIN;
417 ty += GROUP_MARGIN;
418
419 width = encodingGroup->w() - GROUP_MARGIN * 2;
420
421 tightButton = new Fl_Round_Button(LBLRIGHT(tx, ty,
422 RADIO_MIN_WIDTH,
423 RADIO_HEIGHT,
Peter Åstrand4c446002011-08-15 12:33:06 +0000424 "Tight"));
Pierre Ossmand463b572011-05-16 12:04:43 +0000425 tightButton->type(FL_RADIO_BUTTON);
426 ty += RADIO_HEIGHT + TIGHT_MARGIN;
427
428 zrleButton = new Fl_Round_Button(LBLRIGHT(tx, ty,
429 RADIO_MIN_WIDTH,
430 RADIO_HEIGHT,
Peter Åstrand4c446002011-08-15 12:33:06 +0000431 "ZRLE"));
Pierre Ossmand463b572011-05-16 12:04:43 +0000432 zrleButton->type(FL_RADIO_BUTTON);
433 ty += RADIO_HEIGHT + TIGHT_MARGIN;
434
435 hextileButton = new Fl_Round_Button(LBLRIGHT(tx, ty,
436 RADIO_MIN_WIDTH,
437 RADIO_HEIGHT,
Peter Åstrand4c446002011-08-15 12:33:06 +0000438 "Hextile"));
Pierre Ossmand463b572011-05-16 12:04:43 +0000439 hextileButton->type(FL_RADIO_BUTTON);
440 ty += RADIO_HEIGHT + TIGHT_MARGIN;
441
442 rawButton = new Fl_Round_Button(LBLRIGHT(tx, ty,
443 RADIO_MIN_WIDTH,
444 RADIO_HEIGHT,
Peter Åstrand4c446002011-08-15 12:33:06 +0000445 "Raw"));
Pierre Ossmand463b572011-05-16 12:04:43 +0000446 rawButton->type(FL_RADIO_BUTTON);
447 ty += RADIO_HEIGHT + TIGHT_MARGIN;
448 }
449
450 ty += GROUP_MARGIN - TIGHT_MARGIN;
451
452 encodingGroup->end();
453
454 /* Second column */
455 tx = orig_tx + half_width + INNER_MARGIN;
456 ty = orig_ty;
457
458 /* Color box */
459 ty += GROUP_LABEL_OFFSET;
460 height = GROUP_MARGIN * 2 + TIGHT_MARGIN * 3 + RADIO_HEIGHT * 4;
461 colorlevelGroup = new Fl_Group(tx, ty, half_width, height, _("Color level"));
462 colorlevelGroup->box(FL_ENGRAVED_BOX);
463 colorlevelGroup->align(FL_ALIGN_LEFT | FL_ALIGN_TOP);
464
465 {
466 tx += GROUP_MARGIN;
467 ty += GROUP_MARGIN;
468
469 width = colorlevelGroup->w() - GROUP_MARGIN * 2;
470
471 fullcolorCheckbox = new Fl_Round_Button(LBLRIGHT(tx, ty,
472 RADIO_MIN_WIDTH,
473 RADIO_HEIGHT,
474 _("Full (all available colors)")));
475 fullcolorCheckbox->type(FL_RADIO_BUTTON);
476 ty += RADIO_HEIGHT + TIGHT_MARGIN;
477
478 mediumcolorCheckbox = new Fl_Round_Button(LBLRIGHT(tx, ty,
479 RADIO_MIN_WIDTH,
480 RADIO_HEIGHT,
481 _("Medium (256 colors)")));
482 mediumcolorCheckbox->type(FL_RADIO_BUTTON);
483 ty += RADIO_HEIGHT + TIGHT_MARGIN;
484
485 lowcolorCheckbox = new Fl_Round_Button(LBLRIGHT(tx, ty,
486 RADIO_MIN_WIDTH,
487 RADIO_HEIGHT,
488 _("Low (64 colors)")));
489 lowcolorCheckbox->type(FL_RADIO_BUTTON);
490 ty += RADIO_HEIGHT + TIGHT_MARGIN;
491
492 verylowcolorCheckbox = new Fl_Round_Button(LBLRIGHT(tx, ty,
493 RADIO_MIN_WIDTH,
494 RADIO_HEIGHT,
495 _("Very low (8 colors)")));
496 verylowcolorCheckbox->type(FL_RADIO_BUTTON);
497 ty += RADIO_HEIGHT + TIGHT_MARGIN;
498 }
499
500 ty += GROUP_MARGIN - TIGHT_MARGIN;
501
502 colorlevelGroup->end();
503
504 /* Back to normal */
505 tx = orig_tx;
506 ty += INNER_MARGIN;
507
508 /* Checkboxes */
509 compressionCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
510 CHECK_MIN_WIDTH,
511 CHECK_HEIGHT,
512 _("Custom compression level:")));
513 compressionCheckbox->callback(handleCompression, this);
514 ty += CHECK_HEIGHT + TIGHT_MARGIN;
515
516 compressionInput = new Fl_Int_Input(tx + INDENT, ty,
517 INPUT_HEIGHT, INPUT_HEIGHT,
DRCba7bc512011-08-17 02:30:34 +0000518 _("level (1=fast, 6=best [4-6 are rarely useful])"));
Pierre Ossmand463b572011-05-16 12:04:43 +0000519 compressionInput->align(FL_ALIGN_RIGHT);
520 ty += INPUT_HEIGHT + INNER_MARGIN;
521
522 jpegCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
523 CHECK_MIN_WIDTH,
524 CHECK_HEIGHT,
525 _("Allow JPEG compression:")));
526 jpegCheckbox->callback(handleJpeg, this);
527 ty += CHECK_HEIGHT + TIGHT_MARGIN;
528
529 jpegInput = new Fl_Int_Input(tx + INDENT, ty,
530 INPUT_HEIGHT, INPUT_HEIGHT,
DRC41036ed2011-08-23 20:36:50 +0000531 _("quality (0=poor, 9=best)"));
Pierre Ossmand463b572011-05-16 12:04:43 +0000532 jpegInput->align(FL_ALIGN_RIGHT);
533 ty += INPUT_HEIGHT + INNER_MARGIN;
534
535 group->end();
536}
537
538
539void OptionsDialog::createSecurityPage(int tx, int ty, int tw, int th)
540{
541#ifdef HAVE_GNUTLS
542 Fl_Group *group = new Fl_Group(tx, ty, tw, th, _("Security"));
543
544 int orig_tx;
545 int width, height;
546
547 tx += OUTER_MARGIN;
548 ty += OUTER_MARGIN;
549
550 width = tw - OUTER_MARGIN * 2;
551
552 orig_tx = tx;
553
554 /* Security */
555 vencryptCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
556 CHECK_MIN_WIDTH,
557 CHECK_HEIGHT,
558 _("Extended encryption and authentication methods (VeNCrypt)")));
559 vencryptCheckbox->callback(handleVencrypt, this);
560 ty += CHECK_HEIGHT + INNER_MARGIN;
561
562 /* Encryption */
563 ty += GROUP_LABEL_OFFSET;
564 height = GROUP_MARGIN * 2 + TIGHT_MARGIN * 4 + CHECK_HEIGHT * 3 + (INPUT_LABEL_OFFSET + INPUT_HEIGHT) * 2;
565 encryptionGroup = new Fl_Group(tx, ty, width, height, _("Encryption"));
566 encryptionGroup->box(FL_ENGRAVED_BOX);
567 encryptionGroup->align(FL_ALIGN_LEFT | FL_ALIGN_TOP);
568
569 {
570 tx += GROUP_MARGIN;
571 ty += GROUP_MARGIN;
572
573 encNoneCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
574 CHECK_MIN_WIDTH,
575 CHECK_HEIGHT,
576 _("None")));
577 ty += CHECK_HEIGHT + TIGHT_MARGIN;
578
579 encTLSCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
580 CHECK_MIN_WIDTH,
581 CHECK_HEIGHT,
582 _("TLS with anonymous certificates")));
583 ty += CHECK_HEIGHT + TIGHT_MARGIN;
584
585 encX509Checkbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
586 CHECK_MIN_WIDTH,
587 CHECK_HEIGHT,
588 _("TLS with X509 certificates")));
589 encX509Checkbox->callback(handleX509, this);
590 ty += CHECK_HEIGHT + TIGHT_MARGIN;
591
592 ty += INPUT_LABEL_OFFSET;
593 caInput = new Fl_Input(tx + INDENT, ty,
594 width - GROUP_MARGIN*2 - INDENT, INPUT_HEIGHT,
595 _("Path to X509 CA certificate"));
596 caInput->align(FL_ALIGN_LEFT | FL_ALIGN_TOP);
597 ty += INPUT_HEIGHT + TIGHT_MARGIN;
598
599 ty += INPUT_LABEL_OFFSET;
600 crlInput = new Fl_Input(tx + INDENT, ty,
601 width - GROUP_MARGIN*2 - INDENT, INPUT_HEIGHT,
602 _("Path to X509 CRL file"));
603 crlInput->align(FL_ALIGN_LEFT | FL_ALIGN_TOP);
604 ty += INPUT_HEIGHT + TIGHT_MARGIN;
605 }
606
607 ty += GROUP_MARGIN - TIGHT_MARGIN;
608
609 encryptionGroup->end();
610
611 /* Back to normal */
612 tx = orig_tx;
613 ty += INNER_MARGIN;
614
615 /* Authentication */
616 /* Encryption */
617 ty += GROUP_LABEL_OFFSET;
618 height = GROUP_MARGIN * 2 + TIGHT_MARGIN * 2 + CHECK_HEIGHT * 3;
619 authenticationGroup = new Fl_Group(tx, ty, width, height, _("Authentication"));
620 authenticationGroup->box(FL_ENGRAVED_BOX);
621 authenticationGroup->align(FL_ALIGN_LEFT | FL_ALIGN_TOP);
622
623 {
624 tx += GROUP_MARGIN;
625 ty += GROUP_MARGIN;
626
627 authNoneCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
628 CHECK_MIN_WIDTH,
629 CHECK_HEIGHT,
630 _("None")));
631 ty += CHECK_HEIGHT + TIGHT_MARGIN;
632
633 authVncCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
634 CHECK_MIN_WIDTH,
635 CHECK_HEIGHT,
636 _("Standard VNC (insecure without encryption)")));
637 ty += CHECK_HEIGHT + TIGHT_MARGIN;
638
639 authPlainCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
640 CHECK_MIN_WIDTH,
641 CHECK_HEIGHT,
642 _("Username and password (insecure without encryption)")));
643 ty += CHECK_HEIGHT + TIGHT_MARGIN;
644 }
645
646 ty += GROUP_MARGIN - TIGHT_MARGIN;
647
648 authenticationGroup->end();
649
650 /* Back to normal */
651 tx = orig_tx;
652 ty += INNER_MARGIN;
653
654 group->end();
655#endif
656}
657
658
659void OptionsDialog::createInputPage(int tx, int ty, int tw, int th)
660{
661 Fl_Group *group = new Fl_Group(tx, ty, tw, th, _("Input"));
662
663 tx += OUTER_MARGIN;
664 ty += OUTER_MARGIN;
665
666 viewOnlyCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
667 CHECK_MIN_WIDTH,
668 CHECK_HEIGHT,
669 _("View only (ignore mouse and keyboard)")));
670 ty += CHECK_HEIGHT + TIGHT_MARGIN;
671
672 acceptClipboardCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
673 CHECK_MIN_WIDTH,
674 CHECK_HEIGHT,
675 _("Accept clipboard from server")));
676 ty += CHECK_HEIGHT + TIGHT_MARGIN;
677
678 sendClipboardCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
679 CHECK_MIN_WIDTH,
680 CHECK_HEIGHT,
681 _("Send clipboard to server")));
682 ty += CHECK_HEIGHT + TIGHT_MARGIN;
683
684 sendPrimaryCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
685 CHECK_MIN_WIDTH,
686 CHECK_HEIGHT,
687 _("Send primary selection and cut buffer as clipboard")));
688 ty += CHECK_HEIGHT + TIGHT_MARGIN;
689
Pierre Ossman407a5c32011-05-26 14:48:29 +0000690 systemKeysCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
691 CHECK_MIN_WIDTH,
692 CHECK_HEIGHT,
693 _("Pass system keys directly to server (full screen)")));
694 ty += CHECK_HEIGHT + TIGHT_MARGIN;
695
Pierre Ossman4e7271e2011-05-24 12:47:12 +0000696 menuKeyChoice = new Fl_Choice(LBLLEFT(tx, ty, 150, CHOICE_HEIGHT, _("Menu key")));
697
698 menuKeyChoice->add(_("None"), 0, NULL, (void*)0, FL_MENU_DIVIDER);
699 for (int i = 1;i <= 12;i++) {
700 char buf[16];
701 sprintf(buf, "F%d", i);
702 menuKeyChoice->add(buf, 0, NULL, (void*)i, 0);
703 }
704
705 ty += CHOICE_HEIGHT + TIGHT_MARGIN;
706
Pierre Ossmand463b572011-05-16 12:04:43 +0000707 group->end();
708}
709
710
711void 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
724 fullScreenCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
725 CHECK_MIN_WIDTH,
726 CHECK_HEIGHT,
727 _("Full-screen mode")));
728 ty += CHECK_HEIGHT + TIGHT_MARGIN;
729
Pierre Ossmand463b572011-05-16 12:04:43 +0000730 dotCursorCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
731 CHECK_MIN_WIDTH,
732 CHECK_HEIGHT,
733 _("Show dot when no cursor")));
734 ty += CHECK_HEIGHT + TIGHT_MARGIN;
735
736 group->end();
737}
738
739
740void OptionsDialog::handleAutoselect(Fl_Widget *widget, void *data)
741{
742 OptionsDialog *dialog = (OptionsDialog*)data;
743
744 if (dialog->autoselectCheckbox->value()) {
745 dialog->encodingGroup->deactivate();
746 dialog->colorlevelGroup->deactivate();
747 } else {
748 dialog->encodingGroup->activate();
749 dialog->colorlevelGroup->activate();
750 }
751
752 // JPEG setting is also affected by autoselection
753 dialog->handleJpeg(dialog->jpegCheckbox, dialog);
754}
755
756
757void OptionsDialog::handleCompression(Fl_Widget *widget, void *data)
758{
759 OptionsDialog *dialog = (OptionsDialog*)data;
760
761 if (dialog->compressionCheckbox->value())
762 dialog->compressionInput->activate();
763 else
764 dialog->compressionInput->deactivate();
765}
766
767
768void OptionsDialog::handleJpeg(Fl_Widget *widget, void *data)
769{
770 OptionsDialog *dialog = (OptionsDialog*)data;
771
772 if (dialog->jpegCheckbox->value() &&
773 !dialog->autoselectCheckbox->value())
774 dialog->jpegInput->activate();
775 else
776 dialog->jpegInput->deactivate();
777}
778
779
780void OptionsDialog::handleVencrypt(Fl_Widget *widget, void *data)
781{
782 OptionsDialog *dialog = (OptionsDialog*)data;
783
784 if (dialog->vencryptCheckbox->value()) {
785 dialog->encryptionGroup->activate();
786 dialog->authPlainCheckbox->activate();
787 } else {
788 dialog->encryptionGroup->deactivate();
789 dialog->authPlainCheckbox->deactivate();
790 }
791}
792
793
794void OptionsDialog::handleX509(Fl_Widget *widget, void *data)
795{
796 OptionsDialog *dialog = (OptionsDialog*)data;
797
798 if (dialog->encX509Checkbox->value()) {
799 dialog->caInput->activate();
800 dialog->crlInput->activate();
801 } else {
802 dialog->caInput->deactivate();
803 dialog->crlInput->deactivate();
804 }
805}
806
807
808void OptionsDialog::handleCancel(Fl_Widget *widget, void *data)
809{
810 OptionsDialog *dialog = (OptionsDialog*)data;
811
812 dialog->hide();
813}
814
815
816void OptionsDialog::handleOK(Fl_Widget *widget, void *data)
817{
818 OptionsDialog *dialog = (OptionsDialog*)data;
819
820 dialog->hide();
821
822 dialog->storeOptions();
823}