use of com.biglybt.core.Core in project BiglyBT by BiglySoftware.
the class TorrentListener method handleMessage.
@Override
public void handleMessage(final BrowserMessage message) {
String opid = message.getOperationId();
if (OP_LOAD_TORRENT.equals(opid) || OP_LOAD_TORRENT_OLD.equals(opid)) {
final Map decodedMap = message.getDecodedMap();
String url = MapUtils.getMapString(decodedMap, "url", null);
final boolean playNow = MapUtils.getMapBoolean(decodedMap, "play-now", false);
final boolean playPrepare = MapUtils.getMapBoolean(decodedMap, "play-prepare", false);
final boolean bringToFront = MapUtils.getMapBoolean(decodedMap, "bring-to-front", true);
if (url != null) {
if (torrentURLHandler != null) {
try {
torrentURLHandler.handleTorrentURL(url);
} catch (Throwable e) {
Debug.printStackTrace(e);
}
}
final DownloadUrlInfo dlInfo = new DownloadUrlInfo(url);
dlInfo.setReferer(message.getReferer());
CoreFactory.addCoreRunningListener(new CoreRunningListener() {
@Override
public void coreRunning(Core core) {
TorrentUIUtilsV3.loadTorrent(dlInfo, playNow, playPrepare, bringToFront);
}
});
} else {
CoreFactory.addCoreRunningListener(new CoreRunningListener() {
@Override
public void coreRunning(Core core) {
loadTorrentByB64(core, message, MapUtils.getMapString(decodedMap, "b64", null));
}
});
}
} else {
throw new IllegalArgumentException("Unknown operation: " + opid);
}
}
use of com.biglybt.core.Core in project BiglyBT by BiglySoftware.
the class ConfigListener method checkForUpdates.
/**
* @since 3.0.5.3
*/
public static void checkForUpdates() {
UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
if (uiFunctions != null) {
uiFunctions.bringToFront();
}
CoreFactory.addCoreRunningListener(new CoreRunningListener() {
@Override
public void coreRunning(Core core) {
UpdateMonitor.getSingleton(core).performCheck(true, false, false, null);
}
});
}
use of com.biglybt.core.Core in project BiglyBT by BiglySoftware.
the class DeviceManagerUI method createTranscodingSection.
public void createTranscodingSection() {
// default dir
String def = device_manager.getDefaultWorkingDirectory().getAbsolutePath();
final DirectoryParameter def_work_dir = configModel.addDirectoryParameter2("device.config.xcode.workdir", "device.config.xcode.workdir", def);
def_work_dir.setValue(def);
def_work_dir.addListener(new ParameterListener() {
@Override
public void parameterChanged(Parameter param) {
device_manager.setDefaultWorkingDirectory(new File(def_work_dir.getValue()));
}
});
// max xcode
final IntParameter max_xcode = configModel.addIntParameter2("device.config.xcode.maxbps", "device.config.xcode.maxbps", (int) (device_manager.getTranscodeManager().getQueue().getMaxBytesPerSecond() / 1024), 0, Integer.MAX_VALUE);
max_xcode.addListener(new ParameterListener() {
@Override
public void parameterChanged(Parameter param) {
device_manager.getTranscodeManager().getQueue().setMaxBytesPerSecond(max_xcode.getValue() * 1024);
}
});
// disable sleep
final BooleanParameter disable_sleep = configModel.addBooleanParameter2("device.config.xcode.disable_sleep", "device.config.xcode.disable_sleep", device_manager.getDisableSleep());
disable_sleep.addListener(new ParameterListener() {
@Override
public void parameterChanged(Parameter param) {
device_manager.setDisableSleep(disable_sleep.getValue());
}
});
// itunes
final ActionParameter btnITunes = configModel.addActionParameter2("devices.button.installitunes", "UpdateWindow.columns.install");
btnITunes.setEnabled(false);
CoreFactory.addCoreRunningListener(new CoreRunningListener() {
@Override
public void coreRunning(Core core) {
boolean hasItunes = core.getPluginManager().getPluginInterfaceByID("azitunes") != null;
btnITunes.setEnabled(!hasItunes);
}
});
btnITunes.addListener(new ParameterListener() {
@Override
public void parameterChanged(Parameter param) {
CoreWaiterSWT.waitForCoreRunning(new CoreRunningListener() {
@Override
public void coreRunning(Core core) {
try {
PluginInstaller installer = core.getPluginManager().getPluginInstaller();
StandardPlugin itunes_plugin = installer.getStandardPlugin("azitunes");
if (itunes_plugin == null) {
Debug.out("iTunes standard plugin not found");
} else {
itunes_plugin.install(false);
}
} catch (Throwable e) {
Debug.printStackTrace(e);
}
}
});
}
});
configModel.createGroup("device.xcode.group", new Parameter[] { def_work_dir, max_xcode, disable_sleep, btnITunes });
}
use of com.biglybt.core.Core in project BiglyBT by BiglySoftware.
the class SBC_DevicesView method skinObjectInitialShow.
// @see SkinView#skinObjectInitialShow(SWTSkinObject, java.lang.Object)
@Override
public Object skinObjectInitialShow(SWTSkinObject skinObject, Object params) {
CoreFactory.addCoreRunningListener(new CoreRunningListener() {
@Override
public void coreRunning(Core core) {
initColumns(core);
}
});
device_manager = DeviceManagerFactory.getSingleton();
transcode_manager = device_manager.getTranscodeManager();
transcode_queue = transcode_manager.getQueue();
MultipleDocumentInterfaceSWT mdi = UIFunctionsManagerSWT.getUIFunctionsSWT().getMDISWT();
if (mdi != null) {
mdiEntry = mdi.getCurrentEntrySWT();
Object ds = mdiEntry.getDatasource();
if (!(ds instanceof Device)) {
return (null);
}
device = (Device) ds;
}
if (device instanceof TranscodeTarget) {
transTarget = (TranscodeTarget) device;
}
if (device == null) {
new InfoBarUtil(skinObject, "devicesview.infobar", false, "DeviceView.infobar", "v3.deviceview.infobar") {
@Override
public boolean allowShow() {
return true;
}
};
} else if (device instanceof DeviceMediaRenderer) {
DeviceMediaRenderer renderer = (DeviceMediaRenderer) device;
int species = renderer.getRendererSpecies();
String speciesID = null;
switch(species) {
case DeviceMediaRenderer.RS_ITUNES:
speciesID = "itunes";
break;
case DeviceMediaRenderer.RS_PS3:
speciesID = "ps3";
break;
case DeviceMediaRenderer.RS_XBOX:
speciesID = "xbox";
break;
case DeviceMediaRenderer.RS_OTHER:
{
String classification = renderer.getClassification();
if (classification.equals("sony.PSP")) {
speciesID = "psp";
} else if (classification.startsWith("tivo.")) {
speciesID = "tivo";
} else if (classification.toLowerCase().contains("android")) {
speciesID = "android";
}
}
default:
break;
}
if (speciesID != null) {
final String fSpeciesID = speciesID;
new InfoBarUtil(skinObject, "devicesview.infobar", false, "DeviceView.infobar." + speciesID, "v3.deviceview.infobar") {
@Override
public boolean allowShow() {
return true;
}
// @see InfoBarUtil#created(SWTSkinObject)
@Override
protected void created(SWTSkinObject parent) {
SWTSkinObjectText soLine1 = (SWTSkinObjectText) skin.getSkinObject("line1", parent);
soLine1.setTextID("v3.deviceview.infobar.line1.generic", new String[] { device.getName() });
SWTSkinObjectText soLine2 = (SWTSkinObjectText) skin.getSkinObject("line2", parent);
soLine2.setTextID("v3.deviceview.infobar.line2." + fSpeciesID);
}
};
}
}
SWTSkinObject soAdvInfo = getSkinObject("advinfo");
if (soAdvInfo != null) {
initAdvInfo(soAdvInfo);
}
if (device != null) {
device_name = device.getName();
SWTSkinObject soTitle = getSkinObject("title");
if (soTitle instanceof SWTSkinObjectText) {
((SWTSkinObjectText) soTitle).setTextID("device.view.heading", new String[] { device_name });
}
}
return null;
}
use of com.biglybt.core.Core in project BiglyBT by BiglySoftware.
the class BaseMDI method processAutoOpenMap.
private boolean processAutoOpenMap(String id, Map<?, ?> autoOpenInfo, IViewInfo viewInfo) {
try {
MdiEntry entry = getEntry(id);
if (entry != null) {
return true;
}
Object datasource = autoOpenInfo.get("datasource");
String title = MapUtils.getMapString(autoOpenInfo, "title", id);
MdiEntry mdiEntry = createEntryByCreationListener(id, datasource, autoOpenInfo);
if (mdiEntry != null) {
if (mdiEntry.getTitle().equals("")) {
mdiEntry.setTitle(title);
}
return true;
}
String parentID = MapUtils.getMapString(autoOpenInfo, "parentID", SIDEBAR_HEADER_PLUGINS);
if (viewInfo != null) {
if (viewInfo.event_listener != null) {
entry = createEntryFromEventListener(parentID, viewInfo.event_listener, id, true, datasource, null);
if (entry != null) {
entry.setTitle(title);
}
}
}
if (entry != null && datasource == null) {
final MdiEntry fEntry = entry;
final String dmHash = MapUtils.getMapString(autoOpenInfo, "dm", null);
if (dmHash != null) {
CoreFactory.addCoreRunningListener(new CoreRunningListener() {
@Override
public void coreRunning(Core core) {
GlobalManager gm = core.getGlobalManager();
HashWrapper hw = new HashWrapper(Base32.decode(dmHash));
DownloadManager dm = gm.getDownloadManager(hw);
if (dm != null) {
fEntry.setDatasource(dm);
}
}
});
} else {
final List<?> listHashes = MapUtils.getMapList(autoOpenInfo, "dms", null);
if (listHashes != null) {
CoreFactory.addCoreRunningListener(new CoreRunningListener() {
@Override
public void coreRunning(Core core) {
List<DownloadManager> listDMS = new ArrayList<>(1);
GlobalManager gm = core.getGlobalManager();
for (Object oDM : listHashes) {
if (oDM instanceof String) {
String hash = (String) oDM;
DownloadManager dm = gm.getDownloadManager(new HashWrapper(Base32.decode(hash)));
if (dm != null) {
listDMS.add(dm);
}
}
fEntry.setDatasource(listDMS.toArray(new DownloadManager[0]));
}
}
});
}
}
}
return entry != null;
} catch (Throwable e) {
Debug.out(e);
}
return false;
}
Aggregations