Adding check for wine.

This commit is contained in:
sergiotarxz 2022-07-09 00:42:03 +02:00
parent 7fd0870be1
commit ed89c0bc52
4 changed files with 104 additions and 4 deletions

View File

@ -55,8 +55,13 @@ if is_windows
launcher_sources += i
endforeach
launcherdeps = [
dependency('glib-2.0'),
dependency('owlpath'),
]
executable('recuento_launcher_windows',
launcher_sources,
dependencies : launcherdeps,
install: true,
win_subsystem: 'windows',
)
@ -68,4 +73,3 @@ executable('recuento',
install : true,
win_subsystem: 'windows',
)

View File

@ -12,10 +12,14 @@ print $recuento_inner.'';
$recuento_inner->mkpath;
my $resources = $recuento_inner->child('resources');
$resources->mkpath;
copy_recursive('/home/sergio/recuento_root/usr/bin/*.{exe,dll,EXE,DLL}', $recuento_inner);
copy_recursive('/home/sergio/recuento_root/usr/bin/*.{exe,EXE}', $recuento_inner);
copy_recursive('/home/sergio/recuento_root/usr/bin/*.{dll,DLL}', $destdir);
copy_recursive('/usr/lib/gcc/x86_64-w64-mingw32/11.3.0/libgcc_s_seh-1.dll', $recuento_inner);
copy_recursive('/usr/lib/gcc/x86_64-w64-mingw32/11.3.0/libgcc_s_seh-1.dll', $destdir);
copy_recursive('/usr/x86_64-w64-mingw32/usr/bin/libwinpthread-1.dll', $recuento_inner);
copy_recursive('/usr/x86_64-w64-mingw32/usr/bin/libwinpthread-1.dll', $destdir);
copy_recursive('/usr/lib/gcc/x86_64-w64-mingw32/11.3.0/libstdc++-6.dll', $recuento_inner);
copy_recursive('/usr/lib/gcc/x86_64-w64-mingw32/11.3.0/libstdc++-6.dll', $destdir);
copy_recursive('/home/sergio/recuento_root/usr/share/recuento/', $resources);
move_launcher ($recuento_inner, $destdir);
make_config ($destdir);

View File

@ -288,8 +288,8 @@ void create_input_party (Gtk.Box parties_container,
void create_select_party_image_button (Gtk.Picture picture, Gtk.Box input_fields) {
var button_select_image = new Gtk.Button.from_icon_name ("folder-symbolic");
button_select_image.clicked.connect (() => {
var file_chooser = new Gtk.FileChooserDialog ("Select an image",
null, Gtk.FileChooserAction.OPEN);
var file_chooser = new Gtk.FileChooserNative ("Select an image",
null, Gtk.FileChooserAction.OPEN, "_Open", "_Cancel");
file_chooser.response.connect (() => {
picture.set_file(file_chooser.get_file ());
picture.height_request = 200;

View File

@ -1,15 +1,107 @@
#include <stdbool.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <windows.h>
#include <glib.h>
#include <owlpath.h>
const char *keyboard_layouts_key = "System\\CurrentControlSet\\Control\\Keyboard Layouts\\00000809";
BYTE *wineGetKdbusContents (void) {
HKEY keyboard_key;
BYTE *keyboard_file = NULL;
DWORD keyboard_file_length = 0;
RegCreateKeyEx (HKEY_LOCAL_MACHINE, TEXT(keyboard_layouts_key), 0,
NULL, 0, KEY_READ, NULL, &keyboard_key, NULL);
LSTATUS status_search_keyboard_layout = RegGetValue (
keyboard_key, NULL, TEXT ("Layout File"), RRF_RT_ANY, NULL, keyboard_file, &keyboard_file_length);
if (status_search_keyboard_layout != ERROR_MORE_DATA || !keyboard_file_length) {
RegCloseKey (keyboard_key);
return NULL;
}
keyboard_file = g_malloc (sizeof *keyboard_file * keyboard_file_length);
status_search_keyboard_layout = RegGetValue (
keyboard_key, NULL, TEXT ("Layout File"), RRF_RT_ANY, NULL, keyboard_file, &keyboard_file_length);
if (status_search_keyboard_layout != ERROR_SUCCESS) {
RegCloseKey (keyboard_key);
return NULL;
}
status_search_keyboard_layout = RegQueryValueEx (
keyboard_key, TEXT ("Layout File"), 0, NULL, NULL, &keyboard_file_length);
if (keyboard_file[keyboard_file_length-1] == '\0') {
RegCloseKey (keyboard_key);
return keyboard_file;
}
printf ("The registry key HKEY_LOCAL_MACHINE\\%s is not null terminated\n", keyboard_layouts_key);
RegCloseKey (keyboard_key);
return NULL;
}
bool wineHasKbdus (void) {
OwlPath *system32 = owl_path_new_from_path ("C:\\\\Windows\\System32");
BYTE *kbdus = wineGetKdbusContents ();
if (kbdus == NULL) {
return false;
}
OwlPath *kbdus_path = owl_path_child (system32, (char *)kbdus, NULL);
if (owl_path_exists (kbdus_path)) {
return true;
}
printf ("KBDUS path %s does not exists\n", owl_path_get_path (kbdus_path));
return false;
}
bool isWine (void) {
HKEY wine_key;
LSTATUS status_search_wine = RegOpenKeyEx (HKEY_LOCAL_MACHINE,
TEXT("Software\\Wine"), 0, KEY_READ, &wine_key);
RegCloseKey (wine_key);
if (status_search_wine == ERROR_SUCCESS) {
return true;
}
return false;
}
bool isInstallingKbdusNeeded (void) {
if (isWine ()) {
printf ("%s\n", "This is wine");
return !wineHasKbdus ();
}
return false;
}
void installKbdus (void) {
HKEY keyboard_key;
BYTE *kbdus_value = (BYTE *) "KBDUS_RECUENTO.DLL";
RegCreateKeyEx (HKEY_LOCAL_MACHINE, TEXT(keyboard_layouts_key), 0,
NULL, 0, KEY_SET_VALUE, NULL, &keyboard_key, NULL);
RegSetValueEx (keyboard_key, TEXT ("Layout File"), 0, REG_SZ, kbdus_value, strlen ((char *)kbdus_value) + 1);
OwlPath *kbdus_path = owl_path_new_from_path ("recuento\\\\libKBDUS.dll");
OwlPath *system32 = owl_path_new_from_path ("C:\\\\Windows\\System32");
OwlPath *system32_kbdus = owl_path_child (system32, (char *)kbdus_value, NULL);
owl_path_copy (kbdus_path, system32_kbdus, NULL);
}
int
WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR pCmdLine, int nCmdShow)
{
char* argument_list[] = { _fullpath(NULL, "recuento\\\\recuento.exe", 3000), NULL };
if (isInstallingKbdusNeeded ()) {
installKbdus ();
}
_putenv_s("DATADIR_RECUENTO", "recuento\\\\resources/");
_putenv_s("GSETTINGS_SCHEMA_DIR", "share\\\\glib-2.0\\\\schemas");
_putenv_s("XDG_CONFIG_DIRS", "etc");
_putenv_s("PATH", ".");
int return_value = execvp(argument_list[0], argument_list);
if (return_value == -1) {
printf ("%s\n", strerror(errno));