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><a href="../../../../nn/Overview.html">nn</a>::<a href="../../../../nn/cec/Overview.html">cec</a>::<a href="../../../../nn/cec/CTR/Overview.html">CTR</a>::<a href="../../../../nn/cec/CTR/MessageBox/Overview.html">MessageBox</a>::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); 19 20<a href="../../../../nn/Result/Overview.html">nn::Result</a> WriteMessage( 21 const <a href="../../../../nn/cec/CTR/Message/Overview.html">Message</a> & cecMessage, 22 const <a href="../../../../nn/cec/CTR/CecBoxType.html">CecBoxType</a> boxType, 23 <a href="../../../../nn/cec/CTR/MessageId/Overview.html">MessageId</a> & messageIdOut, 24 bool withWriteBoxInfo 25); 26</pre> 27 </div> 28<h2>List of Overloaded Member Functions</h2> 29 <div class="section"> 30 <table class="members"> 31 <tr> 32 <td> 33<a href="./WriteMessage(0).html"><CODE>WriteMessage(const Message &, const CecBoxType, MessageId &)</CODE> </a> 34 </td> 35<td>Writes a <a href="../../../../nn/cec/CTR/Message/Overview.html">message</a> to the system save region.</td> 36 </tr> 37 <tr> 38 <td> 39<a href="./WriteMessage(1).html"><CODE>WriteMessage(const Message &, const CecBoxType, MessageId &, bool)</CODE> </a> 40 </td> 41<td>Writes a <a href="../../../../nn/cec/CTR/Message/Overview.html">message</a> to the system save region.</td> 42 </tr> </table> 43 </div> 44<h2>Description of <CODE>WriteMessage(const Message &, const CecBoxType, MessageId &)</CODE></h2> 45<div class="section"><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 save capacity or maximum number of messages. You can use the <CODE><a href="../../../../nn/cec/CTR/Message/GetMessageSize.html">Message::GetMessageSize</a></CODE> function to get the message size. 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. If the message size is 5 KB, a NAND memory region of 8 KB is used for storing the message. After usage exceeds 1,024 KB, messages cannot be written to memory. The number of 5 KB messages that can be stored (in the inbox and outbox combined) is 1024/8 = 128 messages.<br />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 /> The EULA version to which the user has agreed is checked when a message is written. If an icon file (<CODE>.icn</CODE>) is not set in the ROM, <CODE><a href="../../../../nn/cec/ResultNotAgreeEula/Overview.html">ResultNotAgreeEula</a></CODE> is returned. 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> 46The following simplified C++ code provides guidelines for error handling. <br /><code><pre> 47 nn::Result result = WriteMessage(); 48 if(result.IsFailure()) 49 { 50 if(result == nn::cec::ResultNotAgreeEula()) 51 { 52 // The user has not agreed to the EULA. 53 } 54 else if(result == nn::cec::ResultParentalControlCec()) 55 { 56 // Not permitted by Parental Controls. 57 } 58 else if(result == nn::cec::ResultNotAuthorized()) 59 { 60 // Box is not open 61 // --> OpenMessageBox 62 } 63 else if(result == nn::cec::ResultBoxSizeFull() || result == nn::cec::ResultBoxMessNumFull()) 64 { 65 // Outbox capacity exceeded 66 // You must delete some outbox messages → <CODE>DeleteMessage</CODE>/<CODE>DeleteAllMessages</CODE> 67 } 68 else if(result == nn::cec::ResultMessTooLarge() || result == nn::cec::ResultNoData() 69 || result == nn::cec::ResultInvalidCombination() ) 70 { 71 // Invalid message 72 } 73 else if(result == nn::cec::ResultStateBusy() ) 74 { 75 // Daemon is BUSY. This state never occurs normally. It might be possible to succeed by retrying. 76 } 77 else 78 { 79 // Error 80 } 81 return result; // Failure 82 } 83 return result; // Success 84 85 </pre></code></div> 86<h2>Description of <CODE>WriteMessage(const Message &, const CecBoxType, MessageId &, bool)</CODE></h2> 87<div class="section"><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 save capacity or maximum number of messages. You can use the <CODE><a href="../../../../nn/cec/CTR/Message/GetMessageSize.html">Message::GetMessageSize</a></CODE> function to get the message size. 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. If the message size is 5 KB, a NAND memory region of 8 KB is used for storing the message. After usage exceeds 1,024 KB, messages cannot be written to memory. The number of 5 KB messages that can be stored (in the inbox and outbox combined) is 1024/8 = 128 messages.<br />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 enables 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 /> The EULA version to which the user has agreed is checked when a message is written. If an icon file (<CODE>.icn</CODE>) is not set in the ROM, <CODE><a href="../../../../nn/cec/ResultNotAgreeEula/Overview.html">ResultNotAgreeEula</a></CODE> is returned. 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> 88The following simplified C++ code provides guidelines for error handling. <br /><code><pre> 89 nn::Result result = WriteMessage(); 90 if(result.IsFailure()) 91 { 92 if(result == nn::cec::ResultNotAgreeEula()) 93 { 94 // The user has not agreed to the EULA. 95 } 96 else if(result == nn::cec::ResultParentalControlCec()) 97 { 98 // Not permitted by Parental Controls. 99 } 100 else if(result == nn::cec::ResultNotAuthorized()) 101 { 102 // Box is not open 103 // --> OpenMessageBox 104 } 105 else if(result == nn::cec::ResultBoxSizeFull() || result == nn::cec::ResultBoxMessNumFull()) 106 { 107 // Outbox capacity exceeded 108 // You must delete some outbox messages → <CODE>DeleteMessage</CODE>/<CODE>DeleteAllMessages</CODE> 109 } 110 else if(result == nn::cec::ResultMessTooLarge() || result == nn::cec::ResultNoData() 111 || result == nn::cec::ResultInvalidCombination() ) 112 { 113 // Invalid message 114 } 115 else if(result == nn::cec::ResultStateBusy() ) 116 { 117 // Daemon is BUSY. This state never occurs normally. It might be possible to succeed by retrying. 118 } 119 else 120 { 121 // Error 122 } 123 return result; // Failure 124 } 125 return result; // Success 126 127 </pre></code></div> 128 <hr><p>CONFIDENTIAL</p></body> 129</html> 130