use of com.biglybt.core.subs.SubscriptionManager in project BiglyBT by BiglySoftware.
the class AZPluginConnection method connect.
@Override
public void connect() throws IOException {
String url = getURL().toString();
int pos = url.indexOf("?");
if (pos == -1) {
throw (new IOException("Malformed URL - ? missing"));
}
url = url.substring(pos + 1);
String[] bits = url.split("&");
Map args = new HashMap();
for (int i = 0; i < bits.length; i++) {
String bit = bits[i];
String[] x = bit.split("=");
if (x.length == 2) {
String lhs = x[0];
String rhs = UrlUtils.decode(x[1]);
args.put(lhs.toLowerCase(), rhs);
}
}
String plugin_id = (String) args.get("id");
if (plugin_id == null) {
throw (new IOException("Plugin id missing"));
}
String plugin_name = (String) args.get("name");
String arg = (String) args.get("arg");
if (arg == null) {
arg = "";
}
String plugin_str;
if (plugin_name == null) {
plugin_str = "with id '" + plugin_id + "'";
} else {
plugin_str = "'" + plugin_name + "' (id " + plugin_id + ")";
}
if (plugin_id.equals("subscription")) {
SubscriptionManager manager = SubscriptionManagerFactory.getSingleton();
if (manager == null) {
throw (new IOException("Subscriptions are not available"));
}
try {
manager.subscribeToSubscription(arg);
input_stream = new ByteArrayInputStream(VuzeFileHandler.getSingleton().create().exportToBytes());
} catch (Throwable e) {
throw (new IOException("Subscription addition failed: " + Debug.getNestedExceptionMessage(e)));
}
} else {
// AZPluginConnection is called via reflection
// Let's just assume that the Core is avail..
PluginInterface pi = CoreFactory.getSingleton().getPluginManager().getPluginInterfaceByID(plugin_id);
if (pi == null) {
throw (new IOException("Plugin " + plugin_str + " is required - go to 'Tools->Plugins->Installation Wizard' to install."));
}
IPCInterface ipc = pi.getIPC();
try {
if (ipc.canInvoke("handleURLProtocol", new Object[] { this, arg })) {
input_stream = (InputStream) ipc.invoke("handleURLProtocol", new Object[] { this, arg });
} else {
input_stream = (InputStream) ipc.invoke("handleURLProtocol", new Object[] { arg });
}
} catch (IPCException ipce) {
Throwable e = ipce;
if (e.getCause() != null) {
e = e.getCause();
}
throw (new IOException("Communication error with plugin '" + plugin_str + "': " + Debug.getNestedExceptionMessage(e)));
}
}
}
use of com.biglybt.core.subs.SubscriptionManager 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.SubscriptionManager 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);
}
Aggregations