summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/acc/acc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hle/service/acc/acc.cpp')
-rw-r--r--src/core/hle/service/acc/acc.cpp60
1 files changed, 56 insertions, 4 deletions
diff --git a/src/core/hle/service/acc/acc.cpp b/src/core/hle/service/acc/acc.cpp
index 0b158e015..f3c5b1b9c 100644
--- a/src/core/hle/service/acc/acc.cpp
+++ b/src/core/hle/service/acc/acc.cpp
@@ -10,6 +10,7 @@
#include "core/hle/service/acc/acc_su.h"
#include "core/hle/service/acc/acc_u0.h"
#include "core/hle/service/acc/acc_u1.h"
+#include "core/settings.h"
namespace Service::Account {
@@ -31,34 +32,78 @@ struct ProfileBase {
};
static_assert(sizeof(ProfileBase) == 0x38, "ProfileBase structure has incorrect size");
+// TODO(ogniK): Generate a real user id based on username, md5(username) maybe?
static constexpr u128 DEFAULT_USER_ID{1ull, 0ull};
class IProfile final : public ServiceFramework<IProfile> {
public:
explicit IProfile(u128 user_id) : ServiceFramework("IProfile"), user_id(user_id) {
static const FunctionInfo functions[] = {
- {0, nullptr, "Get"},
+ {0, &IProfile::Get, "Get"},
{1, &IProfile::GetBase, "GetBase"},
{10, nullptr, "GetImageSize"},
- {11, nullptr, "LoadImage"},
+ {11, &IProfile::LoadImage, "LoadImage"},
};
RegisterHandlers(functions);
}
private:
+ void Get(Kernel::HLERequestContext& ctx) {
+ LOG_WARNING(Service_ACC, "(STUBBED) called");
+ ProfileBase profile_base{};
+ profile_base.user_id = user_id;
+ if (Settings::values.username.size() > profile_base.username.size()) {
+ std::copy_n(Settings::values.username.begin(), profile_base.username.size(),
+ profile_base.username.begin());
+ } else {
+ std::copy(Settings::values.username.begin(), Settings::values.username.end(),
+ profile_base.username.begin());
+ }
+
+ IPC::ResponseBuilder rb{ctx, 16};
+ rb.Push(RESULT_SUCCESS);
+ rb.PushRaw(profile_base);
+ }
+
void GetBase(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_ACC, "(STUBBED) called");
// TODO(Subv): Retrieve this information from somewhere.
ProfileBase profile_base{};
profile_base.user_id = user_id;
- profile_base.username = {'y', 'u', 'z', 'u'};
-
+ if (Settings::values.username.size() > profile_base.username.size()) {
+ std::copy_n(Settings::values.username.begin(), profile_base.username.size(),
+ profile_base.username.begin());
+ } else {
+ std::copy(Settings::values.username.begin(), Settings::values.username.end(),
+ profile_base.username.begin());
+ }
IPC::ResponseBuilder rb{ctx, 16};
rb.Push(RESULT_SUCCESS);
rb.PushRaw(profile_base);
}
+ void LoadImage(Kernel::HLERequestContext& ctx) {
+ LOG_WARNING(Service_ACC, "(STUBBED) called");
+ // smallest jpeg https://github.com/mathiasbynens/small/blob/master/jpeg.jpg
+ // TODO(mailwl): load actual profile image from disk, width 256px, max size 0x20000
+ const u32 jpeg_size = 107;
+ static const std::array<u8, jpeg_size> jpeg{
+ 0xff, 0xd8, 0xff, 0xdb, 0x00, 0x43, 0x00, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03,
+ 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x04, 0x06, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x08, 0x06, 0x06, 0x05, 0x06, 0x09, 0x08, 0x0a, 0x0a, 0x09, 0x08, 0x09, 0x09, 0x0a,
+ 0x0c, 0x0f, 0x0c, 0x0a, 0x0b, 0x0e, 0x0b, 0x09, 0x09, 0x0d, 0x11, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x10, 0x11, 0x10, 0x0a, 0x0c, 0x12, 0x13, 0x12, 0x10, 0x13, 0x0f, 0x10, 0x10,
+ 0x10, 0xff, 0xc9, 0x00, 0x0b, 0x08, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x11, 0x00,
+ 0xff, 0xcc, 0x00, 0x06, 0x00, 0x10, 0x10, 0x05, 0xff, 0xda, 0x00, 0x08, 0x01, 0x01,
+ 0x00, 0x00, 0x3f, 0x00, 0xd2, 0xcf, 0x20, 0xff, 0xd9,
+ };
+ ctx.WriteBuffer(jpeg.data(), jpeg_size);
+ IPC::ResponseBuilder rb{ctx, 3};
+ rb.Push(RESULT_SUCCESS);
+ rb.Push<u32>(jpeg_size);
+ }
+
u128 user_id; ///< The user id this profile refers to.
};
@@ -95,6 +140,13 @@ private:
}
};
+void Module::Interface::GetUserCount(Kernel::HLERequestContext& ctx) {
+ LOG_WARNING(Service_ACC, "(STUBBED) called");
+ IPC::ResponseBuilder rb{ctx, 3};
+ rb.Push(RESULT_SUCCESS);
+ rb.Push<u32>(1);
+}
+
void Module::Interface::GetUserExistence(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_ACC, "(STUBBED) called");
IPC::ResponseBuilder rb{ctx, 3};