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