Commit 6203a11d authored by Melroy van den Berg's avatar Melroy van den Berg

Merge branch 'use_wine_start' into 'master'

Use 'wine start' instead of plain 'wine' to run Windows executables

See merge request !5
parents a47b180d 04beb76a
Pipeline #2530 passed with stages
in 2 minutes and 8 seconds
......@@ -47,9 +47,9 @@ public:
static Helper& getInstance();
static std::map<string, unsigned long> GetBottlesPaths(const string& dir_path);
static void RunProgram(string prefix_path, string program, bool enable_tracing, bool give_error);
static void RunProgramUnderWine(string prefix_path, string program, bool enable_tracing, bool is_msi_file);
static void RunProgramWithFinishCallback(string prefix_path, string program, bool enable_tracing, bool give_error, bool is_msi_file, Glib::Dispatcher* finishSignal);
static void RunProgram(string prefix_path, string program, bool give_error, bool enable_tracing);
static void RunProgramUnderWine(string prefix_path, string program, bool give_error, bool enable_tracing);
static void RunProgramWithFinishCallback(string prefix_path, string program, Glib::Dispatcher* finishSignal, bool give_error, bool enable_tracing);
static void WaitUntilWineserverIsTerminated(const string prefix_path);
static string GetWineExecutableLocation();
static string GetWinetricksLocation();
......
......@@ -296,7 +296,10 @@ void BottleManager::RunProgram(string filename, bool is_msi_file = false)
{
if (isBottleNotNull()) {
Glib::ustring wine_prefix = activeBottle->wine_location();
std::thread t(&Helper::RunProgramUnderWine, wine_prefix, filename, false, is_msi_file);
Glib::ustring program_prefix = is_msi_file ? "msiexec /i" : "start /unix";
// Be-sure to execute the filename also between brackets (in case of spaces)
Glib::ustring program = program_prefix + " \"" + filename + "\"";
std::thread t(&Helper::RunProgramUnderWine, wine_prefix, program, true, false);
t.detach();
}
}
......@@ -358,7 +361,7 @@ void BottleManager::OpenExplorer()
{
if (isBottleNotNull()) {
Glib::ustring wine_prefix = activeBottle->wine_location();
std::thread t(&Helper::RunProgram, wine_prefix, "wine explorer", false, true);
std::thread t(&Helper::RunProgramUnderWine, wine_prefix, "explorer", false, false);
t.detach();
}
}
......@@ -370,7 +373,7 @@ void BottleManager::OpenConsole()
{
if (isBottleNotNull()) {
Glib::ustring wine_prefix = activeBottle->wine_location();
std::thread t(&Helper::RunProgram, wine_prefix, "wineconsole", false, true);
std::thread t(&Helper::RunProgramUnderWine, wine_prefix, "wineconsole", false, false);
t.detach();
}
}
......@@ -382,7 +385,7 @@ void BottleManager::OpenWinecfg()
{
if (isBottleNotNull()) {
Glib::ustring wine_prefix = activeBottle->wine_location();
std::thread t(&Helper::RunProgram, wine_prefix, "winecfg", false, true);
std::thread t(&Helper::RunProgramUnderWine, wine_prefix, "winecfg", false, false);
t.detach();
}
}
......@@ -395,7 +398,7 @@ void BottleManager::OpenWinetricks()
if (isBottleNotNull()) {
Glib::ustring wine_prefix = activeBottle->wine_location();
Glib::ustring program = Helper::GetWinetricksLocation() + " --gui";
std::thread t(&Helper::RunProgram, wine_prefix, program, false, true);
std::thread t(&Helper::RunProgram, wine_prefix, program, true, false);
t.detach();
}
}
......@@ -407,7 +410,7 @@ void BottleManager::OpenUninstaller()
{
if (isBottleNotNull()) {
Glib::ustring wine_prefix = activeBottle->wine_location();
std::thread t(&Helper::RunProgram, wine_prefix, "wine uninstaller", false, false);
std::thread t(&Helper::RunProgramUnderWine, wine_prefix, "uninstaller", false, false);
t.detach();
}
}
......@@ -419,7 +422,7 @@ void BottleManager::OpenTaskManager()
{
if (isBottleNotNull()) {
Glib::ustring wine_prefix = activeBottle->wine_location();
std::thread t(&Helper::RunProgram, wine_prefix, "wine taskmgr", false, false);
std::thread t(&Helper::RunProgramUnderWine, wine_prefix, "taskmgr", false, false);
t.detach();
}
}
......@@ -431,7 +434,7 @@ void BottleManager::OpenRegistertyEditor()
{
if (isBottleNotNull()) {
Glib::ustring wine_prefix = activeBottle->wine_location();
std::thread t(&Helper::RunProgram, wine_prefix, "wine regedit", false, true);
std::thread t(&Helper::RunProgramUnderWine, wine_prefix, "regedit", false, false);
t.detach();
}
}
......@@ -490,7 +493,7 @@ void BottleManager::InstallD3DX9(Gtk::Window& parent, const Glib::ustring& versi
Glib::ustring wine_prefix = activeBottle->wine_location();
Glib::ustring program = Helper::GetWinetricksLocation() + " -q " + package;
// finishedPackageInstall signal is needed in order to close the busy dialog again
std::thread t(&Helper::RunProgramWithFinishCallback, wine_prefix, program, false, true, false, &finishedPackageInstall);
std::thread t(&Helper::RunProgramWithFinishCallback, wine_prefix, program, &finishedPackageInstall, true, false);
t.detach();
}
}
......@@ -514,7 +517,7 @@ void BottleManager::InstallDXVK(Gtk::Window& parent, const Glib::ustring& versio
Glib::ustring wine_prefix = activeBottle->wine_location();
Glib::ustring program = Helper::GetWinetricksLocation() + " -q " + package;
// finishedPackageInstall signal is needed in order to close the busy dialog again
std::thread t(&Helper::RunProgramWithFinishCallback, wine_prefix, program, false, true, false, &finishedPackageInstall);
std::thread t(&Helper::RunProgramWithFinishCallback, wine_prefix, program, &finishedPackageInstall, true, false);
t.detach();
}
}
......@@ -534,7 +537,7 @@ void BottleManager::InstallVisualCppPackage(Gtk::Window& parent, const Glib::ust
Glib::ustring wine_prefix = activeBottle->wine_location();
Glib::ustring program = Helper::GetWinetricksLocation() + " -q " + package;
// finishedPackageInstall signal is needed in order to close the busy dialog again
std::thread t(&Helper::RunProgramWithFinishCallback, wine_prefix, program, false, true, false, &finishedPackageInstall);
std::thread t(&Helper::RunProgramWithFinishCallback, wine_prefix, program, &finishedPackageInstall, true, false);
t.detach();
}
}
......@@ -567,7 +570,7 @@ void BottleManager::InstallDotNet(Gtk::Window& parent, const Glib::ustring& vers
program = installCommand;
}
// finishedPackageInstall signal is needed in order to close the busy dialog again
std::thread t(&Helper::RunProgramWithFinishCallback, wine_prefix, program, false, true, false, &finishedPackageInstall);
std::thread t(&Helper::RunProgramWithFinishCallback, wine_prefix, program, &finishedPackageInstall, true, false);
t.detach();
} else {
// Nothing, canceled
......@@ -588,7 +591,7 @@ void BottleManager::InstallCoreFonts(Gtk::Window& parent)
Glib::ustring wine_prefix = activeBottle->wine_location();
Glib::ustring program = Helper::GetWinetricksLocation() + " -q corefonts";
// finishedPackageInstall signal is needed in order to close the busy dialog again
std::thread t(&Helper::RunProgramWithFinishCallback, wine_prefix, program, false, true, false, &finishedPackageInstall);
std::thread t(&Helper::RunProgramWithFinishCallback, wine_prefix, program, &finishedPackageInstall, true, false);
t.detach();
}
}
......@@ -606,7 +609,7 @@ void BottleManager::InstallLiberation(Gtk::Window& parent)
Glib::ustring wine_prefix = activeBottle->wine_location();
Glib::ustring program = Helper::GetWinetricksLocation() + " -q liberation";
// finishedPackageInstall signal is needed in order to close the busy dialog again
std::thread t(&Helper::RunProgramWithFinishCallback, wine_prefix, program, false, true, false, &finishedPackageInstall);
std::thread t(&Helper::RunProgramWithFinishCallback, wine_prefix, program, &finishedPackageInstall, true, false);
t.detach();
}
}
......
......@@ -138,45 +138,30 @@ std::map<std::string, unsigned long> Helper::GetBottlesPaths(const string& dir_p
* \brief Run any program with only setting the WINEPREFIX env variable (run this method async)
* \param[in] prefix_path - The path to wine bottle
* \param[in] program - Program that gets executed (ideally full path)
* \param[in] enable_tracing - Enable debugging tracing to file (give_error should be true as well!)
* \param[in] give_error - Inform user when application exit with non-zero exit code
* \param[in] enable_tracing - Enable debugging tracing to file (give_error should be true as well!)
*/
void Helper::RunProgram(string prefix_path, string program, bool enable_tracing, bool give_error)
void Helper::RunProgram(string prefix_path, string program, bool give_error = true, bool enable_tracing = false)
{
bool execTracing = false;
if (enable_tracing) {
execTracing = true;
}
if (!give_error) {
execTracing = false;
}
if (execTracing) {
if (give_error) {
// Execute the command and show the user a message when exit code is non-zero
// Be-sure to execute the program also between brackets (in case of spaces)
ExecTracing(("WINEPREFIX=\"" + prefix_path + "\" \"" + program + "\"").c_str(), enable_tracing);
ExecTracing(("WINEPREFIX=\"" + prefix_path + "\" " + program).c_str(), enable_tracing);
} else {
// No tracing and no error message when exit code is non-zero
// Be-sure to execute the program also between brackets (in case of spaces)
Exec(("WINEPREFIX=\"" + prefix_path + "\" \"" + program + "\"").c_str());
Exec(("WINEPREFIX=\"" + prefix_path + "\" " + program).c_str());
}
}
/**
* \brief Run a Windows program under Wine (run this method async)
* \param[in] prefix_path - The path to bottle wine
* \param[in] program - Program/executable that will be executed
* \param[in] enable_tracing - Enable debugging tracing to file
* \param[in] is_msi_file - Is the program a MSI installer
* \param[in] program - Program/executable that will be executed (be sure your application executable is between brackets in case of spaces)
* \param[in] give_error - Inform user when application exit with non-zero exit code
* \param[in] enable_tracing - Enable debugging tracing to file (give_error should be true as well!)
*/
void Helper::RunProgramUnderWine(string prefix_path, string program, bool enable_tracing, bool is_msi_file)
void Helper::RunProgramUnderWine(string prefix_path, string program, bool give_error = true, bool enable_tracing = false)
{
string msi = "";
if (is_msi_file) {
msi = " msiexec /i";
}
// Execute the command and show the user a message when exit code is non-zero
// Be-sure to execute the program also between brackets (in case of spaces)
ExecTracing(("WINEPREFIX=\"" + prefix_path + "\"" + msi + " " + Helper::GetWineExecutableLocation() + " \"" + program + "\"").c_str(), enable_tracing);
RunProgram(prefix_path, Helper::GetWineExecutableLocation() + " " + program, give_error, enable_tracing);
}
/**
......@@ -184,38 +169,18 @@ void Helper::RunProgramUnderWine(string prefix_path, string program, bool enable
* This method will really wait until the wineserver is down.
* \param[in] prefix_path - The path to bottle wine
* \param[in] program - Program/executable that will be executed
* \param[in] enable_tracing - Enable debugging tracing to file
* \param[in] give_error - Inform user when application exit with non-zero exit code
* \param[in] is_msi_file - Is the program a MSI installer (don't forget to add GetWineExecutableLocation() to the program parameter)
* \param[in] finishSignal - Signal handler to be called when execution is finished
* \param[in] give_error - Inform user when application exit with non-zero exit code
* \param[in] enable_tracing - Enable debugging tracing to file (give_error should be true as well!)
*/
void Helper::RunProgramWithFinishCallback(string prefix_path,
string program,
bool enable_tracing,
bool give_error,
bool is_msi_file,
Glib::Dispatcher* finishSignal)
Glib::Dispatcher* finishSignal,
bool give_error = true,
bool enable_tracing = false)
{
bool execTracing = false;
if (enable_tracing) {
execTracing = true;
}
if (!give_error) {
execTracing = false;
}
if (execTracing) {
string msi = "";
if (is_msi_file) {
msi = " msiexec /i";
}
// Execute the command and show the user a message when exit code is non-zero
// Be-sure to execute the program also between brackets (in case of spaces)
ExecTracing(("WINEPREFIX=\"" + prefix_path + "\"" + msi + " \"" + program + "\"").c_str(), enable_tracing);
} else {
// No tracing and no error message when exit code is non-zero
// Be-sure to execute the program also between brackets (in case of spaces)
Exec(("WINEPREFIX=\"" + prefix_path + "\" \"" + program + "\"").c_str());
}
// Be-sure to execute the program also between brackets (in case of spaces)
RunProgram(prefix_path, program, give_error, enable_tracing);
// Blocking wait until wineserver is terminated (before we can look in the reg files for example)
Helper::WaitUntilWineserverIsTerminated(prefix_path);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment