fixed exception logging
This commit is contained in:
@@ -7,16 +7,13 @@ package com.threerings.getdown.tools;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import java.security.GeneralSecurityException;
|
import java.security.GeneralSecurityException;
|
||||||
|
|
||||||
import org.apache.tools.ant.BuildException;
|
import org.apache.tools.ant.BuildException;
|
||||||
import org.apache.tools.ant.Task;
|
import org.apache.tools.ant.Task;
|
||||||
|
|
||||||
import com.threerings.getdown.data.Digest;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An ant task used to create a <code>digest.txt</code> for a Getdown
|
* An ant task used to create a {@code digest.txt} for a Getdown
|
||||||
* application deployment.
|
* application deployment.
|
||||||
*/
|
*/
|
||||||
public class DigesterTask extends Task
|
public class DigesterTask extends Task
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import java.util.logging.*;
|
|||||||
/**
|
/**
|
||||||
* A placeholder class that contains a reference to the log object used by the Getdown code.
|
* A placeholder class that contains a reference to the log object used by the Getdown code.
|
||||||
*/
|
*/
|
||||||
public class Log
|
public final class Log
|
||||||
{
|
{
|
||||||
public static class Shim {
|
public static class Shim {
|
||||||
/**
|
/**
|
||||||
@@ -143,6 +143,5 @@ public class Log
|
|||||||
protected FieldPosition _fpos = new FieldPosition(SimpleDateFormat.DATE_FIELD);
|
protected FieldPosition _fpos = new FieldPosition(SimpleDateFormat.DATE_FIELD);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static final String DATE_FORMAT = "{0,date} {0,time}";
|
|
||||||
protected static final Level[] LEVELS = {Level.FINE, Level.INFO, Level.WARNING, Level.SEVERE};
|
protected static final Level[] LEVELS = {Level.FINE, Level.INFO, Level.WARNING, Level.SEVERE};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,6 +96,6 @@ public class GarbageCollector
|
|||||||
private static File getCachedFile (File file)
|
private static File getCachedFile (File file)
|
||||||
{
|
{
|
||||||
return !isLastAccessedFile(file) ? file : new File(
|
return !isLastAccessedFile(file) ? file : new File(
|
||||||
file.getParentFile(), file.getName().substring(0, file.getName().lastIndexOf(".")));
|
file.getParentFile(), file.getName().substring(0, file.getName().lastIndexOf('.')));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ public class ResourceCache
|
|||||||
|
|
||||||
private String getFileSuffix (File fileToCache) {
|
private String getFileSuffix (File fileToCache) {
|
||||||
String fileName = fileToCache.getName();
|
String fileName = fileToCache.getName();
|
||||||
int index = fileName.lastIndexOf(".");
|
int index = fileName.lastIndexOf('.');
|
||||||
|
|
||||||
return index > -1 ? fileName.substring(index) : "";
|
return index > -1 ? fileName.substring(index) : "";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ import static com.threerings.getdown.Log.log;
|
|||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses and provide access to the information contained in the <code>getdown.txt</code>
|
* Parses and provide access to the information contained in the {@code getdown.txt}
|
||||||
* configuration file.
|
* configuration file.
|
||||||
*/
|
*/
|
||||||
public class Application
|
public class Application
|
||||||
@@ -212,10 +212,10 @@ public class Application
|
|||||||
* Used by {@link #verifyMetadata} to communicate status in circumstances where it needs to
|
* Used by {@link #verifyMetadata} to communicate status in circumstances where it needs to
|
||||||
* take network actions.
|
* take network actions.
|
||||||
*/
|
*/
|
||||||
public static interface StatusDisplay
|
public interface StatusDisplay
|
||||||
{
|
{
|
||||||
/** Requests that the specified status message be displayed. */
|
/** Requests that the specified status message be displayed. */
|
||||||
public void updateStatus (String message);
|
void updateStatus (String message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -277,7 +277,7 @@ public class Application
|
|||||||
public Proxy proxy = Proxy.NO_PROXY;
|
public Proxy proxy = Proxy.NO_PROXY;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an application instance which records the location of the <code>getdown.txt</code>
|
* Creates an application instance which records the location of the {@code getdown.txt}
|
||||||
* configuration file from the supplied application directory.
|
* configuration file from the supplied application directory.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -406,8 +406,7 @@ public class Application
|
|||||||
*/
|
*/
|
||||||
public List<Resource> getActiveCodeResources ()
|
public List<Resource> getActiveCodeResources ()
|
||||||
{
|
{
|
||||||
ArrayList<Resource> codes = new ArrayList<>();
|
List<Resource> codes = new ArrayList<>(getCodeResources());
|
||||||
codes.addAll(getCodeResources());
|
|
||||||
for (AuxGroup aux : getAuxGroups()) {
|
for (AuxGroup aux : getAuxGroups()) {
|
||||||
if (isAuxGroupActive(aux.name)) {
|
if (isAuxGroupActive(aux.name)) {
|
||||||
codes.addAll(aux.codes);
|
codes.addAll(aux.codes);
|
||||||
@@ -435,8 +434,7 @@ public class Application
|
|||||||
*/
|
*/
|
||||||
public List<Resource> getActiveResources ()
|
public List<Resource> getActiveResources ()
|
||||||
{
|
{
|
||||||
ArrayList<Resource> rsrcs = new ArrayList<>();
|
List<Resource> rsrcs = new ArrayList<>(getResources());
|
||||||
rsrcs.addAll(getResources());
|
|
||||||
for (AuxGroup aux : getAuxGroups()) {
|
for (AuxGroup aux : getAuxGroups()) {
|
||||||
if (isAuxGroupActive(aux.name)) {
|
if (isAuxGroupActive(aux.name)) {
|
||||||
rsrcs.addAll(aux.rsrcs);
|
rsrcs.addAll(aux.rsrcs);
|
||||||
@@ -609,7 +607,7 @@ public class Application
|
|||||||
|
|
||||||
// make sure there's a trailing slash
|
// make sure there's a trailing slash
|
||||||
if (!_appbase.endsWith("/")) {
|
if (!_appbase.endsWith("/")) {
|
||||||
_appbase = _appbase + "/";
|
_appbase += "/";
|
||||||
}
|
}
|
||||||
|
|
||||||
// extract our version information
|
// extract our version information
|
||||||
@@ -913,7 +911,7 @@ public class Application
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to redownload the <code>getdown.txt</code> file based on information parsed from a
|
* Attempts to redownload the {@code getdown.txt} file based on information parsed from a
|
||||||
* previous call to {@link #init}.
|
* previous call to {@link #init}.
|
||||||
*/
|
*/
|
||||||
public void attemptRecovery (StatusDisplay status)
|
public void attemptRecovery (StatusDisplay status)
|
||||||
@@ -924,7 +922,7 @@ public class Application
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Downloads and replaces the <code>getdown.txt</code> and <code>digest.txt</code> files with
|
* Downloads and replaces the {@code getdown.txt} and {@code digest.txt} files with
|
||||||
* those for the target version of our application.
|
* those for the target version of our application.
|
||||||
*/
|
*/
|
||||||
public void updateMetadata ()
|
public void updateMetadata ()
|
||||||
@@ -935,7 +933,7 @@ public class Application
|
|||||||
_vappbase = createVAppBase(_targetVersion);
|
_vappbase = createVAppBase(_targetVersion);
|
||||||
} catch (MalformedURLException mue) {
|
} catch (MalformedURLException mue) {
|
||||||
String err = MessageUtil.tcompose("m.invalid_appbase", _appbase);
|
String err = MessageUtil.tcompose("m.invalid_appbase", _appbase);
|
||||||
throw (IOException) new IOException(err).initCause(mue);
|
throw new IOException(err, mue);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -1111,7 +1109,7 @@ public class Application
|
|||||||
for (String jvmarg : _jvmargs) {
|
for (String jvmarg : _jvmargs) {
|
||||||
if (jvmarg.startsWith("-D")) {
|
if (jvmarg.startsWith("-D")) {
|
||||||
jvmarg = processArg(jvmarg.substring(2));
|
jvmarg = processArg(jvmarg.substring(2));
|
||||||
int eqidx = jvmarg.indexOf("=");
|
int eqidx = jvmarg.indexOf('=');
|
||||||
if (eqidx == -1) {
|
if (eqidx == -1) {
|
||||||
log.warning("Bogus system property: '" + jvmarg + "'?");
|
log.warning("Bogus system property: '" + jvmarg + "'?");
|
||||||
} else {
|
} else {
|
||||||
@@ -1173,8 +1171,8 @@ public class Application
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the <code>digest.txt</code> file and verifies the contents of both that file and the
|
* Loads the {@code digest.txt} file and verifies the contents of both that file and the
|
||||||
* <code>getdown.text</code> file. Then it loads the <code>version.txt</code> and decides
|
* {@code getdown.text} file. Then it loads the {@code version.txt} and decides
|
||||||
* whether or not the application needs to be updated or whether we can proceed to verification
|
* whether or not the application needs to be updated or whether we can proceed to verification
|
||||||
* and execution.
|
* and execution.
|
||||||
*
|
*
|
||||||
@@ -1265,7 +1263,7 @@ public class Application
|
|||||||
InputStreamReader reader = new InputStreamReader(in, UTF_8);
|
InputStreamReader reader = new InputStreamReader(in, UTF_8);
|
||||||
BufferedReader bin = new BufferedReader(reader)) {
|
BufferedReader bin = new BufferedReader(reader)) {
|
||||||
for (String[] pair : Config.parsePairs(bin, Config.createOpts(false))) {
|
for (String[] pair : Config.parsePairs(bin, Config.createOpts(false))) {
|
||||||
if (pair[0].equals("version")) {
|
if ("version".equals(pair[0])) {
|
||||||
_targetVersion = Math.max(Long.parseLong(pair[1]), _targetVersion);
|
_targetVersion = Math.max(Long.parseLong(pair[1]), _targetVersion);
|
||||||
if (fileVersion != -1 && _targetVersion > fileVersion) {
|
if (fileVersion != -1 && _targetVersion > fileVersion) {
|
||||||
// replace the file with the newest version
|
// replace the file with the newest version
|
||||||
@@ -1471,7 +1469,7 @@ public class Application
|
|||||||
protected URL createVAppBase (long version)
|
protected URL createVAppBase (long version)
|
||||||
throws MalformedURLException
|
throws MalformedURLException
|
||||||
{
|
{
|
||||||
String url = version < 0 ? _appbase : _appbase.replace("%VERSION%", "" + version);
|
String url = version < 0 ? _appbase : _appbase.replace("%VERSION%", String.valueOf(version));
|
||||||
return HostWhitelist.verify(new URL(url));
|
return HostWhitelist.verify(new URL(url));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1642,7 +1640,7 @@ public class Application
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warning("Requested to download invalid control file",
|
log.warning("Requested to download invalid control file",
|
||||||
"appbase", _vappbase, "path", path, "error", e);
|
"appbase", _vappbase, "path", path, "error", e);
|
||||||
throw (IOException) new IOException("Invalid path '" + path + "'.").initCause(e);
|
throw new IOException("Invalid path '" + path + "'.", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("Attempting to refetch '" + path + "' from '" + targetURL + "'.");
|
log.info("Attempting to refetch '" + path + "' from '" + targetURL + "'.");
|
||||||
@@ -1679,9 +1677,7 @@ public class Application
|
|||||||
/** Helper function to add all values in {@code values} (if non-null) to {@code target}. */
|
/** Helper function to add all values in {@code values} (if non-null) to {@code target}. */
|
||||||
protected static void addAll (String[] values, List<String> target) {
|
protected static void addAll (String[] values, List<String> target) {
|
||||||
if (values != null) {
|
if (values != null) {
|
||||||
for (String value : values) {
|
Collections.addAll(target, values);
|
||||||
target.add(value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import static com.threerings.getdown.Log.log;
|
|||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages the <code>digest.txt</code> file and the computing and processing of digests for an
|
* Manages the {@code digest.txt} file and the computing and processing of digests for an
|
||||||
* application.
|
* application.
|
||||||
*/
|
*/
|
||||||
public class Digest
|
public class Digest
|
||||||
@@ -72,8 +72,7 @@ public class Digest
|
|||||||
digests.put(rsrc, rsrc.computeDigest(fversion, md, null));
|
digests.put(rsrc, rsrc.computeDigest(fversion, md, null));
|
||||||
completed.add(rsrc);
|
completed.add(rsrc);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
completed.add(new IOException("Error computing digest for: " + rsrc).
|
completed.add(new IOException("Error computing digest for: " + rsrc, t));
|
||||||
initCause(t));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -88,7 +87,7 @@ public class Digest
|
|||||||
if (done instanceof IOException) {
|
if (done instanceof IOException) {
|
||||||
throw (IOException)done;
|
throw (IOException)done;
|
||||||
} else if (done instanceof Resource) {
|
} else if (done instanceof Resource) {
|
||||||
pending.remove((Resource)done);
|
pending.remove(done);
|
||||||
} else {
|
} else {
|
||||||
throw new AssertionError("What is this? " + done);
|
throw new AssertionError("What is this? " + done);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public final class EnvConfig {
|
|||||||
|
|
||||||
/** Used to report problems or feedback by {@link #create}. */
|
/** Used to report problems or feedback by {@link #create}. */
|
||||||
public static final class Note {
|
public static final class Note {
|
||||||
public static enum Level { INFO, WARN, ERROR };
|
public enum Level { INFO, WARN, ERROR }
|
||||||
public static Note info (String msg) { return new Note(Level.INFO, msg); }
|
public static Note info (String msg) { return new Note(Level.INFO, msg); }
|
||||||
public static Note warn (String msg) { return new Note(Level.WARN, msg); }
|
public static Note warn (String msg) { return new Note(Level.WARN, msg); }
|
||||||
public static Note error (String msg) { return new Note(Level.ERROR, msg); }
|
public static Note error (String msg) { return new Note(Level.ERROR, msg); }
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import static com.threerings.getdown.Log.log;
|
|||||||
public class Resource implements Comparable<Resource>
|
public class Resource implements Comparable<Resource>
|
||||||
{
|
{
|
||||||
/** Defines special attributes for resources. */
|
/** Defines special attributes for resources. */
|
||||||
public static enum Attr {
|
public enum Attr {
|
||||||
/** Indicates that the resource should be unpacked. */
|
/** Indicates that the resource should be unpacked. */
|
||||||
UNPACK,
|
UNPACK,
|
||||||
/** If present, when unpacking a resource, any directories created by the newly
|
/** If present, when unpacking a resource, any directories created by the newly
|
||||||
@@ -35,7 +35,7 @@ public class Resource implements Comparable<Resource>
|
|||||||
PRELOAD,
|
PRELOAD,
|
||||||
/** Indicates that the resource is a jar containing native libs. */
|
/** Indicates that the resource is a jar containing native libs. */
|
||||||
NATIVE
|
NATIVE
|
||||||
};
|
}
|
||||||
|
|
||||||
public static final EnumSet<Attr> NORMAL = EnumSet.noneOf(Attr.class);
|
public static final EnumSet<Attr> NORMAL = EnumSet.noneOf(Attr.class);
|
||||||
public static final EnumSet<Attr> UNPACK = EnumSet.of(Attr.UNPACK);
|
public static final EnumSet<Attr> UNPACK = EnumSet.of(Attr.UNPACK);
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import com.threerings.getdown.util.VersionUtil;
|
|||||||
* accessor so that it's easy to see all of the secret system property arguments that Getdown makes
|
* accessor so that it's easy to see all of the secret system property arguments that Getdown makes
|
||||||
* use of.
|
* use of.
|
||||||
*/
|
*/
|
||||||
public class SysProps
|
public final class SysProps
|
||||||
{
|
{
|
||||||
/** Configures the appdir (in lieu of passing it in argv). Usage: {@code -Dappdir=foo}. */
|
/** Configures the appdir (in lieu of passing it in argv). Usage: {@code -Dappdir=foo}. */
|
||||||
public static String appDir () {
|
public static String appDir () {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ package com.threerings.getdown.spi;
|
|||||||
public interface ProxyAuth
|
public interface ProxyAuth
|
||||||
{
|
{
|
||||||
/** Credentials for a proxy server. */
|
/** Credentials for a proxy server. */
|
||||||
public static class Credentials {
|
class Credentials {
|
||||||
public final String username;
|
public final String username;
|
||||||
public final String password;
|
public final String password;
|
||||||
public Credentials (String username, String password) {
|
public Credentials (String username, String password) {
|
||||||
@@ -23,10 +23,10 @@ public interface ProxyAuth
|
|||||||
/**
|
/**
|
||||||
* Loads the credentials for the app installed in {@code appDir}.
|
* Loads the credentials for the app installed in {@code appDir}.
|
||||||
*/
|
*/
|
||||||
public Credentials loadCredentials (String appDir);
|
Credentials loadCredentials (String appDir);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encrypts and saves the credentials for the app installed in {@code appDir}.
|
* Encrypts and saves the credentials for the app installed in {@code appDir}.
|
||||||
*/
|
*/
|
||||||
public void saveCredentials (String appDir, String username, String password);
|
void saveCredentials (String appDir, String username, String password);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,10 +5,17 @@
|
|||||||
|
|
||||||
package com.threerings.getdown.tools;
|
package com.threerings.getdown.tools;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.BufferedOutputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
|
import java.util.List;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipFile;
|
import java.util.zip.ZipFile;
|
||||||
import java.util.zip.ZipOutputStream;
|
import java.util.zip.ZipOutputStream;
|
||||||
@@ -31,8 +38,8 @@ public class Differ
|
|||||||
/**
|
/**
|
||||||
* Creates a single patch file that contains the differences between
|
* Creates a single patch file that contains the differences between
|
||||||
* the two specified application directories. The patch file will be
|
* the two specified application directories. The patch file will be
|
||||||
* created in the <code>nvdir</code> directory with name
|
* created in the {@code nvdir} directory with name
|
||||||
* <code>patchV.dat</code> where V is the old application version.
|
* {@code patchV.dat} where V is the old application version.
|
||||||
*/
|
*/
|
||||||
public void createDiff (File nvdir, File ovdir, boolean verbose)
|
public void createDiff (File nvdir, File ovdir, boolean verbose)
|
||||||
throws IOException
|
throws IOException
|
||||||
@@ -53,13 +60,13 @@ public class Differ
|
|||||||
|
|
||||||
Application oapp = new Application(new EnvConfig(ovdir));
|
Application oapp = new Application(new EnvConfig(ovdir));
|
||||||
oapp.init(false);
|
oapp.init(false);
|
||||||
ArrayList<Resource> orsrcs = new ArrayList<>();
|
List<Resource> orsrcs = new ArrayList<>();
|
||||||
orsrcs.addAll(oapp.getCodeResources());
|
orsrcs.addAll(oapp.getCodeResources());
|
||||||
orsrcs.addAll(oapp.getResources());
|
orsrcs.addAll(oapp.getResources());
|
||||||
|
|
||||||
Application napp = new Application(new EnvConfig(nvdir));
|
Application napp = new Application(new EnvConfig(nvdir));
|
||||||
napp.init(false);
|
napp.init(false);
|
||||||
ArrayList<Resource> nrsrcs = new ArrayList<>();
|
List<Resource> nrsrcs = new ArrayList<>();
|
||||||
nrsrcs.addAll(napp.getCodeResources());
|
nrsrcs.addAll(napp.getCodeResources());
|
||||||
nrsrcs.addAll(napp.getResources());
|
nrsrcs.addAll(napp.getResources());
|
||||||
|
|
||||||
@@ -83,8 +90,8 @@ public class Differ
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void createPatch (File patch, ArrayList<Resource> orsrcs,
|
protected void createPatch (File patch, List<Resource> orsrcs,
|
||||||
ArrayList<Resource> nrsrcs, boolean verbose)
|
List<Resource> nrsrcs, boolean verbose)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
int version = Digest.VERSION;
|
int version = Digest.VERSION;
|
||||||
@@ -200,7 +207,7 @@ public class Differ
|
|||||||
Differ differ = new Differ();
|
Differ differ = new Differ();
|
||||||
boolean verbose = false;
|
boolean verbose = false;
|
||||||
int aidx = 0;
|
int aidx = 0;
|
||||||
if (args[0].equals("-verbose")) {
|
if ("-verbose".equals(args[0])) {
|
||||||
verbose = true;
|
verbose = true;
|
||||||
aidx++;
|
aidx++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,15 +67,15 @@ import static java.nio.charset.StandardCharsets.UTF_8;
|
|||||||
public class JarDiff implements JarDiffCodes
|
public class JarDiff implements JarDiffCodes
|
||||||
{
|
{
|
||||||
private static final int DEFAULT_READ_SIZE = 2048;
|
private static final int DEFAULT_READ_SIZE = 2048;
|
||||||
private static byte[] newBytes = new byte[DEFAULT_READ_SIZE];
|
private static final byte[] newBytes = new byte[DEFAULT_READ_SIZE];
|
||||||
private static byte[] oldBytes = new byte[DEFAULT_READ_SIZE];
|
private static final byte[] oldBytes = new byte[DEFAULT_READ_SIZE];
|
||||||
|
|
||||||
// The JARDiff.java is the stand-alone jardiff.jar tool. Thus, we do not depend on Globals.java
|
// The JARDiff.java is the stand-alone jardiff.jar tool. Thus, we do not depend on Globals.java
|
||||||
// and other stuff here. Instead, we use an explicit _debug flag.
|
// and other stuff here. Instead, we use an explicit _debug flag.
|
||||||
private static boolean _debug;
|
private static boolean _debug;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a patch from the two passed in files, writing the result to <code>os</code>.
|
* Creates a patch from the two passed in files, writing the result to {@code os}.
|
||||||
*/
|
*/
|
||||||
public static void createPatch (String oldPath, String newPath,
|
public static void createPatch (String oldPath, String newPath,
|
||||||
OutputStream os, boolean minimal) throws IOException
|
OutputStream os, boolean minimal) throws IOException
|
||||||
@@ -83,10 +83,10 @@ public class JarDiff implements JarDiffCodes
|
|||||||
try (ZipFile2 oldArchive = new ZipFile2(oldPath);
|
try (ZipFile2 oldArchive = new ZipFile2(oldPath);
|
||||||
ZipFile2 newArchive = new ZipFile2(newPath)) {
|
ZipFile2 newArchive = new ZipFile2(newPath)) {
|
||||||
|
|
||||||
HashMap<String,String> moved = new HashMap<>();
|
Map<String,String> moved = new HashMap<>();
|
||||||
HashSet<String> implicit = new HashSet<>();
|
Set<String> implicit = new HashSet<>();
|
||||||
HashSet<String> moveSrc = new HashSet<>();
|
Set<String> moveSrc = new HashSet<>();
|
||||||
HashSet<String> newEntries = new HashSet<>();
|
Set<String> newEntries = new HashSet<>();
|
||||||
|
|
||||||
// FIRST PASS
|
// FIRST PASS
|
||||||
// Go through the entries in new archive and determine which files are candidates for
|
// Go through the entries in new archive and determine which files are candidates for
|
||||||
@@ -157,7 +157,7 @@ public class JarDiff implements JarDiffCodes
|
|||||||
|
|
||||||
// SECOND PASS: <deleted files> = <oldjarnames> - <implicitmoves> -
|
// SECOND PASS: <deleted files> = <oldjarnames> - <implicitmoves> -
|
||||||
// <source of move commands> - <new or modified entries>
|
// <source of move commands> - <new or modified entries>
|
||||||
ArrayList<String> deleted = new ArrayList<>();
|
List<String> deleted = new ArrayList<>();
|
||||||
for (ZipEntry oldEntry : oldArchive) {
|
for (ZipEntry oldEntry : oldArchive) {
|
||||||
String oldName = oldEntry.getName();
|
String oldName = oldEntry.getName();
|
||||||
if (!implicit.contains(oldName) && !moveSrc.contains(oldName)
|
if (!implicit.contains(oldName) && !moveSrc.contains(oldName)
|
||||||
@@ -203,9 +203,9 @@ public class JarDiff implements JarDiffCodes
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes the index file out to <code>jos</code>.
|
* Writes the index file out to {@code jos}.
|
||||||
* <code>oldEntries</code> gives the names of the files that were removed,
|
* {@code oldEntries} gives the names of the files that were removed,
|
||||||
* <code>movedMap</code> maps from the new name to the old name.
|
* {@code movedMap} maps from the new name to the old name.
|
||||||
*/
|
*/
|
||||||
private static void createIndex (ZipOutputStream jos, List<String> oldEntries,
|
private static void createIndex (ZipOutputStream jos, List<String> oldEntries,
|
||||||
Map<String,String> movedMap)
|
Map<String,String> movedMap)
|
||||||
@@ -286,7 +286,7 @@ public class JarDiff implements JarDiffCodes
|
|||||||
*/
|
*/
|
||||||
private static class ZipFile2 implements Iterable<ZipEntry>, Closeable
|
private static class ZipFile2 implements Iterable<ZipEntry>, Closeable
|
||||||
{
|
{
|
||||||
private ZipFile _archive;
|
private final ZipFile _archive;
|
||||||
private List<ZipEntry> _entries;
|
private List<ZipEntry> _entries;
|
||||||
private HashMap<String,ZipEntry> _nameToEntryMap;
|
private HashMap<String,ZipEntry> _nameToEntryMap;
|
||||||
private HashMap<Long,LinkedList<ZipEntry>> _crcToEntryMap;
|
private HashMap<Long,LinkedList<ZipEntry>> _crcToEntryMap;
|
||||||
@@ -384,7 +384,7 @@ public class JarDiff implements JarDiffCodes
|
|||||||
|
|
||||||
public String hasSameContent (ZipFile2 file, ZipEntry entry) throws IOException {
|
public String hasSameContent (ZipFile2 file, ZipEntry entry) throws IOException {
|
||||||
String thisName = null;
|
String thisName = null;
|
||||||
Long crcL = Long.valueOf(entry.getCrc());
|
Long crcL = entry.getCrc();
|
||||||
// check if this archive contains files with the passed in entry's crc
|
// check if this archive contains files with the passed in entry's crc
|
||||||
if (_crcToEntryMap.containsKey(crcL)) {
|
if (_crcToEntryMap.containsKey(crcL)) {
|
||||||
// get the Linked List with files with the crc
|
// get the Linked List with files with the crc
|
||||||
@@ -419,7 +419,7 @@ public class JarDiff implements JarDiffCodes
|
|||||||
while (entries.hasMoreElements()) {
|
while (entries.hasMoreElements()) {
|
||||||
ZipEntry entry = entries.nextElement();
|
ZipEntry entry = entries.nextElement();
|
||||||
long crc = entry.getCrc();
|
long crc = entry.getCrc();
|
||||||
Long crcL = Long.valueOf(crc);
|
Long crcL = crc;
|
||||||
if (_debug) {
|
if (_debug) {
|
||||||
System.out.println("\t" + entry.getName() + " CRC " + crc);
|
System.out.println("\t" + entry.getName() + " CRC " + crc);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -215,7 +215,7 @@ public class JarDiffPatcher implements JarDiffCodes
|
|||||||
{
|
{
|
||||||
int index = 0;
|
int index = 0;
|
||||||
int length = path.length();
|
int length = path.length();
|
||||||
ArrayList<String> sub = new ArrayList<>();
|
List<String> sub = new ArrayList<>();
|
||||||
|
|
||||||
while (index < length) {
|
while (index < length) {
|
||||||
while (index < length && Character.isWhitespace
|
while (index < length && Character.isWhitespace
|
||||||
@@ -223,9 +223,8 @@ public class JarDiffPatcher implements JarDiffCodes
|
|||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
if (index < length) {
|
if (index < length) {
|
||||||
int start = index;
|
int last = index;
|
||||||
int last = start;
|
StringBuilder subString = null;
|
||||||
String subString = null;
|
|
||||||
|
|
||||||
while (index < length) {
|
while (index < length) {
|
||||||
char aChar = path.charAt(index);
|
char aChar = path.charAt(index);
|
||||||
@@ -233,9 +232,9 @@ public class JarDiffPatcher implements JarDiffCodes
|
|||||||
path.charAt(index + 1) == ' ') {
|
path.charAt(index + 1) == ' ') {
|
||||||
|
|
||||||
if (subString == null) {
|
if (subString == null) {
|
||||||
subString = path.substring(last, index);
|
subString = new StringBuilder(path.substring(last, index));
|
||||||
} else {
|
} else {
|
||||||
subString += path.substring(last, index);
|
subString.append(path, last, index);
|
||||||
}
|
}
|
||||||
last = ++index;
|
last = ++index;
|
||||||
} else if (Character.isWhitespace(aChar)) {
|
} else if (Character.isWhitespace(aChar)) {
|
||||||
@@ -245,12 +244,14 @@ public class JarDiffPatcher implements JarDiffCodes
|
|||||||
}
|
}
|
||||||
if (last != index) {
|
if (last != index) {
|
||||||
if (subString == null) {
|
if (subString == null) {
|
||||||
subString = path.substring(last, index);
|
subString = new StringBuilder(path.substring(last, index));
|
||||||
} else {
|
} else {
|
||||||
subString += path.substring(last, index);
|
subString.append(path, last, index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sub.add(subString);
|
if (subString != null) {
|
||||||
|
sub.add(subString.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sub;
|
return sub;
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import static java.nio.charset.StandardCharsets.US_ASCII;
|
|||||||
* href="http://www.ietf.org/rfc/rfc2045.txt">2045</a> and <a
|
* href="http://www.ietf.org/rfc/rfc2045.txt">2045</a> and <a
|
||||||
* href="http://www.ietf.org/rfc/rfc3548.txt">3548</a>.
|
* href="http://www.ietf.org/rfc/rfc3548.txt">3548</a>.
|
||||||
*/
|
*/
|
||||||
public class Base64 {
|
public final class Base64 {
|
||||||
/**
|
/**
|
||||||
* Default values for encoder/decoder flags.
|
* Default values for encoder/decoder flags.
|
||||||
*/
|
*/
|
||||||
@@ -68,7 +68,7 @@ public class Base64 {
|
|||||||
// shared code
|
// shared code
|
||||||
// --------------------------------------------------------
|
// --------------------------------------------------------
|
||||||
|
|
||||||
/* package */ static abstract class Coder {
|
/* package */ abstract static class Coder {
|
||||||
public byte[] output;
|
public byte[] output;
|
||||||
public int op;
|
public int op;
|
||||||
|
|
||||||
@@ -178,7 +178,7 @@ public class Base64 {
|
|||||||
* Lookup table for turning bytes into their position in the
|
* Lookup table for turning bytes into their position in the
|
||||||
* Base64 alphabet.
|
* Base64 alphabet.
|
||||||
*/
|
*/
|
||||||
private static final int DECODE[] = {
|
private static final int[] DECODE = {
|
||||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
|
||||||
@@ -201,7 +201,7 @@ public class Base64 {
|
|||||||
* Decode lookup table for the "web safe" variant (RFC 3548
|
* Decode lookup table for the "web safe" variant (RFC 3548
|
||||||
* sec. 4) where - and _ replace + and /.
|
* sec. 4) where - and _ replace + and /.
|
||||||
*/
|
*/
|
||||||
private static final int DECODE_WEBSAFE[] = {
|
private static final int[] DECODE_WEBSAFE = {
|
||||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1,
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1,
|
||||||
@@ -236,7 +236,7 @@ public class Base64 {
|
|||||||
private int state; // state number (0 to 6)
|
private int state; // state number (0 to 6)
|
||||||
private int value;
|
private int value;
|
||||||
|
|
||||||
final private int[] alphabet;
|
private final int[] alphabet;
|
||||||
|
|
||||||
public Decoder(int flags, byte[] output) {
|
public Decoder(int flags, byte[] output) {
|
||||||
this.output = output;
|
this.output = output;
|
||||||
@@ -541,7 +541,7 @@ public class Base64 {
|
|||||||
* Lookup table for turning Base64 alphabet positions (6 bits)
|
* Lookup table for turning Base64 alphabet positions (6 bits)
|
||||||
* into output bytes.
|
* into output bytes.
|
||||||
*/
|
*/
|
||||||
private static final byte ENCODE[] = {
|
private static final byte[] ENCODE = {
|
||||||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
|
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
|
||||||
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
|
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
|
||||||
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
|
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
|
||||||
@@ -552,21 +552,21 @@ public class Base64 {
|
|||||||
* Lookup table for turning Base64 alphabet positions (6 bits)
|
* Lookup table for turning Base64 alphabet positions (6 bits)
|
||||||
* into output bytes.
|
* into output bytes.
|
||||||
*/
|
*/
|
||||||
private static final byte ENCODE_WEBSAFE[] = {
|
private static final byte[] ENCODE_WEBSAFE = {
|
||||||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
|
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
|
||||||
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
|
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
|
||||||
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
|
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
|
||||||
'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-', '_',
|
'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-', '_',
|
||||||
};
|
};
|
||||||
|
|
||||||
final private byte[] tail;
|
private final byte[] tail;
|
||||||
/* package */ int tailLen;
|
/* package */ int tailLen;
|
||||||
private int count;
|
private int count;
|
||||||
|
|
||||||
final public boolean do_padding;
|
public final boolean do_padding;
|
||||||
final public boolean do_newline;
|
public final boolean do_newline;
|
||||||
final public boolean do_cr;
|
public final boolean do_cr;
|
||||||
final private byte[] alphabet;
|
private final byte[] alphabet;
|
||||||
|
|
||||||
public Encoder(int flags, byte[] output) {
|
public Encoder(int flags, byte[] output) {
|
||||||
this.output = output;
|
this.output = output;
|
||||||
@@ -618,7 +618,7 @@ public class Base64 {
|
|||||||
((input[p++] & 0xff) << 8) |
|
((input[p++] & 0xff) << 8) |
|
||||||
(input[p++] & 0xff);
|
(input[p++] & 0xff);
|
||||||
tailLen = 0;
|
tailLen = 0;
|
||||||
};
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
|
|||||||
@@ -8,11 +8,11 @@ package com.threerings.getdown.util;
|
|||||||
/**
|
/**
|
||||||
* Utilities for handling ARGB colors.
|
* Utilities for handling ARGB colors.
|
||||||
*/
|
*/
|
||||||
public class Color
|
public final class Color
|
||||||
{
|
{
|
||||||
public final static int CLEAR = 0x00000000;
|
public static final int CLEAR = 0x00000000;
|
||||||
public final static int WHITE = 0xFFFFFFFF;
|
public static final int WHITE = 0xFFFFFFFF;
|
||||||
public final static int BLACK = 0xFF000000;
|
public static final int BLACK = 0xFF000000;
|
||||||
|
|
||||||
public static float brightness (int argb) {
|
public static float brightness (int argb) {
|
||||||
// TODO: we're ignoring alpha here...
|
// TODO: we're ignoring alpha here...
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ public class Config
|
|||||||
*
|
*
|
||||||
* @param opts options that influence the parsing. See {@link #createOpts}.
|
* @param opts options that influence the parsing. See {@link #createOpts}.
|
||||||
*
|
*
|
||||||
* @return a list of <code>String[]</code> instances containing the key/value pairs in the
|
* @return a list of {@code String[]} instances containing the key/value pairs in the
|
||||||
* order they were parsed from the file.
|
* order they were parsed from the file.
|
||||||
*/
|
*/
|
||||||
public static List<String[]> parsePairs (File source, ParseOpts opts)
|
public static List<String[]> parsePairs (File source, ParseOpts opts)
|
||||||
@@ -83,7 +83,7 @@ public class Config
|
|||||||
List<String[]> pairs = new ArrayList<>();
|
List<String[]> pairs = new ArrayList<>();
|
||||||
for (String line : FileUtil.readLines(source)) {
|
for (String line : FileUtil.readLines(source)) {
|
||||||
// nix comments
|
// nix comments
|
||||||
int cidx = line.indexOf("#");
|
int cidx = line.indexOf('#');
|
||||||
if (opts.strictComments ? cidx == 0 : cidx != -1) {
|
if (opts.strictComments ? cidx == 0 : cidx != -1) {
|
||||||
line = line.substring(0, cidx);
|
line = line.substring(0, cidx);
|
||||||
}
|
}
|
||||||
@@ -97,7 +97,7 @@ public class Config
|
|||||||
// parse our key/value pair
|
// parse our key/value pair
|
||||||
String[] pair = new String[2];
|
String[] pair = new String[2];
|
||||||
// if we're biasing toward key, put all the extra = in the key rather than the value
|
// if we're biasing toward key, put all the extra = in the key rather than the value
|
||||||
int eidx = opts.biasToKey ? line.lastIndexOf("=") : line.indexOf("=");
|
int eidx = opts.biasToKey ? line.lastIndexOf('=') : line.indexOf('=');
|
||||||
if (eidx != -1) {
|
if (eidx != -1) {
|
||||||
pair[0] = line.substring(0, eidx).trim();
|
pair[0] = line.substring(0, eidx).trim();
|
||||||
pair[1] = line.substring(eidx+1).trim();
|
pair[1] = line.substring(eidx+1).trim();
|
||||||
@@ -108,7 +108,7 @@ public class Config
|
|||||||
|
|
||||||
// if the pair has an os qualifier, we need to process it
|
// if the pair has an os qualifier, we need to process it
|
||||||
if (pair[1].startsWith("[")) {
|
if (pair[1].startsWith("[")) {
|
||||||
int qidx = pair[1].indexOf("]");
|
int qidx = pair[1].indexOf(']');
|
||||||
if (qidx == -1) {
|
if (qidx == -1) {
|
||||||
log.warning("Bogus platform specifier", "key", pair[0], "value", pair[1]);
|
log.warning("Bogus platform specifier", "key", pair[0], "value", pair[1]);
|
||||||
continue; // omit the pair entirely
|
continue; // omit the pair entirely
|
||||||
@@ -351,7 +351,7 @@ public class Config
|
|||||||
protected static boolean checkQualifiers (String quals, String osname, String osarch)
|
protected static boolean checkQualifiers (String quals, String osname, String osarch)
|
||||||
{
|
{
|
||||||
if (quals.startsWith("!")) {
|
if (quals.startsWith("!")) {
|
||||||
if (quals.indexOf(",") != -1) { // sanity check
|
if (quals.contains(",")) { // sanity check
|
||||||
log.warning("Multiple qualifiers cannot be used when one of the qualifiers " +
|
log.warning("Multiple qualifiers cannot be used when one of the qualifiers " +
|
||||||
"is negative", "quals", quals);
|
"is negative", "quals", quals);
|
||||||
return false;
|
return false;
|
||||||
@@ -371,7 +371,7 @@ public class Config
|
|||||||
{
|
{
|
||||||
String[] bits = qual.trim().toLowerCase(Locale.ROOT).split("-");
|
String[] bits = qual.trim().toLowerCase(Locale.ROOT).split("-");
|
||||||
String os = bits[0], arch = (bits.length > 1) ? bits[1] : "";
|
String os = bits[0], arch = (bits.length > 1) ? bits[1] : "";
|
||||||
return (osname.indexOf(os) != -1) && (osarch.indexOf(arch) != -1);
|
return (osname.contains(os)) && (osarch.contains(arch));
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Map<String, Object> _data;
|
private final Map<String, Object> _data;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import com.threerings.getdown.data.SysProps;
|
|||||||
|
|
||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
|
||||||
public class ConnectionUtil
|
public final class ConnectionUtil
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Opens a connection to a URL, setting the authentication header if user info is present.
|
* Opens a connection to a URL, setting the authentication header if user info is present.
|
||||||
|
|||||||
@@ -17,19 +17,19 @@ import static com.threerings.getdown.Log.log;
|
|||||||
* Useful routines for launching Java applications from within other Java
|
* Useful routines for launching Java applications from within other Java
|
||||||
* applications.
|
* applications.
|
||||||
*/
|
*/
|
||||||
public class LaunchUtil
|
public final class LaunchUtil
|
||||||
{
|
{
|
||||||
/** The default directory into which a local VM installation should be unpacked. */
|
/** The default directory into which a local VM installation should be unpacked. */
|
||||||
public static final String LOCAL_JAVA_DIR = "java_vm";
|
public static final String LOCAL_JAVA_DIR = "java_vm";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes a <code>version.txt</code> file into the specified application directory and
|
* Writes a {@code version.txt} file into the specified application directory and
|
||||||
* attempts to relaunch Getdown in that directory which will cause it to upgrade to the newly
|
* attempts to relaunch Getdown in that directory which will cause it to upgrade to the newly
|
||||||
* specified version and relaunch the application.
|
* specified version and relaunch the application.
|
||||||
*
|
*
|
||||||
* @param appdir the directory in which the application is installed.
|
* @param appdir the directory in which the application is installed.
|
||||||
* @param getdownJarName the name of the getdown jar file in the application directory. This is
|
* @param getdownJarName the name of the getdown jar file in the application directory. This is
|
||||||
* probably <code>getdown-pro.jar</code> or <code>getdown-retro-pro.jar</code> if you are using
|
* probably {@code getdown-pro.jar} or {@code getdown-retro-pro.jar} if you are using
|
||||||
* the results of the standard build.
|
* the results of the standard build.
|
||||||
* @param newVersion the new version to which Getdown will update when it is executed.
|
* @param newVersion the new version to which Getdown will update when it is executed.
|
||||||
* @param javaLocalDir the name of the directory (inside {@code appdir}) that contains a
|
* @param javaLocalDir the name of the directory (inside {@code appdir}) that contains a
|
||||||
@@ -41,7 +41,7 @@ public class LaunchUtil
|
|||||||
* after making this call as it will be upgraded and restarted. If false is returned, the
|
* after making this call as it will be upgraded and restarted. If false is returned, the
|
||||||
* application should tell the user that they must restart the application manually.
|
* application should tell the user that they must restart the application manually.
|
||||||
*
|
*
|
||||||
* @exception IOException thrown if we were unable to create the <code>version.txt</code> file
|
* @exception IOException thrown if we were unable to create the {@code version.txt} file
|
||||||
* in the supplied application directory. If the version.txt file cannot be created, restarting
|
* in the supplied application directory. If the version.txt file cannot be created, restarting
|
||||||
* Getdown will not cause the application to be upgraded, so the application will have to
|
* Getdown will not cause the application to be upgraded, so the application will have to
|
||||||
* resort to telling the user that it is in a bad way.
|
* resort to telling the user that it is in a bad way.
|
||||||
@@ -177,23 +177,23 @@ public class LaunchUtil
|
|||||||
public static boolean mustMonitorChildren ()
|
public static boolean mustMonitorChildren ()
|
||||||
{
|
{
|
||||||
String osname = System.getProperty("os.name", "").toLowerCase(Locale.ROOT);
|
String osname = System.getProperty("os.name", "").toLowerCase(Locale.ROOT);
|
||||||
return (osname.indexOf("windows 98") != -1 || osname.indexOf("windows me") != -1);
|
return (osname.contains("windows 98") || osname.contains("windows me"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if we're running in a JVM that identifies its operating system as Windows.
|
* Returns true if we're running in a JVM that identifies its operating system as Windows.
|
||||||
*/
|
*/
|
||||||
public static final boolean isWindows () { return _isWindows; }
|
public static boolean isWindows () { return _isWindows; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if we're running in a JVM that identifies its operating system as MacOS.
|
* Returns true if we're running in a JVM that identifies its operating system as MacOS.
|
||||||
*/
|
*/
|
||||||
public static final boolean isMacOS () { return _isMacOS; }
|
public static boolean isMacOS () { return _isMacOS; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if we're running in a JVM that identifies its operating system as Linux.
|
* Returns true if we're running in a JVM that identifies its operating system as Linux.
|
||||||
*/
|
*/
|
||||||
public static final boolean isLinux () { return _isLinux; }
|
public static boolean isLinux () { return _isLinux; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether a Java Virtual Machine can be located in the supplied path.
|
* Checks whether a Java Virtual Machine can be located in the supplied path.
|
||||||
@@ -232,10 +232,9 @@ public class LaunchUtil
|
|||||||
try {
|
try {
|
||||||
String osname = System.getProperty("os.name");
|
String osname = System.getProperty("os.name");
|
||||||
osname = (osname == null) ? "" : osname;
|
osname = (osname == null) ? "" : osname;
|
||||||
_isWindows = (osname.indexOf("Windows") != -1);
|
_isWindows = (osname.contains("Windows"));
|
||||||
_isMacOS = (osname.indexOf("Mac OS") != -1 ||
|
_isMacOS = (osname.contains("Mac OS") || osname.contains("MacOS"));
|
||||||
osname.indexOf("MacOS") != -1);
|
_isLinux = (osname.contains("Linux"));
|
||||||
_isLinux = (osname.indexOf("Linux") != -1);
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// can't grab system properties; we'll just pretend we're not on any of these OSes
|
// can't grab system properties; we'll just pretend we're not on any of these OSes
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
package com.threerings.getdown.util;
|
package com.threerings.getdown.util;
|
||||||
|
|
||||||
public class MessageUtil {
|
public final class MessageUtil {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether or not the provided string is tainted. See {@link #taint}. Null strings
|
* Returns whether or not the provided string is tainted. See {@link #taint}. Null strings
|
||||||
@@ -101,11 +101,11 @@ public class MessageUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to escape single quotes so that they are not interpreted by <code>MessageFormat</code>.
|
* Used to escape single quotes so that they are not interpreted by {@code MessageFormat}.
|
||||||
* As we assume all single quotes are to be escaped, we cannot use the characters
|
* As we assume all single quotes are to be escaped, we cannot use the characters
|
||||||
* <code>{</code> and <code>}</code> in our translation strings, but this is a small price to
|
* <code>{</code> and <code>}</code> in our translation strings, but this is a small price to
|
||||||
* pay to have to differentiate between messages that will and won't eventually be parsed by a
|
* pay to have to differentiate between messages that will and won't eventually be parsed by a
|
||||||
* <code>MessageFormat</code> instance.
|
* {@code MessageFormat} instance.
|
||||||
*/
|
*/
|
||||||
public static String escape (String message)
|
public static String escape (String message)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,5 +14,5 @@ public interface ProgressObserver
|
|||||||
* Informs the observer that we have completed the specified
|
* Informs the observer that we have completed the specified
|
||||||
* percentage of the process.
|
* percentage of the process.
|
||||||
*/
|
*/
|
||||||
public void progress (int percent);
|
void progress (int percent);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,11 +11,10 @@ import java.io.InputStream;
|
|||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
import java.nio.charset.Charset;
|
|
||||||
|
|
||||||
import static com.threerings.getdown.Log.log;
|
import static com.threerings.getdown.Log.log;
|
||||||
|
|
||||||
public class StreamUtil {
|
public final class StreamUtil {
|
||||||
/**
|
/**
|
||||||
* Convenient close for a stream. Use in a finally clause and love life.
|
* Convenient close for a stream. Use in a finally clause and love life.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -7,14 +7,14 @@ package com.threerings.getdown.util;
|
|||||||
|
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
public class StringUtil {
|
public final class StringUtil {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true if the specified string could be a valid URL (contains no illegal characters)
|
* @return true if the specified string could be a valid URL (contains no illegal characters)
|
||||||
*/
|
*/
|
||||||
public static boolean couldBeValidUrl (String url)
|
public static boolean couldBeValidUrl (String url)
|
||||||
{
|
{
|
||||||
return url.matches("[A-Za-z0-9\\-\\._~:/\\?#\\[\\]@!$&'\\(\\)\\*\\+,;=%]+");
|
return url.matches("[A-Za-z0-9\\-._~:/?#\\[\\]@!$&'()*+,;=%]+");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -84,7 +84,7 @@ public class StringUtil {
|
|||||||
source = source.replace(",,", "%COMMA%");
|
source = source.replace(",,", "%COMMA%");
|
||||||
|
|
||||||
// count up the number of tokens
|
// count up the number of tokens
|
||||||
while ((tpos = source.indexOf(",", tpos+1)) != -1) {
|
while ((tpos = source.indexOf(',', tpos+1)) != -1) {
|
||||||
tcount++;
|
tcount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,7 +92,7 @@ public class StringUtil {
|
|||||||
tpos = -1; tcount = 0;
|
tpos = -1; tcount = 0;
|
||||||
|
|
||||||
// do the split
|
// do the split
|
||||||
while ((tpos = source.indexOf(",", tpos+1)) != -1) {
|
while ((tpos = source.indexOf(',', tpos+1)) != -1) {
|
||||||
tokens[tcount] = source.substring(tstart, tpos);
|
tokens[tcount] = source.substring(tstart, tpos);
|
||||||
tokens[tcount] = tokens[tcount].trim().replace("%COMMA%", ",");
|
tokens[tcount] = tokens[tcount].trim().replace("%COMMA%", ",");
|
||||||
if (intern) {
|
if (intern) {
|
||||||
@@ -119,7 +119,7 @@ public class StringUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a string from the supplied bytes that is the HEX encoded representation of those
|
* Generates a string from the supplied bytes that is the HEX encoded representation of those
|
||||||
* bytes. Returns the empty string for a <code>null</code> or empty byte array.
|
* bytes. Returns the empty string for a {@code null} or empty byte array.
|
||||||
*
|
*
|
||||||
* @param bytes the bytes for which we want a string representation.
|
* @param bytes the bytes for which we want a string representation.
|
||||||
* @param count the number of bytes to stop at (which will be coerced into being {@code <=} the
|
* @param count the number of bytes to stop at (which will be coerced into being {@code <=} the
|
||||||
@@ -185,7 +185,7 @@ public class StringUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper function for the various <code>join</code> methods.
|
* Helper function for the various {@code join} methods.
|
||||||
*/
|
*/
|
||||||
protected static String join (Object[] values, String separator, boolean escape)
|
protected static String join (Object[] values, String separator, boolean escape)
|
||||||
{
|
{
|
||||||
@@ -201,6 +201,6 @@ public class StringUtil {
|
|||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Used by {@link #hexlate} and {@link #unhexlate}. */
|
/** Used by {@link #hexlate}. */
|
||||||
protected static final String XLATE = "0123456789abcdef";
|
protected static final String XLATE = "0123456789abcdef";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;
|
|||||||
/**
|
/**
|
||||||
* Version related utilities.
|
* Version related utilities.
|
||||||
*/
|
*/
|
||||||
public class VersionUtil
|
public final class VersionUtil
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Reads a version number from a file.
|
* Reads a version number from a file.
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ public final class AbortPanel extends JFrame
|
|||||||
public void actionPerformed (ActionEvent e)
|
public void actionPerformed (ActionEvent e)
|
||||||
{
|
{
|
||||||
String cmd = e.getActionCommand();
|
String cmd = e.getActionCommand();
|
||||||
if (cmd.equals("ok")) {
|
if ("ok".equals(cmd)) {
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
} else {
|
} else {
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
|
|||||||
@@ -22,7 +22,15 @@ import java.io.InputStreamReader;
|
|||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.ResourceBundle;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import javax.swing.AbstractAction;
|
import javax.swing.AbstractAction;
|
||||||
@@ -31,13 +39,24 @@ import javax.swing.JFrame;
|
|||||||
import javax.swing.JLayeredPane;
|
import javax.swing.JLayeredPane;
|
||||||
|
|
||||||
import com.samskivert.swing.util.SwingUtil;
|
import com.samskivert.swing.util.SwingUtil;
|
||||||
import com.threerings.getdown.data.*;
|
import com.threerings.getdown.data.Application;
|
||||||
import com.threerings.getdown.data.Application.UpdateInterface.Step;
|
import com.threerings.getdown.data.Application.UpdateInterface.Step;
|
||||||
|
import com.threerings.getdown.data.Build;
|
||||||
|
import com.threerings.getdown.data.EnvConfig;
|
||||||
|
import com.threerings.getdown.data.Resource;
|
||||||
|
import com.threerings.getdown.data.SysProps;
|
||||||
import com.threerings.getdown.net.Downloader;
|
import com.threerings.getdown.net.Downloader;
|
||||||
import com.threerings.getdown.net.HTTPDownloader;
|
import com.threerings.getdown.net.HTTPDownloader;
|
||||||
import com.threerings.getdown.tools.Patcher;
|
import com.threerings.getdown.tools.Patcher;
|
||||||
import com.threerings.getdown.util.*;
|
import com.threerings.getdown.util.Config;
|
||||||
|
import com.threerings.getdown.util.ConnectionUtil;
|
||||||
|
import com.threerings.getdown.util.FileUtil;
|
||||||
|
import com.threerings.getdown.util.LaunchUtil;
|
||||||
|
import com.threerings.getdown.util.MessageUtil;
|
||||||
|
import com.threerings.getdown.util.ProgressAggregator;
|
||||||
|
import com.threerings.getdown.util.ProgressObserver;
|
||||||
|
import com.threerings.getdown.util.StringUtil;
|
||||||
|
import com.threerings.getdown.util.VersionUtil;
|
||||||
import static com.threerings.getdown.Log.log;
|
import static com.threerings.getdown.Log.log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -75,7 +94,7 @@ public abstract class Getdown extends Thread
|
|||||||
// welcome to hell, where java can't cope with a classpath that contains jars that live
|
// welcome to hell, where java can't cope with a classpath that contains jars that live
|
||||||
// in a directory that contains a !, at least the same bug happens on all platforms
|
// in a directory that contains a !, at least the same bug happens on all platforms
|
||||||
String dir = envc.appDir.toString();
|
String dir = envc.appDir.toString();
|
||||||
if (dir.equals(".")) {
|
if (".".equals(dir)) {
|
||||||
dir = System.getProperty("user.dir");
|
dir = System.getProperty("user.dir");
|
||||||
}
|
}
|
||||||
String errmsg = "The directory in which this application is installed:\n" + dir +
|
String errmsg = "The directory in which this application is installed:\n" + dir +
|
||||||
@@ -130,7 +149,7 @@ public abstract class Getdown extends Thread
|
|||||||
File instdir = _app.getLocalPath("");
|
File instdir = _app.getLocalPath("");
|
||||||
if (!instdir.canWrite()) {
|
if (!instdir.canWrite()) {
|
||||||
String path = instdir.getPath();
|
String path = instdir.getPath();
|
||||||
if (path.equals(".")) {
|
if (".".equals(path)) {
|
||||||
path = System.getProperty("user.dir");
|
path = System.getProperty("user.dir");
|
||||||
}
|
}
|
||||||
fail(MessageUtil.tcompose("m.readonly_error", path));
|
fail(MessageUtil.tcompose("m.readonly_error", path));
|
||||||
@@ -161,20 +180,7 @@ public abstract class Getdown extends Thread
|
|||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warning("run() failed.", e);
|
log.warning("run() failed.", e);
|
||||||
String msg = e.getMessage();
|
fail(e);
|
||||||
if (msg == null) {
|
|
||||||
msg = MessageUtil.compose("m.unknown_error", _ifc.installError);
|
|
||||||
} else if (!msg.startsWith("m.")) {
|
|
||||||
// try to do something sensible based on the type of error
|
|
||||||
if (e instanceof FileNotFoundException) {
|
|
||||||
msg = MessageUtil.compose(
|
|
||||||
"m.missing_resource", MessageUtil.taint(msg), _ifc.installError);
|
|
||||||
} else {
|
|
||||||
msg = MessageUtil.compose(
|
|
||||||
"m.init_error", MessageUtil.taint(msg), _ifc.installError);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fail(msg);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -285,7 +291,7 @@ public abstract class Getdown extends Thread
|
|||||||
// Store the config modtime before waiting the delay amount of time
|
// Store the config modtime before waiting the delay amount of time
|
||||||
long lastConfigModtime = config.lastModified();
|
long lastConfigModtime = config.lastModified();
|
||||||
log.info("Waiting " + _delay + " minutes before beginning actual work.");
|
log.info("Waiting " + _delay + " minutes before beginning actual work.");
|
||||||
Thread.sleep(_delay * 60 * 1000);
|
TimeUnit.MINUTES.sleep(_delay);
|
||||||
if (lastConfigModtime < config.lastModified()) {
|
if (lastConfigModtime < config.lastModified()) {
|
||||||
log.warning("getdown.txt was modified while getdown was waiting.");
|
log.warning("getdown.txt was modified while getdown was waiting.");
|
||||||
throw new MultipleGetdownRunning();
|
throw new MultipleGetdownRunning();
|
||||||
@@ -334,11 +340,7 @@ public abstract class Getdown extends Thread
|
|||||||
|
|
||||||
if (toDownload.size() > 0) {
|
if (toDownload.size() > 0) {
|
||||||
// we have resources to download, also note them as to-be-installed
|
// we have resources to download, also note them as to-be-installed
|
||||||
for (Resource r : toDownload) {
|
_toInstallResources.addAll(toDownload);
|
||||||
if (!_toInstallResources.contains(r)) {
|
|
||||||
_toInstallResources.add(r);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// if any of our resources have already been marked valid this is not a
|
// if any of our resources have already been marked valid this is not a
|
||||||
@@ -423,22 +425,7 @@ public abstract class Getdown extends Thread
|
|||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warning("getdown() failed.", e);
|
log.warning("getdown() failed.", e);
|
||||||
String msg = e.getMessage();
|
fail(e);
|
||||||
if (msg == null) {
|
|
||||||
msg = MessageUtil.compose("m.unknown_error", _ifc.installError);
|
|
||||||
} else if (!msg.startsWith("m.")) {
|
|
||||||
// try to do something sensible based on the type of error
|
|
||||||
if (e instanceof FileNotFoundException) {
|
|
||||||
msg = MessageUtil.compose(
|
|
||||||
"m.missing_resource", MessageUtil.taint(msg), _ifc.installError);
|
|
||||||
} else {
|
|
||||||
msg = MessageUtil.compose(
|
|
||||||
"m.init_error", MessageUtil.taint(msg), _ifc.installError);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Since we're dead, clear off the 'time remaining' label along with displaying the
|
|
||||||
// error message
|
|
||||||
fail(msg);
|
|
||||||
_app.releaseLock();
|
_app.releaseLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -525,7 +512,7 @@ public abstract class Getdown extends Thread
|
|||||||
|
|
||||||
// lastly regenerate the .jsa dump file that helps Java to start up faster
|
// lastly regenerate the .jsa dump file that helps Java to start up faster
|
||||||
String vmpath = LaunchUtil.getJVMBinaryPath(javaLocalDir, false);
|
String vmpath = LaunchUtil.getJVMBinaryPath(javaLocalDir, false);
|
||||||
String[] command = new String[] { vmpath, "-Xshare:dump" };
|
String[] command = { vmpath, "-Xshare:dump" };
|
||||||
try {
|
try {
|
||||||
log.info("Regenerating classes.jsa for " + vmpath + "...");
|
log.info("Regenerating classes.jsa for " + vmpath + "...");
|
||||||
Runtime.getRuntime().exec(command);
|
Runtime.getRuntime().exec(command);
|
||||||
@@ -732,7 +719,7 @@ public abstract class Getdown extends Thread
|
|||||||
long minshow = _ifc.minShowSeconds * 1000L;
|
long minshow = _ifc.minShowSeconds * 1000L;
|
||||||
if (_container != null && uptime < minshow) {
|
if (_container != null && uptime < minshow) {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(minshow - uptime);
|
TimeUnit.MILLISECONDS.sleep(minshow - uptime);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -848,8 +835,22 @@ public abstract class Getdown extends Thread
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void fail (Exception e) {
|
||||||
|
String msg = e.getMessage();
|
||||||
|
if (msg == null) {
|
||||||
|
msg = MessageUtil.compose("m.unknown_error", _ifc.installError);
|
||||||
|
} else if (!msg.startsWith("m.")) {
|
||||||
|
// try to do something sensible based on the type of error
|
||||||
|
msg = e instanceof FileNotFoundException
|
||||||
|
? MessageUtil.compose("m.missing_resource", MessageUtil.taint(msg), _ifc.installError)
|
||||||
|
: MessageUtil.compose("m.init_error", MessageUtil.taint(msg), _ifc.installError);
|
||||||
|
}
|
||||||
|
// Since we're dead, clear off the 'time remaining' label along with displaying the error message
|
||||||
|
fail(msg);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the status to indicate getdown has failed for the reason in <code>message</code>.
|
* Update the status to indicate getdown has failed for the reason in {@code message}.
|
||||||
*/
|
*/
|
||||||
protected void fail (String message)
|
protected void fail (String message)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ public class GetdownApp
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (_ifc.iconImages != null) {
|
if (_ifc.iconImages != null) {
|
||||||
ArrayList<Image> icons = new ArrayList<>();
|
List<Image> icons = new ArrayList<>();
|
||||||
for (String path : _ifc.iconImages) {
|
for (String path : _ifc.iconImages) {
|
||||||
Image img = loadImage(path);
|
Image img = loadImage(path);
|
||||||
if (img == null) {
|
if (img == null) {
|
||||||
@@ -190,7 +190,7 @@ public class GetdownApp
|
|||||||
String[] cmdarray;
|
String[] cmdarray;
|
||||||
if (LaunchUtil.isWindows()) {
|
if (LaunchUtil.isWindows()) {
|
||||||
String osName = System.getProperty("os.name", "");
|
String osName = System.getProperty("os.name", "");
|
||||||
if (osName.indexOf("9") != -1 || osName.indexOf("Me") != -1) {
|
if (osName.contains("9") || osName.contains("Me")) {
|
||||||
cmdarray = new String[] {
|
cmdarray = new String[] {
|
||||||
"command.com", "/c", "start", "\"" + url + "\"" };
|
"command.com", "/c", "start", "\"" + url + "\"" };
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ public final class ProxyPanel extends JPanel implements ActionListener
|
|||||||
public void actionPerformed (ActionEvent e)
|
public void actionPerformed (ActionEvent e)
|
||||||
{
|
{
|
||||||
String cmd = e.getActionCommand();
|
String cmd = e.getActionCommand();
|
||||||
if (cmd.equals("ok")) {
|
if ("ok".equals(cmd)) {
|
||||||
String user = null, pass = null;
|
String user = null, pass = null;
|
||||||
if (_useAuth.isSelected()) {
|
if (_useAuth.isSelected()) {
|
||||||
user = _username.getText();
|
user = _username.getText();
|
||||||
|
|||||||
@@ -19,20 +19,18 @@ import java.net.URLConnection;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.ServiceLoader;
|
import java.util.ServiceLoader;
|
||||||
|
|
||||||
import ca.beq.util.win32.registry.RegistryKey;
|
|
||||||
import ca.beq.util.win32.registry.RegistryValue;
|
|
||||||
import ca.beq.util.win32.registry.RootKey;
|
|
||||||
|
|
||||||
import com.threerings.getdown.data.Application;
|
import com.threerings.getdown.data.Application;
|
||||||
import com.threerings.getdown.spi.ProxyAuth;
|
import com.threerings.getdown.spi.ProxyAuth;
|
||||||
import com.threerings.getdown.util.Config;
|
import com.threerings.getdown.util.Config;
|
||||||
import com.threerings.getdown.util.ConnectionUtil;
|
import com.threerings.getdown.util.ConnectionUtil;
|
||||||
import com.threerings.getdown.util.LaunchUtil;
|
import com.threerings.getdown.util.LaunchUtil;
|
||||||
import com.threerings.getdown.util.StringUtil;
|
import com.threerings.getdown.util.StringUtil;
|
||||||
|
import ca.beq.util.win32.registry.RegistryKey;
|
||||||
|
import ca.beq.util.win32.registry.RegistryValue;
|
||||||
|
import ca.beq.util.win32.registry.RootKey;
|
||||||
import static com.threerings.getdown.Log.log;
|
import static com.threerings.getdown.Log.log;
|
||||||
|
|
||||||
public class ProxyUtil {
|
public final class ProxyUtil {
|
||||||
|
|
||||||
public static boolean autoDetectProxy (Application app)
|
public static boolean autoDetectProxy (Application app)
|
||||||
{
|
{
|
||||||
@@ -57,12 +55,12 @@ public class ProxyUtil {
|
|||||||
RegistryKey r = new RegistryKey(RootKey.HKEY_CURRENT_USER, PROXY_REGISTRY);
|
RegistryKey r = new RegistryKey(RootKey.HKEY_CURRENT_USER, PROXY_REGISTRY);
|
||||||
for (Iterator<?> iter = r.values(); iter.hasNext(); ) {
|
for (Iterator<?> iter = r.values(); iter.hasNext(); ) {
|
||||||
RegistryValue value = (RegistryValue)iter.next();
|
RegistryValue value = (RegistryValue)iter.next();
|
||||||
if (value.getName().equals("ProxyEnable")) {
|
if ("ProxyEnable".equals(value.getName())) {
|
||||||
enabled = value.getStringValue().equals("1");
|
enabled = "1".equals(value.getStringValue());
|
||||||
}
|
}
|
||||||
if (value.getName().equals("ProxyServer")) {
|
if ("ProxyServer".equals(value.getName())) {
|
||||||
String strval = value.getStringValue();
|
String strval = value.getStringValue();
|
||||||
int cidx = strval.indexOf(":");
|
int cidx = strval.indexOf(':');
|
||||||
if (cidx != -1) {
|
if (cidx != -1) {
|
||||||
rport = strval.substring(cidx+1);
|
rport = strval.substring(cidx+1);
|
||||||
strval = strval.substring(0, cidx);
|
strval = strval.substring(0, cidx);
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public final class RotatingBackgrounds
|
|||||||
{
|
{
|
||||||
public interface ImageLoader {
|
public interface ImageLoader {
|
||||||
/** Loads and returns the image with the supplied path. */
|
/** Loads and returns the image with the supplied path. */
|
||||||
public Image loadImage (String path);
|
Image loadImage (String path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -35,7 +35,7 @@ public final class RotatingBackgrounds
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a sequence of images to be rotated through from <code>backgrounds</code>.
|
* Create a sequence of images to be rotated through from {@code backgrounds}.
|
||||||
*
|
*
|
||||||
* Each String in backgrounds should be the path to the image, a semicolon, and the minimum
|
* Each String in backgrounds should be the path to the image, a semicolon, and the minimum
|
||||||
* amount of time to display the image in seconds. Each image will be active for an equal
|
* amount of time to display the image in seconds. Each image will be active for an equal
|
||||||
|
|||||||
@@ -26,12 +26,9 @@ import com.samskivert.swing.Label;
|
|||||||
import com.samskivert.swing.LabelStyleConstants;
|
import com.samskivert.swing.LabelStyleConstants;
|
||||||
import com.samskivert.swing.util.SwingUtil;
|
import com.samskivert.swing.util.SwingUtil;
|
||||||
import com.samskivert.util.Throttle;
|
import com.samskivert.util.Throttle;
|
||||||
|
|
||||||
import com.threerings.getdown.data.Application.UpdateInterface;
|
import com.threerings.getdown.data.Application.UpdateInterface;
|
||||||
import com.threerings.getdown.util.MessageUtil;
|
import com.threerings.getdown.util.MessageUtil;
|
||||||
import com.threerings.getdown.util.Rectangle;
|
import com.threerings.getdown.util.Rectangle;
|
||||||
import com.threerings.getdown.util.StringUtil;
|
|
||||||
|
|
||||||
import static com.threerings.getdown.Log.log;
|
import static com.threerings.getdown.Log.log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -344,7 +341,7 @@ public final class StatusPanel extends JComponent
|
|||||||
{
|
{
|
||||||
String msg = get(key);
|
String msg = get(key);
|
||||||
if (msg != null) return MessageFormat.format(MessageUtil.escape(msg), (Object[])args);
|
if (msg != null) return MessageFormat.format(MessageUtil.escape(msg), (Object[])args);
|
||||||
return key + String.valueOf(Arrays.asList(args));
|
return key + Arrays.asList(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Used by {@link #setStatus}, and {@link #setProgress}. */
|
/** Used by {@link #setStatus}, and {@link #setProgress}. */
|
||||||
|
|||||||
Reference in New Issue
Block a user