📄 plugininstallerimpl.java
字号:
final PluginInstallationListener val$listener;
final PluginInstallerImpl this$0;
public void cancelled(UpdateCheckInstance instance)
{
listener.cancelled();
}
public void complete(UpdateCheckInstance instance)
{
final Update updates[] = instance.getUpdates();
if (updates.length == 0)
{
listener.failed(new PluginException("No updates were added during check process"));
} else
{
for (int i = 0; i < updates.length; i++)
updates[i].addListener(new UpdateListener() {
private boolean cancelled;
final Update val$updates[];
final 3 this$1;
public void cancelled(Update update)
{
cancelled = true;
check();
}
public void complete(Update update)
{
check();
}
protected void check()
{
for (int i = 0; i < updates.length; i++)
if (!updates[i].isCancelled() && !updates[i].isComplete())
return;
if (cancelled)
listener.cancelled();
else
listener.completed();
}
{
this$1 = 3.this;
updates = aupdate;
super();
}
});
}
}
{
this$0 = PluginInstallerImpl.this;
listener = plugininstallationlistener;
super();
}
});
try
{
for (int i = 0; i < plugins.length; i++)
{
InstallablePlugin plugin = plugins[i];
final String plugin_id = plugin.getId();
PluginInterface existing_plugin_interface = manager.getPluginInterfaceByID(plugin_id, false);
org.gudy.azureus2.plugins.Plugin existing_plugin = null;
if (existing_plugin_interface != null)
{
existing_plugin = existing_plugin_interface.getPlugin();
String old_version = existing_plugin_interface.getPluginVersion();
if (old_version != null)
{
int res = Constants.compareVersions(plugin.getVersion(), old_version);
if (res < 0)
throw new PluginException((new StringBuilder()).append("A higher version (").append(old_version).append(") of Plugin '").append(plugin_id).append("' is already installed").toString());
if (res == 0)
throw new PluginException((new StringBuilder()).append("Version (").append(old_version).append(") of Plugin '").append(plugin_id).append("' is already installed").toString());
}
}
String target_dir;
if (shared)
target_dir = FileUtil.getApplicationFile("plugins").toString();
else
target_dir = FileUtil.getUserFile("plugins").toString();
target_dir = (new StringBuilder()).append(target_dir).append(File.separator).append(plugin_id).toString();
(new File(target_dir)).mkdir();
if (existing_plugin == null)
{
FailedPlugin dummy_plugin = new FailedPlugin(plugin_id, target_dir);
PluginManager.registerPlugin(dummy_plugin, plugin_id);
final PluginInterface dummy_plugin_interface = manager.getPluginInterfaceByID(plugin_id, false);
((InstallablePluginImpl)plugin).addUpdate(inst, pup, dummy_plugin, dummy_plugin_interface);
inst.addListener(new UpdateCheckInstanceListener() {
final PluginInterface val$dummy_plugin_interface;
final String val$plugin_id;
final PluginInstallerImpl this$0;
public void cancelled(UpdateCheckInstance instance)
{
try
{
dummy_plugin_interface.getPluginState().unload();
}
catch (Throwable e)
{
Debug.out("Failed to unload plugin", e);
}
}
public void complete(UpdateCheckInstance instance)
{
PluginInterface pi = manager.getPluginInterfaceByID(plugin_id, false);
if (pi != null && (pi.getPlugin() instanceof FailedPlugin))
try
{
pi.getPluginState().unload();
}
catch (Throwable e)
{
Debug.out("Failed to unload plugin", e);
}
}
{
this$0 = PluginInstallerImpl.this;
dummy_plugin_interface = plugininterface;
plugin_id = s;
super();
}
});
} else
{
((InstallablePluginImpl)plugin).addUpdate(inst, pup, existing_plugin, existing_plugin_interface);
}
}
inst.start();
}
catch (Throwable e)
{
inst.cancel();
if (e instanceof PluginException)
throw (PluginException)e;
else
throw new PluginException("Failed to create installer", e);
}
}
public void uninstall(InstallablePlugin standard_plugin)
throws PluginException
{
PluginInterface pi = standard_plugin.getAlreadyInstalledPlugin();
if (pi == null)
{
throw new PluginException((new StringBuilder()).append(" Plugin '").append(standard_plugin.getId()).append("' is not installed").toString());
} else
{
pi.getPluginState().uninstall();
return;
}
}
public void uninstall(PluginInterface pi)
throws PluginException
{
uninstall(new PluginInterface[] {
pi
});
}
public void uninstall(PluginInterface pis[])
throws PluginException
{
for (int i = 0; i < pis.length; i++)
{
PluginInterface pi = pis[i];
if (pi.getPluginState().isMandatory())
throw new PluginException((new StringBuilder()).append("Plugin '").append(pi.getPluginID()).append("' is mandatory, can't uninstall").toString());
if (pi.getPluginState().isBuiltIn())
throw new PluginException((new StringBuilder()).append("Plugin '").append(pi.getPluginID()).append("' is built-in, can't uninstall").toString());
String plugin_dir = pi.getPluginDirectoryName();
if (plugin_dir == null || !(new File(plugin_dir)).exists())
throw new PluginException((new StringBuilder()).append("Plugin '").append(pi.getPluginID()).append("' is not loaded from the file system, can't uninstall").toString());
}
try
{
UpdateManager uman = manager.getDefaultPluginInterface().getUpdateManager();
UpdateCheckInstance inst = uman.createEmptyUpdateCheckInstance(3, "update.instance.uninstall");
for (int i = 0; i < pis.length; i++)
{
final PluginInterface pi = pis[i];
final String plugin_dir = pi.getPluginDirectoryName();
inst.addUpdatableComponent(new UpdatableComponent() {
final PluginInterface val$pi;
final String val$plugin_dir;
final PluginInstallerImpl this$0;
public String getName()
{
return pi.getPluginName();
}
public int getMaximumCheckTime()
{
return 0;
}
public void checkForUpdate(final UpdateChecker checker)
{
ResourceDownloader rd = manager.getDefaultPluginInterface().getUtilities().getResourceDownloaderFactory().create(new File(plugin_dir));
rd.addListener(new ResourceDownloaderAdapter() {
final UpdateChecker val$checker;
final 5 this$1;
public boolean completed(ResourceDownloader downloader, InputStream data)
{
try
{
if (pi.getPluginState().isUnloadable())
{
pi.getPluginState().unload();
FileUtil.recursiveDelete(new File(plugin_dir));
}
UpdateInstaller installer = checker.createInstaller();
installer.addRemoveAction((new File(plugin_dir)).getCanonicalPath());
}
catch (Throwable e)
{
Debug.printStackTrace(e);
Logger.log(new LogAlert(true, "Plugin uninstall failed", e));
}
return true;
}
public void failed(ResourceDownloader downloader, ResourceDownloaderException e)
{
if (!downloader.isCancelled())
Logger.log(new LogAlert(true, "Plugin uninstall failed", e));
}
{
this$1 = 5.this;
checker = updatechecker;
super();
}
});
String update_name = "";
PluginInterface ifs[] = manager.getPluginInterfaces();
Arrays.sort(ifs, new Comparator() {
final 5 this$1;
public int compare(Object o1, Object o2)
{
return ((PluginInterface)o1).getPluginName().compareTo(((PluginInterface)o2).getPluginName());
}
{
this$1 = 5.this;
super();
}
});
for (int i = 0; i < ifs.length; i++)
if (ifs[i].getPluginID().equals(pi.getPluginID()))
update_name = (new StringBuilder()).append(update_name).append(update_name.length() != 0 ? "," : "").append(ifs[i].getPluginName()).toString();
checker.addUpdate(update_name, new String[] {
(new StringBuilder()).append("Uninstall: ").append(plugin_dir).toString()
}, pi.getPluginVersion(), rd, pi.getPluginState().isUnloadable() ? 1 : 2);
checker.completed();
break MISSING_BLOCK_LABEL_256;
Exception exception;
exception;
checker.completed();
throw exception;
}
{
this$0 = PluginInstallerImpl.this;
pi = plugininterface;
plugin_dir = s;
super();
}
}, false);
}
inst.start();
}
catch (Throwable e)
{
Debug.printStackTrace(e);
}
}
protected PluginInterface getAlreadyInstalledPlugin(String id)
{
return getPluginManager().getPluginInterfaceByID(id, false);
}
public void requestInstall(String reason, InstallablePlugin plugin)
throws PluginException
{
for (int i = 0; i < listeners.size(); i++)
if (((PluginInstallerListener)listeners.get(i)).installRequest(reason, plugin))
return;
throw new PluginException((new StringBuilder()).append("No listeners registered to perform installation of '").append(plugin.getName()).append(" (").append(reason).append(")").toString());
}
public void addListener(PluginInstallerListener l)
{
listeners.add(l);
}
public void removeListener(PluginInstallerListener l)
{
listeners.remove(l);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -