/*---------------------------------------------------------------------------* Project: Wii Connect24 API demos File: PostTestMsg.c Copyright 2006 Nintendo. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. $Log: PostTestMsg.c,v $ Revision 1.1 2006/09/27 08:56:17 torigoe_nobutaka Moved from nwc24demo/src. Revision 1.1 2006/08/25 06:17:59 torigoe_nobutaka Initial check in. $NoKeywords: $ *---------------------------------------------------------------------------*/ #include #include #include #include "PostTestMsg.h" /*---------------------------------------------------------------------------* Static constants *---------------------------------------------------------------------------*/ #define NUM_TEST_MSGS 4 static const NWC24UserId TEST_TO_ID = 1234567890ULL; static const NWC24MsgType TEST_MSG_TYPE[NUM_TEST_MSGS] = { NWC24_MSGTYPE_WII, NWC24_MSGTYPE_WII_APP_ONLY, NWC24_MSGTYPE_WII_MENU_ONLY, NWC24_MSGTYPE_WII }; static const char* STR_TEST_SUBJECT[NUM_TEST_MSGS] = { "Test Message /1", "Test Message /2", "Test Message /3", "Test Message /4" }; static const char* STR_TEST_MSG_TEXT = "Hello WiiConnect24 World!!\x0d\x0a" "This is a test mail.\x0d\x0a" "Thank you.\x0d\x0a"; /*---------------------------------------------------------------------------* Creates and posts test messages. *---------------------------------------------------------------------------*/ void PostTestMsg( void ) { NWC24Err err; NWC24MsgObj msgObj; u8 iObj; NWC24UserId uidTo; /* Initializes the message object. */ for ( iObj = 0; iObj < NUM_TEST_MSGS; ++iObj ) { err = NWC24InitMsgObj( &msgObj, TEST_MSG_TYPE[iObj] ); if ( err != NWC24_OK ) { OSReport( "NWC24InitMsgObj(): Error %d\n", err ); return; } /* To address (by user ID) */ if ( iObj == NUM_TEST_MSGS - 1 ) { err = NWC24GetMyUserId( &uidTo ); if ( err != NWC24_OK ) { OSReport( "NWC24GetMyUserId(): Error %d\n", err ); return; } } else { uidTo = TEST_TO_ID; } err = NWC24SetMsgToId( &msgObj, uidTo ); if ( err != NWC24_OK ) { OSReport( "NWC24SetMsgToId(): Error %d\n", err ); return; } /* Subject */ err = NWC24SetMsgSubject( &msgObj, STR_TEST_SUBJECT[iObj], (u32)strlen( STR_TEST_SUBJECT[iObj] ) ); if ( err != NWC24_OK ) { OSReport( "NWC24SetMsgSubject(): Error %d\n", err ); return; } /* Message body (text) */ err = NWC24SetMsgText( &msgObj, STR_TEST_MSG_TEXT, (u32)strlen( STR_TEST_MSG_TEXT ), NWC24_US_ASCII, NWC24_ENC_7BIT ); if ( err != NWC24_OK ) { OSReport( "NWC24SetMsgText(): Error %d\n", err ); return; } /* Commit settings and post the message into the send box. */ err = NWC24CommitMsg( &msgObj ); if ( err != NWC24_OK ) { OSReport( "NWC24CommitMsg(): Error %d\n", err ); return; } } OSReport( "Posted %d test messages successfully.\n", NUM_TEST_MSGS ); return; } /*======== End of PostTestMsg.c ========*/