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 28KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920
  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. emulateMBCheckbox->value(emulateMiddleButton);
  212. acceptClipboardCheckbox->value(acceptClipboard);
  213. #if !defined(WIN32) && !defined(__APPLE__)
  214. setPrimaryCheckbox->value(setPrimary);
  215. #endif
  216. sendClipboardCheckbox->value(sendClipboard);
  217. #if !defined(WIN32) && !defined(__APPLE__)
  218. sendPrimaryCheckbox->value(sendPrimary);
  219. #endif
  220. systemKeysCheckbox->value(fullscreenSystemKeys);
  221. menuKeyChoice->value(0);
  222. menuKeyBuf = menuKey;
  223. for (int i = 0; i < getMenuKeySymbolCount(); i++)
  224. if (!strcmp(getMenuKeySymbols()[i].name, menuKeyBuf))
  225. menuKeyChoice->value(i + 1);
  226. /* Screen */
  227. int width, height;
  228. if (sscanf((const char*)desktopSize, "%dx%d", &width, &height) != 2) {
  229. desktopSizeCheckbox->value(false);
  230. desktopWidthInput->value("1024");
  231. desktopHeightInput->value("768");
  232. } else {
  233. char buf[32];
  234. desktopSizeCheckbox->value(true);
  235. snprintf(buf, sizeof(buf), "%d", width);
  236. desktopWidthInput->value(buf);
  237. snprintf(buf, sizeof(buf), "%d", height);
  238. desktopHeightInput->value(buf);
  239. }
  240. remoteResizeCheckbox->value(remoteResize);
  241. fullScreenCheckbox->value(fullScreen);
  242. fullScreenAllMonitorsCheckbox->value(fullScreenAllMonitors);
  243. handleDesktopSize(desktopSizeCheckbox, this);
  244. /* Misc. */
  245. sharedCheckbox->value(shared);
  246. dotCursorCheckbox->value(dotWhenNoCursor);
  247. }
  248. void OptionsDialog::storeOptions(void)
  249. {
  250. /* Compression */
  251. autoSelect.setParam(autoselectCheckbox->value());
  252. if (tightButton->value())
  253. preferredEncoding.setParam(encodingName(encodingTight));
  254. else if (zrleButton->value())
  255. preferredEncoding.setParam(encodingName(encodingZRLE));
  256. else if (hextileButton->value())
  257. preferredEncoding.setParam(encodingName(encodingHextile));
  258. else if (rawButton->value())
  259. preferredEncoding.setParam(encodingName(encodingRaw));
  260. fullColour.setParam(fullcolorCheckbox->value());
  261. if (verylowcolorCheckbox->value())
  262. lowColourLevel.setParam(0);
  263. else if (lowcolorCheckbox->value())
  264. lowColourLevel.setParam(1);
  265. else if (mediumcolorCheckbox->value())
  266. lowColourLevel.setParam(2);
  267. customCompressLevel.setParam(compressionCheckbox->value());
  268. noJpeg.setParam(!jpegCheckbox->value());
  269. compressLevel.setParam(atoi(compressionInput->value()));
  270. qualityLevel.setParam(atoi(jpegInput->value()));
  271. #ifdef HAVE_GNUTLS
  272. /* Security */
  273. Security security;
  274. /* Process security types which don't use encryption */
  275. if (encNoneCheckbox->value()) {
  276. if (authNoneCheckbox->value())
  277. security.EnableSecType(secTypeNone);
  278. if (authVncCheckbox->value())
  279. security.EnableSecType(secTypeVncAuth);
  280. if (authPlainCheckbox->value())
  281. security.EnableSecType(secTypePlain);
  282. }
  283. /* Process security types which use TLS encryption */
  284. if (encTLSCheckbox->value()) {
  285. if (authNoneCheckbox->value())
  286. security.EnableSecType(secTypeTLSNone);
  287. if (authVncCheckbox->value())
  288. security.EnableSecType(secTypeTLSVnc);
  289. if (authPlainCheckbox->value())
  290. security.EnableSecType(secTypeTLSPlain);
  291. }
  292. /* Process security types which use X509 encryption */
  293. if (encX509Checkbox->value()) {
  294. if (authNoneCheckbox->value())
  295. security.EnableSecType(secTypeX509None);
  296. if (authVncCheckbox->value())
  297. security.EnableSecType(secTypeX509Vnc);
  298. if (authPlainCheckbox->value())
  299. security.EnableSecType(secTypeX509Plain);
  300. }
  301. SecurityClient::secTypes.setParam(security.ToString());
  302. CSecurityTLS::X509CA.setParam(caInput->value());
  303. CSecurityTLS::X509CRL.setParam(crlInput->value());
  304. #endif
  305. /* Input */
  306. viewOnly.setParam(viewOnlyCheckbox->value());
  307. emulateMiddleButton.setParam(emulateMBCheckbox->value());
  308. acceptClipboard.setParam(acceptClipboardCheckbox->value());
  309. #if !defined(WIN32) && !defined(__APPLE__)
  310. setPrimary.setParam(setPrimaryCheckbox->value());
  311. #endif
  312. sendClipboard.setParam(sendClipboardCheckbox->value());
  313. #if !defined(WIN32) && !defined(__APPLE__)
  314. sendPrimary.setParam(sendPrimaryCheckbox->value());
  315. #endif
  316. fullscreenSystemKeys.setParam(systemKeysCheckbox->value());
  317. if (menuKeyChoice->value() == 0)
  318. menuKey.setParam("");
  319. else {
  320. menuKey.setParam(menuKeyChoice->text());
  321. }
  322. /* Screen */
  323. int width, height;
  324. if (desktopSizeCheckbox->value() &&
  325. (sscanf(desktopWidthInput->value(), "%d", &width) == 1) &&
  326. (sscanf(desktopHeightInput->value(), "%d", &height) == 1)) {
  327. char buf[64];
  328. snprintf(buf, sizeof(buf), "%dx%d", width, height);
  329. desktopSize.setParam(buf);
  330. } else {
  331. desktopSize.setParam("");
  332. }
  333. remoteResize.setParam(remoteResizeCheckbox->value());
  334. fullScreen.setParam(fullScreenCheckbox->value());
  335. fullScreenAllMonitors.setParam(fullScreenAllMonitorsCheckbox->value());
  336. /* Misc. */
  337. shared.setParam(sharedCheckbox->value());
  338. dotWhenNoCursor.setParam(dotCursorCheckbox->value());
  339. std::map<OptionsCallback*, void*>::const_iterator iter;
  340. for (iter = callbacks.begin();iter != callbacks.end();++iter)
  341. iter->first(iter->second);
  342. }
  343. void OptionsDialog::createCompressionPage(int tx, int ty, int tw, int th)
  344. {
  345. Fl_Group *group = new Fl_Group(tx, ty, tw, th, _("Compression"));
  346. int orig_tx, orig_ty;
  347. int half_width, full_width;
  348. int height;
  349. tx += OUTER_MARGIN;
  350. ty += OUTER_MARGIN;
  351. full_width = tw - OUTER_MARGIN * 2;
  352. half_width = (full_width - INNER_MARGIN) / 2;
  353. /* AutoSelect checkbox */
  354. autoselectCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  355. CHECK_MIN_WIDTH,
  356. CHECK_HEIGHT,
  357. _("Auto select")));
  358. autoselectCheckbox->callback(handleAutoselect, this);
  359. ty += CHECK_HEIGHT + INNER_MARGIN;
  360. /* Two columns */
  361. orig_tx = tx;
  362. orig_ty = ty;
  363. /* VNC encoding box */
  364. ty += GROUP_LABEL_OFFSET;
  365. height = GROUP_MARGIN * 2 + TIGHT_MARGIN * 3 + RADIO_HEIGHT * 4;
  366. encodingGroup = new Fl_Group(tx, ty, half_width, height,
  367. _("Preferred encoding"));
  368. encodingGroup->box(FL_ENGRAVED_BOX);
  369. encodingGroup->align(FL_ALIGN_LEFT | FL_ALIGN_TOP);
  370. {
  371. tx += GROUP_MARGIN;
  372. ty += GROUP_MARGIN;
  373. tightButton = new Fl_Round_Button(LBLRIGHT(tx, ty,
  374. RADIO_MIN_WIDTH,
  375. RADIO_HEIGHT,
  376. "Tight"));
  377. tightButton->type(FL_RADIO_BUTTON);
  378. ty += RADIO_HEIGHT + TIGHT_MARGIN;
  379. zrleButton = new Fl_Round_Button(LBLRIGHT(tx, ty,
  380. RADIO_MIN_WIDTH,
  381. RADIO_HEIGHT,
  382. "ZRLE"));
  383. zrleButton->type(FL_RADIO_BUTTON);
  384. ty += RADIO_HEIGHT + TIGHT_MARGIN;
  385. hextileButton = new Fl_Round_Button(LBLRIGHT(tx, ty,
  386. RADIO_MIN_WIDTH,
  387. RADIO_HEIGHT,
  388. "Hextile"));
  389. hextileButton->type(FL_RADIO_BUTTON);
  390. ty += RADIO_HEIGHT + TIGHT_MARGIN;
  391. rawButton = new Fl_Round_Button(LBLRIGHT(tx, ty,
  392. RADIO_MIN_WIDTH,
  393. RADIO_HEIGHT,
  394. "Raw"));
  395. rawButton->type(FL_RADIO_BUTTON);
  396. ty += RADIO_HEIGHT + TIGHT_MARGIN;
  397. }
  398. ty += GROUP_MARGIN - TIGHT_MARGIN;
  399. encodingGroup->end();
  400. /* Second column */
  401. tx = orig_tx + half_width + INNER_MARGIN;
  402. ty = orig_ty;
  403. /* Color box */
  404. ty += GROUP_LABEL_OFFSET;
  405. height = GROUP_MARGIN * 2 + TIGHT_MARGIN * 3 + RADIO_HEIGHT * 4;
  406. colorlevelGroup = new Fl_Group(tx, ty, half_width, height, _("Color level"));
  407. colorlevelGroup->box(FL_ENGRAVED_BOX);
  408. colorlevelGroup->align(FL_ALIGN_LEFT | FL_ALIGN_TOP);
  409. {
  410. tx += GROUP_MARGIN;
  411. ty += GROUP_MARGIN;
  412. fullcolorCheckbox = new Fl_Round_Button(LBLRIGHT(tx, ty,
  413. RADIO_MIN_WIDTH,
  414. RADIO_HEIGHT,
  415. _("Full")));
  416. fullcolorCheckbox->type(FL_RADIO_BUTTON);
  417. ty += RADIO_HEIGHT + TIGHT_MARGIN;
  418. mediumcolorCheckbox = new Fl_Round_Button(LBLRIGHT(tx, ty,
  419. RADIO_MIN_WIDTH,
  420. RADIO_HEIGHT,
  421. _("Medium")));
  422. mediumcolorCheckbox->type(FL_RADIO_BUTTON);
  423. ty += RADIO_HEIGHT + TIGHT_MARGIN;
  424. lowcolorCheckbox = new Fl_Round_Button(LBLRIGHT(tx, ty,
  425. RADIO_MIN_WIDTH,
  426. RADIO_HEIGHT,
  427. _("Low")));
  428. lowcolorCheckbox->type(FL_RADIO_BUTTON);
  429. ty += RADIO_HEIGHT + TIGHT_MARGIN;
  430. verylowcolorCheckbox = new Fl_Round_Button(LBLRIGHT(tx, ty,
  431. RADIO_MIN_WIDTH,
  432. RADIO_HEIGHT,
  433. _("Very low")));
  434. verylowcolorCheckbox->type(FL_RADIO_BUTTON);
  435. ty += RADIO_HEIGHT + TIGHT_MARGIN;
  436. }
  437. ty += GROUP_MARGIN - TIGHT_MARGIN;
  438. colorlevelGroup->end();
  439. /* Back to normal */
  440. tx = orig_tx;
  441. ty += INNER_MARGIN;
  442. /* Checkboxes */
  443. compressionCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  444. CHECK_MIN_WIDTH,
  445. CHECK_HEIGHT,
  446. _("Custom compression level:")));
  447. compressionCheckbox->callback(handleCompression, this);
  448. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  449. compressionInput = new Fl_Int_Input(tx + INDENT, ty,
  450. INPUT_HEIGHT, INPUT_HEIGHT,
  451. _("level (0=fast, 9=best)"));
  452. compressionInput->align(FL_ALIGN_RIGHT);
  453. ty += INPUT_HEIGHT + INNER_MARGIN;
  454. jpegCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  455. CHECK_MIN_WIDTH,
  456. CHECK_HEIGHT,
  457. _("Allow JPEG compression:")));
  458. jpegCheckbox->callback(handleJpeg, this);
  459. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  460. jpegInput = new Fl_Int_Input(tx + INDENT, ty,
  461. INPUT_HEIGHT, INPUT_HEIGHT,
  462. _("quality (0=poor, 9=best)"));
  463. jpegInput->align(FL_ALIGN_RIGHT);
  464. ty += INPUT_HEIGHT + INNER_MARGIN;
  465. group->end();
  466. }
  467. void OptionsDialog::createSecurityPage(int tx, int ty, int tw, int th)
  468. {
  469. #ifdef HAVE_GNUTLS
  470. Fl_Group *group = new Fl_Group(tx, ty, tw, th, _("Security"));
  471. int orig_tx;
  472. int width, height;
  473. tx += OUTER_MARGIN;
  474. ty += OUTER_MARGIN;
  475. width = tw - OUTER_MARGIN * 2;
  476. orig_tx = tx;
  477. /* Encryption */
  478. ty += GROUP_LABEL_OFFSET;
  479. height = GROUP_MARGIN * 2 + TIGHT_MARGIN * 4 + CHECK_HEIGHT * 3 + (INPUT_LABEL_OFFSET + INPUT_HEIGHT) * 2;
  480. encryptionGroup = new Fl_Group(tx, ty, width, height, _("Encryption"));
  481. encryptionGroup->box(FL_ENGRAVED_BOX);
  482. encryptionGroup->align(FL_ALIGN_LEFT | FL_ALIGN_TOP);
  483. {
  484. tx += GROUP_MARGIN;
  485. ty += GROUP_MARGIN;
  486. encNoneCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  487. CHECK_MIN_WIDTH,
  488. CHECK_HEIGHT,
  489. _("None")));
  490. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  491. encTLSCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  492. CHECK_MIN_WIDTH,
  493. CHECK_HEIGHT,
  494. _("TLS with anonymous certificates")));
  495. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  496. encX509Checkbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  497. CHECK_MIN_WIDTH,
  498. CHECK_HEIGHT,
  499. _("TLS with X509 certificates")));
  500. encX509Checkbox->callback(handleX509, this);
  501. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  502. ty += INPUT_LABEL_OFFSET;
  503. caInput = new Fl_Input(tx + INDENT, ty,
  504. width - GROUP_MARGIN*2 - INDENT, INPUT_HEIGHT,
  505. _("Path to X509 CA certificate"));
  506. caInput->align(FL_ALIGN_LEFT | FL_ALIGN_TOP);
  507. ty += INPUT_HEIGHT + TIGHT_MARGIN;
  508. ty += INPUT_LABEL_OFFSET;
  509. crlInput = new Fl_Input(tx + INDENT, ty,
  510. width - GROUP_MARGIN*2 - INDENT, INPUT_HEIGHT,
  511. _("Path to X509 CRL file"));
  512. crlInput->align(FL_ALIGN_LEFT | FL_ALIGN_TOP);
  513. ty += INPUT_HEIGHT + TIGHT_MARGIN;
  514. }
  515. ty += GROUP_MARGIN - TIGHT_MARGIN;
  516. encryptionGroup->end();
  517. /* Back to normal */
  518. tx = orig_tx;
  519. ty += INNER_MARGIN;
  520. /* Authentication */
  521. ty += GROUP_LABEL_OFFSET;
  522. height = GROUP_MARGIN * 2 + TIGHT_MARGIN * 2 + CHECK_HEIGHT * 3;
  523. authenticationGroup = new Fl_Group(tx, ty, width, height, _("Authentication"));
  524. authenticationGroup->box(FL_ENGRAVED_BOX);
  525. authenticationGroup->align(FL_ALIGN_LEFT | FL_ALIGN_TOP);
  526. {
  527. tx += GROUP_MARGIN;
  528. ty += GROUP_MARGIN;
  529. authNoneCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  530. CHECK_MIN_WIDTH,
  531. CHECK_HEIGHT,
  532. _("None")));
  533. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  534. authVncCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  535. CHECK_MIN_WIDTH,
  536. CHECK_HEIGHT,
  537. _("Standard VNC (insecure without encryption)")));
  538. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  539. authPlainCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  540. CHECK_MIN_WIDTH,
  541. CHECK_HEIGHT,
  542. _("Username and password (insecure without encryption)")));
  543. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  544. }
  545. ty += GROUP_MARGIN - TIGHT_MARGIN;
  546. authenticationGroup->end();
  547. /* Back to normal */
  548. tx = orig_tx;
  549. ty += INNER_MARGIN;
  550. group->end();
  551. #endif
  552. }
  553. void OptionsDialog::createInputPage(int tx, int ty, int tw, int th)
  554. {
  555. Fl_Group *group = new Fl_Group(tx, ty, tw, th, _("Input"));
  556. tx += OUTER_MARGIN;
  557. ty += OUTER_MARGIN;
  558. viewOnlyCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  559. CHECK_MIN_WIDTH,
  560. CHECK_HEIGHT,
  561. _("View only (ignore mouse and keyboard)")));
  562. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  563. emulateMBCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  564. CHECK_MIN_WIDTH,
  565. CHECK_HEIGHT,
  566. _("Emulate middle mouse button")));
  567. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  568. acceptClipboardCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  569. CHECK_MIN_WIDTH,
  570. CHECK_HEIGHT,
  571. _("Accept clipboard from server")));
  572. acceptClipboardCheckbox->callback(handleClipboard, this);
  573. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  574. #if !defined(WIN32) && !defined(__APPLE__)
  575. setPrimaryCheckbox = new Fl_Check_Button(LBLRIGHT(tx + INDENT, ty,
  576. CHECK_MIN_WIDTH,
  577. CHECK_HEIGHT,
  578. _("Also set primary selection")));
  579. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  580. #endif
  581. sendClipboardCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  582. CHECK_MIN_WIDTH,
  583. CHECK_HEIGHT,
  584. _("Send clipboard to server")));
  585. sendClipboardCheckbox->callback(handleClipboard, this);
  586. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  587. #if !defined(WIN32) && !defined(__APPLE__)
  588. sendPrimaryCheckbox = new Fl_Check_Button(LBLRIGHT(tx + INDENT, ty,
  589. CHECK_MIN_WIDTH,
  590. CHECK_HEIGHT,
  591. _("Send primary selection as clipboard")));
  592. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  593. #endif
  594. systemKeysCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  595. CHECK_MIN_WIDTH,
  596. CHECK_HEIGHT,
  597. _("Pass system keys directly to server (full screen)")));
  598. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  599. menuKeyChoice = new Fl_Choice(LBLLEFT(tx, ty, 150, CHOICE_HEIGHT, _("Menu key")));
  600. fltk_menu_add(menuKeyChoice, _("None"), 0, NULL, (void*)0, FL_MENU_DIVIDER);
  601. for (int i = 0; i < getMenuKeySymbolCount(); i++)
  602. fltk_menu_add(menuKeyChoice, getMenuKeySymbols()[i].name, 0, NULL, 0, 0);
  603. ty += CHOICE_HEIGHT + TIGHT_MARGIN;
  604. group->end();
  605. }
  606. void OptionsDialog::createScreenPage(int tx, int ty, int tw, int th)
  607. {
  608. int x;
  609. Fl_Group *group = new Fl_Group(tx, ty, tw, th, _("Screen"));
  610. tx += OUTER_MARGIN;
  611. ty += OUTER_MARGIN;
  612. desktopSizeCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  613. CHECK_MIN_WIDTH,
  614. CHECK_HEIGHT,
  615. _("Resize remote session on connect")));
  616. desktopSizeCheckbox->callback(handleDesktopSize, this);
  617. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  618. desktopWidthInput = new Fl_Int_Input(tx + INDENT, ty, 50, INPUT_HEIGHT);
  619. x = desktopWidthInput->x() + desktopWidthInput->w() + \
  620. gui_str_len("x") + 3 * 2;
  621. desktopHeightInput = new Fl_Int_Input(x, ty, 50, INPUT_HEIGHT, "x");
  622. ty += INPUT_HEIGHT + TIGHT_MARGIN;
  623. remoteResizeCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  624. CHECK_MIN_WIDTH,
  625. CHECK_HEIGHT,
  626. _("Resize remote session to the local window")));
  627. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  628. fullScreenCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  629. CHECK_MIN_WIDTH,
  630. CHECK_HEIGHT,
  631. _("Full-screen mode")));
  632. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  633. fullScreenAllMonitorsCheckbox = new Fl_Check_Button(LBLRIGHT(tx + INDENT, ty,
  634. CHECK_MIN_WIDTH,
  635. CHECK_HEIGHT,
  636. _("Enable full-screen mode over all monitors")));
  637. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  638. group->end();
  639. }
  640. void OptionsDialog::createMiscPage(int tx, int ty, int tw, int th)
  641. {
  642. Fl_Group *group = new Fl_Group(tx, ty, tw, th, _("Misc."));
  643. tx += OUTER_MARGIN;
  644. ty += OUTER_MARGIN;
  645. sharedCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  646. CHECK_MIN_WIDTH,
  647. CHECK_HEIGHT,
  648. _("Shared (don't disconnect other viewers)")));
  649. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  650. dotCursorCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
  651. CHECK_MIN_WIDTH,
  652. CHECK_HEIGHT,
  653. _("Show dot when no cursor")));
  654. ty += CHECK_HEIGHT + TIGHT_MARGIN;
  655. group->end();
  656. }
  657. void OptionsDialog::handleAutoselect(Fl_Widget *widget, void *data)
  658. {
  659. OptionsDialog *dialog = (OptionsDialog*)data;
  660. if (dialog->autoselectCheckbox->value()) {
  661. dialog->encodingGroup->deactivate();
  662. dialog->colorlevelGroup->deactivate();
  663. } else {
  664. dialog->encodingGroup->activate();
  665. dialog->colorlevelGroup->activate();
  666. }
  667. // JPEG setting is also affected by autoselection
  668. dialog->handleJpeg(dialog->jpegCheckbox, dialog);
  669. }
  670. void OptionsDialog::handleCompression(Fl_Widget *widget, void *data)
  671. {
  672. OptionsDialog *dialog = (OptionsDialog*)data;
  673. if (dialog->compressionCheckbox->value())
  674. dialog->compressionInput->activate();
  675. else
  676. dialog->compressionInput->deactivate();
  677. }
  678. void OptionsDialog::handleJpeg(Fl_Widget *widget, void *data)
  679. {
  680. OptionsDialog *dialog = (OptionsDialog*)data;
  681. if (dialog->jpegCheckbox->value() &&
  682. !dialog->autoselectCheckbox->value())
  683. dialog->jpegInput->activate();
  684. else
  685. dialog->jpegInput->deactivate();
  686. }
  687. void OptionsDialog::handleX509(Fl_Widget *widget, void *data)
  688. {
  689. OptionsDialog *dialog = (OptionsDialog*)data;
  690. if (dialog->encX509Checkbox->value()) {
  691. dialog->caInput->activate();
  692. dialog->crlInput->activate();
  693. } else {
  694. dialog->caInput->deactivate();
  695. dialog->crlInput->deactivate();
  696. }
  697. }
  698. void OptionsDialog::handleDesktopSize(Fl_Widget *widget, void *data)
  699. {
  700. OptionsDialog *dialog = (OptionsDialog*)data;
  701. if (dialog->desktopSizeCheckbox->value()) {
  702. dialog->desktopWidthInput->activate();
  703. dialog->desktopHeightInput->activate();
  704. } else {
  705. dialog->desktopWidthInput->deactivate();
  706. dialog->desktopHeightInput->deactivate();
  707. }
  708. }
  709. void OptionsDialog::handleClipboard(Fl_Widget *widget, void *data)
  710. {
  711. #if !defined(WIN32) && !defined(__APPLE__)
  712. OptionsDialog *dialog = (OptionsDialog*)data;
  713. if (dialog->acceptClipboardCheckbox->value())
  714. dialog->setPrimaryCheckbox->activate();
  715. else
  716. dialog->setPrimaryCheckbox->deactivate();
  717. if (dialog->sendClipboardCheckbox->value())
  718. dialog->sendPrimaryCheckbox->activate();
  719. else
  720. dialog->sendPrimaryCheckbox->deactivate();
  721. #endif
  722. }
  723. void OptionsDialog::handleCancel(Fl_Widget *widget, void *data)
  724. {
  725. OptionsDialog *dialog = (OptionsDialog*)data;
  726. dialog->hide();
  727. }
  728. void OptionsDialog::handleOK(Fl_Widget *widget, void *data)
  729. {
  730. OptionsDialog *dialog = (OptionsDialog*)data;
  731. dialog->hide();
  732. dialog->storeOptions();
  733. }