mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-06-20 21:42:05 +08:00
CommaApi: class to namespace (#21329)
This commit is contained in:
@@ -15,11 +15,13 @@
|
||||
#include "selfdrive/common/util.h"
|
||||
#include "selfdrive/hardware/hw.h"
|
||||
|
||||
namespace CommaApi {
|
||||
|
||||
const std::string private_key_path =
|
||||
Hardware::PC() ? util::getenv_default("HOME", "/.comma/persist/comma/id_rsa", "/persist/comma/id_rsa")
|
||||
: "/persist/comma/id_rsa";
|
||||
|
||||
QByteArray CommaApi::rsa_sign(const QByteArray &data) {
|
||||
QByteArray rsa_sign(const QByteArray &data) {
|
||||
auto file = QFile(private_key_path.c_str());
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
qDebug() << "No RSA private key found, please run manager.py or registration.py";
|
||||
@@ -43,7 +45,7 @@ QByteArray CommaApi::rsa_sign(const QByteArray &data) {
|
||||
return sig;
|
||||
}
|
||||
|
||||
QString CommaApi::create_jwt(const QJsonObject &payloads, int expiry) {
|
||||
QString create_jwt(const QJsonObject &payloads, int expiry) {
|
||||
QJsonObject header = {{"alg", "RS256"}};
|
||||
|
||||
QString dongle_id = QString::fromStdString(Params().get("DongleId"));
|
||||
@@ -63,6 +65,7 @@ QString CommaApi::create_jwt(const QJsonObject &payloads, int expiry) {
|
||||
return jwt;
|
||||
}
|
||||
|
||||
} // namespace CommaApi
|
||||
|
||||
HttpRequest::HttpRequest(QObject *parent, const QString &requestURL, const QString &cache_key, bool create_jwt_) : cache_key(cache_key), create_jwt(create_jwt_), QObject(parent) {
|
||||
networkAccessManager = new QNetworkAccessManager(this);
|
||||
|
||||
@@ -5,13 +5,12 @@
|
||||
#include <QString>
|
||||
#include <QTimer>
|
||||
|
||||
class CommaApi : public QObject {
|
||||
Q_OBJECT
|
||||
namespace CommaApi {
|
||||
|
||||
public:
|
||||
static QByteArray rsa_sign(const QByteArray &data);
|
||||
static QString create_jwt(const QJsonObject &payloads = {}, int expiry = 3600);
|
||||
};
|
||||
QByteArray rsa_sign(const QByteArray &data);
|
||||
QString create_jwt(const QJsonObject &payloads = {}, int expiry = 3600);
|
||||
|
||||
} // namespace CommaApi
|
||||
|
||||
/**
|
||||
* Makes a request to the request endpoint.
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
#include <QVBoxLayout>
|
||||
#include <QWidget>
|
||||
|
||||
#include "selfdrive/ui/qt/api.h"
|
||||
|
||||
class PairingQRWidget : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
@@ -31,7 +29,6 @@ private:
|
||||
QVBoxLayout* mainLayout;
|
||||
QLabel* username;
|
||||
QLabel* points;
|
||||
CommaApi* api;
|
||||
|
||||
private slots:
|
||||
void replyFinished(const QString &response);
|
||||
@@ -51,7 +48,6 @@ public:
|
||||
|
||||
private:
|
||||
QStackedWidget* mainLayout;
|
||||
CommaApi* api;
|
||||
PrimeAdWidget *primeAd;
|
||||
PrimeUserWidget *primeUser;
|
||||
bool showQr = false;
|
||||
|
||||
Reference in New Issue
Block a user