Search in sources :

Example 6 with InteractiveScriptSession

use of org.phoenicis.scripts.interpreter.InteractiveScriptSession in project POL-POM-5 by PlayOnLinux.

the class ShortcutManager method uninstallFromShortcut.

public void uninstallFromShortcut(ShortcutDTO shortcutDTO, Consumer<Exception> errorCallback) {
    final InteractiveScriptSession interactiveScriptSession = scriptInterpreter.createInteractiveSession();
    interactiveScriptSession.eval("include([\"Functions\", \"Shortcuts\", \"Reader\"]);", ignored -> interactiveScriptSession.eval("new ShortcutReader()", output -> {
        final ScriptObjectMirror shortcutReader = (ScriptObjectMirror) output;
        shortcutReader.callMember("of", shortcutDTO);
        shortcutReader.callMember("uninstall");
    }, errorCallback), errorCallback);
}
Also used : Consumer(java.util.function.Consumer) Logger(org.slf4j.Logger) LoggerFactory(org.slf4j.LoggerFactory) ShortcutDTO(org.phoenicis.library.dto.ShortcutDTO) ScriptInterpreter(org.phoenicis.scripts.interpreter.ScriptInterpreter) FileUtils(org.apache.commons.io.FileUtils) IOException(java.io.IOException) ScriptObjectMirror(jdk.nashorn.api.scripting.ScriptObjectMirror) InteractiveScriptSession(org.phoenicis.scripts.interpreter.InteractiveScriptSession) File(java.io.File) ScriptObjectMirror(jdk.nashorn.api.scripting.ScriptObjectMirror) InteractiveScriptSession(org.phoenicis.scripts.interpreter.InteractiveScriptSession)

Example 7 with InteractiveScriptSession

use of org.phoenicis.scripts.interpreter.InteractiveScriptSession in project POL-POM-5 by PlayOnLinux.

the class ShortcutRunner method stop.

public void stop(ShortcutDTO shortcutDTO, Consumer<Exception> errorCallback) {
    final InteractiveScriptSession interactiveScriptSession = scriptInterpreter.createInteractiveSession();
    interactiveScriptSession.eval("include([\"Functions\", \"Shortcuts\", \"Reader\"]);", ignored -> interactiveScriptSession.eval("new ShortcutReader()", output -> {
        final ScriptObjectMirror shortcutReader = (ScriptObjectMirror) output;
        shortcutReader.callMember("of", shortcutDTO);
        shortcutReader.callMember("stop");
    }, errorCallback), errorCallback);
}
Also used : Consumer(java.util.function.Consumer) List(java.util.List) ShortcutDTO(org.phoenicis.library.dto.ShortcutDTO) ScriptInterpreter(org.phoenicis.scripts.interpreter.ScriptInterpreter) ScriptObjectMirror(jdk.nashorn.api.scripting.ScriptObjectMirror) InteractiveScriptSession(org.phoenicis.scripts.interpreter.InteractiveScriptSession) ScriptObjectMirror(jdk.nashorn.api.scripting.ScriptObjectMirror) InteractiveScriptSession(org.phoenicis.scripts.interpreter.InteractiveScriptSession)

Example 8 with InteractiveScriptSession

use of org.phoenicis.scripts.interpreter.InteractiveScriptSession in project POL-POM-5 by PlayOnLinux.

the class WinePrefixContainerController method killProcesses.

public void killProcesses(WinePrefixContainerDTO winePrefix, Runnable doneCallback, Consumer<Exception> errorCallback) {
    final InteractiveScriptSession interactiveScriptSession = scriptInterpreter.createInteractiveSession();
    interactiveScriptSession.eval("include([\"Functions\", \"Engines\", \"Wine\"]);", ignored -> interactiveScriptSession.eval("new Wine()", output -> {
        final ScriptObjectMirror wine = (ScriptObjectMirror) output;
        wine.callMember("prefix", winePrefix.getName());
        wine.callMember("kill");
        doneCallback.run();
    }, errorCallback), errorCallback);
}
Also used : ShortcutCategoryDTO(org.phoenicis.library.dto.ShortcutCategoryDTO) RegistryWriter(org.phoenicis.win32.registry.RegistryWriter) Logger(org.slf4j.Logger) FileUtilities(org.phoenicis.tools.files.FileUtilities) LoggerFactory(org.slf4j.LoggerFactory) ScriptInterpreter(org.phoenicis.scripts.interpreter.ScriptInterpreter) IOException(java.io.IOException) HashMap(java.util.HashMap) File(java.io.File) Consumer(java.util.function.Consumer) TerminalOpener(org.phoenicis.tools.system.terminal.TerminalOpener) List(java.util.List) RegistryParameter(org.phoenicis.containers.wine.parameters.RegistryParameter) ShortcutManager(org.phoenicis.library.ShortcutManager) Map(java.util.Map) WinePrefixContainerDTO(org.phoenicis.containers.dto.WinePrefixContainerDTO) OperatingSystemFetcher(org.phoenicis.tools.system.OperatingSystemFetcher) ScriptObjectMirror(jdk.nashorn.api.scripting.ScriptObjectMirror) InteractiveScriptSession(org.phoenicis.scripts.interpreter.InteractiveScriptSession) LibraryManager(org.phoenicis.library.LibraryManager) ScriptObjectMirror(jdk.nashorn.api.scripting.ScriptObjectMirror) InteractiveScriptSession(org.phoenicis.scripts.interpreter.InteractiveScriptSession)

Example 9 with InteractiveScriptSession

use of org.phoenicis.scripts.interpreter.InteractiveScriptSession in project POL-POM-5 by PlayOnLinux.

the class EnginesSource method fetchAvailableEngines.

public void fetchAvailableEngines(Consumer<List<EngineCategoryDTO>> callback) {
    final InteractiveScriptSession interactiveScriptSession = scriptInterpreter.createInteractiveSession();
    List<EngineCategoryDTO> engines = new ArrayList<>();
    interactiveScriptSession.eval("include([\"Functions\", \"Engines\", \"Wine\"]);", ignored -> interactiveScriptSession.eval("new Wine().getAvailableVersions()", output -> {
        EngineCategoryDTO wine = new EngineCategoryDTO.Builder().withName("Wine").withDescription("Wine").withSubCategories(unSerialize(output)).build();
        engines.add(wine);
        callback.accept(engines);
    }, this::throwError), this::throwError);
}
Also used : Logger(org.slf4j.Logger) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) LoggerFactory(org.slf4j.LoggerFactory) ScriptInterpreter(org.phoenicis.scripts.interpreter.ScriptInterpreter) IOException(java.io.IOException) ArrayList(java.util.ArrayList) Consumer(java.util.function.Consumer) List(java.util.List) EngineCategoryDTO(org.phoenicis.engines.dto.EngineCategoryDTO) TypeReference(com.fasterxml.jackson.core.type.TypeReference) InteractiveScriptSession(org.phoenicis.scripts.interpreter.InteractiveScriptSession) EngineSubCategoryDTO(org.phoenicis.engines.dto.EngineSubCategoryDTO) Collections(java.util.Collections) EngineCategoryDTO(org.phoenicis.engines.dto.EngineCategoryDTO) ArrayList(java.util.ArrayList) InteractiveScriptSession(org.phoenicis.scripts.interpreter.InteractiveScriptSession)

Example 10 with InteractiveScriptSession

use of org.phoenicis.scripts.interpreter.InteractiveScriptSession in project POL-POM-5 by PlayOnLinux.

the class WinePrefixContainerController method runInPrefix.

public void runInPrefix(WinePrefixContainerDTO winePrefix, String command, Runnable doneCallback, Consumer<Exception> errorCallback) {
    final InteractiveScriptSession interactiveScriptSession = scriptInterpreter.createInteractiveSession();
    interactiveScriptSession.eval("include([\"Functions\", \"Engines\", \"Wine\"]);", ignored -> interactiveScriptSession.eval("new Wine()", output -> {
        final ScriptObjectMirror wine = (ScriptObjectMirror) output;
        wine.callMember("prefix", winePrefix.getName());
        wine.callMember("run", command);
        wine.callMember("wait");
        doneCallback.run();
    }, errorCallback), errorCallback);
}
Also used : ShortcutCategoryDTO(org.phoenicis.library.dto.ShortcutCategoryDTO) RegistryWriter(org.phoenicis.win32.registry.RegistryWriter) Logger(org.slf4j.Logger) FileUtilities(org.phoenicis.tools.files.FileUtilities) LoggerFactory(org.slf4j.LoggerFactory) ScriptInterpreter(org.phoenicis.scripts.interpreter.ScriptInterpreter) IOException(java.io.IOException) HashMap(java.util.HashMap) File(java.io.File) Consumer(java.util.function.Consumer) TerminalOpener(org.phoenicis.tools.system.terminal.TerminalOpener) List(java.util.List) RegistryParameter(org.phoenicis.containers.wine.parameters.RegistryParameter) ShortcutManager(org.phoenicis.library.ShortcutManager) Map(java.util.Map) WinePrefixContainerDTO(org.phoenicis.containers.dto.WinePrefixContainerDTO) OperatingSystemFetcher(org.phoenicis.tools.system.OperatingSystemFetcher) ScriptObjectMirror(jdk.nashorn.api.scripting.ScriptObjectMirror) InteractiveScriptSession(org.phoenicis.scripts.interpreter.InteractiveScriptSession) LibraryManager(org.phoenicis.library.LibraryManager) ScriptObjectMirror(jdk.nashorn.api.scripting.ScriptObjectMirror) InteractiveScriptSession(org.phoenicis.scripts.interpreter.InteractiveScriptSession)

Aggregations

InteractiveScriptSession (org.phoenicis.scripts.interpreter.InteractiveScriptSession)13 Consumer (java.util.function.Consumer)12 ScriptInterpreter (org.phoenicis.scripts.interpreter.ScriptInterpreter)12 List (java.util.List)11 ScriptObjectMirror (jdk.nashorn.api.scripting.ScriptObjectMirror)11 IOException (java.io.IOException)10 LoggerFactory (org.slf4j.LoggerFactory)10 File (java.io.File)9 Logger (org.slf4j.Logger)8 HashMap (java.util.HashMap)6 Map (java.util.Map)6 WinePrefixContainerDTO (org.phoenicis.containers.dto.WinePrefixContainerDTO)6 RegistryParameter (org.phoenicis.containers.wine.parameters.RegistryParameter)6 LibraryManager (org.phoenicis.library.LibraryManager)6 ShortcutManager (org.phoenicis.library.ShortcutManager)6 ShortcutCategoryDTO (org.phoenicis.library.dto.ShortcutCategoryDTO)6 FileUtilities (org.phoenicis.tools.files.FileUtilities)6 OperatingSystemFetcher (org.phoenicis.tools.system.OperatingSystemFetcher)6 TerminalOpener (org.phoenicis.tools.system.terminal.TerminalOpener)6 RegistryWriter (org.phoenicis.win32.registry.RegistryWriter)6