qt/network/sunnylink: rename

This commit is contained in:
Jaosn Wen
2024-07-16 15:05:01 -04:00
parent dbaa14dec1
commit 1b291893bb
15 changed files with 37 additions and 54 deletions
+4 -4
View File
@@ -22,10 +22,10 @@ widgets_src = [
]
network_src = [
"sunnypilot/qt/network/sunnylink/sunnylink_client.cc",
"sunnypilot/qt/network/sunnylink/services/base_device_service.cc",
"sunnypilot/qt/network/sunnylink/services/role_service.cc",
"sunnypilot/qt/network/sunnylink/services/user_service.cc"]
"sunnypilot/qt/network/sunnylink/sp_priv_sunnylink_client.cc",
"sunnypilot/qt/network/sunnylink/services/sp_priv_base_device_service.cc",
"sunnypilot/qt/network/sunnylink/services/sp_priv_role_service.cc",
"sunnypilot/qt/network/sunnylink/services/sp_priv_user_service.cc"]
qt_src = [
"sunnypilot/qt/sp_priv_home.cc",
@@ -1,5 +1,4 @@
#ifndef ROLE_MODEL_H
#define ROLE_MODEL_H
#pragma once
#include <QJsonObject>
@@ -56,5 +55,3 @@ public:
return T(m_raw_json_object);
}
};
#endif
@@ -1,5 +1,4 @@
#ifndef SPONSORROLE_MODEL_H
#define SPONSORROLE_MODEL_H
#pragma once
#include <QJsonObject>
@@ -24,7 +23,7 @@ public:
QJsonObject json = RoleModel::toJson();
json["role_tier"] = sponsorTierToString(roleTier);
return json;
};
}
static SponsorTier stringToSponsorTier(const QString &sponsorTierString) {
const auto sponsorTierStringLower = sponsorTierString.toLower();
@@ -80,5 +79,3 @@ public:
}
[[nodiscard]] auto getSponsorTierColor() const { return sponsorTierToColor(roleTier); }
};
#endif
@@ -1,5 +1,4 @@
#ifndef USER_MODEL_H
#define USER_MODEL_H
#pragma once
#include <QJsonObject>
@@ -29,5 +28,3 @@ public:
return json;
}
};
#endif
@@ -1,4 +1,4 @@
#include "base_device_service.h"
#include "selfdrive/ui/sunnypilot/qt/network/sunnylink//services/sp_priv_base_device_service.h"
#include "common/swaglog.h"
#include "selfdrive/ui/qt/util.h"
@@ -31,7 +31,7 @@ void BaseDeviceService::loadDeviceData(const QString &url, bool poll) {
LOGD("Cache key: SunnylinkCache_%s", qPrintable(QString(getCacheKey())));
repeater = new RequestRepeater(this, fullUrl, "SunnylinkCache_" + getCacheKey(), 60, false, true);
connect(repeater, &RequestRepeater::requestDone, this, &BaseDeviceService::handleResponse);
} else if(isCurrentyPolling()){
} else if (isCurrentyPolling()) {
repeater->ForceUpdate();
} else {
LOGD("Sending one-time %s", qPrintable(fullUrl));
@@ -1,6 +1,4 @@
#ifndef BASESERVICE_H
#define BASESERVICE_H
#pragma once
#include "selfdrive/ui/qt/api.h"
#include "selfdrive/ui/qt/request_repeater.h"
@@ -14,7 +12,7 @@ protected:
void loadDeviceData(const QString &url, bool poll = false);
virtual void handleResponse(const QString &response, bool success) = 0;
static bool is_sunnylink_enabled() { return Params().getBool("SunnylinkEnabled");};
static bool is_sunnylink_enabled() { return Params().getBool("SunnylinkEnabled");}
ParamWatcher* param_watcher;
HttpRequest* initial_request = nullptr;
RequestRepeater* repeater = nullptr;
@@ -25,5 +23,3 @@ public:
bool isCurrentyPolling() {return repeater != nullptr;}
void stopPolling();
};
#endif
@@ -1,4 +1,4 @@
#include "selfdrive/ui/sunnypilot/qt/network/sunnylink/services/role_service.h"
#include "selfdrive/ui/sunnypilot/qt/network/sunnylink/services/sp_priv_role_service.h"
#include <QJsonArray>
#include <QJsonDocument>
@@ -1,8 +1,9 @@
#ifndef ROLESERVICE_H
#define ROLESERVICE_H
#pragma once
#include "selfdrive/ui/sunnypilot/qt/network/sunnylink/services/base_device_service.h"
#include "selfdrive/ui/sunnypilot/qt/network/sunnylink/models/role_model.h"
#include <vector>
#include "selfdrive/ui/sunnypilot/qt/network/sunnylink/services/sp_priv_base_device_service.h"
#include "selfdrive/ui/sunnypilot/qt/network/sunnylink/models/sp_priv_role_model.h"
class RoleService : public BaseDeviceService {
Q_OBJECT
@@ -11,7 +12,7 @@ public:
explicit RoleService(QObject* parent = nullptr);
void load();
void startPolling();
[[nodiscard]] QString getCacheKey() const final { return "Roles"; };
[[nodiscard]] QString getCacheKey() const final { return "Roles"; }
signals:
void rolesReady(const std::vector<RoleModel> &roles);
@@ -22,5 +23,3 @@ protected:
private:
QString url = "/roles";
};
#endif
@@ -1,4 +1,4 @@
#include "selfdrive/ui/sunnypilot/qt/network/sunnylink/services/user_service.h"
#include "selfdrive/ui/sunnypilot/qt/network/sunnylink/services/sp_priv_user_service.h"
#include <QJsonArray>
#include <QJsonDocument>
@@ -1,8 +1,9 @@
#ifndef USERSERVICE_H
#define USERSERVICE_H
#pragma once
#include "selfdrive/ui/sunnypilot/qt/network/sunnylink/services/base_device_service.h"
#include "selfdrive/ui/sunnypilot/qt/network/sunnylink/models/user_model.h"
#include <vector>
#include "selfdrive/ui/sunnypilot/qt/network/sunnylink/services/sp_priv_base_device_service.h"
#include "selfdrive/ui/sunnypilot/qt/network/sunnylink/models/sp_priv_user_model.h"
class UserService : public BaseDeviceService {
Q_OBJECT
@@ -22,5 +23,3 @@ protected:
private:
QString url = "/users";
};
#endif
@@ -1,5 +1,5 @@
#include "selfdrive/ui/sunnypilot/qt/network/sunnylink/sunnylink_client.h"
#include "selfdrive/ui/sunnypilot/qt/network/sunnylink/services/user_service.h"
#include "selfdrive/ui/sunnypilot/qt/network/sunnylink/sp_priv_sunnylink_client.h"
#include "selfdrive/ui/sunnypilot/qt/network/sunnylink/services/sp_priv_user_service.h"
SunnylinkClient::SunnylinkClient(QObject* parent) : QObject(parent) {
role_service = new RoleService(parent);
@@ -1,10 +1,9 @@
#ifndef SUNNYLINK_CLIENT_H
#define SUNNYLINK_CLIENT_H
#pragma once
#include <QObject>
#include "selfdrive/ui/sunnypilot/qt/network/sunnylink/services/role_service.h"
#include "selfdrive/ui/sunnypilot/qt/network/sunnylink/services/user_service.h"
#include "selfdrive/ui/sunnypilot/qt/network/sunnylink/services/sp_priv_role_service.h"
#include "selfdrive/ui/sunnypilot/qt/network/sunnylink/services/sp_priv_user_service.h"
class SunnylinkClient : public QObject {
Q_OBJECT
@@ -14,5 +13,3 @@ public:
RoleService* role_service;
UserService* user_service;
};
#endif
@@ -3,7 +3,7 @@
#include <QtCore/qjsonobject.h>
#include <QrCode.hpp>
#include "selfdrive/ui/sunnypilot/qt/network/sunnylink/sunnylink_client.h"
#include "selfdrive/ui/sunnypilot/qt/network/sunnylink/sp_priv_sunnylink_client.h"
#include "selfdrive/ui/ui.h"
#include "selfdrive/ui/qt/util.h"
+1 -1
View File
@@ -11,7 +11,7 @@
#include "common/swaglog.h"
#include "common/util.h"
#include "common/watchdog.h"
#include "sunnypilot/qt/network/sunnylink/models/role_model.h"
#include "selfdrive/ui/sunnypilot/qt/network/sunnylink/models/sp_priv_role_model.h"
#include "system/hardware/hw.h"
#define BACKLIGHT_DT 0.05
+5 -4
View File
@@ -3,6 +3,7 @@
#include <memory>
#include <optional>
#include <string>
#include <vector>
#include <QObject>
#include <QTimer>
@@ -15,9 +16,9 @@
#include "common/mat.h"
#include "common/params.h"
#include "common/timing.h"
#include "sunnypilot/qt/network/sunnylink/models/role_model.h"
#include "sunnypilot/qt/network/sunnylink/models/sponsor_role_model.h"
#include "sunnypilot/qt/network/sunnylink/models/user_model.h"
#include "selfdrive/ui/sunnypilot/qt/network/sunnylink/models/sp_priv_role_model.h"
#include "selfdrive/ui/sunnypilot/qt/network/sunnylink/models/sp_priv_sponsor_role_model.h"
#include "selfdrive/ui/sunnypilot/qt/network/sunnylink/models/sp_priv_user_model.h"
#include "system/hardware/hw.h"
const int UI_BORDER_SIZE = 30;
@@ -242,7 +243,7 @@ public:
inline SponsorRoleModel sunnylinkSponsorRole() const {
std::optional<SponsorRoleModel> sponsorRoleWithHighestTier = std::nullopt;
for (const auto &role : sunnylinkRoles) {
if(role.roleType != RoleType::Sponsor)
if (role.roleType != RoleType::Sponsor)
continue;
if (auto sponsorRole = role.as<SponsorRoleModel>(); !sponsorRoleWithHighestTier.has_value() || sponsorRoleWithHighestTier->roleTier < sponsorRole.roleTier) {