* @param url
*
* @since 3.0.1.5
*/
private void downloadFiltersAsync(URL url) {
ResourceDownloader rd = ResourceDownloaderFactoryImpl.getSingleton().create(
url);
// old dl exists, load old one while new one downloads async
rd.addListener(new ResourceDownloaderAdapter() {
// @see org.gudy.azureus2.plugins.utils.resourcedownloader.ResourceDownloaderAdapter#reportPercentComplete(org.gudy.azureus2.plugins.utils.resourcedownloader.ResourceDownloader, int)
public void reportPercentComplete(ResourceDownloader downloader,
int percentage) {
}
public boolean completed(ResourceDownloader downloader, InputStream data) {
try {
setNextAutoDownload(true);
Logger.log(new LogEvent(LOGID, "downloaded..waiting"));
// since this is a different thread, we can use class_mon as
// a cheap semaphore to wait until previous load completes
class_mon.enter();
Logger.log(new LogEvent(LOGID, "downloaded.. copying"));
try {
FileUtil.copyFile(data, FileUtil.getUserFile("ipfilter.dl"));
AEThread thread = new AEThread("reload ipfilters", true) {
public void runSupport() {
try {
UIFunctions uif = UIFunctionsManager.getUIFunctions();
if (uif != null) {
uif.setStatusText("Reloading Filters..");
}
ipFilter.reload(false);
if (uif != null) {
uif.setStatusText(null);
}
} catch (Exception e) {
Debug.out(e);
}
}
};
thread.setPriority(Thread.NORM_PRIORITY - 1);
thread.start();
} catch (Exception e) {
Debug.out(e);
}
} finally {
class_mon.exit();
}
return true;
}
});
rd.asyncDownload();
}