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