You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

OptionsDialog.cxx 27KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894
  1. /* 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. #ifdef HAVE_CONFIG_H
  19. #include <config.h>
  20. #endif
  21. #include <stdlib.h>
  22. #include <list>
  23. #include <rdr/types.h>
  24. #include <rfb/encodings.h>
  25. #ifdef HAVE_GNUTLS
  26. #include <rfb/Security.h>
  27. #include <rfb/SecurityClient.h>
  28. #include <rfb/CSecurityTLS.h>
  29. #endif
  30. #include "OptionsDialog.h"
  31. #include "fltk_layout.h"
  32. #include "i18n.h"
  33. #include "menukey.h"
  34. #include "parameters.h"
  35. #include <FL/Fl_Tabs.H>
  36. #include <FL/Fl_Button.H>
  37. #include <FL/Fl_Check_Button.H>
  38. #include <FL/Fl_Return_Button.H>
  39. #include <FL/Fl_Round_Button.H>
  40. #include <FL/Fl_Int_Input.H>
  41. #include <FL/Fl_Choice.H>
  42. using namespace std;
  43. using namespace rdr;
  44. using namespace rfb;
  45. std::map<OptionsCallback*, void*> OptionsDialog::callbacks;
  46. OptionsDialog::OptionsDialog()
  47. : Fl_Window(450, 450, _("VNC Viewer: Connection Options"))
  48. {
  49. int x, y;
  50. Fl_Button *button;
  51. Fl_Tabs *tabs = new Fl_Tabs(OUTER_MARGIN, OUTER_MARGIN,
  52. w() - OUTER_MARGIN*2,
  53. h() - OUTER_MARGIN*2 - INNER_MARGIN - BUTTON_HEIGHT);
  54. {
  55. int tx, ty, tw, th;
  56. tabs->client_area(tx, ty, tw, th, TABS_HEIGHT);
  57. createCompressionPage(tx, ty, tw, th);
  58. createSecurityPage(tx, ty, tw, th);
  59. createInputPage(tx, ty, tw, th);
  60. createScreenPage(tx, ty, tw, th);
  61. createMiscPage(tx, ty, tw, th);
  62. }
  63. tabs->end();
  64. x = w() - BUTTON_WIDTH * 2 - INNER_MARGIN - OUTER_MARGIN;
  65. y = h() - BUTTON_HEIGHT - OUTER_MARGIN;
  66. button = new Fl_Button(x, y, BUTTON_WIDTH, BUTTON_HEIGHT, _("Cancel"));
  67. button->callback(this->handleCancel, this);
  68. x += BUTTON_WIDTH + INNER_MARGIN;
  69. button = new Fl_Return_Button(x, y, BUTTON_WIDTH, BUTTON_HEIGHT, _("OK"));
  70. button->callback(this->handleOK, this);
  71. callback(this->handleCancel, this);
  72. set_modal();
  73. }
  74. OptionsDialog::~OptionsDialog()
  75. {
  76. }
  77. void OptionsDialog::showDialog(void)
  78. {
  79. static OptionsDialog *dialog = NULL;
  80. if (!dialog)
  81. dialog = new OptionsDialog();
  82. if (dialog->shown())
  83. return;
  84. dialog->show();
  85. }
  86. void OptionsDialog::addCallback(OptionsCallback *cb, void *data)
  87. {
  88. callbacks[cb] = data;
  89. }
  90. void OptionsDialog::removeCallback(OptionsCallback *cb)
  91. {
  92. callbacks.erase(cb);
  93. }
  94. void OptionsDialog::show(void)
  95. {
  96. /* show() gets called for raise events as well */
  97. if (!shown())
  98. loadOptions();
  99. Fl_Window::show();
  100. }
  101. void OptionsDialog::loadOptions(void)
  102. {
  103. /* Compression */
  104. autoselectCheckbox->value(autoSelect);
  105. int encNum = encodingNum(preferredEncoding);
  106. switch (encNum) {
  107. case encodingTight:
  108. tightButton->setonly();
  109. break;
  110. case encodingZRLE:
  111. zrleButton->setonly();
  112. break;
  113. case encodingHextile:
  114. hextileButton->setonly();
  115. break;
  116. case encodingRaw:
  117. rawButton->setonly();
  118. break;
  119. }
  120. if (fullColour)
  121. fullcolorCheckbox->setonly();
  122. else {
  123. switch (lowColourLevel) {
  124. case 0:
  125. verylowcolorCheckbox->setonly();
  126. break;
  127. case 1:
  128. lowcolorCheckbox->setonly();
  129. break;
  130. case 2:
  131. mediumcolorCheckbox->setonly();
  132. break;
  133. }
  134. }
  135. char digit[2] = "0";
  136. compressionCheckbox->value(customCompressLevel);
  137. jpegCheckbox->value(!noJpeg);
  138. digit[0] = '0' + compressLevel;
  139. compressionInput->value(digit);
  140. digit[0] = '0' + qualityLevel;
  141. jpegInput->value(digit);
  142. handleAutoselect(autoselectCheckbox, this);
  143. handleCompression(compressionCheckbox, this);
  144. handleJpeg(jpegCheckbox, this);
  145. #ifdef HAVE_GNUTLS
  146. /* Security */
  147. Security security(SecurityClient::secTypes);
  148. list<U8> secTypes;
  149. list<U8>::iterator iter;
  150. list<U32> secTypesExt;
  151. list<U32>::iterator iterExt;
  152. encNoneCheckbox->value(false);
  153. encTLSCheckbox->value(false);
  154. encX509Checkbox->value(false);
  155. authNoneCheckbox->value(false);
  156. authVncCheckbox->value(false);
  157. authPlainCheckbox->value(false);
  158. secTypes = security.GetEnabledSecTypes();
  159. for (iter = secTypes.begin(); iter != secTypes.end(); ++iter) {
  160. switch (*iter) {
  161. case secTypeNone:
  162. encNoneCheckbox->value(true);
  163. authNoneCheckbox->value(true);
  164. break;
  165. case secTypeVncAuth:
  166. encNoneCheckbox->value(true);
  167. authVncCheckbox->value(true);
  168. break;
  169. }
  170. }
  171. secTypesExt = security.GetEnabledExtSecTypes();
  172. for (iterExt = secTypesExt.begin(); iterExt != secTypesExt.end(); ++iterExt) {
  173. switch (*iterExt) {
  174. case secTypePlain:
  175. encNoneCheckbox->value(true);
  176. authPlainCheckbox->value(true);
  177. break;
  178. case secTypeTLSNone:
  179. encTLSCheckbox->value(true);
  180. authNoneCheckbox->value(true);
  181. break;
  182. case secTypeTLSVnc:
  183. encTLSCheckbox->value(true);
  184. authVncCheckbox->value(true);
  185. break;
  186. case secTypeTLSPlain:
  187. encTLSCheckbox->value(true);
  188. authPlainCheckbox->value(true);
  189. break;
  190. case secTypeX509None:
  191. encX509Checkbox->value(true);
  192. authNoneCheckbox->value(true);
  193. break;
  194. case secTypeX509Vnc:
  195. encX509Checkbox->value(true);
  196. authVncCheckbox->value(true);
  197. break;
  198. case secTypeX509Plain:
  199. encX509Checkbox->value(true);
  200. authPlainCheckbox->value(true);
  201. break;
  202. }
  203. }
  204. caInput->value(CSecurityTLS::X509CA);
  205. crlInput->value(CSecurityTLS::X509CRL);
  206. handleX509(encX509Checkbox, this);
  207. #endif
  208. /* Input */
  209. const char *menuKeyBuf;
  210. viewOnlyCheckbox->value(viewOnly);
  211. acceptClipboardCheckbox->value(acceptClipboard);
  212. sendClipboardCheckbox->value(sendClipboard);
  213. sendPrimaryCheckbox->value(sendPrimary);
  214. systemKeysCheckbox->value(fullscreenSystemKeys);
  215. menuKeyChoice->value(0);
  216. menuKeyBuf = menuKey;
  217. for (int i = 0; i < getMenuKeySymbolCount(); i++)
  218. if (!strcmp(getMenuKeySymbols()[i].name, menuKeyBuf))
  219. menuKeyChoice->value(i + 1);
  220. /* Screen */
  221. int width, height;
  222. if (sscanf(desktopSize.getValueStr(), "%dx%d", &width, &height) != 2) {
  223. desktopSizeCheckbox->value(false);
  224. desktopWidthInput->value("1024");
  225. desktopHeightInput->value("768");
  226. } else {
  227. char buf[32];
  228. desktopSizeCheckbox->value(true);
  229. snprintf(buf, sizeof(buf), "%d", width);
  230. desktopWidthInput->value(buf);
  231. snprintf(buf, sizeof(buf), "%d", height);
  232. desktopHeightInput->value(buf);
  233. }
  234. remoteResizeCheckbox->value(remoteResize);
  235. #ifdef HAVE_FLTK_FULLSCREEN
  236. fullScreenCheckbox->value(fullScreen);
  237. #ifdef HAVE_FLTK_FULLSCREEN_SCREENS
  238. fullScreenAllMonitorsCheckbox->value(fullScreenAllMonitors);
  239. #endif // HAVE_FLTK_FULLSCREEN_SCREENS
  240. #endif // HAVE_FLTK_FULLSCREEN
  241. handleDesktopSize(desktopSizeCheckbox, this);
  242. /* Misc. */
  243. sharedCheckbox->value(shared);
  244. dotCursorCheckbox->value(dotWhenNoCursor);
  245. }
  246. void OptionsDialog::storeOptions(void)
  247. {
  248. /* Compression */
  249. autoSelect.setParam(autoselectCheckbox->value());
  250. if (tightButton->value())
  251. preferredEncoding.setParam(encodingName(encodingTight));
  252. else if (zrleButton->value())
  253. preferredEncoding.setParam(encodingName(encodingZRLE));
  254. else if (hextileButton->value())
  255. preferredEncoding.setParam(encodingName(encodingHextile));
  256. else if (rawButton->value())
  257. preferredEncoding.setParam(encodingName(encodingRaw));
  258. fullColour.setParam(fullcolorCheckbox->value());
  259. if (verylowcolorCheckbox->value())
  260. lowColourLevel.setParam(0);
  261. else if (lowcolorCheckbox->value())
  262. lowColourLevel.setParam(1);
  263. else if (mediumcolorCheckbox->value())
  264. lowColourLevel.setParam(2);
  265. customCompressLevel.setParam(compressionCheckbox->value());
  266. noJpeg.setParam(!jpegCheckbox->value());
  267. compressLevel.setParam(atoi(compressionInput->value()));
  268. qualityLevel.setParam(atoi(jpegInput->value()));
  269. #ifdef HAVE_GNUTLS
  270. /* Security */
  271. Security security;
  272. /* Process security types which don't use encryption */
  273. if (encNoneCheckbox->value()) {
  274. if (authNoneCheckbox->value())
  275. security.EnableSecType(secTypeNone);
  276. if (authVncCheckbox->value())
  277. security.EnableSecType(secTypeVncAuth);
  278. if (authPlainCheckbox->value())
  279. security.EnableSecType(secTypePlain);
  280. }
  281. /* Process security types which use TLS encryption */
  282. if (encTLSCheckbox->value()) {
  283. if (authNoneCheckbox->value())
  284. security.EnableSecType(secTypeTLSNone);
  285. if (authVncCheckbox->value())
  286. security.EnableSecType(secTypeTLSVnc);
  287. if (authPlainCheckbox->value())
  288. security.EnableSecType(secTypeTLSPlain);
  289. }
  290. /* Process security types which use X509 encryption */
  291. if (encX509Checkbox->value()) {
  292. if (authNoneCheckbox->value())
  293. security.EnableSecType(secTypeX509None);
  294. if (authVncCheckbox->value())
  295. security.EnableSecType(secTypeX509Vnc);
  296. if (authPlainCheckbox->value())
  297. security.EnableSecType(secTypeX509Plain);
  298. }
  299. SecurityClient::secTypes.setParam(security.ToString());
  300. CSecurityTLS::X509CA.setParam(caInput->value());
  301. CSecurityTLS::X509CRL.setParam(crlInput->value());
  302. #endif
  303. /* Input */
  304. viewOnly.setParam(viewOnlyCheckbox->value());
  305. acceptClipboard.setParam(acceptClipboardCheckbox->value());
  306. sendClipboard.setParam(sendClipboardCheckbox->value());
  307. sendPrimary.setParam(sendPrimaryCheckbox->value());
  308. fullscreenSystemKeys.setParam(systemKeysCheckbox->value());
  309. if (menuKeyChoice->value() == 0)
  310. menuKey.setParam("");
  311. else {
  312. menuKey.setParam(menuKeyChoice->text());
  313. }
  314. /* Screen */
  315. int width, height;
  316. if (desktopSizeCheckbox->value() &&
  317. (sscanf(desktopWidthInput->value(), "%d", &width) == 1) &&
  318. (sscanf(desktopHeightInput->value(), "%d", &height) == 1)) {
  319. char buf[64];
  320. snprintf(buf, sizeof(buf), "%dx%d", width, height);
  321. desktopSize.setParam(buf);
  322. } else {
  323. desktopSize.setParam("");
  324. }
  325. remoteResize.setParam(remoteResizeCheckbox->value());
  326. #ifdef HAVE_FLTK_FULLSCREEN
  327. fullScreen.setParam(fullScreenCheckbox->value());
  328. #ifdef HAVE_FLTK_FULLSCREEN_SCREENS
  329. fullScreenAllMonitors.setParam(fullScreenAllMonitorsCheckbox->value());
  330. #endif // HAVE_FLTK_FULLSCREEN_SCREENS
  331. #endif // HAVE_FLTK_FULLSCREEN
  332. /* Misc. */
  333. shared.setParam(sharedCheckbox->value());
  334. dotWhenNoCursor.setParam(dotCursorCheckbox->value());
  335. std::map<OptionsCallback*, void*>::const_iterator iter;
  336. for (iter = callbacks.begin();iter != callbacks.end();++iter)
  337. iter->first(iter->second);
  338. }
  339. void OptionsDialog::createCompressionPage(int tx, int ty, int tw, int th)
  340. {
  341. Fl_Group *group = new Fl_Group(tx, ty, tw, th, _("Compression"));
  342. int orig_tx, orig_ty;
  343. int half_width, full_width;
  344. int width, height;
  345. tx += OUTER_MARGIN;
  346. ty += OUTER_MARGIN;
  347. full_width = tw - OUTER_MARGIN * 2;
  348. half_width = (full_width - INNER_MARGIN) / 2;
  349. /* AutoSelect checkbox */
  350. autoselectCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  351. CHECK_MIN_WIDTH,
  352. CHECK_HEIGHT,
  353. _("Auto select")));
  354. autoselectCheckbox->callback(handleAutoselect, this);
  355. ty += CHECK_HEIGHT + INNER_MARGIN;
  356. /* Two columns */
  357. orig_tx = tx;
  358. orig_ty = ty;
  359. /* VNC encoding box */
  360. ty += GROUP_LABEL_OFFSET;
  361. height = GROUP_MARGIN * 2 + TIGHT_MARGIN * 3 + RADIO_HEIGHT * 4;
  362. encodingGroup = new Fl_Group(tx, ty, half_width, height,
  363. _("Preferred encoding"));
  364. encodingGroup->box(FL_ENGRAVED_BOX);
  365. encodingGroup->align(FL_ALIGN_LEFT | FL_ALIGN_TOP);
  366. {
  367. tx += GROUP_MARGIN;
  368. ty += GROUP_MARGIN;
  369. width = encodingGroup->w() - GROUP_MARGIN * 2;
  370. tightButton = new Fl_Round_Button(LBLRIGHT(tx, ty,
  371. RADIO_MIN_WIDTH,
  372. RADIO_HEIGHT,
  373. "Tight"));
  374. tightButton->type(FL_RADIO_BUTTON);
  375. ty += RADIO_HEIGHT + TIGHT_MARGIN;
  376. zrleButton = new Fl_Round_Button(LBLRIGHT(tx, ty,
  377. RADIO_MIN_WIDTH,
  378. RADIO_HEIGHT,
  379. "ZRLE"));
  380. zrleButton->type(FL_RADIO_BUTTON);
  381. ty += RADIO_HEIGHT + TIGHT_MARGIN;
  382. hextileButton = new Fl_Round_Button(LBLRIGHT(tx, ty,
  383. RADIO_MIN_WIDTH,
  384. RADIO_HEIGHT,
  385. "Hextile"));
  386. hextileButton->type(FL_RADIO_BUTTON);
  387. ty += RADIO_HEIGHT + TIGHT_MARGIN;
  388. rawButton = new Fl_Round_Button(LBLRIGHT(tx, ty,
  389. RADIO_MIN_WIDTH,
  390. RADIO_HEIGHT,
  391. "Raw"));
  392. rawButton->type(FL_RADIO_BUTTON);
  393. ty += RADIO_HEIGHT + TIGHT_MARGIN;
  394. }
  395. ty += GROUP_MARGIN - TIGHT_MARGIN;
  396. encodingGroup->end();
  397. /* Second column */
  398. tx = orig_tx + half_width + INNER_MARGIN;
  399. ty = orig_ty;
  400. /* Color box */
  401. ty += GROUP_LABEL_OFFSET;
  402. height = GROUP_MARGIN * 2 + TIGHT_MARGIN * 3 + RADIO_HEIGHT * 4;
  403. colorlevelGroup = new Fl_Group(tx, ty, half_width, height, _("Color level"));
  404. colorlevelGroup->box(FL_ENGRAVED_BOX);
  405. colorlevelGroup->align(FL_ALIGN_LEFT | FL_ALIGN_TOP);
  406. {
  407. tx += GROUP_MARGIN;
  408. ty += GROUP_MARGIN;
  409. width = colorlevelGroup->w() - GROUP_MARGIN * 2;
  410. fullcolorCheckbox = new Fl_Round_Button(LBLRIGHT(tx, ty,
  411. RADIO_MIN_WIDTH,
  412. RADIO_HEIGHT,
  413. _("Full (all available colors)")));
  414. fullcolorCheckbox->type(FL_RADIO_BUTTON);
  415. ty += RADIO_HEIGHT + TIGHT_MARGIN;
  416. mediumcolorCheckbox = new Fl_Round_Button(LBLRIGHT(tx, ty,
  417. RADIO_MIN_WIDTH,
  418. RADIO_HEIGHT,
  419. _("Medium (256 colors)")));
  420. mediumcolorCheckbox->type(FL_RADIO_BUTTON);
  421. ty += RADIO_HEIGHT + TIGHT_MARGIN;
  422. lowcolorCheckbox = new Fl_Round_Button(LBLRIGHT(tx, ty,
  423. RADIO_MIN_WIDTH,
  424. RADIO_HEIGHT,
  425. _("Low (64 colors)")));
  426. lowcolorCheckbox->type(FL_RADIO_BUTTON);
  427. ty += RADIO_HEIGHT + TIGHT_MARGIN;
  428. verylowcolorCheckbox = new Fl_Round_Button(LBLRIGHT(tx, ty,
  429. RADIO_MIN_WIDTH,
  430. RADIO_HEIGHT,
  431. _("Very low (8 colors)")));
  432. verylowcolorCheckbox->type(FL_RADIO_BUTTON);
  433. ty += RADIO_HEIGHT + TIGHT_MARGIN;
  434. }
  435. ty += GROUP_MARGIN - TIGHT_MARGIN;
  436. colorlevelGroup->end();
  437. /* Back to normal */
  438. tx = orig_tx;
  439. ty += INNER_MARGIN;
  440. /* Checkboxes */
  441. compressionCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  442. CHECK_MIN_WIDTH,
  443. CHECK_HEIGHT,
  444. _("Custom compression level:")));
  445. compressionCheckbox->callback(handleCompression, this);
  446. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  447. compressionInput = new Fl_Int_Input(tx + INDENT, ty,
  448. INPUT_HEIGHT, INPUT_HEIGHT,
  449. _("level (1=fast, 6=best [4-6 are rarely useful])"));
  450. compressionInput->align(FL_ALIGN_RIGHT);
  451. ty += INPUT_HEIGHT + INNER_MARGIN;
  452. jpegCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  453. CHECK_MIN_WIDTH,
  454. CHECK_HEIGHT,
  455. _("Allow JPEG compression:")));
  456. jpegCheckbox->callback(handleJpeg, this);
  457. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  458. jpegInput = new Fl_Int_Input(tx + INDENT, ty,
  459. INPUT_HEIGHT, INPUT_HEIGHT,
  460. _("quality (0=poor, 9=best)"));
  461. jpegInput->align(FL_ALIGN_RIGHT);
  462. ty += INPUT_HEIGHT + INNER_MARGIN;
  463. group->end();
  464. }
  465. void OptionsDialog::createSecurityPage(int tx, int ty, int tw, int th)
  466. {
  467. #ifdef HAVE_GNUTLS
  468. Fl_Group *group = new Fl_Group(tx, ty, tw, th, _("Security"));
  469. int orig_tx;
  470. int width, height;
  471. tx += OUTER_MARGIN;
  472. ty += OUTER_MARGIN;
  473. width = tw - OUTER_MARGIN * 2;
  474. orig_tx = tx;
  475. /* Encryption */
  476. ty += GROUP_LABEL_OFFSET;
  477. height = GROUP_MARGIN * 2 + TIGHT_MARGIN * 4 + CHECK_HEIGHT * 3 + (INPUT_LABEL_OFFSET + INPUT_HEIGHT) * 2;
  478. encryptionGroup = new Fl_Group(tx, ty, width, height, _("Encryption"));
  479. encryptionGroup->box(FL_ENGRAVED_BOX);
  480. encryptionGroup->align(FL_ALIGN_LEFT | FL_ALIGN_TOP);
  481. {
  482. tx += GROUP_MARGIN;
  483. ty += GROUP_MARGIN;
  484. encNoneCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  485. CHECK_MIN_WIDTH,
  486. CHECK_HEIGHT,
  487. _("None")));
  488. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  489. encTLSCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  490. CHECK_MIN_WIDTH,
  491. CHECK_HEIGHT,
  492. _("TLS with anonymous certificates")));
  493. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  494. encX509Checkbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  495. CHECK_MIN_WIDTH,
  496. CHECK_HEIGHT,
  497. _("TLS with X509 certificates")));
  498. encX509Checkbox->callback(handleX509, this);
  499. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  500. ty += INPUT_LABEL_OFFSET;
  501. caInput = new Fl_Input(tx + INDENT, ty,
  502. width - GROUP_MARGIN*2 - INDENT, INPUT_HEIGHT,
  503. _("Path to X509 CA certificate"));
  504. caInput->align(FL_ALIGN_LEFT | FL_ALIGN_TOP);
  505. ty += INPUT_HEIGHT + TIGHT_MARGIN;
  506. ty += INPUT_LABEL_OFFSET;
  507. crlInput = new Fl_Input(tx + INDENT, ty,
  508. width - GROUP_MARGIN*2 - INDENT, INPUT_HEIGHT,
  509. _("Path to X509 CRL file"));
  510. crlInput->align(FL_ALIGN_LEFT | FL_ALIGN_TOP);
  511. ty += INPUT_HEIGHT + TIGHT_MARGIN;
  512. }
  513. ty += GROUP_MARGIN - TIGHT_MARGIN;
  514. encryptionGroup->end();
  515. /* Back to normal */
  516. tx = orig_tx;
  517. ty += INNER_MARGIN;
  518. /* Authentication */
  519. ty += GROUP_LABEL_OFFSET;
  520. height = GROUP_MARGIN * 2 + TIGHT_MARGIN * 2 + CHECK_HEIGHT * 3;
  521. authenticationGroup = new Fl_Group(tx, ty, width, height, _("Authentication"));
  522. authenticationGroup->box(FL_ENGRAVED_BOX);
  523. authenticationGroup->align(FL_ALIGN_LEFT | FL_ALIGN_TOP);
  524. {
  525. tx += GROUP_MARGIN;
  526. ty += GROUP_MARGIN;
  527. authNoneCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  528. CHECK_MIN_WIDTH,
  529. CHECK_HEIGHT,
  530. _("None")));
  531. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  532. authVncCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  533. CHECK_MIN_WIDTH,
  534. CHECK_HEIGHT,
  535. _("Standard VNC (insecure without encryption)")));
  536. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  537. authPlainCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  538. CHECK_MIN_WIDTH,
  539. CHECK_HEIGHT,
  540. _("Username and password (insecure without encryption)")));
  541. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  542. }
  543. ty += GROUP_MARGIN - TIGHT_MARGIN;
  544. authenticationGroup->end();
  545. /* Back to normal */
  546. tx = orig_tx;
  547. ty += INNER_MARGIN;
  548. group->end();
  549. #endif
  550. }
  551. void OptionsDialog::createInputPage(int tx, int ty, int tw, int th)
  552. {
  553. Fl_Group *group = new Fl_Group(tx, ty, tw, th, _("Input"));
  554. tx += OUTER_MARGIN;
  555. ty += OUTER_MARGIN;
  556. viewOnlyCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  557. CHECK_MIN_WIDTH,
  558. CHECK_HEIGHT,
  559. _("View only (ignore mouse and keyboard)")));
  560. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  561. acceptClipboardCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  562. CHECK_MIN_WIDTH,
  563. CHECK_HEIGHT,
  564. _("Accept clipboard from server")));
  565. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  566. sendClipboardCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  567. CHECK_MIN_WIDTH,
  568. CHECK_HEIGHT,
  569. _("Send clipboard to server")));
  570. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  571. sendPrimaryCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  572. CHECK_MIN_WIDTH,
  573. CHECK_HEIGHT,
  574. _("Send primary selection and cut buffer as clipboard")));
  575. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  576. systemKeysCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  577. CHECK_MIN_WIDTH,
  578. CHECK_HEIGHT,
  579. _("Pass system keys directly to server (full screen)")));
  580. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  581. menuKeyChoice = new Fl_Choice(LBLLEFT(tx, ty, 150, CHOICE_HEIGHT, _("Menu key")));
  582. menuKeyChoice->add(_("None"), 0, NULL, (void*)0, FL_MENU_DIVIDER);
  583. for (int i = 0; i < getMenuKeySymbolCount(); i++)
  584. menuKeyChoice->add(getMenuKeySymbols()[i].name, 0, NULL, 0, 0);
  585. ty += CHOICE_HEIGHT + TIGHT_MARGIN;
  586. group->end();
  587. }
  588. void OptionsDialog::createScreenPage(int tx, int ty, int tw, int th)
  589. {
  590. int x;
  591. Fl_Group *group = new Fl_Group(tx, ty, tw, th, _("Screen"));
  592. tx += OUTER_MARGIN;
  593. ty += OUTER_MARGIN;
  594. desktopSizeCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  595. CHECK_MIN_WIDTH,
  596. CHECK_HEIGHT,
  597. _("Resize remote session on connect")));
  598. desktopSizeCheckbox->callback(handleDesktopSize, this);
  599. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  600. desktopWidthInput = new Fl_Int_Input(tx + INDENT, ty, 50, INPUT_HEIGHT);
  601. x = desktopWidthInput->x() + desktopWidthInput->w() + \
  602. gui_str_len("x") + 3 * 2;
  603. desktopHeightInput = new Fl_Int_Input(x, ty, 50, INPUT_HEIGHT, "x");
  604. ty += INPUT_HEIGHT + TIGHT_MARGIN;
  605. remoteResizeCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  606. CHECK_MIN_WIDTH,
  607. CHECK_HEIGHT,
  608. _("Resize remote session to the local window")));
  609. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  610. #ifdef HAVE_FLTK_FULLSCREEN
  611. fullScreenCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  612. CHECK_MIN_WIDTH,
  613. CHECK_HEIGHT,
  614. _("Full-screen mode")));
  615. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  616. #ifdef HAVE_FLTK_FULLSCREEN_SCREENS
  617. fullScreenAllMonitorsCheckbox = new Fl_Check_Button(LBLRIGHT(tx + INDENT, ty,
  618. CHECK_MIN_WIDTH,
  619. CHECK_HEIGHT,
  620. _("Enable full-screen mode over all monitors")));
  621. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  622. #endif // HAVE_FLTK_FULLSCREEN_SCREENS
  623. #endif // HAVE_FLTK_FULLSCREEN
  624. group->end();
  625. }
  626. void OptionsDialog::createMiscPage(int tx, int ty, int tw, int th)
  627. {
  628. Fl_Group *group = new Fl_Group(tx, ty, tw, th, _("Misc."));
  629. tx += OUTER_MARGIN;
  630. ty += OUTER_MARGIN;
  631. sharedCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  632. CHECK_MIN_WIDTH,
  633. CHECK_HEIGHT,
  634. _("Shared (don't disconnect other viewers)")));
  635. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  636. dotCursorCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  637. CHECK_MIN_WIDTH,
  638. CHECK_HEIGHT,
  639. _("Show dot when no cursor")));
  640. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  641. group->end();
  642. }
  643. void OptionsDialog::handleAutoselect(Fl_Widget *widget, void *data)
  644. {
  645. OptionsDialog *dialog = (OptionsDialog*)data;
  646. if (dialog->autoselectCheckbox->value()) {
  647. dialog->encodingGroup->deactivate();
  648. dialog->colorlevelGroup->deactivate();
  649. } else {
  650. dialog->encodingGroup->activate();
  651. dialog->colorlevelGroup->activate();
  652. }
  653. // JPEG setting is also affected by autoselection
  654. dialog->handleJpeg(dialog->jpegCheckbox, dialog);
  655. }
  656. void OptionsDialog::handleCompression(Fl_Widget *widget, void *data)
  657. {
  658. OptionsDialog *dialog = (OptionsDialog*)data;
  659. if (dialog->compressionCheckbox->value())
  660. dialog->compressionInput->activate();
  661. else
  662. dialog->compressionInput->deactivate();
  663. }
  664. void OptionsDialog::handleJpeg(Fl_Widget *widget, void *data)
  665. {
  666. OptionsDialog *dialog = (OptionsDialog*)data;
  667. if (dialog->jpegCheckbox->value() &&
  668. !dialog->autoselectCheckbox->value())
  669. dialog->jpegInput->activate();
  670. else
  671. dialog->jpegInput->deactivate();
  672. }
  673. void OptionsDialog::handleX509(Fl_Widget *widget, void *data)
  674. {
  675. OptionsDialog *dialog = (OptionsDialog*)data;
  676. if (dialog->encX509Checkbox->value()) {
  677. dialog->caInput->activate();
  678. dialog->crlInput->activate();
  679. } else {
  680. dialog->caInput->deactivate();
  681. dialog->crlInput->deactivate();
  682. }
  683. }
  684. void OptionsDialog::handleDesktopSize(Fl_Widget *widget, void *data)
  685. {
  686. OptionsDialog *dialog = (OptionsDialog*)data;
  687. if (dialog->desktopSizeCheckbox->value()) {
  688. dialog->desktopWidthInput->activate();
  689. dialog->desktopHeightInput->activate();
  690. } else {
  691. dialog->desktopWidthInput->deactivate();
  692. dialog->desktopHeightInput->deactivate();
  693. }
  694. }
  695. void OptionsDialog::handleCancel(Fl_Widget *widget, void *data)
  696. {
  697. OptionsDialog *dialog = (OptionsDialog*)data;
  698. dialog->hide();
  699. }
  700. void OptionsDialog::handleOK(Fl_Widget *widget, void *data)
  701. {
  702. OptionsDialog *dialog = (OptionsDialog*)data;
  703. dialog->hide();
  704. dialog->storeOptions();
  705. }