Search in sources :

Example 11 with Subscription

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);
                }
            }
        }
    }
}
Also used : MultipleDocumentInterface(com.biglybt.ui.mdi.MultipleDocumentInterface) Subscription(com.biglybt.core.subs.Subscription)

Example 12 with Subscription

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);
}
Also used : Rectangle(org.eclipse.swt.graphics.Rectangle) ImageLoader(com.biglybt.ui.swt.imageloader.ImageLoader) Image(org.eclipse.swt.graphics.Image) Subscription(com.biglybt.core.subs.Subscription)

Example 13 with Subscription

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;
}
Also used : Subscription(com.biglybt.core.subs.Subscription)

Example 14 with Subscription

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;
}
Also used : Subscription(com.biglybt.core.subs.Subscription)

Example 15 with Subscription

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);
                }
            }
        }
    });
}
Also used : UserPrompterResultListener(com.biglybt.ui.UserPrompterResultListener) Subscription(com.biglybt.core.subs.Subscription) WebEngine(com.biglybt.core.metasearch.impl.web.WebEngine) Engine(com.biglybt.core.metasearch.Engine) WebEngine(com.biglybt.core.metasearch.impl.web.WebEngine) URL(java.net.URL) SBC_SubscriptionResult(com.biglybt.ui.swt.subscriptions.SBC_SubscriptionResult)

Aggregations

Subscription (com.biglybt.core.subs.Subscription)34 WebEngine (com.biglybt.core.metasearch.impl.web.WebEngine)7 Engine (com.biglybt.core.metasearch.Engine)5 SubscriptionException (com.biglybt.core.subs.SubscriptionException)5 VuzeFile (com.biglybt.core.vuzefile.VuzeFile)4 URL (java.net.URL)4 Rectangle (org.eclipse.swt.graphics.Rectangle)4 PluginEngine (com.biglybt.core.metasearch.impl.plugin.PluginEngine)3 SubscriptionHistory (com.biglybt.core.subs.SubscriptionHistory)3 SubscriptionResult (com.biglybt.core.subs.SubscriptionResult)3 AERunnable (com.biglybt.core.util.AERunnable)3 TableCellAddedListener (com.biglybt.pif.ui.tables.TableCellAddedListener)3 TableCellRefreshListener (com.biglybt.pif.ui.tables.TableCellRefreshListener)3 TableColumnCreationListener (com.biglybt.pif.ui.tables.TableColumnCreationListener)3 MultipleDocumentInterface (com.biglybt.ui.mdi.MultipleDocumentInterface)3 TableCellSWTPaintListener (com.biglybt.ui.swt.views.table.TableCellSWTPaintListener)3 FormAttachment (org.eclipse.swt.layout.FormAttachment)3 FormData (org.eclipse.swt.layout.FormData)3 FormLayout (org.eclipse.swt.layout.FormLayout)3 Event (org.eclipse.swt.widgets.Event)3