use of com.biglybt.core.logging.LogEvent in project BiglyBT by BiglySoftware.
the class MagnetURIHandlerImpl method addInfo.
@Override
public void addInfo(String name, int info) {
info_map.put(name, new Integer(info));
Logger.log(new LogEvent(LOGID, LogEvent.LT_INFORMATION, "MagnetURIHandler: global info registered: " + name + " -> " + info));
}
use of com.biglybt.core.logging.LogEvent in project BiglyBT by BiglySoftware.
the class PlatformManagerImpl method performRecoverableFileDelete.
/**
* {@inheritDoc}
*/
@Override
public void performRecoverableFileDelete(String path) throws PlatformManagerException {
File file = new File(path);
if (!file.exists()) {
if (Logger.isEnabled())
Logger.log(new LogEvent(LOGID, LogEvent.LT_WARNING, "Cannot find " + file.getName()));
return;
}
try {
Class<?> claFileManager = getFileManagerClass();
if (claFileManager != null) {
Method methMoveToTrash = claFileManager.getMethod("moveToTrash", new Class[] { File.class });
if (methMoveToTrash != null) {
Object result = methMoveToTrash.invoke(null, new Object[] { file });
if (result instanceof Boolean) {
if (((Boolean) result).booleanValue()) {
return;
}
}
}
}
} catch (Throwable e) {
}
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);
}
}
}
use of com.biglybt.core.logging.LogEvent in project BiglyBT by BiglySoftware.
the class PlatformManagerUpdateChecker method installUpdate.
protected void installUpdate(UpdateChecker checker, Update update, ResourceDownloader rd, InputStream data) {
ZipInputStream zip = null;
try {
data = update.verifyData(data, true);
rd.reportActivity("Data verified successfully");
UpdateInstaller installer = checker.createInstaller();
zip = new ZipInputStream(data);
ZipEntry entry = null;
while ((entry = zip.getNextEntry()) != null) {
String name = entry.getName();
if (name.toLowerCase().startsWith("osx/")) {
// OSX only files
name = name.substring(4);
if (name.length() > 0) {
rd.reportActivity("Adding update action for '" + name + "'");
if (Logger.isEnabled())
Logger.log(new LogEvent(LOGID, "PlatformManager:OSX adding action for '" + name + "'"));
// handle sub-dirs
String resource_name = name.replaceAll("/", "-");
installer.addResource(resource_name, zip, false);
String appDir = installer.getInstallDir();
String contentsResourceJava = "Contents/Resources/Java/";
if (name.startsWith(contentsResourceJava)) {
// trying to install something into the "Java" dir
// New installs have the "Java" dir as the Install dir.
name = name.substring(contentsResourceJava.length());
}
String target = appDir + File.separator + name;
installer.addMoveAction(resource_name, target);
if (name.endsWith(".jnilib") || name.endsWith("JavaApplicationStub")) {
installer.addChangeRightsAction("755", target);
}
}
}
}
update.complete(true);
} catch (Throwable e) {
update.complete(false);
rd.reportActivity("Update install failed:" + e.getMessage());
} finally {
if (zip != null) {
try {
zip.close();
} catch (Throwable e) {
}
}
}
}
use of com.biglybt.core.logging.LogEvent in project BiglyBT by BiglySoftware.
the class PlatformManagerUpdateChecker method checkForUpdate.
@Override
public void checkForUpdate(final UpdateChecker checker) {
try {
SFPluginDetails sf_details = SFPluginDetailsLoaderFactory.getSingleton().getPluginDetails(plugin_interface.getPluginID());
String current_version = plugin_interface.getPluginVersion();
if (Logger.isEnabled())
Logger.log(new LogEvent(LOGID, "PlatformManager:OSX update check starts: current = " + current_version));
boolean current_az_is_cvs = Constants.isCVSVersion();
String sf_plugin_version = sf_details.getVersion();
String sf_comp_version = sf_plugin_version;
if (current_az_is_cvs) {
String sf_cvs_version = sf_details.getCVSVersion();
if (sf_cvs_version.length() > 0) {
// sf cvs version ALWAYS entry in _CVS
sf_plugin_version = sf_cvs_version;
sf_comp_version = sf_plugin_version.substring(0, sf_plugin_version.length() - 4);
}
}
String target_version = null;
if (sf_comp_version.length() == 0 || !Character.isDigit(sf_comp_version.charAt(0))) {
if (Logger.isEnabled())
Logger.log(new LogEvent(LOGID, LogEvent.LT_WARNING, "PlatformManager:OSX no valid version to check against (" + sf_comp_version + ")"));
} else if (Constants.compareVersions(current_version, sf_comp_version) < 0) {
target_version = sf_comp_version;
}
checker.reportProgress("OSX: current = " + current_version + ", latest = " + sf_comp_version);
if (Logger.isEnabled())
Logger.log(new LogEvent(LOGID, "PlatformManager:OSX update required = " + (target_version != null)));
if (target_version != null) {
String target_download = sf_details.getDownloadURL();
if (current_az_is_cvs) {
String sf_cvs_version = sf_details.getCVSVersion();
if (sf_cvs_version.length() > 0) {
target_download = sf_details.getCVSDownloadURL();
}
}
ResourceDownloaderFactory rdf = ResourceDownloaderFactoryImpl.getSingleton();
ResourceDownloader direct_rdl = rdf.create(new URL(target_download));
String torrent_download = Constants.URL_PLUGINS_TORRENT_BASE;
int slash_pos = target_download.lastIndexOf("/");
if (slash_pos == -1) {
torrent_download += target_download;
} else {
torrent_download += target_download.substring(slash_pos + 1);
}
torrent_download += ".torrent";
if (I2PHelpers.isI2PInstalled()) {
torrent_download += "?i2p=1";
}
ResourceDownloader torrent_rdl = rdf.create(new URL(torrent_download));
torrent_rdl = rdf.getSuffixBasedDownloader(torrent_rdl);
// create an alternate downloader with torrent attempt first
ResourceDownloader alternate_rdl = rdf.getAlternateDownloader(new ResourceDownloader[] { torrent_rdl, direct_rdl });
// get size here so it is cached
rdf.getTimeoutDownloader(rdf.getRetryDownloader(alternate_rdl, RD_SIZE_RETRIES), RD_SIZE_TIMEOUT).getSize();
List update_desc = new ArrayList();
List desc_lines = HTMLUtils.convertHTMLToText("", sf_details.getDescription());
update_desc.addAll(desc_lines);
List comment_lines = HTMLUtils.convertHTMLToText(" ", sf_details.getComment());
update_desc.addAll(comment_lines);
String[] update_d = new String[update_desc.size()];
update_desc.toArray(update_d);
final Update update = checker.addUpdate(UPDATE_NAME, update_d, current_version, target_version, alternate_rdl, Update.RESTART_REQUIRED_YES);
update.setDescriptionURL(sf_details.getInfoURL());
alternate_rdl.addListener(new ResourceDownloaderAdapter() {
@Override
public boolean completed(final ResourceDownloader downloader, InputStream data) {
installUpdate(checker, update, downloader, data);
return (true);
}
@Override
public void failed(ResourceDownloader downloader, ResourceDownloaderException e) {
Debug.out(downloader.getName() + " failed", e);
update.complete(false);
}
});
}
} catch (Throwable e) {
Debug.printStackTrace(e);
checker.reportProgress("Failed to load plugin details for the platform manager: " + Debug.getNestedExceptionMessage(e));
checker.failed();
} finally {
checker.completed();
}
}
use of com.biglybt.core.logging.LogEvent in project BiglyBT by BiglySoftware.
the class SFPluginDetailsLoaderImpl method loadPluginList.
protected void loadPluginList() throws SFPluginDetailsException {
try {
String page_url_to_use = addEPIDS(page_url);
URL original_url = new URL(page_url_to_use);
URL url = original_url;
Proxy proxy = null;
PluginProxy plugin_proxy = null;
boolean tried_proxy = false;
boolean ok = false;
if (COConfigurationManager.getBooleanParameter("update.anonymous")) {
tried_proxy = true;
plugin_proxy = AEProxyFactory.getPluginProxy("loading plugin details", url);
if (plugin_proxy == null) {
throw (new SFPluginDetailsException("Proxy not available"));
} else {
url = plugin_proxy.getURL();
proxy = plugin_proxy.getProxy();
}
}
try {
while (true) {
try {
ResourceDownloader dl = rd_factory.create(url, proxy);
if (plugin_proxy != null) {
dl.setProperty("URL_HOST", plugin_proxy.getURLHostRewrite());
}
dl = rd_factory.getRetryDownloader(dl, 5);
dl.addListener(this);
Properties details = new Properties();
InputStream is = dl.download();
details.load(is);
is.close();
Iterator it = details.keySet().iterator();
while (it.hasNext()) {
String plugin_id = (String) it.next();
String data = (String) details.get(plugin_id);
int pos = 0;
List bits = new ArrayList();
while (pos < data.length()) {
int p1 = data.indexOf(';', pos);
if (p1 == -1) {
bits.add(data.substring(pos).trim());
break;
} else {
bits.add(data.substring(pos, p1).trim());
pos = p1 + 1;
}
}
if (bits.size() < 3) {
Logger.log(new LogEvent(LOGID, LogEvent.LT_ERROR, "SF loadPluginList failed for plugin '" + plugin_id + "'. Details array is " + bits.size() + " (3 min)"));
} else {
String version = (String) bits.get(0);
String cvs_version = (String) bits.get(1);
String name = (String) bits.get(2);
String category = "";
if (bits.size() > 3) {
category = (String) bits.get(3);
}
plugin_ids.add(plugin_id);
plugin_map.put(plugin_id.toLowerCase(MessageText.LOCALE_ENGLISH), new SFPluginDetailsImpl(this, plugin_id, version, cvs_version, name, category));
}
}
ok = true;
break;
} catch (Throwable e) {
if (!tried_proxy) {
tried_proxy = true;
plugin_proxy = AEProxyFactory.getPluginProxy("loading plugin details", url);
if (plugin_proxy == null) {
throw (e);
} else {
url = plugin_proxy.getURL();
proxy = plugin_proxy.getProxy();
}
} else {
throw (e);
}
}
}
} finally {
if (plugin_proxy != null) {
plugin_proxy.setOK(ok);
}
}
plugin_ids_loaded = true;
plugin_ids_loaded_at = SystemTime.getCurrentTime();
} catch (Throwable e) {
Debug.printStackTrace(e);
throw (new SFPluginDetailsException("Plugin list load failed", e));
}
}
Aggregations