use of com.biglybt.core.metasearch.impl.web.WebEngine in project BiglyBT by BiglySoftware.
the class SubscriptionManagerUI method showProperties.
protected static void showProperties(Subscription subs) {
SubscriptionHistory history = subs.getHistory();
SimpleDateFormat df = new SimpleDateFormat();
String last_error = history.getLastError();
if (last_error == null) {
last_error = "";
}
String engine_str;
String auth_str = String.valueOf(false);
try {
Engine engine = subs.getEngine();
engine_str = engine.getNameEx();
if (engine instanceof WebEngine) {
WebEngine web_engine = (WebEngine) engine;
if (web_engine.isNeedsAuth()) {
auth_str = String.valueOf(true) + ": cookies=" + toString(web_engine.getRequiredCookies());
}
}
engine_str += ", eid=" + engine.getId();
} catch (Throwable e) {
engine_str = "Unknown";
auth_str = "";
}
String[] keys = { "subs.prop.enabled", "subs.prop.is_public", "subs.prop.is_auto", "subs.prop.is_auto_ok", "subs.prop.is_dl_anon", "subs.prop.update_period", "subs.prop.last_scan", "subs.prop.last_result", "subs.prop.next_scan", "subs.prop.last_error", "subs.prop.num_read", "subs.prop.num_unread", "label.max.results", "subs.prop.assoc", "subs.prop.version", "subs.prop.high_version", "subscriptions.listwindow.popularity", "subs.prop.template", "subs.prop.auth", "TableColumn.header.category", "TableColumn.header.tag.name", "subs.prop.query" };
String category_str;
String category = subs.getCategory();
if (category == null) {
category_str = MessageText.getString("Categories.uncategorized");
} else {
category_str = category;
}
Tag tag = TagManagerFactory.getTagManager().lookupTagByUID(subs.getTagID());
String tag_str = tag == null ? "" : tag.getTagName(true);
int check_freq = history.getCheckFrequencyMins();
long last_new_result = history.getLastNewResultTime();
long next_scan = history.getNextScanTime();
int max_results = history.getMaxNonDeletedResults();
if (max_results < 0) {
SubscriptionManager subs_man = SubscriptionManagerFactory.getSingleton();
max_results = subs_man.getMaxNonDeletedResults();
}
String max_results_str = (max_results == 0 ? MessageText.getString("ConfigView.unlimited") : String.valueOf(max_results));
String[] values = { String.valueOf(history.isEnabled()), String.valueOf(subs.isPublic()) + "/" + (!subs.isAnonymous()), String.valueOf(history.isAutoDownload()), String.valueOf(subs.isAutoDownloadSupported()), String.valueOf(history.getDownloadNetworks() != null), (check_freq == Integer.MAX_VALUE ? "" : (String.valueOf(history.getCheckFrequencyMins() + " " + MessageText.getString("ConfigView.text.minutes")))), df.format(new Date(history.getLastScanTime())), (last_new_result == 0 ? "" : df.format(new Date(last_new_result))), (next_scan == Long.MAX_VALUE ? "" : df.format(new Date(next_scan))), (last_error.length() == 0 ? MessageText.getString("label.none") : last_error), String.valueOf(history.getNumRead()), String.valueOf(history.getNumUnread()), max_results_str, String.valueOf(subs.getAssociationCount()), String.valueOf(subs.getVersion()), subs.getHighestVersion() > subs.getVersion() ? String.valueOf(subs.getHighestVersion()) : null, subs.getCachedPopularity() <= 1 ? "-" : String.valueOf(subs.getCachedPopularity()), engine_str + ", sid=" + subs.getID(), auth_str, category_str, tag_str, subs.getQueryKey() };
final PropertiesWindow pw = new PropertiesWindow(subs.getName(), keys, values);
try {
// kick off a popularity update
subs.getPopularity(new SubscriptionPopularityListener() {
@Override
public void gotPopularity(long popularity) {
pw.updateProperty("subscriptions.listwindow.popularity", String.valueOf(popularity));
}
@Override
public void failed(SubscriptionException error) {
}
});
} catch (Throwable e) {
}
}
Aggregations