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

📄 plugininstallerimpl.java

📁 java 文件下载器。可自定义
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
// 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:   PluginInstallerImpl.java

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

import com.aelitis.azureus.core.vuzefile.*;
import java.io.*;
import java.util.*;
import org.gudy.azureus2.core3.internat.MessageText;
import org.gudy.azureus2.core3.logging.LogAlert;
import org.gudy.azureus2.core3.logging.Logger;
import org.gudy.azureus2.core3.util.*;
import org.gudy.azureus2.plugins.*;
import org.gudy.azureus2.plugins.installer.*;
import org.gudy.azureus2.plugins.ui.UIManager;
import org.gudy.azureus2.plugins.update.*;
import org.gudy.azureus2.plugins.utils.StaticUtilities;
import org.gudy.azureus2.plugins.utils.Utilities;
import org.gudy.azureus2.plugins.utils.resourcedownloader.*;
import org.gudy.azureus2.pluginsimpl.local.FailedPlugin;
import org.gudy.azureus2.pluginsimpl.local.update.UpdateCheckInstanceImpl;
import org.gudy.azureus2.pluginsimpl.local.update.UpdateManagerImpl;
import org.gudy.azureus2.pluginsimpl.update.PluginUpdatePlugin;
import org.gudy.azureus2.pluginsimpl.update.sf.*;

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

public class PluginInstallerImpl
	implements PluginInstaller
{

	protected static PluginInstallerImpl singleton;
	private PluginManager manager;
	private List listeners;
	private AsyncDispatcher add_file_install_dispatcher;

	public static PluginInstallerImpl getSingleton(PluginManager _manager)
	{
		if (singleton == null)
			singleton = new PluginInstallerImpl(_manager);
		return singleton;
	}

	protected PluginInstallerImpl(PluginManager _manager)
	{
		listeners = new ArrayList();
		manager = _manager;
		VuzeFileHandler.getSingleton().addProcessor(new VuzeFileProcessor() {

			final PluginInstallerImpl this$0;

			public void process(VuzeFile files[], int expected_types)
			{
				for (int i = 0; i < files.length; i++)
				{
					VuzeFile vf = files[i];
					VuzeFileComponent comps[] = vf.getComponents();
					for (int j = 0; j < comps.length; j++)
					{
						VuzeFileComponent comp = comps[j];
						if (comp.getType() != 8)
							continue;
						try
						{
							Map content = comp.getContent();
							String id = new String((byte[])(byte[])content.get("id"), "UTF-8");
							String version = new String((byte[])(byte[])content.get("version"), "UTF-8");
							String suffix = ((Long)content.get("is_jar")).longValue() != 1L ? "zip" : "jar";
							byte plugin_file[] = (byte[])(byte[])content.get("file");
							File temp_dir = AETemporaryFileHandler.createTempDir();
							File temp_file = new File(temp_dir, (new StringBuilder()).append(id).append("_").append(version).append(".").append(suffix).toString());
							FileUtil.copyFile(new ByteArrayInputStream(plugin_file), temp_file);
							FilePluginInstaller installer = installFromFile(temp_file);
							addFileInstallOperation(installer);
							comp.setProcessed();
						}
						catch (Throwable e)
						{
							Debug.printStackTrace(e);
						}
					}

				}

			}

			
			{
				this$0 = PluginInstallerImpl.this;
				super();
			}
		});
	}

	protected void addFileInstallOperation(final FilePluginInstaller installer)
	{
		synchronized (this)
		{
			if (add_file_install_dispatcher == null)
				add_file_install_dispatcher = new AsyncDispatcher();
			add_file_install_dispatcher.dispatch(new AERunnable() {

				final FilePluginInstaller val$installer;
				final PluginInstallerImpl this$0;

				public void runSupport()
				{
					try
					{
						AESemaphore done_sem = new AESemaphore("PluginInstall:fio");
						UIManager ui_manager = StaticUtilities.getUIManager(0x1d4c0L);
						(new AEThread2(ui_manager, done_sem) {

							final UIManager val$ui_manager;
							final AESemaphore val$done_sem;
							final 2 this$1;

							public void run()
							{
								if (installer.isAlreadyInstalled())
								{
									String details = MessageText.getString("fileplugininstall.duplicate.desc", new String[] {
										installer.getName(), installer.getVersion()
									});
									ui_manager.showMessageBox("fileplugininstall.duplicate.title", (new StringBuilder()).append("!").append(details).append("!").toString(), 1L);
									done_sem.release();
								} else
								{
									String details = MessageText.getString("fileplugininstall.install.desc", new String[] {
										installer.getName(), installer.getVersion()
									});
									long res = ui_manager.showMessageBox("fileplugininstall.install.title", (new StringBuilder()).append("!").append(details).append("!").toString(), 12L);
									if (res == 4L)
										try
										{
											install(new InstallablePlugin[] {
												installer
											}, false, true, null, new PluginInstallationListener() {

												final 1 this$2;

												public void completed()
												{
													done_sem.release();
												}

												public void cancelled()
												{
													done_sem.release();
												}

												public void failed(PluginException e)
												{
													done_sem.release();
													Debug.out("Installation failed", e);
												}

						
						{
							this$2 = 1.this;
							super();
						}
											});
										}
										catch (Throwable e)
										{
											Debug.printStackTrace(e);
											done_sem.release();
										}
									else
									if (res == 8L)
									{
										done_sem.release();
									} else
									{
										Debug.out("Message box not handled");
										done_sem.release();
									}
								}
							}

					
					{
						this$1 = 2.this;
						ui_manager = uimanager;
						done_sem = aesemaphore;
						super(x0, x1);
					}
						}).start();
						do
						{
							if (done_sem.reserve(60000L))
								break;
							if (add_file_install_dispatcher.getQueueSize() > 0)
								Debug.out("File plugin install operation queued pending completion of previous");
						} while (true);
					}
					catch (Throwable e)
					{
						Debug.printStackTrace(e);
					}
				}

			
			{
				this$0 = PluginInstallerImpl.this;
				installer = fileplugininstaller;
				super();
			}
			});
		}
	}

	protected PluginManager getPluginManager()
	{
		return manager;
	}

	public StandardPlugin[] getStandardPlugins()
		throws PluginException
	{
		StandardPlugin res_a[];
		SFPluginDetailsLoader loader = SFPluginDetailsLoaderFactory.getSingleton();
		SFPluginDetails details[] = loader.getPluginDetails();
		List res = new ArrayList();
		for (int i = 0; i < details.length; i++)
		{
			SFPluginDetails detail = details[i];
			String name = detail.getId();
			String version = "";
			if (Constants.isCVSVersion())
				version = detail.getCVSVersion();
			if (version == null || version.length() == 0 || !Character.isDigit(version.charAt(0)))
			{
				version = detail.getVersion();
			} else
			{
				String non_cvs_version = detail.getVersion();
				if (version.equals((new StringBuilder()).append(non_cvs_version).append("_CVS").toString()))
					version = non_cvs_version;
			}
			if (!name.startsWith("azplatform") && !name.equals("azupdater") && version != null && version.length() != 0 && Character.isDigit(version.charAt(0)) && !detail.getCategory().equalsIgnoreCase("hidden"))
				res.add(new StandardPluginImpl(this, details[i], version));
		}

		res_a = new StandardPlugin[res.size()];
		res.toArray(res_a);
		return res_a;
		SFPluginDetailsException e;
		e;
		throw new PluginException("Failed to load standard plugin details", e);
	}

	public StandardPlugin getStandardPlugin(String id)
		throws PluginException
	{
		SFPluginDetails details[];
		int i;
		SFPluginDetailsLoader loader = SFPluginDetailsLoaderFactory.getSingleton();
		details = loader.getPluginDetails();
		i = 0;
_L1:
		String name;
		String version;
		if (i >= details.length)
			break MISSING_BLOCK_LABEL_214;
		SFPluginDetails detail = details[i];
		name = detail.getId();
		if (!name.equals(id))
			break MISSING_BLOCK_LABEL_208;
		version = "";
		if (Constants.isCVSVersion())
			version = detail.getCVSVersion();
		if (version == null || version.length() == 0 || !Character.isDigit(version.charAt(0)))
		{
			version = detail.getVersion();
		} else
		{
			String non_cvs_version = detail.getVersion();
			if (version.equals((new StringBuilder()).append(non_cvs_version).append("_CVS").toString()))
				version = non_cvs_version;
		}
		if (!name.startsWith("azplatform") && !name.equals("azupdater") && version != null && version.length() != 0 && Character.isDigit(version.charAt(0)))
			return new StandardPluginImpl(this, details[i], version);
		i++;
		  goto _L1
		return null;
		SFPluginDetailsException e;
		e;
		throw new PluginException("Failed to load standard plugin details", e);
	}

	public FilePluginInstaller installFromFile(File file)
		throws PluginException
	{
		return new FilePluginInstallerImpl(this, file);
	}

	public void install(InstallablePlugin installable_plugin, boolean shared)
		throws PluginException
	{
		install(new InstallablePlugin[] {
			installable_plugin
		}, shared);
	}

	public void install(InstallablePlugin plugins[], boolean shared)
		throws PluginException
	{
		install(plugins, shared, false, null, null);
	}

	public void install(InstallablePlugin plugins[], boolean shared, Map properties, PluginInstallationListener listener)
		throws PluginException
	{
		install(plugins, shared, false, properties, listener);
	}

	protected void install(InstallablePlugin plugins[], boolean shared, boolean low_noise, Map properties, final PluginInstallationListener listener)
		throws PluginException
	{
		PluginUpdatePlugin pup = (PluginUpdatePlugin)manager.getPluginInterfaceByClass(org/gudy/azureus2/pluginsimpl/update/PluginUpdatePlugin).getPlugin();
		UpdateManagerImpl uman = (UpdateManagerImpl)manager.getDefaultPluginInterface().getUpdateManager();
		UpdateCheckInstanceImpl inst = uman.createEmptyUpdateCheckInstance(1, "update.instance.install", low_noise);
		if (properties != null)
		{
			java.util.Map.Entry entry;
			for (Iterator i$ = properties.entrySet().iterator(); i$.hasNext(); inst.setProperty(((Integer)entry.getKey()).intValue(), entry.getValue()))
				entry = (java.util.Map.Entry)i$.next();

		}
		if (listener != null)
			inst.addListener(new UpdateCheckInstanceListener() {

⌨️ 快捷键说明

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