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) /*---------------------------------------------------------------------------*