mirror of
https://github.com/rvtr/ctr_Repair.git
synced 2025-10-31 13:51:08 -04:00
BgsCommunicator:XMLデータ生成まで
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
This commit is contained in:
parent
5d4155571d
commit
c35367985a
@ -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 <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()
|
||||
{
|
||||
// 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<char*>(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 */
|
||||
@ -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 <string>
|
||||
#if defined(__ARMCC_VERSION)
|
||||
#include <nn.h>
|
||||
#else
|
||||
#include <cstddef>
|
||||
#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_ */
|
||||
@ -32,6 +32,7 @@ SOURCES[] =
|
||||
Shop.cpp
|
||||
RegionIdModifier.cpp
|
||||
SimpleXmlPreprocessor.cpp
|
||||
BgsCommunicator.cpp
|
||||
../common/Util.cpp
|
||||
../common/DrawSystemState.cpp
|
||||
../common/FileTransfer.cpp
|
||||
|
||||
@ -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)
|
||||
$<
|
||||
@ -0,0 +1,33 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <cstring>
|
||||
|
||||
#include "BgsCommunicator.h"
|
||||
|
||||
using namespace ConsoleRestore;
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
const char testStr[] = \
|
||||
"<?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\
|
||||
<ns2:DeviceId>17179924184</ns2:DeviceId>\n\
|
||||
<ns2:SerialNo>EJA20305940</ns2:SerialNo>\n\
|
||||
</ns2:GetPreInstalledInfo>\n\
|
||||
</ns2:GetPreInstalledInfo>\n\
|
||||
</ns1:Body>\n\
|
||||
</SOAP-ENV:Envelope>";
|
||||
}
|
||||
|
||||
TEST(testBgsCommunicator, CreateXml)
|
||||
{
|
||||
BgsCommunicator comm;
|
||||
comm.CreateXml(17179924184, reinterpret_cast<u8*>(const_cast<char*>("EJA20305940")));
|
||||
ASSERT_STREQ(testStr, comm.GetXml().c_str());
|
||||
}
|
||||
@ -1 +1 @@
|
||||
.SUBDIRS: RegionIdModifier
|
||||
.SUBDIRS: RegionIdModifier BgsCommunicator
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
INCLUDES[] +=
|
||||
./
|
||||
../common
|
||||
../../../ConsoleRestore
|
||||
|
||||
TARGET = testRegionIdModifier
|
||||
|
||||
@ -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
|
||||
Loading…
Reference in New Issue
Block a user