XML生成部分を分離

git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@568 385bec56-5757-e545-9c3a-d8741f4650f1
This commit is contained in:
N2614 2012-01-18 07:56:39 +00:00
parent a1df85d401
commit b4b01e1c1e
9 changed files with 155 additions and 83 deletions

View File

@ -15,37 +15,9 @@
#include "BgsCommunicator.h"
#include <cstring>
#include <sstream>
namespace ConsoleRestore
{
namespace
{
const char xmlDataPrefix[] = \
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\
<SOAP-ENV:Envelope xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:ns0=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:ns1=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ns2=\"urn:bgs.wsapi.broadon.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">\n\
<SOAP-ENV:Header/>\n\
<ns1:Body>\n\
<ns2:GetPreInstalledInfo>\n\
<ns2:GetPreInstalledInfo>\n\
<ns2:Version/>\n\
<ns2:MessageId/>\n";
const char xmlDeviceIdPrefix[] = \
" <ns2:DeviceId>";
const char xmlDeviceIdSuffix[] = "</ns2:DeviceId>\n";
const char xmlSerialNoPrefix[] = \
" <ns2:SerialNo>";
const char xmlSerialNoSuffix[] = "</ns2:SerialNo>\n";
const char xmlDataSuffix[] = \
" </ns2:GetPreInstalledInfo>\n\
</ns2:GetPreInstalledInfo>\n\
</ns1:Body>\n\
</SOAP-ENV:Envelope>";
}
BgsCommunicator::BgsCommunicator()
{
@ -57,31 +29,9 @@ 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<char*>(serialNo));
m_Xml.append(xmlSerialNoSuffix);
m_Xml.append(xmlDataSuffix);
}
std::string BgsCommunicator::GetXml()
{
return m_Xml;
}
bool BgsCommunicator::Execute()
{
nn::Result result;
return false;
}

View File

@ -16,13 +16,7 @@
#ifndef BGSCOMMUNICATOR_H_
#define BGSCOMMUNICATOR_H_
#include <string>
#if defined(__ARMCC_VERSION)
#include <nn.h>
#else
#include "test_common.h"
#endif
namespace ConsoleRestore
{
@ -32,14 +26,6 @@ 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();
@ -50,9 +36,6 @@ public:
//! @param[out] buf 通信結果を書き込むバッファ
void GetBody(void* buf);
private:
std::string m_Xml;
};
} /* namespace ConsoleRestore */

View File

@ -32,6 +32,7 @@ SOURCES[] =
Shop.cpp
RegionIdModifier.cpp
SimpleXmlPreprocessor.cpp
XmlCreator.cpp
BgsCommunicator.cpp
../common/Util.cpp
../common/DrawSystemState.cpp

View File

@ -0,0 +1,84 @@
/*---------------------------------------------------------------------------*
Project: Horizon
File: XmlCreator.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 "XmlCreator.h"
#include <cstring>
#include <sstream>
namespace ConsoleRestore
{
namespace
{
const char xmlDataPrefix[] = \
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\
<SOAP-ENV:Envelope xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:ns0=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:ns1=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ns2=\"urn:bgs.wsapi.broadon.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">\n\
<SOAP-ENV:Header/>\n\
<ns1:Body>\n\
<ns2:GetPreInstalledInfo>\n\
<ns2:GetPreInstalledInfo>\n\
<ns2:Version/>\n\
<ns2:MessageId/>\n";
const char xmlDeviceIdPrefix[] = \
" <ns2:DeviceId>";
const char xmlDeviceIdSuffix[] = "</ns2:DeviceId>\n";
const char xmlSerialNoPrefix[] = \
" <ns2:SerialNo>";
const char xmlSerialNoSuffix[] = "</ns2:SerialNo>\n";
const char xmlDataSuffix[] = \
" </ns2:GetPreInstalledInfo>\n\
</ns2:GetPreInstalledInfo>\n\
</ns1:Body>\n\
</SOAP-ENV:Envelope>";
}
XmlCreator::XmlCreator()
{
// TODO 自動生成されたコンストラクター・スタブ
}
XmlCreator::~XmlCreator()
{
// TODO Auto-generated destructor stub
}
void XmlCreator::Exec(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<char*>(serialNo));
m_Xml.append(xmlSerialNoSuffix);
m_Xml.append(xmlDataSuffix);
}
std::string XmlCreator::GetData()
{
return m_Xml;
}
} /* namespace ConsoleRestore */

View File

@ -0,0 +1,51 @@
/*---------------------------------------------------------------------------*
Project: Horizon
File: XmlCreator.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 XMLCREATOR_H_
#define XMLCREATOR_H_
#include <string>
#if defined(__ARMCC_VERSION)
#include <nn.h>
#else
#include "test_common.h"
#endif
namespace ConsoleRestore
{
class XmlCreator
{
public:
XmlCreator();
virtual ~XmlCreator();
//! @brief プリインストール情報を取得するためのXMLを構築します
//! @param[in] deviceId デバイスID
//! @param[in] serialNo シリアルNo.
void Exec(bit64 deviceId, u8* serialNo);
//! @brief 構築したXMLデータを取得します
std::string GetData();
private:
std::string m_Xml;
};
} /* namespace ConsoleRestore */
#endif /* XMLCREATOR_H_ */

View File

@ -1 +1 @@
.SUBDIRS: RegionIdModifier BgsCommunicator
.SUBDIRS: RegionIdModifier XmlCreator

View File

@ -4,21 +4,23 @@ INCLUDES[] +=
../../../ConsoleRestore
TARGET = testRegionIdModifier
TEST_TARGET = RegionIdModifier
SRC_FILES[] =
testRegionIdModifier
testUtil
RegionIdModifier
# テスト独自のスタブを使用する場合に定義する
CXXFLAGS += -DPCTEST_USE_STUB
# テストディレクトリ外にあるので独自ルールでビルド
RegionIdModifier$(EXT_OBJ): ../../../ConsoleRestore/RegionIdModifier.cpp
$(TEST_TARGET)$(EXT_OBJ): ../../../ConsoleRestore/$(TEST_TARGET).cpp
$(CXX) $(CXXFLAGS) $(PREFIXED_INCLUDES) -c $<
.DEFAULT: RegionIdModifier$(EXT_OBJ) $(TARGET)$(EXE)
.DEFAULT: $(TEST_TARGET)$(EXT_OBJ) $(TARGET)$(EXE)
CXXProgram(testRegionIdModifier, $(SRC_FILES))
CXXProgram($(TARGET), $(SRC_FILES))
.PHONY: clean test
clean:

View File

@ -3,19 +3,20 @@ INCLUDES[] +=
../common
../../../ConsoleRestore
TARGET = testBgsCommunicator
TARGET = testXmlCreator
TEST_TARGET = XmlCreator
SRC_FILES[] =
testBgsCommunicator
BgsCommunicator
testXmlCreator
XmlCreator
# テストディレクトリ外にあるので独自ルールでビルド
BgsCommunicator$(EXT_OBJ): ../../../ConsoleRestore/BgsCommunicator.cpp
$(TEST_TARGET)$(EXT_OBJ): ../../../ConsoleRestore/$(TEST_TARGET).cpp
$(CXX) $(CXXFLAGS) $(PREFIXED_INCLUDES) -c $<
.DEFAULT: BgsCommunicator$(EXT_OBJ) $(TARGET)$(EXE)
.DEFAULT: $(TEST_TARGET)$(EXT_OBJ) $(TARGET)$(EXE)
CXXProgram(testBgsCommunicator, $(SRC_FILES))
CXXProgram($(TARGET), $(SRC_FILES))
.PHONY: clean test
clean:

View File

@ -1,7 +1,7 @@
#include <gtest/gtest.h>
#include <cstring>
#include "BgsCommunicator.h"
#include "XmlCreator.h"
using namespace ConsoleRestore;
@ -25,9 +25,9 @@ const char testStr[] = \
</SOAP-ENV:Envelope>";
}
TEST(testBgsCommunicator, CreateXml)
TEST(testXmlCreator, Exec)
{
BgsCommunicator comm;
comm.CreateXml(17179924184, reinterpret_cast<u8*>(const_cast<char*>("EJA20305940")));
ASSERT_STREQ(testStr, comm.GetXml().c_str());
XmlCreator xml;
xml.Exec(17179924184, reinterpret_cast<u8*>(const_cast<char*>("EJA20305940")));
ASSERT_STREQ(testStr, xml.GetData().c_str());
}