/* * WiVRn VR streaming * Copyright (C) 2024 Guillaume Meunier * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #pragma once #include "utils/flatpak.h" #include #include template std::unique_ptr escape_sandbox(U && executable, Args &&... args_orig) { auto process = std::make_unique(); QStringList args; auto to_QString = [](const auto & s) { using T = std::decay_t>>; if constexpr (std::is_same_v) return s; if constexpr (std::is_same_v) return s; if constexpr (std::is_same_v) return QString::fromStdString(s); }; if (wivrn::flatpak_key(wivrn::flatpak::section::session_bus_policy, "org.freedesktop.Flatpak") == "talk") { process->setProgram("flatpak-spawn"); args.push_back("--host"); args.push_back(to_QString(executable)); } else { process->setProgram(to_QString(executable)); } (args.push_back(to_QString(args_orig)), ...); process->setArguments(args); return process; }