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/cec/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><a href="../../../../nn/cec/CTR/MessageBox/CommitMessageBox.html">CommitMessageBox</a></CODE> or <CODE><a href="../../../../nn/cec/CTR/MessageBox/CloseMessageBox.html">CloseMessageBox</a></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>ResultMessTooLarge</CODE></th> 72<td>The message is too large.</td> 73 </tr> 74 <tr> 75<th><CODE>ResultBoxSizeFull</CODE></th> 76<td>The box's capacity has been exceeded.</td> 77 </tr> 78 <tr> 79<th><CODE>ResultBoxMessNumFull</CODE></th> 80<td>The maximum number of boxes has been exceeded.</td> 81 </tr> 82 <tr> 83<th><CODE>ResultNoData</CODE></th> 84<td>No message body or icon has been set for the message.</td> 85 </tr> 86 <tr> 87<th><CODE>ResultInvalidCombination</CODE></th> 88<td>The send count and propagation count have both been set equal to a value of 2 or greater.</td> 89 </tr> 90 <tr> 91<th><CODE>ResultNotAgreeEula</CODE></th> 92<td>The EULA has not been agreed to, or no icon file (ICN file) is configured in the ROM.</td> 93 </tr> 94 <tr> 95<th><CODE>ResultParentalControlCec</CODE></th> 96<td>Not allowed by Parental Controls.</td> 97 </tr> 98 <tr> 99<th><CODE>ResultStateBusy</CODE></th> 100<td>Unable to access because the daemon is busy (BUSY state). This may succeed if you wait some time before accessing again.</td> 101 </tr> 102 <tr> 103<th>A value other than the above.</th> 104<td>Process failed.</td> 105 </tr> 106 </table> </div> 107<h2>Description</h2> 108 <div class="section"> 109<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. Written data is committed when the <CODE><a href="../../../../nn/cec/CTR/MessageBox/CloseMessageBox.html">CloseMessageBox</a></CODE> or <CODE><a href="../../../../nn/cec/CTR/MessageBox/CommitMessageBox.html">CommitMessageBox</a></CODE> function is called after a write has been made. <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 as well.<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> 110 The following simplified C++ code provides guidelines for error handling. <br /><code><pre> 111 nn::Result result = WriteMessage(); 112 if(result.IsFailure()) 113 { 114 if(result == nn::cec::ResultNotAgreeEula()) 115 { 116 // The user has not agreed to the EULA. 117 } 118 else if(result == nn::cec::ResultParentalControlCec()) 119 { 120 // Not permitted by Parental Controls. 121 } 122 else if(result == nn::cec::ResultNotAuthorized()) 123 { 124 // Box is not open 125 // --> OpenMessageBox 126 } 127 else if(result == nn::cec::ResultBoxSizeFull() || result == nn::cec::ResultBoxMessNumFull()) 128 { 129 // Outbox capacity overflow 130 // You must delete some outbox messages → <CODE>DeleteMessage</CODE>/<CODE>DeleteAllMessages</CODE> 131 } 132 else if(result == nn::cec::ResultMessTooLarge() || result == nn::cec::ResultNoData() 133 || result == nn::cec::ResultInvalidCombination() ) 134 { 135 // Invalid message 136 } 137 else if(result == nn::cec::ResultStateBusy()) 138 { 139 // Daemon is BUSY. This state will never normally occur, but it might be possible to succeed by retrying. 140 } 141 else 142 { 143 // Error 144 } 145 return result; // Failure 146 } 147 return result; // Success 148 </pre></code></div> 149<h2>Revision History</h2> 150 <div class="section"> 151 <dl class="history"> 152 <dt>2011/01/19</dt> 153<dd>Added description of error handling.<br /> 154 </dd> 155 <dt>2010/08/16</dt> 156<dd>Initial version.<br /> 157 </dd> 158 </dl> 159 </div> 160 <hr><p>CONFIDENTIAL</p></body> 161</html> 162