1 /*---------------------------------------------------------------------------*
2   Project:  WiiConnect24 API demos
3   File:     MsgViewer.h
4 
5   Copyright 2006 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   $Log: MsgViewer.h,v $
14   Revision 1.3  2008/05/01 08:49:38  hirose_kazuki
15   Added "Close library" mode.
16 
17   Revision 1.2  2008/04/28 11:19:22  hirose_kazuki
18   Updated framework.
19 
20   Revision 1.1  2006/09/27 08:59:01  torigoe_nobutaka
21   Renamed from MessageViewer.h
22 
23   Revision 1.2  2006/09/27 07:30:27  torigoe_nobutaka
24   Added definition of MsgData structure.
25   Added GetListedSubjects() and ReleaseListedSubjects().
26   Changed value of some constants.
27 
28   Revision 1.1  2006/08/28 08:51:50  torigoe_nobutaka
29   Initial check in.
30 
31 
32   $NoKeywords: $
33  *---------------------------------------------------------------------------*/
34 
35 #ifndef __DEMOS_NWC24DEMO_MSG_VIEWER_H__
36 #define __DEMOS_NWC24DEMO_MSG_VIEWER_H__
37 
38 #include <revolution/types.h>
39 #include <revolution/nwc24/NWC24Types.h>
40 
41 #define NUM_MSG_BOX_MENUS   4
42 #define FONT_SIZE           16
43 #define LIST_BOX_ROWS       5
44 #define TEXT_BOX_ROWS       5
45 #define LEN_SUBJECT_DISP    32
46 
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50 /*===========================================================================*/
51 
52 /*---------------------------------------------------------------------------*
53    Type definitions
54  *---------------------------------------------------------------------------*/
55 /* Menu Items */
56 typedef enum    MsgBoxMenu
57 {
58     MB_MENU_RECV_BOX,           // Inbox
59     MB_MENU_SEND_BOX,           // Outbox
60     MB_MENU_RECV_MSG,           // Receive message
61     MB_MENU_POST_MSG            // Send message
62 } MsgBoxMenu;
63 
64 /* Type of message box */
65 #define NUM_MSG_BOX_TYPES   2
66 typedef enum    MsgBoxType
67 {
68     MB_TYPE_RECV    = 0,        // Inbox
69     MB_TYPE_SEND    = 1         // Outbox
70 } MsgBoxType;
71 
72 /* Application status */
73 typedef enum    MsgBoxState
74 {
75     MB_STATE_MENU,              // Menu selection
76     MB_STATE_RECV_BOX,          // Select received message
77     MB_STATE_SEND_BOX,          // Select sent message
78     MB_STATE_MSG_CONTENT,       // View message contents
79     MB_STATE_DELETE_MSG,        // Delete message
80     MB_STATE_BEFORE_RECV_MSG,   // Before receiving message
81     MB_STATE_BEFORE_POST_MSG,   // Before sending message
82     MB_STATE_DONE_RECV_MSG,     // After receiving message
83     MB_STATE_DONE_POST_MSG,     // After sending message
84     MB_STATE_LIB_CLOSED,        // The library is closed
85     MB_STATE_WAIT_OPEN,         // Waiting for the library to open
86     MB_STATE_ERROR_CONT,        // Error display (continuous)
87     MB_STATE_ERROR_STOP         // error display
88 } MsgBoxState;
89 
90 #define MAX_ADDR_SIZE       NWC24MSG_MAX_ADDRSTR
91 #define MAX_NUM_TO          NWC24MSG_MAX_TO
92 #define MAX_SUBJECT_SIZE    256
93 #define MAX_TEXT_SIZE       4096
94 typedef struct  MsgData
95 {
96     NWC24MsgType    type;
97     char            from[MAX_ADDR_SIZE];
98     u32             numTo;
99     char            to[MAX_NUM_TO][MAX_ADDR_SIZE];
100     char            subject[MAX_SUBJECT_SIZE];
101     char            text[NWC24MSG_MAX_BODYSIZE];
102 } MsgData;
103 
104 /*---------------------------------------------------------------------------*
105    External constants
106  *---------------------------------------------------------------------------*/
107 extern const GXColor    CLR_DARKBLUE;
108 extern const GXColor    CLR_WHITE;
109 extern const char*      HIDDEN_MESSAGE;
110 extern const char*      BROKEN_MESSAGE;
111 
112 /*---------------------------------------------------------------------------*
113    External variables
114  *---------------------------------------------------------------------------*/
115 extern s16              g_screenWidth;
116 extern s16              g_screenHeight;
117 extern OSFontHeader*    g_fontData;
118 extern MsgBoxState      g_state;
119 extern MsgBoxMenu       g_selectedMenu;
120 extern u32*             g_idListBuf[NUM_MSG_BOX_TYPES];
121 extern u32              g_numMsgs[NUM_MSG_BOX_TYPES];
122 extern u32              g_idxSelectedId[];
123 extern u32              g_idxIdTopOfList[];
124 extern u32              g_lineTopOfBodyText;
125 extern u32              g_numLinesBodyText;
126 extern char*            g_subjectBuf[NUM_MSG_BOX_TYPES][LIST_BOX_ROWS];
127 extern u32              g_idxSubjectBufStart[NUM_MSG_BOX_TYPES];
128 extern MsgData          g_msgData;
129 extern s32              g_errorCode;
130 
131 /*---------------------------------------------------------------------------*
132    Function prototypes
133  *---------------------------------------------------------------------------*/
134 void    CheckError           ( const char* strFunc, NWC24Err err );
135 void    GetMsgIdList         ( NWC24MsgBoxId mBoxId );
136 void    ReleaseMsgIdList     ( NWC24MsgBoxId mBoxId );
137 BOOL    ReadSubject          ( char* buf, u32 size, NWC24MsgBoxId mBoxId, u32 msgId );
138 void    GetListedSubjects    ( NWC24MsgBoxId mBoxId );
139 void    ReleaseListedSubjects( NWC24MsgBoxId mBoxId );
140 BOOL    OpenLib              ( void );
141 BOOL    CloseLib             ( void );
142 
143 /*===========================================================================*/
144 #ifdef __cplusplus
145 }
146 #endif
147 #endif  /* __DEMOS_NWC24DEMO_MSG_VIEWER_H__ */
148 
149 /*======== End of MsgViewer.h ========*/
150