use of org.phoenicis.tools.config.ConfigFile in project phoenicis by PhoenicisOrg.
the class GenericContainersManager method fetchContainers.
/**
* fetches all containers in a given directory
* @param directory
* @return found containers
*/
private List<ContainerDTO> fetchContainers(File directory) {
final List<ContainerDTO> containers = new ArrayList<>();
final File[] containerDirectories = directory.listFiles();
if (containerDirectories != null) {
for (File containerDirectory : containerDirectories) {
final ConfigFile configFile = compatibleConfigFileFormatFactory.open(new File(containerDirectory, "phoenicis.cfg"));
final File userRegistryFile = new File(containerDirectory, "user.reg");
final String containerPath = containerDirectory.getAbsolutePath();
final String containerName = containerPath.substring(containerPath.lastIndexOf('/') + 1);
// find shortcuts which use this container
List<ShortcutDTO> shortcutDTOS = libraryManager.fetchShortcuts().stream().flatMap(shortcutCategory -> shortcutCategory.getShortcuts().stream()).filter(shortcut -> {
boolean toAdd = false;
try {
final Map<String, Object> shortcutProperties = objectMapper.readValue(shortcut.getScript(), new TypeReference<Map<String, Object>>() {
});
toAdd = shortcutProperties.get("winePrefix").equals(containerName);
} catch (IOException e) {
LOGGER.warn("Could not parse shortcut script JSON", e);
}
return toAdd;
}).collect(Collectors.toList());
if (directory.getName().equals("wineprefix")) {
containers.add(new WinePrefixContainerDTO.Builder().withName(containerDirectory.getName()).withPath(containerPath).withInstalledShortcuts(shortcutDTOS).withArchitecture(configFile.readValue("wineArchitecture", "")).withDistribution(configFile.readValue("wineDistribution", "")).withVersion(configFile.readValue("wineVersion", "")).withGlslValue(winePrefixContainerDisplayConfiguration.getGLSL(userRegistryFile)).withDirectDrawRenderer(winePrefixContainerDisplayConfiguration.getDirectDrawRenderer(userRegistryFile)).withVideoMemorySize(winePrefixContainerDisplayConfiguration.getVideoMemorySize(userRegistryFile)).withOffscreenRenderingMode(winePrefixContainerDisplayConfiguration.getOffscreenRenderingMode(userRegistryFile)).withMultisampling(winePrefixContainerDisplayConfiguration.getMultisampling(userRegistryFile)).withAlwaysOffscreen(winePrefixContainerDisplayConfiguration.getAlwaysOffscreen(userRegistryFile)).withStrictDrawOrdering(winePrefixContainerDisplayConfiguration.getStrictDrawOrdering(userRegistryFile)).withRenderTargetModeLock(winePrefixContainerDisplayConfiguration.getRenderTargetModeLock(userRegistryFile)).withMouseWarpOverride(winePrefixContainerInputConfiguration.getMouseWarpOverride(userRegistryFile)).build());
}
}
containers.sort(ContainerDTO.nameComparator());
}
return containers;
}
use of org.phoenicis.tools.config.ConfigFile in project POL-POM-5 by PlayOnLinux.
the class GenericContainersManager method fetchContainers.
/**
* fetches all containers in a given directory
*
* @param directory
* @return found containers
*/
private List<ContainerDTO> fetchContainers(File directory) {
final List<ContainerDTO> containers = new ArrayList<>();
final File[] containerDirectories = directory.listFiles();
if (containerDirectories != null) {
for (File containerDirectory : containerDirectories) {
if (!containerDirectory.isHidden()) {
final ConfigFile configFile = compatibleConfigFileFormatFactory.open(new File(containerDirectory, "phoenicis.cfg"));
final String containerPath = containerDirectory.getAbsolutePath();
final String containerName = containerPath.substring(containerPath.lastIndexOf('/') + 1);
// find shortcuts which use this container
List<ShortcutDTO> shortcutDTOS = libraryManager.fetchShortcuts().stream().flatMap(shortcutCategory -> shortcutCategory.getShortcuts().stream()).filter(shortcut -> {
boolean toAdd = false;
try {
final Map<String, Object> shortcutProperties = objectMapper.readValue(shortcut.getScript(), new TypeReference<Map<String, Object>>() {
});
toAdd = shortcutProperties.get("winePrefix").equals(containerName);
} catch (IOException e) {
LOGGER.warn("Could not parse shortcut script JSON", e);
}
return toAdd;
}).collect(Collectors.toList());
if (directory.getName().equals("wineprefix")) {
containers.add(new WinePrefixContainerDTO.Builder().withName(containerDirectory.getName()).withPath(containerPath).withInstalledShortcuts(shortcutDTOS).withArchitecture(configFile.readValue("wineArchitecture", "")).withDistribution(configFile.readValue("wineDistribution", "")).withVersion(configFile.readValue("wineVersion", "")).build());
}
}
}
containers.sort(ContainerDTO.nameComparator());
}
return containers;
}
use of org.phoenicis.tools.config.ConfigFile in project POL-POM-5 by PhoenicisOrg.
the class GenericContainersManager method fetchContainers.
/**
* fetches all containers in a given directory
*
* @param directory
* @return found containers
*/
private List<ContainerDTO> fetchContainers(File directory) {
final List<ContainerDTO> containers = new ArrayList<>();
final File[] containerDirectories = directory.listFiles();
if (containerDirectories != null) {
for (File containerDirectory : containerDirectories) {
if (!containerDirectory.isHidden()) {
final ConfigFile configFile = compatibleConfigFileFormatFactory.open(new File(containerDirectory, "phoenicis.cfg"));
final String containerPath = containerDirectory.getAbsolutePath();
final String containerName = containerPath.substring(containerPath.lastIndexOf('/') + 1);
// find shortcuts which use this container
List<ShortcutDTO> shortcutDTOS = libraryManager.fetchShortcuts().stream().flatMap(shortcutCategory -> shortcutCategory.getShortcuts().stream()).filter(shortcut -> {
boolean toAdd = false;
try {
final Map<String, Object> shortcutProperties = objectMapper.readValue(shortcut.getScript(), new TypeReference<Map<String, Object>>() {
});
toAdd = shortcutProperties.get("winePrefix").equals(containerName);
} catch (IOException e) {
LOGGER.warn("Could not parse shortcut script JSON", e);
}
return toAdd;
}).collect(Collectors.toList());
if (directory.getName().equals("wineprefix")) {
containers.add(new WinePrefixContainerDTO.Builder().withName(containerDirectory.getName()).withPath(containerPath).withInstalledShortcuts(shortcutDTOS).withArchitecture(configFile.readValue("wineArchitecture", "")).withDistribution(configFile.readValue("wineDistribution", "")).withVersion(configFile.readValue("wineVersion", "")).build());
}
}
}
containers.sort(ContainerDTO.nameComparator());
}
return containers;
}
use of org.phoenicis.tools.config.ConfigFile in project POL-POM-5 by PlayOnLinux.
the class WinePrefixContainersManager method fetchContainers.
@Override
public void fetchContainers(Consumer<List<ContainerCategoryDTO>> callback, Consumer<Exception> errorCallback) {
final File winePrefixesFile = new File(winePrefixPath);
winePrefixesFile.mkdirs();
final File[] winePrefixes = winePrefixesFile.listFiles();
if (winePrefixes == null) {
callback.accept(Collections.emptyList());
} else {
final List<ContainerCategoryDTO> containerCategories = new ArrayList<>();
final List<ContainerDTO> containers = new ArrayList<>();
for (File winePrefix : winePrefixes) {
final ConfigFile configFile = compatibleConfigFileFormatFactory.open(new File(winePrefix, "phoenicis.cfg"));
final File userRegistryFile = new File(winePrefix, "user.reg");
containers.add(new WinePrefixContainerDTO.Builder().withName(winePrefix.getName()).withPath(winePrefix.getAbsolutePath()).withArchitecture(configFile.readValue("wineArchitecture", "")).withDistribution(configFile.readValue("wineDistribution", "")).withVersion(configFile.readValue("wineVersion", "")).withGlslValue(winePrefixContainerDisplayConfiguration.getGLSL(userRegistryFile)).withDirectDrawRenderer(winePrefixContainerDisplayConfiguration.getDirectDrawRenderer(userRegistryFile)).withVideoMemorySize(winePrefixContainerDisplayConfiguration.getVideoMemorySize(userRegistryFile)).withOffscreenRenderingMode(winePrefixContainerDisplayConfiguration.getOffscreenRenderingMode(userRegistryFile)).withMultisampling(winePrefixContainerDisplayConfiguration.getMultisampling(userRegistryFile)).withAlwaysOffscreen(winePrefixContainerDisplayConfiguration.getAlwaysOffscreen(userRegistryFile)).withStrictDrawOrdering(winePrefixContainerDisplayConfiguration.getStrictDrawOrdering(userRegistryFile)).withRenderTargetModeLock(winePrefixContainerDisplayConfiguration.getRenderTargetModeLock(userRegistryFile)).withMouseWarpOverride(winePrefixContainerInputConfiguration.getMouseWarpOverride(userRegistryFile)).build());
}
containers.sort(ContainerDTO.nameComparator());
containerCategories.add(new ContainerCategoryDTO.Builder().withName("Wine").withContainers(containers).build());
callback.accept(containerCategories);
}
}
Aggregations