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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890
  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 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. tightButton = new Fl_Round_Button(LBLRIGHT(tx, ty,
  370. RADIO_MIN_WIDTH,
  371. RADIO_HEIGHT,
  372. "Tight"));
  373. tightButton->type(FL_RADIO_BUTTON);
  374. ty += RADIO_HEIGHT + TIGHT_MARGIN;
  375. zrleButton = new Fl_Round_Button(LBLRIGHT(tx, ty,
  376. RADIO_MIN_WIDTH,
  377. RADIO_HEIGHT,
  378. "ZRLE"));
  379. zrleButton->type(FL_RADIO_BUTTON);
  380. ty += RADIO_HEIGHT + TIGHT_MARGIN;
  381. hextileButton = new Fl_Round_Button(LBLRIGHT(tx, ty,
  382. RADIO_MIN_WIDTH,
  383. RADIO_HEIGHT,
  384. "Hextile"));
  385. hextileButton->type(FL_RADIO_BUTTON);
  386. ty += RADIO_HEIGHT + TIGHT_MARGIN;
  387. rawButton = new Fl_Round_Button(LBLRIGHT(tx, ty,
  388. RADIO_MIN_WIDTH,
  389. RADIO_HEIGHT,
  390. "Raw"));
  391. rawButton->type(FL_RADIO_BUTTON);
  392. ty += RADIO_HEIGHT + TIGHT_MARGIN;
  393. }
  394. ty += GROUP_MARGIN - TIGHT_MARGIN;
  395. encodingGroup->end();
  396. /* Second column */
  397. tx = orig_tx + half_width + INNER_MARGIN;
  398. ty = orig_ty;
  399. /* Color box */
  400. ty += GROUP_LABEL_OFFSET;
  401. height = GROUP_MARGIN * 2 + TIGHT_MARGIN * 3 + RADIO_HEIGHT * 4;
  402. colorlevelGroup = new Fl_Group(tx, ty, half_width, height, _("Color level"));
  403. colorlevelGroup->box(FL_ENGRAVED_BOX);
  404. colorlevelGroup->align(FL_ALIGN_LEFT | FL_ALIGN_TOP);
  405. {
  406. tx += GROUP_MARGIN;
  407. ty += GROUP_MARGIN;
  408. fullcolorCheckbox = new Fl_Round_Button(LBLRIGHT(tx, ty,
  409. RADIO_MIN_WIDTH,
  410. RADIO_HEIGHT,
  411. _("Full (all available colors)")));
  412. fullcolorCheckbox->type(FL_RADIO_BUTTON);
  413. ty += RADIO_HEIGHT + TIGHT_MARGIN;
  414. mediumcolorCheckbox = new Fl_Round_Button(LBLRIGHT(tx, ty,
  415. RADIO_MIN_WIDTH,
  416. RADIO_HEIGHT,
  417. _("Medium (256 colors)")));
  418. mediumcolorCheckbox->type(FL_RADIO_BUTTON);
  419. ty += RADIO_HEIGHT + TIGHT_MARGIN;
  420. lowcolorCheckbox = new Fl_Round_Button(LBLRIGHT(tx, ty,
  421. RADIO_MIN_WIDTH,
  422. RADIO_HEIGHT,
  423. _("Low (64 colors)")));
  424. lowcolorCheckbox->type(FL_RADIO_BUTTON);
  425. ty += RADIO_HEIGHT + TIGHT_MARGIN;
  426. verylowcolorCheckbox = new Fl_Round_Button(LBLRIGHT(tx, ty,
  427. RADIO_MIN_WIDTH,
  428. RADIO_HEIGHT,
  429. _("Very low (8 colors)")));
  430. verylowcolorCheckbox->type(FL_RADIO_BUTTON);
  431. ty += RADIO_HEIGHT + TIGHT_MARGIN;
  432. }
  433. ty += GROUP_MARGIN - TIGHT_MARGIN;
  434. colorlevelGroup->end();
  435. /* Back to normal */
  436. tx = orig_tx;
  437. ty += INNER_MARGIN;
  438. /* Checkboxes */
  439. compressionCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  440. CHECK_MIN_WIDTH,
  441. CHECK_HEIGHT,
  442. _("Custom compression level:")));
  443. compressionCheckbox->callback(handleCompression, this);
  444. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  445. compressionInput = new Fl_Int_Input(tx + INDENT, ty,
  446. INPUT_HEIGHT, INPUT_HEIGHT,
  447. _("level (1=fast, 6=best [4-6 are rarely useful])"));
  448. compressionInput->align(FL_ALIGN_RIGHT);
  449. ty += INPUT_HEIGHT + INNER_MARGIN;
  450. jpegCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  451. CHECK_MIN_WIDTH,
  452. CHECK_HEIGHT,
  453. _("Allow JPEG compression:")));
  454. jpegCheckbox->callback(handleJpeg, this);
  455. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  456. jpegInput = new Fl_Int_Input(tx + INDENT, ty,
  457. INPUT_HEIGHT, INPUT_HEIGHT,
  458. _("quality (0=poor, 9=best)"));
  459. jpegInput->align(FL_ALIGN_RIGHT);
  460. ty += INPUT_HEIGHT + INNER_MARGIN;
  461. group->end();
  462. }
  463. void OptionsDialog::createSecurityPage(int tx, int ty, int tw, int th)
  464. {
  465. #ifdef HAVE_GNUTLS
  466. Fl_Group *group = new Fl_Group(tx, ty, tw, th, _("Security"));
  467. int orig_tx;
  468. int width, height;
  469. tx += OUTER_MARGIN;
  470. ty += OUTER_MARGIN;
  471. width = tw - OUTER_MARGIN * 2;
  472. orig_tx = tx;
  473. /* Encryption */
  474. ty += GROUP_LABEL_OFFSET;
  475. height = GROUP_MARGIN * 2 + TIGHT_MARGIN * 4 + CHECK_HEIGHT * 3 + (INPUT_LABEL_OFFSET + INPUT_HEIGHT) * 2;
  476. encryptionGroup = new Fl_Group(tx, ty, width, height, _("Encryption"));
  477. encryptionGroup->box(FL_ENGRAVED_BOX);
  478. encryptionGroup->align(FL_ALIGN_LEFT | FL_ALIGN_TOP);
  479. {
  480. tx += GROUP_MARGIN;
  481. ty += GROUP_MARGIN;
  482. encNoneCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  483. CHECK_MIN_WIDTH,
  484. CHECK_HEIGHT,
  485. _("None")));
  486. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  487. encTLSCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  488. CHECK_MIN_WIDTH,
  489. CHECK_HEIGHT,
  490. _("TLS with anonymous certificates")));
  491. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  492. encX509Checkbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  493. CHECK_MIN_WIDTH,
  494. CHECK_HEIGHT,
  495. _("TLS with X509 certificates")));
  496. encX509Checkbox->callback(handleX509, this);
  497. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  498. ty += INPUT_LABEL_OFFSET;
  499. caInput = new Fl_Input(tx + INDENT, ty,
  500. width - GROUP_MARGIN*2 - INDENT, INPUT_HEIGHT,
  501. _("Path to X509 CA certificate"));
  502. caInput->align(FL_ALIGN_LEFT | FL_ALIGN_TOP);
  503. ty += INPUT_HEIGHT + TIGHT_MARGIN;
  504. ty += INPUT_LABEL_OFFSET;
  505. crlInput = new Fl_Input(tx + INDENT, ty,
  506. width - GROUP_MARGIN*2 - INDENT, INPUT_HEIGHT,
  507. _("Path to X509 CRL file"));
  508. crlInput->align(FL_ALIGN_LEFT | FL_ALIGN_TOP);
  509. ty += INPUT_HEIGHT + TIGHT_MARGIN;
  510. }
  511. ty += GROUP_MARGIN - TIGHT_MARGIN;
  512. encryptionGroup->end();
  513. /* Back to normal */
  514. tx = orig_tx;
  515. ty += INNER_MARGIN;
  516. /* Authentication */
  517. ty += GROUP_LABEL_OFFSET;
  518. height = GROUP_MARGIN * 2 + TIGHT_MARGIN * 2 + CHECK_HEIGHT * 3;
  519. authenticationGroup = new Fl_Group(tx, ty, width, height, _("Authentication"));
  520. authenticationGroup->box(FL_ENGRAVED_BOX);
  521. authenticationGroup->align(FL_ALIGN_LEFT | FL_ALIGN_TOP);
  522. {
  523. tx += GROUP_MARGIN;
  524. ty += GROUP_MARGIN;
  525. authNoneCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  526. CHECK_MIN_WIDTH,
  527. CHECK_HEIGHT,
  528. _("None")));
  529. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  530. authVncCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  531. CHECK_MIN_WIDTH,
  532. CHECK_HEIGHT,
  533. _("Standard VNC (insecure without encryption)")));
  534. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  535. authPlainCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  536. CHECK_MIN_WIDTH,
  537. CHECK_HEIGHT,
  538. _("Username and password (insecure without encryption)")));
  539. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  540. }
  541. ty += GROUP_MARGIN - TIGHT_MARGIN;
  542. authenticationGroup->end();
  543. /* Back to normal */
  544. tx = orig_tx;
  545. ty += INNER_MARGIN;
  546. group->end();
  547. #endif
  548. }
  549. void OptionsDialog::createInputPage(int tx, int ty, int tw, int th)
  550. {
  551. Fl_Group *group = new Fl_Group(tx, ty, tw, th, _("Input"));
  552. tx += OUTER_MARGIN;
  553. ty += OUTER_MARGIN;
  554. viewOnlyCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  555. CHECK_MIN_WIDTH,
  556. CHECK_HEIGHT,
  557. _("View only (ignore mouse and keyboard)")));
  558. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  559. acceptClipboardCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  560. CHECK_MIN_WIDTH,
  561. CHECK_HEIGHT,
  562. _("Accept clipboard from server")));
  563. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  564. sendClipboardCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  565. CHECK_MIN_WIDTH,
  566. CHECK_HEIGHT,
  567. _("Send clipboard to server")));
  568. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  569. sendPrimaryCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  570. CHECK_MIN_WIDTH,
  571. CHECK_HEIGHT,
  572. _("Send primary selection and cut buffer as clipboard")));
  573. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  574. systemKeysCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  575. CHECK_MIN_WIDTH,
  576. CHECK_HEIGHT,
  577. _("Pass system keys directly to server (full screen)")));
  578. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  579. menuKeyChoice = new Fl_Choice(LBLLEFT(tx, ty, 150, CHOICE_HEIGHT, _("Menu key")));
  580. fltk_menu_add(menuKeyChoice, _("None"), 0, NULL, (void*)0, FL_MENU_DIVIDER);
  581. for (int i = 0; i < getMenuKeySymbolCount(); i++)
  582. fltk_menu_add(menuKeyChoice, getMenuKeySymbols()[i].name, 0, NULL, 0, 0);
  583. ty += CHOICE_HEIGHT + TIGHT_MARGIN;
  584. group->end();
  585. }
  586. void OptionsDialog::createScreenPage(int tx, int ty, int tw, int th)
  587. {
  588. int x;
  589. Fl_Group *group = new Fl_Group(tx, ty, tw, th, _("Screen"));
  590. tx += OUTER_MARGIN;
  591. ty += OUTER_MARGIN;
  592. desktopSizeCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  593. CHECK_MIN_WIDTH,
  594. CHECK_HEIGHT,
  595. _("Resize remote session on connect")));
  596. desktopSizeCheckbox->callback(handleDesktopSize, this);
  597. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  598. desktopWidthInput = new Fl_Int_Input(tx + INDENT, ty, 50, INPUT_HEIGHT);
  599. x = desktopWidthInput->x() + desktopWidthInput->w() + \
  600. gui_str_len("x") + 3 * 2;
  601. desktopHeightInput = new Fl_Int_Input(x, ty, 50, INPUT_HEIGHT, "x");
  602. ty += INPUT_HEIGHT + TIGHT_MARGIN;
  603. remoteResizeCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  604. CHECK_MIN_WIDTH,
  605. CHECK_HEIGHT,
  606. _("Resize remote session to the local window")));
  607. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  608. #ifdef HAVE_FLTK_FULLSCREEN
  609. fullScreenCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  610. CHECK_MIN_WIDTH,
  611. CHECK_HEIGHT,
  612. _("Full-screen mode")));
  613. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  614. #ifdef HAVE_FLTK_FULLSCREEN_SCREENS
  615. fullScreenAllMonitorsCheckbox = new Fl_Check_Button(LBLRIGHT(tx + INDENT, ty,
  616. CHECK_MIN_WIDTH,
  617. CHECK_HEIGHT,
  618. _("Enable full-screen mode over all monitors")));
  619. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  620. #endif // HAVE_FLTK_FULLSCREEN_SCREENS
  621. #endif // HAVE_FLTK_FULLSCREEN
  622. group->end();
  623. }
  624. void OptionsDialog::createMiscPage(int tx, int ty, int tw, int th)
  625. {
  626. Fl_Group *group = new Fl_Group(tx, ty, tw, th, _("Misc."));
  627. tx += OUTER_MARGIN;
  628. ty += OUTER_MARGIN;
  629. sharedCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  630. CHECK_MIN_WIDTH,
  631. CHECK_HEIGHT,
  632. _("Shared (don't disconnect other viewers)")));
  633. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  634. dotCursorCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  635. CHECK_MIN_WIDTH,
  636. CHECK_HEIGHT,
  637. _("Show dot when no cursor")));
  638. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  639. group->end();
  640. }
  641. void OptionsDialog::handleAutoselect(Fl_Widget *widget, void *data)
  642. {
  643. OptionsDialog *dialog = (OptionsDialog*)data;
  644. if (dialog->autoselectCheckbox->value()) {
  645. dialog->encodingGroup->deactivate();
  646. dialog->colorlevelGroup->deactivate();
  647. } else {
  648. dialog->encodingGroup->activate();
  649. dialog->colorlevelGroup->activate();
  650. }
  651. // JPEG setting is also affected by autoselection
  652. dialog->handleJpeg(dialog->jpegCheckbox, dialog);
  653. }
  654. void OptionsDialog::handleCompression(Fl_Widget *widget, void *data)
  655. {
  656. OptionsDialog *dialog = (OptionsDialog*)data;
  657. if (dialog->compressionCheckbox->value())
  658. dialog->compressionInput->activate();
  659. else
  660. dialog->compressionInput->deactivate();
  661. }
  662. void OptionsDialog::handleJpeg(Fl_Widget *widget, void *data)
  663. {
  664. OptionsDialog *dialog = (OptionsDialog*)data;
  665. if (dialog->jpegCheckbox->value() &&
  666. !dialog->autoselectCheckbox->value())
  667. dialog->jpegInput->activate();
  668. else
  669. dialog->jpegInput->deactivate();
  670. }
  671. void OptionsDialog::handleX509(Fl_Widget *widget, void *data)
  672. {
  673. OptionsDialog *dialog = (OptionsDialog*)data;
  674. if (dialog->encX509Checkbox->value()) {
  675. dialog->caInput->activate();
  676. dialog->crlInput->activate();
  677. } else {
  678. dialog->caInput->deactivate();
  679. dialog->crlInput->deactivate();
  680. }
  681. }
  682. void OptionsDialog::handleDesktopSize(Fl_Widget *widget, void *data)
  683. {
  684. OptionsDialog *dialog = (OptionsDialog*)data;
  685. if (dialog->desktopSizeCheckbox->value()) {
  686. dialog->desktopWidthInput->activate();
  687. dialog->desktopHeightInput->activate();
  688. } else {
  689. dialog->desktopWidthInput->deactivate();
  690. dialog->desktopHeightInput->deactivate();
  691. }
  692. }
  693. void OptionsDialog::handleCancel(Fl_Widget *widget, void *data)
  694. {
  695. OptionsDialog *dialog = (OptionsDialog*)data;
  696. dialog->hide();
  697. }
  698. void OptionsDialog::handleOK(Fl_Widget *widget, void *data)
  699. {
  700. OptionsDialog *dialog = (OptionsDialog*)data;
  701. dialog->hide();
  702. dialog->storeOptions();
  703. }