1 /*---------------------------------------------------------------------------*
2   Project:  WiiConnect24
3   File:     NWC24Msg.h
4 
5   Copyright (C) 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: NWC24Msg.h,v $
14   Revision 1.61  2008/05/01 10:53:09  hirose_kazuki
15   Added NWC24SetSearchCondGroupId().
16 
17   Revision 1.60  2008/04/30 09:57:49  hirose_kazuki
18   Added NWC24CheckUserIdRegion().
19 
20   Revision 1.59  2008/03/07 01:18:08  hirose_kazuki
21   Added NWC24_USE_STANDBY.
22 
23   Revision 1.58  2007/11/16 08:17:08  hirose_kazuki
24   Fixed argument names.
25 
26   Revision 1.57  2007/11/16 08:06:27  hirose_kazuki
27   Added NWC24CheckMsgBoxSpace().
28 
29   Revision 1.56  2007/11/05 11:11:28  hirose_kazuki
30   Added definition of NWC24MSG_MAX_DESIG_TIME.
31 
32   Revision 1.55  2007/09/03 02:51:30  seiki_masashi
33   Added NWC24SetSearchCondPublic().
34 
35   Revision 1.54  2007/07/12 12:02:01  hirose_kazuki
36   Changed NWC24SetSearchCondTag() to use NWC24SearchCompareMode
37   as second argument type.
38 
39   Revision 1.53  2007/07/12 11:02:26  hirose_kazuki
40   Removed some functions.
41 
42   Revision 1.52  2007/06/26 12:12:14  seiki_masashi
43   Added NWC24Get/SetMsgSequenceNumber.
44 
45   Revision 1.51  2007/06/25 04:11:32  adachi_hiroaki
46   Changed order of arguments in NWC24GetMsgExecScript()/NWC24SetMsgExecScript().
47 
48   Revision 1.50  2007/06/21 09:58:42  adachi_hiroaki
49   Changed NWC24SetMsgExecScript()/NWC24GetMsgExecScript() to support TTL management.
50 
51   Revision 1.49  2007/06/20 23:54:35  seiki_masashi
52   Changed the vf file names related to automatic replies
53 
54   Revision 1.48  2007/06/16 09:50:26  hirose_kazuki
55   Added NWC24SetSearchCondTag().
56 
57   Revision 1.47  2007/05/30 07:34:30  adachi_hiroaki
58   Added NWC24_SCRIPT_STORAGE_PATH.
59 
60   Revision 1.46  2007/05/29 08:04:33  hirose_kazuki
61   Minor fix.
62 
63   Revision 1.45  2007/05/22 11:49:21  hatamoto_minoru
64   Added NWC24GetMsgExecScript
65 
66   Revision 1.44  2007/05/18 10:53:02  hatamoto_minoru
67   Added NWC24GetScriptVfPath and NWC24_SCRIPT_BINARY_PATH.
68 
69   Revision 1.43  2007/05/18 08:20:03  hatamoto_minoru
70   Added NWC24SetMsgExecScript.
71 
72   Revision 1.42  2007/04/26 08:03:24  adachi_hiroaki
73   Added NWC24SetMsgDesignatedTime().
74 
75   Revision 1.41  2007/04/02 11:51:10  hirose_kazuki
76   Added NWC24MsgIconNewSign().
77 
78   Revision 1.40  2007/02/05 02:11:29  yoshioka_yasuhiro
79   Added NWC24SetMsgSubjectAndTextPublic.
80 
81   Revision 1.39  2007/01/30 00:42:22  hirose_kazuki
82   Added NWC24GetMsgSize().
83 
84   Revision 1.38  2007/01/25 06:43:28  hirose_kazuki
85   Added NWC24_BASE64_ENCODED_SIZE macro.
86 
87   Revision 1.37  2007/01/15 08:15:10  hirose_kazuki
88   Added NWC24GetMsgTextPtr() and NWC24GetMsgAttachedPtr().
89 
90   Revision 1.36  2006/12/05 02:13:12  hirose_kazuki
91   Added NWC24EnableLedNotification().
92 
93   Revision 1.35  2006/11/04 12:21:05  hirose_kazuki
94   Added NWC24SetMsgLedPattern().
95 
96   Revision 1.34  2006/10/30 10:05:25  seiki_masashi
97   Fixed header file error.
98 
99   Revision 1.33  2006/10/30 09:17:03  seiki_masashi
100   Small fix
101 
102   Revision 1.32  2006/10/29 17:31:54  seiki_masashi
103   Added NWC24MSG_AUTO_ENC_CONVERT.
104 
105   Revision 1.31  2006/10/23 12:22:01  hirose_kazuki
106   Set NWC24_WORK_MEM_SIZE back to 16KB.
107 
108   Revision 1.30  2006/10/19 06:28:43  hirose_kazuki
109   Added NWC24ReadMsgTextEx().
110 
111   Revision 1.29  2006/10/19 04:36:30  hirose_kazuki
112   Changed argument type of NWC24Check(). Added NWC24GetErrorCode().
113 
114   Revision 1.28  2006/10/16 08:22:28  hirose_kazuki
115   Added NWC24Check().
116 
117   Revision 1.27  2006/09/23 09:34:25  hirose_kazuki
118   Removed NWC24InitFiles().
119 
120   Revision 1.26  2006/09/22 09:03:21  hirose_kazuki
121   Added definition of NWC24MSG_MAX_ALTNAME_LEN.
122 
123   Revision 1.25  2006/09/20 12:57:11  hirose_kazuki
124   Deleted NWC24InitMsgBox(), added NWC24InitFiles().
125 
126   Revision 1.24  2006/09/20 07:10:22  adachi_hiroaki
127   Changed NWC24_WORK_MEM_SIZE for download APIs.
128 
129   Revision 1.23  2006/09/19 01:20:01  hirose_kazuki
130   Moved message board related APIs to "NWC24MsgBoard.h".
131 
132   Revision 1.22  2006/09/18 11:45:14  hirose_kazuki
133   Added NWC24[Set|Read]MsgMBRegDate().
134 
135   Revision 1.21  2006/09/13 13:22:18  hirose_kazuki
136   Added NWC24[Set|Read]MsgMBNoReply().
137 
138   Revision 1.20  2006/09/12 11:53:26  hirose_kazuki
139   Added NWC24IsNewMsgForMenuArrived().
140 
141   Revision 1.19  2006/09/10 08:37:28  hirose_kazuki
142   Added NWC24GetMsgGroupId().
143 
144   Revision 1.18  2006/09/10 02:33:37  hirose_kazuki
145   Changed NWC24OpenMsgLib to NWC24OpenLib. NWC24CloseLib as well.
146   Old functions still exist for compatibility.
147 
148   Revision 1.17  2006/09/04 06:40:36  adachi_hiroaki
149   Added NWC24CheckUserId().
150 
151   Revision 1.16  2006/09/02 12:09:02  hirose_kazuki
152   Added NWC24Msg[Get|Read]AltName(). Changed maximum size values.
153 
154   Revision 1.15  2006/08/30 04:48:09  hirose_kazuki
155   Added SetMsgTag/GetMsgTag APIs and GetMsgId API.
156 
157   Revision 1.14  2006/08/19 08:45:43  hirose_kazuki
158   Added initial version of search APIs.
159 
160   Revision 1.13  2006/08/16 06:08:07  hirose_kazuki
161   Added NWC24CheckSendBoxVacancy().
162 
163   Revision 1.12  2006/08/09 02:22:48  hirose_kazuki
164   Added const qualifier to input string pointers.
165 
166   Revision 1.11  2006/08/08 04:51:46  hirose_kazuki
167   Added NWC24GetMsgDate().
168 
169   Revision 1.10  2006/08/07 06:42:57  hirose_kazuki
170   Moved type definitions to NWC24Types.h.
171 
172   Revision 1.9  2006/07/31 02:51:53  hirose_kazuki
173   Fixed misleading argument names.
174 
175   Revision 1.8  2006/07/26 04:25:47  adachi_hiroaki
176   Fixed types.h.
177 
178   Revision 1.7  2006/07/18 04:13:04  hirose_kazuki
179   Fixed a compile error on #endif.
180 
181   Revision 1.6  2006/07/18 02:17:23  hirose_kazuki
182   Deleted NWC24SetMsgCharset().
183 
184   Revision 1.5  2006/07/15 00:37:53  hirose_kazuki
185   Added new values for NWC24MsgType.
186 
187   Revision 1.4  2006/07/13 12:40:38  hirose_kazuki
188   Changed enum value definitions. Major API spec changes for alpha3.
189 
190   Revision 1.3  2006/07/12 00:56:50  hirose_kazuki
191   Moved NWC24InitMsgBox() from the admin header.
192   Changed max number of 'To:' to 8.
193   Changed size of NWC24MsgObj (now 256Bytes).
194 
195   Revision 1.2  2006/07/11 04:32:16  hirose_kazuki
196   Yet another repository reforming.
197 
198   Revision 1.2  2006/07/06 11:02:07  hirose_kazuki
199   Added NWC24ReadMsgToAddr(),
200   renamed NWC24ReadMsgFrom() to NWC24ReadMsgFromAddr().
201 
202   Revision 1.1  2006/07/03 03:23:31  yosizaki
203   Moved from ../ppc
204 
205   Revision 1.1  2006/06/29 12:43:43  hirose_kazuki
206   Moved from another repository.
207 
208   Revision 1.2  2006/06/12 07:29:40  hirose
209   Added NWC24GetMsgNumTo() and NWC24GetMsgToId().
210 
211   Revision 1.1  2006/06/10 10:34:21  hirose
212   Initial check in.
213 
214  *---------------------------------------------------------------------------*/
215 
216 /*---------------------------------------------------------------------------*
217     NWC24 Message API
218  *---------------------------------------------------------------------------*/
219 #ifndef __NWC24MSG_H__
220 #define __NWC24MSG_H__
221 
222 #include <revolution/nwc24/NWC24Types.h>
223 
224 #ifdef RVL_OS
225 #include <revolution/enc.h>
226 #endif // RVL_OS
227 
228 /*---------------------------------------------------------------------------*
229     Macros
230  *---------------------------------------------------------------------------*/
231 
232 #define NWC24MSG_MAX_TO             8
233 #define NWC24MSG_MAX_ATTACH         2
234 #define NWC24MSG_MAX_ADDRSTR        256
235 
236 #define NWC24MSG_MAX_ALTNAME_LEN    (34+1)
237 
238 #define NWC24MSG_MAX_DATASIZE       148912
239 #define NWC24MSG_MAX_BODYSIZE       203776
240 
241 #define NWC24_WORK_MEM_SIZE         16384
242 
243 #define NWC24_USE_MESSAGES          0x00000001
244 #define NWC24_USE_DOWNLOADS         0x00000002
245 #define NWC24_USE_SETTINGS          0x00000004
246 #define NWC24_USE_STANDBY           0x00000008
247 
248 #define NWC24MSG_MAX_DESIG_TIME     (60*24*10)
249 
250 #ifdef ENC_CHECK_NOT_FOUND // new ENC library
251 #define NWC24MSG_AUTO_ENC_CONVERT   1
252 #endif
253 
254 #define NWC24_BASE64_ENCODED_SIZE(rawSize)  \
255     (((rawSize*4+2)/3)+((rawSize/57)*2)+4)
256 
257 /*---------------------------------------------------------------------------*
258     API Prototypes
259  *---------------------------------------------------------------------------*/
260 struct OSCalendarTime;
261 
262 #ifdef __cplusplus
263 extern "C" {
264 #endif
265 
266 /*---------------------------------------------------------------------------*
267     Management APIs
268  *---------------------------------------------------------------------------*/
269 int      NWC24IsNewMsgArrived( void );
270 int      NWC24IsNewMsgForMenuArrived( void );
271 
272 /*---------------------------------------------------------------------------*/
273 NWC24Err NWC24OpenLib( void* workMemory );
274 NWC24Err NWC24CloseLib( void );
275 
276 NWC24Err NWC24Check( u32 usageType );
277 s32      NWC24GetErrorCode( void );
278 
279 NWC24Err NWC24GetMyUserId( NWC24UserId *userId );
280 NWC24Err NWC24CheckUserId( NWC24UserId userId );
281 NWC24Err NWC24CheckUserIdRegion( NWC24UserId userId );
282 
283 NWC24Err NWC24EnableLedNotification( BOOL enable );
284 
285 
286 /*---------------------------------------------------------------------------*/
287 /* For compatibility with Alpha version. Not recommended for use. */
288 NWC24Err NWC24OpenMsgLib( void* workMemory );
289 NWC24Err NWC24CloseMsgLib( void );
290 
291 /*---------------------------------------------------------------------------*/
292 
293 /*---------------------------------------------------------------------------*
294     Message creation APIs
295  *---------------------------------------------------------------------------*/
296 NWC24Err NWC24InitMsgObj    ( NWC24MsgObj* obj, NWC24MsgType type );
297 
298 /*---------------------------------------------------------------------------*/
299 
300 NWC24Err NWC24SetMsgToId        ( NWC24MsgObj* obj, NWC24UserId userId );
301 NWC24Err NWC24SetMsgToAddr      ( NWC24MsgObj* obj, const char* addr, u32 length );
302 
303 NWC24Err NWC24SetMsgSubject     ( NWC24MsgObj* obj, const char* subject, u32 size );
304 #ifdef NWC24MSG_AUTO_ENC_CONVERT
305 NWC24Err NWC24SetMsgSubjectPublic( NWC24MsgObj* obj, const u16* subject, u32 length,
306                                   NWC24AutoEncodingType autoEnc, u16 altChar,
307                                   u8* work, u32 workSize );
308 #endif
309 NWC24Err NWC24SetMsgText        ( NWC24MsgObj* obj, const char* text, u32 size,
310                                   NWC24Charset charset, NWC24Encoding encoding );
311 #ifdef NWC24MSG_AUTO_ENC_CONVERT
312 NWC24Err NWC24SetMsgTextPublic  ( NWC24MsgObj* obj, const u16* text, u32 length,
313                                   NWC24AutoEncodingType autoEnc, u16 altChar,
314                                   u8* work, u32 workSize );
315 NWC24Err NWC24SetMsgSubjectAndTextPublic( NWC24MsgObj* obj,
316                                           const u16* subject, u32 subjLen,
317                                           const u16* text, u32 textLen,
318                                           NWC24AutoEncodingType autoEnc, u16 altChar,
319                                           u8* work, u32 workSize );
320 #endif
321 NWC24Err NWC24SetMsgAttached        ( NWC24MsgObj* obj, const char* data, u32 size, NWC24MIMEType type );
322 
323 NWC24Err NWC24SetMsgAltName         ( NWC24MsgObj* obj, const u16* name, u32 length );
324 NWC24Err NWC24SetMsgTag             ( NWC24MsgObj* obj, u16 tag );
325 NWC24Err NWC24SetMsgLedPattern      ( NWC24MsgObj* obj, u16 pattern );
326 NWC24Err NWC24SetMsgIconNewSign     ( NWC24MsgObj* obj, BOOL enable );
327 NWC24Err NWC24SetMsgDesignatedTime  ( NWC24MsgObj* obj, s32 elapsedTime );
328 
329 /*---------------------------------------------------------------------------*
330     Message read APIs
331  *---------------------------------------------------------------------------*/
332 NWC24Err NWC24GetMsgType        ( const NWC24MsgObj* obj, NWC24MsgType* type );
333 NWC24Err NWC24GetMsgSize        ( const NWC24MsgObj* obj, u32* size );
334 NWC24Err NWC24GetMsgFromId      ( const NWC24MsgObj* obj, NWC24UserId* userId );
335 NWC24Err NWC24GetMsgNumTo       ( const NWC24MsgObj* obj, u32* numTo );
336 NWC24Err NWC24GetMsgSubjectSize ( const NWC24MsgObj* obj, u32* size );
337 NWC24Err NWC24GetMsgTextSize    ( const NWC24MsgObj* obj, u32* size );
338 NWC24Err NWC24GetMsgNumAttached ( const NWC24MsgObj* obj, u32* numAttached );
339 NWC24Err NWC24GetMsgAttachedSize( const NWC24MsgObj* obj, u32 index, u32* size );
340 NWC24Err NWC24GetMsgAttachedType( const NWC24MsgObj* obj, u32 index, NWC24MIMEType* type );
341 NWC24Err NWC24GetMsgDate        ( const NWC24MsgObj* obj, struct OSCalendarTime* cTime );
342 NWC24Err NWC24GetMsgTag         ( const NWC24MsgObj* obj, u16* tag );
343 
344 NWC24Err NWC24GetMsgTextPtr     ( const NWC24MsgObj* obj, const char** text );
345 NWC24Err NWC24GetMsgAttachedPtr ( const NWC24MsgObj* obj, u32 index, const char** data );
346 
347 NWC24Err NWC24GetMsgId          ( const NWC24MsgObj* obj, u32* msgId );
348 NWC24Err NWC24GetMsgAppId       ( const NWC24MsgObj* obj, u32* appId );
349 NWC24Err NWC24GetMsgGroupId     ( const NWC24MsgObj* obj, u16* groupId );
350 
351 /*---------------------------------------------------------------------------*/
352 
353 NWC24Err NWC24ReadMsgFromAddr   ( const NWC24MsgObj* obj, char* buffer, u32 bufSize );
354 NWC24Err NWC24ReadMsgToId       ( const NWC24MsgObj* obj, u32 index, NWC24UserId* userId );
355 NWC24Err NWC24ReadMsgToAddr     ( const NWC24MsgObj* obj, u32 index, char* buffer, u32 bufSize );
356 NWC24Err NWC24ReadMsgSubject    ( const NWC24MsgObj* obj, char* buffer, u32 bufSize );
357 #ifdef NWC24MSG_AUTO_ENC_CONVERT
358 NWC24Err NWC24ReadMsgSubjectPublic( const NWC24MsgObj* obj, u16* subject, u32* length,
359                                    NWC24AutoEncodingType autoEnc, u16 altChar,
360                                    u8* work, u32 workSize );
361 #endif
362 NWC24Err NWC24ReadMsgText       ( const NWC24MsgObj* obj, char* buffer, u32 bufSize,
363                                   NWC24Charset* charset, NWC24Encoding* encoding );
364 NWC24Err NWC24ReadMsgTextEx     ( const NWC24MsgObj* obj, char* buffer, u32 bufSize,
365                                   char* csNameBuf, u32 csNameSize );
366 #ifdef NWC24MSG_AUTO_ENC_CONVERT
367 NWC24Err NWC24ReadMsgTextPublic ( const NWC24MsgObj* obj, u16* text, u32* length,
368                                   NWC24AutoEncodingType autoEnc, u16 altChar,
369                                   u8* work, u32 workSize );
370 #endif
371 NWC24Err NWC24ReadMsgAttached   ( const NWC24MsgObj* obj, u32 index, char* buffer, u32 bufSize );
372 NWC24Err NWC24ReadMsgAltName    ( const NWC24MsgObj* obj, u16* name, u32 length );
373 
374 /*---------------------------------------------------------------------------*
375     Message box access APIs
376  *---------------------------------------------------------------------------*/
377 NWC24Err NWC24CommitMsg         ( NWC24MsgObj* obj );
378 
379 NWC24Err NWC24GetNumMsgs        ( NWC24MsgBoxId mboxId, u32* numMsgs );
380 NWC24Err NWC24GetMsgIdList      ( NWC24MsgBoxId mboxId, u32* idTable, u32 size );
381 NWC24Err NWC24GetMsgObj         ( NWC24MsgObj* obj, NWC24MsgBoxId mboxId, u32 msgId );
382 NWC24Err NWC24DeleteMsg         ( NWC24MsgBoxId mboxId, u32 msgId );
383 
384 NWC24Err NWC24CheckMsgBoxSpace  ( NWC24MsgBoxId mboxId, u32 numMsgs, u32 size );
385 
386 /*---------------------------------------------------------------------------*
387     Message box search APIs
388  *---------------------------------------------------------------------------*/
389 NWC24Err NWC24InitSearchConds           ( void );
390 
391 NWC24Err NWC24SetSearchCondMsgBox       ( NWC24MsgBoxId mBoxId );
392 NWC24Err NWC24SetSearchCondForMenu      ( void );
393 NWC24Err NWC24SetSearchCondPublic       ( BOOL includePublic );
394 NWC24Err NWC24SetSearchCondFromAddrId   ( NWC24UserId userId );
395 NWC24Err NWC24SetSearchCondAppId        ( u32 appId );
396 NWC24Err NWC24SetSearchCondGroupId      ( u16 groupId );
397 NWC24Err NWC24SetSearchCondTag          ( u16 tag, NWC24SearchCompareMode mode );
398 
399 NWC24Err NWC24SearchMsgs                ( NWC24MsgObj* msgObjArray, u32 arraySize,
400                                           u32* numStored, u32* numRemain );
401 
402 
403 /*---------------------------------------------------------------------------*/
404 #ifdef __cplusplus
405 }
406 #endif
407 
408 #endif  // __NWC24MSG_H__
409 
410