Clans: HTTP/S support

Signed-off-by: zeph <35661622+ZephyrCodesStuff@users.noreply.github.com>
This commit is contained in:
zeph 2025-12-07 18:43:42 +01:00
parent f467a15e83
commit 53cd84300d
No known key found for this signature in database
5 changed files with 33 additions and 3 deletions

View File

@ -180,7 +180,8 @@ namespace clan
}
std::string host = g_cfg_clans.get_host();
std::string url = std::format("https://{}/clan_manager_{}/{}/{}", host, opType, reqType, action);
std::string protocol = g_cfg_clans.get_use_https() ? "https" : "http";
std::string url = std::format("{}://{}/clan_manager_{}/{}/{}", protocol, host, opType, reqType, action);
std::ostringstream oss;
xmlBody->save(oss, "\t", 8U);
@ -969,8 +970,8 @@ namespace clan
};
strncpy(entry.message.subject, subject_str.c_str(), subject_str.size());
strncpy(entry.message.body, msg_str.c_str(), msg_str.size());
snprintf(entry.message.subject, sizeof(entry.message.subject), "%s", subject_str.c_str());
snprintf(entry.message.body, sizeof(entry.message.body), "%s", msg_str.c_str());
announcements[i] = entry;
i++;

View File

@ -51,6 +51,11 @@ std::string cfg_clans::get_host() const
return host.to_string();
}
bool cfg_clans::get_use_https() const
{
return use_https.get();
}
std::vector<std::pair<std::string, std::string>> cfg_clans::get_hosts()
{
std::vector<std::pair<std::string, std::string>> vec_hosts;
@ -82,6 +87,11 @@ void cfg_clans::set_host(std::string_view host)
this->host.from_string(host);
}
void cfg_clans::set_use_https(bool use_https)
{
this->use_https.set(use_https);
}
void cfg_clans::set_hosts(const std::vector<std::pair<std::string, std::string>>& vec_hosts)
{
std::string final_string;

View File

@ -7,14 +7,17 @@ struct cfg_clans : cfg::node
cfg::uint32 version{this, "Version", 1};
cfg::string host{this, "Host", "clans.rpcs3.net"};
cfg::string hosts{this, "Hosts", "Official Clans Server|clans.rpcs3.net"};
cfg::_bool use_https{this, "Use HTTPS", true};
void load();
void save() const;
std::string get_host() const;
bool get_use_https() const;
std::vector<std::pair<std::string, std::string>> get_hosts();
void set_host(std::string_view host);
void set_use_https(bool use_https);
bool add_host(std::string_view description, std::string_view host);
bool del_host(std::string_view description, std::string_view host);

View File

@ -25,11 +25,17 @@ clans_settings_dialog::clans_settings_dialog(QWidget* parent)
QHBoxLayout* hbox_lbl_combo = new QHBoxLayout();
QLabel* lbl_server = new QLabel(tr("Server:"));
cbx_servers = new QComboBox();
cbx_protocol = new QComboBox();
cbx_protocol->addItem("HTTPS");
cbx_protocol->addItem("HTTP");
cbx_protocol->setCurrentIndex(g_cfg_clans.get_use_https() ? 0 : 1);
refresh_combobox();
hbox_lbl_combo->addWidget(lbl_server);
hbox_lbl_combo->addWidget(cbx_servers);
hbox_lbl_combo->addWidget(cbx_protocol);
QHBoxLayout* hbox_buttons = new QHBoxLayout();
QPushButton* btn_add_server = new QPushButton(tr("Add"));
@ -60,6 +66,15 @@ clans_settings_dialog::clans_settings_dialog(QWidget* parent)
g_cfg_clans.save();
});
connect(cbx_protocol, &QComboBox::currentIndexChanged, this, [this](int index)
{
if (index < 0)
return;
g_cfg_clans.set_use_https(index == 0);
g_cfg_clans.save();
});
connect(btn_add_server, &QAbstractButton::clicked, this, [this]()
{
clans_add_server_dialog dlg(this);

View File

@ -15,6 +15,7 @@ private:
private:
QComboBox* cbx_servers = nullptr;
QComboBox* cbx_protocol = nullptr;
};
class clans_add_server_dialog : public QDialog