1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2<html xml:lang="en-US" lang="en-US" xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 5 <meta http-equiv="Content-Style-Type" content="text/css" /> 6 <link rel="stylesheet" href="../../../../css/manpage.css" type="text/css" /> 7<title>WriteMessage</title> 8 </head> 9 <body> 10<h1><CODE>nn::cec::CTR::MessageBox::WriteMessage</CODE> Member Function</h1> 11<h2>Syntax</h2> 12 <div class="section"> 13 <pre class="definition"> 14<a href="../../../../nn/Result/Overview.html">nn::Result</a> WriteMessage( 15 const <a href="../../../../nn/cec/CTR/Message/Overview.html">Message</a> & cecMessage, 16 const <a href="../../../../nn/cecd/CTR/CecBoxType.html">CecBoxType</a> boxType, 17 <a href="../../../../nn/cec/CTR/MessageId/Overview.html">MessageId</a> & messageIdOut, 18 bool withWriteBoxInfo 19); 20</pre> 21 </div> 22<h2>Arguments</h2> 23 <div class="section"> 24 <table class="arguments"> 25 <thead> 26 <tr> 27 <td width="15" /> 28<th>Name</th> 29<td>Description</td> 30 </tr> 31 </thead> 32 <tr> 33<td>in</td> 34<th>cecMessage</th> 35<td>An object of the <a href="../../../../nn/cec/CTR/Message/Overview.html"><CODE>Message</CODE></a> class.</td> 36 </tr> 37 <tr> 38<td>in</td> 39<th>boxType</th> 40<td>Inbox/outbox specification.</td> 41 </tr> 42 <tr> 43<td>out</td> 44<th>messageIdOut</th> 45<td>Returns the <a href="../../../../nn/cec/CTR/MessageId/Overview.html"><CODE>MessageId</CODE></a> that is assigned during the write.</td> 46 </tr> 47 <tr> 48<td>in</td> 49<th><CODE>withWriteBoxInfo</CODE></th> 50<td>Updates to the internal message list are skipped when <CODE>false</CODE> is specified. The list is updated when the <CODE>CommitMessageBox</CODE> or <CODE>CloseMessageBox</CODE> function is called.</td> 51 </tr> </table> 52 </div> 53<h2>Return Values</h2> 54<div class="section"><a href="../../../../nn/Result/Overview.html"><CODE>nn::Result</CODE></a><br /> <br /> 55 <table class="arguments"> 56 <thead> 57 <tr> 58<th>Value</th> 59<td>Description</td> 60 </tr> 61 </thead> 62 <tr> 63<th><CODE>ResultSuccess</CODE></th> 64<td>Process succeeded.</td> 65 </tr> 66 <tr> 67<th><CODE>ResultNotAuthorized</CODE></th> 68<td>The box has not been opened.</td> 69 </tr> 70 <tr> 71<th><CODE>ResultNoData</CODE></th> 72<td>No message/message body has been set.</td> 73 </tr> 74 <tr> 75<th><CODE>ResultMessTooLarge</CODE></th> 76<td>The message is too large.</td> 77 </tr> 78 <tr> 79<th><CODE>ResultBoxSizeFull</CODE></th> 80<td>The box's capacity has been exceeded.</td> 81 </tr> 82 <tr> 83<th><CODE>ResultBoxMessNumFull</CODE></th> 84<td>The maximum number of boxes has been exceeded.</td> 85 </tr> 86 <tr> 87<th><CODE>ResultNoData</CODE></th> 88<td>No message body or icon has been set for the message.</td> 89 </tr> 90 <tr> 91<th><CODE>ResultInvalidCombination</CODE></th> 92<td>The send count and propagation count have both been set equal to a value of 2 or greater.</td> 93 </tr> 94 <tr> 95<th><CODE>ResultNotAgreeEula</CODE></th> 96<td>The EULA has not been agreed to, or no icon file (ICN file) is configured in the ROM.</td> 97 </tr> 98 <tr> 99<th><CODE>ResultParentalControlCec</CODE></th> 100<td>Not allowed by Parental Controls.</td> 101 </tr> 102 <tr> 103<th><CODE>ResultStateBusy</CODE></th> 104<td>Unable to access because the daemon is busy (BUSY state). This may succeed if you wait some time before accessing again.</td> 105 </tr> 106 <tr> 107<th>A value other than the above.</th> 108<td>Operation failed.</td> 109 </tr> 110 </table> </div> 111<h2>Description</h2> 112 <div class="section"> 113<p>Writes a <a href="../../../../nn/cec/CTR/Message/Overview.html">message</a> to the system save region.</p><p>The message cannot be written if it is larger than 100 KB (including data such as the header and icon) or if it would exceed the box's maximum storage capacity or maximum number of messages. Because NAND memory (the save region) uses a block size of 4 KB, for some message sizes it may be impossible to write up to the maximum storage capacity. After writing, the written data is committed when the <CODE>CloseMessageBox</CODE> or <CODE>CommitMessageBox</CODE> function is called. <br /><br />If you set <SPAN class="argument">withWriteBoxInfo</SPAN> equal to <CODE>false</CODE>, updates to the internal message list are skipped. This allows you to shorten the amount of time to write multiple consecutive messages. Note that the <CODE>GetMessageBoxXXX</CODE> functions are unable to get accurate information if the list has not been updated. <br /> When this function writes a message it checks the agreed EULA version. If no icon file (ICN file) is configured in the ROM, this function returns <a href="../../../../nn/cec/ResultNotAgreeEula/Overview.html"><CODE>ResultNotAgreeEula</CODE></a> in that situation also.<br />You must initialize the FS library before calling this function because the check uses <a href="../../../../nn/fs/Overview.html">FS</a> library features.</p><!-- write here --><h3>Error Handling</h3> 114 The following simplified C++ code provides guidelines for error handling. <br /><code><pre> 115 nn::Result result = WriteMessage(); 116 if(result.IsFailure()) 117 { 118 if(result == nn::cec::ResultNotAgreeEula()) 119 { 120 // The user has not agreed to the EULA. 121 } 122 else if(result == nn::cec::ResultParentalControlCec()) 123 { 124 // Not permitted by Parental Controls. 125 } 126 else if(result == nn::cec::ResultNotAuthorized()) 127 { 128 // Box is not open 129 // --> OpenMessageBox 130 } 131 else if(result == nn::cec::ResultBoxSizeFull() || result == nn::cec::ResultBoxMessNumFull()) 132 { 133 // Outbox capacity overflow 134 // You must delete some outbox messages → <CODE>DeleteMessage</CODE>/<CODE>DeleteAllMessages</CODE> 135 } 136 else if(result == nn::cec::ResultMessTooLarge() || result == nn::cec::ResultNoData() 137 || result == nn::cec::ResultInvalidCombination() ) 138 { 139 // Invalid message 140 } 141 else if(result == nn::cec::ResultStateBusy()) 142 { 143 // Daemon is BUSY. This state will never normally occur, but it might be possible to succeed by retrying. 144 } 145 else 146 { 147 // Error 148 } 149 return result; // Failure 150 } 151 return result; // Success 152 </pre></code></div> 153<h2>Revision History</h2> 154 <div class="section"> 155 <dl class="history"> 156 <dt>2011/01/19</dt> 157<dd>Added a description of error handling.<br /> 158 </dd> 159 <dt>2010/08/16</dt> 160<dd>Initial version.<br /> 161 </dd> 162 </dl> 163 </div> 164 <hr><p>CONFIDENTIAL</p></body> 165</html> 166