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

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