⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fileplugininstallerimpl.java

📁 java 文件下载器。可自定义
💻 JAVA
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   FilePluginInstallerImpl.java

package org.gudy.azureus2.pluginsimpl.local.installer;

import java.io.*;
import java.util.Properties;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import org.gudy.azureus2.core3.util.Debug;
import org.gudy.azureus2.plugins.*;
import org.gudy.azureus2.plugins.installer.FilePluginInstaller;
import org.gudy.azureus2.plugins.update.*;
import org.gudy.azureus2.plugins.utils.Utilities;
import org.gudy.azureus2.plugins.utils.resourcedownloader.ResourceDownloaderFactory;
import org.gudy.azureus2.pluginsimpl.local.PluginInitializer;
import org.gudy.azureus2.pluginsimpl.update.PluginUpdatePlugin;
import org.gudy.azureus2.pluginsimpl.update.sf.SFPluginDetailsLoader;
import org.gudy.azureus2.pluginsimpl.update.sf.SFPluginDetailsLoaderFactory;

// Referenced classes of package org.gudy.azureus2.pluginsimpl.local.installer:
//			InstallablePluginImpl, PluginInstallerImpl

public class FilePluginInstallerImpl extends InstallablePluginImpl
	implements FilePluginInstaller
{

	protected PluginInstallerImpl installer;
	protected File file;
	protected String id;
	protected String version;
	protected String name;
	protected boolean is_jar;

	protected FilePluginInstallerImpl(PluginInstallerImpl _installer, File _file)
		throws PluginException
	{
		boolean ok;
		String prefix;
		Properties properties;
		ZipInputStream zis;
		super(_installer);
		installer = _installer;
		file = _file;
		String name = file.getName();
		int pos = name.lastIndexOf(".");
		ok = false;
		if (pos == -1)
			break MISSING_BLOCK_LABEL_963;
		prefix = name.substring(0, pos);
		String suffix = name.substring(pos + 1);
		if (prefix.lastIndexOf("_src") != -1)
			if (prefix.endsWith("_src"))
			{
				prefix = prefix.substring(0, prefix.length() - 4);
			} else
			{
				int src_bit_pos = prefix.lastIndexOf("_src");
				prefix = (new StringBuilder()).append(prefix.substring(0, src_bit_pos)).append(prefix.substring(src_bit_pos + 1)).toString();
			}
		if (!suffix.toLowerCase().equals("jar") && !suffix.toLowerCase().equals("zip"))
			break MISSING_BLOCK_LABEL_963;
		is_jar = suffix.toLowerCase().equals("jar");
		properties = null;
		zis = null;
		zis = new ZipInputStream(new BufferedInputStream(new FileInputStream(file)));
_L2:
		ZipInputStream zis2;
		String zip_name;
label0:
		do
			do
			{
				if (properties != null)
					break MISSING_BLOCK_LABEL_367;
				ZipEntry entry = zis.getNextEntry();
				if (entry == null)
					break MISSING_BLOCK_LABEL_367;
				zip_name = entry.getName().toLowerCase();
				if (!zip_name.equals("plugin.properties") && !zip_name.endsWith("/plugin.properties"))
					continue label0;
				properties = new Properties();
				properties.load(zis);
			} while (true);
		while (!zip_name.endsWith(".jar"));
		zis2 = new ZipInputStream(zis);
_L4:
		if (properties != null) goto _L2; else goto _L1
_L1:
		ZipEntry entry2 = zis2.getNextEntry();
		if (entry2 != null) goto _L3; else goto _L2
_L3:
		String zip_name2 = entry2.getName().toLowerCase();
		if (zip_name2.equals("plugin.properties"))
		{
			properties = new Properties();
			properties.load(zis2);
		}
		  goto _L4
		Throwable e;
		if (zis != null)
			try
			{
				zis.close();
			}
			// Misplaced declaration of an exception variable
			catch (Throwable e)
			{
				Debug.printStackTrace(e);
			}
		break MISSING_BLOCK_LABEL_429;
		e;
		throw new PluginException("Failed to read plugin file", e);
		Exception exception;
		exception;
		if (zis != null)
			try
			{
				zis.close();
			}
			catch (Throwable e)
			{
				Debug.printStackTrace(e);
			}
		throw exception;
		int pos = prefix.lastIndexOf("_");
		String filename_id = null;
		String filename_version = null;
		if (pos != -1)
		{
			filename_id = prefix.substring(0, pos);
			filename_version = prefix.substring(pos + 1);
		}
		if (properties == null)
		{
			if (filename_id != null)
			{
				id = filename_id;
				version = filename_version;
				PluginInterface pi = installer.getPluginManager().getPluginInterfaceByID(id);
				ok = pi != null && (pi.getPluginDirectoryName() == null || pi.getPluginDirectoryName().length() == 0);
			}
			if (!ok)
				throw new PluginException("Mandatory file 'plugin.properties' not found in plugin file");
		} else
		{
			PluginInitializer.checkJDKVersion("", properties, false);
			PluginInitializer.checkAzureusVersion("", properties, false);
			id = properties.getProperty("plugin.id");
			version = properties.getProperty("plugin.version");
			String prop_version = version;
			if (prop_version != null && filename_version != null && !filename_version.equals(prop_version))
				throw new PluginException((new StringBuilder()).append("inconsistent versions [file=").append(filename_version).append(", prop=").append(prop_version).append("]").toString());
		}
		if (id == null)
		{
			String plugin_class = properties.getProperty("plugin.class");
			if (plugin_class == null)
			{
				String plugin_classes = properties.getProperty("plugin.classes");
				if (plugin_classes != null)
				{
					int semi_pos = plugin_classes.indexOf(";");
					if (semi_pos == -1)
						plugin_class = plugin_classes;
					else
						plugin_class = plugin_classes.substring(0, semi_pos);
				}
			}
			if (plugin_class != null)
				try
				{
					PluginInterface pi = installer.getPluginManager().getPluginInterfaceByClass(plugin_class);
					if (pi != null)
						id = pi.getPluginID();
				}
				catch (Throwable ignore) { }
		}
		pos = prefix.lastIndexOf("_");
		if (pos != -1)
		{
			id = id != null ? id : prefix.substring(0, pos);
			try
			{
				SFPluginDetailsLoader loader = SFPluginDetailsLoaderFactory.getSingleton();
				String ids[] = loader.getPluginIDs();
				int i = 0;
				do
				{
					if (i >= ids.length)
						break;
					if (ids[i].equalsIgnoreCase(id))
					{
						id = ids[i];
						break;
					}
					i++;
				} while (true);
			}
			catch (Throwable e)
			{
				Debug.printStackTrace(e);
			}
			version = version != null ? version : prefix.substring(pos + 1);
		}
		this.name = id;
		if (properties != null)
		{
			String plugin_name = properties.getProperty("plugin.name");
			if (plugin_name != null)
				this.name = plugin_name;
		}
		ok = id != null && version != null;
		if (!ok)
			throw new PluginException("Invalid plugin file name: must be of form <pluginid>_<version>.[jar|zip]");
		else
			return;
	}

	public File getFile()
	{
		return file;
	}

	public String getId()
	{
		return id;
	}

	public String getVersion()
	{
		return version;
	}

	public String getName()
	{
		return name;
	}

	public String getDescription()
	{
		return file.toString();
	}

	public String getRelativeURLBase()
	{
		return "";
	}

	public void addUpdate(UpdateCheckInstance inst, final PluginUpdatePlugin plugin_update_plugin, Plugin plugin, final PluginInterface plugin_interface)
	{
		inst.addUpdatableComponent(new UpdatableComponent() {

			final PluginInterface val$plugin_interface;
			final PluginUpdatePlugin val$plugin_update_plugin;
			final FilePluginInstallerImpl this$0;

			public String getName()
			{
				return name;
			}

			public int getMaximumCheckTime()
			{
				return 0;
			}

			public void checkForUpdate(UpdateChecker checker)
			{
				org.gudy.azureus2.plugins.utils.resourcedownloader.ResourceDownloader rd = plugin_interface.getUtilities().getResourceDownloaderFactory().create(file);
				plugin_update_plugin.addUpdate(plugin_interface, checker, getName(), new String[] {
					(new StringBuilder()).append("Installation from file: ").append(file.toString()).toString()
				}, version, rd, is_jar, plugin_interface.getPluginState().isUnloadable() ? 1 : 2, false);
				checker.completed();
				break MISSING_BLOCK_LABEL_135;
				Exception exception;
				exception;
				checker.completed();
				throw exception;
			}

			
			{
				this$0 = FilePluginInstallerImpl.this;
				plugin_interface = plugininterface;
				plugin_update_plugin = pluginupdateplugin;
				super();
			}
		}, false);
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -