diff --git a/rpcs3/rpcs3.vcxproj b/rpcs3/rpcs3.vcxproj index dd29c87ac1..ef33068716 100644 --- a/rpcs3/rpcs3.vcxproj +++ b/rpcs3/rpcs3.vcxproj @@ -1266,6 +1266,7 @@ + @@ -1785,6 +1786,7 @@ "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\QTGeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -D_WINDOWS -DUNICODE -DWIN32 -DWIN64 -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_WINEXTRAS_LIB -DQT_CONCURRENT_LIB -D%(PreprocessorDefinitions) "-I.\..\3rdparty\wolfssl" "-I.\..\3rdparty\curl\include" "-I.\..\3rdparty\libusb\libusb" "-I$(VULKAN_SDK)\Include" "-I.\..\3rdparty\XAudio2Redist\include" "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtCore" "-I.\debug" "-I$(QTDIR)\mkspecs\win32-msvc2015" "-I.\QTGeneratedFiles\$(ConfigurationName)" "-I.\QTGeneratedFiles" "-I$(QTDIR)\include\QtWinExtras" "-I$(QTDIR)\include\QtConcurrent" + $(QTDIR)\bin\moc.exe;%(FullPath) diff --git a/rpcs3/rpcs3.vcxproj.filters b/rpcs3/rpcs3.vcxproj.filters index 27d085edab..472cbd3b55 100644 --- a/rpcs3/rpcs3.vcxproj.filters +++ b/rpcs3/rpcs3.vcxproj.filters @@ -883,6 +883,9 @@ Generated Files\Debug - LLVM + + rpcs3 + @@ -984,6 +987,9 @@ Gui\game list + + rpcs3 + diff --git a/rpcs3/rpcs3qt/CMakeLists.txt b/rpcs3/rpcs3qt/CMakeLists.txt index 240067934d..19a5694b85 100644 --- a/rpcs3/rpcs3qt/CMakeLists.txt +++ b/rpcs3/rpcs3qt/CMakeLists.txt @@ -5,6 +5,7 @@ breakpoint_list.cpp cg_disasm_window.cpp cheat_manager.cpp + curl_handle.cpp custom_dialog.cpp debugger_frame.cpp debugger_list.cpp diff --git a/rpcs3/rpcs3qt/curl_handle.cpp b/rpcs3/rpcs3qt/curl_handle.cpp new file mode 100644 index 0000000000..be68210454 --- /dev/null +++ b/rpcs3/rpcs3qt/curl_handle.cpp @@ -0,0 +1,24 @@ +#include "stdafx.h" +#include "curl_handle.h" +#include "Emu/System.h" + +curl_handle::curl_handle(QObject* parent) : QObject(parent) +{ + m_curl = curl_easy_init(); + +#ifdef _WIN32 + // This shouldn't be needed on linux + const std::string path_to_cert = Emulator::GetEmuDir() + "cacert.pem"; + curl_easy_setopt(m_curl, CURLOPT_CAINFO, path_to_cert.c_str()); +#endif +} + +curl_handle::~curl_handle() +{ + curl_easy_cleanup(m_curl); +} + +CURL* curl_handle::get_curl() +{ + return m_curl; +} diff --git a/rpcs3/rpcs3qt/curl_handle.h b/rpcs3/rpcs3qt/curl_handle.h new file mode 100644 index 0000000000..302282a75f --- /dev/null +++ b/rpcs3/rpcs3qt/curl_handle.h @@ -0,0 +1,20 @@ +#pragma once + +#include + +#ifndef CURL_STATICLIB +#define CURL_STATICLIB +#endif +#include + +class curl_handle : public QObject +{ +private: + CURL* m_curl = nullptr; + +public: + curl_handle(QObject* parent = nullptr); + ~curl_handle(); + + CURL* get_curl(); +}; diff --git a/rpcs3/rpcs3qt/game_compatibility.cpp b/rpcs3/rpcs3qt/game_compatibility.cpp index f3b0108e72..8c59da3b14 100644 --- a/rpcs3/rpcs3qt/game_compatibility.cpp +++ b/rpcs3/rpcs3qt/game_compatibility.cpp @@ -1,18 +1,13 @@ #include "game_compatibility.h" #include "gui_settings.h" #include "progress_dialog.h" +#include "curl_handle.h" #include #include #include #include -#define NOMINMAX -#ifndef CURL_STATICLIB -#define CURL_STATICLIB -#endif -#include - LOG_CHANNEL(compat_log, "Compat"); constexpr auto qstr = QString::fromStdString; @@ -29,12 +24,7 @@ game_compatibility::game_compatibility(std::shared_ptr settings) : m_filepath = m_xgui_settings->GetSettingsDir() + "/compat_database.dat"; m_url = "https://rpcs3.net/compatibility?api=v1&export"; - m_curl = curl_easy_init(); - -#ifdef _WIN32 - // This shouldn't be needed on linux - curl_easy_setopt(m_curl, CURLOPT_CAINFO, "cacert.pem"); -#endif + m_curl = new curl_handle(this); RequestCompatibility(); @@ -68,7 +58,7 @@ size_t game_compatibility::update_buffer(char* data, size_t size) if (m_actual_dwnld_size < 0) { - if (curl_easy_getinfo(m_curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &m_actual_dwnld_size) == CURLE_OK && m_actual_dwnld_size > 0) + if (curl_easy_getinfo(m_curl->get_curl(), CURLINFO_CONTENT_LENGTH_DOWNLOAD, &m_actual_dwnld_size) == CURLE_OK && m_actual_dwnld_size > 0) { max = static_cast(m_actual_dwnld_size); } @@ -183,10 +173,10 @@ void game_compatibility::RequestCompatibility(bool online) m_progress_dialog = new progress_dialog(tr("Downloading Database"), tr("Please wait ..."), tr("Abort"), 0, 100, true); m_progress_dialog->show(); - curl_easy_setopt(m_curl, CURLOPT_URL, m_url.c_str()); - curl_easy_setopt(m_curl, CURLOPT_WRITEFUNCTION, curl_write_cb_compat); - curl_easy_setopt(m_curl, CURLOPT_WRITEDATA, this); - curl_easy_setopt(m_curl, CURLOPT_FOLLOWLOCATION, 1); + curl_easy_setopt(m_curl->get_curl(), CURLOPT_URL, m_url.c_str()); + curl_easy_setopt(m_curl->get_curl(), CURLOPT_WRITEFUNCTION, curl_write_cb_compat); + curl_easy_setopt(m_curl->get_curl(), CURLOPT_WRITEDATA, this); + curl_easy_setopt(m_curl->get_curl(), CURLOPT_FOLLOWLOCATION, 1); m_curl_buf.clear(); m_curl_abort = false; @@ -197,7 +187,7 @@ void game_compatibility::RequestCompatibility(bool online) auto thread = QThread::create([&] { - const auto result = curl_easy_perform(m_curl); + const auto result = curl_easy_perform(m_curl->get_curl()); m_curl_result = result == CURLE_OK; if (!m_curl_result) diff --git a/rpcs3/rpcs3qt/game_compatibility.h b/rpcs3/rpcs3qt/game_compatibility.h index 42421fb909..6496717861 100644 --- a/rpcs3/rpcs3qt/game_compatibility.h +++ b/rpcs3/rpcs3qt/game_compatibility.h @@ -5,6 +5,7 @@ #include #include +class curl_handle; class gui_settings; class progress_dialog; @@ -40,7 +41,7 @@ private: std::atomic m_curl_result = false; std::atomic m_curl_abort = false; double m_actual_dwnld_size = -1.0; - void* m_curl = nullptr; + curl_handle* m_curl = nullptr; QByteArray m_curl_buf; progress_dialog* m_progress_dialog = nullptr; std::shared_ptr m_xgui_settings; diff --git a/rpcs3/rpcs3qt/update_manager.cpp b/rpcs3/rpcs3qt/update_manager.cpp index ee32860de4..a898aac320 100644 --- a/rpcs3/rpcs3qt/update_manager.cpp +++ b/rpcs3/rpcs3qt/update_manager.cpp @@ -3,6 +3,7 @@ #include "progress_dialog.h" #include "localized.h" #include "rpcs3_version.h" +#include "curl_handle.h" #include "Utilities/StrUtil.h" #include "Crypto/sha256.h" #include "Emu/System.h" @@ -32,11 +33,6 @@ #include #endif -#ifndef CURL_STATICLIB -#define CURL_STATICLIB -#endif -#include - LOG_CHANNEL(update_log, "UPDATER"); size_t curl_write_cb(char* ptr, size_t /*size*/, size_t nmemb, void* userdata) @@ -47,12 +43,7 @@ size_t curl_write_cb(char* ptr, size_t /*size*/, size_t nmemb, void* userdata) update_manager::update_manager() { - m_curl = curl_easy_init(); - -#ifdef _WIN32 - // This shouldn't be needed on linux - curl_easy_setopt(m_curl, CURLOPT_CAINFO, "cacert.pem"); -#endif + m_curl = new curl_handle(this); // We need this signal in order to update the GUI from the main thread connect(this, &update_manager::signal_buffer_update, this, &update_manager::handle_buffer_update); @@ -108,13 +99,13 @@ void update_manager::check_for_updates(bool automatic, QWidget* parent) connect(m_progress_dialog, &QProgressDialog::finished, m_progress_dialog, &QProgressDialog::deleteLater); const std::string request_url = "https://update.rpcs3.net/?api=v1&c=" + rpcs3::get_commit_and_hash().second; - curl_easy_setopt(m_curl, CURLOPT_URL, request_url.c_str()); - curl_easy_setopt(m_curl, CURLOPT_WRITEFUNCTION, curl_write_cb); - curl_easy_setopt(m_curl, CURLOPT_WRITEDATA, this); + curl_easy_setopt(m_curl->get_curl(), CURLOPT_URL, request_url.c_str()); + curl_easy_setopt(m_curl->get_curl(), CURLOPT_WRITEFUNCTION, curl_write_cb); + curl_easy_setopt(m_curl->get_curl(), CURLOPT_WRITEDATA, this); auto thread = QThread::create([this] { - const auto curl_result = curl_easy_perform(m_curl); + const auto curl_result = curl_easy_perform(m_curl->get_curl()); m_curl_result = curl_result == CURLE_OK; if (!m_curl_result) @@ -270,14 +261,14 @@ bool update_manager::handle_json(bool automatic) m_update_dialog = true; const std::string request_url = latest[os]["download"].toString().toStdString(); - curl_easy_setopt(m_curl, CURLOPT_URL, request_url.c_str()); - curl_easy_setopt(m_curl, CURLOPT_FOLLOWLOCATION, 1); + curl_easy_setopt(m_curl->get_curl(), CURLOPT_URL, request_url.c_str()); + curl_easy_setopt(m_curl->get_curl(), CURLOPT_FOLLOWLOCATION, 1); m_curl_buf.clear(); auto thread = QThread::create([this] { - const auto curl_result = curl_easy_perform(m_curl); + const auto curl_result = curl_easy_perform(m_curl->get_curl()); m_curl_result = curl_result == CURLE_OK; if (!m_curl_result) diff --git a/rpcs3/rpcs3qt/update_manager.h b/rpcs3/rpcs3qt/update_manager.h index 0b4a21974d..5865c50e7d 100644 --- a/rpcs3/rpcs3qt/update_manager.h +++ b/rpcs3/rpcs3qt/update_manager.h @@ -4,6 +4,7 @@ #include #include +class curl_handle; class progress_dialog; class update_manager final : public QObject @@ -15,7 +16,7 @@ private: progress_dialog* m_progress_dialog = nullptr; QWidget* m_parent = nullptr; - void* m_curl = nullptr; + curl_handle* m_curl = nullptr; QByteArray m_curl_buf; std::atomic m_curl_abort = false; std::atomic m_curl_result = false;