use of com.biglybt.core.CoreRunningListener in project BiglyBT by BiglySoftware.
the class TopBarView method skinObjectInitialShow.
@Override
public Object skinObjectInitialShow(SWTSkinObject skinObject, Object params) {
this.skin = skinObject.getSkin();
skin.addListener("topbar-plugins", new SWTSkinObjectListener() {
@Override
public Object eventOccured(SWTSkinObject skinObject, int eventType, Object params) {
if (eventType == SWTSkinObjectListener.EVENT_SHOW) {
skin.removeListener("topbar-plugins", this);
// building needs UISWTInstance, which needs core.
CoreFactory.addCoreRunningListener(new CoreRunningListener() {
@Override
public void coreRunning(Core core) {
Utils.execSWTThreadLater(0, new AERunnable() {
@Override
public void runSupport() {
buildTopBarViews();
}
});
}
});
}
return null;
}
});
// trigger autobuild and hook in events
skin.getSkinObject("topbar-area-plugin").addListener(new SWTSkinObjectListener() {
@Override
public Object eventOccured(SWTSkinObject skinObject, int eventType, Object params) {
if (eventType == SWTSkinObjectListener.EVENT_SHOW) {
if (activeTopBar != null) {
activeTopBar.triggerEvent(UISWTViewEvent.TYPE_FOCUSGAINED, null);
}
} else if (eventType == SWTSkinObjectListener.EVENT_HIDE) {
if (activeTopBar != null) {
activeTopBar.triggerEvent(UISWTViewEvent.TYPE_FOCUSLOST, null);
}
}
return (null);
}
});
return null;
}
use of com.biglybt.core.CoreRunningListener in project BiglyBT by BiglySoftware.
the class TagPropertyConstraintHandler method checkTimer.
private void checkTimer() {
if (constrained_tags.size() > 0) {
if (timer == null) {
timer = SimpleTimer.addPeriodicEvent("tag:constraint:timer", 30 * 1000, new TimerEventPerformer() {
@Override
public void perform(TimerEvent event) {
apply_history.clear();
apply();
}
});
CoreFactory.addCoreRunningListener(new CoreRunningListener() {
@Override
public void coreRunning(Core core) {
synchronized (constrained_tags) {
if (timer != null) {
core.getPluginManager().getDefaultPluginInterface().getDownloadManager().getGlobalDownloadEventNotifier().addListener(TagPropertyConstraintHandler.this);
dm_listener_added = true;
}
}
}
});
}
} else if (timer != null) {
timer.cancel();
timer = null;
if (dm_listener_added) {
core.getPluginManager().getDefaultPluginInterface().getDownloadManager().getGlobalDownloadEventNotifier().removeListener(this);
}
apply_history.clear();
}
}
use of com.biglybt.core.CoreRunningListener 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.CoreRunningListener 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.CoreRunningListener 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 });
}
Aggregations