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
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/cecd/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 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>
46        The 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            //  --&gt; OpenMessageBox
62        }
63        else if(result == nn::cec::ResultBoxSizeFull() || result == nn::cec::ResultBoxMessNumFull())
64        {
65            // Outbox capacity overflow
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 will never normally occur, but 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 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>
88        The 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            //  --&gt; OpenMessageBox
104        }
105        else if(result == nn::cec::ResultBoxSizeFull() || result == nn::cec::ResultBoxMessNumFull())
106        {
107            // Outbox capacity overflow
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 will never normally occur, but 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>