From 54684feffa8518fc8cbc361e460114f810ba2a0e Mon Sep 17 00:00:00 2001
From: Zach Hilman <zachhilman@gmail.com>
Date: Wed, 5 Jun 2019 12:18:10 -0400
Subject: [PATCH] frontend: Add base class and default impl for ECommerce
 applet frontend

---
 .../frontend/applets/general_frontend.cpp     | 64 +++++++++++++++++++
 src/core/frontend/applets/general_frontend.h  | 38 +++++++++++
 2 files changed, 102 insertions(+)

diff --git a/src/core/frontend/applets/general_frontend.cpp b/src/core/frontend/applets/general_frontend.cpp
index 7483ffb76..e6cb59b64 100644
--- a/src/core/frontend/applets/general_frontend.cpp
+++ b/src/core/frontend/applets/general_frontend.cpp
@@ -53,4 +53,68 @@ void DefaultPhotoViewerApplet::ShowAllPhotos(std::function<void()> finished) con
     finished();
 }
 
+ECommerceApplet::~ECommerceApplet() = default;
+
+DefaultECommerceApplet::~DefaultECommerceApplet() = default;
+
+void DefaultECommerceApplet::ShowApplicationInformation(
+    std::function<void()> finished, u64 title_id, std::optional<u128> user_id,
+    std::optional<bool> full_display, std::optional<std::string> extra_parameter) {
+    LOG_INFO(Service_AM,
+             "Application requested frontend show application information for EShop, "
+             "title_id={:016X}, user_id={:016X}{:016X}, full_display={}, extra_parameter={}",
+             title_id, user_id.value_or(u128{})[1], user_id.value_or(u128{})[0],
+             full_display.has_value() ? fmt::format("{}", *full_display) : "null",
+             extra_parameter.value_or("null"));
+    finished();
+}
+
+void DefaultECommerceApplet::ShowAddOnContentList(std::function<void()> finished, u64 title_id,
+                                                  std::optional<u128> user_id,
+                                                  std::optional<bool> full_display) {
+    LOG_INFO(Service_AM,
+             "Application requested frontend show add on content list for EShop, "
+             "title_id={:016X}, user_id={:016X}{:016X}, full_display={}",
+             title_id, user_id.value_or(u128{})[1], user_id.value_or(u128{})[0],
+             full_display.has_value() ? fmt::format("{}", *full_display) : "null");
+    finished();
+}
+
+void DefaultECommerceApplet::ShowSubscriptionList(std::function<void()> finished, u64 title_id,
+                                                  std::optional<u128> user_id) {
+    LOG_INFO(Service_AM,
+             "Application requested frontend show subscription list for EShop, title_id={:016X}, "
+             "user_id={:016X}{:016X}",
+             title_id, user_id.value_or(u128{})[1], user_id.value_or(u128{})[0]);
+    finished();
+}
+
+void DefaultECommerceApplet::ShowConsumableItemList(std::function<void()> finished, u64 title_id,
+                                                    std::optional<u128> user_id) {
+    LOG_INFO(
+        Service_AM,
+        "Application requested frontend show consumable item list for EShop, title_id={:016X}, "
+        "user_id={:016X}{:016X}",
+        title_id, user_id.value_or(u128{})[1], user_id.value_or(u128{})[0]);
+    finished();
+}
+
+void DefaultECommerceApplet::ShowShopHome(std::function<void()> finished, u128 user_id,
+                                          bool full_display) {
+    LOG_INFO(Service_AM,
+             "Application requested frontend show home menu for EShop, user_id={:016X}{:016X}, "
+             "full_display={}",
+             user_id[1], user_id[0], full_display);
+    finished();
+}
+
+void DefaultECommerceApplet::ShowSettings(std::function<void()> finished, u128 user_id,
+                                          bool full_display) {
+    LOG_INFO(Service_AM,
+             "Application requested frontend show settings menu for EShop, user_id={:016X}{:016X}, "
+             "full_display={}",
+             user_id[1], user_id[0], full_display);
+    finished();
+}
+
 } // namespace Core::Frontend
diff --git a/src/core/frontend/applets/general_frontend.h b/src/core/frontend/applets/general_frontend.h
index 48e3ce651..616112cfc 100644
--- a/src/core/frontend/applets/general_frontend.h
+++ b/src/core/frontend/applets/general_frontend.h
@@ -5,6 +5,7 @@
 #pragma once
 
 #include <functional>
+#include <optional>
 #include "common/common_types.h"
 
 namespace Core::Frontend {
@@ -47,4 +48,41 @@ public:
     void ShowAllPhotos(std::function<void()> finished) const override;
 };
 
+class ECommerceApplet {
+public:
+    virtual ~ECommerceApplet();
+
+    virtual void ShowApplicationInformation(std::function<void()> finished, u64 title_id,
+                                            std::optional<u128> user_id = {},
+                                            std::optional<bool> full_display = {},
+                                            std::optional<std::string> extra_parameter = {}) = 0;
+    virtual void ShowAddOnContentList(std::function<void()> finished, u64 title_id,
+                                      std::optional<u128> user_id = {},
+                                      std::optional<bool> full_display = {}) = 0;
+    virtual void ShowSubscriptionList(std::function<void()> finished, u64 title_id,
+                                      std::optional<u128> user_id = {}) = 0;
+    virtual void ShowConsumableItemList(std::function<void()> finished, u64 title_id,
+                                        std::optional<u128> user_id = {}) = 0;
+    virtual void ShowShopHome(std::function<void()> finished, u128 user_id, bool full_display) = 0;
+    virtual void ShowSettings(std::function<void()> finished, u128 user_id, bool full_display) = 0;
+};
+
+class DefaultECommerceApplet : public ECommerceApplet {
+public:
+    ~DefaultECommerceApplet() override;
+
+    void ShowApplicationInformation(std::function<void()> finished, u64 title_id,
+                                    std::optional<u128> user_id, std::optional<bool> full_display,
+                                    std::optional<std::string> extra_parameter) override;
+    void ShowAddOnContentList(std::function<void()> finished, u64 title_id,
+                              std::optional<u128> user_id,
+                              std::optional<bool> full_display) override;
+    void ShowSubscriptionList(std::function<void()> finished, u64 title_id,
+                              std::optional<u128> user_id) override;
+    void ShowConsumableItemList(std::function<void()> finished, u64 title_id,
+                                std::optional<u128> user_id) override;
+    void ShowShopHome(std::function<void()> finished, u128 user_id, bool full_display) override;
+    void ShowSettings(std::function<void()> finished, u128 user_id, bool full_display) override;
+};
+
 } // namespace Core::Frontend