use of com.biglybt.core.logging.LogEvent in project BiglyBT by BiglySoftware.
the class CoreUpdateChecker method checkForUpdate.
@Override
public void checkForUpdate(final UpdateChecker checker) {
try {
String current_version = plugin_interface.getApplicationVersion();
log.log("Update check starts: current = " + current_version);
Map decoded = VersionCheckClient.getSingleton().getVersionCheckInfo(first_check ? VersionCheckClient.REASON_UPDATE_CHECK_START : VersionCheckClient.REASON_UPDATE_CHECK_PERIODIC);
displayUserMessage(decoded);
// *actually* returning a map with nothing in it.
if (decoded.isEmpty()) {
return;
}
String latest_version;
String latest_file_name;
byte[] b_version = (byte[]) decoded.get("version");
if (b_version != null) {
latest_version = new String(b_version);
plugin_interface.getPluginProperties().setProperty(LATEST_VERSION_PROPERTY, latest_version);
} else {
throw (new Exception("No version found in reply"));
}
byte[] b_filename = (byte[]) decoded.get("filename");
if (b_filename != null) {
latest_file_name = new String(b_filename);
} else {
throw (new Exception("No update file details in reply"));
}
String msg = "Core: latest_version = '" + latest_version + "', file = '" + latest_file_name + "'";
URL full_download_url;
if (latest_file_name.startsWith("http")) {
try {
full_download_url = new URL(latest_file_name);
} catch (Throwable e) {
full_download_url = null;
log.log(e);
}
int pos = latest_file_name.lastIndexOf('/');
latest_file_name = latest_file_name.substring(pos + 1);
} else {
full_download_url = null;
}
checker.reportProgress(msg);
log.log(msg);
if (!shouldUpdate(current_version, latest_version)) {
return;
}
final String f_latest_version = latest_version;
final String f_latest_file_name = latest_file_name;
ResourceDownloader top_downloader;
if (full_download_url == null) {
throw (new Exception("No download URL available"));
} else {
ResourceDownloader full_rd = rdf.create(full_download_url);
ResourceDownloader full_ap_rd = rdf.createWithAutoPluginProxy(full_download_url);
full_rd = rdf.getSuffixBasedDownloader(full_rd);
top_downloader = rdf.getAlternateDownloader(new ResourceDownloader[] { full_rd, full_ap_rd });
}
top_downloader.addListener(rd_logger);
// get size so it is cached
top_downloader.getSize();
byte[] info_b = (byte[]) decoded.get("info");
String info = null;
if (info_b != null) {
try {
info = new String(info_b, "UTF-8");
} catch (Throwable e) {
Debug.printStackTrace(e);
}
}
byte[] info_url_bytes = (byte[]) decoded.get("info_url");
String info_url = null;
if (info_url_bytes != null) {
try {
info_url = new String(info_url_bytes);
} catch (Exception e) {
Debug.out(e);
}
}
if (info != null || info_url != null) {
String check;
if (info == null) {
check = info_url;
} else if (info_url == null) {
check = info;
} else {
check = info + "|" + info_url;
}
byte[] sig = (byte[]) decoded.get("info_sig");
boolean ok = false;
if (sig == null) {
Logger.log(new LogEvent(LogIDs.LOGGER, "info signature check failed - missing signature"));
} else {
try {
AEVerifier.verifyData(check, sig);
ok = true;
} catch (Throwable e) {
Logger.log(new LogEvent(LogIDs.LOGGER, "info signature check failed", e));
}
}
if (!ok) {
info = null;
info_url = null;
}
}
String update_name = "Core " + Constants.AZUREUS_NAME + " Version";
String[] desc;
if (info == null) {
desc = new String[] { update_name };
} else {
desc = new String[] { update_name, info };
}
final Update update = checker.addUpdate(update_name, desc, current_version, latest_version, top_downloader, Update.RESTART_REQUIRED_YES);
if (info_url != null) {
update.setDescriptionURL(info_url);
}
top_downloader.addListener(new ResourceDownloaderAdapter() {
@Override
public boolean completed(final ResourceDownloader downloader, InputStream data) {
installUpdate(checker, update, downloader, f_latest_file_name, f_latest_version, data);
return (true);
}
@Override
public void failed(ResourceDownloader downloader, ResourceDownloaderException e) {
// Debug.out( downloader.getName() + " failed", e );
update.complete(false);
}
});
} catch (Throwable e) {
log.log(e);
Debug.printStackTrace(e);
checker.reportProgress("Failed to check for core update: " + Debug.getNestedExceptionMessage(e));
checker.failed();
} finally {
checker.completed();
first_check = false;
}
}
use of com.biglybt.core.logging.LogEvent in project BiglyBT by BiglySoftware.
the class ShellManager method addWindow.
/**
* Adds a shell to the shell manager. If the shell is already managed, it is not added again.
* <p><b>Note</b>: This method must be invoked by the SWT display thread</p>
* @param shell A SWT Shell
*/
public final void addWindow(final Shell shell) {
// Debug.out("Invoked by thread " + Thread.currentThread().getName());
if (shells.contains(shell)) {
return;
}
shells.add(shell);
notifyAddListeners(shell);
shell.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent event) {
try {
removeWindow(shell);
} catch (Exception e) {
Logger.log(new LogEvent(LogIDs.GUI, "removeWindow", e));
}
}
});
shell.addListener(SWT.Show, new Listener() {
@Override
public void handleEvent(Event event) {
Utils.verifyShellRect(shell, false);
}
});
}
use of com.biglybt.core.logging.LogEvent in project BiglyBT by BiglySoftware.
the class UIDebugGenerator method getShellImages.
public static java.util.List<Image> getShellImages() {
java.util.List<Image> result = new ArrayList<>();
Display display = Display.getCurrent();
if (display == null) {
return null;
}
Shell activeShell = display.getActiveShell();
if (activeShell != null) {
activeShell.setCursor(display.getSystemCursor(SWT.CURSOR_WAIT));
}
Shell[] shells = display.getShells();
if (shells == null || shells.length == 0) {
return null;
}
for (int i = 0; i < shells.length; i++) {
try {
Shell shell = shells[i];
Image image = null;
if (shell.isDisposed() || !shell.isVisible()) {
continue;
}
shell.moveAbove(null);
Utils.ensureDisplayUpdated(display);
if (shell.getData("class") instanceof ObfuscateShell) {
ObfuscateShell shellClass = (ObfuscateShell) shell.getData("class");
try {
image = shellClass.generateObfuscatedImage();
} catch (Exception e) {
Debug.out("Obfuscating shell " + shell, e);
}
} else {
Rectangle clientArea = shell.getClientArea();
image = new Image(display, clientArea.width, clientArea.height);
GC gc = new GC(shell);
try {
gc.copyArea(image, clientArea.x, clientArea.y);
} finally {
gc.dispose();
}
}
if (image != null) {
result.add(image);
}
} catch (Throwable e) {
Logger.log(new LogEvent(LogIDs.GUI, "Creating Obfuscated Image", e));
}
}
if (activeShell != null) {
activeShell.setCursor(null);
}
return (result);
}
use of com.biglybt.core.logging.LogEvent in project BiglyBT by BiglySoftware.
the class UIFunctionsImpl method closePluginViews.
// @see UIFunctionsSWT#closePluginViews(java.lang.String)
@Override
public void closePluginViews(String sViewID) {
try {
MultipleDocumentInterface mdi = UIFunctionsManager.getUIFunctions().getMDI();
if (mdi == null) {
return;
}
mdi.closeEntry(sViewID);
} catch (Exception e) {
Logger.log(new LogEvent(LOGID, "closePluginViews", e));
}
}
use of com.biglybt.core.logging.LogEvent in project BiglyBT by BiglySoftware.
the class UIFunctionsImpl method closePluginView.
/* (non-Javadoc)
* @see UIFunctionsSWT#closePluginView(com.biglybt.ui.swt.pifimpl.UISWTViewCore)
*/
@Override
public void closePluginView(UISWTViewCore view) {
try {
MultipleDocumentInterface mdi = UIFunctionsManager.getUIFunctions().getMDI();
if (mdi == null) {
return;
}
String id;
if (view instanceof UISWTViewImpl) {
id = ((UISWTViewImpl) view).getViewID();
} else {
id = view.getClass().getName();
int i = id.lastIndexOf('.');
if (i > 0) {
id = id.substring(i + 1);
}
}
mdi.closeEntry(id);
} catch (Exception e) {
Logger.log(new LogEvent(LOGID, "closePluginView", e));
}
}
Aggregations