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

📄 pluginupdateplugin.java

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

package org.gudy.azureus2.pluginsimpl.update;

import com.aelitis.azureus.core.versioncheck.VersionCheckClient;
import java.io.*;
import java.net.URL;
import java.util.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import org.gudy.azureus2.core3.html.HTMLUtils;
import org.gudy.azureus2.core3.internat.MessageText;
import org.gudy.azureus2.core3.util.*;
import org.gudy.azureus2.plugins.*;
import org.gudy.azureus2.plugins.installer.PluginInstaller;
import org.gudy.azureus2.plugins.installer.StandardPlugin;
import org.gudy.azureus2.plugins.logging.*;
import org.gudy.azureus2.plugins.ui.UIManager;
import org.gudy.azureus2.plugins.ui.components.*;
import org.gudy.azureus2.plugins.ui.model.BasicPluginConfigModel;
import org.gudy.azureus2.plugins.ui.model.BasicPluginViewModel;
import org.gudy.azureus2.plugins.update.*;
import org.gudy.azureus2.plugins.utils.Utilities;
import org.gudy.azureus2.plugins.utils.resourcedownloader.*;
import org.gudy.azureus2.pluginsimpl.PluginUtils;
import org.gudy.azureus2.pluginsimpl.update.sf.SFPluginDetails;
import org.gudy.azureus2.pluginsimpl.update.sf.SFPluginDetailsLoader;
import org.gudy.azureus2.pluginsimpl.update.sf.SFPluginDetailsLoaderFactory;
import org.gudy.azureus2.pluginsimpl.update.sf.SFPluginDetailsLoaderListener;
import org.gudy.azureus2.update.CorePatchChecker;

public class PluginUpdatePlugin
	implements Plugin
{

	private static final String PLUGIN_CONFIGSECTION_ID = "plugins.update";
	private static final String PLUGIN_RESOURCE_ID = "ConfigView.section.plugins.update";
	public static final int RD_SIZE_RETRIES = 3;
	public static final int RD_SIZE_TIMEOUT = 10000;
	private PluginInterface plugin_interface;
	private LoggerChannel log;
	private boolean loader_listener_added;
	private String last_id_info;

	public PluginUpdatePlugin()
	{
		last_id_info = "";
	}

	public void initialize(PluginInterface _plugin_interface)
	{
		plugin_interface = _plugin_interface;
		plugin_interface.getPluginProperties().setProperty("plugin.version", "1.0");
		plugin_interface.getPluginProperties().setProperty("plugin.name", "Plugin Updater");
		log = plugin_interface.getLogger().getChannel("Plugin Update");
		UIManager ui_manager = plugin_interface.getUIManager();
		final BasicPluginViewModel model = ui_manager.createBasicPluginViewModel("ConfigView.section.plugins.update");
		final PluginConfig plugin_config = plugin_interface.getPluginconfig();
		boolean enabled = plugin_config.getPluginBooleanParameter("enable.update", true);
		model.setConfigSectionID("plugins.update");
		model.getStatus().setText(enabled ? "Running" : "Optional checks disabled");
		model.getActivity().setVisible(false);
		model.getProgress().setVisible(false);
		log.addListener(new LoggerChannelListener() {

			final BasicPluginViewModel val$model;
			final PluginUpdatePlugin this$0;

			public void messageLogged(int type, String message)
			{
				model.getLogArea().appendText((new StringBuilder()).append(message).append("\n").toString());
			}

			public void messageLogged(String str, Throwable error)
			{
				model.getLogArea().appendText((new StringBuilder()).append(error.toString()).append("\n").toString());
			}

			
			{
				this$0 = PluginUpdatePlugin.this;
				model = basicpluginviewmodel;
				super();
			}
		});
		BasicPluginConfigModel config = ui_manager.createBasicPluginConfigModel("plugins", "plugins.update");
		config.addBooleanParameter2("enable.update", "Plugin.pluginupdate.enablecheck", true);
		plugin_interface.addEventListener(new PluginEventListener() {

			final PluginConfig val$plugin_config;
			final PluginUpdatePlugin this$0;

			public void handleEvent(PluginEvent ev)
			{
				if (ev.getType() == 7)
				{
					plugin_interface.removeEventListener(this);
					initComplete(plugin_config);
				}
			}

			
			{
				this$0 = PluginUpdatePlugin.this;
				plugin_config = pluginconfig;
				super();
			}
		});
	}

	protected void initComplete(final PluginConfig plugin_config)
	{
		UpdateManager update_manager = plugin_interface.getUpdateManager();
		update_manager.addListener(new UpdateManagerListener() {

			final PluginUpdatePlugin this$0;

			public void checkInstanceCreated(UpdateCheckInstance inst)
			{
				SFPluginDetailsLoaderFactory.getSingleton().reset();
			}

			
			{
				this$0 = PluginUpdatePlugin.this;
				super();
			}
		});
		final PluginManager plugin_manager = plugin_interface.getPluginManager();
		PluginInterface plugins[] = plugin_manager.getPlugins();
		int mandatory_count = 0;
		int non_mandatory_count = 0;
		for (int i = 0; i < plugins.length; i++)
		{
			PluginInterface pi = plugins[i];
			boolean pi_mandatory = pi.getPluginState().isMandatory();
			if (pi_mandatory)
				mandatory_count++;
			else
				non_mandatory_count++;
		}

		final int f_non_mandatory_count = non_mandatory_count;
		final int f_mandatory_count = mandatory_count;
		update_manager.registerUpdatableComponent(new UpdatableComponent() {

			final int val$f_non_mandatory_count;
			final PluginManager val$plugin_manager;
			final PluginConfig val$plugin_config;
			final PluginUpdatePlugin this$0;

			public String getName()
			{
				return "Non-mandatory plugins";
			}

			public int getMaximumCheckTime()
			{
				return f_non_mandatory_count * 30;
			}

			public void checkForUpdate(UpdateChecker checker)
			{
				if (checkForUpdateSupport(checker, null, false) == 0)
				{
					String rps[] = VersionCheckClient.getSingleton().getRecommendedPlugins();
					boolean found_one = false;
					for (int i = 0; i < rps.length; i++)
					{
						String rp_id = rps[i];
						if (plugin_manager.getPluginInterfaceByID(rp_id, false) != null)
							continue;
						final String config_key = (new StringBuilder()).append("recommended.processed.").append(rp_id).toString();
						if (!plugin_config.getPluginBooleanParameter(config_key, false))
							try
							{
								final PluginInstaller installer = plugin_interface.getPluginManager().getPluginInstaller();
								StandardPlugin sps[] = installer.getStandardPlugins();
								int j = 0;
								do
								{
									if (j >= sps.length)
										break;
									final StandardPlugin sp = sps[j];
									if (sp.getId().equals(rp_id))
									{
										found_one = true;
										checker.getCheckInstance().addListener(new UpdateCheckInstanceListener() {

											final PluginInstaller val$installer;
											final StandardPlugin val$sp;
											final String val$config_key;
											final 4 this$1;

											public void cancelled(UpdateCheckInstance updatecheckinstance)
											{
											}

											public void complete(UpdateCheckInstance instance)
											{
												if (instance.getUpdates().length == 0)
												{
													installRecommendedPlugin(installer, sp);
													plugin_config.setPluginParameter(config_key, true);
												}
											}

					
					{
						this$1 = 4.this;
						installer = plugininstaller;
						sp = standardplugin;
						config_key = s;
						super();
					}
										});
										break;
									}
									j++;
								} while (true);
							}
							catch (Throwable e) { }
						if (found_one)
							break;
					}

				}
			}

			
			{
				this$0 = PluginUpdatePlugin.this;
				f_non_mandatory_count = i;
				plugin_manager = pluginmanager;
				plugin_config = pluginconfig;
				super();
			}
		}, false);
		update_manager.registerUpdatableComponent(new UpdatableComponent() {

			final int val$f_mandatory_count;
			final PluginUpdatePlugin this$0;

			public String getName()
			{
				return "Mandatory plugins";
			}

			public int getMaximumCheckTime()
			{
				return f_mandatory_count * 30;
			}

			public void checkForUpdate(UpdateChecker checker)
			{
				checkForUpdateSupport(checker, null, true);
			}

			
			{
				this$0 = PluginUpdatePlugin.this;
				f_mandatory_count = i;
				super();
			}
		}, true);
		update_manager.addListener(new UpdateManagerListener() {

			final PluginUpdatePlugin this$0;

			public void checkInstanceCreated(UpdateCheckInstance instance)
			{
				log.log(1, "**** Update check starts ****");
			}

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

	protected void installRecommendedPlugin(PluginInstaller installer, StandardPlugin plugin)
	{
		try
		{
			installer.requestInstall(MessageText.getString("plugin.installer.recommended.plugin"), plugin);
		}
		catch (Throwable e)
		{
			log.log(e);
		}
	}

	public UpdatableComponent getCustomUpdateableComponent(final String id, final boolean mandatory)
	{
		return new UpdatableComponent() {

			final String val$id;
			final boolean val$mandatory;
			final PluginUpdatePlugin this$0;

			public String getName()
			{
				return (new StringBuilder()).append("Installation of '").append(id).append("'").toString();
			}

			public int getMaximumCheckTime()
			{
				return 30;
			}

			public void checkForUpdate(UpdateChecker checker)
			{
				checkForUpdateSupport(checker, new String[] {
					id
				}, mandatory);
			}

			
			{
				this$0 = PluginUpdatePlugin.this;
				id = s;
				mandatory = flag;
				super();
			}
		};
	}

	protected int checkForUpdateSupport(UpdateChecker checker, String ids_to_check[], boolean mandatory)
	{
		int num_updates_found = 0;
		int k;
		if (mandatory || ids_to_check != null || plugin_interface.getPluginconfig().getPluginBooleanParameter("enable.update", true))
			break MISSING_BLOCK_LABEL_44;
		k = num_updates_found;
		checker.completed();
		return k;
		PluginInterface plugins[];
		List plugins_to_check;
		Map plugins_to_check_names;
		SFPluginDetailsLoader loader;
		String ids[];
		int i;
		plugins = plugin_interface.getPluginManager().getPlugins();
		plugins_to_check = new ArrayList();
		List plugins_to_check_ids = new ArrayList();
		plugins_to_check_names = new HashMap();
		for (int i = 0; i < plugins.length; i++)
		{
			PluginInterface pi = plugins[i];
			if (pi.getPluginState().isDisabled() && !pi.getPluginState().hasFailed())
				continue;
			String mand = pi.getPluginProperties().getProperty("plugin.mandatory");
			boolean pi_mandatory = mand != null && mand.trim().toLowerCase().equals("true");
			if (pi_mandatory != mandatory)
				continue;
			String id = pi.getPluginID();
			String version = pi.getPluginVersion();
			String name = pi.getPluginName();
			if (ids_to_check != null)
			{
				boolean id_selected = false;
				int j = 0;
				do
				{
					if (j >= ids_to_check.length)
						break;
					if (ids_to_check[j].equals(id))
					{
						id_selected = true;
						break;
					}
					j++;
				} while (true);
				if (!id_selected)
					continue;
			}
			if (version != null)
				if (plugins_to_check_ids.contains(id))
				{
					String s = (String)plugins_to_check_names.get(id);
					if (!name.equals(id))
						plugins_to_check_names.put(id, (new StringBuilder()).append(s).append(",").append(name).toString());
				} else
				{
					plugins_to_check_ids.add(id);
					plugins_to_check.add(pi);
					plugins_to_check_names.put(id, name.equals(id) ? "" : ((Object) (name)));
				}
			String location = pi.getPluginDirectoryName();
			log.log(1, (new StringBuilder()).append(mandatory ? "*" : "-").append(pi.getPluginName()).append(", id = ").append(id).append(version != null ? (new StringBuilder()).append(", version = ").append(pi.getPluginVersion()).toString() : "").append(location != null ? (new StringBuilder()).append(", loc = ").append(location).toString() : "").toString());
		}

		loader = SFPluginDetailsLoaderFactory.getSingleton();
		if (!loader_listener_added)
		{

⌨️ 快捷键说明

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