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

📄 platformmanagerimpl.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:   PlatformManagerImpl.java

package org.gudy.azureus2.platform.macosx;

import com.apple.cocoa.application.NSApplication;
import java.io.*;
import java.net.InetAddress;
import java.text.MessageFormat;
import java.util.HashSet;
import org.gudy.azureus2.core3.config.COConfigurationManager;
import org.gudy.azureus2.core3.config.ParameterListener;
import org.gudy.azureus2.core3.logging.*;
import org.gudy.azureus2.core3.util.*;
import org.gudy.azureus2.platform.*;
import org.gudy.azureus2.platform.macosx.access.jnilib.OSXAccess;
import org.gudy.azureus2.plugins.platform.PlatformManagerException;

// Referenced classes of package org.gudy.azureus2.platform.macosx:
//			NativeInvocationBridge, PListEditor

public class PlatformManagerImpl
	implements PlatformManager, AEDiagnosticsEvidenceGenerator
{

	private static final LogIDs LOGID;
	protected static PlatformManagerImpl singleton;
	protected static AEMonitor class_mon = new AEMonitor("PlatformManager");
	private static String fileBrowserName = "Finder";
	private final HashSet capabilitySet = new HashSet();

	public static PlatformManagerImpl getSingleton()
	{
		return singleton;
	}

	private static void initializeSingleton()
	{
		class_mon.enter();
		singleton = new PlatformManagerImpl();
		class_mon.exit();
		break MISSING_BLOCK_LABEL_60;
		Throwable e;
		e;
		Logger.log(new LogEvent(LOGID, "Failed to initialize platform manager for Mac OS X", e));
		class_mon.exit();
		break MISSING_BLOCK_LABEL_60;
		Exception exception;
		exception;
		class_mon.exit();
		throw exception;
		COConfigurationManager.addAndFireParameterListener("FileBrowse.usePathFinder", new ParameterListener() {

			public void parameterChanged(String parameterName)
			{
				PlatformManagerImpl.fileBrowserName = COConfigurationManager.getBooleanParameter("FileBrowse.usePathFinder") ? "Path Finder" : "Finder";
			}

		});
		return;
	}

	public PlatformManagerImpl()
	{
		capabilitySet.add(PlatformManagerCapabilities.RecoverableFileDelete);
		capabilitySet.add(PlatformManagerCapabilities.ShowFileInBrowser);
		capabilitySet.add(PlatformManagerCapabilities.ShowPathInCommandLine);
		capabilitySet.add(PlatformManagerCapabilities.CreateCommandLineProcess);
		capabilitySet.add(PlatformManagerCapabilities.GetUserDataDirectory);
		capabilitySet.add(PlatformManagerCapabilities.UseNativeScripting);
		capabilitySet.add(PlatformManagerCapabilities.PlaySystemAlert);
		capabilitySet.add(PlatformManagerCapabilities.RequestUserAttention);
		if (OSXAccess.isLoaded())
			capabilitySet.add(PlatformManagerCapabilities.GetVersion);
		AEDiagnostics.addEvidenceGenerator(this);
		checkPList();
	}

	public int getPlatformType()
	{
		return 3;
	}

	public String getVersion()
		throws PlatformManagerException
	{
		if (!OSXAccess.isLoaded())
			throw new PlatformManagerException("Unsupported capability called on platform manager");
		else
			return OSXAccess.getVersion();
	}

	protected PListEditor getPList()
		throws IOException
	{
		String plist = (new StringBuilder()).append(System.getProperty("user.dir")).append(SystemProperties.SEP).append(SystemProperties.getApplicationName()).append(".app/Contents/Info.plist").toString();
		PListEditor editor = new PListEditor(plist);
		return editor;
	}

	protected void checkPList()
	{
		try
		{
			PListEditor editor = getPList();
			editor.setFileTypeExtensions(new String[] {
				"torrent", "tor", "vuze", "vuz"
			});
			editor.setSimpleStringValue("CFBundleName", "Vuze");
			editor.setSimpleStringValue("CFBundleTypeName", "Vuze Download");
			editor.setSimpleStringValue("CFBundleGetInfoString", "Vuze");
			editor.setSimpleStringValue("CFBundleShortVersionString", "4.2.0.0");
			editor.setSimpleStringValue("CFBundleVersion", "4.2.0.0");
			editor.setArrayValues("CFBundleURLSchemes", "string", new String[] {
				"magnet", "dht", "vuze"
			});
		}
		catch (Throwable e)
		{
			Debug.out("Failed to update plist", e);
		}
	}

	protected void touchPList()
	{
		try
		{
			PListEditor editor = getPList();
			editor.touchFile();
		}
		catch (Throwable e)
		{
			Debug.out("Failed to touch plist", e);
		}
	}

	public String getUserDataDirectory()
		throws PlatformManagerException
	{
		return (new StringBuilder()).append((new File((new StringBuilder()).append(System.getProperty("user.home")).append("/Library/Application Support/").append(SystemProperties.APPLICATION_NAME).toString())).getPath()).append(SystemProperties.SEP).toString();
	}

	public String getComputerName()
	{
		String host = System.getenv("HOST");
		if (host != null && host.length() > 0)
			return host;
		else
			return null;
	}

	public File getLocation(long location_id)
		throws PlatformManagerException
	{
		(int)location_id;
		JVM INSTR tableswitch 1 4: default 71
	//	               1 32
	//	               2 71
	//	               3 44
	//	               4 71;
		   goto _L1 _L2 _L1 _L3 _L1
_L2:
		return new File(getUserDataDirectory());
_L3:
		return new File(OSXAccess.getDocDir());
		Throwable e;
		e;
		return new File(System.getProperty("user.home"), "Documents");
_L1:
		return null;
	}

	public boolean isApplicationRegistered()
		throws PlatformManagerException
	{
		return true;
	}

	public String getApplicationCommandLine()
		throws PlatformManagerException
	{
		File osx_app_bundle;
		String bundle_path = (new StringBuilder()).append(System.getProperty("user.dir")).append(SystemProperties.SEP).append(SystemProperties.getApplicationName()).append(".app").toString();
		osx_app_bundle = (new File(bundle_path)).getAbsoluteFile();
		if (!osx_app_bundle.exists())
		{
			String msg = (new StringBuilder()).append("OSX app bundle not found: [").append(osx_app_bundle.toString()).append("]").toString();
			System.out.println(msg);
			if (Logger.isEnabled())
				Logger.log(new LogEvent(LOGID, msg));
			throw new PlatformManagerException(msg);
		}
		return (new StringBuilder()).append("open -a \"").append(osx_app_bundle.toString()).append("\"").toString();
		Throwable t;
		t;
		t.printStackTrace();
		return null;
	}

	public boolean isAdditionalFileTypeRegistered(String name, String type)
		throws PlatformManagerException
	{
		throw new PlatformManagerException("Unsupported capability called on platform manager");
	}

	public void unregisterAdditionalFileType(String name, String type)
		throws PlatformManagerException
	{
		throw new PlatformManagerException("Unsupported capability called on platform manager");
	}

	public void registerAdditionalFileType(String name, String description, String type, String content_type)
		throws PlatformManagerException
	{
		throw new PlatformManagerException("Unsupported capability called on platform manager");
	}

	public void registerApplication()
		throws PlatformManagerException
	{
		touchPList();
	}

	public void createProcess(String cmd, boolean inheritsHandles)
		throws PlatformManagerException
	{
		try
		{
			performRuntimeExec(cmd.split(" "));
		}
		catch (Throwable e)
		{
			throw new PlatformManagerException("Failed to create process", e);
		}
	}

	public void performRecoverableFileDelete(String path)
		throws PlatformManagerException
	{
		File file = new File(path);
		if (!file.exists())
		{
			if (Logger.isEnabled())
				Logger.log(new LogEvent(LOGID, 1, (new StringBuilder()).append("Cannot find ").append(file.getName()).toString()));
			return;
		}
		boolean useOSA = !NativeInvocationBridge.sharedInstance().isEnabled() || !NativeInvocationBridge.sharedInstance().performRecoverableFileDelete(file);
		if (useOSA)
			try
			{
				StringBuffer sb = new StringBuffer();
				sb.append("tell application \"");
				sb.append("Finder");
				sb.append("\" to move (posix file \"");
				sb.append(path);
				sb.append("\" as alias) to the trash");
				performOSAScript(sb);
			}
			catch (Throwable e)
			{
				throw new PlatformManagerException("Failed to move file", e);
			}
	}

	public boolean hasCapability(PlatformManagerCapabilities capability)
	{
		return capabilitySet.contains(capability);
	}

	public void dispose()
	{
		NativeInvocationBridge.sharedInstance().dispose();
	}

	public void setTCPTOSEnabled(boolean enabled)
		throws PlatformManagerException
	{
		throw new PlatformManagerException("Unsupported capability called on platform manager");
	}

	public void copyFilePermissions(String from_file_name, String to_file_name)
		throws PlatformManagerException
	{
		throw new PlatformManagerException("Unsupported capability called on platform manager");
	}

	public void showFile(String path)
		throws PlatformManagerException
	{
		File file = new File(path);
		if (!file.exists())
		{
			if (Logger.isEnabled())
				Logger.log(new LogEvent(LOGID, 1, (new StringBuilder()).append("Cannot find ").append(file.getName()).toString()));

⌨️ 快捷键说明

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