Merge remote-tracking branch 'origin/master'

This commit is contained in:
Yukino Song
2024-10-05 22:48:35 +08:00
38 changed files with 422 additions and 164 deletions

View File

@@ -197,7 +197,12 @@ namespace http {
bool
download_file(const std::string &url, const std::string &file) {
CURL *curl = curl_easy_init();
if (!curl) {
if (curl) {
// sonar complains about weak ssl and tls versions
// ideally, the setopts should go after the early returns; however sonar cannot detect the fix
curl_easy_setopt(curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2);
}
else {
BOOST_LOG(error) << "Couldn't create CURL instance";
return false;
}
@@ -215,16 +220,16 @@ namespace http {
curl_easy_cleanup(curl);
return false;
}
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
#ifdef _WIN32
curl_easy_setopt(curl, CURLOPT_SSL_OPTIONS, CURLSSLOPT_NATIVE_CA);
#endif
CURLcode result = curl_easy_perform(curl);
if (result != CURLE_OK) {
BOOST_LOG(error) << "Couldn't download ["sv << url << ", code:" << result << ']';
}
curl_easy_cleanup(curl);
fclose(fp);
return result == CURLE_OK;

View File

@@ -47,13 +47,13 @@ namespace boost {
namespace filesystem {
class path;
}
namespace process {
namespace process::inline v1 {
class child;
class group;
template <typename Char>
class basic_environment;
typedef basic_environment<char> environment;
} // namespace process
} // namespace process::inline v1
} // namespace boost
#endif
namespace video {
@@ -600,8 +600,8 @@ namespace platf {
bool
needs_encoder_reenumeration();
boost::process::child
run_command(bool elevated, bool interactive, const std::string &cmd, boost::filesystem::path &working_dir, const boost::process::environment &env, FILE *file, std::error_code &ec, boost::process::group *group);
boost::process::v1::child
run_command(bool elevated, bool interactive, const std::string &cmd, boost::filesystem::path &working_dir, const boost::process::v1::environment &env, FILE *file, std::error_code &ec, boost::process::v1::group *group);
enum class thread_priority_e : int {
low, ///< Low priority

View File

@@ -15,7 +15,7 @@
// lib includes
#include <arpa/inet.h>
#include <boost/asio/ip/address.hpp>
#include <boost/process.hpp>
#include <boost/process/v1.hpp>
#include <dlfcn.h>
#include <fcntl.h>
#include <ifaddrs.h>
@@ -352,7 +352,7 @@ get_local_ip_for_gateway() {
auto working_dir = boost::filesystem::path(std::getenv("HOME"));
std::string cmd = R"(xdg-open ")" + url + R"(")";
boost::process::environment _env = boost::this_process::environment();
boost::process::v1::environment _env = boost::this_process::environment();
std::error_code ec;
auto child = run_command(false, false, cmd, working_dir, _env, nullptr, ec, nullptr);
if (ec) {

View File

@@ -362,6 +362,9 @@ const KeyCodeMap kKeyCodesMap[] = {
CGEventSetDoubleValueField(event, kCGMouseEventDeltaY, deltaY);
CGEventPost(kCGHIDEventTap, event);
// For why this is here, see:
// https://stackoverflow.com/questions/15194409/simulated-mouseevent-not-working-properly-osx
CGWarpMouseCursorPosition(location);
}
inline CGEventType

View File

@@ -23,7 +23,7 @@
#include "src/platform/common.h"
#include <boost/asio/ip/address.hpp>
#include <boost/process.hpp>
#include <boost/process/v1.hpp>
using namespace std::literals;
namespace fs = std::filesystem;
@@ -203,7 +203,7 @@ namespace platf {
boost::filesystem::path working_dir;
std::string cmd = R"(open ")" + url + R"(")";
boost::process::environment _env = boost::this_process::environment();
boost::process::v1::environment _env = boost::this_process::environment();
std::error_code ec;
auto child = run_command(false, false, cmd, working_dir, _env, nullptr, ec, nullptr);
if (ec) {

View File

@@ -7,9 +7,9 @@
#include <thread>
#include <boost/algorithm/string/join.hpp>
#include <boost/process.hpp>
#include <boost/process/v1.hpp>
// We have to include boost/process.hpp before display.h due to WinSock.h,
// We have to include boost/process/v1.hpp before display.h due to WinSock.h,
// but that prevents the definition of NTSTATUS so we must define it ourself.
typedef long NTSTATUS;

View File

@@ -10,7 +10,7 @@
#include <boost/algorithm/string.hpp>
#include <boost/asio/ip/address.hpp>
#include <boost/process.hpp>
#include <boost/process/v1.hpp>
#include <boost/program_options/parsers.hpp>
// prevent clang format from "optimizing" the header include order
@@ -1121,7 +1121,7 @@ namespace platf {
*/
void
open_url(const std::string &url) {
boost::process::environment _env = boost::this_process::environment();
boost::process::v1::environment _env = boost::this_process::environment();
auto working_dir = boost::filesystem::path();
std::error_code ec;

View File

@@ -80,7 +80,7 @@ namespace proc {
}
void
terminate_process_group(boost::process::child &proc, boost::process::group &group, std::chrono::seconds exit_timeout) {
terminate_process_group(boost::process::v1::child &proc, boost::process::v1::group &group, std::chrono::seconds exit_timeout) {
if (group.valid() && platf::process_group_running((std::uintptr_t) group.native_handle())) {
if (exit_timeout.count() > 0) {
// Request processes in the group to exit gracefully
@@ -121,7 +121,7 @@ namespace proc {
}
boost::filesystem::path
find_working_directory(const std::string &cmd, boost::process::environment &env) {
find_working_directory(const std::string &cmd, boost::process::v1::environment &env) {
// Parse the raw command string into parts to get the actual command portion
#ifdef _WIN32
auto parts = boost::program_options::split_winmain(cmd);
@@ -143,7 +143,7 @@ namespace proc {
// If the cmd path is not an absolute path, resolve it using our PATH variable
boost::filesystem::path cmd_path(parts.at(0));
if (!cmd_path.is_absolute()) {
cmd_path = boost::process::search_path(parts.at(0));
cmd_path = boost::process::v1::search_path(parts.at(0));
if (cmd_path.empty()) {
BOOST_LOG(error) << "Unable to find executable ["sv << parts.at(0) << "]. Is it in your PATH?"sv;
return boost::filesystem::path();
@@ -500,8 +500,8 @@ namespace proc {
std::error_code ec;
placebo = false;
terminate_process_group(_process, _process_group, _app.exit_timeout);
_process = boost::process::child();
_process_group = boost::process::group();
_process = boost::process::v1::child();
_process_group = boost::process::v1::group();
for (; _app_prep_it != _app_prep_begin; --_app_prep_it) {
auto &cmd = *(_app_prep_it - 1);
@@ -631,7 +631,7 @@ namespace proc {
}
std::string
parse_env_val(boost::process::native_environment &env, const std::string_view &val_raw) {
parse_env_val(boost::process::v1::native_environment &env, const std::string_view &val_raw) {
auto pos = std::begin(val_raw);
auto dollar = std::find(pos, std::end(val_raw), '$');

View File

@@ -11,7 +11,7 @@
#include <optional>
#include <unordered_map>
#include <boost/process.hpp>
#include <boost/process/v1.hpp>
#include <boost/property_tree/ptree.hpp>
#include "config.h"
@@ -88,7 +88,7 @@ namespace proc {
proc_t(
boost::process::environment &&env,
boost::process::v1::environment &&env,
std::vector<ctx_t> &&apps):
_app_id(0),
_env(std::move(env)),
@@ -120,7 +120,8 @@ namespace proc {
private:
int _app_id;
boost::process::environment _env;
boost::process::v1::environment _env;
std::shared_ptr<rtsp_stream::launch_session_t> _launch_session;
@@ -131,8 +132,8 @@ namespace proc {
// If no command associated with _app_id, yet it's still running
bool placebo {};
boost::process::child _process;
boost::process::group _process_group;
boost::process::v1::child _process;
boost::process::v1::group _process_group;
file_t _pipe;
std::vector<cmd_t>::const_iterator _app_prep_it;
@@ -172,7 +173,7 @@ namespace proc {
* @param exit_timeout The timeout to wait for the process group to gracefully exit.
*/
void
terminate_process_group(boost::process::child &proc, boost::process::group &group, std::chrono::seconds exit_timeout);
terminate_process_group(boost::process::v1::child &proc, boost::process::v1::group &group, std::chrono::seconds exit_timeout);
extern proc_t proc;
} // namespace proc

View File

@@ -36,7 +36,7 @@
// lib includes
#include "tray/src/tray.h"
#include <boost/filesystem.hpp>
#include <boost/process/environment.hpp>
#include <boost/process/v1/environment.hpp>
// local includes
#include "config.h"