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