1 /*---------------------------------------------------------------------------* 2 Project: Horizon 3 File: cec_MessageBox.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: 47785 $ 14 *---------------------------------------------------------------------------*/ 15 16 #ifndef NN_CEC_CTR_CEC_MESSAGE_BOX_H_ 17 #define NN_CEC_CTR_CEC_MESSAGE_BOX_H_ 18 19 20 /* 21 CEC/ 22 | 23 +-- MessageBoxList 24 \-- Message_BOX1/ 25 | | 26 | +-- MessageBoxInfo 27 | \-- InBox/ 28 | | | 29 | | +-- InBoxInfo 30 | | +-- Message1 31 | | 32 | \-- OutBox/ 33 | | 34 | +-- OutBoxIndex 35 | +-- OutBoxInfo 36 | +-- Message2 37 | 38 \-- Message_BOX2/ 39 | 40 41 */ 42 43 #include <nn/cec/CTR/cec_Api.h> 44 #include <nn/cec/CTR/cec_Message.h> 45 46 namespace nn { 47 namespace cec { 48 namespace CTR { 49 50 static const size_t CEC_INBOX_SIZE_DEFAULT = 512 * 1024; // 51 static const size_t CEC_OUTBOX_SIZE_DEFAULT = 512 * 1024; // 52 static const u8 CEC_INBOX_MESSNUM_DEFAULT = 99; // 53 static const u8 CEC_OUTBOX_MESSNUM_DEFAULT = 99; // 54 static const size_t CEC_MESSSIZEMAX_DEFAULT = 100 * 1024; // Unused Buttons 55 56 static const size_t CEC_BOX_DATA_SIZE_MAX = 10 * 1024; 57 58 static const u8 CEC_BOXNUMMAX_APPLICATION = 12; // Maximum number of Boxes for general application 59 static const u8 CEC_BOXNUMMAX_SYSTEM = 6; // Maximum number of Boxes for system application 60 static const u8 CEC_BOXNUMMAX_SYSTEM2 = 6; // Maximum number of Boxes for system application part 2 61 static const u8 MESSAGE_BOX_NUM_MAX = (CEC_BOXNUMMAX_APPLICATION + CEC_BOXNUMMAX_SYSTEM + CEC_BOXNUMMAX_SYSTEM2); 62 63 static const u8 CEC_BOXDIR_NAMELEN_MAX = 16; 64 65 // 66 // 67 /* Please see man pages for details 68 69 70 71 */ 72 typedef bit8 MessageBoxFlag; 73 /* */ 74 static const bit8 MESSAGE_BOX_FLAG_APPLICATION = (0x1); 75 /* */ 76 static const bit8 MESSAGE_BOX_FLAG_SYSTEM = (0x2); 77 /* */ 78 static const bit8 MESSAGE_BOX_FLAG_SYSTEM2 = (0x4); 79 /* */ 80 static const bit8 MESSAGE_BOX_FLAG_HIDDEN = (0x80); 81 82 // 83 84 85 /* Please see man pages for details 86 87 88 */ 89 enum CecBoxType 90 { 91 CEC_BOXTYPE_INBOX = (0x0), // 92 CEC_BOXTYPE_OUTBOX = (0x1) // 93 }; 94 95 96 // Structures 97 static const u16 MESSAGEBOXLIST_MAGIC = 0x6868; 98 static const u32 CEC_BOX_VERSION = 0x00000001; 99 struct MessageBoxList 100 { 101 u16 magic16; 102 NN_PADDING2; 103 u32 CecBoxVersion; 104 u32 DirNum; 105 u8 DirName[MESSAGE_BOX_NUM_MAX][CEC_BOXDIR_NAMELEN_MAX]; 106 }; 107 108 //Message list for local management 109 static const u16 MESSAGEBOXINFO_MAGIC = 0x6363; 110 struct MessageBoxInfo 111 { 112 u16 magic16; 113 NN_PADDING2; 114 u32 cecTitleId; // Title specific ID 115 u32 privateId; // Specific ID assigned by application. It is the key for access. 116 MessageBoxFlag MessageBoxInfoFlag; // MessageBoxInfo flag (System, etc.) 117 bool isActive; 118 NN_PADDING2; 119 char hmacKey[MESSAGE_HMAC_KEYLEN]; // Key used when adding signature with HMAC 120 u32 MessageBoxInfoSize; // MessageBoxInfo size (bytes) 121 nn::fnd::DateTimeParameters lastOpened; // Record the time when accessed 122 u8 flag1; // Flag 1 changed when accessed Unread Flag 123 u8 flag2; // Flag 2 changed when accessed New Flag 124 u8 flag3; // Flag 3 changed when accessed 125 u8 flag4; // Flag 4 changed when accessed 126 nn::fnd::DateTimeParameters lastReceived; // Record the time when received 127 u8 reserved[16]; // reserved (name/icon, etc. are written in a different file) 128 }; 129 130 131 // In/outbox information file data structure 132 133 /* 134 File: InBoxInfo/OutBoxInfo 135 +----------------------+ 136 | CEC Box Info Header | 137 +----------------------+ -+ 138 | CEC Message Header1 | | 139 +----------------------+ | CecMessageHeader_List 140 | CEC Message Header2 | | 141 +----------------------+ | 142 | CEC Message Header3 | | 143 +----------------------+ | 144 | .......... | | 145 | | | 146 +----------------------+ -+ 147 */ 148 149 150 151 static const u16 CEC_BOXINFO_MAGIC = 0x6262; 152 struct CecBoxInfoHeader 153 { 154 u16 magic16; 155 NN_PADDING2; 156 u32 boxInfoSize; // BoxInfo size 157 u32 boxSizeMax; // MessageBox size (bytes) maximum value 158 u32 boxSize; // MessageBox size (used volume) (bytes) 159 u32 messNumMax; // Maximum number of messages that can be stored in the box 160 u32 messNum; // Number of messages stored in the box 161 u32 groupNumMax; // Maximum number of Message Groups that can be stored in the box 162 u32 messSizeMax; // Maximum size of one message 163 }; 164 static const u32 CEC_SIZEOF_BOXINFO_HEADER = (sizeof(struct CecBoxInfoHeader)); 165 166 167 // Outbox Index file (indicates send order) 168 static const u16 CEC_OUTBOXINDEX_MAGIC = 0x6767; 169 struct CecOutBoxIndexHeader 170 { 171 u16 magic16; 172 NN_PADDING2; 173 size_t messageNum; // Number of messages 174 }; 175 176 177 178 /* Please see man pages for details 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 */ 200 201 class MessageBox 202 { 203 protected: 204 u32 currentCecTitleId; 205 206 bool m_Initialized; 207 bool m_BoxAccessible; 208 209 bool b_SkippedWriteInboxInfo; 210 bool b_SkippedWriteOutboxInfo; 211 212 u8* cecBoxBuf; 213 214 struct MessageBoxList cecMessageBoxList; 215 struct MessageBoxInfo cecMessageBoxInfo; 216 217 struct CecBoxInfoHeader cecInboxInfo; 218 CecMessageHeader* cecInboxInfo_body[CEC_INBOX_MESSNUM_DEFAULT]; 219 u8* cecInboxInfoBuf; 220 struct CecBoxInfoHeader cecOutboxInfo; 221 CecMessageHeader* cecOutboxInfo_body[CEC_OUTBOX_MESSNUM_DEFAULT]; 222 u8* cecOutboxInfoBuf; 223 224 CecOutBoxIndexHeader cecOutboxIndex_header; 225 CECMessageId cecOutboxIndex[CEC_OUTBOX_MESSNUM_DEFAULT]; 226 227 static nn::os::CriticalSection m_Cs; 228 static nn::os::CriticalSection m_CsMem; 229 230 struct CecBoxInfoHeader tmp_cecInboxInfo; 231 struct CecBoxInfoHeader tmp_cecOutboxInfo; 232 233 234 public: 235 236 explicit MessageBox(bool NoInitialize = false); 237 virtual ~MessageBox(); 238 239 protected: 240 nn::Result Initialize(); 241 nn::Result Finalize(); 242 243 nn::Result WriteMessageBoxList(); 244 size_t ReadMessageBoxList(); 245 nn::Result AllocInboxInfoBodyBuf(size_t size); 246 nn::Result AllocOutboxInfoBodyBuf(size_t size); 247 nn::Result FreeInboxInfoBodyBuf(); 248 nn::Result FreeOutboxInfoBodyBuf(); 249 250 251 public: 252 u32 GetMessageBoxNum(MessageBoxFlag flag); 253 size_t ReadMessageBoxList(void* bufOut, size_t size); 254 255 /* Please see man pages for details 256 257 258 259 */ GetCurrentCecTitleId()260 inline u32 GetCurrentCecTitleId() const{return currentCecTitleId;} 261 262 263 // 264 // 265 266 /* Please see man pages for details 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 */ 336 nn::Result CreateMessageBox( 337 const TitleId cecTitleId, const u32 privateId, 338 const char* hmacKey, 339 const void* icon, size_t iconSize, 340 const wchar_t* name, size_t nameSize, 341 size_t inboxSizeMax = CEC_INBOX_SIZE_DEFAULT, 342 size_t outboxSizeMax = CEC_OUTBOX_SIZE_DEFAULT, 343 size_t inboxMessNumMax = CEC_INBOX_MESSNUM_DEFAULT, 344 size_t outboxMessNumMax = CEC_OUTBOX_MESSNUM_DEFAULT, 345 size_t size = CEC_MESSSIZEMAX_DEFAULT 346 ); 347 348 /* Please see man pages for details 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 */ 380 nn::Result CreateMessageBox( 381 const TitleId cecTitleId, const u32 privateId, 382 const char* hmacKey, 383 size_t inboxSizeMax = CEC_INBOX_SIZE_DEFAULT, 384 size_t outboxSizeMax = CEC_OUTBOX_SIZE_DEFAULT, 385 size_t inboxMessNumMax = CEC_INBOX_MESSNUM_DEFAULT, 386 size_t outboxMessNumMax = CEC_OUTBOX_MESSNUM_DEFAULT, 387 size_t messageSizeMax = CEC_MESSSIZEMAX_DEFAULT 388 ); 389 390 void CreateInBox(const TitleId cecTitleId); 391 void CreateOutBox(const TitleId cecTitleId); 392 393 /* Please see man pages for details 394 395 396 397 398 399 400 401 402 */ 403 nn::Result DeleteMessageBox(); 404 405 /* Please see man pages for details 406 407 408 409 410 411 412 413 */ 414 nn::Result DeleteMessageBox(const TitleId cecTitleId); 415 416 /* Please see man pages for details 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 */ 438 nn::Result OpenMessageBox(const TitleId cecTitleId, const u32 privateId); 439 440 441 void CloseMessageBox(bool bWithoutCommit); 442 443 /* Please see man pages for details 444 445 446 447 448 449 450 451 */ 452 void CloseMessageBox(); 453 454 /* Please see man pages for details 455 456 457 458 */ 459 bool IsOpened() const; 460 461 // 462 463 /* Please see man pages for details 464 465 466 467 468 469 470 */ SetBoxActivate(bool active)471 inline nn::Result SetBoxActivate(bool active) 472 { 473 cecMessageBoxInfo.isActive = active; 474 return WriteMessageBoxInfo(); 475 } 476 477 /* Please see man pages for details 478 479 480 */ GetBoxActivate()481 inline bool GetBoxActivate() const 482 { 483 return cecMessageBoxInfo.isActive; 484 } 485 486 /* Please see man pages for details 487 488 489 490 */ 491 nn::Result ReadMessageBoxInfo(struct MessageBoxInfo* outbuf) const; 492 493 nn::Result GetBoxInfo(struct CecBoxInfoHeader* boxinfo, CecMessageHeader** boxInfoBody, CecBoxType boxType) const ; 494 nn::Result ReadBoxInfo(struct CecBoxInfoHeader* boxinfo, CecMessageHeader** boxInfoBody, u8* buf, CecBoxType boxType); 495 496 nn::Result ReadMessageBoxInfo(struct MessageBoxInfo* outbuf, TitleId cecTitleId) const; 497 nn::Result WriteBoxInfo( CecBoxType boxType ,CecBoxInfoHeader& boxInfo , CecMessageHeader** boxInfoBody); 498 protected: 499 nn::Result ReadMessageBoxInfo() const; 500 nn::Result WriteMessageBoxInfo(); 501 502 nn::Result ReadInBoxInfo(); 503 504 nn::Result WriteInBoxInfo(); 505 nn::Result ReadOutBoxInfo(); 506 nn::Result WriteOutBoxInfo(); 507 508 509 public: 510 // 511 // 512 /* Please see man pages for details 513 514 515 516 517 518 519 520 521 522 523 524 525 */ 526 nn::Result ReadMessage( 527 Message& cecMessage, void* buf, const size_t bufLen, const CecBoxType boxType, const MessageId& messageId); 528 /* Please see man pages for details 529 530 531 532 533 534 535 536 */ 537 nn::Result ReadMessage( 538 void* bufOut, const size_t bufLen, const CecBoxType boxType, const MessageId& messageId); 539 540 /* Please see man pages for details 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 */ 566 nn::Result WriteMessage( 567 const Message& cecMessage,const CecBoxType boxType, MessageId& messageIdOut); 568 569 /* Please see man pages for details 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 */ 602 nn::Result WriteMessage( 603 const Message& cecMessage,const CecBoxType boxType, MessageId& messageIdOut, bool withWriteBoxInfo); 604 WriteMessage(const Message & cecMessage,const CecBoxType boxType)605 nn::Result WriteMessage( 606 const Message& cecMessage,const CecBoxType boxType) 607 { 608 MessageId messageIdOut; 609 return WriteMessage(cecMessage, boxType, messageIdOut); 610 } 611 612 613 /* Please see man pages for details 614 615 616 617 618 619 620 621 622 623 624 */ 625 nn::Result WriteMessage( 626 const void* message, const size_t messageLen ,const CecBoxType boxType, MessageId& messageIdOut); 627 628 /* Please see man pages for details 629 630 631 632 633 634 635 636 637 638 639 */ 640 nn::Result DeleteMessage( const CecBoxType boxType, const MessageId& messageId); 641 642 /* Please see man pages for details 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 */ 658 nn::Result DeleteMessage( const CecBoxType boxType, const MessageId& messageId, bool withWriteBoxInfo); 659 660 /* Please see man pages for details 661 662 663 664 665 666 667 668 669 670 */ 671 nn::Result DeleteAllMessages(const CecBoxType boxType); 672 673 /* Please see man pages for details 674 675 676 677 */ 678 u32 DeleteSentMessages(); 679 680 /* Please see man pages for details 681 682 683 684 685 686 687 688 689 690 691 692 693 */ 694 nn::Result CommitMessageBox(); 695 696 // 697 698 protected: 699 u8 ReadInBoxMessage(void* bufOut, const size_t messageLen, const MessageId& messageId); 700 u8 WriteInBoxMessage(const void* message, const size_t messageLen, MessageId* pMessageIdOut); 701 u8 WriteInBoxMessage(Message& cecMessage, MessageId* pMessageId); 702 u8 DeleteInBoxMessage(const CECMessageId messageId); 703 u8 ReadOutBoxMessage(void* bufOut, const size_t messageLen, const MessageId& messageId); 704 u8 WriteOutBoxMessage(const void* message, const size_t messageLen, MessageId* pMessageIdOut); 705 u8 WriteOutBoxMessage(Message& cecMessage, MessageId* pMessageIdOut); 706 u8 DeleteOutBoxMessage(const MessageId& messageId); 707 708 nn::Result CheckEulaParentalControl(); 709 710 711 public: 712 // Box List 713 714 // 715 // 716 717 /* Please see man pages for details 718 719 720 721 722 723 724 725 */ 726 nn::Result GetMessageBoxData(u32 datatype, void* dataBuf, size_t dataBufSize) const; 727 728 /* Please see man pages for details 729 730 731 732 */ 733 size_t GetMessageBoxDataSize(const u32 datatype) const; 734 735 /* Please see man pages for details 736 737 738 739 740 741 742 743 744 745 */ 746 nn::Result SetMessageBoxData(u32 datatype, const void* data, size_t dataSize); 747 748 /* Please see man pages for details 749 750 751 752 753 754 755 756 757 758 759 760 */ 761 nn::Result SetMessageBoxName(const wchar_t* data, size_t dataSize); 762 763 /* Please see man pages for details 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 */ 779 nn::Result SetMessageBoxIcon(const void* data, size_t dataSize); 780 781 /* Please see man pages for details 782 783 784 785 786 787 788 789 790 791 */ 792 nn::Result GetMessageBoxName(wchar_t* dataBuf, size_t dataBufSize) const; 793 794 /* Please see man pages for details 795 796 797 798 799 800 801 802 803 */ 804 nn::Result GetMessageBoxIcon(void* dataBuf, size_t dataBufSize) const; 805 806 807 /*-----------------------------------------------*/ 808 809 // 810 // 811 812 /* Please see man pages for details 813 814 815 816 */ GetBoxFlag()817 inline MessageBoxFlag GetBoxFlag() const 818 { 819 return cecMessageBoxInfo.MessageBoxInfoFlag; 820 } 821 822 protected: 823 // Get the number of messages in the Box GetInBoxMessNumMax()824 inline u32 GetInBoxMessNumMax() const 825 { 826 return cecInboxInfo.messNumMax; 827 } 828 GetInBoxMessNum()829 inline u32 GetInBoxMessNum() const 830 { 831 return cecInboxInfo.messNum; 832 } 833 GetOutBoxMessNumMax()834 inline u32 GetOutBoxMessNumMax() const 835 { 836 return cecOutboxInfo.messNumMax; 837 } 838 GetOutBoxMessNum()839 inline u32 GetOutBoxMessNum() const 840 { 841 return cecOutboxInfo.messNum; 842 } 843 844 845 846 // Get the BOX capacity 847 protected: GetInBoxSizeMax()848 inline u32 GetInBoxSizeMax() const 849 { 850 return cecInboxInfo.boxSizeMax; 851 } 852 GetInBoxSize()853 inline u32 GetInBoxSize() const 854 { 855 return cecInboxInfo.boxSize; 856 } GetOutBoxSizeMax()857 inline u32 GetOutBoxSizeMax() const 858 { 859 return cecOutboxInfo.boxSizeMax; 860 } 861 GetOutBoxSize()862 inline u32 GetOutBoxSize() const 863 { 864 return cecOutboxInfo.boxSize; 865 } 866 GetInBoxMessSizeMax()867 inline u32 GetInBoxMessSizeMax() const 868 { 869 return cecInboxInfo.messSizeMax; 870 } 871 GetOutBoxMessSizeMax()872 inline u32 GetOutBoxMessSizeMax() const 873 { 874 return cecOutboxInfo.messSizeMax; 875 } 876 877 public: 878 /* Please see man pages for details 879 880 881 882 */ GetBoxSizeMax(CecBoxType boxType)883 inline u32 GetBoxSizeMax(CecBoxType boxType) const 884 { 885 if(boxType == CEC_BOXTYPE_INBOX){ 886 return GetInBoxSizeMax(); 887 }else{ 888 NN_TASSERT_(boxType == CEC_BOXTYPE_OUTBOX); 889 return GetOutBoxSizeMax(); 890 } 891 } 892 893 /* Please see man pages for details 894 895 896 897 */ GetBoxSize(CecBoxType boxType)898 inline u32 GetBoxSize(CecBoxType boxType) const 899 { 900 if(boxType == CEC_BOXTYPE_INBOX){ 901 return GetInBoxSize(); 902 }else{ 903 NN_TASSERT_(boxType == CEC_BOXTYPE_OUTBOX); 904 return GetOutBoxSize(); 905 } 906 } 907 908 /* Please see man pages for details 909 910 911 912 913 */ GetBoxMessageSizeMax(CecBoxType boxType)914 inline u32 GetBoxMessageSizeMax(CecBoxType boxType) const 915 { 916 if(boxType == CEC_BOXTYPE_INBOX){ 917 return GetInBoxMessSizeMax(); 918 }else{ 919 NN_TASSERT_(boxType == CEC_BOXTYPE_OUTBOX); 920 return GetOutBoxMessSizeMax(); 921 } 922 } 923 924 925 926 /*-----------------------------------------------*/ 927 928 929 /* Please see man pages for details 930 931 932 933 934 */ GetBoxMessNumMax(CecBoxType boxType)935 inline u32 GetBoxMessNumMax(CecBoxType boxType) NN_ATTRIBUTE_DEPRECATED 936 { 937 return GetBoxMessageNumMax(boxType); 938 } 939 940 /* Please see man pages for details 941 942 943 944 */ GetBoxMessageNumMax(CecBoxType boxType)945 inline u32 GetBoxMessageNumMax(CecBoxType boxType) const 946 { 947 if(boxType == CEC_BOXTYPE_INBOX){ 948 return GetInBoxMessNumMax(); 949 }else{ 950 NN_TASSERT_(boxType == CEC_BOXTYPE_OUTBOX); 951 return GetOutBoxMessNumMax(); 952 } 953 } 954 /* Please see man pages for details 955 956 957 958 959 */ GetBoxMessNum(CecBoxType boxType)960 inline u32 GetBoxMessNum(CecBoxType boxType) NN_ATTRIBUTE_DEPRECATED 961 { 962 return GetBoxMessageNum(boxType); 963 }; 964 /* Please see man pages for details 965 966 967 968 */ GetBoxMessageNum(CecBoxType boxType)969 inline u32 GetBoxMessageNum(CecBoxType boxType) const 970 { 971 if(boxType == CEC_BOXTYPE_INBOX){ 972 return GetInBoxMessNum(); 973 }else{ 974 NN_TASSERT_(boxType == CEC_BOXTYPE_OUTBOX); 975 return GetOutBoxMessNum(); 976 } 977 } 978 979 980 /*-----------------------------------------------*/ 981 private: GetInBoxGroupNumMax()982 inline u32 GetInBoxGroupNumMax() const 983 { 984 return cecInboxInfo.groupNumMax; 985 } 986 u32 GetInBoxGroupNum() const; 987 GetOutBoxGroupNumMax()988 inline u32 GetOutBoxGroupNumMax() const 989 { 990 return cecOutboxInfo.groupNumMax; 991 } 992 993 u32 GetOutBoxGroupNum() const; 994 995 public: 996 /* Please see man pages for details 997 998 999 1000 */ GetBoxGroupNumMax(CecBoxType boxType)1001 inline u32 GetBoxGroupNumMax(CecBoxType boxType) const 1002 { 1003 if(boxType == CEC_BOXTYPE_INBOX){ 1004 return GetInBoxGroupNumMax(); 1005 }else{ 1006 NN_TASSERT_(boxType == CEC_BOXTYPE_OUTBOX); 1007 return GetOutBoxGroupNumMax(); 1008 } 1009 } 1010 1011 1012 /* Please see man pages for details 1013 1014 1015 1016 */ GetBoxGroupNum(CecBoxType boxType)1017 inline u32 GetBoxGroupNum(CecBoxType boxType) const 1018 { 1019 if(boxType == CEC_BOXTYPE_INBOX){ 1020 return GetInBoxGroupNum(); 1021 }else{ 1022 NN_TASSERT_(boxType == CEC_BOXTYPE_OUTBOX); 1023 return GetOutBoxGroupNum(); 1024 } 1025 } 1026 1027 /* Please see man pages for details 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 */ 1044 nn::Result SetBoxGroupNumMax(u32 num, CecBoxType boxType); 1045 protected: 1046 nn::Result SetInBoxGroupNumMax(u32 num); 1047 nn::Result SetOutBoxGroupNumMax(u32 num); 1048 /*-----------------------------------------------*/ 1049 1050 u32 GetInBoxSessionNum() const; 1051 1052 public: 1053 /* Please see man pages for details 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 */ GetBoxSessionNum(CecBoxType boxType)1066 inline u32 GetBoxSessionNum(CecBoxType boxType) const 1067 { 1068 if(boxType == CEC_BOXTYPE_INBOX){ 1069 return GetInBoxSessionNum(); 1070 } 1071 else 1072 { 1073 NN_TASSERT_(boxType == CEC_BOXTYPE_OUTBOX); 1074 //return GetOutBoxSessionNum(); 1075 return 0; 1076 } 1077 } 1078 1079 /*-----------------------------------------------*/ 1080 // 1081 1082 #if 1 // Use the BoxInfoReader Message information obtaining portion. Because it is duplicated, the portion originally in the Box class will be deleted in the future. 1083 // 1084 // 1085 protected: 1086 u32 GetInBoxMessHeader(CecMessageHeader& messHeader, const MessageId& messageId) const; 1087 u32 GetInBoxMessHeaderByIndex(CecMessageHeader& messHeader, u32 messIndex) const; 1088 1089 public: 1090 /* Please see man pages for details 1091 1092 1093 1094 1095 1096 1097 */ 1098 u8* GetInBoxMessIdByIndex(u32 messIndex); 1099 1100 protected: 1101 u32 GetOutBoxMessHeader(CecMessageHeader& messHeader, const MessageId& messageId) const; 1102 u32 GetOutBoxMessHeaderByIndex(CecMessageHeader& messHeader, u32 messIndex) const; 1103 public: 1104 1105 /* Please see man pages for details 1106 1107 1108 1109 1110 1111 1112 */ 1113 u8* GetOutBoxMessIdByIndex(u32 messIndex); 1114 1115 /* Please see man pages for details 1116 1117 1118 1119 1120 1121 1122 1123 */ 1124 size_t GetMessSizeByMessId(CecBoxType boxType, const MessageId& messageId) const; 1125 protected: 1126 size_t GetBodySizeByMessId(CecBoxType boxType, const MessageId& messageId) const; 1127 // 1128 #endif 1129 1130 CecMessageHeader* GetMessHeaderByMessId(const CecBoxType boxType, const MessageId& messId) const; 1131 public: 1132 /* Please see man pages for details 1133 1134 1135 1136 1137 1138 */ 1139 CecMessageHeader* GetMessHeader(const CecBoxType boxType, const u32 messIndex) const; 1140 1141 bool MessageExists(CecBoxType boxType, const MessageId& messageId) const; 1142 // 1143 // 1144 1145 public: 1146 /* Please see man pages for details 1147 1148 1149 1150 1151 1152 */ GetMessageMessSize(const CecBoxType boxType,const u32 messIndex)1153 inline u32 GetMessageMessSize(const CecBoxType boxType, const u32 messIndex) NN_ATTRIBUTE_DEPRECATED 1154 { 1155 return GetMessageSize(boxType, messIndex); 1156 } 1157 /* Please see man pages for details 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 */ 1168 u32 GetMessageSize(const CecBoxType boxType, const u32 messIndex) const; 1169 1170 /* Please see man pages for details 1171 1172 1173 1174 1175 */ 1176 u32 GetMessageBodySize(const CecBoxType boxType, const u32 messIndex) const; 1177 1178 /* Please see man pages for details 1179 1180 1181 1182 1183 1184 1185 1186 1187 */ 1188 u32 GetMessageGroupId(const CecBoxType boxType, const u32 messIndex) const; 1189 1190 /* Please see man pages for details 1191 1192 1193 1194 1195 1196 1197 1198 1199 */ 1200 u32 GetMessageSessionId(const CecBoxType boxType, const u32 messIndex) const; 1201 1202 /* Please see man pages for details 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 */ GetMessageMessTypeFlag(const CecBoxType boxType,const u32 messIndex)1213 inline MessageTypeFlag GetMessageMessTypeFlag(const CecBoxType boxType, const u32 messIndex) NN_ATTRIBUTE_DEPRECATED 1214 { 1215 return GetMessageTypeFlag(boxType, messIndex); 1216 }; 1217 /* Please see man pages for details 1218 1219 1220 1221 1222 1223 1224 1225 1226 */ 1227 MessageTypeFlag GetMessageTypeFlag(const CecBoxType boxType, const u32 messIndex) const; 1228 1229 /* Please see man pages for details 1230 1231 1232 1233 1234 1235 1236 1237 1238 */ 1239 SendMode GetMessageSendMode(const CecBoxType boxType, const u32 messIndex) const; 1240 1241 /* Please see man pages for details 1242 1243 1244 1245 1246 1247 1248 1249 1250 */ 1251 u8 GetMessageSendCount(const CecBoxType boxType, const u32 messIndex) const; 1252 1253 /* Please see man pages for details 1254 1255 1256 1257 1258 1259 1260 1261 1262 */ 1263 u8 GetMessagePropagationCount(const CecBoxType boxType, const u32 messIndex) const; 1264 1265 /* Please see man pages for details 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 */ 1276 bit8 GetMessageFlag_Unread(const CecBoxType boxType, const u32 messIndex) const; 1277 1278 /* Please see man pages for details 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 */ 1289 bit8 GetMessageFlag_New(const CecBoxType boxType, const u32 messIndex) const; 1290 1291 /* Please see man pages for details 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 */ 1304 bit16 GetMessageTag(const CecBoxType boxType, const u32 messIndex) const; 1305 1306 /* Please see man pages for details 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 */ 1317 nn::fnd::DateTimeParameters GetMessageSendDate(const CecBoxType boxType, const u32 messIndex) const; 1318 1319 /* Please see man pages for details 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 */ 1330 nn::fnd::DateTimeParameters GetMessageRecvDate(const CecBoxType boxType, const u32 messIndex) const; 1331 1332 /* Please see man pages for details 1333 1334 1335 1336 1337 1338 1339 1340 1341 */ 1342 nn::fnd::DateTimeParameters GetMessageCreateDate(const CecBoxType boxType, const u32 messIndex) const; 1343 1344 /* Please see man pages for details 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 */ GetMessageMessIdPair(MessageId * messId,const CecBoxType boxType,const u32 messIndex)1359 inline nn::Result GetMessageMessIdPair(MessageId* messId, const CecBoxType boxType, const u32 messIndex) NN_ATTRIBUTE_DEPRECATED 1360 { 1361 return GetMessageIdPair(messId, boxType, messIndex); 1362 }; 1363 /* Please see man pages for details 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 */ 1377 nn::Result GetMessageIdPair(MessageId* messId, const CecBoxType boxType, const u32 messIndex) const; 1378 1379 /* Please see man pages for details 1380 1381 1382 1383 1384 1385 1386 1387 1388 */ GetMessageMessIdPair(const CecBoxType boxType,const u32 messIndex)1389 inline MessageId GetMessageMessIdPair(const CecBoxType boxType, const u32 messIndex) NN_ATTRIBUTE_DEPRECATED 1390 { 1391 return GetMessageIdPair(boxType, messIndex); 1392 } 1393 /* Please see man pages for details 1394 1395 1396 1397 1398 1399 1400 1401 */ 1402 MessageId GetMessageIdPair(const CecBoxType boxType, const u32 messIndex) const; 1403 1404 1405 /* Please see man pages for details 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 */ GetMessageMessId(MessageId * messId,const CecBoxType boxType,const u32 messIndex)1416 inline nn::Result GetMessageMessId(MessageId* messId, const CecBoxType boxType, const u32 messIndex) NN_ATTRIBUTE_DEPRECATED 1417 { 1418 return GetMessageId(messId, boxType, messIndex); 1419 } 1420 /* Please see man pages for details 1421 1422 1423 1424 1425 1426 1427 1428 1429 */ 1430 nn::Result GetMessageId(MessageId* messId, const CecBoxType boxType, const u32 messIndex) const; 1431 1432 /* Please see man pages for details 1433 1434 1435 1436 1437 1438 */ GetMessageMessId(const CecBoxType boxType,const u32 messIndex)1439 inline MessageId GetMessageMessId(const CecBoxType boxType, const u32 messIndex) NN_ATTRIBUTE_DEPRECATED 1440 { 1441 return GetMessageId(boxType, messIndex); 1442 } 1443 /* Please see man pages for details 1444 1445 1446 1447 1448 */ 1449 MessageId GetMessageId(const CecBoxType boxType, const u32 messIndex) const; 1450 1451 1452 /* Please see man pages for details 1453 1454 1455 1456 1457 1458 */ GetMessIndex(CecBoxType boxType,MessageId & messId)1459 inline u32 GetMessIndex(CecBoxType boxType, MessageId& messId) NN_ATTRIBUTE_DEPRECATED{ 1460 return GetMessageIndex(boxType, messId); 1461 }; GetMessIndex(CecBoxType boxType,u8 * messId)1462 inline u32 GetMessIndex(CecBoxType boxType, u8* messId) NN_ATTRIBUTE_DEPRECATED{ 1463 return GetMessageIndex(boxType, messId); 1464 } 1465 1466 /* Please see man pages for details 1467 1468 1469 1470 1471 */ 1472 u32 GetMessageIndex(CecBoxType boxType, const MessageId& messId) const; 1473 u32 GetMessageIndex(CecBoxType boxType, u8* messId) const; 1474 // 1475 1476 /* Please see man pages for details 1477 1478 1479 1480 1481 1482 1483 */ 1484 u32 AppendOutBoxIndex(const MessageId& messageId); 1485 1486 /* Please see man pages for details 1487 1488 1489 1490 1491 1492 1493 */ 1494 u32 RemoveOutBoxIndex(const MessageId& messageId); 1495 1496 /* Please see man pages for details 1497 1498 1499 1500 1501 1502 1503 */ 1504 u32 RoundOutBoxIndex(const MessageId& messageId); 1505 1506 protected: 1507 /* Please see man pages for details 1508 1509 1510 */ 1511 u32 ResetOutBoxIndex(); 1512 u32 ReadOutBoxIndex(); 1513 nn::Result WriteOutBoxIndex(); 1514 1515 nn::Result IsAgreeEulaAppRequired() const; 1516 1517 protected: 1518 //IPC 1519 virtual nn::Result OpenFile(const u32 cecTitleId, const u32 dataType, const u32 option, size_t* filesize ) const; 1520 virtual nn::Result ReadFile(void* readBuf, size_t readBufLen, size_t* readLen) const; 1521 virtual nn::Result WriteFile(const void* writeBuf, const size_t writeBufLen) const; 1522 virtual nn::Result ReadMessageFile( 1523 u32 cecTitleId, 1524 u8 boxType, 1525 const u8* pMessId, 1526 size_t messIdLen, 1527 size_t* pReadLen, 1528 u8* pReadBuf, 1529 size_t len); 1530 1531 virtual nn::Result ReadMessageFileWithHmac( 1532 u32 cecTitleId, 1533 u8 boxType, 1534 const u8* pMessId, 1535 size_t messIdLen, 1536 size_t* pReadLen, 1537 u8* pReadBuf, 1538 size_t len, u8* pHmac); 1539 1540 virtual nn::Result WriteMessageFile( 1541 u32 cecTitleId, 1542 u8 boxType, 1543 u8* pMessId, 1544 size_t messIdLen, 1545 const u8* pWriteBuf, 1546 size_t len); 1547 1548 virtual nn::Result WriteMessageFileWithHmac( 1549 u32 cecTitleId, 1550 u8 boxType, 1551 u8* pMessId, 1552 size_t messIdLen, 1553 const u8* pWriteBuf, 1554 size_t len, u8* pHmac); 1555 1556 virtual nn::Result Delete( u32 cecTitleId, u32 dataType, u8 boxType, const u8 pMessId[], size_t messIdLen ); 1557 virtual nn::Result SetData(u32 cecTitleId, const u8* pSetBuf, size_t len, u32 option); 1558 virtual nn::Result ReadData(u8 *pReadBuf, size_t len, u32 option, const u8 optionData[], size_t optionDataLen) const; 1559 virtual nn::Result OpenAndWriteFile( const u8 pWriteBuf[], size_t writeBufLen, u32 cecTitleId, u32 dataType, u32 option ) const; 1560 virtual nn::Result OpenAndReadFile( u8 pReadBuf[], size_t readBufLen, size_t* pReadLen, u32 cecTitleId, u32 dataType, u32 option ) const ; 1561 1562 }; 1563 1564 } // namespace CTR 1565 } // namespace cec 1566 } // namespace nn 1567 1568 1569 #endif //NN_CEC_CTR_CEC_MESSAGE_BOX_H_ 1570 1571