📄 coreupdatechecker.java
字号:
update = update1;
f_latest_version = s;
super();
}
});
checker.completed();
first_check = false;
break MISSING_BLOCK_LABEL_952;
Throwable e;
e;
log.log(e);
Debug.printStackTrace(e);
checker.reportProgress((new StringBuilder()).append("Failed to check for core update: ").append(Debug.getNestedExceptionMessage(e)).toString());
checker.failed();
checker.completed();
first_check = false;
break MISSING_BLOCK_LABEL_952;
Exception exception;
exception;
checker.completed();
first_check = false;
throw exception;
}
private void displayUserMessage(Map reply)
{
Iterator it = reply.keySet().iterator();
_L5:
String message;
String last_message_key;
byte signature[];
String sig_key;
String last;
do
{
String key;
byte message_bytes[];
do
{
do
{
if (!it.hasNext())
break MISSING_BLOCK_LABEL_730;
key = (String)it.next();
} while (key.startsWith("message_sig") || !key.startsWith("message"));
message_bytes = (byte[])(byte[])reply.get(key);
} while (message_bytes == null || message_bytes.length <= 0);
try
{
message = new String(message_bytes, "UTF-8");
}
catch (Throwable e)
{
message = new String(message_bytes);
}
int pos = key.indexOf('_');
if (pos == -1)
sig_key = "message_sig";
else
sig_key = (new StringBuilder()).append("message_sig").append(key.substring(pos)).toString();
last_message_key = (new StringBuilder()).append("CoreUpdateChecker.last").append(key).toString();
last = COConfigurationManager.getStringParameter(last_message_key, "");
} while (message.equals(last));
signature = (byte[])(byte[])reply.get(sig_key);
if (signature == null)
{
Logger.log(new LogEvent(LogIDs.LOGGER, "Signature missing from message"));
return;
}
try
{
AEVerifier.verifyData(message, signature);
}
catch (Throwable e)
{
Logger.log(new LogEvent(LogIDs.LOGGER, "Message signature check failed", e));
return;
}
boolean completed = false;
if (!message.startsWith("x:")) goto _L2; else goto _L1
_L1:
File jar_file;
InputStream is;
URL jar_url = new URL(message.substring(2));
Logger.log(new LogEvent(LogIDs.LOGGER, (new StringBuilder()).append("Patch application requsted: url=").append(jar_url).toString()));
File temp_dir = AETemporaryFileHandler.createTempDir();
jar_file = new File(temp_dir, "patch.jar");
is = rdf.create(jar_url).download();
FileUtil.copyFile(is, jar_file);
is = null;
AEVerifier.verifyData(jar_file);
ClassLoader cl = org/gudy/azureus2/update/CoreUpdateChecker.getClassLoader();
if (cl instanceof URLClassLoader)
{
URL old[] = ((URLClassLoader)cl).getURLs();
URL new_urls[] = new URL[old.length + 1];
System.arraycopy(old, 0, new_urls, 1, old.length);
new_urls[0] = jar_file.toURL();
cl = new URLClassLoader(new_urls, cl);
} else
{
cl = new URLClassLoader(new URL[] {
jar_file.toURL()
}, cl);
}
Class cla = cl.loadClass("org.gudy.azureus2.update.version.Patch");
cla.newInstance();
completed = true;
if (is != null)
is.close();
goto _L3
Exception exception;
exception;
if (is != null)
is.close();
throw exception;
Throwable e;
e;
Logger.log(new LogEvent(LogIDs.LOGGER, "Patch application failed", e));
goto _L3
_L2:
if (message.startsWith("u:") && message.length() > 4)
{
try
{
String type = message.substring(2, 3);
String url = message.substring(4);
UIFunctions uif = UIFunctionsManager.getUIFunctions();
if (uif != null)
uif.viewURL(url, null, 0.90000000000000002D, 0.90000000000000002D, true, type.equals("1"));
}
catch (Throwable t)
{
Logger.log(new LogEvent(LogIDs.LOGGER, "URL message failed", t));
}
completed = true;
} else
{
int alert_type = 1;
String alert_text = message;
if (alert_text.startsWith("i:"))
{
alert_type = 0;
alert_text = alert_text.substring(2);
}
plugin_interface.getPluginProperties().setProperty("message", alert_text);
Logger.log(new LogAlert(false, alert_type, alert_text, 0));
completed = true;
}
_L3:
if (completed)
{
COConfigurationManager.setParameter(last_message_key, message);
COConfigurationManager.save();
}
if (true) goto _L5; else goto _L4
_L4:
Throwable e;
e;
Debug.printStackTrace(e);
}
protected ResourceDownloader[] getPrimaryDownloaders(String latest_file_name)
{
log.log("Downloading primary mirrors");
List res = new ArrayList();
try
{
if (latest_file_name == null)
{
res.add(new URL("http://azureus.sourceforge.net/Azureus2.jar"));
} else
{
URL mirrors_url = new URL((new StringBuilder()).append("http://prdownloads.sourceforge.net/azureus/").append(latest_file_name).append("?download").toString());
ResourceDownloader rd = rdf.create(mirrors_url);
rd = rdf.getRetryDownloader(rd, 3);
rd.addListener(rd_logger);
String page = HTMLPageFactory.loadPage(rd.download()).getContent();
String pattern = (new StringBuilder()).append("/azureus/").append(latest_file_name).append("?use_mirror=").toString();
for (int position = page.indexOf(pattern); position > 0;)
{
int end = page.indexOf(">", position);
if (end < 0)
{
position = -1;
} else
{
String mirror = page.substring(position, end);
if (mirror.endsWith("\""))
mirror = mirror.substring(0, mirror.length() - 1);
try
{
res.add(new URL((new StringBuilder()).append("http://prdownloads.sourceforge.net").append(mirror).toString()));
}
catch (Throwable e)
{
log.log((new StringBuilder()).append("Invalid URL read:").append(mirror).toString(), e);
}
position = page.indexOf(pattern, position + 1);
}
}
}
}
catch (Throwable e)
{
log.log("Failed to read primary mirror list", e);
}
ResourceDownloader dls[] = new ResourceDownloader[res.size()];
for (int i = 0; i < res.size(); i++)
{
URL url = (URL)res.get(i);
log.log((new StringBuilder()).append(" Primary mirror:").append(url.toString()).toString());
ResourceDownloader dl = rdf.create(url);
dl = rdf.getMetaRefreshDownloader(dl);
dl = rdf.getSuffixBasedDownloader(dl);
dls[i] = dl;
}
return dls;
}
protected ResourceDownloader[] getBackupDownloaders(String latest_file_name)
{
List res = new ArrayList();
try
{
if (latest_file_name != null)
{
log.log("Downloading backup mirrors");
URL mirrors_url = new URL("http://azureus.sourceforge.net/mirrors.php");
ResourceDownloader rd = rdf.create(mirrors_url);
rd = rdf.getRetryDownloader(rd, 3);
rd.addListener(rd_logger);
BufferedInputStream data = new BufferedInputStream(rd.download());
Map decoded = BDecoder.decode(data);
data.close();
List mirrors = (List)decoded.get("mirrors");
for (int i = 0; i < mirrors.size(); i++)
{
String mirror = new String((byte[])(byte[])mirrors.get(i));
try
{
res.add(new URL((new StringBuilder()).append(mirror).append(latest_file_name).toString()));
}
catch (Throwable e)
{
log.log((new StringBuilder()).append("Invalid URL read:").append(mirror).toString(), e);
}
}
}
}
catch (Throwable e)
{
log.log("Failed to read backup mirror list", e);
}
ResourceDownloader dls[] = new ResourceDownloader[res.size()];
for (int i = 0; i < res.size(); i++)
{
URL url = (URL)res.get(i);
log.log((new StringBuilder()).append(" Backup mirror:").append(url.toString()).toString());
ResourceDownloader dl = rdf.create(url);
dl = rdf.getSuffixBasedDownloader(dl);
dls[i] = dl;
}
return dls;
}
protected void installUpdate(UpdateChecker checker, Update update, ResourceDownloader rd, String version, InputStream data)
{
try
{
data = update.verifyData(data, true);
rd.reportActivity("Data verified successfully");
String temp_jar_name = (new StringBuilder()).append("Azureus2_").append(version).append(".jar").toString();
String target_jar_name = "Azureus2.jar";
UpdateInstaller installer = checker.createInstaller();
installer.addResource(temp_jar_name, data);
if (Constants.isOSX)
installer.addMoveAction(temp_jar_name, (new StringBuilder()).append(installer.getInstallDir()).append("/").append(SystemProperties.getApplicationName()).append(".app/Contents/Resources/Java/").append(target_jar_name).toString());
else
installer.addMoveAction(temp_jar_name, (new StringBuilder()).append(installer.getInstallDir()).append(File.separator).append(target_jar_name).toString());
}
catch (Throwable e)
{
rd.reportActivity((new StringBuilder()).append("Update install failed:").append(e.getMessage()).toString());
}
}
protected static boolean shouldUpdate(String current_version, String latest_version)
{
String current_base = Constants.getBaseVersion(current_version);
int current_inc = Constants.getIncrementalBuild(current_version);
String latest_base = Constants.getBaseVersion(latest_version);
int latest_inc = Constants.getIncrementalBuild(latest_version);
int major_comp = Constants.compareVersions(current_base, latest_base);
if (major_comp < 0 && latest_inc == 0)
return true;
else
return major_comp == 0 && current_inc > 0 && latest_inc > 0 && latest_inc > current_inc;
}
public static void main(String args[])
{
String tests[][] = {
{
"2.4.0.0", "2.4.0.2", "true"
}, {
"2.4.0.1_CVS", "2.4.0.2", "true"
}, {
"2.4.0.1_B12", "2.4.0.2", "true"
}, {
"2.4.0.1_B12", "2.4.0.1_B34", "true"
}, {
"2.4.0.1_B12", "2.4.0.1_B6", "false"
}, {
"2.4.0.0", "2.4.0.1_CVS", "false"
}, {
"2.4.0.0", "2.4.0.1_B12", "false"
}, {
"2.4.0.0", "2.4.0.0", "false"
}, {
"2.4.0.1_CVS", "2.4.0.1_CVS", "false"
}, {
"2.4.0.1_B2", "2.4.0.1_B2", "false"
}, {
"2.4.0.1_CVS", "2.4.0.1_B2", "false"
}, {
"2.4.0.1_B2", "2.4.0.1_CVS", "false"
}
};
for (int i = 0; i < tests.length; i++)
System.out.println((new StringBuilder()).append(shouldUpdate(tests[i][0], tests[i][1])).append(" / ").append(tests[i][2]).toString());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -