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

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