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"
|
|
|
|
|
|
2016-05-13 15:55:34 +02:00
|
|
|
logs::channel cellUserInfo("cellUserInfo", logs::level::notice);
|
2014-03-11 18:40:37 +01:00
|
|
|
|
2015-07-09 17:30:37 +02:00
|
|
|
s32 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;
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-09 17:30:37 +02:00
|
|
|
s32 cellUserInfoSelectUser_ListType()
|
2014-03-11 18:40:37 +01:00
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED_FUNC(cellUserInfo);
|
|
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-09 17:30:37 +02:00
|
|
|
s32 cellUserInfoSelectUser_SetList()
|
2014-03-11 18:40:37 +01:00
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED_FUNC(cellUserInfo);
|
|
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-09 17:30:37 +02:00
|
|
|
s32 cellUserInfoEnableOverlay()
|
2014-03-11 18:40:37 +01:00
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED_FUNC(cellUserInfo);
|
|
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-09 12:03:53 +02:00
|
|
|
ppu_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
|
|
|
});
|