diff --git a/dashboard/CMakeLists.txt b/dashboard/CMakeLists.txt index d741f89e..319216f2 100644 --- a/dashboard/CMakeLists.txt +++ b/dashboard/CMakeLists.txt @@ -11,6 +11,7 @@ add_executable(wivrn-dashboard wivrn_server.cpp wivrn_qdbus_types.cpp apps.cpp + dashboard_utils.cpp escape_string.cpp settings.cpp rectangle_partitionner.cpp diff --git a/dashboard/dashboard_utils.cpp b/dashboard/dashboard_utils.cpp new file mode 100644 index 00000000..46ac4a05 --- /dev/null +++ b/dashboard/dashboard_utils.cpp @@ -0,0 +1,31 @@ +/* + * WiVRn VR streaming + * Copyright (C) 2025 Patrick Nicolas + * + * 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 . + */ + +#include "dashboard_utils.h" + +#include "utils/flatpak.h" +#include + +QString find_executable(const QString & name) +{ + if (wivrn::is_flatpak()) + return QStandardPaths::findExecutable( + name, + QStringList({"/run/host/usr/sbin", "/run/host/usr/bin", "/run/host/sbin", "/run/host/bin"})); + return QStandardPaths::findExecutable(name); +} diff --git a/dashboard/dashboard_utils.h b/dashboard/dashboard_utils.h new file mode 100644 index 00000000..b15a929d --- /dev/null +++ b/dashboard/dashboard_utils.h @@ -0,0 +1,23 @@ +/* + * WiVRn VR streaming + * Copyright (C) 2025 Patrick Nicolas + * + * 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 + +QString find_executable(const QString & name); diff --git a/dashboard/firewall.cpp b/dashboard/firewall.cpp index 18834458..39a78f86 100644 --- a/dashboard/firewall.cpp +++ b/dashboard/firewall.cpp @@ -18,6 +18,7 @@ #include "firewall.h" +#include "dashboard_utils.h" #include "escape_sandbox.h" #include "utils/flatpak.h" #include "wivrn_config.h" @@ -26,7 +27,6 @@ #include #include #include -#include #include #include @@ -171,19 +171,8 @@ std::unique_ptr make_impl() if (auto fwd = std::make_unique(); fwd->enabled()) return fwd; - if (wivrn::is_flatpak()) - { - if (not QStandardPaths::findExecutable( - "ufw", - QStringList({"/run/host/usr/sbin", "/run/host/usr/bin"})) - .isEmpty()) - return std::make_unique(); - } - else - { - if (not QStandardPaths::findExecutable("ufw").isEmpty()) - return std::make_unique(); - } + if (not find_executable("ufw").isEmpty()) + return std::make_unique(); return std::make_unique(); }