📄 platformmanagerunixplugin.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: PlatformManagerUnixPlugin.java
package org.gudy.azureus2.platform.unix;
import com.aelitis.azureus.ui.UIFunctions;
import com.aelitis.azureus.ui.UIFunctionsManager;
import java.io.*;
import java.util.Properties;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.gudy.azureus2.core3.config.COConfigurationManager;
import org.gudy.azureus2.core3.internat.MessageText;
import org.gudy.azureus2.core3.util.*;
import org.gudy.azureus2.platform.*;
import org.gudy.azureus2.plugins.*;
import org.gudy.azureus2.plugins.ui.*;
import org.gudy.azureus2.update.UpdaterUtils;
// Referenced classes of package org.gudy.azureus2.platform.unix:
// ScriptAfterShutdown
public class PlatformManagerUnixPlugin
implements Plugin
{
private PluginInterface plugin_interface;
public PlatformManagerUnixPlugin()
{
}
public void initialize(PluginInterface _plugin_interface)
throws PluginException
{
plugin_interface = _plugin_interface;
plugin_interface.getPluginProperties().setProperty("plugin.name", "Platform-Specific Support");
String version = "1.0";
PlatformManager platform = PlatformManagerFactory.getPlatformManager();
if (platform.hasCapability(PlatformManagerCapabilities.GetVersion))
try
{
version = platform.getVersion();
}
catch (Throwable e)
{
Debug.printStackTrace(e);
}
else
plugin_interface.getPluginProperties().setProperty("plugin.version.info", "Not required for this platform");
plugin_interface.getPluginProperties().setProperty("plugin.version", version);
plugin_interface.getUIManager().addUIListener(new UIManagerListener() {
boolean done;
final PlatformManagerUnixPlugin this$0;
public void UIDetached(UIInstance uiinstance)
{
}
public void UIAttached(UIInstance instance)
{
if (!done)
{
done = true;
if (Constants.compareVersions(UpdaterUtils.getUpdaterPluginVersion(), "1.8.5") >= 0)
checkStartupScript();
}
}
{
this$0 = PlatformManagerUnixPlugin.this;
super();
done = false;
}
});
}
private void checkStartupScript()
{
COConfigurationManager.setIntDefault("unix.script.lastaskversion", -1);
int lastAskedVersion = COConfigurationManager.getIntParameter("unix.script.lastaskversion");
String sVersion = System.getProperty("azureus.script.version", "0");
int version = 0;
try
{
version = Integer.parseInt(sVersion);
}
catch (Throwable t) { }
Pattern pat = Pattern.compile("SCRIPT_VERSION=([0-9]+)", 2);
String sScriptFile = System.getProperty("azureus.script", null);
File oldFilePath;
if (sScriptFile != null && (new File(sScriptFile)).exists())
{
oldFilePath = new File(sScriptFile);
} else
{
oldFilePath = new File(SystemProperties.getApplicationPath(), "azureus");
if (!oldFilePath.exists())
return;
}
String oldFilePathString = oldFilePath.getAbsolutePath();
String oldStartupScript;
try
{
oldStartupScript = FileUtil.readFileAsString(oldFilePath, 65535, "utf8");
}
catch (IOException e)
{
oldStartupScript = "";
}
if (version == 0)
{
Matcher matcher = pat.matcher(oldStartupScript);
if (matcher.find())
{
String sScriptVersion = matcher.group(1);
try
{
version = Integer.parseInt(sScriptVersion);
}
catch (Throwable t) { }
}
}
if (version <= lastAskedVersion)
return;
java.io.InputStream stream = getClass().getResourceAsStream("startupScript");
try
{
String startupScript = FileUtil.readInputStreamAsString(stream, 65535, "utf8");
Matcher matcher = pat.matcher(startupScript);
if (matcher.find())
{
String sScriptVersion = matcher.group(1);
int latestVersion = 0;
try
{
latestVersion = Integer.parseInt(sScriptVersion);
}
catch (Throwable t) { }
if (latestVersion > version)
{
boolean bNotChanged = oldStartupScript.indexOf("SCRIPT_NOT_CHANGED=0") > 0;
boolean bInformUserManual = true;
if (bNotChanged)
if (version >= 1)
{
String newFilePath = (new File(SystemProperties.getApplicationPath(), "azureus.new")).getAbsolutePath();
FileUtil.writeBytesAsFile(newFilePath, startupScript.getBytes());
String s = (new StringBuilder()).append("cp \"").append(newFilePath).append("\" \"").append(oldFilePathString).append("\"; chmod +x \"").append(oldFilePathString).append("\"; echo \"Script Update successful\"").toString();
ScriptAfterShutdown.addExtraCommand(s);
ScriptAfterShutdown.setRequiresExit(true);
bInformUserManual = false;
} else
{
try
{
FileUtil.writeBytesAsFile(oldFilePathString, startupScript.getBytes());
Runtime.getRuntime().exec(new String[] {
"chmod", "+x", oldStartupScript
});
bInformUserManual = false;
}
catch (Throwable t) { }
}
if (bInformUserManual)
{
String newFilePath = (new File(SystemProperties.getApplicationPath(), "azureus.new")).getAbsolutePath();
FileUtil.writeBytesAsFile(newFilePath, startupScript.getBytes());
showScriptManualUpdateDialog(newFilePath, oldFilePathString, latestVersion);
} else
{
showScriptAutoUpdateDialog();
}
}
}
}
catch (Throwable t)
{
t.printStackTrace();
}
}
private void showScriptManualUpdateDialog(String newFilePath, String oldFilePath, int version)
{
UIFunctions uif = UIFunctionsManager.getUIFunctions();
if (uif != null)
{
String sCopyLine = (new StringBuilder()).append("cp \"").append(newFilePath).append("\" \"").append(oldFilePath).append("\"").toString();
int answer = uif.promptUser(MessageText.getString("unix.script.new.title"), MessageText.getString("unix.script.new.text", new String[] {
newFilePath, sCopyLine
}), new String[] {
MessageText.getString("unix.script.new.button.quit"), MessageText.getString("unix.script.new.button.continue"), MessageText.getString("unix.script.new.button.asknomore")
}, 0, null, null, false, 0);
if (answer == 0)
{
System.out.println((new StringBuilder()).append("The line you should run:\n").append(sCopyLine).toString());
uif.dispose(false, false);
} else
if (answer == 2)
COConfigurationManager.setParameter("unix.script.lastaskversion", version);
} else
{
System.out.println("NO UIF");
}
}
private void showScriptAutoUpdateDialog()
{
UIFunctions uif = UIFunctionsManager.getUIFunctions();
if (uif != null)
{
int answer = uif.promptUser(MessageText.getString("unix.script.new.auto.title"), MessageText.getString("unix.script.new.auto.text", new String[0]), new String[] {
MessageText.getString("UpdateWindow.restart"), MessageText.getString("UpdateWindow.restartLater")
}, 0, null, null, false, 0);
if (answer == 0)
uif.dispose(true, false);
} else
{
System.out.println("NO UIF");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -