2014-03-11 18:40:37 +01:00
|
|
|
#include "stdafx.h"
|
2014-06-02 19:27:24 +02:00
|
|
|
#include "Emu/System.h"
|
2016-03-21 20:43:03 +01:00
|
|
|
#include "Emu/Cell/PPUModule.h"
|
2014-03-11 18:40:37 +01:00
|
|
|
|
|
|
|
|
#include "cellUserInfo.h"
|
|
|
|
|
|
2016-04-27 00:27:24 +02:00
|
|
|
#include "Utilities/StrUtil.h"
|
|
|
|
|
|
2017-05-13 20:30:37 +02:00
|
|
|
logs::channel cellUserInfo("cellUserInfo");
|
2014-03-11 18:40:37 +01:00
|
|
|
|
2016-08-16 17:46:24 +02:00
|
|
|
template<>
|
|
|
|
|
void fmt_class_string<CellUserInfoError>::format(std::string& out, u64 arg)
|
|
|
|
|
{
|
|
|
|
|
format_enum(out, arg, [](auto error)
|
|
|
|
|
{
|
|
|
|
|
switch (error)
|
|
|
|
|
{
|
|
|
|
|
STR_CASE(CELL_USERINFO_ERROR_BUSY);
|
|
|
|
|
STR_CASE(CELL_USERINFO_ERROR_INTERNAL);
|
|
|
|
|
STR_CASE(CELL_USERINFO_ERROR_PARAM);
|
|
|
|
|
STR_CASE(CELL_USERINFO_ERROR_NOUSER);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return unknown;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-15 13:30:14 +02:00
|
|
|
error_code cellUserInfoGetStat(u32 id, vm::ptr<CellUserInfoUserStat> stat)
|
2014-03-11 18:40:37 +01:00
|
|
|
{
|
2016-01-12 22:57:16 +01:00
|
|
|
cellUserInfo.warning("cellUserInfoGetStat(id=%d, stat=*0x%x)", id, stat);
|
2014-03-11 18:40:37 +01:00
|
|
|
|
2015-12-11 18:09:24 +01:00
|
|
|
if (id > CELL_SYSUTIL_USERID_MAX)
|
2016-04-09 12:03:53 +02:00
|
|
|
{
|
2014-03-11 18:40:37 +01:00
|
|
|
return CELL_USERINFO_ERROR_NOUSER;
|
2016-04-09 12:03:53 +02:00
|
|
|
}
|
2014-03-11 18:40:37 +01:00
|
|
|
|
2015-12-11 18:09:24 +01:00
|
|
|
if (id == CELL_SYSUTIL_USERID_CURRENT)
|
|
|
|
|
{
|
|
|
|
|
// TODO: Return current user/profile when that is implemented
|
|
|
|
|
id = 1;
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-21 20:43:03 +01:00
|
|
|
const std::string& path = vfs::get(fmt::format("/dev_hdd0/home/%08d/", id));
|
2016-04-09 12:03:53 +02:00
|
|
|
|
2016-03-21 20:43:03 +01:00
|
|
|
if (!fs::is_dir(path))
|
2016-04-09 12:03:53 +02:00
|
|
|
{
|
|
|
|
|
cellUserInfo.error("cellUserInfoGetStat(): CELL_USERINFO_ERROR_NOUSER. User %d doesn't exist. Did you delete the user folder?", id);
|
2014-03-11 18:40:37 +01:00
|
|
|
return CELL_USERINFO_ERROR_NOUSER;
|
2016-04-09 12:03:53 +02:00
|
|
|
}
|
2014-03-11 18:40:37 +01:00
|
|
|
|
2016-03-21 20:43:03 +01:00
|
|
|
const fs::file f(path + "localusername");
|
2016-04-09 12:03:53 +02:00
|
|
|
|
2016-03-21 20:43:03 +01:00
|
|
|
if (!f)
|
2016-04-09 12:03:53 +02:00
|
|
|
{
|
|
|
|
|
cellUserInfo.error("cellUserInfoGetStat(): CELL_USERINFO_ERROR_INTERNAL. Username for user %d doesn't exist. Did you delete the username file?", id);
|
2014-03-11 18:40:37 +01:00
|
|
|
return CELL_USERINFO_ERROR_INTERNAL;
|
2016-04-09 12:03:53 +02:00
|
|
|
}
|
2014-03-11 18:40:37 +01:00
|
|
|
|
|
|
|
|
stat->id = id;
|
2016-03-21 20:43:03 +01:00
|
|
|
strcpy_trunc(stat->name, f.to_string());
|
2016-04-09 12:03:53 +02:00
|
|
|
|
2014-03-11 18:40:37 +01:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-15 13:30:14 +02:00
|
|
|
error_code cellUserInfoSelectUser_ListType(vm::ptr<CellUserInfoTypeSet> listType, vm::ptr<CellUserInfoFinishCallback> funcSelect, u32 container, vm::ptr<void> userdata)
|
2014-03-11 18:40:37 +01:00
|
|
|
{
|
2017-05-15 13:30:14 +02:00
|
|
|
cellUserInfo.todo("cellUserInfoSelectUser_ListType(listType=*0x%x, funcSelect=*0x%x, container=0x%x, userdata=*0x%x)", listType, funcSelect, container, userdata);
|
2014-03-11 18:40:37 +01:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-15 13:30:14 +02:00
|
|
|
error_code cellUserInfoSelectUser_SetList(vm::ptr<CellUserInfoListSet> setList, vm::ptr<CellUserInfoFinishCallback> funcSelect, u32 container, vm::ptr<void> userdata)
|
2014-03-11 18:40:37 +01:00
|
|
|
{
|
2017-05-15 13:30:14 +02:00
|
|
|
cellUserInfo.todo("cellUserInfoSelectUser_SetList(setList=*0x%x, funcSelect=*0x%x, container=0x%x, userdata=*0x%x)", setList, funcSelect, container, userdata);
|
2014-03-11 18:40:37 +01:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-15 13:30:14 +02:00
|
|
|
void cellUserInfoEnableOverlay(s32 enable)
|
2014-03-11 18:40:37 +01:00
|
|
|
{
|
2017-05-15 13:30:14 +02:00
|
|
|
cellUserInfo.todo("cellUserInfoEnableOverlay(enable=%d)", enable);
|
2014-03-11 18:40:37 +01:00
|
|
|
}
|
|
|
|
|
|
2016-08-16 17:46:24 +02:00
|
|
|
error_code cellUserInfoGetList(vm::ptr<u32> listNum, vm::ptr<CellUserInfoUserList> listBuf, vm::ptr<u32> currentUserId)
|
2014-03-11 18:40:37 +01:00
|
|
|
{
|
2016-04-09 12:03:53 +02:00
|
|
|
cellUserInfo.todo("cellUserInfoGetList(listNum=*0x%x, listBuf=*0x%x, currentUserId=*0x%x)", listNum, listBuf, currentUserId);
|
2014-03-11 18:40:37 +01:00
|
|
|
|
2014-05-25 22:31:40 +02:00
|
|
|
// If only listNum is NULL, an error will be returned
|
2014-09-01 02:51:48 +02:00
|
|
|
if (listBuf && !listNum)
|
2016-04-09 12:03:53 +02:00
|
|
|
{
|
2014-05-19 15:05:53 +02:00
|
|
|
return CELL_USERINFO_ERROR_PARAM;
|
2016-04-09 12:03:53 +02:00
|
|
|
}
|
|
|
|
|
|
2014-09-01 02:51:48 +02:00
|
|
|
if (listNum)
|
2016-04-09 12:03:53 +02:00
|
|
|
{
|
2014-09-01 02:51:48 +02:00
|
|
|
*listNum = 1;
|
2016-04-09 12:03:53 +02:00
|
|
|
}
|
|
|
|
|
|
2014-09-01 02:51:48 +02:00
|
|
|
if (listBuf)
|
2016-04-09 12:03:53 +02:00
|
|
|
{
|
2014-05-19 15:05:53 +02:00
|
|
|
listBuf->userId[0] = 1;
|
2016-04-09 12:03:53 +02:00
|
|
|
}
|
2014-05-19 15:05:53 +02:00
|
|
|
|
2014-09-01 02:51:48 +02:00
|
|
|
if (currentUserId)
|
2016-04-09 12:03:53 +02:00
|
|
|
{
|
|
|
|
|
// TODO: Properly set the current user ID here, once implemented
|
2014-09-01 02:51:48 +02:00
|
|
|
*currentUserId = 1;
|
2016-04-09 12:03:53 +02:00
|
|
|
}
|
2014-05-19 15:05:53 +02:00
|
|
|
|
2014-03-11 18:40:37 +01:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-21 20:43:03 +01:00
|
|
|
DECLARE(ppu_module_manager::cellUserInfo)("cellUserInfo", []()
|
2014-03-11 18:40:37 +01:00
|
|
|
{
|
2015-02-20 14:58:40 +01:00
|
|
|
REG_FUNC(cellUserInfo, cellUserInfoGetStat);
|
|
|
|
|
REG_FUNC(cellUserInfo, cellUserInfoSelectUser_ListType);
|
|
|
|
|
REG_FUNC(cellUserInfo, cellUserInfoSelectUser_SetList);
|
|
|
|
|
REG_FUNC(cellUserInfo, cellUserInfoEnableOverlay);
|
|
|
|
|
REG_FUNC(cellUserInfo, cellUserInfoGetList);
|
2015-02-18 17:22:06 +01:00
|
|
|
});
|