From 103d7a26131fb4920ffa7b6048ecffb2698444bd Mon Sep 17 00:00:00 2001 From: N2614 Date: Fri, 27 Jan 2012 08:31:17 +0000 Subject: [PATCH] =?UTF-8?q?=E5=BF=85=E8=A6=81=E3=81=AA=E6=99=82=E3=81=AE?= =?UTF-8?q?=E3=81=BFac=E6=8E=A5=E7=B6=9A=E3=81=99=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@616 385bec56-5757-e545-9c3a-d8741f4650f1 --- .../ConsoleRestore/BgsCommunicator.cpp | 10 +-- .../sources/ConsoleRestore/Importer.cpp | 3 + .../sources/ConsoleRestore/NtpClient.cpp | 7 +- .../sources/ConsoleRestore/Shop.cpp | 71 ++----------------- .../sources/ConsoleRestore/Updater.cpp | 68 ++---------------- .../sources/common/Util.cpp | 12 ++++ 6 files changed, 40 insertions(+), 131 deletions(-) diff --git a/trunk/ConsoleDataMigration/sources/ConsoleRestore/BgsCommunicator.cpp b/trunk/ConsoleDataMigration/sources/ConsoleRestore/BgsCommunicator.cpp index 06d6311..8fa2713 100644 --- a/trunk/ConsoleDataMigration/sources/ConsoleRestore/BgsCommunicator.cpp +++ b/trunk/ConsoleDataMigration/sources/ConsoleRestore/BgsCommunicator.cpp @@ -17,6 +17,7 @@ #include "Util.h" #include "CommonLogger.h" +#include #include #include #include @@ -200,8 +201,11 @@ BgsCommunicator::~BgsCommunicator() bool BgsCommunicator::Execute(const void* buf, size_t size) { - m_Result = common::InitializeNetwork(); - COMMON_LOGGER_RETURN_FALSE_IF_FAILED(m_Result); + if(!nn::ac::IsConnected()) + { + m_Result = common::InitializeNetwork(); + COMMON_LOGGER_RETURN_FALSE_IF_FAILED(m_Result); + } /* ------------------------------------------------------------------------ ライブラリの初期化(HTTPライブラリ使用前に、各プロセスで一度だけ実行する。) @@ -299,8 +303,6 @@ bool BgsCommunicator::Finalize() COMMON_LOGGER_RETURN_FALSE_IF_FAILED(m_Result); m_Result = nn::http::Finalize(); COMMON_LOGGER_RETURN_FALSE_IF_FAILED(m_Result); - m_Result = common::FinalizeNetwork(); - COMMON_LOGGER_RETURN_FALSE_IF_FAILED(m_Result); return true; } diff --git a/trunk/ConsoleDataMigration/sources/ConsoleRestore/Importer.cpp b/trunk/ConsoleDataMigration/sources/ConsoleRestore/Importer.cpp index 332d793..f15c49a 100644 --- a/trunk/ConsoleDataMigration/sources/ConsoleRestore/Importer.cpp +++ b/trunk/ConsoleDataMigration/sources/ConsoleRestore/Importer.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -1115,6 +1116,8 @@ bool UpdateNetworkSetting(nn::ac::NetworkSetting& networkSetting) } else { + // 設定が変わるので切断しておく + nn::ac::CloseAll(); result = nn::ac::FinalizeInternal(); if (!result.IsSuccess()) { diff --git a/trunk/ConsoleDataMigration/sources/ConsoleRestore/NtpClient.cpp b/trunk/ConsoleDataMigration/sources/ConsoleRestore/NtpClient.cpp index 77b0e9a..f91848a 100644 --- a/trunk/ConsoleDataMigration/sources/ConsoleRestore/NtpClient.cpp +++ b/trunk/ConsoleDataMigration/sources/ConsoleRestore/NtpClient.cpp @@ -62,8 +62,11 @@ bool GetNtpTime(u32* ntpTime) NN_LOG("Initializing network.\n"); // 本体に書き込まれているネットワーク設定を使ってネットワーク接続を初期化 - result = common::InitializeNetwork(); - COMMON_LOGGER_RESULT_IF_FAILED(result); + if(!nn::ac::IsConnected()) + { + result = common::InitializeNetwork(); + COMMON_LOGGER_RESULT_IF_FAILED(result); + } { NN_LOG("Initializing socket..\n"); diff --git a/trunk/ConsoleDataMigration/sources/ConsoleRestore/Shop.cpp b/trunk/ConsoleDataMigration/sources/ConsoleRestore/Shop.cpp index ae65ff1..1a9bfac 100644 --- a/trunk/ConsoleDataMigration/sources/ConsoleRestore/Shop.cpp +++ b/trunk/ConsoleDataMigration/sources/ConsoleRestore/Shop.cpp @@ -25,6 +25,7 @@ #include "Shop.h" #include "CommonLogger.h" +#include "Util.h" using namespace ES_NAMESPACE; using namespace EC_NAMESPACE; @@ -200,63 +201,6 @@ void PrintECAccountInfo(const ECAccountInfo& accountInfo) } } -nn::Result PrintNetworkSetting() -{ - nn::Result result; - nn::ac::NetworkSetting networkSetting; - result = nn::ac::LoadNetworkSetting(0, networkSetting); - COMMON_LOGGER("SSID: %s\n", networkSetting.wireless.essidSecurity.ssid); - COMMON_LOGGER("DNS : %d.%d.%d.%d\n", - networkSetting.ip.dns[0][0], networkSetting.ip.dns[0][1], - networkSetting.ip.dns[0][2], networkSetting.ip.dns[0][3]); - return result; -} - - -nn::Result ConnectNetwork() -{ - nn::Result result; - nn::ac::Config config; - - result = nn::ac::CreateDefaultConfig(&config); - COMMON_LOGGER_RETURN_RESULT_IF_FAILED(result); - - result = nn::ac::ConnectWithoutEula(config); - COMMON_LOGGER_RETURN_RESULT_IF_FAILED(result); - - COMMON_LOGGER_DETAIL("Success nn::ac::ConnectWithoutEula\n"); - - result = PrintNetworkSetting(); - COMMON_LOGGER_RETURN_RESULT_IF_FAILED(result); - - return result; -} - -nn::Result InitializeInternal() -{ - nn::Result result; - - result = nn::ac::InitializeInternal(); - COMMON_LOGGER_RETURN_RESULT_IF_FAILED(result); - - result = ConnectNetwork(); - COMMON_LOGGER_RETURN_RESULT_IF_FAILED(result); - - return result; -} - -nn::Result FinalizeInternal() -{ - nn::Result result = nn::ResultSuccess(); - - nn::ac::CloseAll(); - - result = nn::ac::FinalizeInternal(); - NN_UTIL_RETURN_IF_FAILED(result); - - return result; -} - } @@ -357,10 +301,6 @@ nn::Result ShopOperationFinalize() NN_UTIL_RETURN_IF_FAILED(result); s_IsNimShopInitialized = false; - COMMON_LOGGER_DETAIL("util::ac::Finalize\n"); - result = FinalizeInternal(); - NN_UTIL_RETURN_IF_FAILED(result); - return result; } @@ -407,9 +347,12 @@ void ShopOperationSingleThreadFunc(ShopThreadParam param) s_ShopResult = nn::ResultSuccess(); - COMMON_LOGGER_DETAIL("util::ac::Initialize\n"); - result = InitializeInternal(); - NIM_SHOP_RESULT_CHECK(result); + if(!nn::ac::IsConnected()) + { + COMMON_LOGGER_DETAIL("util::ac::Initialize\n"); + result = common::InitializeNetwork(); + NIM_SHOP_RESULT_CHECK(result); + } switch(param.op) { diff --git a/trunk/ConsoleDataMigration/sources/ConsoleRestore/Updater.cpp b/trunk/ConsoleDataMigration/sources/ConsoleRestore/Updater.cpp index aa6b7cc..64b188b 100644 --- a/trunk/ConsoleDataMigration/sources/ConsoleRestore/Updater.cpp +++ b/trunk/ConsoleDataMigration/sources/ConsoleRestore/Updater.cpp @@ -23,6 +23,7 @@ #include #include "CommonLogger.h" +#include "Util.h" namespace ConsoleRestore { @@ -60,61 +61,6 @@ nn::os::StackBuffer s_UpdaterThreadStack; u64 s_Progress = 0; -nn::Result PrintNetworkSetting() -{ - nn::ac::NetworkSetting networkSetting; - NN_UTIL_RETURN_IF_FAILED(nn::ac::LoadNetworkSetting(0, networkSetting)); - COMMON_LOGGER("SSID: %s\n", networkSetting.wireless.essidSecurity.ssid); - COMMON_LOGGER("DNS : %d.%d.%d.%d\n", - networkSetting.ip.dns[0][0], networkSetting.ip.dns[0][1], - networkSetting.ip.dns[0][2], networkSetting.ip.dns[0][3]); - return nn::ResultSuccess(); -} - - -nn::Result ConnectNetwork() -{ - nn::Result result = nn::ResultSuccess(); - nn::ac::Config config; - - result = nn::ac::CreateDefaultConfig(&config); - NN_UTIL_RETURN_IF_FAILED(result); - - result = nn::ac::ConnectWithoutEula(config); - NN_UTIL_RETURN_IF_FAILED(result); - - COMMON_LOGGER_DETAIL("Success nn::ac::ConnectWithoutEula\n"); - - NN_UTIL_RETURN_IF_FAILED(PrintNetworkSetting()); - - return result; -} - -nn::Result InitializeInternal() -{ - nn::Result result = nn::ResultSuccess(); - - result = nn::ac::InitializeInternal(); - NN_UTIL_RETURN_IF_FAILED(result); - - result = ConnectNetwork(); - NN_UTIL_RETURN_IF_FAILED(result); - - return result; -} - -nn::Result FinalizeInternal() -{ - nn::Result result = nn::ResultSuccess(); - - nn::ac::CloseAll(); - - result = nn::ac::FinalizeInternal(); - NN_UTIL_RETURN_IF_FAILED(result); - - return result; -} - } void UpdateThreadFunc() @@ -145,9 +91,12 @@ void UpdateThreadFunc() result = nn::nim::InitializeForUpdater(); NIM_UPDATER_RESULT_CHECK(result); - COMMON_LOGGER_DETAIL("[Updater] InitializeInternal\n"); - result = InitializeInternal(); - NIM_UPDATER_RESULT_CHECK(result); + if(!nn::ac::IsConnected()) + { + COMMON_LOGGER_DETAIL("[Updater] InitializeInternal\n"); + result = common::InitializeNetwork(); + NIM_UPDATER_RESULT_CHECK(result); + } /* ------------------------------------------------------------------- @@ -211,9 +160,6 @@ void UpdateThreadFunc() result = nn::nim::FinalizeForUpdater(); NIM_UPDATER_RESULT_CHECK(result); - result = FinalizeInternal(); - NIM_UPDATER_RESULT_CHECK(result); - COMMON_LOGGER_DETAIL("[Updater] Finish nim Updater demo.\n"); } diff --git a/trunk/ConsoleDataMigration/sources/common/Util.cpp b/trunk/ConsoleDataMigration/sources/common/Util.cpp index 908b4d9..a21abad 100644 --- a/trunk/ConsoleDataMigration/sources/common/Util.cpp +++ b/trunk/ConsoleDataMigration/sources/common/Util.cpp @@ -370,6 +370,18 @@ bool Util::HasReadFriendCode() return m_HasReadFriendCode; } +nn::Result PrintNetworkSetting() +{ + nn::Result result; + nn::ac::NetworkSetting networkSetting; + result = nn::ac::LoadNetworkSetting(0, networkSetting); + COMMON_LOGGER("SSID: %s\n", networkSetting.wireless.essidSecurity.ssid); + COMMON_LOGGER("DNS : %d.%d.%d.%d\n", + networkSetting.ip.dns[0][0], networkSetting.ip.dns[0][1], + networkSetting.ip.dns[0][2], networkSetting.ip.dns[0][3]); + return result; +} + nn::Result InitializeNetwork(void) { nn::Result result;