Migrate the BTextMailComponent docs to the Haiku Book.

This commit is contained in:
Augustin Cavalier 2017-12-26 13:56:25 -05:00
parent 3305611025
commit 97f4f2b559
3 changed files with 155 additions and 615 deletions

View File

@ -1,614 +0,0 @@
<HTML>
<HEAD>
<TITLE>PlainTextBodyComponent</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" LINK="#2222AA" BACKGROUND="../art/bodyBack.gif">
<P><A NAME=BCursor></A> <!--TOP LINKS--></P>
<CENTER><TABLE BORDER=2 BGCOLOR="#FFDD88">
<TR>
<TD>
<P><TABLE BGCOLOR="#550033" CELLPADDING=5>
<TR>
<TD>
<P><A HREF="../index.html"><FONT FACE="HELVETICA" COLOR="#FFFFFF"><B>Mail
Kit 2 Root</B></FONT></A></P>
</TD>
<TD>
<P><A HREF="index.html"><FONT FACE="HELVETICA" COLOR="#FFFFFF"><B>The
Public API</B></FONT></A></P>
</TD>
</TR>
</TABLE>
</P>
</TD>
</TR>
</TABLE>
<HR NOSHADE>
</CENTER>
<P><!--TOP LINKS--></P>
<H1><FONT SIZE="+4">PlainTextBodyComponent</FONT></H1>
<BLOCKQUOTE><FONT FACE="helvetica"><B>Derived
from:</B></FONT>&nbsp;<A HREF="MailComponent.html">MailComponent</A><BR>
<FONT FACE="helvetica"><B>Declared in:</B></FONT>&nbsp;
include/public/MailComponent.h<BR>
<FONT FACE="helvetica"><B>Library:</B></FONT>&nbsp;libmail.so<BR>
<P><BR>
</P>
<P>PlainTextBodyComponent stores plain text. It uses UTF8 text as
its canonical format and reads and writes RFC 2047 style text. As
such, it handles accents and other 8 bit characters with ease. If
you want to send text, this is the way to go.</P></BLOCKQUOTE>
<P>
<HR NOSHADE>
</P>
<H2><FONT SIZE="+3" COLOR="#430000">C</FONT><FONT COLOR="#430000">onstructor
and
</FONT><FONT SIZE="+3" COLOR="#430000">D</FONT><FONT COLOR="#430000">estructor</FONT></H2>
<P>
<HR>
<A NAME=PlainTextBodyComponent></A><TABLE>
<TR>
<TD>
<P></P>
</TD>
<TD>
<P><FONT SIZE="+2">PlainTextBodyComponent() </FONT></P>
</TD>
</TR>
</TABLE>
</P>
<P>&nbsp;</P>
<BLOCKQUOTE><TABLE BORDER=2 BGCOLOR="#550033" WIDTH=1000>
<TR>
<TD>
<P><TABLE BORDER=1 BGCOLOR="#FFFFFF" CELLPADDING=8 WIDTH=1000>
<TR>
<TD>
<P><FONT SIZE="+1"><B><TT>PlainTextBodyComponent(</TT></B></FONT>const
char*<FONT FACE="HELVETICA" COLOR="#991122"><I>text</I></FONT>
=
<B>NULL</B><FONT SIZE="+1"><B><TT>)</TT></B></FONT></P>
</TD>
</TR>
</TABLE>
</P>
</TD>
</TR>
</TABLE>
<P>Initializes the component and sets its content to <FONT FACE="HELVETICA" COLOR="#991122"><I>text</I></FONT>,
which can be NULL. The argument is a UTF8 null-terminated string.
Encoding defaults to quoted printable with the ISO-8859-1
charset.</P>
<P>&nbsp;</P></BLOCKQUOTE>
<P>
<HR>
<A NAME="~PlainTextBodyComponent"></A><TABLE>
<TR>
<TD>
<P></P>
</TD>
<TD>
<P><FONT SIZE="+2">~PlainTextBodyComponent() </FONT></P>
</TD>
</TR>
</TABLE>
</P>
<P>&nbsp;</P>
<BLOCKQUOTE><TABLE BORDER=2 BGCOLOR="#550033" WIDTH=1000>
<TR>
<TD>
<P><TABLE BORDER=1 BGCOLOR="#FFFFFF" CELLPADDING=8 WIDTH=1000>
<TR>
<TD>
<P>virtual
<FONT SIZE="+1"><B><TT>~PlainTextBodyComponent()</TT></B></FONT></P>
</TD>
</TR>
</TABLE>
</P>
</TD>
</TR>
</TABLE>
<P>Destroys the component and frees internal buffers. Does nothing
of interest.</P></BLOCKQUOTE>
<P>
<HR NOSHADE>
</P>
<H2><FONT SIZE="+3" COLOR="#430000">M</FONT><FONT COLOR="#430000">ember
</FONT><FONT SIZE="+3" COLOR="#430000">F</FONT><FONT COLOR="#430000">unctions</FONT></H2>
<P>
<HR>
<A NAME=GetDecodedData></A><TABLE>
<TR>
<TD>
<P></P>
</TD>
<TD>
<P><FONT SIZE="+2">GetDecodedData () </FONT></P>
</TD>
</TR>
</TABLE>
</P>
<P>&nbsp;</P>
<BLOCKQUOTE><TABLE BORDER=2 BGCOLOR="#550033" WIDTH=1000>
<TR>
<TD>
<P><TABLE BORDER=1 BGCOLOR="#FFFFFF" CELLPADDING=8 WIDTH=1000>
<TR>
<TD>
<P>virtual status_t
<FONT SIZE="+1"><B><TT>GetDecodedData(</TT></B></FONT>BPositionIO
*<FONT FACE="HELVETICA" COLOR="#991122"><I>data</I></FONT><FONT SIZE="+1"><B><TT>)</TT></B></FONT></P>
</TD>
</TR>
</TABLE>
</P>
</TD>
</TR>
</TABLE>
<P>Retrieves the data contained in this component as a UTF8 string
and places the contents of this string in<FONT FACE="HELVETICA" COLOR="#991122"><I>
data</I></FONT>.</P>
<P><B>Return Value:</B></P>
<BLOCKQUOTE>- <B>B_OK</B> if everything succeeds.
<P>- <B>B_ERROR<I> </I></B>if something goes wrong.</P></BLOCKQUOTE></BLOCKQUOTE>
<P>
<HR>
<A NAME=Text></A><TABLE>
<TR>
<TD>
<P></P>
</TD>
<TD>
<P><FONT SIZE="+2">Text () </FONT></P>
</TD>
</TR>
</TABLE>
</P>
<P>&nbsp;</P>
<BLOCKQUOTE><TABLE BORDER=2 BGCOLOR="#550033" WIDTH=1000>
<TR>
<TD>
<P><TABLE BORDER=1 BGCOLOR="#FFFFFF" CELLPADDING=8 WIDTH=1000>
<TR>
<TD>
<P>const char *
<FONT SIZE="+1"><B><TT>Text()</TT></B></FONT></P>
</TD>
</TR>
</TABLE>
</P>
</TD>
</TR>
</TABLE>
<P>Returns the contents of this component as a UTF8
string.</P></BLOCKQUOTE>
<P>
<HR>
<A NAME=BStringText></A><TABLE>
<TR>
<TD>
<P></P>
</TD>
<TD>
<P><FONT SIZE="+2">BStringText () </FONT></P>
</TD>
</TR>
</TABLE>
</P>
<P>&nbsp;</P>
<BLOCKQUOTE><TABLE BORDER=2 BGCOLOR="#550033" WIDTH=1000>
<TR>
<TD>
<P><TABLE BORDER=1 BGCOLOR="#FFFFFF" CELLPADDING=8 WIDTH=1000>
<TR>
<TD>
<P>BString *
<FONT SIZE="+1"><B><TT>BStringText()</TT></B></FONT></P>
</TD>
</TR>
</TABLE>
</P>
</TD>
</TR>
</TABLE>
<P>Returns the internal UTF8 format BString used by this component.
As such, you can do raw text operations on the content of the message. The use of
this function is not reccomended.</P>
</BLOCKQUOTE>
<P>
<HR>
<A NAME=Quote></A><TABLE>
<TR>
<TD>
<P></P>
</TD>
<TD>
<P><FONT SIZE="+2">Quote () </FONT></P>
</TD>
</TR>
</TABLE>
</P>
<P>&nbsp;</P>
<BLOCKQUOTE><TABLE BORDER=2 BGCOLOR="#550033" WIDTH=1000>
<TR>
<TD>
<P><TABLE BORDER=1 BGCOLOR="#FFFFFF" CELLPADDING=8 WIDTH=1000>
<TR>
<TD>
<P>void
<FONT SIZE="+1"><B><TT>Quote(</TT></B></FONT>
const char *<FONT FACE="HELVETICA" COLOR="#991122"><I>message</I></FONT> = <B>NULL</B>,
const char *<FONT FACE="HELVETICA" COLOR="#991122"><I>quote_style</I></FONT> = <B>&quot;&gt;&nbsp;&quot;</B>
<FONT SIZE="+1"><B><TT>)</TT></B></FONT></P>
</TD>
</TR>
</TABLE>
</P>
</TD>
</TR>
</TABLE>
<P>Quotes the contents of this component. Inserts <FONT FACE="HELVETICA" COLOR="#991122"><I>quote_style</I></FONT> at the start of every line,
and prefaces the content with <FONT FACE="HELVETICA" COLOR="#991122"><I>message</I></FONT>, if it is not NULL. <FONT FACE="HELVETICA" COLOR="#991122"><I>message</I></FONT>
should be something like &quot;On September 30, 2001, John Smith said:&quot;, or something in that vein. Note that the new line after <FONT FACE="HELVETICA" COLOR="#991122"><I>message</I></FONT>
is supplied for you, so you do not need to add it.</P>
</BLOCKQUOTE>
<P>
<HR>
<A NAME=SetDecodedData></A><TABLE>
<TR>
<TD>
<P></P>
</TD>
<TD>
<P><FONT SIZE="+2">SetDecodedData () </FONT></P>
</TD>
</TR>
</TABLE>
</P>
<P>&nbsp;</P>
<BLOCKQUOTE><TABLE BORDER=2 BGCOLOR="#550033" WIDTH=1000>
<TR>
<TD>
<P><TABLE BORDER=1 BGCOLOR="#FFFFFF" CELLPADDING=8 WIDTH=1000>
<TR>
<TD>
<P>virtual status_t
<FONT SIZE="+1"><B><TT>SetDecodedData(</TT></B></FONT>BPositionIO
*<FONT FACE="HELVETICA" COLOR="#991122"><I>data</I></FONT><FONT SIZE="+1"><B><TT>)</TT></B></FONT></P>
</TD>
</TR>
</TABLE>
</P>
</TD>
</TR>
</TABLE>
<P>Sets the contents of this component to the UTF8 format data
contained in <FONT FACE="HELVETICA" COLOR="#991122"><I>data</I></FONT>.</P>
<P><B>Return Value:</B></P>
<BLOCKQUOTE>- <B>B_OK</B> if everything succeeds.
<P>- <B>B_ERROR<I> </I></B>if something goes wrong.</P></BLOCKQUOTE></BLOCKQUOTE>
<P>
<HR>
<A NAME=SetText></A><TABLE>
<TR>
<TD>
<P></P>
</TD>
<TD>
<P><FONT SIZE="+2">SetText () </FONT></P>
</TD>
</TR>
</TABLE>
</P>
<P>&nbsp;</P>
<BLOCKQUOTE><TABLE BORDER=2 BGCOLOR="#550033" WIDTH=1000>
<TR>
<TD>
<P><TABLE BORDER=1 BGCOLOR="#FFFFFF" CELLPADDING=8 WIDTH=1000>
<TR>
<TD>
<P>void
<FONT SIZE="+1"><B><TT>SetText(</TT></B></FONT>const
char *<FONT FACE="HELVETICA" COLOR="#991122"><I>text</I></FONT><FONT SIZE="+1"><B><TT>)</TT></B></FONT></P>
</TD>
</TR>
</TABLE>
</P>
</TD>
</TR>
</TABLE>
<P>Sets the contents of this component to the UTF8 string
contained in <FONT FACE="HELVETICA" COLOR="#991122"><I>text</I></FONT>.</P></BLOCKQUOTE>
<P>
<HR>
<A NAME=AppendText></A><TABLE>
<TR>
<TD>
<P></P>
</TD>
<TD>
<P><FONT SIZE="+2">AppendText () </FONT></P>
</TD>
</TR>
</TABLE>
</P>
<P>&nbsp;</P>
<BLOCKQUOTE><TABLE BORDER=2 BGCOLOR="#550033" WIDTH=1000>
<TR>
<TD>
<P><TABLE BORDER=1 BGCOLOR="#FFFFFF" CELLPADDING=8 WIDTH=1000>
<TR>
<TD>
<P>void
<FONT SIZE="+1"><B><TT>AppendText(</TT></B></FONT>const
char *<FONT FACE="HELVETICA" COLOR="#991122"><I>text</I></FONT><FONT SIZE="+1"><B><TT>)</TT></B></FONT></P>
</TD>
</TR>
</TABLE>
</P>
</TD>
</TR>
</TABLE>
<P>Appends <FONT FACE="HELVETICA" COLOR="#991122"><I>text
</I></FONT>to the current contents of this component. <FONT FACE="HELVETICA" COLOR="#991122"><I>text</I></FONT>
should be a UTF8 string.</P></BLOCKQUOTE>
<P>
<HR>
<A NAME=AppendText></A><TABLE>
<TR>
<TD>
<P></P>
</TD>
<TD>
<P><FONT SIZE="+2">SetEncoding () </FONT></P>
</TD>
</TR>
</TABLE>
</P>
<P>&nbsp;</P>
<BLOCKQUOTE><TABLE BORDER=2 BGCOLOR="#550033" WIDTH=1000>
<TR>
<TD>
<P><TABLE BORDER=1 BGCOLOR="#FFFFFF" CELLPADDING=8 WIDTH=1000>
<TR>
<TD>
<P>void
<FONT SIZE="+1"><B><TT>SetEncoding(</TT></B></FONT>mail_encoding
<FONT FACE="HELVETICA" COLOR="#991122"><I>encoding</I></FONT>,
int32 <FONT FACE="HELVETICA" COLOR="#991122"><I>charset</I></FONT><FONT SIZE="+1"><B><TT>)</TT></B></FONT></P>
</TD>
</TR>
</TABLE>
</P>
</TD>
</TR>
</TABLE>
<P>Sets the encoding and charset used by <A HREF="#Render"><B>Render()</B></A>
to <FONT FACE="HELVETICA" COLOR="#991122"><I>encoding</I></FONT>
and <FONT FACE="HELVETICA" COLOR="#991122"><I>charset</I></FONT>,
respectively. Use the conversion constants from <B>UTF8.h</B> for
<FONT FACE="HELVETICA" COLOR="#991122"><I>charset</I></FONT>. We
<I>strongly</I> reccomend that you always use the defaults for the
reasons outlined in <A HREF="http://www.faqs.org/rfcs/rfc2047.html">RFC
2047</A>.</P></BLOCKQUOTE>
<P>
<HR>
<A NAME=Instantiate></A><TABLE>
<TR>
<TD>
<P></P>
</TD>
<TD>
<P><FONT SIZE="+2">Instantiate () </FONT></P>
</TD>
</TR>
</TABLE>
</P>
<P>&nbsp;</P>
<BLOCKQUOTE><TABLE BORDER=2 BGCOLOR="#550033" WIDTH=1000>
<TR>
<TD>
<P><TABLE BORDER=1 BGCOLOR="#FFFFFF" CELLPADDING=8 WIDTH=1000>
<TR>
<TD>
<P>virtual status_t
<FONT SIZE="+1"><B><TT>Instantiate(</TT></B></FONT>BPositionIO
*<FONT FACE="HELVETICA" COLOR="#991122"><I>data</I></FONT>,
size_t <FONT FACE="HELVETICA" COLOR="#991122"><I>length</I></FONT><FONT SIZE="+1"><B><TT>)</TT></B></FONT></P>
</TD>
</TR>
</TABLE>
</P>
</TD>
</TR>
</TABLE>
<P>Initializes this component to the RFC 822 format data in
<FONT FACE="HELVETICA" COLOR="#991122"><I>data</I></FONT>,
starting at <FONT FACE="HELVETICA" COLOR="#991122"><I>data
</I></FONT>-&gt;Position(), for up to <FONT FACE="HELVETICA" COLOR="#991122"><I>length
</I></FONT>bytes. Handles encoded data according to RFC 2047</P>
<P><B>Return Value:</B></P>
<BLOCKQUOTE>- <B>B_OK</B> if everything succeeds.
<P>- <B>B_BAD_TYPE</B> if <FONT FACE="HELVETICA" COLOR="#991122"><I>data</I></FONT><FONT FACE="HELVETICA">
</FONT>does not seem to be plain text.</P></BLOCKQUOTE></BLOCKQUOTE>
<P>
<HR>
<A NAME=Render></A><TABLE>
<TR>
<TD>
<P></P>
</TD>
<TD>
<P><FONT SIZE="+2">Render () </FONT></P>
</TD>
</TR>
</TABLE>
</P>
<P>&nbsp;</P>
<BLOCKQUOTE><TABLE BORDER=2 BGCOLOR="#550033" WIDTH=1000>
<TR>
<TD>
<P><TABLE BORDER=1 BGCOLOR="#FFFFFF" CELLPADDING=8 WIDTH=1000>
<TR>
<TD>
<P>virtual status_t
<FONT SIZE="+1"><B><TT>Render(</TT></B></FONT>BPositionIO
*<FONT FACE="HELVETICA" COLOR="#991122"><I>data</I></FONT><FONT SIZE="+1"><B><TT>)</TT></B></FONT></P>
</TD>
</TR>
</TABLE>
</P>
</TD>
</TR>
</TABLE>
<P>Renders the component into RFC 822 format and places the result
in <FONT FACE="HELVETICA" COLOR="#991122"><I>data</I></FONT>,
starting at <FONT FACE="HELVETICA" COLOR="#991122"><I>data
</I></FONT>-&gt;Position(). Encodes and translates charsets
according to the arguments passed to <A HREF="#SetEncoding"><B>SetEncoding()</B></A>.
Encoding defaults to quoted printable and charset to
ISO-8859-1.</P>
<P><B>Return Value:</B></P>
<BLOCKQUOTE>- <B>B_OK</B> if everything succeeds.</BLOCKQUOTE>
<P></TABLE></P></BLOCKQUOTE>
<P><!--TOP LINKS-->
<HR NOSHADE>
</P>
<CENTER><TABLE BORDER=2 BGCOLOR="#FFDD88">
<TR>
<TD>
<P><TABLE BGCOLOR="#550033" CELLPADDING=5>
<TR>
<TD>
<P><A HREF="../index.html"><FONT FACE="HELVETICA" COLOR="#FFFFFF"><B>Mail
Kit 2 Root</B></FONT></A></P>
</TD>
<TD>
<P><A HREF="index.html"><FONT FACE="HELVETICA" COLOR="#FFFFFF"><B>The
Public API</B></FONT></A></P>
</TD>
</TR>
</TABLE>
</P>
</TD>
</TR>
</TABLE>
</CENTER>
<P><!--TOP LINKS--> <!-- Footer for Release 5 HTML Be Book --><BR>
</P>
<CENTER><FONT SIZE="+3" COLOR="#555555"><I>Mail Daemon 2 API
Documentation</I></FONT>
<P><FONT SIZE="+1" COLOR="#555555"><I>&copy;2001 Dr. Zoidberg
Enterprises</I></FONT></P></CENTER>
</BODY>
</HTML>

View File

@ -240,7 +240,7 @@ const char *subject = component->HeaderField("Subject");
and places it into \a data. and places it into \a data.
The various attachments subclasses implement this function to return The various attachments subclasses implement this function to return
decoded data, and \c BPlainTextBodyComponent returns UTF8 text. \c BMailComponent decoded data, and BTextMailComponent returns UTF8 text. \c BMailComponent
implements this function to do nothing and return \c B_OK. implements this function to do nothing and return \c B_OK.
\since Haiku R1 \since Haiku R1

View File

@ -0,0 +1,154 @@
/*
* Copyright 2017 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Augustin Cavalier <waddlesplash>
* Nathan Whitehorn
*
* Corresponds to:
* headers/os/mail/MailComponent.h hrev51708
* src/kits/mail/MailComponent.cpp hrev51708
*/
/*!
\class BTextMailComponent
\ingroup mail
\brief A component that stores plain text.
It uses UTF8 text as its canonical format and reads and writes
<a href="https://www.ietf.org/rfc/rfc2047.txt">RFC-2047</a> style text. As such,
it handles accents and other 8 bit characters with ease. If you want to
send text, this is the way to go.
\since Haiku R1
*/
/*!
\fn BTextMailComponent::BTextMailComponent(const char *text = NULL,
uint32 defaultCharSet = B_MAIL_NULL_CONVERSION)
\brief Initializes the component and sets its content to \a text.
\a text can be \c NULL. The argument is a UTF-8 null-terminated string.
Encoding defaults to quoted_printable with the ISO-15 charset.
\since Haiku R1
*/
/*!
\fn BTextMailComponent::~BTextMailComponent()
\brief Destructor.
*/
/*!
\fn void BTextMailComponent::SetEncoding(mail_encoding encoding,
int32 charset)
\brief Sets the \a encoding and \a charset used by Render().
Use the conversion constants from UTF8.h for \a charset. We strongly
reccomend that you always use the defaults (and strongly recommend
against using base64) for the reasons outlined in RFC 2047.
\since Haiku R1
*/
/*!
\fn void BTextMailComponent::SetText(const char *text)
\brief Sets the contents of this component to the UTF8 string \a text.
\since Haiku R1
*/
/*!
\fn void BTextMailComponent::AppendText(const char *text)
\brief Appends the UTF8 string \a text to the current contents of this
component.
\since Haiku R1
*/
/*!
\fn const char* BTextMailComponent::Text()
\brief Returns the contents of this component as a UTF8 string.
\since Haiku R1
*/
/*!
\fn BString* BTextMailComponent::BStringText()
\brief Returns the internal UTF8 format BString used by this component.
As such, you can do raw text operations on the content of the message.
The use of this function is not reccomended.
\since Haiku R1
*/
/*!
\fn void BTextMailComponent::Quote(const char *message = NULL,
const char *quote_style = "> ")
\brief Quotes the contents of this component.
Inserts \a quote_style at the start of every line, and prefaces the content
with \a message, if it is not \c NULL. \a message should be something like
<code>"On September 30, 2001, John Smith said:"</code>, or something in that vein.
Note that the new line after \a message is supplied for you, so you do not
need to add it.
\since Haiku R1
*/
/*!
\fn virtual status_t BTextMailComponent::GetDecodedData(BPositionIO *data)
\brief Retrieves the data contained in this component as a UTF8 string
into \a data.
\since Haiku R1
*/
/*!
\fn virtual status_t BTextMailComponent::SetDecodedData(BPositionIO *data)
\brief Sets the contents of this component to the UTF8 format \a data.
\since Haiku R1
*/
/*!
\fn virtual status_t BTextMailComponent::SetToRFC822(BPositionIO *data,
size_t length, bool parse_now = false)
\brief Sets this object from a component in RFC-822 format.
Initializes this component to the RFC 822 format data in \a data,
starting at <code>data->Position()</code>, for up to \a length bytes.
Handles encoded data according to RFC 2047.
If \a parse_now is \c false, then the \a data will not be parsed
until RenderToRFC822 is called.
\since Haiku R1
*/
/*!
\fn virtual status_t BTextMailComponent::RenderToRFC822(BPositionIO* render_to)
\brief Renders the component into RFC-822 format.
It places the result in data, starting at data->Position().
Encodes and translates charsets according to the arguments passed to
SetEncoding(), or the defaults set in BTextMailComponent::BTextMailComponent()
otherwise.
\since Haiku R1
*/