1 /*---------------------------------------------------------------------------* 2 Project: Horizon 3 File: cec_MessageBoxInfoReader.h 4 5 Copyright (C)2009-2012 Nintendo Co., Ltd. All rights reserved. 6 7 These coded instructions, statements, and computer programs contain 8 proprietary information of Nintendo of America Inc. and/or Nintendo 9 Company Ltd., and are protected by Federal copyright law. They may 10 not be disclosed to third parties or copied or duplicated in any form, 11 in whole or in part, without the prior written consent of Nintendo. 12 13 $Rev: 46347 $ 14 *---------------------------------------------------------------------------*/ 15 16 #ifndef NN_CEC_CTR_CEC_MESSAGE_BOX_INFO_READER_H_ 17 #define NN_CEC_CTR_CEC_MESSAGE_BOX_INFO_READER_H_ 18 19 #include <nn/cec/CTR/cec_Message.h> 20 #include <nn/cec/CTR/cec_MessageBox.h> 21 22 /* 23 CEC/ 24 | 25 +-- MessageBoxList 26 \-- Message_BOX1/ 27 | | 28 | +-- MessageBoxInfo 29 | \-- InBox/ 30 | | | 31 | | +-- InBoxInfo 32 | | +-- Message1 33 | | 34 | \-- OutBox/ 35 | | 36 | +-- OutBoxIndex 37 | +-- OutBoxInfo 38 | +-- Message2 39 | 40 \-- Message_BOX2/ 41 | 42 43 ------------------------------------ 44 45 struct MessageBoxInfo 46 { 47 u16 magic16; 48 NN_PADDING2; 49 u32 cecTitleId; // Unique Title ID 50 u32 privateId; // Unique ID assigned by application. Used to make the key for access. 51 MessageBoxFlag MessageBoxInfoFlag; // MessageBoxInfo flag (System etc.) 52 NN_PADDING3; 53 char hmacKey[MESSAGE_HMAC_KEYLEN]; // Key used to sign using HMAC 54 u32 MessageBoxInfoSize; // MessageBoxInfo size (in bytes) 55 nn::fnd::DateTimeParameters lastOpened; // Records time of access 56 u8 reserved[256]; // reserved (name, icon etc. are written to a different file) 57 }; 58 59 ------------------------------------ 60 61 File: InBoxInfo/OutBoxInfo 62 +----------------------+ 63 | CEC Box Info Header | 64 +----------------------+ -+ 65 | CEC Message Header1 | | 66 +----------------------+ | CecMessageHeader_List 67 | CEC Message Header2 | | 68 +----------------------+ | 69 | CEC Message Header3 | | 70 +----------------------+ | 71 | .......... | | 72 | | | 73 +----------------------+ -+ 74 75 struct CecBoxInfoHeader 76 { 77 u16 magic16; 78 NN_PADDING2; 79 u32 boxInfoSize; // BoxInfo size 80 u32 boxSizeMax; // Maximum MessageBox size (in bytes) 81 u32 boxSize; // MessageBox size (amount used) (in bytes) 82 u32 messNumMax; // Maximum number of messages that can be stored in the box 83 u32 messNum; // Number of messages stored in the box 84 u32 groupNumMax; // Maximum number of message groups that can be stored in the box 85 u32 messSizeMax; // Max size of one message 86 }; 87 88 */ 89 90 91 namespace nn { 92 namespace cec { 93 namespace CTR { 94 95 /* Please see man pages for details 96 97 98 99 100 101 102 103 104 */ 105 class MessageBoxInfoReader 106 { 107 private: 108 109 u32 m_currentCecTitleId; 110 struct MessageBoxInfo m_cecMessageboxInfo; 111 struct CecBoxInfoHeader m_cecInboxInfo; 112 CecMessageHeader* m_cecInboxInfo_body[CEC_INBOX_MESSNUM_DEFAULT]; 113 struct CecBoxInfoHeader m_cecOutboxInfo; 114 CecMessageHeader* m_cecOutboxInfo_body[CEC_OUTBOX_MESSNUM_DEFAULT]; 115 116 public: 117 // 118 // 119 /* Please see man pages for details 120 121 122 123 124 */ 125 explicit MessageBoxInfoReader(const MessageBox& cecMessBox); 126 MessageBoxInfoReader(); 127 ~MessageBoxInfoReader(); 128 129 /* Please see man pages for details 130 131 132 133 134 */ 135 nn::Result LoadMessageBoxInfo(const MessageBox& cecMessBox); 136 // 137 138 // 139 // 140 /* Please see man pages for details 141 142 143 144 */ 145 MessageBoxFlag GetMessageBoxInfoFlag(); 146 147 /* Please see man pages for details 148 149 150 151 */ 152 u32 GetBoxSizeMax(CecBoxType boxType); 153 154 /* Please see man pages for details 155 156 157 158 */ 159 u32 GetBoxSize(CecBoxType boxType); 160 161 /* Please see man pages for details 162 163 164 165 */ 166 u32 GetMessNumMax(CecBoxType boxType); 167 168 /* Please see man pages for details 169 170 171 172 */ 173 u32 GetMessNum(CecBoxType boxType); 174 175 u32 GetGroupNumMax(CecBoxType boxType); 176 // 177 178 CecMessageHeader* GetCecMessageHeader(CecBoxType boxType, u32 messIndex); 179 180 181 182 // 183 // 184 185 /* Please see man pages for details 186 187 188 189 190 */ 191 u32 GetMessageMessSize(CecBoxType boxType, u32 messIndex); 192 193 /* Please see man pages for details 194 195 196 197 198 */ 199 u32 GetMessageBodySize(CecBoxType boxType, u32 messIndex); 200 201 /* Please see man pages for details 202 203 204 205 206 */ 207 u32 GetMessageGroupId(CecBoxType boxType, u32 messIndex); 208 209 /* Please see man pages for details 210 211 212 213 214 */ 215 u32 GetMessageSessionId(CecBoxType boxType, u32 messIndex); 216 217 /* Please see man pages for details 218 219 220 221 222 */ 223 u8 GetMessageMessTypeFlag(CecBoxType boxType, u32 messIndex); 224 225 /* Please see man pages for details 226 227 228 229 230 */ 231 u8 GetMessageSendMode(CecBoxType boxType, u32 messIndex); 232 233 /* Please see man pages for details 234 235 236 237 238 */ 239 u8 GetMessageSendCount(CecBoxType boxType, u32 messIndex); 240 241 /* Please see man pages for details 242 243 244 245 246 */ 247 u8 GetMessagePropagationCount(CecBoxType boxType, u32 messIndex); 248 249 /* Please see man pages for details 250 251 252 253 254 */ 255 bit8 GetMessageFlag_Unread(CecBoxType boxType, u32 messIndex); 256 257 /* Please see man pages for details 258 259 260 261 262 */ 263 bit8 GetMessageFlag_New(CecBoxType boxType, u32 messIndex); 264 265 /* Please see man pages for details 266 267 268 269 270 */ 271 bit16 GetMessageTag(CecBoxType boxType, u32 messIndex); 272 273 /* Please see man pages for details 274 275 276 277 278 */ 279 nn::fnd::DateTimeParameters GetMessageSendDate(CecBoxType boxType, u32 messIndex); 280 281 /* Please see man pages for details 282 283 284 285 286 */ 287 nn::fnd::DateTimeParameters GetMessageRecvDate(CecBoxType boxType, u32 messIndex); 288 289 /* Please see man pages for details 290 291 292 293 294 */ 295 nn::fnd::DateTimeParameters GetMessageCreateDate(CecBoxType boxType, u32 messIndex); 296 297 /* Please see man pages for details 298 299 300 301 302 303 304 305 */ 306 u8* GetMessageMessIdPair(CecBoxType boxType, u32 messIndex); 307 308 309 /* Please see man pages for details 310 311 312 313 314 */ 315 u8* GetMessageMessId(CecBoxType boxType, u32 messIndex); 316 317 318 /* Please see man pages for details 319 320 321 322 323 */ 324 u32 GetMessIndex(CecBoxType boxType, const MessageId& messageId); 325 // 326 327 }; 328 329 330 } // namespace CTR 331 } // namespace cec 332 } // namespace nn 333 334 335 #endif //NN_CEC_CTR_CEC_MESSAGE_BOX_INFO_READER_H_ 336 337