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