diff options
author | Brian Hinz <bphinz@users.sourceforge.net> | 2013-05-12 15:46:09 +0000 |
---|---|---|
committer | Brian Hinz <bphinz@users.sourceforge.net> | 2013-05-12 15:46:09 +0000 |
commit | c0a360943aa9d1eac940c7105388eddc4c87e702 (patch) | |
tree | 0d6e4ee5603d7a062f71cde7430aa4e08f052a30 /java/com/tigervnc/vncviewer | |
parent | 5cb75ac9bbd3b445b883bb470b7a77387e079620 (diff) | |
download | tigervnc-c0a360943aa9d1eac940c7105388eddc4c87e702.tar.gz tigervnc-c0a360943aa9d1eac940c7105388eddc4c87e702.zip |
Whitespace cleanup only
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@5097 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'java/com/tigervnc/vncviewer')
-rw-r--r-- | java/com/tigervnc/vncviewer/BIPixelBuffer.java | 24 | ||||
-rw-r--r-- | java/com/tigervnc/vncviewer/CConn.java | 72 | ||||
-rw-r--r-- | java/com/tigervnc/vncviewer/ClipboardDialog.java | 10 | ||||
-rw-r--r-- | java/com/tigervnc/vncviewer/DesktopWindow.java | 12 | ||||
-rw-r--r-- | java/com/tigervnc/vncviewer/Dialog.java | 12 | ||||
-rw-r--r-- | java/com/tigervnc/vncviewer/F8Menu.java | 6 | ||||
-rw-r--r-- | java/com/tigervnc/vncviewer/FileUtils.java | 6 | ||||
-rw-r--r-- | java/com/tigervnc/vncviewer/MenuKey.java | 28 | ||||
-rw-r--r-- | java/com/tigervnc/vncviewer/OptionsDialog.java | 30 | ||||
-rw-r--r-- | java/com/tigervnc/vncviewer/OptionsDialogCallback.java | 6 | ||||
-rw-r--r-- | java/com/tigervnc/vncviewer/PasswdDialog.java | 18 | ||||
-rw-r--r-- | java/com/tigervnc/vncviewer/PlatformPixelBuffer.java | 6 | ||||
-rw-r--r-- | java/com/tigervnc/vncviewer/ServerDialog.java | 12 | ||||
-rw-r--r-- | java/com/tigervnc/vncviewer/UserPreferences.java | 6 | ||||
-rw-r--r-- | java/com/tigervnc/vncviewer/Viewport.java | 10 | ||||
-rw-r--r-- | java/com/tigervnc/vncviewer/VncViewer.java | 34 | ||||
-rw-r--r-- | java/com/tigervnc/vncviewer/tunnel.java | 90 |
17 files changed, 191 insertions, 191 deletions
diff --git a/java/com/tigervnc/vncviewer/BIPixelBuffer.java b/java/com/tigervnc/vncviewer/BIPixelBuffer.java index ae38302c..9612b36f 100644 --- a/java/com/tigervnc/vncviewer/BIPixelBuffer.java +++ b/java/com/tigervnc/vncviewer/BIPixelBuffer.java @@ -1,16 +1,16 @@ /* Copyright (C) 2012 Brian P. Hinz * Copyright (C) 2012 D. R. Commander. All Rights Reserved. - * + * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, @@ -41,7 +41,7 @@ public class BIPixelBuffer extends PlatformPixelBuffer implements ImageObserver super.updateColourMap(); createImage(width_, height_); } - + // resize() resizes the image, preserving the image data where possible. public void resize(int w, int h) { if (w == width() && h == height()) @@ -67,14 +67,14 @@ public class BIPixelBuffer extends PlatformPixelBuffer implements ImageObserver Graphics2D graphics = (Graphics2D)image.getGraphics(); switch (format.depth) { case 24: - graphics.setColor(new Color(pix)); - graphics.fillRect(x, y, w, h); + graphics.setColor(new Color(pix)); + graphics.fillRect(x, y, w, h); break; default: Color color = new Color((0xff << 24) | (cm.getRed(pix) << 16) | (cm.getGreen(pix) << 8) | (cm.getBlue(pix))); - graphics.setColor(color); - graphics.fillRect(x, y, w, h); + graphics.setColor(color); + graphics.fillRect(x, y, w, h); break; } graphics.dispose(); @@ -83,7 +83,7 @@ public class BIPixelBuffer extends PlatformPixelBuffer implements ImageObserver public void imageRect(int x, int y, int w, int h, Object pix) { if (pix instanceof Image) { Image img = (Image)pix; - clip = new Rectangle(x, y, w, h); + clip = new Rectangle(x, y, w, h); synchronized(clip) { tk.prepareImage(img, -1, -1, this); try { @@ -91,7 +91,7 @@ public class BIPixelBuffer extends PlatformPixelBuffer implements ImageObserver } catch (InterruptedException e) { throw new Exception("Error decoding JPEG data"); } - } + } clip = null; img.flush(); } else { @@ -101,7 +101,7 @@ public class BIPixelBuffer extends PlatformPixelBuffer implements ImageObserver bytes[i] = (byte)((int[])pix)[i]; pix = bytes; } - image.getSampleModel().setDataElements(x, y, w, h, pix, db); + image.getSampleModel().setDataElements(x, y, w, h, pix, db); } } @@ -123,7 +123,7 @@ public class BIPixelBuffer extends PlatformPixelBuffer implements ImageObserver if (clip != null) { synchronized(clip) { Graphics2D graphics = (Graphics2D)image.getGraphics(); - graphics.drawImage(img, clip.x, clip.y, clip.width, clip.height, null); + graphics.drawImage(img, clip.x, clip.y, clip.width, clip.height, null); graphics.dispose(); clip.notify(); } diff --git a/java/com/tigervnc/vncviewer/CConn.java b/java/com/tigervnc/vncviewer/CConn.java index 97ba9da9..15521aa5 100644 --- a/java/com/tigervnc/vncviewer/CConn.java +++ b/java/com/tigervnc/vncviewer/CConn.java @@ -61,11 +61,11 @@ public class CConn extends CConnection { public final PixelFormat getPreferredPF() { return fullColourPF; } - static final PixelFormat verylowColourPF = + static final PixelFormat verylowColourPF = new PixelFormat(8, 3, false, true, 1, 1, 1, 2, 1, 0); - static final PixelFormat lowColourPF = + static final PixelFormat lowColourPF = new PixelFormat(8, 6, false, true, 3, 3, 3, 4, 2, 0); - static final PixelFormat mediumColourPF = + static final PixelFormat mediumColourPF = new PixelFormat(8, 8, false, false, 7, 7, 3, 0, 3, 6); static final int KEY_LOC_SHIFT_R = 0; static final int KEY_LOC_SHIFT_L = 16; @@ -75,9 +75,9 @@ public class CConn extends CConnection // The following methods are all called from the RFB thread public CConn(VncViewer viewer_, Socket sock_, - String vncServerName) + String vncServerName) { - serverHost = null; serverPort = 0; sock = sock_; viewer = viewer_; + serverHost = null; serverPort = 0; sock = sock_; viewer = viewer_; pendingPFChange = false; currentEncoding = Encodings.encodingTight; lastServerEncoding = -1; fullColour = viewer.fullColour.getValue(); @@ -188,7 +188,7 @@ public class CConn extends CConnection String title = ("VNC Authentication [" +csecurity.description() + "]"); String passwordFileStr = viewer.passwordFile.getValue(); - PasswdDialog dlg; + PasswdDialog dlg; if (user == null && passwordFileStr != "") { InputStream fp = null; @@ -217,7 +217,7 @@ public class CConn extends CConnection user.append((String)System.getProperties().get("user.name")); return true; } - dlg = new PasswdDialog(title, viewer.sendLocalUsername.getValue(), + dlg = new PasswdDialog(title, viewer.sendLocalUsername.getValue(), (passwd == null)); } if (!dlg.showDialog()) return false; @@ -242,7 +242,7 @@ public class CConn extends CConnection super.serverInit(); // If using AutoSelect with old servers, start in FullColor - // mode. See comment in autoSelectFormatAndEncoding. + // mode. See comment in autoSelectFormatAndEncoding. if (cp.beforeVersion(3, 8) && autoSelect) fullColour = true; @@ -305,7 +305,7 @@ public class CConn extends CConnection // setName() is called when the desktop name changes public void setName(String name) { super.setName(name); - + if (viewport != null) { viewport.setTitle(name+" - TigerVNC"); } @@ -314,8 +314,8 @@ public class CConn extends CConnection // framebufferUpdateStart() is called at the beginning of an update. // Here we try to send out a new framebuffer update request so that the // next update can be sent out in parallel with us decoding the current - // one. - public void framebufferUpdateStart() + // one. + public void framebufferUpdateStart() { // Note: This might not be true if sync fences are supported pendingUpdate = false; @@ -327,14 +327,14 @@ public class CConn extends CConnection // For each rectangle, the FdInStream will have timed the speed // of the connection, allowing us to select format and encoding // appropriately, and then request another incremental update. - public void framebufferUpdateEnd() + public void framebufferUpdateEnd() { desktop.updateWindow(); if (firstUpdate) { int width, height; - + // We need fences to make extra update requests and continuous // updates "safe". See fence() for the next step. if (cp.supportsFence) @@ -354,9 +354,9 @@ public class CConn extends CConnection else if (layout.num_screens() != 1) { while (true) { - Iterator<Screen> iter = layout.screens.iterator(); + Iterator<Screen> iter = layout.screens.iterator(); Screen screen = (Screen)iter.next(); - + if (!iter.hasNext()) break; @@ -395,9 +395,9 @@ public class CConn extends CConnection desktop.setColourMapEntries(firstColour, nColours, rgbs); } - public void bell() { + public void bell() { if (viewer.acceptBell.getValue()) - desktop.getToolkit().beep(); + desktop.getToolkit().beep(); } public void serverCutText(String str, int len) { @@ -484,7 +484,7 @@ public class CConn extends CConnection return; if ((desktop.width() == cp.width) && (desktop.height() == cp.height)) return; - + desktop.resize(); recreateViewport(); } @@ -580,14 +580,14 @@ public class CConn extends CConnection // Check that we have a decent bandwidth measurement if ((kbitsPerSecond == 0) || (timeWaited < 100)) return; - + // Select appropriate quality level if (!cp.noJpeg) { if (kbitsPerSecond > 16000) newQualityLevel = 8; else newQualityLevel = 6; - + if (newQualityLevel != cp.qualityLevel) { vlog.info("Throughput "+kbitsPerSecond+ " kbit/s - changing to quality "+newQualityLevel); @@ -607,17 +607,17 @@ public class CConn extends CConnection // old servers. return; } - + // Select best color level newFullColour = (kbitsPerSecond > 256); if (newFullColour != fullColour) { vlog.info("Throughput "+kbitsPerSecond+ - " kbit/s - full color is now "+ + " kbit/s - full color is now "+ (newFullColour ? "enabled" : "disabled")); fullColour = newFullColour; formatChange = true; forceNonincremental = true; - } + } } // requestNewUpdate() requests an update from the server, having set the @@ -721,10 +721,10 @@ public class CConn extends CConnection Window fullScreenWindow = Viewport.getFullScreenWindow(); if (fullScreenWindow != null) Viewport.setFullScreenWindow(null); - String msg = + String msg = String.format(VncViewer.aboutText, VncViewer.version, VncViewer.build, VncViewer.buildDate, VncViewer.buildTime); - JOptionPane op = + JOptionPane op = new JOptionPane(msg, JOptionPane.INFORMATION_MESSAGE, JOptionPane.DEFAULT_OPTION, VncViewer.logoIcon); JDialog dlg = op.createDialog("About TigerVNC Viewer for Java"); @@ -748,7 +748,7 @@ public class CConn extends CConnection "Line speed estimate: %d kbit/s%n"+ "Protocol version: %d.%d%n"+ "Security method: %s [%s]%n"); - String msg = + String msg = String.format(info, cp.name(), sock.getPeerName(), sock.getPeerPort(), cp.width, cp.height, @@ -922,7 +922,7 @@ public class CConn extends CConnection options.scalingFactor.setSelectedItem("Auto"); } else if(scaleString.equalsIgnoreCase("FixedRatio")) { options.scalingFactor.setSelectedItem("Fixed Aspect Ratio"); - } else { + } else { digit = Integer.parseInt(scaleString); if (digit >= 1 && digit <= 1000) { options.scalingFactor.setSelectedItem(digit+"%"); @@ -930,7 +930,7 @@ public class CConn extends CConnection digit = Integer.parseInt(viewer.scalingFactor.getDefaultStr()); options.scalingFactor.setSelectedItem(digit+"%"); } - int scaleFactor = + int scaleFactor = Integer.parseInt(scaleString.substring(0, scaleString.length())); if (desktop != null) desktop.setScaledSize(); @@ -967,7 +967,7 @@ public class CConn extends CConnection cp.customCompressLevel = viewer.customCompressLevel.getValue(); encodingChange = true; } - if (Integer.parseInt(options.compressLevel.getSelectedItem().toString()) >= 0 && + if (Integer.parseInt(options.compressLevel.getSelectedItem().toString()) >= 0 && Integer.parseInt(options.compressLevel.getSelectedItem().toString()) <= 9) { viewer.compressLevel.setParam(options.compressLevel.getSelectedItem().toString()); } else { @@ -1059,7 +1059,7 @@ public class CConn extends CConnection Security.DisableSecType(Security.secTypeTLSPlain); Security.DisableSecType(Security.secTypeTLSIdent); } - + /* Process security types which use X509 encryption */ if (options.encX509.isSelected()) { if (options.secNone.isSelected()) @@ -1076,7 +1076,7 @@ public class CConn extends CConnection Security.DisableSecType(Security.secTypeX509Plain); Security.DisableSecType(Security.secTypeX509Ident); } - + /* Process *None security types */ if (options.secNone.isSelected()) { if (options.encNone.isSelected()) @@ -1090,7 +1090,7 @@ public class CConn extends CConnection Security.DisableSecType(Security.secTypeTLSNone); Security.DisableSecType(Security.secTypeX509None); } - + /* Process *Vnc security types */ if (options.secVnc.isSelected()) { if (options.encNone.isSelected()) @@ -1104,7 +1104,7 @@ public class CConn extends CConnection Security.DisableSecType(Security.secTypeTLSVnc); Security.DisableSecType(Security.secTypeX509Vnc); } - + /* Process *Plain security types */ if (options.secPlain.isSelected()) { if (options.encNone.isSelected()) @@ -1118,7 +1118,7 @@ public class CConn extends CConnection Security.DisableSecType(Security.secTypeTLSPlain); Security.DisableSecType(Security.secTypeX509Plain); } - + /* Process *Ident security types */ if (options.secIdent.isSelected()) { if (options.encNone.isSelected()) @@ -1542,7 +1542,7 @@ public class CConn extends CConnection // reading and writing int and boolean is atomic in java, so no // synchronization of the following flags is needed: - + int lowColourLevel; @@ -1589,6 +1589,6 @@ public class CConn extends CConnection private boolean fullColour; private boolean autoSelect; boolean fullScreen; - + static LogWriter vlog = new LogWriter("CConn"); } diff --git a/java/com/tigervnc/vncviewer/ClipboardDialog.java b/java/com/tigervnc/vncviewer/ClipboardDialog.java index 41f92b1a..d6e2525c 100644 --- a/java/com/tigervnc/vncviewer/ClipboardDialog.java +++ b/java/com/tigervnc/vncviewer/ClipboardDialog.java @@ -1,16 +1,16 @@ /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. * Copyright (C) 2011 Brian P. Hinz - * + * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, @@ -61,7 +61,7 @@ class ClipboardDialog extends Dialog implements ActionListener { textArea.setText(current); textArea.selectAll(); } - + public void setContents(String str) { current = str; textArea.setText(str); @@ -69,7 +69,7 @@ class ClipboardDialog extends Dialog implements ActionListener { } public void serverCutText(String str, int len) { - setContents(str); + setContents(str); SecurityManager sm = System.getSecurityManager(); try { if (sm != null) sm.checkSystemClipboardAccess(); diff --git a/java/com/tigervnc/vncviewer/DesktopWindow.java b/java/com/tigervnc/vncviewer/DesktopWindow.java index 7621af50..3657b03a 100644 --- a/java/com/tigervnc/vncviewer/DesktopWindow.java +++ b/java/com/tigervnc/vncviewer/DesktopWindow.java @@ -70,7 +70,7 @@ class DesktopWindow extends JPanel implements Runnable, MouseListener, cursorBacking = new ManagedPixelBuffer(); Dimension bestSize = tk.getBestCursorSize(16, 16); BufferedImage cursorImage; - cursorImage = new BufferedImage(bestSize.width, bestSize.height, + cursorImage = new BufferedImage(bestSize.width, bestSize.height, BufferedImage.TYPE_INT_ARGB); java.awt.Point hotspot = new java.awt.Point(0,0); nullCursor = tk.createCustomCursor(cursorImage, hotspot, "nullCursor"); @@ -153,12 +153,12 @@ class DesktopWindow extends JPanel implements Runnable, MouseListener, int ch = (int)Math.floor((float)cursor.height() * scaleHeightRatio); Dimension bestSize = tk.getBestCursorSize(cw, ch); MemoryImageSource cursorSrc; - cursorSrc = new MemoryImageSource(cursor.width(), cursor.height(), + cursorSrc = new MemoryImageSource(cursor.width(), cursor.height(), ColorModel.getRGBdefault(), cursor.data, 0, cursor.width()); Image srcImage = tk.createImage(cursorSrc); BufferedImage cursorImage; - cursorImage = new BufferedImage(bestSize.width, bestSize.height, + cursorImage = new BufferedImage(bestSize.width, bestSize.height, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = cursorImage.createGraphics(); g2.setRenderingHint(RenderingHints.KEY_RENDERING, @@ -313,9 +313,9 @@ class DesktopWindow extends JPanel implements Runnable, MouseListener, if (!scaleString.equalsIgnoreCase("Auto") && !scaleString.equalsIgnoreCase("FixedRatio")) { int scalingFactor = Integer.parseInt(scaleString); - scaledWidth = + scaledWidth = (int)Math.floor((float)cc.cp.width * (float)scalingFactor/100.0); - scaledHeight = + scaledHeight = (int)Math.floor((float)cc.cp.height * (float)scalingFactor/100.0); } else { if (cc.viewport == null) { @@ -324,7 +324,7 @@ class DesktopWindow extends JPanel implements Runnable, MouseListener, } else { Dimension vpSize = cc.viewport.getSize(); Insets vpInsets = cc.viewport.getInsets(); - Dimension availableSize = + Dimension availableSize = new Dimension(vpSize.width - vpInsets.left - vpInsets.right, vpSize.height - vpInsets.top - vpInsets.bottom); if (availableSize.width == 0 || availableSize.height == 0) diff --git a/java/com/tigervnc/vncviewer/Dialog.java b/java/com/tigervnc/vncviewer/Dialog.java index 19e38e42..41301232 100644 --- a/java/com/tigervnc/vncviewer/Dialog.java +++ b/java/com/tigervnc/vncviewer/Dialog.java @@ -1,16 +1,16 @@ /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. * Copyright (C) 2011-2013 Brian P. Hinz - * + * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, @@ -83,10 +83,10 @@ class Dialog extends JDialog { } public void addGBComponent(JComponent c, JComponent cp, - int gx, int gy, - int gw, int gh, + int gx, int gy, + int gw, int gh, int gipx, int gipy, - double gwx, double gwy, + double gwx, double gwy, int fill, int anchor, Insets insets) { diff --git a/java/com/tigervnc/vncviewer/F8Menu.java b/java/com/tigervnc/vncviewer/F8Menu.java index 54a42535..543f7408 100644 --- a/java/com/tigervnc/vncviewer/F8Menu.java +++ b/java/com/tigervnc/vncviewer/F8Menu.java @@ -1,16 +1,16 @@ /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. * Copyright (C) 2011 Brian P. Hinz - * + * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, diff --git a/java/com/tigervnc/vncviewer/FileUtils.java b/java/com/tigervnc/vncviewer/FileUtils.java index e7f3c5a4..af5da3c2 100644 --- a/java/com/tigervnc/vncviewer/FileUtils.java +++ b/java/com/tigervnc/vncviewer/FileUtils.java @@ -1,15 +1,15 @@ /* Copyright (C) 2012 Brian P. Hinz - * + * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, diff --git a/java/com/tigervnc/vncviewer/MenuKey.java b/java/com/tigervnc/vncviewer/MenuKey.java index 5fdd037a..63b63802 100644 --- a/java/com/tigervnc/vncviewer/MenuKey.java +++ b/java/com/tigervnc/vncviewer/MenuKey.java @@ -1,17 +1,17 @@ /* Copyright 2011 Martin Koegler <mkoegler@auto.tuwien.ac.at> * Copyright 2011 Pierre Ossman <ossman@cendio.se> for Cendio AB * Copyright 2012 Brian P. Hinz - * + * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, @@ -24,7 +24,7 @@ import java.awt.event.KeyEvent; import com.tigervnc.rfb.*; -public class MenuKey +public class MenuKey { static class MenuKeySymbol { public MenuKeySymbol(String name_, int keycode_, int keysym_) { @@ -52,7 +52,7 @@ public class MenuKey new MenuKeySymbol("F12", KeyEvent.VK_F12, Keysyms.F12), new MenuKeySymbol("Pause", KeyEvent.VK_PAUSE, Keysyms.Pause), new MenuKeySymbol("Print", KeyEvent.VK_PRINTSCREEN, Keysyms.Print), - new MenuKeySymbol("Scroll_Lock", KeyEvent.VK_SCROLL_LOCK, + new MenuKeySymbol("Scroll_Lock", KeyEvent.VK_SCROLL_LOCK, Keysyms.Scroll_Lock), new MenuKeySymbol("Escape", KeyEvent.VK_ESCAPE, Keysyms.Escape), new MenuKeySymbol("Insert", KeyEvent.VK_INSERT, Keysyms.Insert), @@ -61,11 +61,11 @@ public class MenuKey new MenuKeySymbol("Page_Up", KeyEvent.VK_PAGE_UP, Keysyms.Page_Up), new MenuKeySymbol("Page_Down", KeyEvent.VK_PAGE_DOWN, Keysyms.Page_Down) }; - + static int getMenuKeySymbolCount() { return menuSymbols.length; } - + public static MenuKeySymbol[] getMenuKeySymbols() { return menuSymbols; } @@ -79,30 +79,30 @@ public class MenuKey } return s; } - + static int getMenuKeyCode() { int menuKeyCode = KeyEvent.VK_F8; - + @SuppressWarnings({"static"}) - String menuKeyStr = + String menuKeyStr = Configuration.global().getParam("menuKey").getValueStr(); for(int i = 0; i < getMenuKeySymbolCount(); i++) if (menuSymbols[i].name.equals(menuKeyStr)) menuKeyCode = menuSymbols[i].keycode; - + return menuKeyCode; } static int getMenuKeySym() { int menuKeySym = Keysyms.F8; - + @SuppressWarnings({"static"}) - String menuKeyStr = + String menuKeyStr = Configuration.global().getParam("menuKey").getValueStr(); for(int i = 0; i < getMenuKeySymbolCount(); i++) if (menuSymbols[i].name.equals(menuKeyStr)) menuKeySym = menuSymbols[i].keysym; - + return menuKeySym; } diff --git a/java/com/tigervnc/vncviewer/OptionsDialog.java b/java/com/tigervnc/vncviewer/OptionsDialog.java index e78563e6..3d73d4c3 100644 --- a/java/com/tigervnc/vncviewer/OptionsDialog.java +++ b/java/com/tigervnc/vncviewer/OptionsDialog.java @@ -1,16 +1,16 @@ /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. * Copyright (C) 2011-2012 Brian P. Hinz - * + * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, @@ -53,7 +53,7 @@ class OptionsDialog extends Dialog implements JButton cfLoadButton, cfSaveAsButton, defSaveButton, defReloadButton, defClearButton; @SuppressWarnings({"rawtypes","unchecked"}) - public OptionsDialog(OptionsDialogCallback cb_) { + public OptionsDialog(OptionsDialogCallback cb_) { super(true); cb = cb_; setResizable(false); @@ -61,7 +61,7 @@ class OptionsDialog extends Dialog implements getContentPane().setLayout( new BoxLayout(getContentPane(), BoxLayout.PAGE_AXIS)); - + JTabbedPane tabPane = new JTabbedPane(); ButtonGroup encodingGroup = new ButtonGroup(); @@ -133,7 +133,7 @@ class OptionsDialog extends Dialog implements sendClipboard = new JCheckBox("Send clipboard to server"); sendClipboard.addItemListener(this); JLabel menuKeyLabel = new JLabel("Menu Key"); - String[] menuKeys = new String[MenuKey.getMenuKeySymbolCount()]; + String[] menuKeys = new String[MenuKey.getMenuKeySymbolCount()]; for (int i = 0; i < MenuKey.getMenuKeySymbolCount(); i++) menuKeys[i] = KeyEvent.getKeyText(MenuKey.getMenuKeySymbols()[i].keycode); menuKey = new JComboBox(menuKeys); @@ -156,8 +156,8 @@ class OptionsDialog extends Dialog implements acceptBell = new JCheckBox("Beep when requested by the server"); acceptBell.addItemListener(this); JLabel scalingFactorLabel = new JLabel("Scaling Factor"); - Object[] scalingFactors = { - "Auto", "Fixed Aspect Ratio", "50%", "75%", "95%", "100%", "105%", + Object[] scalingFactors = { + "Auto", "Fixed Aspect Ratio", "50%", "75%", "95%", "100%", "105%", "125%", "150%", "175%", "200%", "250%", "300%", "350%", "400%" }; scalingFactor = new JComboBox(scalingFactors); // Hack to set the left inset on editable JComboBox @@ -167,7 +167,7 @@ class OptionsDialog extends Dialog implements } else if (UIManager.getLookAndFeel().getID() == "Metal") { ComboBoxEditor sfe = scalingFactor.getEditor(); JTextField sfeTextField = (JTextField)sfe.getEditorComponent(); - sfeTextField.setBorder(new CompoundBorder(sfeTextField.getBorder(), + sfeTextField.setBorder(new CompoundBorder(sfeTextField.getBorder(), new EmptyBorder(0,2,0,0))); } scalingFactor.setEditable(true); @@ -274,7 +274,7 @@ class OptionsDialog extends Dialog implements this.getContentPane().add(buttonPane); pack(); - + } public void initDialog() { @@ -292,7 +292,7 @@ class OptionsDialog extends Dialog implements sendLocalUsername.setEnabled(secVeNCrypt.isEnabled()&& (secPlain.isSelected()||secIdent.isSelected())); } - + private void updatePreferences() { if (autoSelect.isSelected()) { UserPreferences.set("global", "AutoSelect", true); @@ -338,7 +338,7 @@ class OptionsDialog extends Dialog implements UserPreferences.set("global", "ScalingFactor", "Auto"); } else if(scaleString.equalsIgnoreCase("Fixed Aspect Ratio")) { UserPreferences.set("global", "ScalingFactor", "FixedRatio"); - } else { + } else { scaleString=scaleString.substring(0, scaleString.length()-1); UserPreferences.set("global", "ScalingFactor", scaleString); } @@ -411,7 +411,7 @@ class OptionsDialog extends Dialog implements scalingFactor.setSelectedItem("Auto"); } else if (scaleString.equalsIgnoreCase("FixedRatio")) { scalingFactor.setSelectedItem("Fixed Aspect Ratio"); - } else { + } else { scalingFactor.setSelectedItem(scaleString+"%"); } } @@ -466,7 +466,7 @@ class OptionsDialog extends Dialog implements if (group != null) group.add(c); c.addItemListener(this); - + return c; } @@ -547,7 +547,7 @@ class OptionsDialog extends Dialog implements mediumColour.setEnabled(!autoSelect.isSelected()); lowColour.setEnabled(!autoSelect.isSelected()); veryLowColour.setEnabled(!autoSelect.isSelected()); - } + } if (s instanceof JCheckBox && (JCheckBox)s == customCompressLevel) { compressLevel.setEnabled(customCompressLevel.isSelected()); } diff --git a/java/com/tigervnc/vncviewer/OptionsDialogCallback.java b/java/com/tigervnc/vncviewer/OptionsDialogCallback.java index 297daed6..efb8c069 100644 --- a/java/com/tigervnc/vncviewer/OptionsDialogCallback.java +++ b/java/com/tigervnc/vncviewer/OptionsDialogCallback.java @@ -1,15 +1,15 @@ /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. - * + * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, diff --git a/java/com/tigervnc/vncviewer/PasswdDialog.java b/java/com/tigervnc/vncviewer/PasswdDialog.java index 10281e0d..edd95540 100644 --- a/java/com/tigervnc/vncviewer/PasswdDialog.java +++ b/java/com/tigervnc/vncviewer/PasswdDialog.java @@ -1,16 +1,16 @@ /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. * Copyright (C) 2011-2012 Brian P. Hinz - * + * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, @@ -86,7 +86,7 @@ class PasswdDialog extends Dialog implements KeyListener, } } - public String getPassword() { + public String getPassword() { return new String(passwdEntry.getPassword()); } public String getPassphrase(){ return null; } @@ -103,10 +103,10 @@ class PasswdDialog extends Dialog implements KeyListener, } public boolean promptYesNo(String str){ Object[] options={ "yes", "no" }; - int foo=JOptionPane.showOptionDialog(null, + int foo=JOptionPane.showOptionDialog(null, str, - "Warning", - JOptionPane.DEFAULT_OPTION, + "Warning", + JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]); return foo==0; @@ -119,7 +119,7 @@ class PasswdDialog extends Dialog implements KeyListener, Container panel = new JPanel(); panel.setLayout(new GridBagLayout()); - GridBagConstraints gbc = + GridBagConstraints gbc = new GridBagConstraints(0,0,1,1,1,1, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, @@ -152,7 +152,7 @@ class PasswdDialog extends Dialog implements KeyListener, gbc.gridy++; } - if(JOptionPane.showConfirmDialog(null, panel, + if(JOptionPane.showConfirmDialog(null, panel, destination+": "+name, JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE) diff --git a/java/com/tigervnc/vncviewer/PlatformPixelBuffer.java b/java/com/tigervnc/vncviewer/PlatformPixelBuffer.java index b14924d1..e0e24f06 100644 --- a/java/com/tigervnc/vncviewer/PlatformPixelBuffer.java +++ b/java/com/tigervnc/vncviewer/PlatformPixelBuffer.java @@ -1,16 +1,16 @@ /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. * Copyright (C) 2011-2012 Brian P.Hinz - * + * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, diff --git a/java/com/tigervnc/vncviewer/ServerDialog.java b/java/com/tigervnc/vncviewer/ServerDialog.java index ae0793e1..7b8ee0c7 100644 --- a/java/com/tigervnc/vncviewer/ServerDialog.java +++ b/java/com/tigervnc/vncviewer/ServerDialog.java @@ -1,16 +1,16 @@ /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. * Copyright (C) 2011-2013 Brian P. Hinz - * + * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, @@ -35,7 +35,7 @@ class ServerDialog extends Dialog implements @SuppressWarnings({"unchecked","rawtypes"}) public ServerDialog(OptionsDialog options_, String defaultServerName, CConn cc_) { - + super(true); cc = cc_; setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); @@ -123,7 +123,7 @@ class ServerDialog extends Dialog implements aboutButton.addActionListener(this); okButton.addActionListener(this); cancelButton.addActionListener(this); - + pack(); } @@ -177,7 +177,7 @@ class ServerDialog extends Dialog implements UserPreferences.save("ServerDialog"); endDialog(); } - + CConn cc; @SuppressWarnings("rawtypes") JComboBox server; diff --git a/java/com/tigervnc/vncviewer/UserPreferences.java b/java/com/tigervnc/vncviewer/UserPreferences.java index 95c56fbd..544774db 100644 --- a/java/com/tigervnc/vncviewer/UserPreferences.java +++ b/java/com/tigervnc/vncviewer/UserPreferences.java @@ -1,15 +1,15 @@ /* Copyright (C) 2012 Brian P. Hinz - * + * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, diff --git a/java/com/tigervnc/vncviewer/Viewport.java b/java/com/tigervnc/vncviewer/Viewport.java index 465dee88..66ac131f 100644 --- a/java/com/tigervnc/vncviewer/Viewport.java +++ b/java/com/tigervnc/vncviewer/Viewport.java @@ -1,17 +1,17 @@ /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. * Copyright (C) 2011-2013 Brian P. Hinz * Copyright (C) 2012 D. R. Commander. All Rights Reserved. - * + * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, @@ -41,7 +41,7 @@ public class Viewport extends JFrame setFocusable(false); setFocusTraversalKeysEnabled(false); setIconImage(VncViewer.frameIcon); - UIManager.getDefaults().put("ScrollPane.ancestorInputMap", + UIManager.getDefaults().put("ScrollPane.ancestorInputMap", new UIDefaults.LazyInputMap(new Object[]{})); sp = new JScrollPane(); sp.getViewport().setBackground(Color.BLACK); @@ -93,7 +93,7 @@ public class Viewport extends JFrame } if (cc.desktop.cursor != null) { Cursor cursor = cc.desktop.cursor; - cc.setCursor(cursor.width(),cursor.height(),cursor.hotspot, + cc.setCursor(cursor.width(),cursor.height(),cursor.hotspot, cursor.data, cursor.mask); } } diff --git a/java/com/tigervnc/vncviewer/VncViewer.java b/java/com/tigervnc/vncviewer/VncViewer.java index 90abea0b..c783bef4 100644 --- a/java/com/tigervnc/vncviewer/VncViewer.java +++ b/java/com/tigervnc/vncviewer/VncViewer.java @@ -2,17 +2,17 @@ * Copyright 2011 Pierre Ossman <ossman@cendio.se> for Cendio AB * Copyright (C) 2011 D. R. Commander. All Rights Reserved. * Copyright (C) 2011-2013 Brian P. Hinz - * + * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, @@ -55,18 +55,18 @@ public class VncViewer extends java.applet.Applet implements Runnable "Built on %s at %s%n"+ "Copyright (C) 1999-2012 TigerVNC Team and many others (see README.txt)%n"+ "See http://www.tigervnc.org for information on TigerVNC."); - + public static String version = null; public static String build = null; public static String buildDate = null; public static String buildTime = null; - static ImageIcon frameIconSrc = + static ImageIcon frameIconSrc = new ImageIcon(VncViewer.class.getResource("tigervnc.ico")); public static final Image frameIcon = frameIconSrc.getImage(); - public static final ImageIcon logoIcon = + public static final ImageIcon logoIcon = new ImageIcon(VncViewer.class.getResource("tigervnc.png")); public static final Image logoImage = logoIcon.getImage(); - public static final InputStream timestamp = + public static final InputStream timestamp = VncViewer.class.getResourceAsStream("timestamp"); public static void setLookAndFeel() { @@ -107,7 +107,7 @@ public class VncViewer extends java.applet.Applet implements Runnable FontUIResource r = new FontUIResource(name, style, size); UIManager.put("TitledBorder.font", r); } - } catch (java.lang.Exception e) { + } catch (java.lang.Exception e) { vlog.info(e.toString()); } } @@ -118,7 +118,7 @@ public class VncViewer extends java.applet.Applet implements Runnable viewer.start(); } - + public VncViewer(String[] argv) { applet = false; @@ -126,11 +126,11 @@ public class VncViewer extends java.applet.Applet implements Runnable UserPreferences.load("global"); SecurityClient.setDefaults(); - + // Write about text to console, still using normal locale codeset getTimestamp(); System.err.format("%n"); - System.err.format(aboutText, version, build, buildDate, buildTime); + System.err.format(aboutText, version, build, buildDate, buildTime); System.err.format("%n"); Configuration.enableViewerParams(); @@ -338,7 +338,7 @@ public class VncViewer extends java.applet.Applet implements Runnable public void paint(Graphics g) { g.drawImage(logoImage, 0, 0, this); int h = logoImage.getHeight(this)+20; - g.drawString(String.format(aboutText, version, build, + g.drawString(String.format(aboutText, version, build, buildDate, buildTime), 0, h); } @@ -348,7 +348,7 @@ public class VncViewer extends java.applet.Applet implements Runnable if (listenMode.getValue()) { int port = 5500; - if (vncServerName.getValue() != null && + if (vncServerName.getValue() != null && Character.isDigit(vncServerName.getValue().charAt(0))) port = Integer.parseInt(vncServerName.getValue()); @@ -378,7 +378,7 @@ public class VncViewer extends java.applet.Applet implements Runnable vlog.info(e.getMessage()); } else if (cc == null || !cc.shuttingDown) { e.printStackTrace(); - JOptionPane op = + JOptionPane op = new JOptionPane(e.getMessage(), JOptionPane.WARNING_MESSAGE); JDialog dlg = op.createDialog("TigerVNC Viewer"); dlg.setIconImage(frameIcon); @@ -427,7 +427,7 @@ public class VncViewer extends java.applet.Applet implements Runnable = new IntParameter("LowColorLevel", "Color level to use on slow connections. "+ "0 = Very Low (8 colors), 1 = Low (64 colors), "+ - "2 = Medium (256 colors)", + "2 = Medium (256 colors)", 2); AliasParameter lowColourLevelAlias = new AliasParameter("LowColourLevel", @@ -470,7 +470,7 @@ public class VncViewer extends java.applet.Applet implements Runnable "connect (if possible)", ""); BoolParameter listenMode = new BoolParameter("listen", - "Listen for connections from VNC servers", + "Listen for connections from VNC servers", false); StringParameter scalingFactor = new StringParameter("ScalingFactor", @@ -503,7 +503,7 @@ public class VncViewer extends java.applet.Applet implements Runnable 0); BoolParameter acceptBell = new BoolParameter("AcceptBell", - "Produce a system beep when requested to by the server.", + "Produce a system beep when requested to by the server.", true); StringParameter via = new StringParameter("via", diff --git a/java/com/tigervnc/vncviewer/tunnel.java b/java/com/tigervnc/vncviewer/tunnel.java index a66d83ae..6d55fece 100644 --- a/java/com/tigervnc/vncviewer/tunnel.java +++ b/java/com/tigervnc/vncviewer/tunnel.java @@ -37,32 +37,32 @@ import com.tigervnc.network.*; import com.jcraft.jsch.JSch; import com.jcraft.jsch.Session; -public class tunnel +public class tunnel { private final static Integer SERVER_PORT_OFFSET = 5900;; private final static String DEFAULT_SSH_CMD = "/usr/bin/ssh"; - private final static String DEFAULT_TUNNEL_CMD + private final static String DEFAULT_TUNNEL_CMD = DEFAULT_SSH_CMD+" -f -L %L:localhost:%R %H sleep 20"; - private final static String DEFAULT_VIA_CMD + private final static String DEFAULT_VIA_CMD = DEFAULT_SSH_CMD+" -f -L %L:%H:%R %G sleep 20"; private final static int H = 17; private final static int G = 16; private final static int R = 27; private final static int L = 21; - + /* True if there was -tunnel or -via option in the command line. */ private static boolean tunnelSpecified = false; - + /* True if it was -tunnel, not -via option. */ private static boolean tunnelOption = false; - + /* "Hostname:display" pair in the command line will be substituted by this fake argument when tunneling is used. */ private static String lastArgv; private static String tunnelEndpoint; - + public static Boolean createTunnel(int pargc, String[] argv, int tunnelArgIndex) { @@ -74,19 +74,19 @@ public class tunnel char[] remotePortStr = new char[8]; StringBuilder gatewayHost = new StringBuilder(""); StringBuilder remoteHost = new StringBuilder("localhost"); - + tunnelSpecified = true; if (argv[tunnelArgIndex].equalsIgnoreCase("-tunnel")) tunnelOption = true; - + pattern = getCmdPattern(); if (pattern == null) return false; - + localPort[0] = TcpSocket.findFreeTcpPort(); if (localPort[0] == 0) return false; - + if (tunnelOption) { processTunnelArgs(remoteHost, remotePort, localPort, pargc, argv, tunnelArgIndex); @@ -94,50 +94,50 @@ public class tunnel processViaArgs(gatewayHost, remoteHost, remotePort, localPort, pargc, argv, tunnelArgIndex); } - + localPortStr = Integer.toString(localPort[0]).toCharArray(); remotePortStr = Integer.toString(remotePort[0]).toCharArray(); - - if (!fillCmdPattern(cmd, pattern, gatewayHost.toString().toCharArray(), + + if (!fillCmdPattern(cmd, pattern, gatewayHost.toString().toCharArray(), remoteHost.toString().toCharArray(), remotePortStr, localPortStr)) return false; - + if (!runCommand(new String(cmd))) return false; - + return true; } - + private static void - processTunnelArgs(StringBuilder remoteHost, int[] remotePort, - int[] localPort, int pargc, String[] argv, + processTunnelArgs(StringBuilder remoteHost, int[] remotePort, + int[] localPort, int pargc, String[] argv, int tunnelArgIndex) { String pdisplay; - + if (tunnelArgIndex >= pargc - 1) VncViewer.usage(); - + pdisplay = argv[pargc - 1].split(":")[1]; if (pdisplay == null || pdisplay == argv[pargc - 1]) VncViewer.usage(); - + if (pdisplay.matches("/[^0-9]/")) VncViewer.usage(); - + remotePort[0] = Integer.parseInt(pdisplay); if (remotePort[0] < 100) remotePort[0] = remotePort[0] + SERVER_PORT_OFFSET; - + lastArgv = new String("localhost::"+localPort[0]); - + remoteHost.setLength(0); remoteHost.insert(0, argv[pargc - 1].split(":")[0]); argv[pargc - 1] = lastArgv; - + //removeArgs(pargc, argv, tunnelArgIndex, 1); } - + private static void processViaArgs(StringBuilder gatewayHost, StringBuilder remoteHost, int[] remotePort, int[] localPort, @@ -146,10 +146,10 @@ public class tunnel String colonPos; int len, portOffset; int disp; - + if (tunnelArgIndex >= pargc - 2) VncViewer.usage(); - + colonPos = argv[pargc - 1].split(":", 2)[1]; if (colonPos == null) { /* No colon -- use default port number */ @@ -171,44 +171,44 @@ public class tunnel portOffset = 0; remotePort[0] = disp + portOffset; } - + lastArgv = "localhost::"+localPort[0]; - + gatewayHost.setLength(0); gatewayHost.insert(0, argv[tunnelArgIndex + 1]); - + if (!argv[pargc - 1].split(":", 2)[0].equals("")) { remoteHost.setLength(0); remoteHost.insert(0, argv[pargc - 1].split(":", 2)[0]); } - + argv[pargc - 1] = lastArgv; - + //removeArgs(pargc, argv, tunnelArgIndex, 2); } - + private static char[] getCmdPattern() { String pattern = ""; - + try { if (tunnelOption) { pattern = System.getProperty("VNC_TUNNEL_CMD"); } else { pattern = System.getProperty("VNC_VIA_CMD"); } - } catch (java.lang.Exception e) { + } catch (java.lang.Exception e) { vlog.info(e.toString()); } if (pattern == null || pattern.equals("")) pattern = (tunnelOption) ? DEFAULT_TUNNEL_CMD : DEFAULT_VIA_CMD; - + return pattern.toCharArray(); } - + /* Note: in fillCmdPattern() result points to a 1024-byte buffer */ - + private static boolean fillCmdPattern(char[] result, char[] pattern, char[] gatewayHost, char[] remoteHost, @@ -249,12 +249,12 @@ public class tunnel } result[j] = pattern[i]; } - + if (pattern.length > 1024) { vlog.error("Tunneling command is too long."); return false; } - + if (!H_found || !R_found || !L_found) { vlog.error("%H, %R or %L absent in tunneling command."); return false; @@ -263,10 +263,10 @@ public class tunnel vlog.error("%G pattern absent in tunneling command."); return false; } - + return true; } - + private static Boolean runCommand(String cmd) { @@ -322,6 +322,6 @@ public class tunnel } return true; } - + static LogWriter vlog = new LogWriter("tunnel"); } |