summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2015-09-10 13:49:11 +0200
committerStephan Bergmann <sbergman@redhat.com>2015-09-10 23:04:34 +0200
commit40bcf53b5d663010efa8360c0d7dd0fe222bacfb (patch)
tree0988bb06f27189fad814c46e3679b5377b452171 /tools
parente871b6a31aa5004daa7fb3b8531bd7f43e8fc203 (diff)
Remove unused INetMessageOStream functionality
Change-Id: I34ee4750f30635809b8e23cbf1bd0e16f269f549
Diffstat (limited to 'tools')
-rw-r--r--tools/source/inet/inetstrm.cxx710
1 files changed, 0 insertions, 710 deletions
diff --git a/tools/source/inet/inetstrm.cxx b/tools/source/inet/inetstrm.cxx
index 9836f39f1b57..053b649c576e 100644
--- a/tools/source/inet/inetstrm.cxx
+++ b/tools/source/inet/inetstrm.cxx
@@ -26,11 +26,6 @@
#include <ctype.h>
-inline bool SAL_CALL ascii_isWhitespace( sal_Unicode ch )
-{
- return ((ch <= 0x20) && ch);
-}
-
/** Quoted-Printable Encoding */
class INetMessageEncodeQPStream_Impl : public INetMessageIStream
{
@@ -56,22 +51,6 @@ public:
virtual ~INetMessageEncodeQPStream_Impl();
};
-/** Quoted-Printable Decoding */
-class INetMessageDecodeQPStream_Impl : public INetMessageOStream
-{
- INetMessageStreamState eState;
- SvMemoryStream *pMsgBuffer;
-
- sal_uIntPtr nTokBufLen;
- sal_Char pTokBuffer[4];
-
- virtual int PutMsgLine(const sal_Char* pData, sal_uIntPtr nSize) SAL_OVERRIDE;
-
-public:
- INetMessageDecodeQPStream_Impl();
- virtual ~INetMessageDecodeQPStream_Impl();
-};
-
/** Base64 Encoding */
class INetMessageEncode64Stream_Impl : public INetMessageIStream
{
@@ -96,23 +75,6 @@ public:
virtual ~INetMessageEncode64Stream_Impl();
};
-/** Base64 Decoding */
-class INetMessageDecode64Stream_Impl : public INetMessageOStream
-{
- INetMessageStreamState eState;
-
- sal_uIntPtr nMsgBufSiz;
- sal_Char* pMsgBuffer;
- sal_Char* pMsgRead;
- sal_Char* pMsgWrite;
-
- virtual int PutMsgLine(const sal_Char* pData, sal_uIntPtr nSize) SAL_OVERRIDE;
-
-public:
- explicit INetMessageDecode64Stream_Impl(sal_uIntPtr nMsgBufferSize = 128);
- virtual ~INetMessageDecode64Stream_Impl();
-};
-
// INetMessageIStream
INetMessageIStream::INetMessageIStream(sal_uIntPtr nBufferSize)
@@ -245,172 +207,6 @@ int INetMessageIStream::GetMsgLine(sal_Char* pData, sal_uIntPtr nSize)
return (pWBuf - pData);
}
-// INetMessageOStream
-
-INetMessageOStream::INetMessageOStream()
- : pTargetMsg (NULL),
- bHeaderParsed (false),
- eOState (INETMSG_EOL_BEGIN),
- pMsgBuffer (new SvMemoryStream)
-{
-}
-
-INetMessageOStream::~INetMessageOStream()
-{
- if (pMsgBuffer->Tell() > 0)
- PutMsgLine(static_cast<const sal_Char*>(pMsgBuffer->GetData()), pMsgBuffer->Tell());
- delete pMsgBuffer;
-
- if (pTargetMsg)
- {
- SvOpenLockBytes* pLB = PTR_CAST(SvOpenLockBytes, pTargetMsg->GetDocumentLB());
- if (pLB)
- {
- pLB->Flush();
- pLB->Terminate();
- }
- }
-}
-
-/// Simple Field Parsing (RFC822, Appendix B)
-int INetMessageOStream::Write(const sal_Char* pData, sal_uIntPtr nSize)
-{
- if (pTargetMsg == NULL) return INETSTREAM_STATUS_ERROR;
-
- const sal_Char* pStop = (pData + nSize);
-
- while (!bHeaderParsed && (pData < pStop))
- {
- if (eOState == INETMSG_EOL_BEGIN)
- {
- if ((*pData == '\r') || (*pData == '\n'))
- {
- /*
- * Empty Line. Separates header fields from message body.
- * Skip this and any 2nd line break character (if any).
- */
- pData++;
- if ((pData < pStop) && ((*pData == '\r') || (*pData == '\n')))
- pData++;
-
- // Emit any buffered last header field.
- if (pMsgBuffer->Tell() > 0)
- {
- pMsgBuffer->WriteChar( '\0' );
- int status = PutMsgLine( static_cast<const sal_Char*>(pMsgBuffer->GetData()),
- pMsgBuffer->Tell());
- if (status != INETSTREAM_STATUS_OK) return status;
- }
-
- // Reset to begin.
- eOState = INETMSG_EOL_BEGIN;
- pMsgBuffer->Seek(STREAM_SEEK_TO_BEGIN);
-
- // Mark header parsed.
- bHeaderParsed = true;
- }
- else if ((*pData == ' ') || (*pData == '\t'))
- {
- // Continuation line. Unfold multi-line field-body.
- pMsgBuffer->WriteChar( ' ' );
- pData++;
- }
- else
- {
- // Begin of new header field.
- if (pMsgBuffer->Tell() > 0)
- {
- // Emit buffered header field now.
- pMsgBuffer->WriteChar( '\0' );
- int status = PutMsgLine(static_cast<const sal_Char*>(pMsgBuffer->GetData()),
- pMsgBuffer->Tell());
- if (status != INETSTREAM_STATUS_OK) return status;
- }
-
- // Reset to begin of buffer.
- pMsgBuffer->Seek(STREAM_SEEK_TO_BEGIN);
-
- // Insert current character into buffer.
- pMsgBuffer->WriteChar( *pData++ );
- }
-
- // Search for next line break character.
- if (!bHeaderParsed) eOState = INETMSG_EOL_SCR;
- }
- else if (eOState == INETMSG_EOL_FCR)
- {
- // Skip line break character.
- pData++;
-
- // Mark begin of line.
- eOState = INETMSG_EOL_BEGIN;
- }
- else if ((*pData == '\r') || (*pData == '\n'))
- {
- if (*pData == '\r') pData++;
- eOState = INETMSG_EOL_FCR;
- }
- else if (ascii_isWhitespace(*pData & 0x7f))
- {
- // Any <LWS> is folded into a single <SP> character.
- sal_Char c = *(static_cast<const sal_Char*>(pMsgBuffer->GetData()) + pMsgBuffer->Tell() - 1);
- if (!ascii_isWhitespace(c & 0x7f)) pMsgBuffer->WriteChar( ' ' );
-
- // Skip over this <LWS> character.
- pData++;
- }
- else
- {
- // Any other character is inserted into line buffer.
- pMsgBuffer->WriteChar( *pData++ );
- }
- }
-
- if (bHeaderParsed && (pData < pStop))
- {
- // Put message body down-stream.
- return PutMsgLine(pData, (pStop - pData));
- }
-
- return INETSTREAM_STATUS_OK;
-}
-
-int INetMessageOStream::PutMsgLine(const sal_Char* pData, sal_uIntPtr nSize)
-{
- // Check for message container.
- if (pTargetMsg == NULL) return INETSTREAM_STATUS_ERROR;
-
- // Check for header or body.
- if (!IsHeaderParsed())
- {
- OString aField(pData);
- sal_Int32 nPos = aField.indexOf(':');
- if (nPos != -1)
- {
- OString aName( aField.copy(0, nPos));
- OString aValue( aField.copy(nPos + 1, aField.getLength() - nPos + 1));
- aValue = comphelper::string::stripStart(aValue, ' ');
-
- pTargetMsg->SetHeaderField( INetMessageHeader (aName, aValue));
- }
- }
- else
- {
- SvOpenLockBytes *pLB = PTR_CAST(SvOpenLockBytes, pTargetMsg->GetDocumentLB());
- if (pLB == NULL)
- return INETSTREAM_STATUS_WOULDBLOCK;
-
- sal_Size nDocSiz = pTargetMsg->GetDocumentSize();
- sal_Size nWrite = 0;
-
- pLB->FillAppend(pData, nSize, &nWrite);
- pTargetMsg->SetDocumentSize(nDocSiz + nWrite);
-
- if (nWrite < nSize) return INETSTREAM_STATUS_ERROR;
- }
- return INETSTREAM_STATUS_OK;
-}
-
// INetMessageEncodeQPStream_Impl
static const sal_Char hex2pr[16] = {
@@ -611,125 +407,6 @@ int INetMessageEncodeQPStream_Impl::GetMsgLine(sal_Char* pData, sal_uIntPtr nSiz
return (pWBuf - pData);
}
-// INetMessageDecodeQPStream_Impl
-
-static const sal_uInt8 pr2hex[128] = {
- 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
- 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
- 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
- 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
-
- 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
- 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x08, 0x09, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
-
- 0x10, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10,
- 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
- 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
- 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
-
- 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
- 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
- 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
- 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10
-};
-
-INetMessageDecodeQPStream_Impl::INetMessageDecodeQPStream_Impl()
- : INetMessageOStream(),
- eState (INETMSG_EOL_BEGIN),
- pMsgBuffer (new SvMemoryStream),
- nTokBufLen (0)
-{
- ParseHeader(false);
-}
-
-INetMessageDecodeQPStream_Impl::~INetMessageDecodeQPStream_Impl()
-{
- delete pMsgBuffer;
-}
-
-int INetMessageDecodeQPStream_Impl::PutMsgLine( const sal_Char* pData,
- sal_uIntPtr nSize)
-{
- INetMIMEMessage* pMsg = GetTargetMessage();
- if (pMsg == NULL) return INETSTREAM_STATUS_ERROR;
-
- SvOpenLockBytes* pLB = PTR_CAST(SvOpenLockBytes, pMsg->GetDocumentLB());
- if (pLB == NULL) return INETSTREAM_STATUS_WOULDBLOCK;
-
- const sal_Char* pStop = pData + nSize;
- while (pData < pStop)
- {
- if (eState == INETMSG_EOL_FESC)
- {
- *(pTokBuffer + nTokBufLen++) = static_cast< char >(toupper(*pData));
- pData++;
- if (nTokBufLen == 2)
- {
- if ((*pTokBuffer == '\r') || (*pTokBuffer == '\n'))
- {
- // Soft line break (=<CR><LF>). Emit buffer now.
- eState = INETMSG_EOL_BEGIN;
- }
- else
- {
- // Decode token.
- pMsgBuffer->WriteUChar( sal_uInt8 (
- (pr2hex[(int)(pTokBuffer[0] & 0x7f)] << 4) |
- (pr2hex[(int)(pTokBuffer[1] & 0x7f)] & 15) ) );
-
- // Search for next <CR>.
- eState = INETMSG_EOL_SCR;
- }
-
- // Reset token buffer.
- nTokBufLen = 0;
- }
- }
- else if (*pData == '=')
- {
- // Found escape character.
- pData++;
- eState = INETMSG_EOL_FESC;
- }
- else if (eState == INETMSG_EOL_FCR)
- {
- pMsgBuffer->WriteChar( *pData++ );
- eState = INETMSG_EOL_BEGIN;
- }
- else if (*pData == '\r')
- {
- pMsgBuffer->WriteChar( *pData++ );
- eState = INETMSG_EOL_FCR;
- }
- else
- {
- pMsgBuffer->WriteChar( *pData++ );
- }
-
- if (eState == INETMSG_EOL_BEGIN)
- {
- sal_Size nRead = pMsgBuffer->Tell();
- if (nRead > 0)
- {
- // Emit buffer.
- sal_Size nDocSiz = pMsg->GetDocumentSize();
- sal_Size nWrite = 0;
-
- pLB->FillAppend(pMsgBuffer->GetData(), nRead, &nWrite);
- pMsg->SetDocumentSize(nDocSiz + nWrite);
-
- if (nWrite < nRead) return INETSTREAM_STATUS_ERROR;
-
- pMsgBuffer->Seek(STREAM_SEEK_TO_BEGIN);
- }
- eState = INETMSG_EOL_SCR;
- }
- }
- return INETSTREAM_STATUS_OK;
-}
-
// INetMessageEncode64Stream_Impl
static const sal_Char six2pr[64] = {
@@ -888,163 +565,6 @@ int INetMessageEncode64Stream_Impl::GetMsgLine(sal_Char* pData, sal_uIntPtr nSiz
return (pWBuf - pData);
}
-// INetMessageDecode64Stream_Impl
-
-static const sal_uInt8 pr2six[256] = {
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
-
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
- 0x40, 0x40, 0x40, 0x3E, 0x40, 0x40, 0x40, 0x3F,
- 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B,
- 0x3C, 0x3D, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
-
- 0x40, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
- 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E,
- 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16,
- 0x17, 0x18, 0x19, 0x40, 0x40, 0x40, 0x40, 0x40,
-
- 0x40, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20,
- 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
- 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30,
- 0x31, 0x32, 0x33, 0x40, 0x40, 0x40, 0x40, 0x40,
-
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
-
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
-
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
-
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40
-};
-
-INetMessageDecode64Stream_Impl::INetMessageDecode64Stream_Impl(
- sal_uIntPtr nMsgBufferSize)
- : INetMessageOStream(),
- eState (INETMSG_EOL_SCR),
- nMsgBufSiz (nMsgBufferSize)
-{
- ParseHeader(false);
-
- pMsgBuffer = new sal_Char[nMsgBufSiz];
- pMsgRead = pMsgWrite = pMsgBuffer;
-}
-
-INetMessageDecode64Stream_Impl::~INetMessageDecode64Stream_Impl()
-{
- delete [] pMsgBuffer;
-}
-
-int INetMessageDecode64Stream_Impl::PutMsgLine(const sal_Char* pData,
- sal_uIntPtr nSize)
-{
- INetMIMEMessage* pMsg = GetTargetMessage();
- if (pMsg == NULL) return INETSTREAM_STATUS_ERROR;
-
- SvOpenLockBytes* pLB = PTR_CAST(SvOpenLockBytes, pMsg->GetDocumentLB());
- if (pLB == NULL) return INETSTREAM_STATUS_WOULDBLOCK;
-
- const sal_Char* pStop = (pData + nSize);
- while (pData < pStop)
- {
- if (pr2six[(int)(*pData)] > 63)
- {
- /*
- * Character not in base64 alphabet.
- * Check for <End-of-Stream> or Junk.
- */
- if (*pData == '=')
- {
- // Final pad character -> Done.
- sal_Size nDocSiz = pMsg->GetDocumentSize();
- sal_Size nRead = pMsgWrite - pMsgBuffer;
- sal_Size nWrite = 0;
-
- pLB->FillAppend(pMsgBuffer, nRead, &nWrite);
- pMsg->SetDocumentSize(nDocSiz + nWrite);
-
- if (nWrite < nRead)
- return INETSTREAM_STATUS_ERROR;
- else
- return INETSTREAM_STATUS_LOADED;
- }
- else if (eState == INETMSG_EOL_FCR)
- {
- // Skip any line break character.
- if ((*pData == '\r') || (*pData == '\n')) pData++;
-
- // Store decoded message buffer contents.
- sal_Size nDocSiz = pMsg->GetDocumentSize();
- sal_Size nRead = pMsgWrite - pMsgBuffer;
- sal_Size nWrite = 0;
-
- pLB->FillAppend(pMsgBuffer, nRead, &nWrite);
- pMsg->SetDocumentSize(nDocSiz + nWrite);
-
- if (nWrite < nRead) return INETSTREAM_STATUS_ERROR;
-
- // Reset to <Begin-of-Buffer>.
- pMsgWrite = pMsgBuffer;
- eState = INETMSG_EOL_SCR;
- }
- else if ((*pData == '\r') || (*pData == '\n'))
- {
- // Skip any line break character.
- pData++;
- eState = INETMSG_EOL_FCR;
- }
- else
- {
- // Skip any junk character (may be transmission error).
- pData++;
- }
- }
- else
- {
- // Decode any other character into message buffer.
- switch ((pMsgRead - pMsgBuffer) % 4)
- {
- case 0:
- *pMsgWrite = (pr2six[(int)(*pData++)] << 2);
- pMsgRead++;
- break;
-
- case 1:
- *pMsgWrite++ |= (pr2six[(int)(*pData )] >> 4);
- *pMsgWrite = (pr2six[(int)(*pData++)] << 4);
- pMsgRead++;
- break;
-
- case 2:
- *pMsgWrite++ |= (pr2six[(int)(*pData )] >> 2);
- *pMsgWrite = (pr2six[(int)(*pData++)] << 6);
- pMsgRead++;
- break;
-
- default: // == case 3
- *pMsgWrite++ |= (pr2six[(int)(*pData++)]);
- pMsgRead = pMsgBuffer;
- break;
- } // switch ((pMsgRead - pMsgBuffer) % 4)
- }
- } // while (pData < pStop)
- return INETSTREAM_STATUS_OK;
-}
-
// INetMIMEMessageStream
INetMIMEMessageStream::INetMIMEMessageStream(sal_uIntPtr nBufferSize)
@@ -1054,7 +574,6 @@ INetMIMEMessageStream::INetMIMEMessageStream(sal_uIntPtr nBufferSize)
pChildStrm (NULL),
eEncoding (INETMSG_ENCODING_BINARY),
pEncodeStrm (NULL),
- pDecodeStrm (NULL),
pMsgBuffer (NULL)
{
}
@@ -1063,7 +582,6 @@ INetMIMEMessageStream::~INetMIMEMessageStream()
{
delete pChildStrm;
delete pEncodeStrm;
- delete pDecodeStrm;
delete pMsgBuffer;
}
@@ -1324,232 +842,4 @@ int INetMIMEMessageStream::GetMsgLine(sal_Char* pData, sal_uIntPtr nSize)
}
}
-/// Message Parser
-int INetMIMEMessageStream::PutMsgLine(const sal_Char* pData, sal_uIntPtr nSize)
-{
- // Check for message container.
- INetMIMEMessage* pMsg = GetTargetMessage();
- if (pMsg == NULL) return INETSTREAM_STATUS_ERROR;
-
- // Check for header or body.
- if (!IsHeaderParsed())
- {
- // Parse the message header.
- int nRet = INetMessageOStream::PutMsgLine(pData, nSize);
- return nRet;
- }
- else
- {
- pMsg->SetHeaderParsed();
- // Parse the message body.
- if (pMsg->IsContainer())
- {
-
- // Content-Transfer-Encoding MUST be "7bit" (RFC1521).
- if (pMsg->IsMessage())
- {
- if( !pChildStrm )
- {
- // Encapsulated message.
- INetMIMEMessage* pNewMessage = new INetMIMEMessage;
- pNewMessage->SetDocumentLB( new SvAsyncLockBytes(new SvMemoryStream(), false));
- pMsg->AttachChild( *pNewMessage );
-
- // Encapsulated message body. Create message parser stream.
- pChildStrm = new INetMIMEMessageStream;
- pChildStrm->SetTargetMessage( pNewMessage );
-
- // Initialize control variables.
- eState = INETMSG_EOL_BEGIN;
- }
- if ( nSize > 0)
- {
- // Bytes still in buffer. Put message down-stream.
- int status = pChildStrm->Write( pData, nSize );
- if (status != INETSTREAM_STATUS_OK)
- return status;
- }
-
- return INetMessageOStream::PutMsgLine(pData, nSize);
- }
- else
- {
-
- // Multipart message body. Initialize multipart delimiters.
- // Multipart message.
- if (pMsg->GetMultipartBoundary().getLength() == 0)
- {
- // Determine boundary.
- OString aType(OUStringToOString(
- pMsg->GetContentType(), RTL_TEXTENCODING_ASCII_US));
- OString aLowerType(aType.toAsciiLowerCase());
-
- sal_Int32 nPos = aLowerType.indexOf("boundary=");
- OString aBoundary(aType.copy(nPos + 9));
-
- aBoundary = comphelper::string::strip(aBoundary, ' ');
- aBoundary = comphelper::string::strip(aBoundary, '"');
-
- // Save boundary.
- pMsg->SetMultipartBoundary(aBoundary);
- }
-
- OString aPlainDelim(pMsg->GetMultipartBoundary());
- OString aDelim = OStringBuffer("--").
- append(aPlainDelim).
- makeStringAndClear();
- OString aPlainClose = OStringBuffer(
- aPlainDelim).
- append("--").
- makeStringAndClear();
- OString aClose = OStringBuffer(
- aDelim).
- append("--").
- makeStringAndClear();
-
- if (pMsgBuffer == NULL) pMsgBuffer = new SvMemoryStream;
- pMsgBuffer->Write(pData, nSize);
- sal_uIntPtr nBufSize = pMsgBuffer->Tell();
-
- const sal_Char* pChar;
- const sal_Char* pOldPos;
- int status;
- for( pOldPos = pChar = static_cast<const sal_Char*>(pMsgBuffer->GetData()); nBufSize--;
- pChar++ )
- {
- if( *pChar == '\r' || *pChar == '\n' )
- {
- if( aDelim.compareTo(pOldPos, aDelim.getLength())
- != -1 &&
- aClose.compareTo(pOldPos, aClose.getLength())
- != -1 &&
- aPlainDelim.compareTo(pOldPos, aPlainDelim.getLength())
- != -1 &&
- aPlainClose.compareTo(pOldPos, aPlainClose.getLength())
- != -1 )
- {
- if( nBufSize &&
- ( pChar[1] == '\r' || pChar[1] == '\n' ) )
- nBufSize--, pChar++;
- if( pChildStrm )
- {
- status = pChildStrm->Write(
- pOldPos, pChar - pOldPos + 1 );
- if( status != INETSTREAM_STATUS_OK )
- return status;
- }
- else {
- SAL_WARN( "tools.stream", "Boundary not found." );
- }
- status = INetMessageOStream::PutMsgLine(
- pOldPos, pChar - pOldPos + 1 );
- if( status != INETSTREAM_STATUS_OK )
- return status;
- pOldPos = pChar + 1;
- }
- else
- {
- if( nBufSize &&
- ( pChar[1] == '\r' || pChar[1] == '\n' ) )
- nBufSize--, pChar++;
- pOldPos = pChar + 1;
- DELETEZ( pChildStrm );
-
- if (aClose.compareTo(pOldPos, aClose.getLength())
- != -1 &&
- aPlainClose.compareTo(pOldPos, aClose.getLength())
- != -1 )
- {
- // Encapsulated message.
- INetMIMEMessage* pNewMessage =
- new INetMIMEMessage;
- pNewMessage->SetDocumentLB(
- new SvAsyncLockBytes(
- new SvMemoryStream(), false));
-
- pMsg->AttachChild( *pNewMessage );
-
- // Encapsulated message body. Create message parser stream.
- pChildStrm = new INetMIMEMessageStream;
- pChildStrm->SetTargetMessage( pNewMessage );
-
- // Initialize control variables.
- }
- eState = INETMSG_EOL_BEGIN;
- status = INetMessageOStream::PutMsgLine(
- pOldPos, pChar - pOldPos + 1 );
- if( status != INETSTREAM_STATUS_OK )
- return status;
- }
- }
- }
- if( pOldPos < pChar )
- {
- SvMemoryStream* pNewStream = new SvMemoryStream;
- pNewStream->Write( pOldPos, pChar - pOldPos );
- SvMemoryStream* pTmp = pMsgBuffer;
- pMsgBuffer = pNewStream;
- delete pTmp;
- }
- else
- {
- pMsgBuffer->Seek( 0L );
- pMsgBuffer->SetStreamSize( 0 );
- }
- return INETSTREAM_STATUS_OK;
- }
- }
- else
- {
- /*
- * Single part message.
- * Remove any ContentTransferEncoding.
- */
- if (pMsg->GetContentType().isEmpty())
- {
- pMsg->SetContentType(pMsg->GetDefaultContentType());
- }
-
- if (eEncoding == INETMSG_ENCODING_BINARY)
- {
- OUString aEncoding(pMsg->GetContentTransferEncoding());
- if (aEncoding.startsWithIgnoreAsciiCase("base64"))
- {
- eEncoding = INETMSG_ENCODING_BASE64;
- }
- else if (aEncoding.startsWithIgnoreAsciiCase("quoted-printable"))
- {
- eEncoding = INETMSG_ENCODING_QUOTED;
- }
- else
- {
- eEncoding = INETMSG_ENCODING_7BIT;
- }
- }
-
- if (eEncoding == INETMSG_ENCODING_7BIT)
- {
- // No decoding necessary.
- return INetMessageOStream::PutMsgLine(pData, nSize);
- }
- else
- {
- if (pDecodeStrm == NULL)
- {
- if (eEncoding == INETMSG_ENCODING_QUOTED)
- {
- pDecodeStrm = new INetMessageDecodeQPStream_Impl;
- }
- else
- {
- pDecodeStrm = new INetMessageDecode64Stream_Impl;
- }
- pDecodeStrm->SetTargetMessage(pMsg);
- }
- return pDecodeStrm->Write(pData, nSize);
- }
- }
- }
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */