blob: df9f3554ccafe3e7f4b756f31cc47a4418680282 [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 Ossman2441e822012-07-10 11:11:23 +0000289#ifdef HAVE_FLTK_FULLSCREEN
Pierre Ossman1c2189b2012-07-05 09:23:03 +0000290 fullScreenCheckbox->value(fullScreen);
Pierre Ossmanaae38912012-07-13 11:22:55 +0000291#ifdef HAVE_FLTK_FULLSCREEN_SCREENS
292 fullScreenAllMonitorsCheckbox->value(fullScreenAllMonitors);
293#endif // HAVE_FLTK_FULLSCREEN_SCREENS
Pierre Ossman2441e822012-07-10 11:11:23 +0000294#endif // HAVE_FLTK_FULLSCREEN
Pierre Ossman1c2189b2012-07-05 09:23:03 +0000295
Pierre Ossman9ff733a2012-07-05 11:01:23 +0000296 handleDesktopSize(desktopSizeCheckbox, this);
297
Pierre Ossmand463b572011-05-16 12:04:43 +0000298 /* Misc. */
299 sharedCheckbox->value(shared);
Pierre Ossmand463b572011-05-16 12:04:43 +0000300 dotCursorCheckbox->value(dotWhenNoCursor);
301}
302
303
304void OptionsDialog::storeOptions(void)
305{
Pierre Ossman61fd4862011-05-16 12:46:51 +0000306 /* Compression */
307 autoSelect.setParam(autoselectCheckbox->value());
308
309 if (tightButton->value())
310 preferredEncoding.setParam(encodingName(encodingTight));
311 else if (zrleButton->value())
312 preferredEncoding.setParam(encodingName(encodingZRLE));
313 else if (hextileButton->value())
314 preferredEncoding.setParam(encodingName(encodingHextile));
315 else if (rawButton->value())
316 preferredEncoding.setParam(encodingName(encodingRaw));
317
318 fullColour.setParam(fullcolorCheckbox->value());
Pierre Ossmancf836f22011-07-14 14:34:09 +0000319 if (verylowcolorCheckbox->value())
Pierre Ossman61fd4862011-05-16 12:46:51 +0000320 lowColourLevel.setParam(0);
321 else if (lowcolorCheckbox->value())
322 lowColourLevel.setParam(1);
Pierre Ossmancf836f22011-07-14 14:34:09 +0000323 else if (mediumcolorCheckbox->value())
Pierre Ossman61fd4862011-05-16 12:46:51 +0000324 lowColourLevel.setParam(2);
325
326 customCompressLevel.setParam(compressionCheckbox->value());
327 noJpeg.setParam(!jpegCheckbox->value());
328 compressLevel.setParam(atoi(compressionInput->value()));
329 qualityLevel.setParam(atoi(jpegInput->value()));
330
331#ifdef HAVE_GNUTLS
332 /* Security */
333 Security security;
334
335 /* Process security types which don't use encryption */
336 if (encNoneCheckbox->value()) {
337 if (authNoneCheckbox->value())
338 security.EnableSecType(secTypeNone);
339 if (authVncCheckbox->value())
340 security.EnableSecType(secTypeVncAuth);
Pierre Ossmanc1764bd2011-09-30 12:26:25 +0000341 if (authPlainCheckbox->value())
342 security.EnableSecType(secTypePlain);
Pierre Ossman61fd4862011-05-16 12:46:51 +0000343 }
344
Pierre Ossmanc1764bd2011-09-30 12:26:25 +0000345 /* Process security types which use TLS encryption */
346 if (encTLSCheckbox->value()) {
347 if (authNoneCheckbox->value())
348 security.EnableSecType(secTypeTLSNone);
349 if (authVncCheckbox->value())
350 security.EnableSecType(secTypeTLSVnc);
351 if (authPlainCheckbox->value())
352 security.EnableSecType(secTypeTLSPlain);
353 }
Pierre Ossman61fd4862011-05-16 12:46:51 +0000354
Pierre Ossmanc1764bd2011-09-30 12:26:25 +0000355 /* Process security types which use X509 encryption */
356 if (encX509Checkbox->value()) {
357 if (authNoneCheckbox->value())
358 security.EnableSecType(secTypeX509None);
359 if (authVncCheckbox->value())
360 security.EnableSecType(secTypeX509Vnc);
361 if (authPlainCheckbox->value())
362 security.EnableSecType(secTypeX509Plain);
Pierre Ossman61fd4862011-05-16 12:46:51 +0000363 }
364
Pierre Ossman5535fe62011-09-30 12:11:52 +0000365 SecurityClient::secTypes.setParam(security.ToString());
366
Pierre Ossman61fd4862011-05-16 12:46:51 +0000367 CSecurityTLS::x509ca.setParam(caInput->value());
368 CSecurityTLS::x509crl.setParam(crlInput->value());
369#endif
370
371 /* Input */
372 viewOnly.setParam(viewOnlyCheckbox->value());
373 acceptClipboard.setParam(acceptClipboardCheckbox->value());
374 sendClipboard.setParam(sendClipboardCheckbox->value());
375 sendPrimary.setParam(sendPrimaryCheckbox->value());
Pierre Ossman407a5c32011-05-26 14:48:29 +0000376 fullscreenSystemKeys.setParam(systemKeysCheckbox->value());
Pierre Ossman61fd4862011-05-16 12:46:51 +0000377
Pierre Ossman4e7271e2011-05-24 12:47:12 +0000378 if (menuKeyChoice->value() == 0)
379 menuKey.setParam("");
380 else {
Martin Koegler498ef462011-09-04 07:04:43 +0000381 menuKey.setParam(menuKeyChoice->text());
Pierre Ossman4e7271e2011-05-24 12:47:12 +0000382 }
383
Pierre Ossman1c2189b2012-07-05 09:23:03 +0000384 /* Screen */
Pierre Ossman9ff733a2012-07-05 11:01:23 +0000385 int width, height;
386
387 if (desktopSizeCheckbox->value() &&
388 (sscanf(desktopWidthInput->value(), "%d", &width) == 1) &&
389 (sscanf(desktopHeightInput->value(), "%d", &height) == 1)) {
390 char buf[64];
391 snprintf(buf, sizeof(buf), "%dx%d", width, height);
392 desktopSize.setParam(buf);
393 } else {
394 desktopSize.setParam("");
395 }
Pierre Ossman99197012012-07-05 11:06:18 +0000396 remoteResize.setParam(remoteResizeCheckbox->value());
Pierre Ossman2441e822012-07-10 11:11:23 +0000397#ifdef HAVE_FLTK_FULLSCREEN
Pierre Ossman1c2189b2012-07-05 09:23:03 +0000398 fullScreen.setParam(fullScreenCheckbox->value());
Pierre Ossmanaae38912012-07-13 11:22:55 +0000399#ifdef HAVE_FLTK_FULLSCREEN_SCREENS
400 fullScreenAllMonitors.setParam(fullScreenAllMonitorsCheckbox->value());
401#endif // HAVE_FLTK_FULLSCREEN_SCREENS
Pierre Ossman2441e822012-07-10 11:11:23 +0000402#endif // HAVE_FLTK_FULLSCREEN
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;
421 int width, height;
422
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
453 width = encodingGroup->w() - GROUP_MARGIN * 2;
454
455 tightButton = new Fl_Round_Button(LBLRIGHT(tx, ty,
456 RADIO_MIN_WIDTH,
457 RADIO_HEIGHT,
Peter Åstrand4c446002011-08-15 12:33:06 +0000458 "Tight"));
Pierre Ossmand463b572011-05-16 12:04:43 +0000459 tightButton->type(FL_RADIO_BUTTON);
460 ty += RADIO_HEIGHT + TIGHT_MARGIN;
461
462 zrleButton = new Fl_Round_Button(LBLRIGHT(tx, ty,
463 RADIO_MIN_WIDTH,
464 RADIO_HEIGHT,
Peter Åstrand4c446002011-08-15 12:33:06 +0000465 "ZRLE"));
Pierre Ossmand463b572011-05-16 12:04:43 +0000466 zrleButton->type(FL_RADIO_BUTTON);
467 ty += RADIO_HEIGHT + TIGHT_MARGIN;
468
469 hextileButton = new Fl_Round_Button(LBLRIGHT(tx, ty,
470 RADIO_MIN_WIDTH,
471 RADIO_HEIGHT,
Peter Åstrand4c446002011-08-15 12:33:06 +0000472 "Hextile"));
Pierre Ossmand463b572011-05-16 12:04:43 +0000473 hextileButton->type(FL_RADIO_BUTTON);
474 ty += RADIO_HEIGHT + TIGHT_MARGIN;
475
476 rawButton = new Fl_Round_Button(LBLRIGHT(tx, ty,
477 RADIO_MIN_WIDTH,
478 RADIO_HEIGHT,
Peter Åstrand4c446002011-08-15 12:33:06 +0000479 "Raw"));
Pierre Ossmand463b572011-05-16 12:04:43 +0000480 rawButton->type(FL_RADIO_BUTTON);
481 ty += RADIO_HEIGHT + TIGHT_MARGIN;
482 }
483
484 ty += GROUP_MARGIN - TIGHT_MARGIN;
485
486 encodingGroup->end();
487
488 /* Second column */
489 tx = orig_tx + half_width + INNER_MARGIN;
490 ty = orig_ty;
491
492 /* Color box */
493 ty += GROUP_LABEL_OFFSET;
494 height = GROUP_MARGIN * 2 + TIGHT_MARGIN * 3 + RADIO_HEIGHT * 4;
495 colorlevelGroup = new Fl_Group(tx, ty, half_width, height, _("Color level"));
496 colorlevelGroup->box(FL_ENGRAVED_BOX);
497 colorlevelGroup->align(FL_ALIGN_LEFT | FL_ALIGN_TOP);
498
499 {
500 tx += GROUP_MARGIN;
501 ty += GROUP_MARGIN;
502
503 width = colorlevelGroup->w() - GROUP_MARGIN * 2;
504
505 fullcolorCheckbox = new Fl_Round_Button(LBLRIGHT(tx, ty,
506 RADIO_MIN_WIDTH,
507 RADIO_HEIGHT,
508 _("Full (all available colors)")));
509 fullcolorCheckbox->type(FL_RADIO_BUTTON);
510 ty += RADIO_HEIGHT + TIGHT_MARGIN;
511
512 mediumcolorCheckbox = new Fl_Round_Button(LBLRIGHT(tx, ty,
513 RADIO_MIN_WIDTH,
514 RADIO_HEIGHT,
515 _("Medium (256 colors)")));
516 mediumcolorCheckbox->type(FL_RADIO_BUTTON);
517 ty += RADIO_HEIGHT + TIGHT_MARGIN;
518
519 lowcolorCheckbox = new Fl_Round_Button(LBLRIGHT(tx, ty,
520 RADIO_MIN_WIDTH,
521 RADIO_HEIGHT,
522 _("Low (64 colors)")));
523 lowcolorCheckbox->type(FL_RADIO_BUTTON);
524 ty += RADIO_HEIGHT + TIGHT_MARGIN;
525
526 verylowcolorCheckbox = new Fl_Round_Button(LBLRIGHT(tx, ty,
527 RADIO_MIN_WIDTH,
528 RADIO_HEIGHT,
529 _("Very low (8 colors)")));
530 verylowcolorCheckbox->type(FL_RADIO_BUTTON);
531 ty += RADIO_HEIGHT + TIGHT_MARGIN;
532 }
533
534 ty += GROUP_MARGIN - TIGHT_MARGIN;
535
536 colorlevelGroup->end();
537
538 /* Back to normal */
539 tx = orig_tx;
540 ty += INNER_MARGIN;
541
542 /* Checkboxes */
543 compressionCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
544 CHECK_MIN_WIDTH,
545 CHECK_HEIGHT,
546 _("Custom compression level:")));
547 compressionCheckbox->callback(handleCompression, this);
548 ty += CHECK_HEIGHT + TIGHT_MARGIN;
549
550 compressionInput = new Fl_Int_Input(tx + INDENT, ty,
551 INPUT_HEIGHT, INPUT_HEIGHT,
DRCba7bc512011-08-17 02:30:34 +0000552 _("level (1=fast, 6=best [4-6 are rarely useful])"));
Pierre Ossmand463b572011-05-16 12:04:43 +0000553 compressionInput->align(FL_ALIGN_RIGHT);
554 ty += INPUT_HEIGHT + INNER_MARGIN;
555
556 jpegCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
557 CHECK_MIN_WIDTH,
558 CHECK_HEIGHT,
559 _("Allow JPEG compression:")));
560 jpegCheckbox->callback(handleJpeg, this);
561 ty += CHECK_HEIGHT + TIGHT_MARGIN;
562
563 jpegInput = new Fl_Int_Input(tx + INDENT, ty,
564 INPUT_HEIGHT, INPUT_HEIGHT,
DRC41036ed2011-08-23 20:36:50 +0000565 _("quality (0=poor, 9=best)"));
Pierre Ossmand463b572011-05-16 12:04:43 +0000566 jpegInput->align(FL_ALIGN_RIGHT);
567 ty += INPUT_HEIGHT + INNER_MARGIN;
568
569 group->end();
570}
571
572
573void OptionsDialog::createSecurityPage(int tx, int ty, int tw, int th)
574{
575#ifdef HAVE_GNUTLS
576 Fl_Group *group = new Fl_Group(tx, ty, tw, th, _("Security"));
577
578 int orig_tx;
579 int width, height;
580
581 tx += OUTER_MARGIN;
582 ty += OUTER_MARGIN;
583
584 width = tw - OUTER_MARGIN * 2;
585
586 orig_tx = tx;
587
Pierre Ossmand463b572011-05-16 12:04:43 +0000588 /* Encryption */
589 ty += GROUP_LABEL_OFFSET;
590 height = GROUP_MARGIN * 2 + TIGHT_MARGIN * 4 + CHECK_HEIGHT * 3 + (INPUT_LABEL_OFFSET + INPUT_HEIGHT) * 2;
591 encryptionGroup = new Fl_Group(tx, ty, width, height, _("Encryption"));
592 encryptionGroup->box(FL_ENGRAVED_BOX);
593 encryptionGroup->align(FL_ALIGN_LEFT | FL_ALIGN_TOP);
594
595 {
596 tx += GROUP_MARGIN;
597 ty += GROUP_MARGIN;
598
599 encNoneCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
600 CHECK_MIN_WIDTH,
601 CHECK_HEIGHT,
602 _("None")));
603 ty += CHECK_HEIGHT + TIGHT_MARGIN;
604
605 encTLSCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
606 CHECK_MIN_WIDTH,
607 CHECK_HEIGHT,
608 _("TLS with anonymous certificates")));
609 ty += CHECK_HEIGHT + TIGHT_MARGIN;
610
611 encX509Checkbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
612 CHECK_MIN_WIDTH,
613 CHECK_HEIGHT,
614 _("TLS with X509 certificates")));
615 encX509Checkbox->callback(handleX509, this);
616 ty += CHECK_HEIGHT + TIGHT_MARGIN;
617
618 ty += INPUT_LABEL_OFFSET;
619 caInput = new Fl_Input(tx + INDENT, ty,
620 width - GROUP_MARGIN*2 - INDENT, INPUT_HEIGHT,
621 _("Path to X509 CA certificate"));
622 caInput->align(FL_ALIGN_LEFT | FL_ALIGN_TOP);
623 ty += INPUT_HEIGHT + TIGHT_MARGIN;
624
625 ty += INPUT_LABEL_OFFSET;
626 crlInput = new Fl_Input(tx + INDENT, ty,
627 width - GROUP_MARGIN*2 - INDENT, INPUT_HEIGHT,
628 _("Path to X509 CRL file"));
629 crlInput->align(FL_ALIGN_LEFT | FL_ALIGN_TOP);
630 ty += INPUT_HEIGHT + TIGHT_MARGIN;
631 }
632
633 ty += GROUP_MARGIN - TIGHT_MARGIN;
634
635 encryptionGroup->end();
636
637 /* Back to normal */
638 tx = orig_tx;
639 ty += INNER_MARGIN;
640
641 /* Authentication */
Pierre Ossmand463b572011-05-16 12:04:43 +0000642 ty += GROUP_LABEL_OFFSET;
643 height = GROUP_MARGIN * 2 + TIGHT_MARGIN * 2 + CHECK_HEIGHT * 3;
644 authenticationGroup = new Fl_Group(tx, ty, width, height, _("Authentication"));
645 authenticationGroup->box(FL_ENGRAVED_BOX);
646 authenticationGroup->align(FL_ALIGN_LEFT | FL_ALIGN_TOP);
647
648 {
649 tx += GROUP_MARGIN;
650 ty += GROUP_MARGIN;
651
652 authNoneCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
653 CHECK_MIN_WIDTH,
654 CHECK_HEIGHT,
655 _("None")));
656 ty += CHECK_HEIGHT + TIGHT_MARGIN;
657
658 authVncCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
659 CHECK_MIN_WIDTH,
660 CHECK_HEIGHT,
661 _("Standard VNC (insecure without encryption)")));
662 ty += CHECK_HEIGHT + TIGHT_MARGIN;
663
664 authPlainCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
665 CHECK_MIN_WIDTH,
666 CHECK_HEIGHT,
667 _("Username and password (insecure without encryption)")));
668 ty += CHECK_HEIGHT + TIGHT_MARGIN;
669 }
670
671 ty += GROUP_MARGIN - TIGHT_MARGIN;
672
673 authenticationGroup->end();
674
675 /* Back to normal */
676 tx = orig_tx;
677 ty += INNER_MARGIN;
678
679 group->end();
680#endif
681}
682
683
684void OptionsDialog::createInputPage(int tx, int ty, int tw, int th)
685{
686 Fl_Group *group = new Fl_Group(tx, ty, tw, th, _("Input"));
687
688 tx += OUTER_MARGIN;
689 ty += OUTER_MARGIN;
690
691 viewOnlyCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
692 CHECK_MIN_WIDTH,
693 CHECK_HEIGHT,
694 _("View only (ignore mouse and keyboard)")));
695 ty += CHECK_HEIGHT + TIGHT_MARGIN;
696
697 acceptClipboardCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
698 CHECK_MIN_WIDTH,
699 CHECK_HEIGHT,
700 _("Accept clipboard from server")));
701 ty += CHECK_HEIGHT + TIGHT_MARGIN;
702
703 sendClipboardCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
704 CHECK_MIN_WIDTH,
705 CHECK_HEIGHT,
706 _("Send clipboard to server")));
707 ty += CHECK_HEIGHT + TIGHT_MARGIN;
708
709 sendPrimaryCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
710 CHECK_MIN_WIDTH,
711 CHECK_HEIGHT,
712 _("Send primary selection and cut buffer as clipboard")));
713 ty += CHECK_HEIGHT + TIGHT_MARGIN;
714
Pierre Ossman407a5c32011-05-26 14:48:29 +0000715 systemKeysCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
716 CHECK_MIN_WIDTH,
717 CHECK_HEIGHT,
718 _("Pass system keys directly to server (full screen)")));
719 ty += CHECK_HEIGHT + TIGHT_MARGIN;
720
Pierre Ossman4e7271e2011-05-24 12:47:12 +0000721 menuKeyChoice = new Fl_Choice(LBLLEFT(tx, ty, 150, CHOICE_HEIGHT, _("Menu key")));
722
723 menuKeyChoice->add(_("None"), 0, NULL, (void*)0, FL_MENU_DIVIDER);
Martin Koegler498ef462011-09-04 07:04:43 +0000724 for (int i = 0; i < getMenuKeySymbolCount(); i++)
725 menuKeyChoice->add(getMenuKeySymbols()[i].name, 0, NULL, 0, 0);
Pierre Ossman4e7271e2011-05-24 12:47:12 +0000726
727 ty += CHOICE_HEIGHT + TIGHT_MARGIN;
728
Pierre Ossmand463b572011-05-16 12:04:43 +0000729 group->end();
730}
731
732
Pierre Ossman1c2189b2012-07-05 09:23:03 +0000733void OptionsDialog::createScreenPage(int tx, int ty, int tw, int th)
734{
Pierre Ossman9ff733a2012-07-05 11:01:23 +0000735 int x;
736
Pierre Ossman1c2189b2012-07-05 09:23:03 +0000737 Fl_Group *group = new Fl_Group(tx, ty, tw, th, _("Screen"));
738
739 tx += OUTER_MARGIN;
740 ty += OUTER_MARGIN;
741
Pierre Ossman9ff733a2012-07-05 11:01:23 +0000742 desktopSizeCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
743 CHECK_MIN_WIDTH,
744 CHECK_HEIGHT,
745 _("Resize remote session on connect")));
746 desktopSizeCheckbox->callback(handleDesktopSize, this);
747 ty += CHECK_HEIGHT + TIGHT_MARGIN;
748
749 desktopWidthInput = new Fl_Int_Input(tx + INDENT, ty, 50, INPUT_HEIGHT);
750 x = desktopWidthInput->x() + desktopWidthInput->w() + \
751 gui_str_len("x") + 3 * 2;
752 desktopHeightInput = new Fl_Int_Input(x, ty, 50, INPUT_HEIGHT, "x");
753 ty += INPUT_HEIGHT + TIGHT_MARGIN;
754
Pierre Ossman99197012012-07-05 11:06:18 +0000755 remoteResizeCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
756 CHECK_MIN_WIDTH,
757 CHECK_HEIGHT,
758 _("Resize remote session to the local window")));
759 ty += CHECK_HEIGHT + TIGHT_MARGIN;
760
Pierre Ossman2441e822012-07-10 11:11:23 +0000761#ifdef HAVE_FLTK_FULLSCREEN
762
Pierre Ossman1c2189b2012-07-05 09:23:03 +0000763 fullScreenCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
764 CHECK_MIN_WIDTH,
765 CHECK_HEIGHT,
766 _("Full-screen mode")));
767 ty += CHECK_HEIGHT + TIGHT_MARGIN;
768
Pierre Ossmanaae38912012-07-13 11:22:55 +0000769#ifdef HAVE_FLTK_FULLSCREEN_SCREENS
770
771 fullScreenAllMonitorsCheckbox = new Fl_Check_Button(LBLRIGHT(tx + INDENT, ty,
772 CHECK_MIN_WIDTH,
773 CHECK_HEIGHT,
774 _("Enable full-screen mode over all monitors")));
775 ty += CHECK_HEIGHT + TIGHT_MARGIN;
776
777#endif // HAVE_FLTK_FULLSCREEN_SCREENS
778
Pierre Ossman2441e822012-07-10 11:11:23 +0000779#endif // HAVE_FLTK_FULLSCREEN
780
Pierre Ossman1c2189b2012-07-05 09:23:03 +0000781 group->end();
782}
783
784
Pierre Ossmand463b572011-05-16 12:04:43 +0000785void OptionsDialog::createMiscPage(int tx, int ty, int tw, int th)
786{
787 Fl_Group *group = new Fl_Group(tx, ty, tw, th, _("Misc."));
788
789 tx += OUTER_MARGIN;
790 ty += OUTER_MARGIN;
791
792 sharedCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
793 CHECK_MIN_WIDTH,
794 CHECK_HEIGHT,
795 _("Shared (don't disconnect other viewers)")));
796 ty += CHECK_HEIGHT + TIGHT_MARGIN;
797
Pierre Ossmand463b572011-05-16 12:04:43 +0000798 dotCursorCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
799 CHECK_MIN_WIDTH,
800 CHECK_HEIGHT,
801 _("Show dot when no cursor")));
802 ty += CHECK_HEIGHT + TIGHT_MARGIN;
803
804 group->end();
805}
806
807
808void OptionsDialog::handleAutoselect(Fl_Widget *widget, void *data)
809{
810 OptionsDialog *dialog = (OptionsDialog*)data;
811
812 if (dialog->autoselectCheckbox->value()) {
813 dialog->encodingGroup->deactivate();
814 dialog->colorlevelGroup->deactivate();
815 } else {
816 dialog->encodingGroup->activate();
817 dialog->colorlevelGroup->activate();
818 }
819
820 // JPEG setting is also affected by autoselection
821 dialog->handleJpeg(dialog->jpegCheckbox, dialog);
822}
823
824
825void OptionsDialog::handleCompression(Fl_Widget *widget, void *data)
826{
827 OptionsDialog *dialog = (OptionsDialog*)data;
828
829 if (dialog->compressionCheckbox->value())
830 dialog->compressionInput->activate();
831 else
832 dialog->compressionInput->deactivate();
833}
834
835
836void OptionsDialog::handleJpeg(Fl_Widget *widget, void *data)
837{
838 OptionsDialog *dialog = (OptionsDialog*)data;
839
840 if (dialog->jpegCheckbox->value() &&
841 !dialog->autoselectCheckbox->value())
842 dialog->jpegInput->activate();
843 else
844 dialog->jpegInput->deactivate();
845}
846
847
Pierre Ossmand463b572011-05-16 12:04:43 +0000848void OptionsDialog::handleX509(Fl_Widget *widget, void *data)
849{
850 OptionsDialog *dialog = (OptionsDialog*)data;
851
852 if (dialog->encX509Checkbox->value()) {
853 dialog->caInput->activate();
854 dialog->crlInput->activate();
855 } else {
856 dialog->caInput->deactivate();
857 dialog->crlInput->deactivate();
858 }
859}
860
861
Pierre Ossman9ff733a2012-07-05 11:01:23 +0000862void OptionsDialog::handleDesktopSize(Fl_Widget *widget, void *data)
863{
864 OptionsDialog *dialog = (OptionsDialog*)data;
865
866 if (dialog->desktopSizeCheckbox->value()) {
867 dialog->desktopWidthInput->activate();
868 dialog->desktopHeightInput->activate();
869 } else {
870 dialog->desktopWidthInput->deactivate();
871 dialog->desktopHeightInput->deactivate();
872 }
873}
874
Pierre Ossmand463b572011-05-16 12:04:43 +0000875void OptionsDialog::handleCancel(Fl_Widget *widget, void *data)
876{
877 OptionsDialog *dialog = (OptionsDialog*)data;
878
879 dialog->hide();
880}
881
882
883void OptionsDialog::handleOK(Fl_Widget *widget, void *data)
884{
885 OptionsDialog *dialog = (OptionsDialog*)data;
886
887 dialog->hide();
888
889 dialog->storeOptions();
890}