📄 pluginupdateplugin.java
字号:
loader_listener_added = true;
loader.addListener(new SFPluginDetailsLoaderListener() {
final PluginUpdatePlugin this$0;
public void log(String str)
{
PluginUpdatePlugin.this.log.log(1, (new StringBuilder()).append("[").append(str).append("]").toString());
}
{
this$0 = PluginUpdatePlugin.this;
super();
}
});
}
ids = loader.getPluginIDs();
String id_info = "";
for (i = 0; i < ids.length; i++)
{
String id = ids[i];
SFPluginDetails details = loader.getPluginDetails(id);
id_info = (new StringBuilder()).append(id_info).append(i != 0 ? "," : "").append(ids[i]).append("=").append(details.getVersion()).append("/").append(details.getCVSVersion()).toString();
}
if (!id_info.equals(last_id_info))
{
last_id_info = id_info;
log.log(1, (new StringBuilder()).append("Downloaded plugin info = ").append(id_info).toString());
}
i = 0;
_L3:
if (i >= plugins_to_check.size()) goto _L2; else goto _L1
_L1:
PluginInterface pi_being_checked;
String plugin_id;
String plugin_names;
if (checker.getCheckInstance().isCancelled())
throw new Exception("Update check cancelled");
pi_being_checked = (PluginInterface)plugins_to_check.get(i);
plugin_id = pi_being_checked.getPluginID();
boolean found = false;
int j = 0;
do
{
if (j >= ids.length)
break;
if (ids[j].equalsIgnoreCase(plugin_id))
{
found = true;
break;
}
j++;
} while (true);
if (!found)
{
if (!pi_being_checked.getPluginState().isBuiltIn())
log.log(1, (new StringBuilder()).append("Skipping ").append(plugin_id).append(" as not listed on web site").toString());
continue; /* Loop/switch isn't completed */
}
plugin_names = (String)plugins_to_check_names.get(plugin_id);
log.log(1, (new StringBuilder()).append("Checking ").append(plugin_id).toString());
SFPluginDetails details;
boolean az_cvs;
String pi_version_info;
String az_plugin_version;
String sf_plugin_version;
String sf_comp_version;
checker.reportProgress((new StringBuilder()).append("Loading details for ").append(plugin_id).append("/").append(pi_being_checked.getPluginName()).toString());
details = loader.getPluginDetails(plugin_id);
if (plugin_names.length() == 0)
plugin_names = details.getName();
az_cvs = plugin_interface.getUtilities().isCVSVersion();
pi_version_info = pi_being_checked.getPluginProperties().getProperty("plugin.version.info");
az_plugin_version = pi_being_checked.getPluginVersion();
sf_plugin_version = details.getVersion();
sf_comp_version = sf_plugin_version;
if (az_cvs)
{
String sf_cvs_version = details.getCVSVersion();
if (sf_cvs_version.length() > 0)
{
sf_plugin_version = sf_cvs_version;
sf_comp_version = sf_plugin_version.substring(0, sf_plugin_version.length() - 4);
}
}
if (sf_comp_version.length() == 0 || !Character.isDigit(sf_comp_version.charAt(0)))
{
log.log(1, (new StringBuilder()).append("Skipping ").append(plugin_id).append(" as no valid version to check").toString());
continue; /* Loop/switch isn't completed */
}
try
{
int comp = PluginUtils.comparePluginVersions(az_plugin_version, sf_comp_version);
log.log(1, (new StringBuilder()).append(" Current: ").append(az_plugin_version).append(comp != 0 || !sf_plugin_version.endsWith("_CVS") ? "" : "_CVS").append(", Latest: ").append(sf_plugin_version).append(pi_version_info != null ? (new StringBuilder()).append(" [").append(pi_version_info).append("]").toString() : "").toString());
checker.reportProgress((new StringBuilder()).append(" current=").append(az_plugin_version).append(comp != 0 || !sf_plugin_version.endsWith("_CVS") ? "" : "_CVS").append(", latest=").append(sf_plugin_version).toString());
if (comp >= 0 || (pi_being_checked.getPlugin() instanceof UpdatableComponent))
continue; /* Loop/switch isn't completed */
String sf_plugin_download = details.getDownloadURL();
if (az_cvs)
{
String sf_cvs_version = details.getCVSVersion();
if (sf_cvs_version.length() > 0)
sf_plugin_download = details.getCVSDownloadURL();
}
log.log(1, " Description:");
List update_desc = new ArrayList();
List desc_lines = HTMLUtils.convertHTMLToText("", details.getDescription());
logMultiLine(" ", desc_lines);
update_desc.addAll(desc_lines);
log.log(1, " Comment:");
List comment_lines = HTMLUtils.convertHTMLToText(" ", details.getComment());
logMultiLine(" ", comment_lines);
update_desc.addAll(comment_lines);
String msg = (new StringBuilder()).append("A newer version (version ").append(sf_plugin_version).append(") of plugin '").append(plugin_id).append("' ").append(plugin_names.length() != 0 ? (new StringBuilder()).append("(").append(plugin_names).append(") ").toString() : "").append("is available. ").toString();
log.log(1, "");
log.log(1, (new StringBuilder()).append(" ").append(msg).append("Download from ").append(sf_plugin_download).toString());
ResourceDownloaderFactory rdf = plugin_interface.getUtilities().getResourceDownloaderFactory();
ResourceDownloader direct_rdl = rdf.create(new URL(sf_plugin_download));
String torrent_download = "http://torrents.aelitis.com:88/torrents/";
int slash_pos = sf_plugin_download.lastIndexOf("/");
if (slash_pos == -1)
torrent_download = (new StringBuilder()).append(torrent_download).append(sf_plugin_download).toString();
else
torrent_download = (new StringBuilder()).append(torrent_download).append(sf_plugin_download.substring(slash_pos + 1)).toString();
torrent_download = (new StringBuilder()).append(torrent_download).append(".torrent").toString();
ResourceDownloader torrent_rdl = rdf.create(new URL(torrent_download));
torrent_rdl = rdf.getSuffixBasedDownloader(torrent_rdl);
ResourceDownloader alternate_rdl = rdf.getAlternateDownloader(new ResourceDownloader[] {
torrent_rdl, direct_rdl
});
rdf.getTimeoutDownloader(rdf.getRetryDownloader(alternate_rdl, 3), 10000).getSize();
String update_d[] = new String[update_desc.size()];
update_desc.toArray(update_d);
num_updates_found++;
boolean plugin_unloadable = true;
for (int j = 0; j < plugins.length; j++)
{
PluginInterface pi = plugins[j];
if (pi.getPluginID().equals(plugin_id))
plugin_unloadable &= pi.getPluginState().isUnloadable();
}
if (plugin_unloadable)
checker.reportProgress("Plugin is unloadable");
Update update = addUpdate(pi_being_checked, checker, (new StringBuilder()).append(plugin_id).append("/").append(plugin_names).toString(), update_d, sf_plugin_version, alternate_rdl, sf_plugin_download.toLowerCase().endsWith(".jar"), plugin_unloadable ? 1 : 2, true);
update.setRelativeURLBase(details.getRelativeURLBase());
update.setDescriptionURL(details.getInfoURL());
continue; /* Loop/switch isn't completed */
}
catch (Throwable e)
{
checker.reportProgress((new StringBuilder()).append("Failed to load details for plugin '").append(plugin_id).append("': ").append(Debug.getNestedExceptionMessage(e)).toString());
log.log(" Plugin check failed", e);
i++;
}
goto _L3
_L2:
checker.completed();
break MISSING_BLOCK_LABEL_2161;
Throwable e;
e;
if (!"Update check cancelled".equals(e.getMessage()))
log.log("Failed to load plugin details", e);
checker.reportProgress((new StringBuilder()).append("Failed to load plugin details: ").append(Debug.getNestedExceptionMessage(e)).toString());
checker.failed();
checker.completed();
break MISSING_BLOCK_LABEL_2161;
Exception exception;
exception;
checker.completed();
throw exception;
return num_updates_found;
}
public Update addUpdate(final PluginInterface pi_for_update, final UpdateChecker checker, String update_name, String update_details[], final String version, ResourceDownloader resource_downloader, final boolean is_jar,
final int restart_type, final boolean verify)
{
final Update update = checker.addUpdate(update_name, update_details, version, resource_downloader, restart_type);
update.setUserObject(pi_for_update);
resource_downloader.addListener(new ResourceDownloaderAdapter() {
final UpdateChecker val$checker;
final Update val$update;
final PluginInterface val$pi_for_update;
final int val$restart_type;
final boolean val$is_jar;
final String val$version;
final boolean val$verify;
final PluginUpdatePlugin this$0;
public boolean completed(final ResourceDownloader downloader, InputStream data)
{
LoggerChannelListener list = new LoggerChannelListener() {
final ResourceDownloader val$downloader;
final 9 this$1;
public void messageLogged(int type, String content)
{
downloader.reportActivity(content);
}
public void messageLogged(String str, Throwable error)
{
downloader.reportActivity(str);
}
{
this$1 = 9.this;
downloader = resourcedownloader;
super();
}
};
boolean flag;
log.addListener(list);
installUpdate(checker, update, pi_for_update, restart_type == 1, is_jar, version, data, verify);
flag = true;
log.removeListener(list);
return flag;
Exception exception;
exception;
log.removeListener(list);
throw exception;
}
{
this$0 = PluginUpdatePlugin.this;
checker = updatechecker;
update = update1;
pi_for_update = plugininterface;
restart_type = i;
is_jar = flag;
version = s;
verify = flag1;
super();
}
});
return update;
}
protected void installUpdate(UpdateChecker checker, Update update, PluginInterface plugin, boolean unloadable, boolean is_jar, String version, InputStream data,
boolean verify)
{
String target_version;
UpdateInstaller installer;
log.log(1, (new StringBuilder()).append("Installing plugin '").append(update.getName()).append("', version ").append(version).toString());
target_version = version.endsWith("_CVS") ? version.substring(0, version.length() - 4) : version;
installer = null;
boolean update_txt_found;
File plugin_dir;
File user_dir;
File prog_dir;
boolean force_indirect_install;
File target_plugin_dir;
File target_prog_dir;
File target_user_dir;
File target_jar_zip;
ZipInputStream zis;
String common_prefix;
String selected_platform;
List selected_sub_platforms;
data = update.verifyData(data, verify);
log.log(" Data verification stage complete");
update_txt_found = false;
String plugin_dir_name = plugin.getPluginDirectoryName();
if (plugin_dir_name == null || plugin_dir_name.length() == 0)
{
log.log(1, " This is a built-in plugin, updating core");
CorePatchChecker.patchAzureus2(update.getCheckInstance(), data, (new StringBuilder()).append(plugin.getPluginID()).append("_").append(version).toString(), log);
update.setRestartRequired(2);
break MISSING_BLOCK_LABEL_3457;
}
plugin_dir = new File(plugin_dir_name);
user_dir = new File(plugin_interface.getUtilities().getAzureusUserDir());
prog_dir = new File(plugin_interface.getUtilities().getAzureusProgramDir());
force_indirect_install = false;
if (Constants.isWindowsVista)
{
File test_file = new File(plugin_dir, "_aztest45.dll");
boolean ok = false;
try
{
if (test_file.exists())
test_file.delete();
FileOutputStream os = new FileOutputStream(test_file);
os.write(32);
os.close();
ok = test_file.delete();
}
catch (Throwable e) { }
if (!ok)
{
log.log("Can't write directly to the plugin directroy, installing indirectly");
force_indirect_install = true;
}
}
if (force_indirect_install)
{
File temp_dir = AETemporaryFileHandler.createTempDir();
target_plugin_dir = new File(temp_dir, "plugin");
target_user_dir = new File(temp_dir, "user");
target_prog_dir = new File(temp_dir, "prog");
target_plugin_dir.mkdirs();
target_user_dir.mkdirs();
target_prog_dir.mkdirs();
installer = update.getCheckInstance().createInstaller();
update.setRestartRequired(2);
} else
{
target_plugin_dir = plugin_dir;
target_user_dir = user_dir;
target_prog_dir = prog_dir;
}
target_jar_zip = new File(target_plugin_dir, (new StringBuilder()).append(plugin.getPluginID()).append("_").append(target_version).append(is_jar ? ".jar" : ".zip").toString());
FileUtil.copyFile(data, new FileOutputStream(target_jar_zip));
if (is_jar)
break MISSING_BLOCK_LABEL_3245;
zis = new ZipInputStream(new BufferedInputStream(new FileInputStream(target_jar_zip)));
common_prefix = null;
selected_platform = null;
selected_sub_platforms = new ArrayList();
do
{
ZipEntry entry = zis.getNextEntry();
if (entry == null)
break;
String name = entry.getName();
if (!name.equals("azureus.sig") && !name.endsWith("/"))
{
if (common_prefix == null)
{
common_prefix = name;
} else
{
int len = 0;
for (int i = 0; i < Math.min(common_prefix.length(), name.length()) && common_prefix.charAt(i) == name.charAt(i); i++)
len++;
common_prefix = common_prefix.substring(0, len);
}
int plat_pos = name.indexOf("platform/");
if (plat_pos != -1)
{
plat_pos += 9;
int plat_end_pos = name.indexOf("/", plat_pos);
if (plat_end_pos != -1)
{
String platform = name.substring(plat_pos, plat_end_pos);
String sub_platform = null;
int sub_plat_pos = platform.indexOf("_");
if (sub_plat_pos != -1)
{
sub_platform = platform.substring(sub_plat_pos + 1);
platform = platform.substring(0, sub_plat_pos);
}
if (Constants.isWindows && platform.equalsIgnoreCase("windows") || Constants.isLinux && platform.equalsIgnoreCase("linux") || Constants.isUnix && platform.equalsIgnoreCase("unix") || Constants.isFreeBSD && platform.equalsIgnoreCase("freebsd") || Constants.isSolaris && platform.equalsIgnoreCase("solaris") || Constants.isOSX && platform.equalsIgnoreCase("osx"))
{
selected_platform = platform;
if (sub_platform != null && !selected_sub_platforms.contains(sub_platform))
selected_sub_platforms.add(sub_platform);
}
}
}
}
byte buffer[] = new byte[0x10000];
int len;
do
len = zis.read(buffer);
while (len > 0);
} while (true);
zis.close();
break MISSING_BLOCK_LABEL_930;
Exception exception;
exception;
zis.close();
throw exception;
if (selected_platform != null)
{
String options[] = new String[selected_sub_platforms.size()];
selected_sub_platforms.toArray(options);
if (options.length == 1)
{
selected_platform = (new StringBuilder()).append(selected_platform).append("_").append(options[0]).toString();
log.log(1, (new StringBuilder()).append("platform is '").append(selected_platform).append("'").toString());
} else
if (options.length > 1)
{
String selected_sub_platform = (String)update.getDecision(0, "Select Platform", "Multiple platform options exist for this plugin, please select required one", options);
if (selected_sub_platform == null)
throw new Exception("Valid sub-platform selection not selected");
selected_platform = (new StringBuilder()).append(selected_platform).append("_").append(selected_sub_platform).toString();
log.log(1, (new StringBuilder()).append("platform is '").append(selected_platform).append("'").toString());
}
}
if (common_prefix == null)
break MISSING_BLOCK_LABEL_3245;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -