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