Merge branch 'master' into windows-clang

This commit is contained in:
Live session user 2026-02-28 12:27:14 -08:00
commit 64c419089f
11 changed files with 64 additions and 41 deletions

View file

@ -900,7 +900,7 @@ lv2_file::open_raw_result_t lv2_file::open_raw(const std::string& local_path, s3
switch (auto error = fs::g_tls_error)
{
case fs::error::noent: return {CELL_ENOENT};
default: sys_fs.error("lv2_file::open(): unknown error %s", error);
default: sys_fs.error("lv2_file::open(): unknown error %s", error); break;
}
return {CELL_EIO};

View file

@ -128,12 +128,6 @@ void fmt_class_string<clan::ClanRequestAction>::format(std::string& out, u64 arg
namespace clan
{
struct curl_memory
{
char* response;
size_t size;
};
size_t clans_client::curl_write_callback(void* data, size_t size, size_t nmemb, void* clientp)
{
const size_t realsize = size * nmemb;

View file

@ -254,7 +254,7 @@ namespace np
// Trim null characters
const auto& vec = node.data.data_vec;
auto it = std::find(vec.begin(), vec.end(), 0);
const auto it = std::find(vec.begin(), vec.end(), 0);
return std::string(vec.begin(), it);
}
@ -1375,12 +1375,12 @@ namespace np
return history;
}
u32 np_handler::get_clan_ticket_ready()
u32 np_handler::get_clan_ticket_ready() const
{
return clan_ticket_ready.load();
}
ticket np_handler::get_clan_ticket()
ticket np_handler::get_clan_ticket() const
{
clan_ticket_ready.wait(0, atomic_wait_timeout{60'000'000'000}); // 60 seconds

View file

@ -257,8 +257,8 @@ namespace np
// Misc stuff
void req_ticket(u32 version, const SceNpId* npid, const char* service_id, const u8* cookie, u32 cookie_size, const char* entitlement_id, u32 consumed_count);
const ticket& get_ticket() const;
u32 get_clan_ticket_ready();
ticket get_clan_ticket();
u32 get_clan_ticket_ready() const;
ticket get_clan_ticket() const;
void add_player_to_history(const SceNpId* npid, const char* description);
u32 add_players_to_history(const SceNpId* npids, const char* description, u32 count);
u32 get_players_history_count(u32 options);

View file

@ -920,19 +920,19 @@ namespace np
ensure(!reply.is_error(), "Malformed reply to RequestTicket command");
auto incoming_ticket = ticket(std::move(ticket_raw));
// Clans: check if ticket belongs to the clan service.
// If so, hijack the ticket and cache it for future use.
if (incoming_ticket.get_service_id() == CLANS_SERVICE_ID)
{
clan_ticket = incoming_ticket;
clan_ticket = std::move(incoming_ticket);
clan_ticket_ready.store(1);
clan_ticket_ready.notify_all();
return;
}
current_ticket = incoming_ticket;
current_ticket = std::move(incoming_ticket);
auto ticket_size = static_cast<s32>(current_ticket.size());
if (manager_cb)

View file

@ -1,5 +1,6 @@
#include <QApplication>
#include <QThread>
#include <QJsonObject>
#include "downloader.h"
#include "curl_handle.h"
@ -7,6 +8,8 @@
#include "util/logs.hpp"
#include <thread>
LOG_CHANNEL(network_log, "NET");
usz curl_write_cb_compat(char* ptr, usz /*size*/, usz nmemb, void* userdata)
@ -31,7 +34,7 @@ downloader::~downloader()
}
}
void downloader::start(const std::string& url, bool follow_location, bool show_progress_dialog, const QString& progress_dialog_title, bool keep_progress_dialog_open, int expected_size)
void downloader::start(const std::string& url, bool follow_location, bool show_progress_dialog, const QString& progress_dialog_title, bool keep_progress_dialog_open, int expected_size, bool check_return_code, bool again)
{
network_log.notice("Starting download from URL: %s", url);
@ -49,6 +52,21 @@ void downloader::start(const std::string& url, bool follow_location, bool show_p
m_curl_buf.clear();
m_curl_abort = false;
if (again)
{
m_download_attempts++;
if (m_progress_dialog && m_download_attempts > 1)
{
handle_buffer_update(0, 100);
m_progress_dialog->setLabelText(tr("Please wait... Trying again"));
}
}
else
{
m_download_attempts = 1;
}
CURLcode err = curl_easy_setopt(m_curl->get_curl(), CURLOPT_URL, url.c_str());
if (err != CURLE_OK) network_log.error("curl_easy_setopt(CURLOPT_URL, %s) error: %s", url, curl_easy_strerror(err));
@ -77,7 +95,7 @@ void downloader::start(const std::string& url, bool follow_location, bool show_p
}
});
connect(m_thread, &QThread::finished, this, [this]()
connect(m_thread, &QThread::finished, this, [=, this]()
{
if (m_curl_abort)
{
@ -93,6 +111,21 @@ void downloader::start(const std::string& url, bool follow_location, bool show_p
if (m_curl_success)
{
network_log.notice("Download finished");
if (check_return_code && m_download_attempts < 3)
{
const QJsonObject json_data = QJsonDocument::fromJson(m_curl_buf).object();
const int return_code = json_data["return_code"].toInt(-255);
if (return_code == -255)
{
network_log.error("Error during download. Trying to download again (attempts=%d, return_code=%d)", m_download_attempts, return_code);
std::this_thread::sleep_for(500ms); // Wait for a little while
start(url, follow_location, show_progress_dialog, progress_dialog_title, keep_progress_dialog_open, expected_size, check_return_code, true);
return;
}
}
Q_EMIT signal_download_finished(m_curl_buf);
}
});

View file

@ -21,7 +21,7 @@ public:
explicit downloader(QWidget* parent = nullptr);
~downloader();
void start(const std::string& url, bool follow_location, bool show_progress_dialog, const QString& progress_dialog_title = "", bool keep_progress_dialog_open = false, int expected_size = -1);
void start(const std::string& url, bool follow_location, bool show_progress_dialog, const QString& progress_dialog_title = "", bool keep_progress_dialog_open = false, int expected_size = -1, bool check_return_code = true, bool again = false);
usz update_buffer(char* data, usz size);
void update_progress_dialog(const QString& title) const;
@ -46,6 +46,7 @@ private:
atomic_t<bool> m_curl_abort = false;
atomic_t<bool> m_curl_success = false;
double m_actual_download_size = -1.0;
u32 m_download_attempts = 0;
progress_dialog* m_progress_dialog = nullptr;
atomic_t<bool> m_keep_progress_dialog_open = false;

View file

@ -69,7 +69,7 @@ void game_compatibility::handle_download_canceled()
bool game_compatibility::ReadJSON(const QJsonObject& json_data, bool after_download)
{
const int return_code = json_data["return_code"].toInt();
const int return_code = json_data["return_code"].toInt(-255);
if (return_code < 0)
{
@ -78,15 +78,10 @@ bool game_compatibility::ReadJSON(const QJsonObject& json_data, bool after_downl
std::string error_message;
switch (return_code)
{
case -1:
error_message = "Server Error - Internal Error";
break;
case -2:
error_message = "Server Error - Maintenance Mode";
break;
default:
error_message = "Server Error - Unknown Error";
break;
case -1: error_message = "Server Error - Internal Error"; break;
case -2: error_message = "Server Error - Maintenance Mode"; break;
case -255: error_message = "Server Error - Return code not found"; break;
default: error_message = "Server Error - Unknown Error"; break;
}
compat_log.error("%s: return code %d", error_message, return_code);
Q_EMIT DownloadError(QString::fromStdString(error_message) + " " + QString::number(return_code));

View file

@ -1184,9 +1184,9 @@ bool patch_manager_dialog::handle_json(const QByteArray& data)
}
if (return_code != -1)
patch_log.error("Patch download error: %s return code: %d", error_message, return_code);
patch_log.error("Patch download error: %s, return code: %d", error_message, return_code);
else
patch_log.warning("Patch download error: %s return code: %d", error_message, return_code);
patch_log.warning("Patch download error: %s, return code: %d", error_message, return_code);
return false;
}

View file

@ -135,9 +135,9 @@ bool update_manager::handle_json(bool automatic, bool check_only, bool auto_acce
}
if (return_code != -1)
update_log.error("Update error: %s return code: %d", error_message, return_code);
update_log.error("Update error: %s, return code: %d", error_message, return_code);
else
update_log.warning("Update error: %s return code: %d", error_message, return_code);
update_log.warning("Update error: %s, return code: %d", error_message, return_code);
// If a user clicks "Check for Updates" with a custom build ask him if he's sure he wants to update to latest version
if (!automatic && return_code == -1)

View file

@ -13,6 +13,14 @@ class update_manager final : public QObject
{
Q_OBJECT
public:
update_manager(QObject* parent, std::shared_ptr<gui_settings> gui_settings);
void check_for_updates(bool automatic, bool check_only, bool auto_accept, QWidget* parent = nullptr);
void update(bool auto_accept);
Q_SIGNALS:
void signal_update_available(bool update_available);
private:
downloader* m_downloader = nullptr;
QWidget* m_parent = nullptr;
@ -45,12 +53,4 @@ private:
bool handle_json(bool automatic, bool check_only, bool auto_accept, const QByteArray& data);
bool handle_rpcs3(const QByteArray& data, bool auto_accept);
public:
update_manager(QObject* parent, std::shared_ptr<gui_settings> gui_settings);
void check_for_updates(bool automatic, bool check_only, bool auto_accept, QWidget* parent = nullptr);
void update(bool auto_accept);
Q_SIGNALS:
void signal_update_available(bool update_available);
};