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

📄 corepatchchecker.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:   CorePatchChecker.java

package org.gudy.azureus2.update;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Properties;
import org.gudy.azureus2.core3.logging.LogAlert;
import org.gudy.azureus2.core3.logging.LogEvent;
import org.gudy.azureus2.core3.logging.LogIDs;
import org.gudy.azureus2.core3.logging.Logger;
import org.gudy.azureus2.core3.util.AETemporaryFileHandler;
import org.gudy.azureus2.core3.util.Constants;
import org.gudy.azureus2.core3.util.Debug;
import org.gudy.azureus2.core3.util.SystemProperties;
import org.gudy.azureus2.plugins.Plugin;
import org.gudy.azureus2.plugins.PluginException;
import org.gudy.azureus2.plugins.PluginInterface;
import org.gudy.azureus2.plugins.PluginManager;
import org.gudy.azureus2.plugins.logging.LoggerChannel;
import org.gudy.azureus2.plugins.update.UpdatableComponent;
import org.gudy.azureus2.plugins.update.Update;
import org.gudy.azureus2.plugins.update.UpdateCheckInstance;
import org.gudy.azureus2.plugins.update.UpdateCheckInstanceListener;
import org.gudy.azureus2.plugins.update.UpdateChecker;
import org.gudy.azureus2.plugins.update.UpdateInstaller;
import org.gudy.azureus2.plugins.update.UpdateListener;
import org.gudy.azureus2.plugins.update.UpdateManager;
import org.gudy.azureus2.plugins.utils.resourcedownloader.ResourceDownloader;

// Referenced classes of package org.gudy.azureus2.update:
//			CorePatchLevel, UpdateJarPatcher, UpdaterUpdateChecker

public class CorePatchChecker
	implements Plugin, UpdatableComponent, UpdateCheckInstanceListener
{

	private static final LogIDs LOGID;
	public static final boolean TESTING = false;
	protected PluginInterface plugin_interface;

	public CorePatchChecker()
	{
	}

	public void initialize(PluginInterface _plugin_interface)
		throws PluginException
	{
		plugin_interface = _plugin_interface;
		plugin_interface.getPluginProperties().setProperty("plugin.version", "1.0");
		plugin_interface.getPluginProperties().setProperty("plugin.name", (new StringBuilder()).append("Core Patcher (level=").append(CorePatchLevel.getCurrentPatchLevel()).append(")").toString());
		if (!Constants.isCVSVersion())
			plugin_interface.getUpdateManager().registerUpdatableComponent(this, false);
	}

	public String getName()
	{
		return "Core Patch Checker";
	}

	public int getMaximumCheckTime()
	{
		return 0;
	}

	public void checkForUpdate(UpdateChecker checker)
	{
		UpdateCheckInstance inst = checker.getCheckInstance();
		inst.addListener(this);
		checker.addUpdate("Core Patch Checker", new String[0], "", new ResourceDownloader[0], 3);
		checker.completed();
		break MISSING_BLOCK_LABEL_52;
		Exception exception;
		exception;
		checker.completed();
		throw exception;
	}

	public void cancelled(UpdateCheckInstance updatecheckinstance)
	{
	}

	public void complete(final UpdateCheckInstance instance)
	{
		Update updates[] = instance.getUpdates();
		final PluginInterface updater_plugin = plugin_interface.getPluginManager().getPluginInterfaceByClass(org/gudy/azureus2/update/UpdaterUpdateChecker);
		for (int i = 0; i < updates.length; i++)
		{
			Update update = updates[i];
			Object user_object = update.getUserObject();
			if (user_object == null || user_object != updater_plugin)
				continue;
			if (Logger.isEnabled())
				Logger.log(new LogEvent(LOGID, "Core Patcher: updater update found"));
			update.setRestartRequired(3);
			update.addListener(new UpdateListener() {

				final UpdateCheckInstance val$instance;
				final PluginInterface val$updater_plugin;
				final CorePatchChecker this$0;

				public void complete(Update update)
				{
					if (Logger.isEnabled())
						Logger.log(new LogEvent(CorePatchChecker.LOGID, "Core Patcher: updater update complete"));
					patch(instance, update, updater_plugin);
				}

				public void cancelled(Update update1)
				{
				}

			
			{
				this$0 = CorePatchChecker.this;
				instance = updatecheckinstance;
				updater_plugin = plugininterface;
				super();
			}
			});
		}

	}

	protected void patch(UpdateCheckInstance instance, Update updater_update, PluginInterface updater_plugin)
	{
		ResourceDownloader rd_log;
		File files[];
		rd_log = updater_update.getDownloaders()[0];
		files = (new File(updater_plugin.getPluginDirectoryName())).listFiles();
		if (files == null)
		{
			if (Logger.isEnabled())
				Logger.log(new LogEvent(LOGID, "Core Patcher: no files in plugin dir!!!"));
			return;
		}
		try
		{
			String patch_prefix = (new StringBuilder()).append("Azureus2_").append(Constants.getBaseVersion()).append("_P").toString();
			int highest_p = -1;
			File highest_p_file = null;
			for (int i = 0; i < files.length; i++)
			{
				String name = files[i].getName();
				if (!name.startsWith(patch_prefix) || !name.endsWith(".pat"))
					continue;
				if (Logger.isEnabled())
					Logger.log(new LogEvent(LOGID, (new StringBuilder()).append("Core Patcher: found patch file '").append(name).append("'").toString()));
				try
				{
					int this_p = Integer.parseInt(name.substring(patch_prefix.length(), name.indexOf(".pat")));
					if (this_p > highest_p)
					{
						highest_p = this_p;
						highest_p_file = files[i];
					}
				}
				catch (Throwable e)
				{
					Debug.printStackTrace(e);
				}
			}

			if (CorePatchLevel.getCurrentPatchLevel() >= highest_p)
			{
				if (Logger.isEnabled())
					Logger.log(new LogEvent(LOGID, (new StringBuilder()).append("Core Patcher: no applicable patch found (highest = ").append(highest_p).append(")").toString()));
				if (updater_update.getRestartRequired() == 3)
					updater_update.setRestartRequired(1);
			} else
			{
				rd_log.reportActivity((new StringBuilder()).append("Applying patch '").append(highest_p_file.getName()).append("'").toString());
				if (Logger.isEnabled())
					Logger.log(new LogEvent(LOGID, (new StringBuilder()).append("Core Patcher: applying patch '").append(highest_p_file.toString()).append("'").toString()));
				InputStream pis = new FileInputStream(highest_p_file);
				patchAzureus2(instance, pis, (new StringBuilder()).append("P").append(highest_p).toString(), plugin_interface.getLogger().getChannel("CorePatcher"));
				Logger.log(new LogAlert(false, 0, (new StringBuilder()).append("Patch ").append(highest_p_file.getName()).append(" ready to be applied").toString()));
				String done_file = highest_p_file.toString();
				done_file = (new StringBuilder()).append(done_file.substring(0, done_file.length() - 1)).append("x").toString();
				highest_p_file.renameTo(new File(done_file));
				updater_update.setRestartRequired(2);
			}
		}
		catch (Throwable e)
		{
			Debug.printStackTrace(e);
			Logger.log(new LogAlert(false, "Core Patcher failed", e));
		}
		return;
	}

	public static void patchAzureus2(UpdateCheckInstance instance, InputStream pis, String resource_tag, LoggerChannel log)
		throws Exception
	{
		String resource_name = (new StringBuilder()).append("Azureus2_").append(resource_tag).append(".jar").toString();
		UpdateInstaller installer = instance.createInstaller();
		File tmp = AETemporaryFileHandler.createTempFile();
		OutputStream os = new FileOutputStream(tmp);
		String az2_jar;
		if (Constants.isOSX)
			az2_jar = (new StringBuilder()).append(installer.getInstallDir()).append("/").append(SystemProperties.getApplicationName()).append(".app/Contents/Resources/Java/").toString();
		else
			az2_jar = (new StringBuilder()).append(installer.getInstallDir()).append(File.separator).toString();
		az2_jar = (new StringBuilder()).append(az2_jar).append("Azureus2.jar").toString();
		InputStream is = new FileInputStream(az2_jar);
		new UpdateJarPatcher(is, pis, os, log);
		is.close();
		pis.close();
		os.close();
		installer.addResource(resource_name, new FileInputStream(tmp));
		tmp.delete();
		installer.addMoveAction(resource_name, az2_jar);
	}

	static 
	{
		LOGID = LogIDs.CORE;
	}

}

⌨️ 快捷键说明

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