summaryrefslogtreecommitdiff
path: root/src/core/frontend
diff options
context:
space:
mode:
authorGravatar bunnei2019-06-26 15:55:24 -0400
committerGravatar GitHub2019-06-26 15:55:24 -0400
commit5829ba1ccc18c083a4d2a6e42ad27ebe1c6fbac8 (patch)
tree63d9887d2160fe6064f1d2b09b09553c4c8d9fce /src/core/frontend
parentMerge pull request #2607 from DarkLordZach/arp-1 (diff)
parentapplets: Pass current process title ID to applets (diff)
downloadyuzu-5829ba1ccc18c083a4d2a6e42ad27ebe1c6fbac8.tar.gz
yuzu-5829ba1ccc18c083a4d2a6e42ad27ebe1c6fbac8.tar.xz
yuzu-5829ba1ccc18c083a4d2a6e42ad27ebe1c6fbac8.zip
Merge pull request #2548 from DarkLordZach/applet-shopn
applets: Implement backend and default frontend for Parental Controls and EShop (ShopN) applets
Diffstat (limited to 'src/core/frontend')
-rw-r--r--src/core/frontend/applets/general_frontend.cpp99
-rw-r--r--src/core/frontend/applets/general_frontend.h84
-rw-r--r--src/core/frontend/applets/web_browser.cpp6
-rw-r--r--src/core/frontend/applets/web_browser.h8
4 files changed, 189 insertions, 8 deletions
diff --git a/src/core/frontend/applets/general_frontend.cpp b/src/core/frontend/applets/general_frontend.cpp
index b974f2289..c30b36de7 100644
--- a/src/core/frontend/applets/general_frontend.cpp
+++ b/src/core/frontend/applets/general_frontend.cpp
@@ -7,9 +7,38 @@
7 7
8namespace Core::Frontend { 8namespace Core::Frontend {
9 9
10ParentalControlsApplet::~ParentalControlsApplet() = default;
11
12DefaultParentalControlsApplet::~DefaultParentalControlsApplet() = default;
13
14void DefaultParentalControlsApplet::VerifyPIN(std::function<void(bool)> finished,
15 bool suspend_future_verification_temporarily) {
16 LOG_INFO(Service_AM,
17 "Application requested frontend to verify PIN (normal), "
18 "suspend_future_verification_temporarily={}, verifying as correct.",
19 suspend_future_verification_temporarily);
20 finished(true);
21}
22
23void DefaultParentalControlsApplet::VerifyPINForSettings(std::function<void(bool)> finished) {
24 LOG_INFO(Service_AM,
25 "Application requested frontend to verify PIN (settings), verifying as correct.");
26 finished(true);
27}
28
29void DefaultParentalControlsApplet::RegisterPIN(std::function<void()> finished) {
30 LOG_INFO(Service_AM, "Application requested frontend to register new PIN");
31 finished();
32}
33
34void DefaultParentalControlsApplet::ChangePIN(std::function<void()> finished) {
35 LOG_INFO(Service_AM, "Application requested frontend to change PIN to new value");
36 finished();
37}
38
10PhotoViewerApplet::~PhotoViewerApplet() = default; 39PhotoViewerApplet::~PhotoViewerApplet() = default;
11 40
12DefaultPhotoViewerApplet::~DefaultPhotoViewerApplet() {} 41DefaultPhotoViewerApplet::~DefaultPhotoViewerApplet() = default;
13 42
14void DefaultPhotoViewerApplet::ShowPhotosForApplication(u64 title_id, 43void DefaultPhotoViewerApplet::ShowPhotosForApplication(u64 title_id,
15 std::function<void()> finished) const { 44 std::function<void()> finished) const {
@@ -24,4 +53,72 @@ void DefaultPhotoViewerApplet::ShowAllPhotos(std::function<void()> finished) con
24 finished(); 53 finished();
25} 54}
26 55
56ECommerceApplet::~ECommerceApplet() = default;
57
58DefaultECommerceApplet::~DefaultECommerceApplet() = default;
59
60void DefaultECommerceApplet::ShowApplicationInformation(
61 std::function<void()> finished, u64 title_id, std::optional<u128> user_id,
62 std::optional<bool> full_display, std::optional<std::string> extra_parameter) {
63 const auto value = user_id.value_or(u128{});
64 LOG_INFO(Service_AM,
65 "Application requested frontend show application information for EShop, "
66 "title_id={:016X}, user_id={:016X}{:016X}, full_display={}, extra_parameter={}",
67 title_id, value[1], value[0],
68 full_display.has_value() ? fmt::format("{}", *full_display) : "null",
69 extra_parameter.value_or("null"));
70 finished();
71}
72
73void DefaultECommerceApplet::ShowAddOnContentList(std::function<void()> finished, u64 title_id,
74 std::optional<u128> user_id,
75 std::optional<bool> full_display) {
76 const auto value = user_id.value_or(u128{});
77 LOG_INFO(Service_AM,
78 "Application requested frontend show add on content list for EShop, "
79 "title_id={:016X}, user_id={:016X}{:016X}, full_display={}",
80 title_id, value[1], value[0],
81 full_display.has_value() ? fmt::format("{}", *full_display) : "null");
82 finished();
83}
84
85void DefaultECommerceApplet::ShowSubscriptionList(std::function<void()> finished, u64 title_id,
86 std::optional<u128> user_id) {
87 const auto value = user_id.value_or(u128{});
88 LOG_INFO(Service_AM,
89 "Application requested frontend show subscription list for EShop, title_id={:016X}, "
90 "user_id={:016X}{:016X}",
91 title_id, value[1], value[0]);
92 finished();
93}
94
95void DefaultECommerceApplet::ShowConsumableItemList(std::function<void()> finished, u64 title_id,
96 std::optional<u128> user_id) {
97 const auto value = user_id.value_or(u128{});
98 LOG_INFO(
99 Service_AM,
100 "Application requested frontend show consumable item list for EShop, title_id={:016X}, "
101 "user_id={:016X}{:016X}",
102 title_id, value[1], value[0]);
103 finished();
104}
105
106void DefaultECommerceApplet::ShowShopHome(std::function<void()> finished, u128 user_id,
107 bool full_display) {
108 LOG_INFO(Service_AM,
109 "Application requested frontend show home menu for EShop, user_id={:016X}{:016X}, "
110 "full_display={}",
111 user_id[1], user_id[0], full_display);
112 finished();
113}
114
115void DefaultECommerceApplet::ShowSettings(std::function<void()> finished, u128 user_id,
116 bool full_display) {
117 LOG_INFO(Service_AM,
118 "Application requested frontend show settings menu for EShop, user_id={:016X}{:016X}, "
119 "full_display={}",
120 user_id[1], user_id[0], full_display);
121 finished();
122}
123
27} // namespace Core::Frontend 124} // namespace Core::Frontend
diff --git a/src/core/frontend/applets/general_frontend.h b/src/core/frontend/applets/general_frontend.h
index d4506c999..4b63f828e 100644
--- a/src/core/frontend/applets/general_frontend.h
+++ b/src/core/frontend/applets/general_frontend.h
@@ -5,10 +5,43 @@
5#pragma once 5#pragma once
6 6
7#include <functional> 7#include <functional>
8#include <optional>
8#include "common/common_types.h" 9#include "common/common_types.h"
9 10
10namespace Core::Frontend { 11namespace Core::Frontend {
11 12
13class ParentalControlsApplet {
14public:
15 virtual ~ParentalControlsApplet();
16
17 // Prompts the user to enter a PIN and calls the callback with whether or not it matches the
18 // correct PIN. If the bool is passed, and the PIN was recently entered correctly, the frontend
19 // should not prompt and simply return true.
20 virtual void VerifyPIN(std::function<void(bool)> finished,
21 bool suspend_future_verification_temporarily) = 0;
22
23 // Prompts the user to enter a PIN and calls the callback for correctness. Frontends can
24 // optionally alert the user that this is to change parental controls settings.
25 virtual void VerifyPINForSettings(std::function<void(bool)> finished) = 0;
26
27 // Prompts the user to create a new PIN for pctl and stores it with the service.
28 virtual void RegisterPIN(std::function<void()> finished) = 0;
29
30 // Prompts the user to verify the current PIN and then store a new one into pctl.
31 virtual void ChangePIN(std::function<void()> finished) = 0;
32};
33
34class DefaultParentalControlsApplet final : public ParentalControlsApplet {
35public:
36 ~DefaultParentalControlsApplet() override;
37
38 void VerifyPIN(std::function<void(bool)> finished,
39 bool suspend_future_verification_temporarily) override;
40 void VerifyPINForSettings(std::function<void(bool)> finished) override;
41 void RegisterPIN(std::function<void()> finished) override;
42 void ChangePIN(std::function<void()> finished) override;
43};
44
12class PhotoViewerApplet { 45class PhotoViewerApplet {
13public: 46public:
14 virtual ~PhotoViewerApplet(); 47 virtual ~PhotoViewerApplet();
@@ -25,4 +58,55 @@ public:
25 void ShowAllPhotos(std::function<void()> finished) const override; 58 void ShowAllPhotos(std::function<void()> finished) const override;
26}; 59};
27 60
61class ECommerceApplet {
62public:
63 virtual ~ECommerceApplet();
64
65 // Shows a page with application icons, description, name, and price.
66 virtual void ShowApplicationInformation(std::function<void()> finished, u64 title_id,
67 std::optional<u128> user_id = {},
68 std::optional<bool> full_display = {},
69 std::optional<std::string> extra_parameter = {}) = 0;
70
71 // Shows a page with all of the add on content available for a game, with name, description, and
72 // price.
73 virtual void ShowAddOnContentList(std::function<void()> finished, u64 title_id,
74 std::optional<u128> user_id = {},
75 std::optional<bool> full_display = {}) = 0;
76
77 // Shows a page with all of the subscriptions (recurring payments) for a game, with name,
78 // description, price, and renewal period.
79 virtual void ShowSubscriptionList(std::function<void()> finished, u64 title_id,
80 std::optional<u128> user_id = {}) = 0;
81
82 // Shows a page with a list of any additional game related purchasable items (DLC,
83 // subscriptions, etc) for a particular game, with name, description, type, and price.
84 virtual void ShowConsumableItemList(std::function<void()> finished, u64 title_id,
85 std::optional<u128> user_id = {}) = 0;
86
87 // Shows the home page of the shop.
88 virtual void ShowShopHome(std::function<void()> finished, u128 user_id, bool full_display) = 0;
89
90 // Shows the user settings page of the shop.
91 virtual void ShowSettings(std::function<void()> finished, u128 user_id, bool full_display) = 0;
92};
93
94class DefaultECommerceApplet : public ECommerceApplet {
95public:
96 ~DefaultECommerceApplet() override;
97
98 void ShowApplicationInformation(std::function<void()> finished, u64 title_id,
99 std::optional<u128> user_id, std::optional<bool> full_display,
100 std::optional<std::string> extra_parameter) override;
101 void ShowAddOnContentList(std::function<void()> finished, u64 title_id,
102 std::optional<u128> user_id,
103 std::optional<bool> full_display) override;
104 void ShowSubscriptionList(std::function<void()> finished, u64 title_id,
105 std::optional<u128> user_id) override;
106 void ShowConsumableItemList(std::function<void()> finished, u64 title_id,
107 std::optional<u128> user_id) override;
108 void ShowShopHome(std::function<void()> finished, u128 user_id, bool full_display) override;
109 void ShowSettings(std::function<void()> finished, u128 user_id, bool full_display) override;
110};
111
28} // namespace Core::Frontend 112} // namespace Core::Frontend
diff --git a/src/core/frontend/applets/web_browser.cpp b/src/core/frontend/applets/web_browser.cpp
index 3a3d3d0bf..528295ffc 100644
--- a/src/core/frontend/applets/web_browser.cpp
+++ b/src/core/frontend/applets/web_browser.cpp
@@ -11,9 +11,9 @@ WebBrowserApplet::~WebBrowserApplet() = default;
11 11
12DefaultWebBrowserApplet::~DefaultWebBrowserApplet() = default; 12DefaultWebBrowserApplet::~DefaultWebBrowserApplet() = default;
13 13
14void DefaultWebBrowserApplet::OpenPage(std::string_view filename, 14void DefaultWebBrowserApplet::OpenPageLocal(std::string_view filename,
15 std::function<void()> unpack_romfs_callback, 15 std::function<void()> unpack_romfs_callback,
16 std::function<void()> finished_callback) { 16 std::function<void()> finished_callback) {
17 LOG_INFO(Service_AM, 17 LOG_INFO(Service_AM,
18 "(STUBBED) called - No suitable web browser implementation found to open website page " 18 "(STUBBED) called - No suitable web browser implementation found to open website page "
19 "at '{}'!", 19 "at '{}'!",
diff --git a/src/core/frontend/applets/web_browser.h b/src/core/frontend/applets/web_browser.h
index f952856af..110e33bc4 100644
--- a/src/core/frontend/applets/web_browser.h
+++ b/src/core/frontend/applets/web_browser.h
@@ -13,16 +13,16 @@ class WebBrowserApplet {
13public: 13public:
14 virtual ~WebBrowserApplet(); 14 virtual ~WebBrowserApplet();
15 15
16 virtual void OpenPage(std::string_view url, std::function<void()> unpack_romfs_callback, 16 virtual void OpenPageLocal(std::string_view url, std::function<void()> unpack_romfs_callback,
17 std::function<void()> finished_callback) = 0; 17 std::function<void()> finished_callback) = 0;
18}; 18};
19 19
20class DefaultWebBrowserApplet final : public WebBrowserApplet { 20class DefaultWebBrowserApplet final : public WebBrowserApplet {
21public: 21public:
22 ~DefaultWebBrowserApplet() override; 22 ~DefaultWebBrowserApplet() override;
23 23
24 void OpenPage(std::string_view url, std::function<void()> unpack_romfs_callback, 24 void OpenPageLocal(std::string_view url, std::function<void()> unpack_romfs_callback,
25 std::function<void()> finished_callback) override; 25 std::function<void()> finished_callback) override;
26}; 26};
27 27
28} // namespace Core::Frontend 28} // namespace Core::Frontend