Search in sources :

Example 16 with Subscription

use of com.biglybt.core.subs.Subscription in project BiglyBT by BiglySoftware.

the class SearchUtils method showCreateSubscriptionDialog.

public static void showCreateSubscriptionDialog(final long engineID, final String searchTerm, final Map optionalFilters) {
    final SkinnedDialog dialog = new SkinnedDialog("skin3_dlg_create_search_subscription", "shell", SWT.DIALOG_TRIM);
    SWTSkin skin = dialog.getSkin();
    final SWTSkinObjectTextbox tb = (SWTSkinObjectTextbox) skin.getSkinObject("sub-name");
    final SWTSkinObjectCheckbox cbShare = (SWTSkinObjectCheckbox) skin.getSkinObject("sub-share");
    final SWTSkinObjectCheckbox cbAutoDL = (SWTSkinObjectCheckbox) skin.getSkinObject("sub-autodl");
    SWTSkinObject soEngineArea = skin.getSkinObject("sub-engine-area");
    final SWTSkinObjectCombo soEngines = (SWTSkinObjectCombo) skin.getSkinObject("sub-engine");
    if (tb == null || cbShare == null || cbAutoDL == null) {
        return;
    }
    boolean hasEngineID = engineID >= 0;
    soEngineArea.setVisible(!hasEngineID);
    final Map<Integer, Engine> mapEngines = new HashMap<>();
    if (!hasEngineID) {
        Engine[] engines = MetaSearchManagerFactory.getSingleton().getMetaSearch().getEngines(true, false);
        List<String> list = new ArrayList<>();
        int pos = 0;
        for (Engine engine : engines) {
            mapEngines.put(pos++, engine);
            list.add(engine.getName());
        }
        soEngines.setList(list.toArray(new String[list.size()]));
    }
    cbShare.setChecked(COConfigurationManager.getBooleanParameter("sub.sharing.default.checked"));
    cbAutoDL.setChecked(COConfigurationManager.getBooleanParameter("sub.autodl.default.checked"));
    SWTSkinObject soButtonArea = skin.getSkinObject("bottom-area");
    if (soButtonArea instanceof SWTSkinObjectContainer) {
        StandardButtonsArea buttonsArea = new StandardButtonsArea() {

            // @see StandardButtonsArea#clicked(int)
            @Override
            protected void clicked(int buttonValue) {
                if (buttonValue == SWT.OK) {
                    String name = tb.getText().trim();
                    boolean isShared = cbShare.isChecked();
                    boolean autoDL = cbAutoDL.isChecked();
                    long realEngineID = engineID;
                    if (engineID <= 0) {
                        int engineIndex = soEngines.getComboControl().getSelectionIndex();
                        if (engineIndex < 0) {
                            // TODO: Flicker combobox
                            return;
                        }
                        realEngineID = mapEngines.get(engineIndex).getId();
                    }
                    Map<String, Object> payload = new HashMap<>();
                    payload.put("engine_id", realEngineID);
                    payload.put("search_term", searchTerm);
                    Map<String, Object> mapSchedule = new HashMap<>();
                    mapSchedule.put("days", Collections.EMPTY_LIST);
                    // minutes
                    mapSchedule.put("interval", 120);
                    payload.put("schedule", mapSchedule);
                    Map<String, Object> mapOptions = new HashMap<>();
                    mapOptions.put("auto_dl", autoDL);
                    payload.put("options", mapOptions);
                    Map<String, Object> mapFilters = new HashMap<>();
                    if (optionalFilters != null) {
                        mapFilters.putAll(optionalFilters);
                    }
                    payload.put("filters", mapFilters);
                    try {
                        Subscription subs;
                        subs = SubscriptionManagerFactory.getSingleton().create(name, isShared, JSONUtils.encodeToJSON(payload));
                        subs.getHistory().setDetails(true, autoDL);
                        subs.requestAttention();
                    } catch (SubscriptionException e) {
                    }
                }
                dialog.close();
            }
        };
        buttonsArea.setButtonIDs(new String[] { MessageText.getString("Button.add"), MessageText.getString("Button.cancel") });
        buttonsArea.setButtonVals(new Integer[] { SWT.OK, SWT.CANCEL });
        buttonsArea.swt_createButtons(((SWTSkinObjectContainer) soButtonArea).getComposite());
    }
    dialog.open();
}
Also used : SubscriptionException(com.biglybt.core.subs.SubscriptionException) SkinnedDialog(com.biglybt.ui.swt.views.skin.SkinnedDialog) StandardButtonsArea(com.biglybt.ui.swt.views.skin.StandardButtonsArea) Subscription(com.biglybt.core.subs.Subscription) WebEngine(com.biglybt.core.metasearch.impl.web.WebEngine) Engine(com.biglybt.core.metasearch.Engine) PluginEngine(com.biglybt.core.metasearch.impl.plugin.PluginEngine)

Example 17 with Subscription

use of com.biglybt.core.subs.Subscription in project BiglyBT by BiglySoftware.

the class SBC_SubscriptionResultsView method dataSourceChanged.

@Override
public Object dataSourceChanged(SWTSkinObject skinObject, Object params) {
    synchronized (this) {
        Subscription new_ds = null;
        if (params instanceof Subscription) {
            new_ds = (Subscription) params;
        } else if (params instanceof Object[]) {
            Object[] objs = (Object[]) params;
            if (objs.length == 1 && objs[0] instanceof Subscription) {
                new_ds = (Subscription) objs[0];
            }
        }
        if (ds != null) {
            ds.removeListener(this);
        }
        ds = new_ds;
        if (new_ds != null) {
            ds.addListener(this);
        }
    }
    return (super.dataSourceChanged(skinObject, params));
}
Also used : Subscription(com.biglybt.core.subs.Subscription)

Example 18 with Subscription

use of com.biglybt.core.subs.Subscription in project BiglyBT by BiglySoftware.

the class SubscriptionListWindow method startChecking.

private void startChecking() {
    action.setText(MessageText.getString("subscriptions.listwindow.subscribe"));
    action.setEnabled(false);
    try {
        SubscriptionManager subs_man = SubscriptionManagerFactory.getSingleton();
        if (useCachedSubs) {
            Subscription[] subs = subs_man.getKnownSubscriptions(torrent_hash);
            complete(torrent_hash, subs);
        } else {
            lookup = subs_man.lookupAssociations(torrent_hash, display_name, networks, this);
            lookup.setTimeout(1 * 60 * 1000);
        }
        loadingDone = false;
        AEThread2 progressMover = new AEThread2("progressMover", true) {

            @Override
            public void run() {
                final int[] waitTime = new int[1];
                waitTime[0] = 100;
                while (!loadingDone) {
                    if (display != null && !display.isDisposed()) {
                        display.asyncExec(new Runnable() {

                            @Override
                            public void run() {
                                if (loadingProgress != null && !loadingProgress.isDisposed()) {
                                    int currentSelection = loadingProgress.getSelection() + 1;
                                    loadingProgress.setSelection(currentSelection);
                                    if (currentSelection > (loadingProgress.getMaximum()) * 80 / 100) {
                                        waitTime[0] = 300;
                                    }
                                    if (currentSelection > (loadingProgress.getMaximum()) * 90 / 100) {
                                        waitTime[0] = 1000;
                                    }
                                } else {
                                    loadingDone = true;
                                }
                            }
                        });
                    }
                    try {
                        Thread.sleep(waitTime[0]);
                    // Thread.sleep(100);
                    } catch (Exception e) {
                        loadingDone = true;
                    }
                }
            }
        };
        progressMover.start();
    } catch (Exception e) {
        failed(null, null);
    }
    animatedImage.start();
    mainLayout.topControl = loadingPanel;
}
Also used : SubscriptionManager(com.biglybt.core.subs.SubscriptionManager) Subscription(com.biglybt.core.subs.Subscription) AEThread2(com.biglybt.core.util.AEThread2) SubscriptionException(com.biglybt.core.subs.SubscriptionException)

Example 19 with Subscription

use of com.biglybt.core.subs.Subscription in project BiglyBT by BiglySoftware.

the class EngineImpl method getSubscription.

@Override
public Subscription getSubscription() {
    try {
        VuzeFile vf = exportToVuzeFile(true);
        byte[] bytes = vf.exportToBytes();
        String url_str = "vuze://?body=" + new String(bytes, Constants.BYTE_ENCODING);
        boolean is_anon = isAnonymous();
        SubscriptionManager sub_man = SubscriptionManagerFactory.getSingleton();
        Subscription subs = sub_man.createSingletonRSS(vf.getName() + ": " + getName() + " (v" + getVersion() + ")", new URL(url_str), Integer.MAX_VALUE, is_anon);
        return (subs);
    } catch (Throwable e) {
        Debug.out(e);
    }
    return (null);
}
Also used : VuzeFile(com.biglybt.core.vuzefile.VuzeFile) SubscriptionManager(com.biglybt.core.subs.SubscriptionManager) Subscription(com.biglybt.core.subs.Subscription) URL(java.net.URL)

Example 20 with Subscription

use of com.biglybt.core.subs.Subscription in project BiglyBT by BiglySoftware.

the class MetaSearchManagerImpl method checkPotentialAssociations.

void checkPotentialAssociations(byte[] hash, String key) {
    EngineImpl engine;
    synchronized (potential_associations) {
        engine = potential_associations.remove(key);
    }
    if (engine != null) {
        Subscription subs = engine.getSubscription();
        if (subs != null) {
            subs.setSubscribed(true);
            subs.addAssociation(hash);
        }
    }
}
Also used : Subscription(com.biglybt.core.subs.Subscription)

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