blob: f112a529531936a44cc2c59c1417e4762177b356 [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);
Pierre Ossmanf7fef922015-12-10 21:24:08 +0100267#if !defined(WIN32) && !defined(__APPLE__)
Pierre Ossmand463b572011-05-16 12:04:43 +0000268 sendPrimaryCheckbox->value(sendPrimary);
Pierre Ossmanf7fef922015-12-10 21:24:08 +0100269#endif
Pierre Ossman407a5c32011-05-26 14:48:29 +0000270 systemKeysCheckbox->value(fullscreenSystemKeys);
Pierre Ossmand463b572011-05-16 12:04:43 +0000271
Pierre Ossman4e7271e2011-05-24 12:47:12 +0000272 menuKeyChoice->value(0);
273
274 menuKeyBuf = menuKey;
Martin Koegler498ef462011-09-04 07:04:43 +0000275 for (int i = 0; i < getMenuKeySymbolCount(); i++)
276 if (!strcmp(getMenuKeySymbols()[i].name, menuKeyBuf))
277 menuKeyChoice->value(i + 1);
Pierre Ossman4e7271e2011-05-24 12:47:12 +0000278
Pierre Ossman1c2189b2012-07-05 09:23:03 +0000279 /* Screen */
Pierre Ossman9ff733a2012-07-05 11:01:23 +0000280 int width, height;
281
282 if (sscanf(desktopSize.getValueStr(), "%dx%d", &width, &height) != 2) {
283 desktopSizeCheckbox->value(false);
284 desktopWidthInput->value("1024");
285 desktopHeightInput->value("768");
286 } else {
287 char buf[32];
288 desktopSizeCheckbox->value(true);
289 snprintf(buf, sizeof(buf), "%d", width);
290 desktopWidthInput->value(buf);
291 snprintf(buf, sizeof(buf), "%d", height);
292 desktopHeightInput->value(buf);
293 }
Pierre Ossman99197012012-07-05 11:06:18 +0000294 remoteResizeCheckbox->value(remoteResize);
Pierre Ossman1c2189b2012-07-05 09:23:03 +0000295 fullScreenCheckbox->value(fullScreen);
Pierre Ossmanaae38912012-07-13 11:22:55 +0000296 fullScreenAllMonitorsCheckbox->value(fullScreenAllMonitors);
Pierre Ossman1c2189b2012-07-05 09:23:03 +0000297
Pierre Ossman9ff733a2012-07-05 11:01:23 +0000298 handleDesktopSize(desktopSizeCheckbox, this);
299
Pierre Ossmand463b572011-05-16 12:04:43 +0000300 /* Misc. */
301 sharedCheckbox->value(shared);
Pierre Ossmand463b572011-05-16 12:04:43 +0000302 dotCursorCheckbox->value(dotWhenNoCursor);
303}
304
305
306void OptionsDialog::storeOptions(void)
307{
Pierre Ossman61fd4862011-05-16 12:46:51 +0000308 /* Compression */
309 autoSelect.setParam(autoselectCheckbox->value());
310
311 if (tightButton->value())
312 preferredEncoding.setParam(encodingName(encodingTight));
313 else if (zrleButton->value())
314 preferredEncoding.setParam(encodingName(encodingZRLE));
315 else if (hextileButton->value())
316 preferredEncoding.setParam(encodingName(encodingHextile));
317 else if (rawButton->value())
318 preferredEncoding.setParam(encodingName(encodingRaw));
319
320 fullColour.setParam(fullcolorCheckbox->value());
Pierre Ossmancf836f22011-07-14 14:34:09 +0000321 if (verylowcolorCheckbox->value())
Pierre Ossman61fd4862011-05-16 12:46:51 +0000322 lowColourLevel.setParam(0);
323 else if (lowcolorCheckbox->value())
324 lowColourLevel.setParam(1);
Pierre Ossmancf836f22011-07-14 14:34:09 +0000325 else if (mediumcolorCheckbox->value())
Pierre Ossman61fd4862011-05-16 12:46:51 +0000326 lowColourLevel.setParam(2);
327
328 customCompressLevel.setParam(compressionCheckbox->value());
329 noJpeg.setParam(!jpegCheckbox->value());
330 compressLevel.setParam(atoi(compressionInput->value()));
331 qualityLevel.setParam(atoi(jpegInput->value()));
332
333#ifdef HAVE_GNUTLS
334 /* Security */
335 Security security;
336
337 /* Process security types which don't use encryption */
338 if (encNoneCheckbox->value()) {
339 if (authNoneCheckbox->value())
340 security.EnableSecType(secTypeNone);
341 if (authVncCheckbox->value())
342 security.EnableSecType(secTypeVncAuth);
Pierre Ossmanc1764bd2011-09-30 12:26:25 +0000343 if (authPlainCheckbox->value())
344 security.EnableSecType(secTypePlain);
Pierre Ossman61fd4862011-05-16 12:46:51 +0000345 }
346
Pierre Ossmanc1764bd2011-09-30 12:26:25 +0000347 /* Process security types which use TLS encryption */
348 if (encTLSCheckbox->value()) {
349 if (authNoneCheckbox->value())
350 security.EnableSecType(secTypeTLSNone);
351 if (authVncCheckbox->value())
352 security.EnableSecType(secTypeTLSVnc);
353 if (authPlainCheckbox->value())
354 security.EnableSecType(secTypeTLSPlain);
355 }
Pierre Ossman61fd4862011-05-16 12:46:51 +0000356
Pierre Ossmanc1764bd2011-09-30 12:26:25 +0000357 /* Process security types which use X509 encryption */
358 if (encX509Checkbox->value()) {
359 if (authNoneCheckbox->value())
360 security.EnableSecType(secTypeX509None);
361 if (authVncCheckbox->value())
362 security.EnableSecType(secTypeX509Vnc);
363 if (authPlainCheckbox->value())
364 security.EnableSecType(secTypeX509Plain);
Pierre Ossman61fd4862011-05-16 12:46:51 +0000365 }
366
Pierre Ossman5535fe62011-09-30 12:11:52 +0000367 SecurityClient::secTypes.setParam(security.ToString());
368
Pierre Ossman3d2a84b2014-09-17 16:45:35 +0200369 CSecurityTLS::X509CA.setParam(caInput->value());
370 CSecurityTLS::X509CRL.setParam(crlInput->value());
Pierre Ossman61fd4862011-05-16 12:46:51 +0000371#endif
372
373 /* Input */
374 viewOnly.setParam(viewOnlyCheckbox->value());
375 acceptClipboard.setParam(acceptClipboardCheckbox->value());
376 sendClipboard.setParam(sendClipboardCheckbox->value());
Pierre Ossmanf7fef922015-12-10 21:24:08 +0100377#if !defined(WIN32) && !defined(__APPLE__)
Pierre Ossman61fd4862011-05-16 12:46:51 +0000378 sendPrimary.setParam(sendPrimaryCheckbox->value());
Pierre Ossmanf7fef922015-12-10 21:24:08 +0100379#endif
Pierre Ossman407a5c32011-05-26 14:48:29 +0000380 fullscreenSystemKeys.setParam(systemKeysCheckbox->value());
Pierre Ossman61fd4862011-05-16 12:46:51 +0000381
Pierre Ossman4e7271e2011-05-24 12:47:12 +0000382 if (menuKeyChoice->value() == 0)
383 menuKey.setParam("");
384 else {
Martin Koegler498ef462011-09-04 07:04:43 +0000385 menuKey.setParam(menuKeyChoice->text());
Pierre Ossman4e7271e2011-05-24 12:47:12 +0000386 }
387
Pierre Ossman1c2189b2012-07-05 09:23:03 +0000388 /* Screen */
Pierre Ossman9ff733a2012-07-05 11:01:23 +0000389 int width, height;
390
391 if (desktopSizeCheckbox->value() &&
392 (sscanf(desktopWidthInput->value(), "%d", &width) == 1) &&
393 (sscanf(desktopHeightInput->value(), "%d", &height) == 1)) {
394 char buf[64];
395 snprintf(buf, sizeof(buf), "%dx%d", width, height);
396 desktopSize.setParam(buf);
397 } else {
398 desktopSize.setParam("");
399 }
Pierre Ossman99197012012-07-05 11:06:18 +0000400 remoteResize.setParam(remoteResizeCheckbox->value());
Pierre Ossman1c2189b2012-07-05 09:23:03 +0000401 fullScreen.setParam(fullScreenCheckbox->value());
Pierre Ossmanaae38912012-07-13 11:22:55 +0000402 fullScreenAllMonitors.setParam(fullScreenAllMonitorsCheckbox->value());
Pierre Ossman1c2189b2012-07-05 09:23:03 +0000403
Pierre Ossman61fd4862011-05-16 12:46:51 +0000404 /* Misc. */
405 shared.setParam(sharedCheckbox->value());
Pierre Ossman61fd4862011-05-16 12:46:51 +0000406 dotWhenNoCursor.setParam(dotCursorCheckbox->value());
Pierre Ossman0c41e1d2011-05-17 09:36:04 +0000407
408 std::map<OptionsCallback*, void*>::const_iterator iter;
409
410 for (iter = callbacks.begin();iter != callbacks.end();++iter)
411 iter->first(iter->second);
Pierre Ossmand463b572011-05-16 12:04:43 +0000412}
413
414
415void OptionsDialog::createCompressionPage(int tx, int ty, int tw, int th)
416{
417 Fl_Group *group = new Fl_Group(tx, ty, tw, th, _("Compression"));
418
419 int orig_tx, orig_ty;
420 int half_width, full_width;
Pierre Ossmaneb955322015-03-03 16:10:53 +0100421 int height;
Pierre Ossmand463b572011-05-16 12:04:43 +0000422
423 tx += OUTER_MARGIN;
424 ty += OUTER_MARGIN;
425
426 full_width = tw - OUTER_MARGIN * 2;
427 half_width = (full_width - INNER_MARGIN) / 2;
428
429 /* AutoSelect checkbox */
430 autoselectCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
431 CHECK_MIN_WIDTH,
432 CHECK_HEIGHT,
433 _("Auto select")));
434 autoselectCheckbox->callback(handleAutoselect, this);
435 ty += CHECK_HEIGHT + INNER_MARGIN;
436
437 /* Two columns */
438 orig_tx = tx;
439 orig_ty = ty;
440
441 /* VNC encoding box */
442 ty += GROUP_LABEL_OFFSET;
443 height = GROUP_MARGIN * 2 + TIGHT_MARGIN * 3 + RADIO_HEIGHT * 4;
444 encodingGroup = new Fl_Group(tx, ty, half_width, height,
445 _("Preferred encoding"));
446 encodingGroup->box(FL_ENGRAVED_BOX);
447 encodingGroup->align(FL_ALIGN_LEFT | FL_ALIGN_TOP);
448
449 {
450 tx += GROUP_MARGIN;
451 ty += GROUP_MARGIN;
452
Pierre Ossmand463b572011-05-16 12:04:43 +0000453 tightButton = new Fl_Round_Button(LBLRIGHT(tx, ty,
454 RADIO_MIN_WIDTH,
455 RADIO_HEIGHT,
Peter Åstrand4c446002011-08-15 12:33:06 +0000456 "Tight"));
Pierre Ossmand463b572011-05-16 12:04:43 +0000457 tightButton->type(FL_RADIO_BUTTON);
458 ty += RADIO_HEIGHT + TIGHT_MARGIN;
459
460 zrleButton = new Fl_Round_Button(LBLRIGHT(tx, ty,
461 RADIO_MIN_WIDTH,
462 RADIO_HEIGHT,
Peter Åstrand4c446002011-08-15 12:33:06 +0000463 "ZRLE"));
Pierre Ossmand463b572011-05-16 12:04:43 +0000464 zrleButton->type(FL_RADIO_BUTTON);
465 ty += RADIO_HEIGHT + TIGHT_MARGIN;
466
467 hextileButton = new Fl_Round_Button(LBLRIGHT(tx, ty,
468 RADIO_MIN_WIDTH,
469 RADIO_HEIGHT,
Peter Åstrand4c446002011-08-15 12:33:06 +0000470 "Hextile"));
Pierre Ossmand463b572011-05-16 12:04:43 +0000471 hextileButton->type(FL_RADIO_BUTTON);
472 ty += RADIO_HEIGHT + TIGHT_MARGIN;
473
474 rawButton = new Fl_Round_Button(LBLRIGHT(tx, ty,
475 RADIO_MIN_WIDTH,
476 RADIO_HEIGHT,
Peter Åstrand4c446002011-08-15 12:33:06 +0000477 "Raw"));
Pierre Ossmand463b572011-05-16 12:04:43 +0000478 rawButton->type(FL_RADIO_BUTTON);
479 ty += RADIO_HEIGHT + TIGHT_MARGIN;
480 }
481
482 ty += GROUP_MARGIN - TIGHT_MARGIN;
483
484 encodingGroup->end();
485
486 /* Second column */
487 tx = orig_tx + half_width + INNER_MARGIN;
488 ty = orig_ty;
489
490 /* Color box */
491 ty += GROUP_LABEL_OFFSET;
492 height = GROUP_MARGIN * 2 + TIGHT_MARGIN * 3 + RADIO_HEIGHT * 4;
493 colorlevelGroup = new Fl_Group(tx, ty, half_width, height, _("Color level"));
494 colorlevelGroup->box(FL_ENGRAVED_BOX);
495 colorlevelGroup->align(FL_ALIGN_LEFT | FL_ALIGN_TOP);
496
497 {
498 tx += GROUP_MARGIN;
499 ty += GROUP_MARGIN;
500
Pierre Ossmand463b572011-05-16 12:04:43 +0000501 fullcolorCheckbox = new Fl_Round_Button(LBLRIGHT(tx, ty,
502 RADIO_MIN_WIDTH,
503 RADIO_HEIGHT,
504 _("Full (all available colors)")));
505 fullcolorCheckbox->type(FL_RADIO_BUTTON);
506 ty += RADIO_HEIGHT + TIGHT_MARGIN;
507
508 mediumcolorCheckbox = new Fl_Round_Button(LBLRIGHT(tx, ty,
509 RADIO_MIN_WIDTH,
510 RADIO_HEIGHT,
511 _("Medium (256 colors)")));
512 mediumcolorCheckbox->type(FL_RADIO_BUTTON);
513 ty += RADIO_HEIGHT + TIGHT_MARGIN;
514
515 lowcolorCheckbox = new Fl_Round_Button(LBLRIGHT(tx, ty,
516 RADIO_MIN_WIDTH,
517 RADIO_HEIGHT,
518 _("Low (64 colors)")));
519 lowcolorCheckbox->type(FL_RADIO_BUTTON);
520 ty += RADIO_HEIGHT + TIGHT_MARGIN;
521
522 verylowcolorCheckbox = new Fl_Round_Button(LBLRIGHT(tx, ty,
523 RADIO_MIN_WIDTH,
524 RADIO_HEIGHT,
525 _("Very low (8 colors)")));
526 verylowcolorCheckbox->type(FL_RADIO_BUTTON);
527 ty += RADIO_HEIGHT + TIGHT_MARGIN;
528 }
529
530 ty += GROUP_MARGIN - TIGHT_MARGIN;
531
532 colorlevelGroup->end();
533
534 /* Back to normal */
535 tx = orig_tx;
536 ty += INNER_MARGIN;
537
538 /* Checkboxes */
539 compressionCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
540 CHECK_MIN_WIDTH,
541 CHECK_HEIGHT,
542 _("Custom compression level:")));
543 compressionCheckbox->callback(handleCompression, this);
544 ty += CHECK_HEIGHT + TIGHT_MARGIN;
545
546 compressionInput = new Fl_Int_Input(tx + INDENT, ty,
547 INPUT_HEIGHT, INPUT_HEIGHT,
DRCba7bc512011-08-17 02:30:34 +0000548 _("level (1=fast, 6=best [4-6 are rarely useful])"));
Pierre Ossmand463b572011-05-16 12:04:43 +0000549 compressionInput->align(FL_ALIGN_RIGHT);
550 ty += INPUT_HEIGHT + INNER_MARGIN;
551
552 jpegCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
553 CHECK_MIN_WIDTH,
554 CHECK_HEIGHT,
555 _("Allow JPEG compression:")));
556 jpegCheckbox->callback(handleJpeg, this);
557 ty += CHECK_HEIGHT + TIGHT_MARGIN;
558
559 jpegInput = new Fl_Int_Input(tx + INDENT, ty,
560 INPUT_HEIGHT, INPUT_HEIGHT,
DRC41036ed2011-08-23 20:36:50 +0000561 _("quality (0=poor, 9=best)"));
Pierre Ossmand463b572011-05-16 12:04:43 +0000562 jpegInput->align(FL_ALIGN_RIGHT);
563 ty += INPUT_HEIGHT + INNER_MARGIN;
564
565 group->end();
566}
567
568
569void OptionsDialog::createSecurityPage(int tx, int ty, int tw, int th)
570{
571#ifdef HAVE_GNUTLS
572 Fl_Group *group = new Fl_Group(tx, ty, tw, th, _("Security"));
573
574 int orig_tx;
575 int width, height;
576
577 tx += OUTER_MARGIN;
578 ty += OUTER_MARGIN;
579
580 width = tw - OUTER_MARGIN * 2;
581
582 orig_tx = tx;
583
Pierre Ossmand463b572011-05-16 12:04:43 +0000584 /* Encryption */
585 ty += GROUP_LABEL_OFFSET;
586 height = GROUP_MARGIN * 2 + TIGHT_MARGIN * 4 + CHECK_HEIGHT * 3 + (INPUT_LABEL_OFFSET + INPUT_HEIGHT) * 2;
587 encryptionGroup = new Fl_Group(tx, ty, width, height, _("Encryption"));
588 encryptionGroup->box(FL_ENGRAVED_BOX);
589 encryptionGroup->align(FL_ALIGN_LEFT | FL_ALIGN_TOP);
590
591 {
592 tx += GROUP_MARGIN;
593 ty += GROUP_MARGIN;
594
595 encNoneCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
596 CHECK_MIN_WIDTH,
597 CHECK_HEIGHT,
598 _("None")));
599 ty += CHECK_HEIGHT + TIGHT_MARGIN;
600
601 encTLSCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
602 CHECK_MIN_WIDTH,
603 CHECK_HEIGHT,
604 _("TLS with anonymous certificates")));
605 ty += CHECK_HEIGHT + TIGHT_MARGIN;
606
607 encX509Checkbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
608 CHECK_MIN_WIDTH,
609 CHECK_HEIGHT,
610 _("TLS with X509 certificates")));
611 encX509Checkbox->callback(handleX509, this);
612 ty += CHECK_HEIGHT + TIGHT_MARGIN;
613
614 ty += INPUT_LABEL_OFFSET;
615 caInput = new Fl_Input(tx + INDENT, ty,
616 width - GROUP_MARGIN*2 - INDENT, INPUT_HEIGHT,
617 _("Path to X509 CA certificate"));
618 caInput->align(FL_ALIGN_LEFT | FL_ALIGN_TOP);
619 ty += INPUT_HEIGHT + TIGHT_MARGIN;
620
621 ty += INPUT_LABEL_OFFSET;
622 crlInput = new Fl_Input(tx + INDENT, ty,
623 width - GROUP_MARGIN*2 - INDENT, INPUT_HEIGHT,
624 _("Path to X509 CRL file"));
625 crlInput->align(FL_ALIGN_LEFT | FL_ALIGN_TOP);
626 ty += INPUT_HEIGHT + TIGHT_MARGIN;
627 }
628
629 ty += GROUP_MARGIN - TIGHT_MARGIN;
630
631 encryptionGroup->end();
632
633 /* Back to normal */
634 tx = orig_tx;
635 ty += INNER_MARGIN;
636
637 /* Authentication */
Pierre Ossmand463b572011-05-16 12:04:43 +0000638 ty += GROUP_LABEL_OFFSET;
639 height = GROUP_MARGIN * 2 + TIGHT_MARGIN * 2 + CHECK_HEIGHT * 3;
640 authenticationGroup = new Fl_Group(tx, ty, width, height, _("Authentication"));
641 authenticationGroup->box(FL_ENGRAVED_BOX);
642 authenticationGroup->align(FL_ALIGN_LEFT | FL_ALIGN_TOP);
643
644 {
645 tx += GROUP_MARGIN;
646 ty += GROUP_MARGIN;
647
648 authNoneCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
649 CHECK_MIN_WIDTH,
650 CHECK_HEIGHT,
651 _("None")));
652 ty += CHECK_HEIGHT + TIGHT_MARGIN;
653
654 authVncCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
655 CHECK_MIN_WIDTH,
656 CHECK_HEIGHT,
657 _("Standard VNC (insecure without encryption)")));
658 ty += CHECK_HEIGHT + TIGHT_MARGIN;
659
660 authPlainCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
661 CHECK_MIN_WIDTH,
662 CHECK_HEIGHT,
663 _("Username and password (insecure without encryption)")));
664 ty += CHECK_HEIGHT + TIGHT_MARGIN;
665 }
666
667 ty += GROUP_MARGIN - TIGHT_MARGIN;
668
669 authenticationGroup->end();
670
671 /* Back to normal */
672 tx = orig_tx;
673 ty += INNER_MARGIN;
674
675 group->end();
676#endif
677}
678
679
680void OptionsDialog::createInputPage(int tx, int ty, int tw, int th)
681{
682 Fl_Group *group = new Fl_Group(tx, ty, tw, th, _("Input"));
683
684 tx += OUTER_MARGIN;
685 ty += OUTER_MARGIN;
686
687 viewOnlyCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
688 CHECK_MIN_WIDTH,
689 CHECK_HEIGHT,
690 _("View only (ignore mouse and keyboard)")));
691 ty += CHECK_HEIGHT + TIGHT_MARGIN;
692
693 acceptClipboardCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
694 CHECK_MIN_WIDTH,
695 CHECK_HEIGHT,
696 _("Accept clipboard from server")));
697 ty += CHECK_HEIGHT + TIGHT_MARGIN;
698
699 sendClipboardCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
700 CHECK_MIN_WIDTH,
701 CHECK_HEIGHT,
702 _("Send clipboard to server")));
703 ty += CHECK_HEIGHT + TIGHT_MARGIN;
704
Pierre Ossmanf7fef922015-12-10 21:24:08 +0100705#if !defined(WIN32) && !defined(__APPLE__)
Pierre Ossmand463b572011-05-16 12:04:43 +0000706 sendPrimaryCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
707 CHECK_MIN_WIDTH,
708 CHECK_HEIGHT,
709 _("Send primary selection and cut buffer as clipboard")));
710 ty += CHECK_HEIGHT + TIGHT_MARGIN;
Pierre Ossmanf7fef922015-12-10 21:24:08 +0100711#endif
Pierre Ossmand463b572011-05-16 12:04:43 +0000712
Pierre Ossman407a5c32011-05-26 14:48:29 +0000713 systemKeysCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
714 CHECK_MIN_WIDTH,
715 CHECK_HEIGHT,
716 _("Pass system keys directly to server (full screen)")));
717 ty += CHECK_HEIGHT + TIGHT_MARGIN;
718
Pierre Ossman4e7271e2011-05-24 12:47:12 +0000719 menuKeyChoice = new Fl_Choice(LBLLEFT(tx, ty, 150, CHOICE_HEIGHT, _("Menu key")));
720
Pierre Ossman245c8022015-02-25 11:27:49 +0100721 fltk_menu_add(menuKeyChoice, _("None"), 0, NULL, (void*)0, FL_MENU_DIVIDER);
Martin Koegler498ef462011-09-04 07:04:43 +0000722 for (int i = 0; i < getMenuKeySymbolCount(); i++)
Pierre Ossman245c8022015-02-25 11:27:49 +0100723 fltk_menu_add(menuKeyChoice, getMenuKeySymbols()[i].name, 0, NULL, 0, 0);
Pierre Ossman4e7271e2011-05-24 12:47:12 +0000724
725 ty += CHOICE_HEIGHT + TIGHT_MARGIN;
726
Pierre Ossmand463b572011-05-16 12:04:43 +0000727 group->end();
728}
729
730
Pierre Ossman1c2189b2012-07-05 09:23:03 +0000731void OptionsDialog::createScreenPage(int tx, int ty, int tw, int th)
732{
Pierre Ossman9ff733a2012-07-05 11:01:23 +0000733 int x;
734
Pierre Ossman1c2189b2012-07-05 09:23:03 +0000735 Fl_Group *group = new Fl_Group(tx, ty, tw, th, _("Screen"));
736
737 tx += OUTER_MARGIN;
738 ty += OUTER_MARGIN;
739
Pierre Ossman9ff733a2012-07-05 11:01:23 +0000740 desktopSizeCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
741 CHECK_MIN_WIDTH,
742 CHECK_HEIGHT,
743 _("Resize remote session on connect")));
744 desktopSizeCheckbox->callback(handleDesktopSize, this);
745 ty += CHECK_HEIGHT + TIGHT_MARGIN;
746
747 desktopWidthInput = new Fl_Int_Input(tx + INDENT, ty, 50, INPUT_HEIGHT);
748 x = desktopWidthInput->x() + desktopWidthInput->w() + \
749 gui_str_len("x") + 3 * 2;
750 desktopHeightInput = new Fl_Int_Input(x, ty, 50, INPUT_HEIGHT, "x");
751 ty += INPUT_HEIGHT + TIGHT_MARGIN;
752
Pierre Ossman99197012012-07-05 11:06:18 +0000753 remoteResizeCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
754 CHECK_MIN_WIDTH,
755 CHECK_HEIGHT,
756 _("Resize remote session to the local window")));
757 ty += CHECK_HEIGHT + TIGHT_MARGIN;
758
Pierre Ossman1c2189b2012-07-05 09:23:03 +0000759 fullScreenCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
760 CHECK_MIN_WIDTH,
761 CHECK_HEIGHT,
762 _("Full-screen mode")));
763 ty += CHECK_HEIGHT + TIGHT_MARGIN;
764
Pierre Ossmanaae38912012-07-13 11:22:55 +0000765 fullScreenAllMonitorsCheckbox = new Fl_Check_Button(LBLRIGHT(tx + INDENT, ty,
766 CHECK_MIN_WIDTH,
767 CHECK_HEIGHT,
768 _("Enable full-screen mode over all monitors")));
769 ty += CHECK_HEIGHT + TIGHT_MARGIN;
770
Pierre Ossman1c2189b2012-07-05 09:23:03 +0000771 group->end();
772}
773
774
Pierre Ossmand463b572011-05-16 12:04:43 +0000775void OptionsDialog::createMiscPage(int tx, int ty, int tw, int th)
776{
777 Fl_Group *group = new Fl_Group(tx, ty, tw, th, _("Misc."));
778
779 tx += OUTER_MARGIN;
780 ty += OUTER_MARGIN;
781
782 sharedCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
783 CHECK_MIN_WIDTH,
784 CHECK_HEIGHT,
785 _("Shared (don't disconnect other viewers)")));
786 ty += CHECK_HEIGHT + TIGHT_MARGIN;
787
Pierre Ossmand463b572011-05-16 12:04:43 +0000788 dotCursorCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
789 CHECK_MIN_WIDTH,
790 CHECK_HEIGHT,
791 _("Show dot when no cursor")));
792 ty += CHECK_HEIGHT + TIGHT_MARGIN;
793
794 group->end();
795}
796
797
798void OptionsDialog::handleAutoselect(Fl_Widget *widget, void *data)
799{
800 OptionsDialog *dialog = (OptionsDialog*)data;
801
802 if (dialog->autoselectCheckbox->value()) {
803 dialog->encodingGroup->deactivate();
804 dialog->colorlevelGroup->deactivate();
805 } else {
806 dialog->encodingGroup->activate();
807 dialog->colorlevelGroup->activate();
808 }
809
810 // JPEG setting is also affected by autoselection
811 dialog->handleJpeg(dialog->jpegCheckbox, dialog);
812}
813
814
815void OptionsDialog::handleCompression(Fl_Widget *widget, void *data)
816{
817 OptionsDialog *dialog = (OptionsDialog*)data;
818
819 if (dialog->compressionCheckbox->value())
820 dialog->compressionInput->activate();
821 else
822 dialog->compressionInput->deactivate();
823}
824
825
826void OptionsDialog::handleJpeg(Fl_Widget *widget, void *data)
827{
828 OptionsDialog *dialog = (OptionsDialog*)data;
829
830 if (dialog->jpegCheckbox->value() &&
831 !dialog->autoselectCheckbox->value())
832 dialog->jpegInput->activate();
833 else
834 dialog->jpegInput->deactivate();
835}
836
837
Pierre Ossmand463b572011-05-16 12:04:43 +0000838void OptionsDialog::handleX509(Fl_Widget *widget, void *data)
839{
840 OptionsDialog *dialog = (OptionsDialog*)data;
841
842 if (dialog->encX509Checkbox->value()) {
843 dialog->caInput->activate();
844 dialog->crlInput->activate();
845 } else {
846 dialog->caInput->deactivate();
847 dialog->crlInput->deactivate();
848 }
849}
850
851
Pierre Ossman9ff733a2012-07-05 11:01:23 +0000852void OptionsDialog::handleDesktopSize(Fl_Widget *widget, void *data)
853{
854 OptionsDialog *dialog = (OptionsDialog*)data;
855
856 if (dialog->desktopSizeCheckbox->value()) {
857 dialog->desktopWidthInput->activate();
858 dialog->desktopHeightInput->activate();
859 } else {
860 dialog->desktopWidthInput->deactivate();
861 dialog->desktopHeightInput->deactivate();
862 }
863}
864
Pierre Ossmand463b572011-05-16 12:04:43 +0000865void OptionsDialog::handleCancel(Fl_Widget *widget, void *data)
866{
867 OptionsDialog *dialog = (OptionsDialog*)data;
868
869 dialog->hide();
870}
871
872
873void OptionsDialog::handleOK(Fl_Widget *widget, void *data)
874{
875 OptionsDialog *dialog = (OptionsDialog*)data;
876
877 dialog->hide();
878
879 dialog->storeOptions();
880}