blob: 87cc5afdfeb5d646332dab83e50c32c94d389523 [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 */
Pierre Ossman9ff733a2012-07-05 11:01:23 +0000274 int width, height;
275
276 if (sscanf(desktopSize.getValueStr(), "%dx%d", &width, &height) != 2) {
277 desktopSizeCheckbox->value(false);
278 desktopWidthInput->value("1024");
279 desktopHeightInput->value("768");
280 } else {
281 char buf[32];
282 desktopSizeCheckbox->value(true);
283 snprintf(buf, sizeof(buf), "%d", width);
284 desktopWidthInput->value(buf);
285 snprintf(buf, sizeof(buf), "%d", height);
286 desktopHeightInput->value(buf);
287 }
Pierre Ossman99197012012-07-05 11:06:18 +0000288 remoteResizeCheckbox->value(remoteResize);
Pierre Ossman1c2189b2012-07-05 09:23:03 +0000289 fullScreenCheckbox->value(fullScreen);
290
Pierre Ossman9ff733a2012-07-05 11:01:23 +0000291 handleDesktopSize(desktopSizeCheckbox, this);
292
Pierre Ossmand463b572011-05-16 12:04:43 +0000293 /* Misc. */
294 sharedCheckbox->value(shared);
Pierre Ossmand463b572011-05-16 12:04:43 +0000295 dotCursorCheckbox->value(dotWhenNoCursor);
296}
297
298
299void OptionsDialog::storeOptions(void)
300{
Pierre Ossman61fd4862011-05-16 12:46:51 +0000301 /* Compression */
302 autoSelect.setParam(autoselectCheckbox->value());
303
304 if (tightButton->value())
305 preferredEncoding.setParam(encodingName(encodingTight));
306 else if (zrleButton->value())
307 preferredEncoding.setParam(encodingName(encodingZRLE));
308 else if (hextileButton->value())
309 preferredEncoding.setParam(encodingName(encodingHextile));
310 else if (rawButton->value())
311 preferredEncoding.setParam(encodingName(encodingRaw));
312
313 fullColour.setParam(fullcolorCheckbox->value());
Pierre Ossmancf836f22011-07-14 14:34:09 +0000314 if (verylowcolorCheckbox->value())
Pierre Ossman61fd4862011-05-16 12:46:51 +0000315 lowColourLevel.setParam(0);
316 else if (lowcolorCheckbox->value())
317 lowColourLevel.setParam(1);
Pierre Ossmancf836f22011-07-14 14:34:09 +0000318 else if (mediumcolorCheckbox->value())
Pierre Ossman61fd4862011-05-16 12:46:51 +0000319 lowColourLevel.setParam(2);
320
321 customCompressLevel.setParam(compressionCheckbox->value());
322 noJpeg.setParam(!jpegCheckbox->value());
323 compressLevel.setParam(atoi(compressionInput->value()));
324 qualityLevel.setParam(atoi(jpegInput->value()));
325
326#ifdef HAVE_GNUTLS
327 /* Security */
328 Security security;
329
330 /* Process security types which don't use encryption */
331 if (encNoneCheckbox->value()) {
332 if (authNoneCheckbox->value())
333 security.EnableSecType(secTypeNone);
334 if (authVncCheckbox->value())
335 security.EnableSecType(secTypeVncAuth);
Pierre Ossmanc1764bd2011-09-30 12:26:25 +0000336 if (authPlainCheckbox->value())
337 security.EnableSecType(secTypePlain);
Pierre Ossman61fd4862011-05-16 12:46:51 +0000338 }
339
Pierre Ossmanc1764bd2011-09-30 12:26:25 +0000340 /* Process security types which use TLS encryption */
341 if (encTLSCheckbox->value()) {
342 if (authNoneCheckbox->value())
343 security.EnableSecType(secTypeTLSNone);
344 if (authVncCheckbox->value())
345 security.EnableSecType(secTypeTLSVnc);
346 if (authPlainCheckbox->value())
347 security.EnableSecType(secTypeTLSPlain);
348 }
Pierre Ossman61fd4862011-05-16 12:46:51 +0000349
Pierre Ossmanc1764bd2011-09-30 12:26:25 +0000350 /* Process security types which use X509 encryption */
351 if (encX509Checkbox->value()) {
352 if (authNoneCheckbox->value())
353 security.EnableSecType(secTypeX509None);
354 if (authVncCheckbox->value())
355 security.EnableSecType(secTypeX509Vnc);
356 if (authPlainCheckbox->value())
357 security.EnableSecType(secTypeX509Plain);
Pierre Ossman61fd4862011-05-16 12:46:51 +0000358 }
359
Pierre Ossman5535fe62011-09-30 12:11:52 +0000360 SecurityClient::secTypes.setParam(security.ToString());
361
Pierre Ossman61fd4862011-05-16 12:46:51 +0000362 CSecurityTLS::x509ca.setParam(caInput->value());
363 CSecurityTLS::x509crl.setParam(crlInput->value());
364#endif
365
366 /* Input */
367 viewOnly.setParam(viewOnlyCheckbox->value());
368 acceptClipboard.setParam(acceptClipboardCheckbox->value());
369 sendClipboard.setParam(sendClipboardCheckbox->value());
370 sendPrimary.setParam(sendPrimaryCheckbox->value());
Pierre Ossman407a5c32011-05-26 14:48:29 +0000371 fullscreenSystemKeys.setParam(systemKeysCheckbox->value());
Pierre Ossman61fd4862011-05-16 12:46:51 +0000372
Pierre Ossman4e7271e2011-05-24 12:47:12 +0000373 if (menuKeyChoice->value() == 0)
374 menuKey.setParam("");
375 else {
Martin Koegler498ef462011-09-04 07:04:43 +0000376 menuKey.setParam(menuKeyChoice->text());
Pierre Ossman4e7271e2011-05-24 12:47:12 +0000377 }
378
Pierre Ossman1c2189b2012-07-05 09:23:03 +0000379 /* Screen */
Pierre Ossman9ff733a2012-07-05 11:01:23 +0000380 int width, height;
381
382 if (desktopSizeCheckbox->value() &&
383 (sscanf(desktopWidthInput->value(), "%d", &width) == 1) &&
384 (sscanf(desktopHeightInput->value(), "%d", &height) == 1)) {
385 char buf[64];
386 snprintf(buf, sizeof(buf), "%dx%d", width, height);
387 desktopSize.setParam(buf);
388 } else {
389 desktopSize.setParam("");
390 }
Pierre Ossman99197012012-07-05 11:06:18 +0000391 remoteResize.setParam(remoteResizeCheckbox->value());
Pierre Ossman1c2189b2012-07-05 09:23:03 +0000392 fullScreen.setParam(fullScreenCheckbox->value());
393
Pierre Ossman61fd4862011-05-16 12:46:51 +0000394 /* Misc. */
395 shared.setParam(sharedCheckbox->value());
Pierre Ossman61fd4862011-05-16 12:46:51 +0000396 dotWhenNoCursor.setParam(dotCursorCheckbox->value());
Pierre Ossman0c41e1d2011-05-17 09:36:04 +0000397
398 std::map<OptionsCallback*, void*>::const_iterator iter;
399
400 for (iter = callbacks.begin();iter != callbacks.end();++iter)
401 iter->first(iter->second);
Pierre Ossmand463b572011-05-16 12:04:43 +0000402}
403
404
405void OptionsDialog::createCompressionPage(int tx, int ty, int tw, int th)
406{
407 Fl_Group *group = new Fl_Group(tx, ty, tw, th, _("Compression"));
408
409 int orig_tx, orig_ty;
410 int half_width, full_width;
411 int width, height;
412
413 tx += OUTER_MARGIN;
414 ty += OUTER_MARGIN;
415
416 full_width = tw - OUTER_MARGIN * 2;
417 half_width = (full_width - INNER_MARGIN) / 2;
418
419 /* AutoSelect checkbox */
420 autoselectCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
421 CHECK_MIN_WIDTH,
422 CHECK_HEIGHT,
423 _("Auto select")));
424 autoselectCheckbox->callback(handleAutoselect, this);
425 ty += CHECK_HEIGHT + INNER_MARGIN;
426
427 /* Two columns */
428 orig_tx = tx;
429 orig_ty = ty;
430
431 /* VNC encoding box */
432 ty += GROUP_LABEL_OFFSET;
433 height = GROUP_MARGIN * 2 + TIGHT_MARGIN * 3 + RADIO_HEIGHT * 4;
434 encodingGroup = new Fl_Group(tx, ty, half_width, height,
435 _("Preferred encoding"));
436 encodingGroup->box(FL_ENGRAVED_BOX);
437 encodingGroup->align(FL_ALIGN_LEFT | FL_ALIGN_TOP);
438
439 {
440 tx += GROUP_MARGIN;
441 ty += GROUP_MARGIN;
442
443 width = encodingGroup->w() - GROUP_MARGIN * 2;
444
445 tightButton = new Fl_Round_Button(LBLRIGHT(tx, ty,
446 RADIO_MIN_WIDTH,
447 RADIO_HEIGHT,
Peter Åstrand4c446002011-08-15 12:33:06 +0000448 "Tight"));
Pierre Ossmand463b572011-05-16 12:04:43 +0000449 tightButton->type(FL_RADIO_BUTTON);
450 ty += RADIO_HEIGHT + TIGHT_MARGIN;
451
452 zrleButton = new Fl_Round_Button(LBLRIGHT(tx, ty,
453 RADIO_MIN_WIDTH,
454 RADIO_HEIGHT,
Peter Åstrand4c446002011-08-15 12:33:06 +0000455 "ZRLE"));
Pierre Ossmand463b572011-05-16 12:04:43 +0000456 zrleButton->type(FL_RADIO_BUTTON);
457 ty += RADIO_HEIGHT + TIGHT_MARGIN;
458
459 hextileButton = new Fl_Round_Button(LBLRIGHT(tx, ty,
460 RADIO_MIN_WIDTH,
461 RADIO_HEIGHT,
Peter Åstrand4c446002011-08-15 12:33:06 +0000462 "Hextile"));
Pierre Ossmand463b572011-05-16 12:04:43 +0000463 hextileButton->type(FL_RADIO_BUTTON);
464 ty += RADIO_HEIGHT + TIGHT_MARGIN;
465
466 rawButton = new Fl_Round_Button(LBLRIGHT(tx, ty,
467 RADIO_MIN_WIDTH,
468 RADIO_HEIGHT,
Peter Åstrand4c446002011-08-15 12:33:06 +0000469 "Raw"));
Pierre Ossmand463b572011-05-16 12:04:43 +0000470 rawButton->type(FL_RADIO_BUTTON);
471 ty += RADIO_HEIGHT + TIGHT_MARGIN;
472 }
473
474 ty += GROUP_MARGIN - TIGHT_MARGIN;
475
476 encodingGroup->end();
477
478 /* Second column */
479 tx = orig_tx + half_width + INNER_MARGIN;
480 ty = orig_ty;
481
482 /* Color box */
483 ty += GROUP_LABEL_OFFSET;
484 height = GROUP_MARGIN * 2 + TIGHT_MARGIN * 3 + RADIO_HEIGHT * 4;
485 colorlevelGroup = new Fl_Group(tx, ty, half_width, height, _("Color level"));
486 colorlevelGroup->box(FL_ENGRAVED_BOX);
487 colorlevelGroup->align(FL_ALIGN_LEFT | FL_ALIGN_TOP);
488
489 {
490 tx += GROUP_MARGIN;
491 ty += GROUP_MARGIN;
492
493 width = colorlevelGroup->w() - GROUP_MARGIN * 2;
494
495 fullcolorCheckbox = new Fl_Round_Button(LBLRIGHT(tx, ty,
496 RADIO_MIN_WIDTH,
497 RADIO_HEIGHT,
498 _("Full (all available colors)")));
499 fullcolorCheckbox->type(FL_RADIO_BUTTON);
500 ty += RADIO_HEIGHT + TIGHT_MARGIN;
501
502 mediumcolorCheckbox = new Fl_Round_Button(LBLRIGHT(tx, ty,
503 RADIO_MIN_WIDTH,
504 RADIO_HEIGHT,
505 _("Medium (256 colors)")));
506 mediumcolorCheckbox->type(FL_RADIO_BUTTON);
507 ty += RADIO_HEIGHT + TIGHT_MARGIN;
508
509 lowcolorCheckbox = new Fl_Round_Button(LBLRIGHT(tx, ty,
510 RADIO_MIN_WIDTH,
511 RADIO_HEIGHT,
512 _("Low (64 colors)")));
513 lowcolorCheckbox->type(FL_RADIO_BUTTON);
514 ty += RADIO_HEIGHT + TIGHT_MARGIN;
515
516 verylowcolorCheckbox = new Fl_Round_Button(LBLRIGHT(tx, ty,
517 RADIO_MIN_WIDTH,
518 RADIO_HEIGHT,
519 _("Very low (8 colors)")));
520 verylowcolorCheckbox->type(FL_RADIO_BUTTON);
521 ty += RADIO_HEIGHT + TIGHT_MARGIN;
522 }
523
524 ty += GROUP_MARGIN - TIGHT_MARGIN;
525
526 colorlevelGroup->end();
527
528 /* Back to normal */
529 tx = orig_tx;
530 ty += INNER_MARGIN;
531
532 /* Checkboxes */
533 compressionCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
534 CHECK_MIN_WIDTH,
535 CHECK_HEIGHT,
536 _("Custom compression level:")));
537 compressionCheckbox->callback(handleCompression, this);
538 ty += CHECK_HEIGHT + TIGHT_MARGIN;
539
540 compressionInput = new Fl_Int_Input(tx + INDENT, ty,
541 INPUT_HEIGHT, INPUT_HEIGHT,
DRCba7bc512011-08-17 02:30:34 +0000542 _("level (1=fast, 6=best [4-6 are rarely useful])"));
Pierre Ossmand463b572011-05-16 12:04:43 +0000543 compressionInput->align(FL_ALIGN_RIGHT);
544 ty += INPUT_HEIGHT + INNER_MARGIN;
545
546 jpegCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
547 CHECK_MIN_WIDTH,
548 CHECK_HEIGHT,
549 _("Allow JPEG compression:")));
550 jpegCheckbox->callback(handleJpeg, this);
551 ty += CHECK_HEIGHT + TIGHT_MARGIN;
552
553 jpegInput = new Fl_Int_Input(tx + INDENT, ty,
554 INPUT_HEIGHT, INPUT_HEIGHT,
DRC41036ed2011-08-23 20:36:50 +0000555 _("quality (0=poor, 9=best)"));
Pierre Ossmand463b572011-05-16 12:04:43 +0000556 jpegInput->align(FL_ALIGN_RIGHT);
557 ty += INPUT_HEIGHT + INNER_MARGIN;
558
559 group->end();
560}
561
562
563void OptionsDialog::createSecurityPage(int tx, int ty, int tw, int th)
564{
565#ifdef HAVE_GNUTLS
566 Fl_Group *group = new Fl_Group(tx, ty, tw, th, _("Security"));
567
568 int orig_tx;
569 int width, height;
570
571 tx += OUTER_MARGIN;
572 ty += OUTER_MARGIN;
573
574 width = tw - OUTER_MARGIN * 2;
575
576 orig_tx = tx;
577
Pierre Ossmand463b572011-05-16 12:04:43 +0000578 /* Encryption */
579 ty += GROUP_LABEL_OFFSET;
580 height = GROUP_MARGIN * 2 + TIGHT_MARGIN * 4 + CHECK_HEIGHT * 3 + (INPUT_LABEL_OFFSET + INPUT_HEIGHT) * 2;
581 encryptionGroup = new Fl_Group(tx, ty, width, height, _("Encryption"));
582 encryptionGroup->box(FL_ENGRAVED_BOX);
583 encryptionGroup->align(FL_ALIGN_LEFT | FL_ALIGN_TOP);
584
585 {
586 tx += GROUP_MARGIN;
587 ty += GROUP_MARGIN;
588
589 encNoneCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
590 CHECK_MIN_WIDTH,
591 CHECK_HEIGHT,
592 _("None")));
593 ty += CHECK_HEIGHT + TIGHT_MARGIN;
594
595 encTLSCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
596 CHECK_MIN_WIDTH,
597 CHECK_HEIGHT,
598 _("TLS with anonymous certificates")));
599 ty += CHECK_HEIGHT + TIGHT_MARGIN;
600
601 encX509Checkbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
602 CHECK_MIN_WIDTH,
603 CHECK_HEIGHT,
604 _("TLS with X509 certificates")));
605 encX509Checkbox->callback(handleX509, this);
606 ty += CHECK_HEIGHT + TIGHT_MARGIN;
607
608 ty += INPUT_LABEL_OFFSET;
609 caInput = new Fl_Input(tx + INDENT, ty,
610 width - GROUP_MARGIN*2 - INDENT, INPUT_HEIGHT,
611 _("Path to X509 CA certificate"));
612 caInput->align(FL_ALIGN_LEFT | FL_ALIGN_TOP);
613 ty += INPUT_HEIGHT + TIGHT_MARGIN;
614
615 ty += INPUT_LABEL_OFFSET;
616 crlInput = new Fl_Input(tx + INDENT, ty,
617 width - GROUP_MARGIN*2 - INDENT, INPUT_HEIGHT,
618 _("Path to X509 CRL file"));
619 crlInput->align(FL_ALIGN_LEFT | FL_ALIGN_TOP);
620 ty += INPUT_HEIGHT + TIGHT_MARGIN;
621 }
622
623 ty += GROUP_MARGIN - TIGHT_MARGIN;
624
625 encryptionGroup->end();
626
627 /* Back to normal */
628 tx = orig_tx;
629 ty += INNER_MARGIN;
630
631 /* Authentication */
Pierre Ossmand463b572011-05-16 12:04:43 +0000632 ty += GROUP_LABEL_OFFSET;
633 height = GROUP_MARGIN * 2 + TIGHT_MARGIN * 2 + CHECK_HEIGHT * 3;
634 authenticationGroup = new Fl_Group(tx, ty, width, height, _("Authentication"));
635 authenticationGroup->box(FL_ENGRAVED_BOX);
636 authenticationGroup->align(FL_ALIGN_LEFT | FL_ALIGN_TOP);
637
638 {
639 tx += GROUP_MARGIN;
640 ty += GROUP_MARGIN;
641
642 authNoneCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
643 CHECK_MIN_WIDTH,
644 CHECK_HEIGHT,
645 _("None")));
646 ty += CHECK_HEIGHT + TIGHT_MARGIN;
647
648 authVncCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
649 CHECK_MIN_WIDTH,
650 CHECK_HEIGHT,
651 _("Standard VNC (insecure without encryption)")));
652 ty += CHECK_HEIGHT + TIGHT_MARGIN;
653
654 authPlainCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
655 CHECK_MIN_WIDTH,
656 CHECK_HEIGHT,
657 _("Username and password (insecure without encryption)")));
658 ty += CHECK_HEIGHT + TIGHT_MARGIN;
659 }
660
661 ty += GROUP_MARGIN - TIGHT_MARGIN;
662
663 authenticationGroup->end();
664
665 /* Back to normal */
666 tx = orig_tx;
667 ty += INNER_MARGIN;
668
669 group->end();
670#endif
671}
672
673
674void OptionsDialog::createInputPage(int tx, int ty, int tw, int th)
675{
676 Fl_Group *group = new Fl_Group(tx, ty, tw, th, _("Input"));
677
678 tx += OUTER_MARGIN;
679 ty += OUTER_MARGIN;
680
681 viewOnlyCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
682 CHECK_MIN_WIDTH,
683 CHECK_HEIGHT,
684 _("View only (ignore mouse and keyboard)")));
685 ty += CHECK_HEIGHT + TIGHT_MARGIN;
686
687 acceptClipboardCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
688 CHECK_MIN_WIDTH,
689 CHECK_HEIGHT,
690 _("Accept clipboard from server")));
691 ty += CHECK_HEIGHT + TIGHT_MARGIN;
692
693 sendClipboardCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
694 CHECK_MIN_WIDTH,
695 CHECK_HEIGHT,
696 _("Send clipboard to server")));
697 ty += CHECK_HEIGHT + TIGHT_MARGIN;
698
699 sendPrimaryCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
700 CHECK_MIN_WIDTH,
701 CHECK_HEIGHT,
702 _("Send primary selection and cut buffer as clipboard")));
703 ty += CHECK_HEIGHT + TIGHT_MARGIN;
704
Pierre Ossman407a5c32011-05-26 14:48:29 +0000705 systemKeysCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
706 CHECK_MIN_WIDTH,
707 CHECK_HEIGHT,
708 _("Pass system keys directly to server (full screen)")));
709 ty += CHECK_HEIGHT + TIGHT_MARGIN;
710
Pierre Ossman4e7271e2011-05-24 12:47:12 +0000711 menuKeyChoice = new Fl_Choice(LBLLEFT(tx, ty, 150, CHOICE_HEIGHT, _("Menu key")));
712
713 menuKeyChoice->add(_("None"), 0, NULL, (void*)0, FL_MENU_DIVIDER);
Martin Koegler498ef462011-09-04 07:04:43 +0000714 for (int i = 0; i < getMenuKeySymbolCount(); i++)
715 menuKeyChoice->add(getMenuKeySymbols()[i].name, 0, NULL, 0, 0);
Pierre Ossman4e7271e2011-05-24 12:47:12 +0000716
717 ty += CHOICE_HEIGHT + TIGHT_MARGIN;
718
Pierre Ossmand463b572011-05-16 12:04:43 +0000719 group->end();
720}
721
722
Pierre Ossman1c2189b2012-07-05 09:23:03 +0000723void OptionsDialog::createScreenPage(int tx, int ty, int tw, int th)
724{
Pierre Ossman9ff733a2012-07-05 11:01:23 +0000725 int x;
726
Pierre Ossman1c2189b2012-07-05 09:23:03 +0000727 Fl_Group *group = new Fl_Group(tx, ty, tw, th, _("Screen"));
728
729 tx += OUTER_MARGIN;
730 ty += OUTER_MARGIN;
731
Pierre Ossman9ff733a2012-07-05 11:01:23 +0000732 desktopSizeCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
733 CHECK_MIN_WIDTH,
734 CHECK_HEIGHT,
735 _("Resize remote session on connect")));
736 desktopSizeCheckbox->callback(handleDesktopSize, this);
737 ty += CHECK_HEIGHT + TIGHT_MARGIN;
738
739 desktopWidthInput = new Fl_Int_Input(tx + INDENT, ty, 50, INPUT_HEIGHT);
740 x = desktopWidthInput->x() + desktopWidthInput->w() + \
741 gui_str_len("x") + 3 * 2;
742 desktopHeightInput = new Fl_Int_Input(x, ty, 50, INPUT_HEIGHT, "x");
743 ty += INPUT_HEIGHT + TIGHT_MARGIN;
744
Pierre Ossman99197012012-07-05 11:06:18 +0000745 remoteResizeCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
746 CHECK_MIN_WIDTH,
747 CHECK_HEIGHT,
748 _("Resize remote session to the local window")));
749 ty += CHECK_HEIGHT + TIGHT_MARGIN;
750
Pierre Ossman1c2189b2012-07-05 09:23:03 +0000751 fullScreenCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
752 CHECK_MIN_WIDTH,
753 CHECK_HEIGHT,
754 _("Full-screen mode")));
755 ty += CHECK_HEIGHT + TIGHT_MARGIN;
756
757 group->end();
758}
759
760
Pierre Ossmand463b572011-05-16 12:04:43 +0000761void OptionsDialog::createMiscPage(int tx, int ty, int tw, int th)
762{
763 Fl_Group *group = new Fl_Group(tx, ty, tw, th, _("Misc."));
764
765 tx += OUTER_MARGIN;
766 ty += OUTER_MARGIN;
767
768 sharedCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
769 CHECK_MIN_WIDTH,
770 CHECK_HEIGHT,
771 _("Shared (don't disconnect other viewers)")));
772 ty += CHECK_HEIGHT + TIGHT_MARGIN;
773
Pierre Ossmand463b572011-05-16 12:04:43 +0000774 dotCursorCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
775 CHECK_MIN_WIDTH,
776 CHECK_HEIGHT,
777 _("Show dot when no cursor")));
778 ty += CHECK_HEIGHT + TIGHT_MARGIN;
779
780 group->end();
781}
782
783
784void OptionsDialog::handleAutoselect(Fl_Widget *widget, void *data)
785{
786 OptionsDialog *dialog = (OptionsDialog*)data;
787
788 if (dialog->autoselectCheckbox->value()) {
789 dialog->encodingGroup->deactivate();
790 dialog->colorlevelGroup->deactivate();
791 } else {
792 dialog->encodingGroup->activate();
793 dialog->colorlevelGroup->activate();
794 }
795
796 // JPEG setting is also affected by autoselection
797 dialog->handleJpeg(dialog->jpegCheckbox, dialog);
798}
799
800
801void OptionsDialog::handleCompression(Fl_Widget *widget, void *data)
802{
803 OptionsDialog *dialog = (OptionsDialog*)data;
804
805 if (dialog->compressionCheckbox->value())
806 dialog->compressionInput->activate();
807 else
808 dialog->compressionInput->deactivate();
809}
810
811
812void OptionsDialog::handleJpeg(Fl_Widget *widget, void *data)
813{
814 OptionsDialog *dialog = (OptionsDialog*)data;
815
816 if (dialog->jpegCheckbox->value() &&
817 !dialog->autoselectCheckbox->value())
818 dialog->jpegInput->activate();
819 else
820 dialog->jpegInput->deactivate();
821}
822
823
Pierre Ossmand463b572011-05-16 12:04:43 +0000824void OptionsDialog::handleX509(Fl_Widget *widget, void *data)
825{
826 OptionsDialog *dialog = (OptionsDialog*)data;
827
828 if (dialog->encX509Checkbox->value()) {
829 dialog->caInput->activate();
830 dialog->crlInput->activate();
831 } else {
832 dialog->caInput->deactivate();
833 dialog->crlInput->deactivate();
834 }
835}
836
837
Pierre Ossman9ff733a2012-07-05 11:01:23 +0000838void OptionsDialog::handleDesktopSize(Fl_Widget *widget, void *data)
839{
840 OptionsDialog *dialog = (OptionsDialog*)data;
841
842 if (dialog->desktopSizeCheckbox->value()) {
843 dialog->desktopWidthInput->activate();
844 dialog->desktopHeightInput->activate();
845 } else {
846 dialog->desktopWidthInput->deactivate();
847 dialog->desktopHeightInput->deactivate();
848 }
849}
850
Pierre Ossmand463b572011-05-16 12:04:43 +0000851void OptionsDialog::handleCancel(Fl_Widget *widget, void *data)
852{
853 OptionsDialog *dialog = (OptionsDialog*)data;
854
855 dialog->hide();
856}
857
858
859void OptionsDialog::handleOK(Fl_Widget *widget, void *data)
860{
861 OptionsDialog *dialog = (OptionsDialog*)data;
862
863 dialog->hide();
864
865 dialog->storeOptions();
866}