mirror of
https://github.com/rvtr/ctr_Repair.git
synced 2025-10-31 13:51:08 -04:00
TitleDownloaderをTWL以外でも使いまわせるように
git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@561 385bec56-5757-e545-9c3a-d8741f4650f1
This commit is contained in:
parent
1787870ee8
commit
ccf5b145f3
@ -1376,7 +1376,7 @@ void ControlState(common::HardwareStateManager& manager, ::std::vector<std::stri
|
||||
{
|
||||
COMMON_LOGGER("Download Twl Title\n");
|
||||
s_ExecuteTitleDownload = true;
|
||||
StartTitleDownload();
|
||||
StartTwlTitleDownload();
|
||||
}
|
||||
|
||||
// 動いていることを表示
|
||||
|
||||
@ -115,17 +115,21 @@ namespace ConsoleRestore
|
||||
|
||||
nn::Result TitleDownloader::m_Result = nn::ResultSuccess();
|
||||
|
||||
void TitleDownloaderThreadFunc()
|
||||
void TwlTitleDownloaderThreadFunc()
|
||||
{
|
||||
TitleDownloader TwlTitleDownloader;
|
||||
|
||||
s_Progress = 0;
|
||||
if(TwlTitleDownloader.ListUpTwlTitles().IsFailure())
|
||||
{
|
||||
return;
|
||||
}
|
||||
TwlTitleDownloader.Start();
|
||||
}
|
||||
|
||||
void StartTitleDownload()
|
||||
void StartTwlTitleDownload()
|
||||
{
|
||||
s_TitleDownloaderThread.Start(TitleDownloaderThreadFunc, s_TitleDownloaderThreadStack);
|
||||
s_TitleDownloaderThread.Start(TwlTitleDownloaderThreadFunc, s_TitleDownloaderThreadStack);
|
||||
}
|
||||
|
||||
bool IsDownloadTitleFinished()
|
||||
@ -150,9 +154,9 @@ u32 GetTitleDownloadProgress()
|
||||
}
|
||||
|
||||
|
||||
TitleDownloader::TitleDownloader() : m_TwlTiteNum(0)
|
||||
TitleDownloader::TitleDownloader() : m_TiteNum(0)
|
||||
{
|
||||
for(u32 i = 0; i < TWL_IMPORTABLE_TITLE_MAX; i++)
|
||||
for(u32 i = 0; i < IMPORTABLE_TITLE_MAX; i++)
|
||||
{
|
||||
m_ProgramIdList[i] = 0;
|
||||
}
|
||||
@ -193,15 +197,9 @@ void WaitShopOperationAndFinalize()
|
||||
|
||||
void TitleDownloader::Start()
|
||||
{
|
||||
m_Result = ListUp();
|
||||
if(m_Result.IsFailure())
|
||||
for(u8 i = 0; i < m_TiteNum; i++)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for(u8 i = 0; i < m_TwlTiteNum; i++)
|
||||
{
|
||||
s_Progress = i * 100 / m_TwlTiteNum;
|
||||
s_Progress = i * 100 / m_TiteNum;
|
||||
StartShopOperationSingle(SHOP_OPERATION_CONNECT_WITHOUT_CLOSE);
|
||||
WaitShopOperationAndFinalize();
|
||||
|
||||
@ -216,7 +214,7 @@ void TitleDownloader::Start()
|
||||
}
|
||||
}
|
||||
|
||||
nn::Result TitleDownloader::ListUp()
|
||||
nn::Result TitleDownloader::ListUpTwlTitles()
|
||||
{
|
||||
COMMON_LOGGER("Read TwlTitle List.\n");
|
||||
|
||||
@ -244,15 +242,15 @@ nn::Result TitleDownloader::ListUp()
|
||||
char ProgramIdStr[32];
|
||||
char *error;
|
||||
std::memcpy(ProgramIdStr, &titleListBuf[listHead], i - listHead);
|
||||
m_ProgramIdList[m_TwlTiteNum] = std::strtoull(ProgramIdStr, &error, 16);
|
||||
m_TwlTiteNum++;
|
||||
COMMON_LOGGER_DETAIL("%016llx\n", m_ProgramIdList[m_TwlTiteNum - 1]);
|
||||
m_ProgramIdList[m_TiteNum] = std::strtoull(ProgramIdStr, &error, 16);
|
||||
m_TiteNum++;
|
||||
COMMON_LOGGER_DETAIL("%016llx\n", m_ProgramIdList[m_TiteNum - 1]);
|
||||
|
||||
listHead = i + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
COMMON_LOGGER("%d Title(s) found.\n", m_TwlTiteNum);
|
||||
COMMON_LOGGER("%d Title(s) found.\n", m_TiteNum);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -21,8 +21,8 @@
|
||||
namespace ConsoleRestore
|
||||
{
|
||||
|
||||
// 新たにスレッドを立て、タイトルのダウンロードを開始する
|
||||
void StartTitleDownload();
|
||||
// 新たにスレッドを立て、TWLタイトルのダウンロードを開始する
|
||||
void StartTwlTitleDownload();
|
||||
|
||||
// タイトルのダウンロードスレッドが終了したかどうか
|
||||
bool IsDownloadTitleFinished();
|
||||
@ -46,16 +46,20 @@ public:
|
||||
// タイトルのダウンロードを開始する
|
||||
void Start();
|
||||
|
||||
// Twlタイトルをリストアップする
|
||||
nn::Result ListUpTwlTitles();
|
||||
|
||||
//TODO: プリインストールタイトルをリストアップする
|
||||
|
||||
NN_PADDING4;
|
||||
static nn::Result m_Result;
|
||||
|
||||
private:
|
||||
nn::Result ListUp();
|
||||
|
||||
static const size_t TWL_IMPORTABLE_TITLE_MAX = 40;
|
||||
static const size_t IMPORTABLE_TITLE_MAX = 256;
|
||||
|
||||
nn::ProgramID m_ProgramIdList[TWL_IMPORTABLE_TITLE_MAX];
|
||||
u32 m_TwlTiteNum;
|
||||
nn::ProgramID m_ProgramIdList[IMPORTABLE_TITLE_MAX];
|
||||
u32 m_TiteNum;
|
||||
|
||||
|
||||
};
|
||||
|
||||
@ -38,6 +38,7 @@ TEST_COMMON_SOURCES[] =
|
||||
../../../common/FileTransfer.cpp
|
||||
../../../common/SdReaderWriter.cpp
|
||||
|
||||
CCFLAGS += -DCOMMON_LOGGER_DETAIL_ENABLE
|
||||
|
||||
SOURCES_TEST[] = test_TitleDownloader.cpp
|
||||
|
||||
|
||||
@ -100,7 +100,7 @@ void TitleDownloaderTest::ListUp()
|
||||
NN_LOG("WriteTwlTitleData\n");
|
||||
ConsoleRestore::TitleDownloader dl;
|
||||
|
||||
dl.Start();
|
||||
dl.ListUpTwlTitles();
|
||||
}
|
||||
|
||||
NN_TEST_DEFINE_MAIN(TitleDownloaderTest)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user