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.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648
  1. /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
  2. * Copyright (C) 2011-2019 Brian P. Hinz
  3. *
  4. * This is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This software is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this software; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
  17. * USA.
  18. */
  19. package com.tigervnc.vncviewer;
  20. import java.awt.*;
  21. import java.awt.event.*;
  22. import java.io.File;
  23. import java.lang.reflect.*;
  24. import java.text.Format;
  25. import java.text.NumberFormat;
  26. import javax.swing.*;
  27. import javax.swing.border.*;
  28. import javax.swing.filechooser.*;
  29. import javax.swing.UIManager.*;
  30. import javax.swing.text.*;
  31. import java.util.*;
  32. import java.util.List;
  33. import java.util.Map.Entry;
  34. import java.util.prefs.*;
  35. import com.tigervnc.rfb.*;
  36. import static java.awt.GridBagConstraints.BOTH;
  37. import static java.awt.GridBagConstraints.CENTER;
  38. import static java.awt.GridBagConstraints.HORIZONTAL;
  39. import static java.awt.GridBagConstraints.LINE_END;
  40. import static java.awt.GridBagConstraints.LINE_START;
  41. import static java.awt.GridBagConstraints.PAGE_START;
  42. import static java.awt.GridBagConstraints.NONE;
  43. import static java.awt.GridBagConstraints.RELATIVE;
  44. import static java.awt.GridBagConstraints.REMAINDER;
  45. import static java.awt.GridBagConstraints.VERTICAL;
  46. import static com.tigervnc.vncviewer.Parameters.*;
  47. class OptionsDialog extends Dialog {
  48. private class IntegerDocument extends PlainDocument {
  49. private int limit;
  50. public IntegerDocument(int max) {
  51. super();
  52. limit = max;
  53. }
  54. public void insertString(int offset, String str, AttributeSet a)
  55. throws BadLocationException {
  56. if (str == null || !str.matches("^[0-9]+$")) return;
  57. if ((getLength() + str.length()) > limit)
  58. Toolkit.getDefaultToolkit().beep();
  59. else
  60. super.insertString(offset, str, a);
  61. }
  62. }
  63. private class IntegerTextField extends JFormattedTextField {
  64. public IntegerTextField(int digits) {
  65. super();
  66. setDocument(new IntegerDocument(digits));
  67. Font f = getFont();
  68. String template = String.format("%0"+digits+"d", 0);
  69. int w = getFontMetrics(f).stringWidth(template) +
  70. getMargin().left + getMargin().right +
  71. getInsets().left + getInsets().right;
  72. int h = getPreferredSize().height;
  73. setPreferredSize(new Dimension(w, h));
  74. }
  75. @Override
  76. protected void processFocusEvent(final FocusEvent e) {
  77. if (e.isTemporary())
  78. return;
  79. if (e.getID() == FocusEvent.FOCUS_LOST)
  80. if (getText() == null || getText().isEmpty())
  81. setValue(null);
  82. super.processFocusEvent(e);
  83. }
  84. }
  85. private static Map<Object, String> callbacks = new HashMap<Object, String>();
  86. /* Compression */
  87. JCheckBox autoselectCheckbox;
  88. ButtonGroup encodingGroup;
  89. JRadioButton tightButton;
  90. JRadioButton zrleButton;
  91. JRadioButton hextileButton;
  92. JRadioButton rawButton;
  93. ButtonGroup colorlevelGroup;
  94. JRadioButton fullcolorButton;
  95. JRadioButton mediumcolorButton;
  96. JRadioButton lowcolorButton;
  97. JRadioButton verylowcolorButton;
  98. JCheckBox compressionCheckbox;
  99. JCheckBox jpegCheckbox;
  100. JComboBox compressionInput;
  101. JComboBox jpegInput;
  102. /* Security */
  103. JCheckBox encNoneCheckbox;
  104. JCheckBox encTLSCheckbox;
  105. JCheckBox encX509Checkbox;
  106. JCheckBox encRSAAESCheckbox;
  107. JTextField caInput;
  108. JTextField crlInput;
  109. JButton caChooser;
  110. JButton crlChooser;
  111. JCheckBox authNoneCheckbox;
  112. JCheckBox authVncCheckbox;
  113. JCheckBox authPlainCheckbox;
  114. JCheckBox authIdentCheckbox;
  115. JCheckBox sendLocalUsernameCheckbox;
  116. /* Input */
  117. JCheckBox viewOnlyCheckbox;
  118. JCheckBox acceptClipboardCheckbox;
  119. JCheckBox sendClipboardCheckbox;
  120. JComboBox menuKeyChoice;
  121. /* Screen */
  122. JCheckBox desktopSizeCheckbox;
  123. JTextField desktopWidthInput;
  124. JTextField desktopHeightInput;
  125. ButtonGroup sizingGroup;
  126. JRadioButton remoteResizeButton;
  127. JRadioButton remoteScaleButton;
  128. JComboBox scalingFactorInput;
  129. JCheckBox fullScreenCheckbox;
  130. JCheckBox fullScreenAllMonitorsCheckbox;
  131. /* Misc. */
  132. JCheckBox sharedCheckbox;
  133. JCheckBox dotWhenNoCursorCheckbox;
  134. JCheckBox largeCursorInsteadOfDotCheckbox;
  135. JCheckBox acceptBellCheckbox;
  136. /* SSH */
  137. JCheckBox tunnelCheckbox;
  138. JCheckBox viaCheckbox;
  139. JTextField viaUserInput;
  140. JTextField viaHostInput;
  141. JTextField viaPortInput;
  142. JCheckBox extSSHCheckbox;
  143. JTextField sshClientInput;
  144. JButton sshClientChooser;
  145. JRadioButton sshArgsDefaultButton;
  146. JRadioButton sshArgsCustomButton;
  147. JTextField sshArgsInput;
  148. JTextField sshConfigInput;
  149. JTextField sshKeyFileInput;
  150. JButton sshConfigChooser;
  151. JButton sshKeyFileChooser;
  152. @SuppressWarnings({"rawtypes","unchecked"})
  153. public OptionsDialog() {
  154. super(true);
  155. setTitle("VNC Viewer Options");
  156. setResizable(false);
  157. getContentPane().setLayout(
  158. new BoxLayout(getContentPane(), BoxLayout.PAGE_AXIS));
  159. JTabbedPane tabPane = new JTabbedPane();
  160. tabPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
  161. encodingGroup = new ButtonGroup();
  162. colorlevelGroup = new ButtonGroup();
  163. // tabPane
  164. tabPane.addTab("Compression", createCompressionPanel());
  165. tabPane.addTab("Security", createSecurityPanel());
  166. tabPane.addTab("Input", createInputPanel());
  167. tabPane.addTab("Screen", createScreenPanel());
  168. tabPane.addTab("Misc", createMiscPanel());
  169. tabPane.addTab("SSH", createSshPanel());
  170. tabPane.setBorder(BorderFactory.createEmptyBorder());
  171. // Resize the tabPane if necessary to prevent scrolling
  172. int minWidth = 0;
  173. Object tpi = UIManager.get("TabbedPane:TabbedPaneTabArea.contentMargins");
  174. if (tpi != null)
  175. minWidth += ((Insets)tpi).left + ((Insets)tpi).right;
  176. for (int i = 0; i < tabPane.getTabCount(); i++)
  177. minWidth += tabPane.getBoundsAt(i).width;
  178. int minHeight = tabPane.getPreferredSize().height;
  179. if (tabPane.getPreferredSize().width < minWidth)
  180. tabPane.setPreferredSize(new Dimension(minWidth, minHeight));
  181. // button pane
  182. JButton okButton = new JButton("OK \u21B5");
  183. okButton.addActionListener(new ActionListener() {
  184. public void actionPerformed(ActionEvent e) {
  185. storeOptions();
  186. endDialog();
  187. }
  188. });
  189. JButton cancelButton = new JButton("Cancel");
  190. cancelButton.addActionListener(new ActionListener() {
  191. public void actionPerformed(ActionEvent e) {
  192. endDialog();
  193. }
  194. });
  195. JPanel buttonPane = new JPanel(new GridLayout(1, 5, 10, 10));
  196. buttonPane.setBorder(BorderFactory.createEmptyBorder(10, 5, 5, 5));
  197. buttonPane.add(Box.createRigidArea(new Dimension()));
  198. buttonPane.add(Box.createRigidArea(new Dimension()));
  199. buttonPane.add(Box.createRigidArea(new Dimension()));
  200. buttonPane.add(cancelButton);
  201. buttonPane.add(okButton);
  202. this.add(tabPane);
  203. this.add(buttonPane);
  204. addListeners(this);
  205. pack();
  206. }
  207. public static void showDialog(Container c) {
  208. OptionsDialog dialog = new OptionsDialog();
  209. dialog.show(c);
  210. }
  211. public void show(Container c) {
  212. loadOptions();
  213. super.showDialog(c);
  214. }
  215. public static void addCallback(String cb, Object obj)
  216. {
  217. callbacks.put(obj, cb);
  218. }
  219. public static void removeCallback(Object obj)
  220. {
  221. callbacks.remove(obj);
  222. }
  223. public void endDialog() {
  224. super.endDialog();
  225. // Making a new dialog is so cheap that it's not worth keeping
  226. this.dispose();
  227. }
  228. private void loadOptions()
  229. {
  230. /* Compression */
  231. autoselectCheckbox.setSelected(autoSelect.getValue());
  232. int encNum = Encodings.encodingNum(preferredEncoding.getValueStr());
  233. switch (encNum) {
  234. case Encodings.encodingTight:
  235. tightButton.setSelected(true);
  236. break;
  237. case Encodings.encodingZRLE:
  238. zrleButton.setSelected(true);
  239. break;
  240. case Encodings.encodingHextile:
  241. hextileButton.setSelected(true);
  242. break;
  243. case Encodings.encodingRaw:
  244. rawButton.setSelected(true);
  245. break;
  246. }
  247. if (fullColor.getValue())
  248. fullcolorButton.setSelected(true);
  249. else {
  250. switch (lowColorLevel.getValue()) {
  251. case 0:
  252. verylowcolorButton.setSelected(true);
  253. break;
  254. case 1:
  255. lowcolorButton.setSelected(true);
  256. break;
  257. case 2:
  258. mediumcolorButton.setSelected(true);
  259. break;
  260. }
  261. }
  262. int digit = 0;
  263. compressionCheckbox.setSelected(customCompressLevel.getValue());
  264. jpegCheckbox.setSelected(!noJpeg.getValue());
  265. digit = 0 + compressLevel.getValue();
  266. compressionInput.setSelectedItem(digit);
  267. digit = 0 + qualityLevel.getValue();
  268. jpegInput.setSelectedItem(digit);
  269. handleAutoselect();
  270. handleCompression();
  271. handleJpeg();
  272. /* Security */
  273. Security security = new Security(SecurityClient.secTypes);
  274. List<Integer> secTypes;
  275. Iterator<Integer> iter;
  276. List<Integer> secTypesExt;
  277. Iterator<Integer> iterExt;
  278. encNoneCheckbox.setSelected(false);
  279. encTLSCheckbox.setSelected(false);
  280. encX509Checkbox.setSelected(false);
  281. encRSAAESCheckbox.setSelected(false);
  282. authNoneCheckbox.setSelected(false);
  283. authVncCheckbox.setSelected(false);
  284. authPlainCheckbox.setSelected(false);
  285. authIdentCheckbox.setSelected(false);
  286. sendLocalUsernameCheckbox.setSelected(sendLocalUsername.getValue());
  287. secTypes = security.GetEnabledSecTypes();
  288. for (iter = secTypes.iterator(); iter.hasNext(); ) {
  289. switch ((Integer)iter.next()) {
  290. case Security.secTypeNone:
  291. encNoneCheckbox.setSelected(true);
  292. authNoneCheckbox.setSelected(true);
  293. break;
  294. case Security.secTypeVncAuth:
  295. encNoneCheckbox.setSelected(true);
  296. authVncCheckbox.setSelected(true);
  297. break;
  298. }
  299. }
  300. secTypesExt = security.GetEnabledExtSecTypes();
  301. for (iterExt = secTypesExt.iterator(); iterExt.hasNext(); ) {
  302. switch ((Integer)iterExt.next()) {
  303. case Security.secTypePlain:
  304. encNoneCheckbox.setSelected(true);
  305. authPlainCheckbox.setSelected(true);
  306. break;
  307. case Security.secTypeIdent:
  308. encNoneCheckbox.setSelected(true);
  309. authIdentCheckbox.setSelected(true);
  310. break;
  311. case Security.secTypeTLSNone:
  312. encTLSCheckbox.setSelected(true);
  313. authNoneCheckbox.setSelected(true);
  314. break;
  315. case Security.secTypeTLSVnc:
  316. encTLSCheckbox.setSelected(true);
  317. authVncCheckbox.setSelected(true);
  318. break;
  319. case Security.secTypeTLSPlain:
  320. encTLSCheckbox.setSelected(true);
  321. authPlainCheckbox.setSelected(true);
  322. break;
  323. case Security.secTypeTLSIdent:
  324. encTLSCheckbox.setSelected(true);
  325. authIdentCheckbox.setSelected(true);
  326. break;
  327. case Security.secTypeX509None:
  328. encX509Checkbox.setSelected(true);
  329. authNoneCheckbox.setSelected(true);
  330. break;
  331. case Security.secTypeX509Vnc:
  332. encX509Checkbox.setSelected(true);
  333. authVncCheckbox.setSelected(true);
  334. break;
  335. case Security.secTypeX509Plain:
  336. encX509Checkbox.setSelected(true);
  337. authPlainCheckbox.setSelected(true);
  338. break;
  339. case Security.secTypeX509Ident:
  340. encX509Checkbox.setSelected(true);
  341. authIdentCheckbox.setSelected(true);
  342. break;
  343. case Security.secTypeRA2:
  344. case Security.secTypeRA256:
  345. encRSAAESCheckbox.setSelected(true);
  346. case Security.secTypeRA2ne:
  347. case Security.secTypeRAne256:
  348. authVncCheckbox.setSelected(true);
  349. authPlainCheckbox.setSelected(true);
  350. break;
  351. }
  352. }
  353. File caFile = new File(CSecurityTLS.X509CA.getValueStr());
  354. if (caFile.exists() && caFile.canRead())
  355. caInput.setText(caFile.getAbsolutePath());
  356. File crlFile = new File(CSecurityTLS.X509CRL.getValueStr());
  357. if (crlFile.exists() && crlFile.canRead())
  358. crlInput.setText(crlFile.getAbsolutePath());
  359. handleX509();
  360. handleSendLocalUsername();
  361. /* Input */
  362. viewOnlyCheckbox.setSelected(viewOnly.getValue());
  363. acceptClipboardCheckbox.setSelected(acceptClipboard.getValue());
  364. sendClipboardCheckbox.setSelected(sendClipboard.getValue());
  365. menuKeyChoice.setSelectedIndex(0);
  366. String menuKeyStr = menuKey.getValueStr();
  367. for (int i = 0; i < menuKeyChoice.getItemCount(); i++)
  368. if (menuKeyStr.equals(menuKeyChoice.getItemAt(i)))
  369. menuKeyChoice.setSelectedIndex(i);
  370. /* Screen */
  371. String width, height;
  372. if (desktopSize.getValueStr().isEmpty() ||
  373. desktopSize.getValueStr().split("x").length != 2) {
  374. desktopSizeCheckbox.setSelected(false);
  375. desktopWidthInput.setText("1024");
  376. desktopHeightInput.setText("768");
  377. } else {
  378. desktopSizeCheckbox.setSelected(true);
  379. width = desktopSize.getValueStr().split("x")[0];
  380. desktopWidthInput.setText(width);
  381. height = desktopSize.getValueStr().split("x")[1];
  382. desktopHeightInput.setText(height);
  383. }
  384. if (remoteResize.getValue())
  385. remoteResizeButton.setSelected(true);
  386. else
  387. remoteScaleButton.setSelected(true);
  388. fullScreenCheckbox.setSelected(fullScreen.getValue());
  389. fullScreenAllMonitorsCheckbox.setSelected(fullScreenAllMonitors.getValue());
  390. scalingFactorInput.setSelectedItem("100%");
  391. String scaleStr = scalingFactor.getValueStr();
  392. if (scaleStr.matches("^[0-9]+$"))
  393. scaleStr = scaleStr.concat("%");
  394. if (scaleStr.matches("^FixedRatio$"))
  395. scaleStr = new String("Fixed Aspect Ratio");
  396. for (int i = 0; i < scalingFactorInput.getItemCount(); i++)
  397. if (scaleStr.equals(scalingFactorInput.getItemAt(i)))
  398. scalingFactorInput.setSelectedIndex(i);
  399. handleDesktopSize();
  400. /* Misc. */
  401. sharedCheckbox.setSelected(shared.getValue());
  402. dotWhenNoCursorCheckbox.setSelected(dotWhenNoCursor.getValue());
  403. largeCursorInsteadOfDotCheckbox.setSelected(largeCursorInsteadOfDot.getValue());
  404. acceptBellCheckbox.setSelected(acceptBell.getValue());
  405. /* SSH */
  406. File f;
  407. tunnelCheckbox.setSelected(tunnel.getValue() || !via.getValueStr().isEmpty());
  408. viaCheckbox.setSelected(!via.getValueStr().isEmpty());
  409. if (viaCheckbox.isSelected()) {
  410. viaUserInput.setText(Tunnel.getSshUser());
  411. viaHostInput.setText(Tunnel.getSshHost());
  412. viaPortInput.setText(Integer.toString(Tunnel.getSshPort()));
  413. }
  414. extSSHCheckbox.setSelected(extSSH.getValue());
  415. f = new File(extSSHClient.getValueStr());
  416. if (f.exists() && f.isFile() && f.canExecute())
  417. sshClientInput.setText(f.getAbsolutePath());
  418. if (extSSHArgs.getValueStr().isEmpty()) {
  419. sshArgsDefaultButton.setSelected(true);
  420. } else {
  421. sshArgsCustomButton.setSelected(true);
  422. sshArgsInput.setText(extSSHArgs.getValueStr());
  423. }
  424. f = new File(sshKeyFile.getValueStr());
  425. if (f.exists() && f.isFile() && f.canRead())
  426. sshKeyFileInput.setText(f.getAbsolutePath());
  427. f = new File(sshConfig.getValueStr());
  428. if (f.exists() && f.isFile() && f.canRead())
  429. sshConfigInput.setText(f.getAbsolutePath());
  430. handleTunnel();
  431. handleVia();
  432. handleExtSSH();
  433. handleRfbState();
  434. }
  435. private void storeOptions() {
  436. /* Compression */
  437. autoSelect.setParam(autoselectCheckbox.isSelected());
  438. if (tightButton.isSelected())
  439. preferredEncoding.setParam(Encodings.encodingName(Encodings.encodingTight));
  440. else if (zrleButton.isSelected())
  441. preferredEncoding.setParam(Encodings.encodingName(Encodings.encodingZRLE));
  442. else if (hextileButton.isSelected())
  443. preferredEncoding.setParam(Encodings.encodingName(Encodings.encodingHextile));
  444. else if (rawButton.isSelected())
  445. preferredEncoding.setParam(Encodings.encodingName(Encodings.encodingRaw));
  446. fullColor.setParam(fullcolorButton.isSelected());
  447. if (verylowcolorButton.isSelected())
  448. lowColorLevel.setParam(0);
  449. else if (lowcolorButton.isSelected())
  450. lowColorLevel.setParam(1);
  451. else if (mediumcolorButton.isSelected())
  452. lowColorLevel.setParam(2);
  453. customCompressLevel.setParam(compressionCheckbox.isSelected());
  454. noJpeg.setParam(!jpegCheckbox.isSelected());
  455. compressLevel.setParam((Integer)compressionInput.getSelectedItem());
  456. qualityLevel.setParam((Integer)jpegInput.getSelectedItem());
  457. /* Security */
  458. Security security = new Security();
  459. /* Process security types which don't use encryption */
  460. if (encNoneCheckbox.isSelected()) {
  461. if (authNoneCheckbox.isSelected())
  462. security.EnableSecType(Security.secTypeNone);
  463. if (authVncCheckbox.isSelected()) {
  464. security.EnableSecType(Security.secTypeVncAuth);
  465. security.EnableSecType(Security.secTypeRA2ne);
  466. security.EnableSecType(Security.secTypeRAne256);
  467. }
  468. if (authPlainCheckbox.isSelected()) {
  469. security.EnableSecType(Security.secTypePlain);
  470. security.EnableSecType(Security.secTypeRA2ne);
  471. security.EnableSecType(Security.secTypeRAne256);
  472. }
  473. if (authIdentCheckbox.isSelected())
  474. security.EnableSecType(Security.secTypeIdent);
  475. }
  476. /* Process security types which use TLS encryption */
  477. if (encTLSCheckbox.isSelected()) {
  478. if (authNoneCheckbox.isSelected())
  479. security.EnableSecType(Security.secTypeTLSNone);
  480. if (authVncCheckbox.isSelected())
  481. security.EnableSecType(Security.secTypeTLSVnc);
  482. if (authPlainCheckbox.isSelected())
  483. security.EnableSecType(Security.secTypeTLSPlain);
  484. if (authIdentCheckbox.isSelected())
  485. security.EnableSecType(Security.secTypeTLSIdent);
  486. }
  487. /* Process security types which use X509 encryption */
  488. if (encX509Checkbox.isSelected()) {
  489. if (authNoneCheckbox.isSelected())
  490. security.EnableSecType(Security.secTypeX509None);
  491. if (authVncCheckbox.isSelected())
  492. security.EnableSecType(Security.secTypeX509Vnc);
  493. if (authPlainCheckbox.isSelected())
  494. security.EnableSecType(Security.secTypeX509Plain);
  495. if (authIdentCheckbox.isSelected())
  496. security.EnableSecType(Security.secTypeX509Ident);
  497. }
  498. if (encRSAAESCheckbox.isSelected()) {
  499. security.EnableSecType(Security.secTypeRA2);
  500. security.EnableSecType(Security.secTypeRA256);
  501. }
  502. if (authIdentCheckbox.isSelected() ||
  503. authPlainCheckbox.isSelected()) {
  504. sendLocalUsername.setParam(sendLocalUsernameCheckbox.isSelected());
  505. }
  506. SecurityClient.secTypes.setParam(security.ToString());
  507. File caFile = new File(caInput.getText());
  508. if (caFile.exists() && caFile.canRead())
  509. CSecurityTLS.X509CA.setParam(caFile.getAbsolutePath());
  510. File crlFile = new File(crlInput.getText());
  511. if (crlFile.exists() && crlFile.canRead())
  512. CSecurityTLS.X509CRL.setParam(crlFile.getAbsolutePath());
  513. /* Input */
  514. viewOnly.setParam(viewOnlyCheckbox.isSelected());
  515. acceptClipboard.setParam(acceptClipboardCheckbox.isSelected());
  516. sendClipboard.setParam(sendClipboardCheckbox.isSelected());
  517. String menuKeyStr =
  518. MenuKey.getMenuKeySymbols()[menuKeyChoice.getSelectedIndex()].name;
  519. menuKey.setParam(menuKeyStr);
  520. /* Screen */
  521. if (desktopSizeCheckbox.isSelected() &&
  522. !desktopWidthInput.getText().isEmpty() &&
  523. !desktopHeightInput.getText().isEmpty()) {
  524. String width = desktopWidthInput.getText();
  525. String height = desktopHeightInput.getText();
  526. desktopSize.setParam(width.concat("x").concat(height));
  527. } else {
  528. desktopSize.setParam("");
  529. }
  530. remoteResize.setParam(remoteResizeButton.isSelected());
  531. fullScreen.setParam(fullScreenCheckbox.isSelected());
  532. fullScreenAllMonitors.setParam(fullScreenAllMonitorsCheckbox.isSelected());
  533. String scaleStr =
  534. ((String)scalingFactorInput.getSelectedItem()).replace("%", "");
  535. scaleStr.replace("Fixed Aspect Ratio", "FixedRatio");
  536. scalingFactor.setParam(scaleStr);
  537. /* Misc. */
  538. shared.setParam(sharedCheckbox.isSelected());
  539. dotWhenNoCursor.setParam(dotWhenNoCursorCheckbox.isSelected());
  540. largeCursorInsteadOfDot.setParam(largeCursorInsteadOfDotCheckbox.isSelected());
  541. acceptBell.setParam(acceptBellCheckbox.isSelected());
  542. /* SSH */
  543. tunnel.setParam(tunnelCheckbox.isSelected());
  544. if (viaCheckbox.isSelected() &&
  545. !viaUserInput.getText().isEmpty() &&
  546. !viaHostInput.getText().isEmpty() &&
  547. !viaPortInput.getText().isEmpty()) {
  548. String sshUser = viaUserInput.getText();
  549. String sshHost = viaHostInput.getText();
  550. String sshPort = viaPortInput.getText();
  551. String viaStr = sshUser.concat("@").concat(sshHost).concat(":").concat(sshPort);
  552. via.setParam(viaStr);
  553. } else {
  554. via.setParam("");
  555. }
  556. extSSH.setParam(extSSHCheckbox.isSelected());
  557. if (!sshClientInput.getText().isEmpty())
  558. extSSHClient.setParam(sshClientInput.getText());
  559. if (sshArgsCustomButton.isSelected() &&
  560. !sshArgsInput.getText().isEmpty()) {
  561. extSSHArgs.setParam(sshArgsInput.getText());
  562. } else {
  563. extSSHArgs.setParam(new String());
  564. }
  565. if (!sshConfigInput.getText().isEmpty())
  566. sshConfig.setParam(sshConfigInput.getText());
  567. if (!sshKeyFileInput.getText().isEmpty())
  568. sshKeyFile.setParam(sshKeyFileInput.getText());
  569. try {
  570. for (Map.Entry<Object, String> iter : callbacks.entrySet()) {
  571. Object obj = iter.getKey();
  572. Method cb = obj.getClass().getMethod(iter.getValue(), new Class[]{});
  573. if (cb == null)
  574. vlog.info(obj.getClass().getName());
  575. cb.invoke(obj);
  576. }
  577. } catch (NoSuchMethodException e) {
  578. vlog.error("NoSuchMethodException: "+e.getMessage());
  579. } catch (IllegalAccessException e) {
  580. vlog.error("IllegalAccessException: "+e.getMessage());
  581. } catch (InvocationTargetException e) {
  582. vlog.error("InvocationTargetException: "+e.getMessage());
  583. }
  584. }
  585. private JPanel createCompressionPanel() {
  586. JPanel FormatPanel = new JPanel();
  587. FormatPanel.setLayout(new BoxLayout(FormatPanel,
  588. BoxLayout.PAGE_AXIS));
  589. FormatPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 0, 5));
  590. JPanel autoSelectPane = new JPanel();
  591. autoSelectPane.setLayout(new BoxLayout(autoSelectPane,
  592. BoxLayout.LINE_AXIS));
  593. autoSelectPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0));
  594. autoselectCheckbox = new JCheckBox("Auto Select");
  595. autoselectCheckbox.addItemListener(new ItemListener() {
  596. public void itemStateChanged(ItemEvent e) {
  597. handleAutoselect();
  598. }
  599. });
  600. autoSelectPane.add(autoselectCheckbox);
  601. autoSelectPane.add(Box.createHorizontalGlue());
  602. JPanel encodingPanel = new JPanel(new GridLayout(4, 1));
  603. encodingPanel.setBorder(BorderFactory.createTitledBorder("Preferred encoding"));
  604. tightButton = new GroupedJRadioButton("Tight", encodingGroup, encodingPanel);
  605. zrleButton = new GroupedJRadioButton("ZRLE", encodingGroup, encodingPanel);
  606. hextileButton = new GroupedJRadioButton("Hextile", encodingGroup, encodingPanel);
  607. rawButton = new GroupedJRadioButton("Raw", encodingGroup, encodingPanel);
  608. JPanel colorPanel = new JPanel(new GridLayout(4, 1));
  609. colorPanel.setBorder(BorderFactory.createTitledBorder("Color level"));
  610. fullcolorButton = new GroupedJRadioButton("Full", colorlevelGroup, colorPanel);
  611. mediumcolorButton = new GroupedJRadioButton("Medium", colorlevelGroup, colorPanel);
  612. lowcolorButton = new GroupedJRadioButton("Low", colorlevelGroup, colorPanel);
  613. verylowcolorButton = new GroupedJRadioButton("Very low", colorlevelGroup, colorPanel);
  614. JPanel encodingPane = new JPanel(new GridLayout(1, 2, 5, 0));
  615. encodingPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0));
  616. encodingPane.add(encodingPanel);
  617. encodingPane.add(colorPanel);
  618. JPanel tightPanel = new JPanel(new GridBagLayout());
  619. compressionCheckbox = new JCheckBox("Custom Compression Level");
  620. compressionCheckbox.addItemListener(new ItemListener() {
  621. public void itemStateChanged(ItemEvent e) {
  622. handleCompression();
  623. }
  624. });
  625. Object[] compressionLevels = { 1, 2, 3, 4, 5, 6 };
  626. compressionInput = new MyJComboBox(compressionLevels);
  627. ((MyJComboBox)compressionInput).setDocument(new IntegerDocument(1));
  628. compressionInput.setPrototypeDisplayValue("0.");
  629. compressionInput.setEditable(true);
  630. JLabel compressionLabel =
  631. new JLabel("Level (0=fast, 9=best)");
  632. jpegCheckbox = new JCheckBox("Allow JPEG Compression");
  633. jpegCheckbox.addItemListener(new ItemListener() {
  634. public void itemStateChanged(ItemEvent e) {
  635. handleJpeg();
  636. }
  637. });
  638. Object[] qualityLevels = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
  639. jpegInput = new MyJComboBox(qualityLevels);
  640. jpegInput.setPrototypeDisplayValue("0.");
  641. JLabel qualityLabel = new JLabel("Quality (0=poor, 9=best)");
  642. tightPanel.add(compressionCheckbox,
  643. new GridBagConstraints(0, 0,
  644. REMAINDER, 1,
  645. LIGHT, LIGHT,
  646. LINE_START, NONE,
  647. new Insets(0, 0, 0, 0),
  648. NONE, NONE));
  649. int indent = getButtonLabelInset(compressionCheckbox);
  650. tightPanel.add(compressionInput,
  651. new GridBagConstraints(0, 1,
  652. 1, 1,
  653. LIGHT, LIGHT,
  654. LINE_START, NONE,
  655. new Insets(0, indent, 0, 0),
  656. NONE, NONE));
  657. tightPanel.add(compressionLabel,
  658. new GridBagConstraints(1, 1,
  659. 1, 1,
  660. HEAVY, LIGHT,
  661. LINE_START, HORIZONTAL,
  662. new Insets(0, 5, 0, 0),
  663. NONE, NONE));
  664. tightPanel.add(jpegCheckbox,
  665. new GridBagConstraints(0, 2,
  666. REMAINDER, 1,
  667. LIGHT, LIGHT,
  668. LINE_START, NONE,
  669. new Insets(5, 0, 0, 0),
  670. NONE, NONE));
  671. indent = getButtonLabelInset(jpegCheckbox);
  672. tightPanel.add(jpegInput,
  673. new GridBagConstraints(0, 3,
  674. 1, 1,
  675. LIGHT, LIGHT,
  676. LINE_START, NONE,
  677. new Insets(0, indent, 0, 0),
  678. NONE, NONE));
  679. tightPanel.add(qualityLabel,
  680. new GridBagConstraints(1, 3,
  681. 1, 1,
  682. HEAVY, NONE,
  683. LINE_START, HORIZONTAL,
  684. new Insets(0, 5, 0, 0),
  685. NONE, NONE));
  686. tightPanel.add(Box.createRigidArea(new Dimension(5,0)),
  687. new GridBagConstraints(0, 4,
  688. REMAINDER, REMAINDER,
  689. HEAVY, HEAVY,
  690. LINE_START, BOTH,
  691. new Insets(0, 0, 0, 0),
  692. NONE, NONE));
  693. FormatPanel.add(autoSelectPane);
  694. FormatPanel.add(encodingPane);
  695. FormatPanel.add(tightPanel);
  696. return FormatPanel;
  697. }
  698. private JPanel createSecurityPanel() {
  699. JPanel SecPanel = new JPanel();
  700. SecPanel.setLayout(new BoxLayout(SecPanel,
  701. BoxLayout.PAGE_AXIS));
  702. SecPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 0, 5));
  703. JPanel vencryptPane = new JPanel();
  704. vencryptPane.setLayout(new BoxLayout(vencryptPane,
  705. BoxLayout.LINE_AXIS));
  706. vencryptPane.setBorder(BorderFactory.createEmptyBorder(0,0,5,0));
  707. JPanel encrPanel = new JPanel(new GridBagLayout());
  708. encrPanel.setBorder(BorderFactory.createTitledBorder("Encryption"));
  709. encNoneCheckbox = new JCheckBox("None");
  710. encTLSCheckbox = new JCheckBox("Anonymous TLS");
  711. encX509Checkbox = new JCheckBox("TLS with X.509 certificates");
  712. encX509Checkbox.addItemListener(new ItemListener() {
  713. public void itemStateChanged(ItemEvent e) {
  714. handleX509();
  715. }
  716. });
  717. JLabel caLabel = new JLabel("X.509 CA Certificate");
  718. caInput = new JTextField();
  719. caChooser = new JButton("Browse");
  720. caChooser.addActionListener(new ActionListener() {
  721. public void actionPerformed(ActionEvent e) {
  722. JComponent c = ((JButton)e.getSource()).getRootPane();
  723. File dflt = new File(CSecurityTLS.X509CA.getValueStr());
  724. FileNameExtensionFilter filter =
  725. new FileNameExtensionFilter("X.509 certificate", "crt", "cer", "pem");
  726. File f = showChooser("Path to X509 CA certificate", dflt, c, filter);
  727. if (f != null && f.exists() && f.canRead())
  728. caInput.setText(f.getAbsolutePath());
  729. }
  730. });
  731. JLabel crlLabel = new JLabel("X.509 CRL file");
  732. crlInput = new JTextField();
  733. crlChooser = new JButton("Browse");
  734. crlChooser.addActionListener(new ActionListener() {
  735. public void actionPerformed(ActionEvent e) {
  736. JComponent c = ((JButton)e.getSource()).getRootPane();
  737. File dflt = new File(CSecurityTLS.X509CRL.getValueStr());
  738. FileNameExtensionFilter filter =
  739. new FileNameExtensionFilter("X.509 CRL", "crl");
  740. File f = showChooser("Path to X509 CRL file", dflt, c, filter);
  741. if (f != null && f.exists() && f.canRead())
  742. crlInput.setText(f.getAbsolutePath());
  743. }
  744. });
  745. encRSAAESCheckbox = new JCheckBox("RSA-AES");
  746. encRSAAESCheckbox.addItemListener(new ItemListener() {
  747. public void itemStateChanged(ItemEvent e) {
  748. handleRSAAES();
  749. }
  750. });
  751. encrPanel.add(encNoneCheckbox,
  752. new GridBagConstraints(0, 0,
  753. REMAINDER, 1,
  754. HEAVY, LIGHT,
  755. LINE_START, NONE,
  756. new Insets(0, 0, 4, 0),
  757. NONE, NONE));
  758. encrPanel.add(encTLSCheckbox,
  759. new GridBagConstraints(0, 1,
  760. REMAINDER, 1,
  761. HEAVY, LIGHT,
  762. LINE_START, NONE,
  763. new Insets(0, 0, 4, 0),
  764. NONE, NONE));
  765. encrPanel.add(encX509Checkbox,
  766. new GridBagConstraints(0, 2,
  767. 3, 1,
  768. HEAVY, LIGHT,
  769. LINE_START, NONE,
  770. new Insets(0, 0, 0, 0),
  771. NONE, NONE));
  772. int indent = getButtonLabelInset(encX509Checkbox);
  773. encrPanel.add(caLabel,
  774. new GridBagConstraints(0, 3,
  775. 1, 1,
  776. LIGHT, LIGHT,
  777. LINE_END, NONE,
  778. new Insets(0, indent, 5, 0),
  779. 0, 0));
  780. encrPanel.add(caInput,
  781. new GridBagConstraints(1, 3,
  782. 1, 1,
  783. HEAVY, LIGHT,
  784. LINE_START, HORIZONTAL,
  785. new Insets(0, 5, 5, 0),
  786. 0, 0));
  787. encrPanel.add(caChooser,
  788. new GridBagConstraints(2, 3,
  789. 1, 1,
  790. LIGHT, LIGHT,
  791. LINE_START, VERTICAL,
  792. new Insets(0, 5, 5, 0),
  793. 0, 0));
  794. encrPanel.add(crlLabel,
  795. new GridBagConstraints(0, 4,
  796. 1, 1,
  797. LIGHT, LIGHT,
  798. LINE_END, NONE,
  799. new Insets(0, indent, 0, 0),
  800. 0, 0));
  801. encrPanel.add(crlInput,
  802. new GridBagConstraints(1, 4,
  803. 1, 1,
  804. HEAVY, LIGHT,
  805. LINE_START, HORIZONTAL,
  806. new Insets(0, 5, 0, 0),
  807. 0, 0));
  808. encrPanel.add(crlChooser,
  809. new GridBagConstraints(2, 4,
  810. 1, 1,
  811. LIGHT, LIGHT,
  812. LINE_START, VERTICAL,
  813. new Insets(0, 5, 0, 0),
  814. 0, 0));
  815. encrPanel.add(encRSAAESCheckbox,
  816. new GridBagConstraints(0, 5,
  817. REMAINDER, 1,
  818. HEAVY, LIGHT,
  819. LINE_START, NONE,
  820. new Insets(0, 0, 4, 0),
  821. NONE, NONE));
  822. JPanel authPanel = new JPanel(new GridBagLayout());
  823. authPanel.setBorder(BorderFactory.createTitledBorder("Authentication"));
  824. authNoneCheckbox = new JCheckBox("None");
  825. authVncCheckbox = new JCheckBox("Standard VNC");
  826. authPlainCheckbox = new JCheckBox("Plaintext");
  827. authPlainCheckbox.addItemListener(new ItemListener() {
  828. public void itemStateChanged(ItemEvent e) {
  829. handleSendLocalUsername();
  830. }
  831. });
  832. authIdentCheckbox = new JCheckBox("Ident");
  833. authIdentCheckbox.addItemListener(new ItemListener() {
  834. public void itemStateChanged(ItemEvent e) {
  835. handleSendLocalUsername();
  836. }
  837. });
  838. sendLocalUsernameCheckbox = new JCheckBox("Send Local Username");
  839. authPanel.add(authNoneCheckbox,
  840. new GridBagConstraints(0, 0,
  841. REMAINDER, 1,
  842. LIGHT, LIGHT,
  843. LINE_START, NONE,
  844. new Insets(0, 0, 4, 0),
  845. NONE, NONE));
  846. authPanel.add(authVncCheckbox,
  847. new GridBagConstraints(0, 1,
  848. REMAINDER, 1,
  849. LIGHT, LIGHT,
  850. LINE_START, NONE,
  851. new Insets(0, 0, 4, 0),
  852. NONE, NONE));
  853. authPanel.add(authPlainCheckbox,
  854. new GridBagConstraints(0, 2,
  855. 1, 1,
  856. LIGHT, LIGHT,
  857. LINE_START, NONE,
  858. new Insets(0, 0, 2, 0),
  859. NONE, NONE));
  860. authPanel.add(authIdentCheckbox,
  861. new GridBagConstraints(0, 3,
  862. 1, 1,
  863. LIGHT, LIGHT,
  864. LINE_START, NONE,
  865. new Insets(2, 0, 0, 0),
  866. NONE, NONE));
  867. authPanel.add(sendLocalUsernameCheckbox,
  868. new GridBagConstraints(1, 2,
  869. 1, 2,
  870. HEAVY, LIGHT,
  871. LINE_START, NONE,
  872. new Insets(2, 20, 2, 0),
  873. NONE, NONE));
  874. SecPanel.add(vencryptPane,
  875. new GridBagConstraints(0, 0,
  876. REMAINDER, 1,
  877. LIGHT, LIGHT,
  878. LINE_START, HORIZONTAL,
  879. new Insets(0, 0, 4, 0),
  880. NONE, NONE));
  881. SecPanel.add(encrPanel,
  882. new GridBagConstraints(0, 1,
  883. REMAINDER, 1,
  884. LIGHT, LIGHT,
  885. LINE_START, HORIZONTAL,
  886. new Insets(0, 0, 4, 0),
  887. NONE, NONE));
  888. SecPanel.add(authPanel,
  889. new GridBagConstraints(0, 2,
  890. REMAINDER, 1,
  891. LIGHT, LIGHT,
  892. LINE_START, HORIZONTAL,
  893. new Insets(0, 0, 4, 0),
  894. NONE, NONE));
  895. SecPanel.add(Box.createRigidArea(new Dimension(0,0)),
  896. new GridBagConstraints(0, RELATIVE,
  897. REMAINDER, REMAINDER,
  898. HEAVY, HEAVY,
  899. LINE_START, BOTH,
  900. new Insets(0, 0, 0, 0),
  901. NONE, NONE));
  902. return SecPanel;
  903. }
  904. private JPanel createInputPanel() {
  905. JPanel inputPanel = new JPanel(new GridBagLayout());
  906. inputPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 0, 5));
  907. viewOnlyCheckbox = new JCheckBox("View only (ignore mouse and keyboard)");
  908. acceptClipboardCheckbox = new JCheckBox("Accept clipboard from server");
  909. sendClipboardCheckbox = new JCheckBox("Send clipboard to server");
  910. JLabel menuKeyLabel = new JLabel("Menu key");
  911. String[] menuKeys = new String[MenuKey.getMenuKeySymbolCount()];
  912. //menuKeys[0] = "None";
  913. for (int i = 0; i < MenuKey.getMenuKeySymbolCount(); i++)
  914. menuKeys[i] = MenuKey.getKeyText(MenuKey.getMenuKeySymbols()[i]);
  915. menuKeyChoice = new JComboBox(menuKeys);
  916. inputPanel.add(viewOnlyCheckbox,
  917. new GridBagConstraints(0, 0,
  918. REMAINDER, 1,
  919. HEAVY, LIGHT,
  920. LINE_START, NONE,
  921. new Insets(0, 0, 4, 0),
  922. NONE, NONE));
  923. inputPanel.add(acceptClipboardCheckbox,
  924. new GridBagConstraints(0, 1,
  925. REMAINDER, 1,
  926. HEAVY, LIGHT,
  927. LINE_START, NONE,
  928. new Insets(0, 0, 4, 0),
  929. NONE, NONE));
  930. inputPanel.add(sendClipboardCheckbox,
  931. new GridBagConstraints(0, 2,
  932. REMAINDER, 1,
  933. HEAVY, LIGHT,
  934. LINE_START, NONE,
  935. new Insets(0, 0, 4, 0),
  936. NONE, NONE));
  937. inputPanel.add(menuKeyLabel,
  938. new GridBagConstraints(0, 3,
  939. 1, 1,
  940. LIGHT, LIGHT,
  941. LINE_START, NONE,
  942. new Insets(0, 0, 0, 0),
  943. NONE, NONE));
  944. inputPanel.add(menuKeyChoice,
  945. new GridBagConstraints(1, 3,
  946. 1, 1,
  947. HEAVY, LIGHT,
  948. LINE_START, NONE,
  949. new Insets(0, 5, 0, 0),
  950. NONE, NONE));
  951. inputPanel.add(Box.createRigidArea(new Dimension(5, 0)),
  952. new GridBagConstraints(0, 4,
  953. REMAINDER, REMAINDER,
  954. HEAVY, HEAVY,
  955. LINE_START, BOTH,
  956. new Insets(0, 0, 0, 0),
  957. NONE, NONE));
  958. return inputPanel;
  959. }
  960. private JPanel createScreenPanel() {
  961. JPanel ScreenPanel = new JPanel(new GridBagLayout());
  962. ScreenPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 0, 5));
  963. JPanel SizingPanel = new JPanel(new GridBagLayout());
  964. SizingPanel.setBorder(BorderFactory.createTitledBorder("Desktop Sizing"));
  965. desktopSizeCheckbox = new JCheckBox("Resize remote session on connect");
  966. desktopSizeCheckbox.addItemListener(new ItemListener() {
  967. public void itemStateChanged(ItemEvent e) {
  968. handleDesktopSize();
  969. }
  970. });
  971. desktopWidthInput = new IntegerTextField(5);
  972. desktopHeightInput = new IntegerTextField(5);
  973. JPanel desktopSizePanel =
  974. new JPanel(new FlowLayout(FlowLayout.LEADING, 0, 0));
  975. desktopSizePanel.add(desktopWidthInput);
  976. desktopSizePanel.add(new JLabel(" x "));
  977. desktopSizePanel.add(desktopHeightInput);
  978. sizingGroup = new ButtonGroup();
  979. remoteResizeButton =
  980. new JRadioButton("Resize remote session to the local window");
  981. sizingGroup.add(remoteResizeButton);
  982. remoteScaleButton =
  983. new JRadioButton("Scale remote session to the local window");
  984. sizingGroup.add(remoteScaleButton);
  985. remoteResizeButton.addItemListener(new ItemListener() {
  986. public void itemStateChanged(ItemEvent e) {
  987. handleRemoteResize();
  988. }
  989. });
  990. JLabel scalingFactorLabel = new JLabel("Scaling Factor");
  991. Object[] scalingFactors = {
  992. "Auto", "Fixed Aspect Ratio", "50%", "75%", "95%", "100%", "105%",
  993. "125%", "150%", "175%", "200%", "250%", "300%", "350%", "400%" };
  994. scalingFactorInput = new MyJComboBox(scalingFactors);
  995. scalingFactorInput.setEditable(true);
  996. fullScreenCheckbox = new JCheckBox("Full-screen mode");
  997. fullScreenAllMonitorsCheckbox =
  998. new JCheckBox("Enable full-screen mode over all monitors");
  999. SizingPanel.add(desktopSizeCheckbox,
  1000. new GridBagConstraints(0, 0,
  1001. REMAINDER, 1,
  1002. LIGHT, LIGHT,
  1003. LINE_START, NONE,
  1004. new Insets(0, 0, 0, 0),
  1005. NONE, NONE));
  1006. int indent = getButtonLabelInset(desktopSizeCheckbox);
  1007. SizingPanel.add(desktopSizePanel,
  1008. new GridBagConstraints(0, 1,
  1009. REMAINDER, 1,
  1010. LIGHT, LIGHT,
  1011. LINE_START, NONE,
  1012. new Insets(0, indent, 0, 0),
  1013. NONE, NONE));
  1014. SizingPanel.add(remoteResizeButton,
  1015. new GridBagConstraints(0, 2,
  1016. REMAINDER, 1,
  1017. LIGHT, LIGHT,
  1018. LINE_START, NONE,
  1019. new Insets(0, 0, 4, 0),
  1020. NONE, NONE));
  1021. SizingPanel.add(remoteScaleButton,
  1022. new GridBagConstraints(0, 3,
  1023. REMAINDER, 1,
  1024. LIGHT, LIGHT,
  1025. LINE_START, NONE,
  1026. new Insets(0, 0, 4, 0),
  1027. NONE, NONE));
  1028. indent = getButtonLabelInset(remoteScaleButton);
  1029. SizingPanel.add(scalingFactorLabel,
  1030. new GridBagConstraints(0, 4,
  1031. 1, 1,
  1032. LIGHT, LIGHT,
  1033. LINE_START, NONE,
  1034. new Insets(0, indent, 4, 0),
  1035. NONE, NONE));
  1036. SizingPanel.add(scalingFactorInput,
  1037. new GridBagConstraints(1, 4,
  1038. 1, 1,
  1039. HEAVY, LIGHT,
  1040. LINE_START, NONE,
  1041. new Insets(0, 5, 4, 0),
  1042. NONE, NONE));
  1043. ScreenPanel.add(SizingPanel,
  1044. new GridBagConstraints(0, 0,
  1045. REMAINDER, 1,
  1046. LIGHT, LIGHT,
  1047. LINE_START, HORIZONTAL,
  1048. new Insets(0, 0, 4, 0),
  1049. NONE, NONE));
  1050. ScreenPanel.add(fullScreenCheckbox,
  1051. new GridBagConstraints(0, 1,
  1052. REMAINDER, 1,
  1053. LIGHT, LIGHT,
  1054. LINE_START, NONE,
  1055. new Insets(0, 0, 4, 0),
  1056. NONE, NONE));
  1057. indent = getButtonLabelInset(fullScreenCheckbox);
  1058. ScreenPanel.add(fullScreenAllMonitorsCheckbox,
  1059. new GridBagConstraints(0, 2,
  1060. REMAINDER, 1,
  1061. LIGHT, LIGHT,
  1062. LINE_START, NONE,
  1063. new Insets(0, indent, 4, 0),
  1064. NONE, NONE));
  1065. ScreenPanel.add(Box.createRigidArea(new Dimension(5, 0)),
  1066. new GridBagConstraints(0, 3,
  1067. REMAINDER, REMAINDER,
  1068. HEAVY, HEAVY,
  1069. LINE_START, BOTH,
  1070. new Insets(0, 0, 0, 0),
  1071. NONE, NONE));
  1072. return ScreenPanel;
  1073. }
  1074. private JPanel createMiscPanel() {
  1075. JPanel MiscPanel = new JPanel(new GridBagLayout());
  1076. MiscPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 0, 5));
  1077. sharedCheckbox =
  1078. new JCheckBox("Shared (don't disconnect other viewers)");
  1079. dotWhenNoCursorCheckbox = new JCheckBox("Show dot when no cursor");
  1080. largeCursorInsteadOfDotCheckbox = new JCheckBox("Use large cursor instead of dot");
  1081. acceptBellCheckbox = new JCheckBox("Beep when requested by the server");
  1082. MiscPanel.add(sharedCheckbox,
  1083. new GridBagConstraints(0, 0,
  1084. 1, 1,
  1085. LIGHT, LIGHT,
  1086. LINE_START, NONE,
  1087. new Insets(0, 0, 4, 0),
  1088. NONE, NONE));
  1089. MiscPanel.add(dotWhenNoCursorCheckbox,
  1090. new GridBagConstraints(0, 1,
  1091. 1, 1,
  1092. LIGHT, LIGHT,
  1093. LINE_START, NONE,
  1094. new Insets(0, 0, 4, 0),
  1095. NONE, NONE));
  1096. MiscPanel.add(largeCursorInsteadOfDotCheckbox,
  1097. new GridBagConstraints(0, 2,
  1098. 1, 1,
  1099. LIGHT, LIGHT,
  1100. LINE_START, NONE,
  1101. new Insets(0, 0, 4, 0),
  1102. NONE, NONE));
  1103. MiscPanel.add(acceptBellCheckbox,
  1104. new GridBagConstraints(0, 3,
  1105. 1, 1,
  1106. LIGHT, LIGHT,
  1107. LINE_START, NONE,
  1108. new Insets(0, 0, 4, 0),
  1109. NONE, NONE));
  1110. MiscPanel.add(Box.createRigidArea(new Dimension(5, 0)),
  1111. new GridBagConstraints(0, 4,
  1112. REMAINDER, REMAINDER,
  1113. HEAVY, HEAVY,
  1114. LINE_START, BOTH,
  1115. new Insets(0, 0, 0, 0),
  1116. NONE, NONE));
  1117. return MiscPanel;
  1118. }
  1119. private JPanel createSshPanel() {
  1120. JPanel sshPanel = new JPanel(new GridBagLayout());
  1121. sshPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 0, 5));
  1122. ButtonGroup sshArgsGroup = new ButtonGroup();
  1123. tunnelCheckbox = new JCheckBox("Tunnel VNC over SSH");
  1124. tunnelCheckbox.addItemListener(new ItemListener() {
  1125. public void itemStateChanged(ItemEvent e) {
  1126. handleTunnel();
  1127. }
  1128. });
  1129. JPanel tunnelPanel = new JPanel(new GridBagLayout());
  1130. viaCheckbox = new JCheckBox("Use SSH gateway");
  1131. viaCheckbox.addItemListener(new ItemListener() {
  1132. public void itemStateChanged(ItemEvent e) {
  1133. handleVia();
  1134. }
  1135. });
  1136. JLabel sshUserLabel = new JLabel("Username");
  1137. viaUserInput = new JTextField();
  1138. JLabel sshUserAtLabel = new JLabel("@");
  1139. JLabel sshHostLabel = new JLabel("Hostname (or IP address)");
  1140. viaHostInput = new JTextField("");
  1141. JLabel sshPortLabel = new JLabel("Port");
  1142. viaPortInput = new IntegerTextField(5);
  1143. extSSHCheckbox = new JCheckBox("Use external SSH client");
  1144. extSSHCheckbox.addItemListener(new ItemListener() {
  1145. public void itemStateChanged(ItemEvent e) {
  1146. handleExtSSH();
  1147. }
  1148. });
  1149. sshClientInput = new JTextField();
  1150. sshClientChooser = new JButton("Browse");
  1151. sshClientChooser.addActionListener(new ActionListener() {
  1152. public void actionPerformed(ActionEvent e) {
  1153. JComponent c = ((JButton)e.getSource()).getRootPane();
  1154. File dflt = new File(extSSHClient.getValueStr());
  1155. File f = showChooser("Path to external SSH client", dflt, c);
  1156. if (f != null && f.exists() && f.isFile() && f.canExecute())
  1157. sshClientInput.setText(f.getAbsolutePath());
  1158. }
  1159. });
  1160. JLabel sshConfigLabel = new JLabel("SSH config file");
  1161. sshConfigInput = new JTextField();
  1162. sshConfigChooser = new JButton("Browse");
  1163. sshConfigChooser.addActionListener(new ActionListener() {
  1164. public void actionPerformed(ActionEvent e) {
  1165. JComponent c = ((JButton)e.getSource()).getRootPane();
  1166. File dflt = new File(sshConfig.getValueStr());
  1167. File f = showChooser("Path to OpenSSH client config file", dflt, c);
  1168. if (f != null && f.exists() && f.isFile() && f.canRead())
  1169. sshConfigInput.setText(f.getAbsolutePath());
  1170. }
  1171. });
  1172. JLabel sshKeyFileLabel = new JLabel("SSH identity file");
  1173. sshKeyFileInput = new JTextField();
  1174. sshKeyFileChooser = new JButton("Browse");
  1175. sshKeyFileChooser.addActionListener(new ActionListener() {
  1176. public void actionPerformed(ActionEvent e) {
  1177. JComponent c = ((JButton)e.getSource()).getRootPane();
  1178. File f = showChooser("Path to SSH key file", null, c);
  1179. if (f != null && f.exists() && f.isFile() && f.canRead())
  1180. sshKeyFileInput.setText(f.getAbsolutePath());
  1181. }
  1182. });
  1183. JPanel sshArgsPanel = new JPanel(new GridBagLayout());
  1184. JLabel sshArgsLabel = new JLabel("Arguments:");
  1185. sshArgsDefaultButton = new GroupedJRadioButton("Default", sshArgsGroup, sshArgsPanel);
  1186. sshArgsDefaultButton.addActionListener(new ActionListener() {
  1187. public void actionPerformed(ActionEvent e) {
  1188. sshArgsInput.setEnabled(sshArgsCustomButton.isSelected());
  1189. }
  1190. });
  1191. sshArgsCustomButton = new GroupedJRadioButton("Custom", sshArgsGroup, sshArgsPanel);
  1192. sshArgsCustomButton.addActionListener(new ActionListener() {
  1193. public void actionPerformed(ActionEvent e) {
  1194. sshArgsInput.setEnabled(sshArgsCustomButton.isSelected());
  1195. }
  1196. });
  1197. sshArgsInput = new JTextField();
  1198. JPanel gatewayPanel = new JPanel(new GridBagLayout());
  1199. gatewayPanel.add(viaCheckbox,
  1200. new GridBagConstraints(0, 0,
  1201. REMAINDER, 1,
  1202. LIGHT, LIGHT,
  1203. LINE_START, NONE,
  1204. new Insets(0, 0, 4, 0),
  1205. NONE, NONE));
  1206. int indent = getButtonLabelInset(viaCheckbox);
  1207. gatewayPanel.add(sshUserLabel,
  1208. new GridBagConstraints(0, 1,
  1209. 1, 1,
  1210. LIGHT, LIGHT,
  1211. LINE_START, HORIZONTAL,
  1212. new Insets(0, indent, 4, 0),
  1213. NONE, NONE));
  1214. gatewayPanel.add(sshHostLabel,
  1215. new GridBagConstraints(2, 1,
  1216. 1, 1,
  1217. HEAVY, LIGHT,
  1218. LINE_START, HORIZONTAL,
  1219. new Insets(0, 0, 4, 0),
  1220. NONE, NONE));
  1221. gatewayPanel.add(sshPortLabel,
  1222. new GridBagConstraints(3, 1,
  1223. 1, 1,
  1224. LIGHT, LIGHT,
  1225. LINE_START, HORIZONTAL,
  1226. new Insets(0, 5, 4, 0),
  1227. NONE, NONE));
  1228. gatewayPanel.add(viaUserInput,
  1229. new GridBagConstraints(0, 2,
  1230. 1, 1,
  1231. LIGHT, LIGHT,
  1232. LINE_START, HORIZONTAL,
  1233. new Insets(0, indent, 0, 0),
  1234. NONE, NONE));
  1235. gatewayPanel.add(sshUserAtLabel,
  1236. new GridBagConstraints(1, 2,
  1237. 1, 1,
  1238. LIGHT, LIGHT,
  1239. LINE_START, HORIZONTAL,
  1240. new Insets(0, 2, 0, 2),
  1241. NONE, NONE));
  1242. gatewayPanel.add(viaHostInput,
  1243. new GridBagConstraints(2, 2,
  1244. 1, 1,
  1245. HEAVY, LIGHT,
  1246. LINE_START, HORIZONTAL,
  1247. new Insets(0, 0, 0, 0),
  1248. NONE, NONE));
  1249. gatewayPanel.add(viaPortInput,
  1250. new GridBagConstraints(3, 2,
  1251. 1, 1,
  1252. LIGHT, LIGHT,
  1253. LINE_START, HORIZONTAL,
  1254. new Insets(0, 5, 0, 0),
  1255. NONE, NONE));
  1256. JPanel clientPanel = new JPanel(new GridBagLayout());
  1257. clientPanel.add(extSSHCheckbox,
  1258. new GridBagConstraints(0, 0,
  1259. 1, 1,
  1260. LIGHT, LIGHT,
  1261. LINE_START, NONE,
  1262. new Insets(0, 0, 0, 0),
  1263. NONE, NONE));
  1264. clientPanel.add(sshClientInput,
  1265. new GridBagConstraints(1, 0,
  1266. 1, 1,
  1267. HEAVY, LIGHT,
  1268. LINE_START, HORIZONTAL,
  1269. new Insets(0, 5, 0, 0),
  1270. NONE, NONE));
  1271. clientPanel.add(sshClientChooser,
  1272. new GridBagConstraints(2, 0,
  1273. 1, 1,
  1274. LIGHT, LIGHT,
  1275. LINE_START, NONE,
  1276. new Insets(0, 5, 0, 0),
  1277. NONE, NONE));
  1278. sshArgsPanel.add(sshArgsLabel,
  1279. new GridBagConstraints(0, 1,
  1280. 1, 1,
  1281. LIGHT, LIGHT,
  1282. LINE_START, NONE,
  1283. new Insets(0, 0, 0, 0),
  1284. NONE, NONE));
  1285. sshArgsPanel.add(sshArgsDefaultButton,
  1286. new GridBagConstraints(1, 1,
  1287. 1, 1,
  1288. LIGHT, LIGHT,
  1289. LINE_START, NONE,
  1290. new Insets(0, 5, 0, 0),
  1291. NONE, NONE));
  1292. sshArgsPanel.add(sshArgsCustomButton,
  1293. new GridBagConstraints(2, 1,
  1294. 1, 1,
  1295. LIGHT, LIGHT,
  1296. LINE_START, NONE,
  1297. new Insets(0, 5, 0, 0),
  1298. NONE, NONE));
  1299. sshArgsPanel.add(sshArgsInput,
  1300. new GridBagConstraints(3, 1,
  1301. 1, 1,
  1302. HEAVY, LIGHT,
  1303. LINE_START, HORIZONTAL,
  1304. new Insets(0, 5, 0, 0),
  1305. NONE, NONE));
  1306. indent = getButtonLabelInset(extSSHCheckbox);
  1307. clientPanel.add(sshArgsPanel,
  1308. new GridBagConstraints(0, 1,
  1309. REMAINDER, 1,
  1310. LIGHT, LIGHT,
  1311. LINE_START, HORIZONTAL,
  1312. new Insets(4, indent, 0, 0),
  1313. NONE, NONE));
  1314. JPanel opensshPanel = new JPanel(new GridBagLayout());
  1315. TitledBorder border =
  1316. BorderFactory.createTitledBorder("Embedded SSH client configuration");
  1317. opensshPanel.setBorder(border);
  1318. opensshPanel.add(sshConfigLabel,
  1319. new GridBagConstraints(0, 0,
  1320. 1, 1,
  1321. LIGHT, LIGHT,
  1322. LINE_START, NONE,
  1323. new Insets(0, 0, 5, 0),
  1324. NONE, NONE));
  1325. opensshPanel.add(sshConfigInput,
  1326. new GridBagConstraints(1, 0,
  1327. 1, 1,
  1328. HEAVY, LIGHT,
  1329. LINE_START, HORIZONTAL,
  1330. new Insets(0, 5, 5, 0),
  1331. NONE, NONE));
  1332. opensshPanel.add(sshConfigChooser,
  1333. new GridBagConstraints(2, 0,
  1334. 1, 1,
  1335. LIGHT, LIGHT,
  1336. LINE_START, VERTICAL,
  1337. new Insets(0, 5, 5, 0),
  1338. NONE, NONE));
  1339. opensshPanel.add(sshKeyFileLabel,
  1340. new GridBagConstraints(0, 1,
  1341. 1, 1,
  1342. LIGHT, LIGHT,
  1343. LINE_START, NONE,
  1344. new Insets(0, 0, 0, 0),
  1345. NONE, NONE));
  1346. opensshPanel.add(sshKeyFileInput,
  1347. new GridBagConstraints(1, 1,
  1348. 1, 1,
  1349. HEAVY, LIGHT,
  1350. LINE_START, HORIZONTAL,
  1351. new Insets(0, 5, 0, 0),
  1352. NONE, NONE));
  1353. opensshPanel.add(sshKeyFileChooser,
  1354. new GridBagConstraints(2, 1,
  1355. 1, 1,
  1356. LIGHT, LIGHT,
  1357. LINE_START, VERTICAL,
  1358. new Insets(0, 5, 0, 0),
  1359. NONE, NONE));
  1360. tunnelPanel.add(gatewayPanel,
  1361. new GridBagConstraints(0, 0,
  1362. REMAINDER, 1,
  1363. HEAVY, LIGHT,
  1364. LINE_START, HORIZONTAL,
  1365. new Insets(0, 0, 4, 0),
  1366. NONE, NONE));
  1367. tunnelPanel.add(clientPanel,
  1368. new GridBagConstraints(0, 1,
  1369. REMAINDER, 1,
  1370. HEAVY, LIGHT,
  1371. LINE_START, HORIZONTAL,
  1372. new Insets(0, 0, 4, 0),
  1373. NONE, NONE));
  1374. tunnelPanel.add(opensshPanel,
  1375. new GridBagConstraints(0, 2,
  1376. REMAINDER, 1,
  1377. HEAVY, LIGHT,
  1378. LINE_START, HORIZONTAL,
  1379. new Insets(0, 0, 0, 0),
  1380. NONE, NONE));
  1381. sshPanel.add(tunnelCheckbox,
  1382. new GridBagConstraints(0, 0,
  1383. REMAINDER, 1,
  1384. LIGHT, LIGHT,
  1385. LINE_START, NONE,
  1386. new Insets(0, 0, 4, 0),
  1387. NONE, NONE));
  1388. indent = getButtonLabelInset(tunnelCheckbox);
  1389. sshPanel.add(tunnelPanel,
  1390. new GridBagConstraints(0, 2,
  1391. REMAINDER, 1,
  1392. LIGHT, LIGHT,
  1393. LINE_START, HORIZONTAL,
  1394. new Insets(0, indent, 4, 0),
  1395. NONE, NONE));
  1396. sshPanel.add(Box.createRigidArea(new Dimension(5, 0)),
  1397. new GridBagConstraints(0, RELATIVE,
  1398. REMAINDER, REMAINDER,
  1399. HEAVY, HEAVY,
  1400. LINE_START, BOTH,
  1401. new Insets(0, 0, 0, 0),
  1402. NONE, NONE));
  1403. return sshPanel;
  1404. }
  1405. private void handleAutoselect()
  1406. {
  1407. ButtonGroup[] groups = { encodingGroup, colorlevelGroup };
  1408. for (ButtonGroup grp : groups) {
  1409. Enumeration<AbstractButton> elems = grp.getElements();
  1410. while (elems.hasMoreElements())
  1411. elems.nextElement().setEnabled(!autoselectCheckbox.isSelected());
  1412. }
  1413. // JPEG setting is also affected by autoselection
  1414. jpegCheckbox.setEnabled(!autoselectCheckbox.isSelected());
  1415. handleJpeg();
  1416. }
  1417. private void handleCompression()
  1418. {
  1419. compressionInput.setEnabled(compressionCheckbox.isSelected());
  1420. }
  1421. private void handleJpeg()
  1422. {
  1423. if (jpegCheckbox.isSelected() &&
  1424. !autoselectCheckbox.isSelected())
  1425. jpegInput.setEnabled(true);
  1426. else
  1427. jpegInput.setEnabled(false);
  1428. }
  1429. private void handleX509()
  1430. {
  1431. caInput.setEnabled(encX509Checkbox.isSelected());
  1432. caChooser.setEnabled(encX509Checkbox.isSelected());
  1433. crlInput.setEnabled(encX509Checkbox.isSelected());
  1434. crlChooser.setEnabled(encX509Checkbox.isSelected());
  1435. }
  1436. private void handleRSAAES()
  1437. {
  1438. authVncCheckbox.setSelected(true);
  1439. authPlainCheckbox.setSelected(true);
  1440. }
  1441. private void handleSendLocalUsername()
  1442. {
  1443. boolean value = authIdentCheckbox.isSelected() ||
  1444. authPlainCheckbox.isSelected();
  1445. sendLocalUsernameCheckbox.setEnabled(value);
  1446. }
  1447. private void handleDesktopSize()
  1448. {
  1449. desktopWidthInput.setEnabled(desktopSizeCheckbox.isSelected());
  1450. desktopHeightInput.setEnabled(desktopSizeCheckbox.isSelected());
  1451. }
  1452. private void handleRemoteResize()
  1453. {
  1454. scalingFactorInput.setEnabled(!remoteResizeButton.isSelected());
  1455. }
  1456. private void handleTunnel()
  1457. {
  1458. viaCheckbox.setEnabled(tunnelCheckbox.isSelected());
  1459. extSSHCheckbox.setEnabled(tunnelCheckbox.isSelected());
  1460. if (tunnelCheckbox.isSelected()) {
  1461. JComponent[] components = { viaUserInput, viaHostInput, viaPortInput };
  1462. for (JComponent c : components)
  1463. c.setEnabled(viaCheckbox.isSelected());
  1464. sshClientInput.setEnabled(extSSHCheckbox.isSelected());
  1465. sshClientChooser.setEnabled(extSSHCheckbox.isSelected());
  1466. sshArgsDefaultButton.setEnabled(extSSHCheckbox.isSelected());
  1467. sshArgsCustomButton.setEnabled(extSSHCheckbox.isSelected());
  1468. sshArgsInput.setEnabled(extSSHCheckbox.isSelected());
  1469. sshConfigInput.setEnabled(!extSSHCheckbox.isSelected());
  1470. sshConfigChooser.setEnabled(!extSSHCheckbox.isSelected());
  1471. sshKeyFileInput.setEnabled(!extSSHCheckbox.isSelected());
  1472. sshKeyFileChooser.setEnabled(!extSSHCheckbox.isSelected());
  1473. } else {
  1474. JComponent[] components = {
  1475. viaUserInput, viaHostInput, viaPortInput, sshClientInput,
  1476. sshClientChooser, sshArgsDefaultButton, sshArgsCustomButton,
  1477. sshArgsInput, sshConfigInput, sshConfigChooser, sshKeyFileInput,
  1478. sshKeyFileChooser, };
  1479. for (JComponent c : components)
  1480. c.setEnabled(false);
  1481. }
  1482. }
  1483. private void handleVia()
  1484. {
  1485. if (tunnelCheckbox.isSelected()) {
  1486. viaUserInput.setEnabled(viaCheckbox.isSelected());
  1487. viaHostInput.setEnabled(viaCheckbox.isSelected());
  1488. viaPortInput.setEnabled(viaCheckbox.isSelected());
  1489. }
  1490. }
  1491. private void handleExtSSH()
  1492. {
  1493. if (tunnelCheckbox.isSelected()) {
  1494. sshClientInput.setEnabled(extSSHCheckbox.isSelected());
  1495. sshClientChooser.setEnabled(extSSHCheckbox.isSelected());
  1496. sshArgsDefaultButton.setEnabled(extSSHCheckbox.isSelected());
  1497. sshArgsCustomButton.setEnabled(extSSHCheckbox.isSelected());
  1498. sshConfigInput.setEnabled(!extSSHCheckbox.isSelected());
  1499. sshConfigChooser.setEnabled(!extSSHCheckbox.isSelected());
  1500. sshKeyFileInput.setEnabled(!extSSHCheckbox.isSelected());
  1501. sshKeyFileChooser.setEnabled(!extSSHCheckbox.isSelected());
  1502. if (sshArgsCustomButton.isSelected())
  1503. sshArgsInput.setEnabled(extSSHCheckbox.isSelected());
  1504. else
  1505. sshArgsInput.setEnabled(false);
  1506. }
  1507. }
  1508. private void handleRfbState()
  1509. {
  1510. CConn cc = VncViewer.cc;
  1511. if (cc != null && cc.state() == CConnection.stateEnum.RFBSTATE_NORMAL) {
  1512. JComponent[] components = {
  1513. encNoneCheckbox, encTLSCheckbox, encX509Checkbox, authNoneCheckbox,
  1514. authVncCheckbox, authVncCheckbox, authIdentCheckbox, authPlainCheckbox,
  1515. sendLocalUsernameCheckbox, caInput, caChooser, crlInput, crlChooser,
  1516. sharedCheckbox, tunnelCheckbox, viaCheckbox, viaUserInput, viaHostInput,
  1517. viaPortInput, extSSHCheckbox, sshClientInput, sshClientChooser,
  1518. sshArgsDefaultButton, sshArgsCustomButton, sshArgsInput, sshConfigInput,
  1519. sshKeyFileInput, sshConfigChooser, sshKeyFileChooser,
  1520. };
  1521. for (JComponent c : components)
  1522. c.setEnabled(false);
  1523. }
  1524. }
  1525. static LogWriter vlog = new LogWriter("OptionsDialog");
  1526. }