From c35367985aacbc3f6128976eb542d4ea6eb0240d Mon Sep 17 00:00:00 2001 From: N2614 Date: Wed, 18 Jan 2012 07:03:27 +0000 Subject: [PATCH] =?UTF-8?q?BgsCommunicator:XML=E3=83=87=E3=83=BC=E3=82=BF?= =?UTF-8?q?=E7=94=9F=E6=88=90=E3=81=BE=E3=81=A7?= 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@566 385bec56-5757-e545-9c3a-d8741f4650f1 --- .../ConsoleRestore/BgsCommunicator.cpp | 95 +++++++++++++++++++ .../sources/ConsoleRestore/BgsCommunicator.h | 60 ++++++++++++ .../sources/ConsoleRestore/OMakefile | 1 + .../googletest/BgsCommunicator/OMakefile | 25 +++++ .../BgsCommunicator/testBgsCommunicator.cpp | 33 +++++++ .../sources/tests/googletest/OMakefile | 2 +- .../googletest/RegionIdModifier/OMakefile | 1 + .../{RegionIdModifier => common}/types.h | 2 + 8 files changed, 218 insertions(+), 1 deletion(-) create mode 100644 trunk/ConsoleDataMigration/sources/ConsoleRestore/BgsCommunicator.cpp create mode 100644 trunk/ConsoleDataMigration/sources/ConsoleRestore/BgsCommunicator.h create mode 100644 trunk/ConsoleDataMigration/sources/tests/googletest/BgsCommunicator/OMakefile create mode 100644 trunk/ConsoleDataMigration/sources/tests/googletest/BgsCommunicator/testBgsCommunicator.cpp rename trunk/ConsoleDataMigration/sources/tests/googletest/{RegionIdModifier => common}/types.h (75%) diff --git a/trunk/ConsoleDataMigration/sources/ConsoleRestore/BgsCommunicator.cpp b/trunk/ConsoleDataMigration/sources/ConsoleRestore/BgsCommunicator.cpp new file mode 100644 index 0000000..7188c05 --- /dev/null +++ b/trunk/ConsoleDataMigration/sources/ConsoleRestore/BgsCommunicator.cpp @@ -0,0 +1,95 @@ +/*---------------------------------------------------------------------------* + Project: Horizon + File: BgsCommunicator.cpp + + Copyright 2009-2011 Nintendo. 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 "BgsCommunicator.h" + +#include +#include + +namespace ConsoleRestore +{ + +namespace +{ +const char xmlDataPrefix[] = \ +"\n\ +\n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n"; +const char xmlDeviceIdPrefix[] = \ +" "; +const char xmlDeviceIdSuffix[] = "\n"; +const char xmlSerialNoPrefix[] = \ +" "; +const char xmlSerialNoSuffix[] = "\n"; +const char xmlDataSuffix[] = \ +" \n\ + \n\ + \n\ +"; + +} + + +BgsCommunicator::BgsCommunicator() +{ + // TODO 自動生成されたコンストラクター・スタブ +} + +BgsCommunicator::~BgsCommunicator() +{ + // TODO Auto-generated destructor stub +} + +void BgsCommunicator::CreateXml(bit64 deviceId, u8* serialNo) +{ + m_Xml.append(xmlDataPrefix); + + m_Xml.append(xmlDeviceIdPrefix); + std::ostringstream oss; + oss << std::dec; + oss << deviceId; + m_Xml.append(oss.str()); + m_Xml.append(xmlDeviceIdSuffix); + + m_Xml.append(xmlSerialNoPrefix); + m_Xml.append(reinterpret_cast(serialNo)); + m_Xml.append(xmlSerialNoSuffix); + + m_Xml.append(xmlDataSuffix); +} + +std::string BgsCommunicator::GetXml() +{ + return m_Xml; +} + +bool BgsCommunicator::Execute() +{ +} + +size_t BgsCommunicator::GetBodySize() +{ +} + +void BgsCommunicator::GetBody(void *buf) +{ +} + +} /* namespace ConsoleRestore */ diff --git a/trunk/ConsoleDataMigration/sources/ConsoleRestore/BgsCommunicator.h b/trunk/ConsoleDataMigration/sources/ConsoleRestore/BgsCommunicator.h new file mode 100644 index 0000000..8372fe7 --- /dev/null +++ b/trunk/ConsoleDataMigration/sources/ConsoleRestore/BgsCommunicator.h @@ -0,0 +1,60 @@ +/*---------------------------------------------------------------------------* + Project: Horizon + File: BgsCommunicator.h + + Copyright 2009-2011 Nintendo. 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 BGSCOMMUNICATOR_H_ +#define BGSCOMMUNICATOR_H_ + +#include +#if defined(__ARMCC_VERSION) +#include +#else +#include +#include "types.h" +#endif + +namespace ConsoleRestore +{ + +class BgsCommunicator +{ +public: + BgsCommunicator(); + virtual ~BgsCommunicator(); + + //! @brief プリインストール情報を取得するためのXMLを構築します + //! @param[in] deviceId デバイスID + //! @param[in] serialNo シリアルNo. + void CreateXml(bit64 deviceId, u8* serialNo); + + //! @brief 構築したXMLデータを取得します + std::string GetXml(); + + //! @brief 構築したXMLを使ってBGSと通信します + bool Execute(); + + //! @brief 通信結果のサイズを取得します + size_t GetBodySize(); + + //! @brief 通信結果を取得します + //! @param[out] buf 通信結果を書き込むバッファ + void GetBody(void* buf); + +private: + std::string m_Xml; + +}; + +} /* namespace ConsoleRestore */ +#endif /* BGSCOMMUNICATOR_H_ */ diff --git a/trunk/ConsoleDataMigration/sources/ConsoleRestore/OMakefile b/trunk/ConsoleDataMigration/sources/ConsoleRestore/OMakefile index 998ed67..da9e6ce 100644 --- a/trunk/ConsoleDataMigration/sources/ConsoleRestore/OMakefile +++ b/trunk/ConsoleDataMigration/sources/ConsoleRestore/OMakefile @@ -32,6 +32,7 @@ SOURCES[] = Shop.cpp RegionIdModifier.cpp SimpleXmlPreprocessor.cpp + BgsCommunicator.cpp ../common/Util.cpp ../common/DrawSystemState.cpp ../common/FileTransfer.cpp diff --git a/trunk/ConsoleDataMigration/sources/tests/googletest/BgsCommunicator/OMakefile b/trunk/ConsoleDataMigration/sources/tests/googletest/BgsCommunicator/OMakefile new file mode 100644 index 0000000..eeff804 --- /dev/null +++ b/trunk/ConsoleDataMigration/sources/tests/googletest/BgsCommunicator/OMakefile @@ -0,0 +1,25 @@ +INCLUDES[] += + ./ + ../common + ../../../ConsoleRestore + +TARGET = testBgsCommunicator + +SRC_FILES[] = + testBgsCommunicator + BgsCommunicator + +# テストディレクトリ外にあるので独自ルールでビルド +BgsCommunicator$(EXT_OBJ): ../../../ConsoleRestore/BgsCommunicator.cpp + $(CXX) $(PREFIXED_INCLUDES) -c $< + +.DEFAULT: BgsCommunicator$(EXT_OBJ) $(TARGET)$(EXE) + +CXXProgram(testBgsCommunicator, $(SRC_FILES)) + +.PHONY: clean test +clean: + rm -rf *$(EXT_OBJ) *$(EXE) + +test: $(TARGET)$(EXE) + $< diff --git a/trunk/ConsoleDataMigration/sources/tests/googletest/BgsCommunicator/testBgsCommunicator.cpp b/trunk/ConsoleDataMigration/sources/tests/googletest/BgsCommunicator/testBgsCommunicator.cpp new file mode 100644 index 0000000..f32114a --- /dev/null +++ b/trunk/ConsoleDataMigration/sources/tests/googletest/BgsCommunicator/testBgsCommunicator.cpp @@ -0,0 +1,33 @@ +#include +#include + +#include "BgsCommunicator.h" + +using namespace ConsoleRestore; + +namespace +{ + +const char testStr[] = \ +"\n\ +\n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + 17179924184\n\ + EJA20305940\n\ + \n\ + \n\ + \n\ +"; +} + +TEST(testBgsCommunicator, CreateXml) +{ + BgsCommunicator comm; + comm.CreateXml(17179924184, reinterpret_cast(const_cast("EJA20305940"))); + ASSERT_STREQ(testStr, comm.GetXml().c_str()); +} diff --git a/trunk/ConsoleDataMigration/sources/tests/googletest/OMakefile b/trunk/ConsoleDataMigration/sources/tests/googletest/OMakefile index d9640a6..f90b55e 100644 --- a/trunk/ConsoleDataMigration/sources/tests/googletest/OMakefile +++ b/trunk/ConsoleDataMigration/sources/tests/googletest/OMakefile @@ -1 +1 @@ -.SUBDIRS: RegionIdModifier +.SUBDIRS: RegionIdModifier BgsCommunicator diff --git a/trunk/ConsoleDataMigration/sources/tests/googletest/RegionIdModifier/OMakefile b/trunk/ConsoleDataMigration/sources/tests/googletest/RegionIdModifier/OMakefile index b3d37f8..511d761 100644 --- a/trunk/ConsoleDataMigration/sources/tests/googletest/RegionIdModifier/OMakefile +++ b/trunk/ConsoleDataMigration/sources/tests/googletest/RegionIdModifier/OMakefile @@ -1,5 +1,6 @@ INCLUDES[] += ./ + ../common ../../../ConsoleRestore TARGET = testRegionIdModifier diff --git a/trunk/ConsoleDataMigration/sources/tests/googletest/RegionIdModifier/types.h b/trunk/ConsoleDataMigration/sources/tests/googletest/common/types.h similarity index 75% rename from trunk/ConsoleDataMigration/sources/tests/googletest/RegionIdModifier/types.h rename to trunk/ConsoleDataMigration/sources/tests/googletest/common/types.h index 170af82..9de300f 100644 --- a/trunk/ConsoleDataMigration/sources/tests/googletest/RegionIdModifier/types.h +++ b/trunk/ConsoleDataMigration/sources/tests/googletest/common/types.h @@ -6,8 +6,10 @@ typedef signed char s8; typedef unsigned short u16; typedef short s16; typedef unsigned int u32; +typedef unsigned int bit32; typedef int s32; typedef unsigned long long u64; +typedef unsigned long long bit64; typedef long long s64; #endif