Search in sources :

Example 1 with WinePrefixContainerDTO

use of org.phoenicis.containers.dto.WinePrefixContainerDTO in project POL-POM-5 by PlayOnLinux.

the class WinePrefixContainerController method repairPrefix.

public void repairPrefix(WinePrefixContainerDTO winePrefix, Runnable doneCallback, Consumer<Exception> errorCallback) {
    // FIXME
    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", "wineboot");
        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)

Example 2 with WinePrefixContainerDTO

use of org.phoenicis.containers.dto.WinePrefixContainerDTO in project POL-POM-5 by PlayOnLinux.

the class WinePrefixContainerController method deletePrefix.

public void deletePrefix(WinePrefixContainerDTO winePrefix, Consumer<Exception> errorCallback) {
    try {
        fileUtilities.remove(new File(winePrefix.getPath()));
    } catch (IOException e) {
        LOGGER.error("Cannot delete Wine prefix (" + winePrefix.getPath() + ")! Exception: " + e.toString());
        errorCallback.accept(e);
    }
    List<ShortcutCategoryDTO> categories = libraryManager.fetchShortcuts();
    categories.stream().flatMap(shortcutCategoryDTO -> shortcutCategoryDTO.getShortcuts().stream()).forEach(shortcutDTO -> {
        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);
            final String container = (String) shortcutReader.callMember("container");
            if (container.equals(winePrefix.getName())) {
                shortcutManager.deleteShortcut(shortcutDTO);
            }
        }, 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) ShortcutCategoryDTO(org.phoenicis.library.dto.ShortcutCategoryDTO) IOException(java.io.IOException) InteractiveScriptSession(org.phoenicis.scripts.interpreter.InteractiveScriptSession) File(java.io.File)

Example 3 with WinePrefixContainerDTO

use of org.phoenicis.containers.dto.WinePrefixContainerDTO in project POL-POM-5 by PlayOnLinux.

the class WinePrefixContainerController method changeSetting.

public void changeSetting(WinePrefixContainerDTO winePrefix, RegistryParameter setting, Runnable doneCallback, Consumer<Exception> errorCallback) {
    final InteractiveScriptSession interactiveScriptSession = scriptInterpreter.createInteractiveSession();
    final String registryPatch = registryWriter.generateRegFileContent(setting.toRegistryPatch());
    LOGGER.info("Updating registry for prefix: " + winePrefix.getPath());
    LOGGER.info(registryPatch);
    interactiveScriptSession.eval("include([\"Functions\", \"Engines\", \"Wine\"]);", ignored -> interactiveScriptSession.eval("new Wine()", output -> {
        final ScriptObjectMirror wine = (ScriptObjectMirror) output;
        wine.callMember("prefix", winePrefix.getName());
        final ScriptObjectMirror regedit = (ScriptObjectMirror) wine.callMember("regedit");
        regedit.callMember("patch", registryPatch);
        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)

Example 4 with WinePrefixContainerDTO

use of org.phoenicis.containers.dto.WinePrefixContainerDTO in project POL-POM-5 by PlayOnLinux.

the class WinePrefixContainerController method createShortcut.

/**
     * creates a shortcut for a given executable in a Wine prefix
     * @param winePrefix the Wine prefix
     * @param name name which is shown in the library
     * @param executable filename of the executable (WineShortcut will search for this file in the given prefix)
     * @param doneCallback callback executed after the shortcut has been created
     * @param errorCallback callback executed if there is an error
     */
public void createShortcut(WinePrefixContainerDTO winePrefix, String name, String executable, Runnable doneCallback, Consumer<Exception> errorCallback) {
    final InteractiveScriptSession interactiveScriptSession = scriptInterpreter.createInteractiveSession();
    interactiveScriptSession.eval("include([\"Functions\", \"Shortcuts\", \"Wine\"]);", ignored -> interactiveScriptSession.eval("new WineShortcut()", output -> {
        final ScriptObjectMirror wine = (ScriptObjectMirror) output;
        wine.callMember("name", name);
        wine.callMember("search", executable);
        wine.callMember("prefix", winePrefix.getName());
        wine.callMember("create");
        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 5 with WinePrefixContainerDTO

use of org.phoenicis.containers.dto.WinePrefixContainerDTO in project POL-POM-5 by PhoenicisOrg.

the class WinePrefixContainerController method changeSetting.

public void changeSetting(WinePrefixContainerDTO winePrefix, RegistryParameter setting, Runnable doneCallback, Consumer<Exception> errorCallback) {
    final InteractiveScriptSession interactiveScriptSession = scriptInterpreter.createInteractiveSession();
    final String registryPatch = registryWriter.generateRegFileContent(setting.toRegistryPatch());
    LOGGER.info("Updating registry for prefix: " + winePrefix.getPath());
    LOGGER.info(registryPatch);
    interactiveScriptSession.eval("include([\"Engines\", \"Wine\", \"Engine\", \"Object\"]);", ignored -> interactiveScriptSession.eval("new Wine()", output -> {
        final ScriptObjectMirror wine = (ScriptObjectMirror) output;
        wine.callMember("prefix", winePrefix.getName());
        final ScriptObjectMirror regedit = (ScriptObjectMirror) wine.callMember("regedit");
        regedit.callMember("patch", registryPatch);
        wine.callMember("wait");
        doneCallback.run();
    }, errorCallback), errorCallback);
}
Also used : Consumer(java.util.function.Consumer) RegistryWriter(org.phoenicis.win32.registry.RegistryWriter) RegistryParameter(org.phoenicis.containers.wine.parameters.RegistryParameter) Logger(org.slf4j.Logger) LoggerFactory(org.slf4j.LoggerFactory) WinePrefixContainerDTO(org.phoenicis.containers.dto.WinePrefixContainerDTO) ScriptInterpreter(org.phoenicis.scripts.interpreter.ScriptInterpreter) ScriptObjectMirror(jdk.nashorn.api.scripting.ScriptObjectMirror) InteractiveScriptSession(org.phoenicis.scripts.interpreter.InteractiveScriptSession) ContainerDTO(org.phoenicis.containers.dto.ContainerDTO) ScriptObjectMirror(jdk.nashorn.api.scripting.ScriptObjectMirror) InteractiveScriptSession(org.phoenicis.scripts.interpreter.InteractiveScriptSession)

Aggregations

WinePrefixContainerDTO (org.phoenicis.containers.dto.WinePrefixContainerDTO)9 Consumer (java.util.function.Consumer)8 ScriptObjectMirror (jdk.nashorn.api.scripting.ScriptObjectMirror)8 RegistryParameter (org.phoenicis.containers.wine.parameters.RegistryParameter)8 InteractiveScriptSession (org.phoenicis.scripts.interpreter.InteractiveScriptSession)8 ScriptInterpreter (org.phoenicis.scripts.interpreter.ScriptInterpreter)8 RegistryWriter (org.phoenicis.win32.registry.RegistryWriter)8 Logger (org.slf4j.Logger)8 LoggerFactory (org.slf4j.LoggerFactory)8 List (java.util.List)7 File (java.io.File)6 IOException (java.io.IOException)6 HashMap (java.util.HashMap)6 Map (java.util.Map)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