/*---------------------------------------------------------------------------* Project: Horizon File: cec_MessageBox.h Copyright 2009 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. $Date:: 2010-09-27#$ $Rev: 26754 $ $Author: sato_yoshinobu $ *---------------------------------------------------------------------------*/ #ifndef __MESSAGE_BOX_H__ #define __MESSAGE_BOX_H__ #define MESSAGE_BOX_NUM_MAX (36) #define CEC_OUTBOX_MESS_NUM_MAX (64) #define CEC_MAX_MESSAGE_NUM (64) /* CEC/ | +-- MessageBoxList \-- Message_BOX1/ | | | +-- MessageBoxInfo | \-- InBox/ | | | | | +-- InBoxInfo | | +-- Message1 | | | \-- OutBox/ | | | +-- OutBoxIndex | +-- OutBoxInfo | +-- Message2 | \-- Message_BOX2/ | */ #define CEC_INBOX_SIZE_DEFAULT (512*1024) //! 受信Box サイズ初期値 #define CEC_OUTBOX_SIZE_DEFAULT (512*1024) //! 送信Box サイズ初期値 #define CEC_INBOX_MESSNUM_DEFAULT (99) #define CEC_OUTBOX_MESSNUM_DEFAULT (99) #define CEC_MESSSIZEMAX_DEFAULT (100*1024) #define CEC_BOX_DATA_SIZE_MAX (10*1024) #define CEC_BOXNUMMAX_APPLICATION (12) // 一般アプリケーション用 Box 最大数 #define CEC_BOXNUMMAX_SYSTEM (12) // System アプリケーション用 Box 最大数 #define CEC_BOXNUMMAX_SYSTEM2 (6) // System アプリケーション その2 用 Box 最大数 #define CEC_BOXDIR_NAMELEN_MAX (16) #include namespace nn { namespace cec { namespace CTR { //! @name MessageBoxFlag //@{ /*! * @typedef MessageBoxFlag * @brief MessageBox の属性を示すフラグです。 */ typedef bit8 MessageBoxFlag; /*! @brief 一般アプリケーション用
デフォルトでこの値が指定されています。 */ static const bit8 MESSAGE_BOX_FLAG_APPLICATION = (0x1); /* @brief System アプリケーション用 */ static const bit8 MESSAGE_BOX_FLAG_SYSTEM = (0x2); /* @brief System アプリケーション用 その2 */ static const bit8 MESSAGE_BOX_FLAG_SYSTEM2 = (0x4); /* @brief 接続時にBOXの存在を通知しない */ static const bit8 MESSAGE_BOX_FLAG_HIDDEN = (0x80); //@} /*! * @enum CecBoxType * @brief 受信BOX/ 送信BOX の種別 */ enum CecBoxType { CEC_BOXTYPE_INBOX = (0x0), //!< 受信BOX CEC_BOXTYPE_OUTBOX = (0x1) //!< 送信BOX }; // 構造体 #define MESSAGEBOXLIST_MAGIC 0x6868 #define CEC_BOX_VERSION 0x00000001 struct MessageBoxList { u16 magic16; NN_PADDING2; u32 CecBoxVersion; u32 DirNum; u8 DirName[MESSAGE_BOX_NUM_MAX][CEC_BOXDIR_NAMELEN_MAX]; }; //ローカル管理用メッセージリスト #define MESSAGEBOXINFO_MAGIC 0x6363 struct MessageBoxInfo { u16 magic16; NN_PADDING2; u32 cecTitleId; // Title固有ID u32 privateId; // アプリがつける固有ID。アクセスする為のキーとなる。 MessageBoxFlag MessageBoxInfoFlag; // MessageBoxInfoのフラグ(Systemなど) bool isActive; NN_PADDING2; char hmacKey[MESSAGE_HMAC_KEYLEN]; // HMACで署名を付けるときに使用するKey u32 MessageBoxInfoSize; // MessageBoxInfoのサイズ(Byte) nn::fnd::DateTimeParameters lastOpened; // アクセス時の時刻を記録 u8 reserved[32]; // reserved (名称・iconなどは別ファイルに書く) }; // 送信/受信 ボックス情報ファイル データ構造 /* File : InBoxInfo/OutBoxInfo +----------------------+ | CEC Box Info Header | +----------------------+ -+ | CEC Message Header1 | | +----------------------+ | CecMessageHeader_List | CEC Message Header2 | | +----------------------+ | | CEC Message Header3 | | +----------------------+ | | .......... | | | | | +----------------------+ -+ */ //typedef std::vector CecMessageHeader_List; // MessageHeader のリストの配列定義 //typedef nn::fnd::IntrusiveLinkedList CecMessageHeader_List; // MessageHeader のリスト #define CEC_BOXINFO_MAGIC 0x6262 #define CEC_SIZEOF_BOXINFO_HEADER (sizeof(struct CecBoxInfoHeader)) struct CecBoxInfoHeader { u16 magic16; NN_PADDING2; u32 boxInfoSize; // BoxInfoのサイズ u32 boxSizeMax; // MessageBoxのサイズ(Byte)最大値 u32 boxSize; // MessageBoxのサイズ(使用量)(Byte) u32 messNumMax; // ボックスに格納可能な message数 の最大値 u32 messNum; // ボックスに格納されているmessage数 u32 groupNumMax; // ボックスに格納可能な Message Group 数 の最大値 u32 messSizeMax; // 1つのMessageの最大サイズ }; // 送信ボックス Index ファイル (送信順を示す) #define CEC_OUTBOXINDEX_MAGIC 0x6767 struct CecOutBoxIndexHeader { u16 magic16; NN_PADDING2; size_t messageNum; // Message の 個数 }; /* struct CecOutBoxindex : public nn::fnd::IntrusiveLinkedList::Item { CECMessageId messageId; }; //typedef std::vector MessageId_List; // MessageId のリストの配列定義 typedef nn::fnd::IntrusiveLinkedList MessageId_List; */ /* // ボックス内のMessageのMessageIDのリスト struct CecBoxMessageList { u32 messageNum; CECMessageId messageId[CEC_OUTBOX_MESS_NUM_MAX]; }; */ /*! @brief CEC MessageBox にアクセスするためのクラスです。 */ class MessageBox { protected: u32 currentCecTitleId; bool m_Initialized; NN_PADDING3; u8* cecBoxBuf; struct MessageBoxList cecMessageBoxList; struct MessageBoxInfo cecMessageBoxInfo; struct CecBoxInfoHeader cecInboxInfo; CecMessageHeader* cecInboxInfo_body[CEC_INBOX_MESSNUM_DEFAULT]; u8* cecInboxInfoBuf; struct CecBoxInfoHeader cecOutboxInfo; CecMessageHeader* cecOutboxInfo_body[CEC_OUTBOX_MESSNUM_DEFAULT]; u8* cecOutboxInfoBuf; CecOutBoxIndexHeader cecOutboxIndex_header; //u8* cecOutboxIndex[CEC_OUTBOX_MESSNUM_DEFAULT]; CECMessageId cecOutboxIndex[CEC_OUTBOX_MESSNUM_DEFAULT]; // u8* cecOutboxIndexBuf; bool m_BoxAccessible; NN_PADDING3; public: MessageBox(bool NoInitialize = false); virtual ~MessageBox(); nn::Result Initialize(); nn::Result Finalize(); nn::Result WriteMessageBoxList(); size_t ReadMessageBoxList(); size_t ReadMessageBoxList(void* bufOut, size_t size); u32 GetMessageBoxNum(MessageBoxFlag flag); nn::Result DeleteOldestMessageBox(MessageBoxFlag flag); inline u32 GetCurrentCecTitleId() const{return currentCecTitleId;} //! @name Boxの作成/削除 //@{ /*! @brief MessageBoxを作成します。Box内に 受信BOX と 送信BOX が作成されます。
送信BOX に Message をセットすることで、すれちがい通信時にデータ送信が行われ、受信BOXに相手からのデータが保持されます。 MessageBoxは、NAND領域に作成されます。1アプリにつき、作成できるBOXは1つです。BOXの最大数は12で、これを超える場合は新規にBOXを作成することはできません。
privateId, hmacKey はアクセス可能な範囲を制限する為の値です。
privateId はBOXをOpenするために必要なキーで、1本体内に閉じられた値を想定しています。
hmacKey は同一アプリが共通して持つキーで、データの改竄・アプリの偽装を防ぐ目的にも使用されます。このキーはBOXに保持されます。
複数セーブデータ・複数アプリから同一のBOXにアクセスする必要がある場合は、適切な範囲で共通するキーを設定してください。 @param[in] cecTitleId Title固有ID @param[in] privateId BOXをOpenするために必要なキーとなります。→ @ref OpenMessageBox
BOXにアクセスするアプリが保持している値を使用する必要があります。 @param[in] hmacKey Message を読み出すときに必要なキーを指定します。32文字の文字列で指定します。 通信相手と共通のキーである必要があります。
この値は、送受信されるデータの改竄をチェックするために使用されます。送受信されるデータには、このキーを使用して生成された署名が付けられます。 アプリ内で保持している値を使用してください。 @param[in] icon アイコンを指定します。
フォーマット: RGB565 (リトルエンディアン)
サイズ: 48×48 (4.5KBytes)
@param[in] iconSize アイコンのデータサイズを指定します。 @param[in] name アプリ名称を指定します。
文字コード: UTF16-LE
表示サイズ: 全角17文字で表示できる文字数
バッファ最大: 64×2Bytes (NULL終端込み)
@param[in] nameSize アプリ名称のデータサイズを指定します。 @param[in] inboxSizeMax 受信ボックスの最大保存サイズを指定します。受信BOXと送信BOXで合わせて 1MB 以内にする必要があります。デフォルトは 512*1024 バイトです。 @param[in] outboxSizeMax 送信ボックスの最大保存サイズを指定します。受信BOXと送信BOXで合わせて 1MB 以内にする必要があります。デフォルトは 512*1024 バイトです。 @param[in] inboxMessNumMax 受信ボックスの最大保存Message数を指定します。デフォルトは 99 で、この値より多い値を指定することはできません。 @param[in] outboxMessNumMax 送信ボックスの最大保存Message数を指定します。デフォルトは 99 で、この値より多い値を指定することはできません。 @param[in] messageSizeMax Messageの最大サイズを指定します。このサイズを超えるMessageは保存できず、WriteMessage でエラーとなります。 @return nn::Result */ nn::Result CreateMessageBox( const TitleId cecTitleId, const u32 privateId, const char* hmacKey, void* icon, size_t iconSize, wchar_t* name, size_t nameSize, size_t inboxSizeMax = CEC_INBOX_SIZE_DEFAULT, size_t outboxSizeMax = CEC_OUTBOX_SIZE_DEFAULT, size_t inboxMessNumMax = CEC_INBOX_MESSNUM_DEFAULT, size_t outboxMessNumMax = CEC_OUTBOX_MESSNUM_DEFAULT, size_t messageSizeMax = CEC_MESSSIZEMAX_DEFAULT ); /*! @brief MessageBoxを作成します。Box内に 受信BOX と 送信BOX が作成されます。
(最終バージョンでは、アイコンとアプリ名称の設定が必須になります。この形式は過去のバージョンとの互換性のために残されています。) @param[in] cecTitleId Title固有ID @param[in] privateId BOXをOpenするために必要なキーとなります。→ @ref OpenMessageBox
BOXにアクセスするアプリが保持している値を使用する必要があります。 @param[in] hmacKey Message を読み出すときに必要なキーを指定します。32文字の文字列で指定します。 通信相手と共通のキーである必要があります。
この値は、送受信されるデータの改竄をチェックするために使用されます。送受信されるデータには、このキーを使用して生成された署名が付けられます。 アプリ内で保持している値を使用してください。 @param[in] inboxSizeMax 受信ボックスの最大保存サイズを指定します。受信BOXと送信BOXで合わせて 1MB 以内にする必要があります。デフォルトは 512*1024 バイトです。 @param[in] outboxSizeMax 送信ボックスの最大保存サイズを指定します。受信BOXと送信BOXで合わせて 1MB 以内にする必要があります。デフォルトは 512*1024 バイトです。 @param[in] inboxMessNumMax 受信ボックスの最大保存Message数を指定します。デフォルトは 99 で、この値より多い値を指定することはできません。 @param[in] outboxMessNumMax 送信ボックスの最大保存Message数を指定します。デフォルトは 99 で、この値より多い値を指定することはできません。 @param[in] messageSizeMax Messageの最大サイズを指定します。このサイズを超えるMessageは保存できず、WriteMessage でエラーとなります。 @return nn::Result */ nn::Result CreateMessageBox( const TitleId cecTitleId, const u32 privateId, const char* hmacKey, size_t inboxSizeMax = CEC_INBOX_SIZE_DEFAULT, size_t outboxSizeMax = CEC_OUTBOX_SIZE_DEFAULT, size_t inboxMessNumMax = CEC_INBOX_MESSNUM_DEFAULT, size_t outboxMessNumMax = CEC_OUTBOX_MESSNUM_DEFAULT, size_t messageSizeMax = CEC_MESSSIZEMAX_DEFAULT ); void CreateInBox(const TitleId cecTitleId); void CreateOutBox(const TitleId cecTitleId); /*! @brief MessageBox を削除します。 @ref OpenMessageBox で開いているBoxを削除します。
また、記憶していた通信相手のリストも消去され、同じ相手と再接続することが可能になります。このとき、設定中のボックスだけでなく、全てのボックス(アプリ)のデータが、再度交換される可能性があります。
リストの消去は、nn::cec::CTR::CecControl::StartScanning(true) で通信開始するときも行われます。 @return nn::Result */ nn::Result DeleteMessageBox(); /*! @brief MessageBox を削除します。CecTitleIdを指定して削除します。 MessageBoxをOpenできないときに強制的に削除するといった用途に使用します。別アプリのMessageBoxを削除しないでください。 @param[in] cecTitleId Title固有ID @return nn::Result */ nn::Result DeleteMessageBox(const TitleId cecTitleId); nn::Result DeleteAllBoxes(); /*! @brief MessageBox を開きます。Box内のMessageにアクセスするために、まずこの関数でBoxを開く必要があります。 @param[in] cecTitleId Title固有ID @param[in] privateId @ref CreateMessageBox でBOXを作成したときに指定した値と同じ値を指定します。 値が異なる場合はアクセスできません。 @return nn::Result */ nn::Result OpenMessageBox(const TitleId cecTitleId, const u32 privateId); bool IsOpened(); //@} /*! @brief MessageBox の 有効/無効 を指定します。無効にされているBOXのデータは送受信されません。 @param[in] active 有効: true / 無効: false @return nn::Result */ nn::Result SetBoxActivate(bool active); /*! @brief MessageBox の 有効/無効 を取得します。無効にされているBOXのデータは送受信されません。 @return 有効: true / 無効: false */ bool GetBoxActivate(); nn::Result ReadMessageBoxInfo(struct MessageBoxInfo* outbuf) const; nn::Result GetBoxInfo(struct CecBoxInfoHeader* boxinfo, CecMessageHeader** boxInfoBody, CecBoxType boxType) const ; nn::Result ReadBoxInfo(struct CecBoxInfoHeader* boxinfo, CecMessageHeader** boxInfoBody, u8* buf, CecBoxType boxType); protected: nn::Result ReadMessageBoxInfo(struct MessageBoxInfo* outbuf, TitleId cecTitleId) const; nn::Result ReadMessageBoxInfo() const; nn::Result WriteMessageBoxInfo(); nn::Result WriteBoxInfo( CecBoxType boxType ,CecBoxInfoHeader& boxInfo , CecMessageHeader** boxInfoBody); nn::Result ReadInBoxInfo(); nn::Result WriteInBoxInfo(); nn::Result ReadOutBoxInfo(); nn::Result WriteOutBoxInfo(); public: //! @name Message操作 //@{ /*! @brief Message を読み出します。 @param[out] cecMessage 読み出し先の @ref Message クラスのオブジェクト @param[out] buf Message のバイナリ列を格納するバッファ @param[in] bufLen バッファのサイズ @param[in] boxType 受信BOX/送信BOXの指定 @param[in] messageId MessageId の指定 @return nn::Result */ nn::Result ReadMessage( Message& cecMessage, void* buf, const size_t bufLen, const CecBoxType boxType, const MessageId& messageId); /*! :private @brief Message を読み出します。 @param[out] bufOut Message のバイナリ列を格納するバッファ @param[in] bufLen バッファのサイズ @param[in] boxType 受信BOX/送信BOXの指定 @param[in] messageId MessageId の指定 @return nn::Result */ nn::Result ReadMessage( void* bufOut, const size_t bufLen, const CecBoxType boxType, const MessageId& messageId); /*! @brief Message を本体保存領域に書きこみます。 Messageのサイズが 100KB を超える場合、またはBOXの最大保存容量/個数 をオーバーする場合は書き込むことができません。
@param[in] cecMessage @ref Message クラスのオブジェクト @param[in] boxType 受信BOX/送信BOXの指定 @param[out] messageIdOut 書き込むときに付与される MessageId が返ります。 @return nn::Result */ nn::Result WriteMessage( const Message& cecMessage,const CecBoxType boxType, MessageId& messageIdOut); nn::Result WriteMessage( const Message& cecMessage,const CecBoxType boxType) { MessageId messageIdOut; return WriteMessage(cecMessage, boxType, messageIdOut); } /*! :private @brief Message を本体保存領域に書きこみます。 Messageのサイズが 100KB を超える場合、またはBOXの最大保存容量/個数 をオーバーする場合は書き込むことができません。
@param[in] message Message のバイナリ列を格納するバッファ @param[in] messageLen バッファのサイズ @param[in] boxType 受信BOX/送信BOXの指定 @param[out] messageIdOut 書き込むときに付与される MessageId が返ります。 @return nn::Result */ nn::Result WriteMessage( const void* message, const size_t messageLen ,const CecBoxType boxType, MessageId& messageIdOut); /*! @brief Message を削除します。 @param[in] boxType 受信BOX/送信BOXの指定 @param[in] messageId MessageId の指定 @return nn::Result */ nn::Result DeleteMessage( const CecBoxType boxType, const MessageId& messageId); //@} protected: u8 ReadInBoxMessage(void* bufOut, const size_t messageLen, const MessageId& messageId); u8 WriteInBoxMessage(const void* message, const size_t messageLen, MessageId* pMessageIdOut); u8 WriteInBoxMessage(Message& cecMessage, MessageId* pMessageId); u8 DeleteInBoxMessage(const CECMessageId messageId); u8 ReadOutBoxMessage(void* bufOut, const size_t messageLen, const MessageId& messageId); u8 WriteOutBoxMessage(const void* message, const size_t messageLen, MessageId* pMessageIdOut); u8 WriteOutBoxMessage(Message& cecMessage, MessageId* pMessageIdOut); u8 DeleteOutBoxMessage(const MessageId& messageId); public: // Box List //! @name BOX制御・情報取得 //@{ /*! @brief MessageBox に付随するデータを取得します。 @param[in] datatype データ種別を指定します。 @ref CecBoxDataType で指定します。 @param[out] dataBuf バッファを指定します。 @param[in] dataBufSize バッファサイズを指定します。 @return nn::Result */ nn::Result GetMessageBoxData(u32 datatype, void* dataBuf, size_t dataBufSize); /*! @brief MessageBox に付随するデータサイズを取得します。 @param[in] datatype データ種別を指定します。 @ref CecBoxDataType で指定します。 @return データサイズ */ size_t GetMessageBoxDataSize(const u32 datatype); /*! @brief MessageBox に付随するデータをセットします。 @param[in] datatype データ種別を指定します。 @ref CecBoxDataType で指定します。 @param[in] data データを指定します。 @param[in] dataSize データサイズを指定します。最大長は 10KB です。 @return nn::Result */ nn::Result SetMessageBoxData(u32 datatype, const void* data, size_t dataSize); /*! @brief MessageBox の名称をセットします。 @param[in] data データを指定します。
文字コード: UTF16-LE
表示サイズ: 全角17文字で表示できる文字数
バッファ最大: 64×2Bytes (NULL終端込み)
@param[in] dataSize データサイズを指定します。 @return nn::Result */ nn::Result SetMessageBoxName(const wchar_t* data, size_t dataSize); /*! @brief MessageBox のアイコンをセットします。 @param[in] data データを指定します。
フォーマット: RGB565 (リトルエンディアン)
サイズ: 48×48 (4.5KBytes)
@param[in] dataSize データサイズを指定します。 @return nn::Result */ nn::Result SetMessageBoxIcon(const void* data, size_t dataSize); /*! @brief MessageBox の名称を取得します。 @param[out] dataBuf バッファを指定します。
文字コード: UTF16-LE
表示サイズ: 全角17文字で表示できる文字数
バッファ最大: 64×2Bytes (NULL終端込み)
@param[in] dataBufSize バッファサイズを指定します。 @return nn::Result */ nn::Result GetMessageBoxName(wchar_t* dataBuf, size_t dataBufSize); /*! @brief MessageBox のアイコンを取得します。 @param[out] dataBuf バッファを指定します。
フォーマット: RGB565 (リトルエンディアン)
サイズ: 48×48 (4.5KBytes)
@param[in] dataBufSize バッファサイズを指定します。 @return nn::Result */ nn::Result GetMessageBoxIcon(void* dataBuf, size_t dataBufSize); /*-----------------------------------------------*/ //! @name BOX情報取得 //@{ /*! @brief MessageBox の属性 を取得します。 @return @ref MessageBoxFlag */ MessageBoxFlag GetBoxFlag(); u32 GetInBoxSizeMax(); u32 GetInBoxSize(); u32 GetOutBoxSizeMax(); u32 GetOutBoxSize(); /*! @brief 送信 BOX / 受信BOX の容量を取得します。 @param[in] boxType 送信 BOX / 受信BOXの指定 @return 容量の値が返ります。(BOX作成時に指定したものと同じです。) */ u32 GetBoxSizeMax(CecBoxType boxType); /*! @brief 送信 BOX / 受信BOX の使用量を取得します。 @param[in] boxType 送信 BOX / 受信BOXの指定 @return 使用量の値が返ります。 */ u32 GetBoxSize(CecBoxType boxType); /*-----------------------------------------------*/ u32 GetInBoxMessNumMax(); u32 GetInBoxMessNum(); u32 GetOutBoxMessNumMax(); u32 GetOutBoxMessNum(); /*! @brief 送信 BOX / 受信BOX の最大 Message 数を取得します。 @param[in] boxType 送信 BOX / 受信BOXの指定 @return 個数の値が返ります。(BOX作成時に指定したものと同じです。) */ u32 GetBoxMessNumMax(CecBoxType boxType); /*! @brief 送信 BOX / 受信BOX の Message 数を取得します。 @param[in] boxType 送信 BOX / 受信BOXの指定 @return 個数の値が返ります。 */ u32 GetBoxMessNum(CecBoxType boxType); /*-----------------------------------------------*/ u32 GetInBoxGroupNumMax(); u32 GetInBoxGroupNum(); u32 GetOutBoxGroupNumMax(); u32 GetOutBoxGroupNum(); /*! @brief 送信 BOX / 受信BOX の最大 Message Group 数を取得します。 @param[in] boxType 送信 BOX / 受信BOXの指定 @return Message Group 数の値が返ります。(SetBoxGroupNumMax で指定した値です。) */ u32 GetBoxGroupNumMax(CecBoxType boxType); /*! @brief 送信 BOX / 受信BOX の Message Group 数を取得します。 @param[in] boxType 送信 BOX / 受信BOXの指定 @return Message Group 数の値が返ります。 */ u32 GetBoxGroupNum(CecBoxType boxType); /*! @brief 送信 BOX / 受信BOX の 最大 Message Group 数を指定します。
実際にこの値でGroup数が制限されることはありません。
保存可能数としての目安として、ユーザに通知(表示)するための値です。
受信BOXのサイズ(GetBoxSizeMax(CEC_BOXTYPE_INBOX)) ÷ 1Group のサイズ、
または、 受信BOX の最大 Message 数(GetBoxMessNumMax(CEC_BOXTYPE_INBOX)) ÷ 1GroupのMessage数 の値を指定するのが目安となります。 @param[in] num 最大 Group 数 @param[in] boxType 送信 BOX / 受信BOXの指定 @return nn::Result */ nn::Result SetBoxGroupNumMax(u32 num, CecBoxType boxType); nn::Result SetInBoxGroupNumMax(u32 num); nn::Result SetOutBoxGroupNumMax(u32 num); /*-----------------------------------------------*/ //u32 GetInBoxSessionNumMax(); u32 GetInBoxSessionNum(); //u32 GetOutBoxSessionNumMax(); //u32 GetOutBoxSessionNum(); /*! @brief 受信BOX の Session ID 数(=受信した回数)を取得します。 Session ID は、通信相手の検索に入る前に乱数で生成されます。
相手を発見して通信するときに、相手にその ID を渡します。
データ受信側は、相手の Session ID を 受信Message に書き込みます。
1回のすれちがい通信で受信したデータ全てに、同じSession ID が書き込まれます。
GroupIDが同じでも、Session ID が異なる場合は、別の通信で受信したデータであることがわかります。BOX内のMessageの Session 数をカウントすることで、受信した回数を知ることができます。
@param[in] boxType CecBoxType で指定します。CEC_BOXTYPE_INBOX を指定します。 @return Session ID 数の値が返ります。 */ u32 GetBoxSessionNum(CecBoxType boxType); /*-----------------------------------------------*/ //@} #if 1 // BoxInfoReader の Message情報取得部を使用する。重複するため、元々Boxクラスにあった部分を将来的に削除。 //! @name Message情報取得(旧API) //@{ u32 GetInBoxMessHeader(CecMessageHeader& messHeader, const MessageId& messageId); u32 GetInBoxMessHeaderByIndex(CecMessageHeader& messHeader, u32 messIndex); /*! @brief 受信BOXの n 番目 の Message の MessageID を取得します。 GetMessageMessId で取得できる値と同じです。 @param[in] messIndex n 番目 @return @ref CECMessageId が返ります。 */ u8* GetInBoxMessIdByIndex(u32 messIndex); u32 GetOutBoxMessHeader(CecMessageHeader& messHeader, const MessageId& messageId); u32 GetOutBoxMessHeaderByIndex(CecMessageHeader& messHeader, u32 messIndex); /*! @brief 送信BOXの n 番目 の Message の MessageID を取得します。 GetMessageMessId で取得できる値と同じです。 @param[in] messIndex n 番目(n=0が先頭を示します。) @return @ref CECMessageId が返ります。 */ u8* GetOutBoxMessIdByIndex(u32 messIndex); /*! @brief MessageID を指定して Message のサイズを取得します。 GetMessageMessSize で取得できる値と同じです。 @param[in] boxType 送信 BOX / 受信BOXの指定 @param[in] messId MessageId @return サイズの値が返ります。 */ size_t GetMessSizeByMessId(CecBoxType boxType, const MessageId& messageId); size_t GetBodySizeByMessId(CecBoxType boxType, const MessageId& messageId); //@} #endif CecMessageHeader* GetMessHeaderByMessId(const CecBoxType boxType, const MessageId& messId); CecMessageHeader* GetMessHeader(const CecBoxType boxType, const u32 messIndex); bool MessageExists(CecBoxType boxType, const MessageId& messageId); //! @name Message の情報取得 //@{ /*! * @brief BoxのMessageのサイズを取得します。 * @param[in] boxType @ref CecBoxType * @param[in] messIndex n番目のMessage * @return Messageのサイズ */ u32 GetMessageMessSize(const CecBoxType boxType, const u32 messIndex); /*! * @brief BoxのMessageの本文サイズを取得します。 * @param[in] boxType @ref CecBoxType * @param[in] messIndex n番目のMessage * @return Messageの本文サイズ */ u32 GetMessageBodySize(const CecBoxType boxType, const u32 messIndex); /*! * @brief BoxのMessageの Group ID を取得します。 * @param[in] boxType @ref CecBoxType * @param[in] messIndex n番目のMessage * @return Messageの Group ID */ u32 GetMessageGroupId(const CecBoxType boxType, const u32 messIndex); /*! * @brief 受信BoxのMessageの Session ID を取得します。(受信時に付与されるIDです) * @param[in] boxType @ref CecBoxType * @param[in] messIndex n番目のMessage * @return Messageの Session ID */ u32 GetMessageSessionId(const CecBoxType boxType, const u32 messIndex); /*! * @brief BoxのMessageの @ref CecMessageTypeFlag を取得します。 * @param[in] boxType @ref CecBoxType * @param[in] messIndex n番目のMessage * @return @ref CecMessageTypeFlag */ MessageTypeFlag GetMessageMessTypeFlag(const CecBoxType boxType, const u32 messIndex); /*! * @brief BoxのMessageの @ref SendMode を取得します。 * @param[in] boxType @ref CecBoxType * @param[in] messIndex n番目のMessage * @return @ref SendMode */ SendMode GetMessageSendMode(const CecBoxType boxType, const u32 messIndex); /*! * @brief BoxのMessageの 送信回数 を取得します。 * @param[in] boxType @ref CecBoxType * @param[in] messIndex n番目のMessage * @return 送信回数 */ u8 GetMessageSendCount(const CecBoxType boxType, const u32 messIndex); /*! * @brief BoxのMessageの 伝播回数 を取得します。 * @param[in] boxType @ref CecBoxType * @param[in] messIndex n番目のMessage * @return 伝播回数 */ u8 GetMessagePropagationCount(const CecBoxType boxType, const u32 messIndex); /*! :private * @brief BoxのMessageの 未読フラグ を取得します。 * @param[in] boxType @ref CecBoxType * @param[in] messIndex n番目のMessage * @return 未読フラグ */ bit8 GetMessageFlag_Unread(const CecBoxType boxType, const u32 messIndex); /*! :private * @brief BoxのMessageの 新着フラグ を取得します。 * @param[in] boxType @ref CecBoxType * @param[in] messIndex n番目のMessage * @return 新着フラグ */ bit8 GetMessageFlag_New(const CecBoxType boxType, const u32 messIndex); /*! * @brief BoxのMessageの Tag を取得します。 * @param[in] boxType @ref CecBoxType * @param[in] messIndex n番目のMessage * @return Tag */ bit16 GetMessageTag(const CecBoxType boxType, const u32 messIndex); /*! * @brief Boxの受信Messageの 送信日時 を取得します。 * @param[in] boxType @ref CecBoxType * @param[in] messIndex n番目のMessage * @return @ref nn::fnd::DateTimeParameters */ nn::fnd::DateTimeParameters GetMessageSendDate(const CecBoxType boxType, const u32 messIndex); /*! * @brief Boxの受信Messageの 受信日時 を取得します。 * @param[in] boxType @ref CecBoxType * @param[in] messIndex n番目のMessage * @return @ref nn::fnd::DateTimeParameters */ nn::fnd::DateTimeParameters GetMessageRecvDate(const CecBoxType boxType, const u32 messIndex); /*! * @brief BoxのMessageの 作成日時 を取得します。 * @param[in] boxType @ref CecBoxType * @param[in] messIndex n番目のMessage * @return @ref nn::fnd::DateTimeParameters */ nn::fnd::DateTimeParameters GetMessageCreateDate(const CecBoxType boxType, const u32 messIndex); /*! * @brief 交換された Message の 対になる MessageID を取得します。 通信の方式に「交換」を 指定して通信したとき、対になる 送信 Message の MessageID が、受信 Message に記録されます。 * @param[out] messId @ref MessageId * @param[in] boxType @ref CecBoxType * @param[in] messIndex n番目のMessage * @return nn::Result */ nn::Result GetMessageMessIdPair(MessageId& messId, const CecBoxType boxType, const u32 messIndex); u8* GetMessageMessIdPair(const CecBoxType boxType, const u32 messIndex); /*! * @brief BoxのMessageの MessageID を取得します。 * @param[out] messId @ref MessageId * @param[in] boxType @ref CecBoxType * @param[in] messIndex n番目のMessage * @return nn::Result */ nn::Result GetMessageMessId(MessageId& messId, const CecBoxType boxType, const u32 messIndex); u8* GetMessageMessId(const CecBoxType boxType, const u32 messIndex); /*! * @brief MessageID から、何番目のMessageであるか(messIndex)を取得します。 * @param[in] boxType @ref CecBoxType * @param[in] messId MessageId * @return messIndex */ u32 GetMessIndex(CecBoxType boxType, MessageId& messId); u32 GetMessIndex(CecBoxType boxType, u8* messId); //@} /*! :private @brief 送信BOX の Message 送信順リストの末尾に MessageID を追加します。 ( @ref WriteMessage で Message をセットした時点で自動的に追加されるので、 通常はこのAPIを使う必要はありません。) @param[in] messageId MessageID を指定します。 @return リストの MessageID 数 が返ります。 */ u32 AppendOutBoxIndex(const MessageId& messageId); /*! :private @brief 送信BOX の Message 送信順リストから MessageID を削除します。 ( Message を削除した時点で自動的にリストから削除されるので、 通常はこのAPIを使う必要はありません。) @param[in] messageId MessageID を指定します。 @return リストの MessageID 数 が返ります。 */ u32 RemoveOutBoxIndex(const MessageId& messageId); /*! @brief 送信BOX の Message 送信順リスト内で、指定した MessageID の Message を末尾に回します。 ( Message を送信した時点で自動的に順番を変更されるので、 通常はこのAPIを使う必要はありません。) @param[in] messageId MessageID を指定します。 @return リストの MessageID 数 が返ります。 */ u32 RoundOutBoxIndex(const MessageId& messageId); u32 ResetOutBoxIndex(); u32 ReadOutBoxIndex(); nn::Result WriteOutBoxIndex(); protected: //IPC virtual nn::Result OpenFile(const u32 cecTitleId, const u32 dataType, const u32 option, size_t* filesize ) const ; virtual nn::Result ReadFile(void* readBuf, size_t readBufLen, size_t* readLen) const; virtual nn::Result WriteFile(const void* writeBuf, const size_t writeBufLen) const; virtual nn::Result ReadMessageFile( u32 cecTitleId, u8 boxType, const u8* pMessId, size_t messIdLen, size_t* pReadLen, u8* pReadBuf, size_t len); virtual nn::Result ReadMessageFileWithHmac( u32 cecTitleId, u8 boxType, const u8* pMessId, size_t messIdLen, size_t* pReadLen, u8* pReadBuf, size_t len, u8* pHmac); virtual nn::Result WriteMessageFile( u32 cecTitleId, u8 boxType, u8* pMessId, size_t messIdLen, const u8* pWriteBuf, size_t len); virtual nn::Result WriteMessageFileWithHmac( u32 cecTitleId, u8 boxType, u8* pMessId, size_t messIdLen, const u8* pWriteBuf, size_t len, u8* pHmac); virtual nn::Result Delete( u32 cecTitleId, u32 dataType, u8 boxType, const u8 pMessId[], size_t messIdLen ); virtual nn::Result SetData(u32 cecTitleId, const u8* pSetBuf, size_t len, u32 option); virtual nn::Result ReadData(u8 *pReadBuf, size_t len, u32 option, const u8 optionData[], size_t optionDataLen); }; } // namespace CTR } // namespace cec } // namespace nn /* #define CEC_STATE_MFILTER_EXCHANGE (0x1) #define CEC_STATE_ID_EXCHANGE (0x2) #define CEC_STATE_LIST_EXCHANGE (0x4) */ #endif //__MESSAGE_BOX_H__