From e1e5748ccffd6a765641e0bce5370b645aaf7692 Mon Sep 17 00:00:00 2001 From: N2614 Date: Thu, 14 Nov 2013 08:30:05 +0000 Subject: [PATCH] =?UTF-8?q?NNA=E7=A7=BB=E8=A1=8C=E5=AE=8C=E4=BA=86?= =?UTF-8?q?=E5=87=A6=E7=90=86=E3=82=92=E8=BF=BD=E5=8A=A0?= 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@761 385bec56-5757-e545-9c3a-d8741f4650f1 --- .../sources/ConsoleRestore/ActCompleter.cpp | 96 +++++++++++++++++++ .../sources/ConsoleRestore/ActCompleter.h | 45 +++++++++ .../sources/ConsoleRestore/Controller.cpp | 49 +++++++++- .../sources/ConsoleRestore/OMakefile | 2 + 4 files changed, 190 insertions(+), 2 deletions(-) create mode 100644 trunk/ConsoleDataMigration/sources/ConsoleRestore/ActCompleter.cpp create mode 100644 trunk/ConsoleDataMigration/sources/ConsoleRestore/ActCompleter.h diff --git a/trunk/ConsoleDataMigration/sources/ConsoleRestore/ActCompleter.cpp b/trunk/ConsoleDataMigration/sources/ConsoleRestore/ActCompleter.cpp new file mode 100644 index 0000000..a1d2b4e --- /dev/null +++ b/trunk/ConsoleDataMigration/sources/ConsoleRestore/ActCompleter.cpp @@ -0,0 +1,96 @@ +/*---------------------------------------------------------------------------* + Project: Horizon + File: ActCompleter.cpp + + Copyright (C)2013 Nintendo Co., Ltd. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Rev$ + *---------------------------------------------------------------------------*/ + +#include "ActCompleter.h" +#include "Util.h" +#include "CommonLogger.h" +#include +#include +#include +#include + +namespace ConsoleRestore +{ +nn::Result ActCompleter::s_Result; +const size_t ActCompleter::STACK_SIZE; +nn::os::Thread ActCompleter::s_Thread; +nn::os::StackBuffer ActCompleter::s_ThreadStack; + + +ActCompleter::ActCompleter() +{ + // TODO 自動生成されたコンストラクター・スタブ + +} + +ActCompleter::~ActCompleter() +{ + // TODO Auto-generated destructor stub +} + +nn::Result ActCompleter::GetResult() +{ + return s_Result; +} + +void ActCompleter::Start() +{ + s_Thread.Start(Exec, s_ThreadStack); +} + +bool ActCompleter::IsFinished() +{ + return s_Thread.IsValid() && !s_Thread.IsAlive(); +} + +void ActCompleter::Finish() +{ + s_Thread.Join(); + s_Thread.Finalize(); +} + +void ActCompleter::Exec() +{ + if(!nn::ac::IsConnected()) + { + s_Result = common::InitializeNetwork(); + COMMON_LOGGER_RETURN_VOID_IF_FAILED(s_Result); + } + + s_Result = nn::act::InitializeAdmin(); + COMMON_LOGGER_RETURN_VOID_IF_FAILED(s_Result); + + s_Result = nn::act::CompleteTransfer(); + if(s_Result.IsFailure()) + { + if (nn::act::ResultAccountNotLoaded().Includes(s_Result) || nn::act::ResultAuthenticationError().Includes(s_Result)) + { + // これらは発生する可能性があるので成功で上書きする + s_Result = nn::ResultSuccess(); + } + else + { + COMMON_LOGGER_RETURN_VOID_IF_FAILED(s_Result); + } + } + + s_Result = nn::act::FinalizeAdmin(); + COMMON_LOGGER_RETURN_VOID_IF_FAILED(s_Result); + + s_Result = common::FinalizeNetwork(); + COMMON_LOGGER_RETURN_VOID_IF_FAILED(s_Result); +} + +} /* namespace ConsoleRestore */ diff --git a/trunk/ConsoleDataMigration/sources/ConsoleRestore/ActCompleter.h b/trunk/ConsoleDataMigration/sources/ConsoleRestore/ActCompleter.h new file mode 100644 index 0000000..5c391e1 --- /dev/null +++ b/trunk/ConsoleDataMigration/sources/ConsoleRestore/ActCompleter.h @@ -0,0 +1,45 @@ +/*---------------------------------------------------------------------------* + Project: Horizon + File: ActCompleter.h + + Copyright (C)2013 Nintendo Co., Ltd. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Rev$ + *---------------------------------------------------------------------------*/ + +#ifndef ACTCOMPLETER_H_ +#define ACTCOMPLETER_H_ + +#include + +namespace ConsoleRestore +{ + +class ActCompleter +{ +public: + ActCompleter(); + virtual ~ActCompleter(); + + static nn::Result GetResult(); + static void Start(); + static bool IsFinished(); + static void Finish(); + +private: + static void Exec(); + static nn::Result s_Result; + static const size_t STACK_SIZE = 0x1000; + static nn::os::Thread s_Thread; + static nn::os::StackBuffer s_ThreadStack; + +}; + +} /* namespace ConsoleRestore */ +#endif /* ACTCOMPLETER_H_ */ diff --git a/trunk/ConsoleDataMigration/sources/ConsoleRestore/Controller.cpp b/trunk/ConsoleDataMigration/sources/ConsoleRestore/Controller.cpp index 48b1bfd..6d65757 100644 --- a/trunk/ConsoleDataMigration/sources/ConsoleRestore/Controller.cpp +++ b/trunk/ConsoleDataMigration/sources/ConsoleRestore/Controller.cpp @@ -34,6 +34,7 @@ #include "TitleDownloader.h" #include "Shop.h" #include "Util.h" +#include "ActCompleter.h" namespace ConsoleRestore { @@ -72,6 +73,9 @@ bool s_ExecuteTwlTitleDownload = false; // TWLタイトルのダウンロードを何回リトライしたか u32 s_TwlTitleDownloadRetryCount = 0; +// NNA転送完了を何回リトライしたか +u32 s_NNATransferRetryCount = 0; + // プリインストールタイトルのダウンロード準備を開始したかどうか bool s_ExecutePreparePreinstallTitleDownload = false; // プリインストールタイトルのダウンロード準備を何回リトライしたか @@ -144,6 +148,8 @@ typedef enum RestoreState RESTORE_DONE, // 書き込み完了 REBOOTING, // 再起動を行う ERASE, // 削除処理を行う + COMPLETE_ACT, // actアカウント移行完了処理を行う + COMPLETE_ACT_WAIT, // actアカウント移行完了処理の完了待ち RESTORE_CAL, // cfgの一部をcal値で上書きする REPAIR_SIMPLE_ADDRESS_ID, // 本ツールで過去に破壊されたSimpleAddress.idを修正する TIME_ADJUST, // 時計あわせを行う @@ -1389,11 +1395,50 @@ void ControlState(common::HardwareStateManager& manager, common::OperationMessag result = InitializeHardwareDependentSetting(); if (result.IsFailure()) { + COMMON_LOGGER_RESULT(result, __func__); s_RestoreState = FAIL; } + else + { + s_RestoreState = COMPLETE_ACT; + } + } + break; - COMMON_LOGGER("Sync eTicket\n"); - s_RestoreState = SYNC_TICKET; + case COMPLETE_ACT: + { + COMMON_LOGGER("Complete NNA Transfer\n"); + ActCompleter::Start(); + s_RestoreState = COMPLETE_ACT_WAIT; + } + break; + + case COMPLETE_ACT_WAIT: + { + PutAliveMessage(operationMessage, "Complete NNA Transfer"); + if (ActCompleter::IsFinished()) + { + ActCompleter::Finish(); + result = ActCompleter::GetResult(); + if (result.IsFailure()) + { + if(++s_NNATransferRetryCount >= RETRY_MAX) + { + COMMON_LOGGER_RESULT(result, __func__); + s_RestoreState = FAIL; + } + else + { + COMMON_LOGGER("Complete NNA Transfer failed, Retrying..."); + s_RestoreState = COMPLETE_ACT; + } + } + else + { + COMMON_LOGGER("Sync eTicket\n"); + s_RestoreState = SYNC_TICKET; + } + } } break; diff --git a/trunk/ConsoleDataMigration/sources/ConsoleRestore/OMakefile b/trunk/ConsoleDataMigration/sources/ConsoleRestore/OMakefile index 7d8da8c..84f60ba 100644 --- a/trunk/ConsoleDataMigration/sources/ConsoleRestore/OMakefile +++ b/trunk/ConsoleDataMigration/sources/ConsoleRestore/OMakefile @@ -33,6 +33,7 @@ SOURCES[] = Shop.cpp RegionIdModifier.cpp PreinstallImporter.cpp + ActCompleter.cpp ../common/Util.cpp ../common/DrawSystemState.cpp ../common/FileTransfer.cpp @@ -75,6 +76,7 @@ LIBS += libnn_cfg \ libnn_am \ libnn_nim \ libnn_xml_simple \ + libnn_act \ QRE_LIBRARIES[] = libmw_qre LIBFILES += $`(addprefix $(CTRMW_QRE_ROOT)$(DIRSEP)$(SUBDIR_LIBRARIES)$(DIRSEP)$(config.getTargetSubDirectory true)$(DIRSEP), $(QRE_LIBRARIES)) \