use of com.biglybt.core.subs.Subscription in project BiglyBT by BiglySoftware.
the class ColumnSubscriptionName method cellMouseTrigger.
@Override
public void cellMouseTrigger(TableCellMouseEvent event) {
if (event.eventType == TableCellMouseEvent.EVENT_MOUSEUP && event.button == 1) {
TableCell cell = event.cell;
int cellWidth = cell.getWidth();
if (event.x > cellWidth - imageWidth - 5 && event.x < cellWidth - 5) {
Subscription sub = (Subscription) cell.getDataSource();
if (sub != null && !sub.isSearchTemplate()) {
String key = "Subscription_" + ByteFormatter.encodeString(sub.getPublicKey());
MultipleDocumentInterface mdi = UIFunctionsManager.getUIFunctions().getMDI();
if (mdi != null) {
mdi.showEntryByID(key);
}
}
}
}
}
use of com.biglybt.core.subs.Subscription in project BiglyBT by BiglySoftware.
the class ColumnSubscriptionName method cellPaint.
@Override
public void cellPaint(GC gc, TableCellSWT cell) {
Rectangle bounds = cell.getBounds();
ImageLoader imageLoader = ImageLoader.getInstance();
Image viewImage = imageLoader.getImage("ic_view");
if (imageWidth == -1 || imageHeight == -1) {
imageWidth = viewImage.getBounds().width;
imageHeight = viewImage.getBounds().height;
}
bounds.width -= (imageWidth + 5);
GCStringPrinter.printString(gc, cell.getSortValue().toString(), bounds, true, false, SWT.LEFT);
Subscription sub = (Subscription) cell.getDataSource();
if (sub != null && !sub.isSearchTemplate()) {
gc.drawImage(viewImage, bounds.x + bounds.width, bounds.y + bounds.height / 2 - imageHeight / 2);
}
imageLoader.releaseImage("ic_view");
// gc.drawText(cell.getText(), bounds.x,bounds.y);
}
use of com.biglybt.core.subs.Subscription in project BiglyBT by BiglySoftware.
the class ColumnSubscriptionNbNewResults method refresh.
@Override
public void refresh(TableCell cell) {
int nbResults = 0;
Subscription sub = (Subscription) cell.getDataSource();
if (sub != null) {
if (sub.isSearchTemplate()) {
nbResults = -1;
} else {
nbResults = sub.getHistory().getNumUnread();
}
}
if (!cell.setSortValue(nbResults) && cell.isValid()) {
return;
}
if (!cell.isShown()) {
return;
}
if (sub.isSearchTemplate()) {
cell.setText("");
} else {
cell.setText("" + nbResults);
}
return;
}
use of com.biglybt.core.subs.Subscription in project BiglyBT by BiglySoftware.
the class ColumnSubscriptionNbResults method refresh.
@Override
public void refresh(TableCell cell) {
int nbResults = 0;
Subscription sub = (Subscription) cell.getDataSource();
if (sub != null) {
nbResults = sub.getHistory().getNumUnread() + sub.getHistory().getNumRead();
}
if (!cell.setSortValue(nbResults) && cell.isValid()) {
return;
}
if (!cell.isShown()) {
return;
}
if (sub.isSearchTemplate()) {
cell.setText("");
} else {
cell.setText("" + nbResults);
}
return;
}
use of com.biglybt.core.subs.Subscription 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);
}
}
}
});
}
Aggregations