From 1b291893bb9bdf9a37cd6da24938c9ec90f27e7f Mon Sep 17 00:00:00 2001 From: Jaosn Wen Date: Tue, 16 Jul 2024 15:05:01 -0400 Subject: [PATCH] qt/network/sunnylink: rename --- selfdrive/ui/sunnypilot/SConscript | 8 ++++---- .../models/{role_model.h => sp_priv_role_model.h} | 5 +---- ...or_role_model.h => sp_priv_sponsor_role_model.h} | 7 ++----- .../models/{user_model.h => sp_priv_user_model.h} | 5 +---- ...ce_service.cc => sp_priv_base_device_service.cc} | 4 ++-- ...vice_service.h => sp_priv_base_device_service.h} | 8 ++------ .../{role_service.cc => sp_priv_role_service.cc} | 2 +- .../{role_service.h => sp_priv_role_service.h} | 13 ++++++------- .../{user_service.cc => sp_priv_user_service.cc} | 2 +- .../{user_service.h => sp_priv_user_service.h} | 11 +++++------ ...nylink_client.cc => sp_priv_sunnylink_client.cc} | 4 ++-- ...unnylink_client.h => sp_priv_sunnylink_client.h} | 9 +++------ .../ui/sunnypilot/qt/offroad/sunnylink_settings.h | 2 +- selfdrive/ui/ui.cc | 2 +- selfdrive/ui/ui.h | 9 +++++---- 15 files changed, 37 insertions(+), 54 deletions(-) rename selfdrive/ui/sunnypilot/qt/network/sunnylink/models/{role_model.h => sp_priv_role_model.h} (96%) rename selfdrive/ui/sunnypilot/qt/network/sunnylink/models/{sponsor_role_model.h => sp_priv_sponsor_role_model.h} (97%) rename selfdrive/ui/sunnypilot/qt/network/sunnylink/models/{user_model.h => sp_priv_user_model.h} (93%) rename selfdrive/ui/sunnypilot/qt/network/sunnylink/services/{base_device_service.cc => sp_priv_base_device_service.cc} (92%) rename selfdrive/ui/sunnypilot/qt/network/sunnylink/services/{base_device_service.h => sp_priv_base_device_service.h} (90%) rename selfdrive/ui/sunnypilot/qt/network/sunnylink/services/{role_service.cc => sp_priv_role_service.cc} (96%) rename selfdrive/ui/sunnypilot/qt/network/sunnylink/services/{role_service.h => sp_priv_role_service.h} (75%) rename selfdrive/ui/sunnypilot/qt/network/sunnylink/services/{user_service.cc => sp_priv_user_service.cc} (96%) rename selfdrive/ui/sunnypilot/qt/network/sunnylink/services/{user_service.h => sp_priv_user_service.h} (76%) rename selfdrive/ui/sunnypilot/qt/network/sunnylink/{sunnylink_client.cc => sp_priv_sunnylink_client.cc} (67%) rename selfdrive/ui/sunnypilot/qt/network/sunnylink/{sunnylink_client.h => sp_priv_sunnylink_client.h} (77%) diff --git a/selfdrive/ui/sunnypilot/SConscript b/selfdrive/ui/sunnypilot/SConscript index bcc296e496..c0cd96dcfd 100644 --- a/selfdrive/ui/sunnypilot/SConscript +++ b/selfdrive/ui/sunnypilot/SConscript @@ -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", diff --git a/selfdrive/ui/sunnypilot/qt/network/sunnylink/models/role_model.h b/selfdrive/ui/sunnypilot/qt/network/sunnylink/models/sp_priv_role_model.h similarity index 96% rename from selfdrive/ui/sunnypilot/qt/network/sunnylink/models/role_model.h rename to selfdrive/ui/sunnypilot/qt/network/sunnylink/models/sp_priv_role_model.h index d7f3a98281..a5c40e5057 100644 --- a/selfdrive/ui/sunnypilot/qt/network/sunnylink/models/role_model.h +++ b/selfdrive/ui/sunnypilot/qt/network/sunnylink/models/sp_priv_role_model.h @@ -1,5 +1,4 @@ -#ifndef ROLE_MODEL_H -#define ROLE_MODEL_H +#pragma once #include @@ -56,5 +55,3 @@ public: return T(m_raw_json_object); } }; - -#endif diff --git a/selfdrive/ui/sunnypilot/qt/network/sunnylink/models/sponsor_role_model.h b/selfdrive/ui/sunnypilot/qt/network/sunnylink/models/sp_priv_sponsor_role_model.h similarity index 97% rename from selfdrive/ui/sunnypilot/qt/network/sunnylink/models/sponsor_role_model.h rename to selfdrive/ui/sunnypilot/qt/network/sunnylink/models/sp_priv_sponsor_role_model.h index 64aad1ca46..e964c66c28 100644 --- a/selfdrive/ui/sunnypilot/qt/network/sunnylink/models/sponsor_role_model.h +++ b/selfdrive/ui/sunnypilot/qt/network/sunnylink/models/sp_priv_sponsor_role_model.h @@ -1,5 +1,4 @@ -#ifndef SPONSORROLE_MODEL_H -#define SPONSORROLE_MODEL_H +#pragma once #include @@ -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 diff --git a/selfdrive/ui/sunnypilot/qt/network/sunnylink/models/user_model.h b/selfdrive/ui/sunnypilot/qt/network/sunnylink/models/sp_priv_user_model.h similarity index 93% rename from selfdrive/ui/sunnypilot/qt/network/sunnylink/models/user_model.h rename to selfdrive/ui/sunnypilot/qt/network/sunnylink/models/sp_priv_user_model.h index 72baa3983d..1f83af9be2 100644 --- a/selfdrive/ui/sunnypilot/qt/network/sunnylink/models/user_model.h +++ b/selfdrive/ui/sunnypilot/qt/network/sunnylink/models/sp_priv_user_model.h @@ -1,5 +1,4 @@ -#ifndef USER_MODEL_H -#define USER_MODEL_H +#pragma once #include @@ -29,5 +28,3 @@ public: return json; } }; - -#endif diff --git a/selfdrive/ui/sunnypilot/qt/network/sunnylink/services/base_device_service.cc b/selfdrive/ui/sunnypilot/qt/network/sunnylink/services/sp_priv_base_device_service.cc similarity index 92% rename from selfdrive/ui/sunnypilot/qt/network/sunnylink/services/base_device_service.cc rename to selfdrive/ui/sunnypilot/qt/network/sunnylink/services/sp_priv_base_device_service.cc index 46752b38a4..c2d4e6f87a 100644 --- a/selfdrive/ui/sunnypilot/qt/network/sunnylink/services/base_device_service.cc +++ b/selfdrive/ui/sunnypilot/qt/network/sunnylink/services/sp_priv_base_device_service.cc @@ -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)); diff --git a/selfdrive/ui/sunnypilot/qt/network/sunnylink/services/base_device_service.h b/selfdrive/ui/sunnypilot/qt/network/sunnylink/services/sp_priv_base_device_service.h similarity index 90% rename from selfdrive/ui/sunnypilot/qt/network/sunnylink/services/base_device_service.h rename to selfdrive/ui/sunnypilot/qt/network/sunnylink/services/sp_priv_base_device_service.h index cd7aa9d9b9..9b8900a328 100644 --- a/selfdrive/ui/sunnypilot/qt/network/sunnylink/services/base_device_service.h +++ b/selfdrive/ui/sunnypilot/qt/network/sunnylink/services/sp_priv_base_device_service.h @@ -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 diff --git a/selfdrive/ui/sunnypilot/qt/network/sunnylink/services/role_service.cc b/selfdrive/ui/sunnypilot/qt/network/sunnylink/services/sp_priv_role_service.cc similarity index 96% rename from selfdrive/ui/sunnypilot/qt/network/sunnylink/services/role_service.cc rename to selfdrive/ui/sunnypilot/qt/network/sunnylink/services/sp_priv_role_service.cc index e31d2af5fe..64b19d3a19 100644 --- a/selfdrive/ui/sunnypilot/qt/network/sunnylink/services/role_service.cc +++ b/selfdrive/ui/sunnypilot/qt/network/sunnylink/services/sp_priv_role_service.cc @@ -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 #include diff --git a/selfdrive/ui/sunnypilot/qt/network/sunnylink/services/role_service.h b/selfdrive/ui/sunnypilot/qt/network/sunnylink/services/sp_priv_role_service.h similarity index 75% rename from selfdrive/ui/sunnypilot/qt/network/sunnylink/services/role_service.h rename to selfdrive/ui/sunnypilot/qt/network/sunnylink/services/sp_priv_role_service.h index 13b5d0505b..9c7d951ef7 100644 --- a/selfdrive/ui/sunnypilot/qt/network/sunnylink/services/role_service.h +++ b/selfdrive/ui/sunnypilot/qt/network/sunnylink/services/sp_priv_role_service.h @@ -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 + +#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 &roles); @@ -22,5 +23,3 @@ protected: private: QString url = "/roles"; }; - -#endif diff --git a/selfdrive/ui/sunnypilot/qt/network/sunnylink/services/user_service.cc b/selfdrive/ui/sunnypilot/qt/network/sunnylink/services/sp_priv_user_service.cc similarity index 96% rename from selfdrive/ui/sunnypilot/qt/network/sunnylink/services/user_service.cc rename to selfdrive/ui/sunnypilot/qt/network/sunnylink/services/sp_priv_user_service.cc index 9076dc6a5c..f43df2861a 100644 --- a/selfdrive/ui/sunnypilot/qt/network/sunnylink/services/user_service.cc +++ b/selfdrive/ui/sunnypilot/qt/network/sunnylink/services/sp_priv_user_service.cc @@ -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 #include diff --git a/selfdrive/ui/sunnypilot/qt/network/sunnylink/services/user_service.h b/selfdrive/ui/sunnypilot/qt/network/sunnylink/services/sp_priv_user_service.h similarity index 76% rename from selfdrive/ui/sunnypilot/qt/network/sunnylink/services/user_service.h rename to selfdrive/ui/sunnypilot/qt/network/sunnylink/services/sp_priv_user_service.h index 53f490722c..dba8dd444c 100644 --- a/selfdrive/ui/sunnypilot/qt/network/sunnylink/services/user_service.h +++ b/selfdrive/ui/sunnypilot/qt/network/sunnylink/services/sp_priv_user_service.h @@ -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 + +#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 diff --git a/selfdrive/ui/sunnypilot/qt/network/sunnylink/sunnylink_client.cc b/selfdrive/ui/sunnypilot/qt/network/sunnylink/sp_priv_sunnylink_client.cc similarity index 67% rename from selfdrive/ui/sunnypilot/qt/network/sunnylink/sunnylink_client.cc rename to selfdrive/ui/sunnypilot/qt/network/sunnylink/sp_priv_sunnylink_client.cc index b56d9bd582..98bc734d95 100644 --- a/selfdrive/ui/sunnypilot/qt/network/sunnylink/sunnylink_client.cc +++ b/selfdrive/ui/sunnypilot/qt/network/sunnylink/sp_priv_sunnylink_client.cc @@ -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); diff --git a/selfdrive/ui/sunnypilot/qt/network/sunnylink/sunnylink_client.h b/selfdrive/ui/sunnypilot/qt/network/sunnylink/sp_priv_sunnylink_client.h similarity index 77% rename from selfdrive/ui/sunnypilot/qt/network/sunnylink/sunnylink_client.h rename to selfdrive/ui/sunnypilot/qt/network/sunnylink/sp_priv_sunnylink_client.h index cd802b590e..f63a0f44dc 100644 --- a/selfdrive/ui/sunnypilot/qt/network/sunnylink/sunnylink_client.h +++ b/selfdrive/ui/sunnypilot/qt/network/sunnylink/sp_priv_sunnylink_client.h @@ -1,10 +1,9 @@ -#ifndef SUNNYLINK_CLIENT_H -#define SUNNYLINK_CLIENT_H +#pragma once #include -#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 diff --git a/selfdrive/ui/sunnypilot/qt/offroad/sunnylink_settings.h b/selfdrive/ui/sunnypilot/qt/offroad/sunnylink_settings.h index 1a3cb630d9..4027147975 100644 --- a/selfdrive/ui/sunnypilot/qt/offroad/sunnylink_settings.h +++ b/selfdrive/ui/sunnypilot/qt/offroad/sunnylink_settings.h @@ -3,7 +3,7 @@ #include #include -#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" diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index 72571c4b85..3a3741a27b 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -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 diff --git a/selfdrive/ui/ui.h b/selfdrive/ui/ui.h index eb02b8d2d8..b28aa6a74d 100644 --- a/selfdrive/ui/ui.h +++ b/selfdrive/ui/ui.h @@ -3,6 +3,7 @@ #include #include #include +#include #include #include @@ -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 sponsorRoleWithHighestTier = std::nullopt; for (const auto &role : sunnylinkRoles) { - if(role.roleType != RoleType::Sponsor) + if (role.roleType != RoleType::Sponsor) continue; if (auto sponsorRole = role.as(); !sponsorRoleWithHighestTier.has_value() || sponsorRoleWithHighestTier->roleTier < sponsorRole.roleTier) {