📄 swtupdatechecker.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: SWTUpdateChecker.java
package org.gudy.azureus2.ui.swt.updater2;
import java.io.File;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import org.eclipse.swt.SWT;
import org.gudy.azureus2.core3.config.COConfigurationManager;
import org.gudy.azureus2.core3.internat.MessageText;
import org.gudy.azureus2.core3.logging.*;
import org.gudy.azureus2.core3.util.*;
import org.gudy.azureus2.plugins.PluginInterface;
import org.gudy.azureus2.plugins.update.*;
import org.gudy.azureus2.plugins.utils.resourcedownloader.*;
import org.gudy.azureus2.pluginsimpl.local.PluginInitializer;
import org.gudy.azureus2.pluginsimpl.local.utils.resourcedownloader.ResourceDownloaderFactoryImpl;
// Referenced classes of package org.gudy.azureus2.ui.swt.updater2:
// SWTVersionGetter
public class SWTUpdateChecker
implements UpdatableComponent
{
private static final LogIDs LOGID;
private static final String OSX_APP = (new StringBuilder()).append("/").append(SystemProperties.getApplicationName()).append(".app").toString();
public static void initialize()
{
PluginInitializer.getDefaultInterface().getUpdateManager().registerUpdatableComponent(new SWTUpdateChecker(), true);
}
public SWTUpdateChecker()
{
}
public void checkForUpdate(final UpdateChecker checker)
{
SWTVersionGetter versionGetter;
versionGetter = new SWTVersionGetter(checker);
boolean update_required = System.getProperty("azureus.skipSWTcheck") == null && versionGetter.needsUpdate();
if (!update_required)
break MISSING_BLOCK_LABEL_745;
int update_prevented_version = COConfigurationManager.getIntParameter("swt.update.prevented.version", -1);
try
{
URL swt_url = org/eclipse/swt/SWT.getClassLoader().getResource("org/eclipse/swt/SWT.class");
if (swt_url != null)
{
String url_str = swt_url.toExternalForm();
if (url_str.startsWith("jar:file:"))
{
File jar_file = FileUtil.getJarFileFromURL(url_str);
String expected_location;
if (Constants.isOSX)
expected_location = (new StringBuilder()).append(checker.getCheckInstance().getManager().getInstallDir()).append(OSX_APP).append("/Contents/Resources/Java").toString();
else
expected_location = checker.getCheckInstance().getManager().getInstallDir();
File expected_dir = new File(expected_location);
File jar_file_dir = jar_file.getParentFile();
if (expected_dir.exists() && jar_file_dir.exists())
{
expected_dir = expected_dir.getCanonicalFile();
jar_file_dir = jar_file_dir.getCanonicalFile();
if (expected_dir.equals(jar_file_dir))
{
if (update_prevented_version != -1)
{
update_prevented_version = -1;
COConfigurationManager.setParameter("swt.update.prevented.version", update_prevented_version);
}
} else
{
String alert = MessageText.getString("swt.alert.cant.update", new String[] {
String.valueOf(versionGetter.getCurrentVersion()), String.valueOf(versionGetter.getLatestVersion()), jar_file_dir.toString(), expected_dir.toString()
});
checker.reportProgress(alert);
long last_prompt = COConfigurationManager.getLongParameter("swt.update.prevented.version.time", 0L);
long now = SystemTime.getCurrentTime();
boolean force = now < last_prompt || now - last_prompt > 0x240c8400L;
if (!checker.getCheckInstance().isAutomatic())
force = true;
if (force || update_prevented_version != versionGetter.getCurrentVersion())
{
Logger.log(new LogAlert(true, 3, alert));
update_prevented_version = versionGetter.getCurrentVersion();
COConfigurationManager.setParameter("swt.update.prevented.version", update_prevented_version);
COConfigurationManager.setParameter("swt.update.prevented.version.time", now);
}
}
}
}
}
}
catch (Throwable e)
{
Debug.printStackTrace(e);
}
if (update_prevented_version != versionGetter.getCurrentVersion())
break MISSING_BLOCK_LABEL_452;
Logger.log(new LogEvent(LOGID, 3, "SWT update aborted due to previously reported issues regarding its install location"));
checker.failed();
checker.getCheckInstance().cancel();
checker.completed();
return;
String mirrors[] = versionGetter.getMirrors();
ResourceDownloader swtDownloader = null;
ResourceDownloaderFactory factory = ResourceDownloaderFactoryImpl.getSingleton();
List downloaders = new ArrayList();
for (int i = 0; i < mirrors.length; i++)
{
try
{
downloaders.add(factory.getSuffixBasedDownloader(factory.create(new URL(mirrors[i]))));
continue;
}
catch (MalformedURLException e) { }
if (Logger.isEnabled())
Logger.log(new LogEvent(LOGID, 1, (new StringBuilder()).append("Cannot use URL ").append(mirrors[i]).append(" (not valid)").toString()));
}
ResourceDownloader resourceDownloaders[] = (ResourceDownloader[])(ResourceDownloader[])downloaders.toArray(new ResourceDownloader[downloaders.size()]);
swtDownloader = factory.getRandomDownloader(resourceDownloaders);
try
{
swtDownloader.getSize();
}
catch (ResourceDownloaderException e)
{
Debug.printStackTrace(e);
}
final Update update = checker.addUpdate((new StringBuilder()).append("SWT Library for ").append(versionGetter.getPlatform()).toString(), new String[] {
(new StringBuilder()).append("SWT is the graphical library used by ").append(Constants.APP_NAME).toString()
}, (new StringBuilder()).append("").append(versionGetter.getLatestVersion()).toString(), swtDownloader, 2);
update.setDescriptionURL(versionGetter.getInfoURL());
swtDownloader.addListener(new ResourceDownloaderAdapter() {
final UpdateChecker val$checker;
final Update val$update;
final SWTUpdateChecker this$0;
public boolean completed(ResourceDownloader downloader, InputStream data)
{
return processData(checker, update, downloader, data);
}
{
this$0 = SWTUpdateChecker.this;
checker = updatechecker;
update = update1;
super();
}
});
checker.completed();
break MISSING_BLOCK_LABEL_795;
Throwable e;
e;
Logger.log(new LogAlert(false, "SWT Version check failed", e));
checker.failed();
checker.completed();
break MISSING_BLOCK_LABEL_795;
Exception exception;
exception;
checker.completed();
throw exception;
}
private boolean processData(UpdateChecker checker, Update update, ResourceDownloader rd, InputStream data)
{
ZipInputStream zip = null;
data = update.verifyData(data, true);
rd.reportActivity("Data verified successfully");
UpdateInstaller installer = checker.createInstaller();
zip = new ZipInputStream(data);
ZipEntry entry = null;
do
{
if ((entry = zip.getNextEntry()) == null)
break;
String name = entry.getName();
if (name.endsWith(".jar"))
{
installer.addResource(name, zip, false);
if (Constants.isOSX)
installer.addMoveAction(name, (new StringBuilder()).append(installer.getInstallDir()).append(OSX_APP).append("/Contents/Resources/Java/").append(name).toString());
else
installer.addMoveAction(name, (new StringBuilder()).append(installer.getInstallDir()).append(File.separator).append(name).toString());
} else
if (name.endsWith(".jnilib") && Constants.isOSX)
{
installer.addResource(name, zip, false);
installer.addMoveAction(name, (new StringBuilder()).append(installer.getInstallDir()).append(OSX_APP).append("/Contents/Resources/Java/dll/").append(name).toString());
} else
if (name.equals("java_swt"))
{
installer.addResource(name, zip, false);
installer.addMoveAction(name, (new StringBuilder()).append(installer.getInstallDir()).append(OSX_APP).append("/Contents/MacOS/").append(name).toString());
installer.addChangeRightsAction("755", (new StringBuilder()).append(installer.getInstallDir()).append(OSX_APP).append("/Contents/MacOS/").append(name).toString());
} else
if (name.endsWith(".dll") || name.endsWith(".so") || name.indexOf(".so.") != -1)
{
installer.addResource(name, zip, false);
installer.addMoveAction(name, (new StringBuilder()).append(installer.getInstallDir()).append(File.separator).append(name).toString());
} else
if (!name.equals("javaw.exe.manifest") && !name.equals("azureus.sig"))
Debug.outNoStack((new StringBuilder()).append("SWTUpdate: ignoring zip entry '").append(name).append("'").toString());
} while (true);
Exception e;
if (zip != null)
try
{
zip.close();
}
// Misplaced declaration of an exception variable
catch (Exception e) { }
break MISSING_BLOCK_LABEL_588;
e;
boolean flag;
Logger.log(new LogAlert(false, "SWT Update failed", e));
flag = false;
if (zip != null)
try
{
zip.close();
}
catch (Throwable e) { }
return flag;
Exception exception;
exception;
if (zip != null)
try
{
zip.close();
}
catch (Throwable e) { }
throw exception;
return true;
}
public String getName()
{
return "SWT library";
}
public int getMaximumCheckTime()
{
return 30;
}
static
{
LOGID = LogIDs.GUI;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -