use of com.biglybt.ui.swt.subscriptions.SBC_SubscriptionResult in project BiglyBT by BiglySoftware.
the class SBC_SearchResultsView method downloadAction.
public static void downloadAction(final SearchSubsResultBase entry) {
String link = entry.getTorrentLink();
if (link.startsWith("chat:")) {
Utils.launch(link);
return;
}
showDownloadFTUX(entry, new UserPrompterResultListener() {
@Override
public void prompterClosed(int result) {
if (result == 0) {
String referer_str = null;
String torrentUrl = entry.getTorrentLink();
try {
Map headers = UrlUtils.getBrowserHeaders(referer_str);
if (entry instanceof SBC_SubscriptionResult) {
SBC_SubscriptionResult sub_entry = (SBC_SubscriptionResult) entry;
Subscription subs = sub_entry.getSubscription();
try {
Engine engine = subs.getEngine();
if (engine != null && engine instanceof WebEngine) {
WebEngine webEngine = (WebEngine) engine;
if (webEngine.isNeedsAuth()) {
headers.put("Cookie", webEngine.getCookies());
}
}
} catch (Throwable e) {
Debug.out(e);
}
subs.addPotentialAssociation(sub_entry.getID(), torrentUrl);
} else {
SBC_SearchResult search_entry = (SBC_SearchResult) entry;
Engine engine = search_entry.getEngine();
if (engine != null) {
engine.addPotentialAssociation(torrentUrl);
if (engine instanceof WebEngine) {
WebEngine webEngine = (WebEngine) engine;
if (webEngine.isNeedsAuth()) {
headers.put("Cookie", webEngine.getCookies());
}
}
}
}
byte[] torrent_hash = entry.getHash();
if (torrent_hash != null) {
if (torrent_hash != null && !torrentUrl.toLowerCase().startsWith("magnet")) {
String title = entry.getName();
String magnet = UrlUtils.getMagnetURI(torrent_hash, title, null);
headers.put("X-Alternative-URI-1", magnet);
}
}
PluginInitializer.getDefaultInterface().getDownloadManager().addDownload(new URL(torrentUrl), headers);
} catch (Throwable e) {
Debug.out(e);
}
}
}
});
}
use of com.biglybt.ui.swt.subscriptions.SBC_SubscriptionResult in project BiglyBT by BiglySoftware.
the class ColumnSubResultNew method refresh.
@Override
public void refresh(TableCell cell) {
SBC_SubscriptionResult entry = (SBC_SubscriptionResult) cell.getDataSource();
if (entry != null) {
boolean unread = !entry.getRead();
long sortVal = ((unread ? 2 : 1L) << 61) + (SystemTime.getCurrentTime() - entry.getTime()) / 1000;
cell.setSortValue(sortVal);
}
}
use of com.biglybt.ui.swt.subscriptions.SBC_SubscriptionResult in project BiglyBT by BiglySoftware.
the class ColumnSubResultNew method cellMouseTrigger.
@Override
public void cellMouseTrigger(final TableCellMouseEvent event) {
if (event.eventType == TableRowMouseEvent.EVENT_MOUSEDOWN && event.button == 1) {
SBC_SubscriptionResult entry = (SBC_SubscriptionResult) event.cell.getDataSource();
if (entry != null) {
entry.setRead(!entry.getRead());
event.cell.invalidate();
}
}
}
use of com.biglybt.ui.swt.subscriptions.SBC_SubscriptionResult in project BiglyBT by BiglySoftware.
the class ColumnSubResultNew method cellPaint.
@Override
public void cellPaint(GC gc, TableCellSWT cell) {
SBC_SubscriptionResult entry = (SBC_SubscriptionResult) cell.getDataSource();
Rectangle cellBounds = cell.getBounds();
Image img = entry == null || entry.getRead() ? imgOld : imgNew;
if (img != null && !img.isDisposed()) {
Rectangle imgBounds = img.getBounds();
gc.drawImage(img, cellBounds.x + ((cellBounds.width - imgBounds.width) / 2), cellBounds.y + ((cellBounds.height - imgBounds.height) / 2));
}
}
use of com.biglybt.ui.swt.subscriptions.SBC_SubscriptionResult in project BiglyBT by BiglySoftware.
the class SBC_SearchResultsView method showDownloadFTUX.
protected static void showDownloadFTUX(SearchSubsResultBase entry, final UserPrompterResultListener listener) {
if (entry instanceof SBC_SubscriptionResult) {
listener.prompterClosed(0);
return;
}
if (RememberedDecisionsManager.getRememberedDecision("searchsubs.dl.ftux") == 1) {
listener.prompterClosed(0);
return;
}
final VuzeMessageBox box = new VuzeMessageBox(MessageText.getString("searchsubs.dl.ftux.title"), null, new String[] { MessageText.getString("Button.ok"), MessageText.getString("Button.cancel") }, 0);
box.setSubTitle(MessageText.getString("searchsubs.dl.ftux.heading"));
final boolean[] check_state = new boolean[] { true };
box.setListener(new VuzeMessageBoxListener() {
@Override
public void shellReady(Shell shell, SWTSkinObjectContainer soExtra) {
SWTSkin skin = soExtra.getSkin();
addResourceBundle(skin, "com/biglybt/ui/swt/columns/searchsubs/", "skin3_dl_ftux");
String id = "searchsubs.dlftux.shell";
skin.createSkinObject(id, id, soExtra);
final SWTSkinObjectCheckbox cb = (SWTSkinObjectCheckbox) skin.getSkinObject("agree-checkbox");
cb.setChecked(true);
cb.addSelectionListener(new SWTSkinCheckboxListener() {
@Override
public void checkboxChanged(SWTSkinObjectCheckbox so, boolean checked) {
check_state[0] = checked;
}
});
}
});
box.open(new UserPrompterResultListener() {
@Override
public void prompterClosed(int result) {
if (result == 0 && check_state[0]) {
RememberedDecisionsManager.setRemembered("searchsubs.dl.ftux", 1);
}
listener.prompterClosed(result);
}
});
}
Aggregations