Search in sources :

Example 1 with SBC_SubscriptionResult

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);
                }
            }
        }
    });
}
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)

Example 2 with SBC_SubscriptionResult

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);
    }
}
Also used : SBC_SubscriptionResult(com.biglybt.ui.swt.subscriptions.SBC_SubscriptionResult)

Example 3 with SBC_SubscriptionResult

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();
        }
    }
}
Also used : SBC_SubscriptionResult(com.biglybt.ui.swt.subscriptions.SBC_SubscriptionResult)

Example 4 with SBC_SubscriptionResult

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));
    }
}
Also used : Rectangle(org.eclipse.swt.graphics.Rectangle) Image(org.eclipse.swt.graphics.Image) SBC_SubscriptionResult(com.biglybt.ui.swt.subscriptions.SBC_SubscriptionResult)

Example 5 with SBC_SubscriptionResult

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);
        }
    });
}
Also used : SWTSkinCheckboxListener(com.biglybt.ui.swt.skin.SWTSkinCheckboxListener) SWTSkinObjectCheckbox(com.biglybt.ui.swt.skin.SWTSkinObjectCheckbox) SWTSkin(com.biglybt.ui.swt.skin.SWTSkin) Shell(org.eclipse.swt.widgets.Shell) UserPrompterResultListener(com.biglybt.ui.UserPrompterResultListener) SWTSkinObjectContainer(com.biglybt.ui.swt.skin.SWTSkinObjectContainer) VuzeMessageBoxListener(com.biglybt.ui.swt.views.skin.VuzeMessageBoxListener) VuzeMessageBox(com.biglybt.ui.swt.views.skin.VuzeMessageBox) SBC_SubscriptionResult(com.biglybt.ui.swt.subscriptions.SBC_SubscriptionResult)

Aggregations

SBC_SubscriptionResult (com.biglybt.ui.swt.subscriptions.SBC_SubscriptionResult)5 UserPrompterResultListener (com.biglybt.ui.UserPrompterResultListener)2 Engine (com.biglybt.core.metasearch.Engine)1 WebEngine (com.biglybt.core.metasearch.impl.web.WebEngine)1 Subscription (com.biglybt.core.subs.Subscription)1 SWTSkin (com.biglybt.ui.swt.skin.SWTSkin)1 SWTSkinCheckboxListener (com.biglybt.ui.swt.skin.SWTSkinCheckboxListener)1 SWTSkinObjectCheckbox (com.biglybt.ui.swt.skin.SWTSkinObjectCheckbox)1 SWTSkinObjectContainer (com.biglybt.ui.swt.skin.SWTSkinObjectContainer)1 VuzeMessageBox (com.biglybt.ui.swt.views.skin.VuzeMessageBox)1 VuzeMessageBoxListener (com.biglybt.ui.swt.views.skin.VuzeMessageBoxListener)1 URL (java.net.URL)1 Image (org.eclipse.swt.graphics.Image)1 Rectangle (org.eclipse.swt.graphics.Rectangle)1 Shell (org.eclipse.swt.widgets.Shell)1