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