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

📄 azpluginconnection.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:   AZPluginConnection.java

package org.gudy.azureus2.core3.util.protocol.azplug;

import com.aelitis.azureus.core.AzureusCore;
import com.aelitis.azureus.core.AzureusCoreFactory;
import java.io.IOException;
import java.io.InputStream;
import java.net.*;
import java.util.*;
import org.gudy.azureus2.core3.util.Debug;
import org.gudy.azureus2.plugins.PluginInterface;
import org.gudy.azureus2.plugins.PluginManager;
import org.gudy.azureus2.plugins.ipc.IPCException;
import org.gudy.azureus2.plugins.ipc.IPCInterface;

public class AZPluginConnection extends HttpURLConnection
{

	private int response_code;
	private String response_msg;
	private InputStream input_stream;
	private Map headers;

	protected AZPluginConnection(URL _url)
	{
		super(_url);
		response_code = 200;
		response_msg = "OK";
		headers = new HashMap();
	}

	public void connect()
		throws IOException
	{
		String url = getURL().toString();
		int pos = url.indexOf("?");
		if (pos == -1)
			throw new IOException("Malformed URL - ? missing");
		url = url.substring(pos + 1);
		String bits[] = url.split("&");
		Map args = new HashMap();
		for (int i = 0; i < bits.length; i++)
		{
			String bit = bits[i];
			String x[] = bit.split("=");
			if (x.length == 2)
			{
				String lhs = x[0];
				String rhs = URLDecoder.decode(x[1], "UTF-8");
				args.put(lhs.toLowerCase(), rhs);
			}
		}

		String plugin_id = (String)args.get("id");
		if (plugin_id == null)
			throw new IOException("Plugin id missing");
		String plugin_name = (String)args.get("name");
		String arg = (String)args.get("arg");
		String plugin_str = (new StringBuilder()).append(plugin_id).append(plugin_name != null ? (new StringBuilder()).append(" (").append(plugin_name).append(")").toString() : "").toString();
		PluginInterface pi = AzureusCoreFactory.getSingleton().getPluginManager().getPluginInterfaceByID(plugin_id);
		if (pi == null)
			throw new IOException((new StringBuilder()).append("Plugin id ").append(plugin_str).append(" not installed").toString());
		IPCInterface ipc = pi.getIPC();
		try
		{
			if (ipc.canInvoke("handleURLProtocol", new Object[] {
	this, arg
}))
				input_stream = (InputStream)ipc.invoke("handleURLProtocol", new Object[] {
					this, arg
				});
			else
				input_stream = (InputStream)ipc.invoke("handleURLProtocol", new Object[] {
					arg
				});
		}
		catch (IPCException ipce)
		{
			Throwable e = ipce;
			if (e.getCause() != null)
				e = e.getCause();
			throw new IOException((new StringBuilder()).append("Communication error with plugin '").append(plugin_str).append("': ").append(Debug.getNestedExceptionMessage(e)).toString());
		}
	}

	public Map getHeaderFields()
	{
		return headers;
	}

	public String getHeaderField(String name)
	{
		List values = (List)headers.get(name);
		if (values == null || values.size() == 0)
			return null;
		else
			return (String)values.get(values.size() - 1);
	}

	public void setHeaderField(String name, String value)
	{
		List values = (List)headers.get(name);
		if (values == null)
		{
			values = new ArrayList();
			headers.put(name, values);
		}
		values.add(value);
	}

	public InputStream getInputStream()
		throws IOException
	{
		return input_stream;
	}

	public void setResponse(int _code, String _msg)
	{
		response_code = _code;
		response_msg = _msg;
	}

	public int getResponseCode()
	{
		return response_code;
	}

	public String getResponseMessage()
	{
		return response_msg;
	}

	public boolean usingProxy()
	{
		return false;
	}

	public void disconnect()
	{
	}
}

⌨️ 快捷键说明

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