From 38b5e07c8213d6bb4570ac0251fae306434c6a36 Mon Sep 17 00:00:00 2001 From: N2614 Date: Fri, 20 Jan 2012 06:40:22 +0000 Subject: [PATCH] =?UTF-8?q?TitleDownloader=E3=81=A7=E3=83=97=E3=83=AA?= =?UTF-8?q?=E3=82=A4=E3=83=B3=E3=82=B9=E3=83=88=E3=83=BC=E3=83=AB=E3=82=BF?= =?UTF-8?q?=E3=82=A4=E3=83=88=E3=83=AB=E3=82=92=E3=83=80=E3=82=A6=E3=83=B3?= =?UTF-8?q?=E3=83=AD=E3=83=BC=E3=83=89=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@589 385bec56-5757-e545-9c3a-d8741f4650f1 --- .../sources/ConsoleRestore/OMakefile | 2 ++ .../ConsoleRestore/TitleDownloader.cpp | 28 +++++++++++++++++++ .../sources/ConsoleRestore/TitleDownloader.h | 12 ++++++++ .../test_PreinstallImporter.cpp | 2 +- .../ConsoleRestore/TitleDownloader/OMakefile | 5 ++++ .../TitleDownloader/test_TitleDownloader.cpp | 15 ++++++++++ 6 files changed, 63 insertions(+), 1 deletion(-) diff --git a/trunk/ConsoleDataMigration/sources/ConsoleRestore/OMakefile b/trunk/ConsoleDataMigration/sources/ConsoleRestore/OMakefile index ace98aa..1397c8b 100644 --- a/trunk/ConsoleDataMigration/sources/ConsoleRestore/OMakefile +++ b/trunk/ConsoleDataMigration/sources/ConsoleRestore/OMakefile @@ -34,6 +34,7 @@ SOURCES[] = SimpleXmlPreprocessor.cpp XmlCreator.cpp BgsCommunicator.cpp + PreinstallImporter.cpp ../common/Util.cpp ../common/DrawSystemState.cpp ../common/FileTransfer.cpp @@ -71,6 +72,7 @@ LIBS += libnn_cfg \ libnn_ns \ libnn_am \ libnn_nim \ + libnn_xml_simple \ INSTALL_SDK_TOOL = true diff --git a/trunk/ConsoleDataMigration/sources/ConsoleRestore/TitleDownloader.cpp b/trunk/ConsoleDataMigration/sources/ConsoleRestore/TitleDownloader.cpp index f66e35b..2dee96c 100644 --- a/trunk/ConsoleDataMigration/sources/ConsoleRestore/TitleDownloader.cpp +++ b/trunk/ConsoleDataMigration/sources/ConsoleRestore/TitleDownloader.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include "common_Types.h" #include "FileName.h" @@ -25,6 +26,7 @@ #include "TitleDownloader.h" #include "Shop.h" #include "SdReaderWriter.h" +#include "PreinstallImporter.h" namespace @@ -131,11 +133,37 @@ void TwlTitleDownloaderThreadFunc() TwlTitleDownloader.Start(); } +void PreinstallTitleDownloaderThreadFunc(PreinstallListupParam param) +{ + TitleDownloader PreinstallTitleDownloader; + PreinstallImporter importer; + + s_Progress = 0; + size_t num = 0; + nn::ProgramId list[256]; + TitleDownloader::m_Result = importer.ListTitles(list, &num, param.deviceId, param.serialNo); + if(TitleDownloader::m_Result.IsFailure()) + { + return; + } + PreinstallTitleDownloader.SetupTitleList(list, num); + PreinstallTitleDownloader.Start(); +} + void StartTwlTitleDownload() { s_TitleDownloaderThread.Start(TwlTitleDownloaderThreadFunc, s_TitleDownloaderThreadStack); } +void StartPreinstallTitleDownload(bit64 deviceId, u8* serialNo) +{ + PreinstallListupParam param; + param.deviceId = deviceId; + std::memcpy(param.serialNo, serialNo, nn::cfg::CTR::CFG_SECURE_INFO_SERIAL_NO_LEN); + + s_TitleDownloaderThread.Start(PreinstallTitleDownloaderThreadFunc, param, s_TitleDownloaderThreadStack); +} + bool IsDownloadTitleFinished() { return s_TitleDownloaderThread.IsValid() && !s_TitleDownloaderThread.IsAlive(); diff --git a/trunk/ConsoleDataMigration/sources/ConsoleRestore/TitleDownloader.h b/trunk/ConsoleDataMigration/sources/ConsoleRestore/TitleDownloader.h index bb37d36..e9bdb3e 100644 --- a/trunk/ConsoleDataMigration/sources/ConsoleRestore/TitleDownloader.h +++ b/trunk/ConsoleDataMigration/sources/ConsoleRestore/TitleDownloader.h @@ -24,6 +24,18 @@ namespace ConsoleRestore // 新たにスレッドを立て、TWLタイトルのダウンロードを開始する void StartTwlTitleDownload(); +//! @brief 新たにスレッドを立て、プリインストールタイトルのダウンロードを開始します
+//! SDカードはインポート可能な状態にしておく必要があります。 +void StartPreinstallTitleDownload(bit64 deviceId, u8* serialNo); + + +// プリインストール情報取得に必要なパラメータをまとめた構造体 +struct PreinstallListupParam +{ + bit64 deviceId; + u8 serialNo[nn::cfg::CTR::CFG_SECURE_INFO_SERIAL_NO_LEN]; +}; + //! @brief ダウンロードするTWLタイトルをSDカードからリストアップする nn::Result ListUpTwlTitles(nn::ProgramId* list, size_t* num); diff --git a/trunk/ConsoleDataMigration/sources/tests/ConsoleRestore/PreinstallImporter/test_PreinstallImporter.cpp b/trunk/ConsoleDataMigration/sources/tests/ConsoleRestore/PreinstallImporter/test_PreinstallImporter.cpp index 9f09fa1..ef16e89 100644 --- a/trunk/ConsoleDataMigration/sources/tests/ConsoleRestore/PreinstallImporter/test_PreinstallImporter.cpp +++ b/trunk/ConsoleDataMigration/sources/tests/ConsoleRestore/PreinstallImporter/test_PreinstallImporter.cpp @@ -99,7 +99,7 @@ void PreinstallImporterTest::ListUp() { ConsoleRestore::PreinstallImporter importer; - size_t num = 0; + size_t num; nn::ProgramId list[256]; NN_TEST_ASSERT_RESULT_SUCCESS( importer.ListTitles(list, &num, 17179924184, reinterpret_cast(const_cast("EJA20305940")))); diff --git a/trunk/ConsoleDataMigration/sources/tests/ConsoleRestore/TitleDownloader/OMakefile b/trunk/ConsoleDataMigration/sources/tests/ConsoleRestore/TitleDownloader/OMakefile index 3c65c79..6af7d2e 100644 --- a/trunk/ConsoleDataMigration/sources/tests/ConsoleRestore/TitleDownloader/OMakefile +++ b/trunk/ConsoleDataMigration/sources/tests/ConsoleRestore/TitleDownloader/OMakefile @@ -27,6 +27,10 @@ INCLUDES += $(SAMPLED_DEMOS_COMMON_INCLUDE_DIR) \ TEST_COMMON_SOURCES[] = ../../../ConsoleRestore/TitleDownloader.cpp ../../../ConsoleRestore/Shop.cpp + ../../../ConsoleRestore/BgsCommunicator.cpp + ../../../ConsoleRestore/SimpleXmlPreprocessor.cpp + ../../../ConsoleRestore/XmlCreator.cpp + ../../../ConsoleRestore/PreinstallImporter.cpp ../../../common/Util.cpp ../../../common/HeapManager.cpp ../../../common/SdLogger.cpp @@ -53,6 +57,7 @@ LIBS += libnn_test \ libnn_am \ lib_demo \ libnn_nim \ + libnn_xml_simple \ ROM_SPEC_FILE = ../../../ConsoleRestore/ConsoleRestore.rsf diff --git a/trunk/ConsoleDataMigration/sources/tests/ConsoleRestore/TitleDownloader/test_TitleDownloader.cpp b/trunk/ConsoleDataMigration/sources/tests/ConsoleRestore/TitleDownloader/test_TitleDownloader.cpp index 863fed3..915a645 100644 --- a/trunk/ConsoleDataMigration/sources/tests/ConsoleRestore/TitleDownloader/test_TitleDownloader.cpp +++ b/trunk/ConsoleDataMigration/sources/tests/ConsoleRestore/TitleDownloader/test_TitleDownloader.cpp @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -39,9 +40,11 @@ public: TitleDownloaderTest() { SUITE_NAME("TestUtil"); TEST_ADD(TitleDownloaderTest::ListUp); + TEST_ADD(TitleDownloaderTest::DownloadPreinstall); } private: void ListUp(); + void DownloadPreinstall(); }; namespace @@ -61,6 +64,8 @@ bool TitleDownloaderTest::InitializeSuite() nn::os::Initialize(); nn::fs::Initialize(); + nn::cfg::CTR::init::Initialize(); + nn::cfg::CTR::system::Initialize(); // amの初期化 nn::am::InitializeForLocalImporter(); @@ -107,6 +112,16 @@ void TitleDownloaderTest::ListUp() dl.SetupTitleList(list, num); } +void TitleDownloaderTest::DownloadPreinstall() +{ + ConsoleRestore::StartPreinstallTitleDownload(17179924184, reinterpret_cast(const_cast("EJA20305940"))); + + while(!ConsoleRestore::IsDownloadTitleFinished()) + { + nn::os::Thread::Sleep(nn::fnd::TimeSpan::FromMilliSeconds(1)); + } +} + NN_TEST_DEFINE_MAIN(TitleDownloaderTest) /*---------------------------------------------------------------------------*