diff options
Diffstat (limited to 'tools/source/inet')
-rw-r--r-- | tools/source/inet/inetmime.cxx | 298 | ||||
-rw-r--r-- | tools/source/inet/inetmsg.cxx | 485 | ||||
-rw-r--r-- | tools/source/inet/inetstrm.cxx | 44 |
3 files changed, 23 insertions, 804 deletions
diff --git a/tools/source/inet/inetmime.cxx b/tools/source/inet/inetmime.cxx index 78032e7d376e..d1178f29253e 100644 --- a/tools/source/inet/inetmime.cxx +++ b/tools/source/inet/inetmime.cxx @@ -492,18 +492,6 @@ bool INetMIME::isIMAPAtomChar(sal_uInt32 nChar) //============================================================================ // static -sal_uInt32 INetMIME::getDigit(int nWeight) -{ - DBG_ASSERT(nWeight >= 0 && nWeight < 10, - "INetMIME::getDigit(): Bad weight"); - - static const sal_Char aDigits[16] - = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' }; - return aDigits[nWeight]; -} - -//============================================================================ -// static sal_uInt32 INetMIME::getHexDigit(int nWeight) { DBG_ASSERT(nWeight >= 0 && nWeight < 16, @@ -517,40 +505,6 @@ sal_uInt32 INetMIME::getHexDigit(int nWeight) //============================================================================ // static -sal_uInt32 INetMIME::getBase64Digit(int nWeight) -{ - DBG_ASSERT(nWeight >= 0 && nWeight < 64, - "INetMIME::getBase64Digit(): Bad weight"); - - static const sal_Char aDigits[64] - = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', - 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', - 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', - 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/' }; - return aDigits[nWeight]; -} - -//============================================================================ -// static -bool INetMIME::equalIgnoreCase(const sal_Char * pBegin1, - const sal_Char * pEnd1, - const sal_Char * pBegin2, - const sal_Char * pEnd2) -{ - DBG_ASSERT(pBegin1 && pBegin1 <= pEnd1 && pBegin2 && pBegin2 <= pEnd2, - "INetMIME::equalIgnoreCase(): Bad sequences"); - - if (pEnd1 - pBegin1 != pEnd2 - pBegin2) - return false; - while (pBegin1 != pEnd1) - if (toUpperCase(*pBegin1++) != toUpperCase(*pBegin2++)) - return false; - return true; -} - -//============================================================================ -// static bool INetMIME::equalIgnoreCase(const sal_Char * pBegin1, const sal_Char * pEnd1, const sal_Char * pString2) @@ -583,35 +537,6 @@ bool INetMIME::equalIgnoreCase(const sal_Unicode * pBegin1, //============================================================================ // static -const sal_Char * INetMIME::skipLinearWhiteSpace(const sal_Char * pBegin, - const sal_Char * pEnd) -{ - DBG_ASSERT(pBegin && pBegin <= pEnd, - "INetMIME::skipLinearWhiteSpace(): Bad sequence"); - - while (pBegin != pEnd) - switch (*pBegin) - { - case '\t': - case ' ': - ++pBegin; - break; - - case 0x0D: // CR - if (startsWithLineFolding(pBegin, pEnd)) - pBegin += 3; - else - return pBegin; - break; - - default: - return pBegin; - } - return pBegin; -} - -//============================================================================ -// static const sal_Unicode * INetMIME::skipLinearWhiteSpace(const sal_Unicode * pBegin, const sal_Unicode * pEnd) { @@ -842,26 +767,6 @@ const sal_Unicode * INetMIME::skipQuotedString(const sal_Unicode * pBegin, //============================================================================ // static -const sal_Char * INetMIME::scanAtom(const sal_Char * pBegin, - const sal_Char * pEnd) -{ - while (pBegin != pEnd && isAtomChar(*pBegin)) - ++pBegin; - return pBegin; -} - -//============================================================================ -// static -const sal_Unicode * INetMIME::scanAtom(const sal_Unicode * pBegin, - const sal_Unicode * pEnd) -{ - while (pBegin != pEnd && isAtomChar(*pBegin)) - ++pBegin; - return pBegin; -} - -//============================================================================ -// static bool INetMIME::scanUnsigned(const sal_Char *& rBegin, const sal_Char * pEnd, bool bLeadingZeroes, sal_uInt32 & rValue) { @@ -909,127 +814,6 @@ bool INetMIME::scanUnsigned(const sal_Unicode *& rBegin, //============================================================================ // static -bool INetMIME::scanUnsignedHex(const sal_Char *& rBegin, - const sal_Char * pEnd, bool bLeadingZeroes, - sal_uInt32 & rValue) -{ - sal_uInt64 nTheValue = 0; - const sal_Char * p = rBegin; - for ( p = rBegin; p != pEnd; ++p) - { - int nWeight = getHexWeight(*p); - if (nWeight < 0) - break; - nTheValue = nTheValue << 4 | nWeight; - if (nTheValue > std::numeric_limits< sal_uInt32 >::max()) - return false; - } - if (nTheValue == 0 && (p == rBegin || (!bLeadingZeroes && p - rBegin != 1))) - return false; - rBegin = p; - rValue = sal_uInt32(nTheValue); - return true; -} - -//============================================================================ -// static -bool INetMIME::scanUnsignedHex(const sal_Unicode *& rBegin, - const sal_Unicode * pEnd, bool bLeadingZeroes, - sal_uInt32 & rValue) -{ - sal_uInt64 nTheValue = 0; - const sal_Unicode * p = rBegin; - for ( ; p != pEnd; ++p) - { - int nWeight = getHexWeight(*p); - if (nWeight < 0) - break; - nTheValue = nTheValue << 4 | nWeight; - if (nTheValue > std::numeric_limits< sal_uInt32 >::max()) - return false; - } - if (nTheValue == 0 && (p == rBegin || (!bLeadingZeroes && p - rBegin != 1))) - return false; - rBegin = p; - rValue = sal_uInt32(nTheValue); - return true; -} - -//============================================================================ -// static -const sal_Char * INetMIME::scanQuotedBlock(const sal_Char * pBegin, - const sal_Char * pEnd, - sal_uInt32 nOpening, - sal_uInt32 nClosing, - sal_Size & rLength, - bool & rModify) -{ - DBG_ASSERT(pBegin && pBegin <= pEnd, - "INetMIME::scanQuotedBlock(): Bad sequence"); - - if (pBegin != pEnd && static_cast< unsigned char >(*pBegin) == nOpening) - { - ++rLength; - ++pBegin; - while (pBegin != pEnd) - if (static_cast< unsigned char >(*pBegin) == nClosing) - { - ++rLength; - return ++pBegin; - } - else - { - sal_uInt32 c = *pBegin++; - switch (c) - { - case 0x0D: // CR - if (pBegin != pEnd && *pBegin == 0x0A) // LF - if (pEnd - pBegin >= 2 && isWhiteSpace(pBegin[1])) - { - ++rLength; - rModify = true; - pBegin += 2; - } - else - { - rLength += 3; - rModify = true; - ++pBegin; - } - else - ++rLength; - break; - - case '\\': - ++rLength; - if (pBegin != pEnd) - { - if (startsWithLineBreak(pBegin, pEnd) - && (pEnd - pBegin < 3 - || !isWhiteSpace(pBegin[2]))) - { - rLength += 3; - rModify = true; - pBegin += 2; - } - else - ++pBegin; - } - break; - - default: - ++rLength; - if (!isUSASCII(c)) - rModify = true; - break; - } - } - } - return pBegin; -} - -//============================================================================ -// static const sal_Unicode * INetMIME::scanQuotedBlock(const sal_Unicode * pBegin, const sal_Unicode * pEnd, sal_uInt32 nOpening, @@ -1767,14 +1551,6 @@ rtl_TextEncoding INetMIME::getCharsetEncoding(sal_Char const * pBegin, //============================================================================ // static -rtl_TextEncoding INetMIME::getCharsetEncoding(sal_Unicode const * pBegin, - sal_Unicode const * pEnd) -{ - return getCharsetEncoding_Impl(pBegin, pEnd); -} - -//============================================================================ -// static INetMIMECharsetList_Impl * INetMIME::createPreferredCharsetList(rtl_TextEncoding eEncoding) { @@ -2170,80 +1946,6 @@ void INetMIME::writeUTF8(INetMIMEOutputSink & rSink, sal_uInt32 nChar) //============================================================================ // static -void INetMIME::writeUnsigned(INetMIMEOutputSink & rSink, sal_uInt32 nValue, - int nMinDigits) -{ - sal_Char aBuffer[10]; - // max unsigned 32 bit value (4294967295) has 10 places - sal_Char * p = aBuffer; - for (; nValue > 0; nValue /= 10) - *p++ = sal_Char(getDigit(nValue % 10)); - nMinDigits -= p - aBuffer; - while (nMinDigits-- > 0) - rSink << '0'; - while (p != aBuffer) - rSink << *--p; -} - -//============================================================================ -// static -void INetMIME::writeDateTime(INetMIMEOutputSink & rSink, - const DateTime & rUTC) -{ - static const sal_Char aDay[7][3] - = { { 'M', 'o', 'n' }, - { 'T', 'u', 'e' }, - { 'W', 'e', 'd' }, - { 'T', 'h', 'u' }, - { 'F', 'r', 'i' }, - { 'S', 'a', 't' }, - { 'S', 'u', 'n' } }; - const sal_Char * pTheDay = aDay[rUTC.GetDayOfWeek()]; - rSink.write(pTheDay, pTheDay + 3); - rSink << ", "; - writeUnsigned(rSink, rUTC.GetDay()); - rSink << ' '; - static const sal_Char aMonth[12][3] - = { { 'J', 'a', 'n' }, - { 'F', 'e', 'b' }, - { 'M', 'a', 'r' }, - { 'A', 'p', 'r' }, - { 'M', 'a', 'y' }, - { 'J', 'u', 'n' }, - { 'J', 'u', 'l' }, - { 'A', 'u', 'g' }, - { 'S', 'e', 'p' }, - { 'O', 'c', 't' }, - { 'N', 'o', 'v' }, - { 'D', 'e', 'c' } }; - const sal_Char * pTheMonth = aMonth[rUTC.GetMonth() - 1]; - rSink.write(pTheMonth, pTheMonth + 3); - rSink << ' '; - writeUnsigned(rSink, rUTC.GetYear()); - rSink << ' '; - writeUnsigned(rSink, rUTC.GetHour(), 2); - rSink << ':'; - writeUnsigned(rSink, rUTC.GetMin(), 2); - rSink << ':'; - writeUnsigned(rSink, rUTC.GetSec(), 2); - rSink << " +0000"; -} - -//============================================================================ -// static -void INetMIME::writeHeaderFieldBody(INetMIMEOutputSink & rSink, - HeaderFieldType eType, - const ByteString & rBody, - rtl_TextEncoding ePreferredEncoding, - bool bInitialSpace) -{ - writeHeaderFieldBody(rSink, eType, - UniString(rBody, RTL_TEXTENCODING_UTF8), - ePreferredEncoding, bInitialSpace); -} - -//============================================================================ -// static void INetMIME::writeHeaderFieldBody(INetMIMEOutputSink & rSink, HeaderFieldType eType, const UniString & rBody, diff --git a/tools/source/inet/inetmsg.cxx b/tools/source/inet/inetmsg.cxx index 2fc9f5fcb8e3..1645e9ba7aea 100644 --- a/tools/source/inet/inetmsg.cxx +++ b/tools/source/inet/inetmsg.cxx @@ -34,6 +34,7 @@ #include <tools/inetmsg.hxx> #include <tools/inetstrm.hxx> #include <rtl/instance.hxx> +#include <rtl/strbuf.hxx> #include <stdio.h> @@ -63,7 +64,6 @@ inline sal_Unicode ascii_toLowerCase( sal_Unicode ch ) * *=====================================================================*/ #define CONSTASCII_STRINGPARAM(a) (a), RTL_TEXTENCODING_ASCII_US -#define HEADERFIELD INetMessageHeader /* * ~INetMessage. @@ -79,10 +79,10 @@ INetMessage::~INetMessage (void) void INetMessage::ListCleanup_Impl (void) { // Cleanup. - sal_uIntPtr i, n = m_aHeaderList.Count(); + sal_uIntPtr i, n = m_aHeaderList.size(); for (i = 0; i < n; i++) - delete ((HEADERFIELD*)(m_aHeaderList.GetObject(i))); - m_aHeaderList.Clear(); + delete m_aHeaderList[ i ]; + m_aHeaderList.clear(); } /* @@ -99,8 +99,8 @@ void INetMessage::ListCopy (const INetMessage &rMsg) sal_uIntPtr i, n = rMsg.GetHeaderCount(); for (i = 0; i < n; i++) { - HEADERFIELD *p = (HEADERFIELD*)(rMsg.m_aHeaderList.GetObject(i)); - m_aHeaderList.Insert (new HEADERFIELD(*p), LIST_APPEND); + INetMessageHeader *p = rMsg.m_aHeaderList[ i ]; + m_aHeaderList.push_back( new INetMessageHeader(*p) ); } } } @@ -125,20 +125,6 @@ void INetMessage::SetHeaderField_Impl ( * SetHeaderField. */ sal_uIntPtr INetMessage::SetHeaderField ( - const UniString& rName, const UniString& rValue, sal_uIntPtr nIndex) -{ - sal_uIntPtr nResult = nIndex; - SetHeaderField_Impl ( - INetMIME::HEADER_FIELD_TEXT, - ByteString (rName, RTL_TEXTENCODING_ASCII_US), rValue, - nResult); - return nResult; -} - -/* - * SetHeaderField. - */ -sal_uIntPtr INetMessage::SetHeaderField ( const INetMessageHeader &rHeader, sal_uIntPtr nIndex) { sal_uIntPtr nResult = nIndex; @@ -155,11 +141,11 @@ SvStream& INetMessage::operator<< (SvStream& rStrm) const rStrm << static_cast<sal_uInt32>(m_nDocSize); rStrm.WriteByteString (m_aDocName, RTL_TEXTENCODING_UTF8); - sal_uIntPtr i, n = m_aHeaderList.Count(); + sal_uIntPtr i, n = m_aHeaderList.size(); rStrm << static_cast<sal_uInt32>(n); for (i = 0; i < n; i++) - rStrm << *((HEADERFIELD *)(m_aHeaderList.GetObject(i))); + rStrm << *( m_aHeaderList[ i ] ); return rStrm; } @@ -187,9 +173,9 @@ SvStream& INetMessage::operator>> (SvStream& rStrm) for (i = 0; i < n; i++) { - HEADERFIELD *p = new HEADERFIELD(); + INetMessageHeader *p = new INetMessageHeader(); rStrm >> *p; - m_aHeaderList.Insert (p, LIST_APPEND); + m_aHeaderList.push_back( p ); } // Done. @@ -198,34 +184,6 @@ SvStream& INetMessage::operator>> (SvStream& rStrm) /*======================================================================= * - * INetMessageHeaderIterator Implementation. - * - *=====================================================================*/ -INetMessageHeaderIterator::INetMessageHeaderIterator ( - const INetMessage& rMsg, const UniString& rHdrName) -{ - sal_uIntPtr i, n = rMsg.GetHeaderCount(); - for (i = 0; i < n; i++) - { - if (rHdrName.CompareIgnoreCaseToAscii (rMsg.GetHeaderName(i)) == 0) - { - UniString *pValue = new UniString (rMsg.GetHeaderValue(i)); - aValueList.Insert (pValue, LIST_APPEND); - } - } - nValueCount = aValueList.Count(); -} - -INetMessageHeaderIterator::~INetMessageHeaderIterator (void) -{ - sal_uIntPtr i, n = aValueList.Count(); - for (i = 0; i < n; i++) - delete ((UniString*)(aValueList.GetObject(i))); - aValueList.Clear(); -} - -/*======================================================================= - * * INetRFC822Message Implementation. * *=====================================================================*/ @@ -324,13 +282,8 @@ INetRFC822Message::~INetRFC822Message (void) } /* - * <Generate|Parse>DateField and local helper functions. - * - * GenerateDateField. - * Generates a String from Date and Time objects in format: - * Wkd, 00 Mon 0000 00:00:00 [GMT] (rfc822, rfc1123) + * ParseDateField and local helper functions. * - * ParseDateField. * Parses a String in (implied) GMT format into class Date and Time objects. * Four formats are accepted: * @@ -349,62 +302,6 @@ static const sal_Char *months[12] = "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; -static const sal_Char *wkdays[7] = -{ - "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" -}; - -/* - * GenerateDateField. - */ -sal_Bool INetRFC822Message::GenerateDateField ( - const DateTime& rDateTime, UniString& rDateFieldW) -{ - // Check arguments. - if (!rDateTime.IsValid() || - (rDateTime.GetSec() > 59) || - (rDateTime.GetMin() > 59) || - (rDateTime.GetHour() > 23) ) return sal_False; - - // Prepare output string. - ByteString rDateField; - - // Insert Date. - rDateField += wkdays[(sal_uInt16)(rDateTime.GetDayOfWeek())]; - rDateField += ", "; - - sal_uInt16 nNum = rDateTime.GetDay(); - if (nNum < 10) rDateField += '0'; - rDateField += ByteString::CreateFromInt32(nNum); - rDateField += ' '; - - rDateField += months[(sal_uInt16)(rDateTime.GetMonth() - 1)]; - rDateField += ' '; - - rDateField += ByteString::CreateFromInt32(rDateTime.GetYear()); - rDateField += ' '; - - // Insert Time. - nNum = rDateTime.GetHour(); - if (nNum < 10) rDateField += '0'; - rDateField += ByteString::CreateFromInt32(nNum); - rDateField += ':'; - - nNum = rDateTime.GetMin(); - if (nNum < 10) rDateField += '0'; - rDateField += ByteString::CreateFromInt32(nNum); - rDateField += ':'; - - nNum = rDateTime.GetSec(); - if (nNum < 10) rDateField += '0'; - rDateField += ByteString::CreateFromInt32(nNum); - rDateField += " GMT"; - - // Done. - rDateFieldW = UniString (rDateField, RTL_TEXTENCODING_ASCII_US); - return sal_True; -} - /* * ParseDateField and local helper functions. */ @@ -761,7 +658,7 @@ sal_uIntPtr INetRFC822Message::SetHeaderField ( case INETMSG_RFC822_OK: pData = pStop; SetHeaderField_Impl ( - HEADERFIELD (HDR(nIdx), rHeader.GetValue()), + INetMessageHeader (HDR(nIdx), rHeader.GetValue()), m_nIndex[nIdx]); nNewIndex = m_nIndex[nIdx]; break; @@ -776,129 +673,6 @@ sal_uIntPtr INetRFC822Message::SetHeaderField ( } /* - * Specific Set-Methods. - */ -void INetRFC822Message::SetBCC (const UniString& rBCC) -{ - SetHeaderField_Impl ( - INetMIME::HEADER_FIELD_ADDRESS, - HDR(INETMSG_RFC822_BCC), rBCC, - m_nIndex[INETMSG_RFC822_BCC]); -} - -void INetRFC822Message::SetCC (const UniString& rCC) -{ - SetHeaderField_Impl ( - INetMIME::HEADER_FIELD_ADDRESS, - HDR(INETMSG_RFC822_CC), rCC, - m_nIndex[INETMSG_RFC822_CC]); -} - -void INetRFC822Message::SetComments (const UniString& rComments) -{ - SetHeaderField_Impl ( - INetMIME::HEADER_FIELD_TEXT, - HDR(INETMSG_RFC822_COMMENTS), rComments, - m_nIndex[INETMSG_RFC822_COMMENTS]); -} - -void INetRFC822Message::SetDate (const UniString& rDate) -{ - SetHeaderField_Impl ( - INetMIME::HEADER_FIELD_STRUCTURED, - HDR(INETMSG_RFC822_DATE), rDate, - m_nIndex[INETMSG_RFC822_DATE]); -} - -void INetRFC822Message::SetFrom (const UniString& rFrom) -{ - SetHeaderField_Impl ( - INetMIME::HEADER_FIELD_ADDRESS, - HDR(INETMSG_RFC822_FROM), rFrom, - m_nIndex[INETMSG_RFC822_FROM]); -} - -void INetRFC822Message::SetInReplyTo (const UniString& rInReplyTo) -{ - SetHeaderField_Impl ( - INetMIME::HEADER_FIELD_ADDRESS, // ??? MESSAGE_ID ??? - HDR(INETMSG_RFC822_IN_REPLY_TO), rInReplyTo, - m_nIndex[INETMSG_RFC822_IN_REPLY_TO]); -} - -void INetRFC822Message::SetKeywords (const UniString& rKeywords) -{ - SetHeaderField_Impl ( - INetMIME::HEADER_FIELD_PHRASE, - HDR(INETMSG_RFC822_KEYWORDS), rKeywords, - m_nIndex[INETMSG_RFC822_KEYWORDS]); -} - -void INetRFC822Message::SetMessageID (const UniString& rMessageID) -{ - SetHeaderField_Impl ( - INetMIME::HEADER_FIELD_MESSAGE_ID, - HDR(INETMSG_RFC822_MESSAGE_ID), rMessageID, - m_nIndex[INETMSG_RFC822_MESSAGE_ID]); -} - -void INetRFC822Message::SetReferences (const UniString& rReferences) -{ - SetHeaderField_Impl ( - INetMIME::HEADER_FIELD_MESSAGE_ID, - HDR(INETMSG_RFC822_REFERENCES), rReferences, - m_nIndex[INETMSG_RFC822_REFERENCES]); -} - -void INetRFC822Message::SetReplyTo (const UniString& rReplyTo) -{ - SetHeaderField_Impl ( - INetMIME::HEADER_FIELD_ADDRESS, - HDR(INETMSG_RFC822_REPLY_TO), rReplyTo, - m_nIndex[INETMSG_RFC822_REPLY_TO]); -} - -void INetRFC822Message::SetReturnPath (const UniString& rReturnPath) -{ - SetHeaderField_Impl ( - INetMIME::HEADER_FIELD_ADDRESS, - HDR(INETMSG_RFC822_RETURN_PATH), rReturnPath, - m_nIndex[INETMSG_RFC822_RETURN_PATH]); -} - -void INetRFC822Message::SetReturnReceiptTo (const UniString& rValue) -{ - SetHeaderField_Impl ( - INetMIME::HEADER_FIELD_ADDRESS, - HDR(INETMSG_RFC822_RETURN_RECEIPT_TO), rValue, - m_nIndex[INETMSG_RFC822_RETURN_RECEIPT_TO]); -} - -void INetRFC822Message::SetSender (const UniString& rSender) -{ - SetHeaderField_Impl ( - INetMIME::HEADER_FIELD_ADDRESS, - HDR(INETMSG_RFC822_SENDER), rSender, - m_nIndex[INETMSG_RFC822_SENDER]); -} - -void INetRFC822Message::SetSubject (const UniString& rSubject) -{ - SetHeaderField_Impl ( - INetMIME::HEADER_FIELD_TEXT, - HDR(INETMSG_RFC822_SUBJECT), rSubject, - m_nIndex[INETMSG_RFC822_SUBJECT]); -} - -void INetRFC822Message::SetTo (const UniString& rTo) -{ - SetHeaderField_Impl ( - INetMIME::HEADER_FIELD_ADDRESS, - HDR(INETMSG_RFC822_TO), rTo, - m_nIndex[INETMSG_RFC822_TO]); -} - -/* * operator<< */ SvStream& INetRFC822Message::operator<< (SvStream& rStrm) const @@ -982,7 +756,6 @@ enum _ImplINetMIMEMessageHeaderState INetMIMEMessage::INetMIMEMessage (void) : INetRFC822Message (), pParent (NULL), - nNumChildren (0), bHeaderParsed (sal_False) { for (sal_uInt16 i = 0; i < INETMSG_MIME_NUMHDR; i++) @@ -1030,9 +803,10 @@ INetMIMEMessage::~INetMIMEMessage (void) */ void INetMIMEMessage::CleanupImp (void) { - INetMIMEMessage *pChild = NULL; - while ((pChild = (INetMIMEMessage *)(aChildren.Remove())) != NULL) - if (pChild->pParent == this) delete pChild; + for( size_t i = 0, n = aChildren.size(); i < n; ++i ) { + delete aChildren[ i ]; + } + aChildren.clear(); } /* @@ -1042,24 +816,22 @@ void INetMIMEMessage::CopyImp (const INetMIMEMessage& rMsg) { bHeaderParsed = rMsg.bHeaderParsed; - sal_uInt16 i; + size_t i; for (i = 0; i < INETMSG_MIME_NUMHDR; i++) m_nIndex[i] = rMsg.m_nIndex[i]; m_aBoundary = rMsg.m_aBoundary; - nNumChildren = rMsg.nNumChildren; - for (i = 0; i < rMsg.aChildren.Count(); i++) + for (i = 0; i < rMsg.aChildren.size(); i++) { - INetMIMEMessage *pChild = - (INetMIMEMessage *)(rMsg.aChildren.GetObject (i)); + INetMIMEMessage *pChild = rMsg.aChildren[ i ]; if (pChild->pParent == &rMsg) { pChild = pChild->CreateMessage (*pChild); pChild->pParent = this; } - aChildren.Insert (pChild, LIST_APPEND); + aChildren.push_back( pChild ); } } @@ -1207,7 +979,7 @@ sal_uIntPtr INetMIMEMessage::SetHeaderField ( case INETMSG_MIME_OK: pData = pStop; SetHeaderField_Impl ( - HEADERFIELD (MIMEHDR(nIdx), rHeader.GetValue()), + INetMessageHeader (MIMEHDR(nIdx), rHeader.GetValue()), m_nIndex[nIdx]); nNewIndex = m_nIndex[nIdx]; break; @@ -1233,14 +1005,6 @@ void INetMIMEMessage::SetMIMEVersion (const UniString& rVersion) m_nIndex[INETMSG_MIME_VERSION]); } -void INetMIMEMessage::SetContentDescription (const String& rDescription) -{ - SetHeaderField_Impl ( - INetMIME::HEADER_FIELD_TEXT, - MIMEHDR(INETMSG_MIME_CONTENT_DESCRIPTION), rDescription, - m_nIndex[INETMSG_MIME_CONTENT_DESCRIPTION]); -} - void INetMIMEMessage::SetContentDisposition (const String& rDisposition) { SetHeaderField_Impl ( @@ -1249,14 +1013,6 @@ void INetMIMEMessage::SetContentDisposition (const String& rDisposition) m_nIndex[INETMSG_MIME_CONTENT_DISPOSITION]); } -void INetMIMEMessage::SetContentID (const String& rID) -{ - SetHeaderField_Impl ( - INetMIME::HEADER_FIELD_TEXT, - MIMEHDR(INETMSG_MIME_CONTENT_ID), rID, - m_nIndex[INETMSG_MIME_CONTENT_ID]); -} - void INetMIMEMessage::SetContentType (const String& rType) { SetHeaderField_Impl ( @@ -1388,202 +1144,8 @@ sal_Bool INetMIMEMessage::AttachChild ( if (IsContainer() /*&& rChildMsg.GetContentType().Len() */) { if (bOwner) rChildMsg.pParent = this; - aChildren.Insert (&rChildMsg, LIST_APPEND); - nNumChildren = aChildren.Count(); - - return sal_True; - } - return sal_False; -} - -/* - * DetachChild. - */ -sal_Bool INetMIMEMessage::DetachChild ( - sal_uIntPtr nIndex, INetMIMEMessage& rChildMsg) const -{ - if (IsContainer()) - { - // Check document stream. - if (GetDocumentLB() == NULL) return sal_False; - SvStream *pDocStrm = new SvStream (GetDocumentLB()); - - // Initialize message buffer. - char pMsgBuffer[1024]; - char *pMsgRead, *pMsgWrite; - pMsgRead = pMsgWrite = pMsgBuffer; - - // Initialize message parser stream. - INetMIMEMessageStream *pMsgStrm = NULL; - - // Check for "multipart/uvw" or "message/xyz". - if (IsMultipart()) - { - // Multipart message body. Initialize multipart delimiters. - ByteString aDelim ("--"); - aDelim += GetMultipartBoundary(); - ByteString aClose = aDelim; - aClose += "--"; - - // Initialize line buffer. - SvMemoryStream aLineBuf; - - // Initialize control variables. - INetMessageStreamState eState = INETMSG_EOL_SCR; - int nCurIndex = -1; - - // Go! - while (nCurIndex < (int)(nIndex + 1)) - { - if ((pMsgRead - pMsgWrite) > 0) - { - // Bytes still in buffer. - if (eState == INETMSG_EOL_FCR) - { - // Check for 2nd line break character. - if ((*pMsgWrite == '\r') || (*pMsgWrite == '\n')) - aLineBuf << *pMsgWrite++; - - // Check current index. - if (nCurIndex == (int)nIndex) - { - // Found requested part. - if (pMsgStrm == NULL) - { - // Create message parser stream. - pMsgStrm = new INetMIMEMessageStream; - pMsgStrm->SetTargetMessage (&rChildMsg); - } - - // Put message down-stream. - int status = pMsgStrm->Write ( - (const sal_Char *) aLineBuf.GetData(), aLineBuf.Tell()); - if (status != INETSTREAM_STATUS_OK) - { - // Cleanup. - delete pDocStrm; - delete pMsgStrm; - - // Finish. - return (!(status == INETSTREAM_STATUS_OK)); - } - } - - // Reset to <Begin-of-Line>. - aLineBuf.Seek (STREAM_SEEK_TO_BEGIN); - eState = INETMSG_EOL_SCR; - } - else if ((*pMsgWrite == '\r') || (*pMsgWrite == '\n')) - { - /* - * Found any line break character. - * Compare buffered line with part/close delimiter. - * Increment current part index upon match. - */ - sal_uInt16 nLen = (sal_uInt16)(aLineBuf.Tell() & 0xffff); - if (nLen == aDelim.Len()) - { - if (aDelim.CompareTo ((const sal_Char *) aLineBuf.GetData(), nLen) - == COMPARE_EQUAL) nCurIndex++; - } - else if (nLen == aClose.Len()) - { - if (aClose.CompareTo ((const sal_Char *) aLineBuf.GetData(), nLen) - == COMPARE_EQUAL) nCurIndex++; - } - aLineBuf << *pMsgWrite++; - eState = INETMSG_EOL_FCR; - } - else - { - // Insert into line buffer. - aLineBuf << *pMsgWrite; - } - } - else - { - // Buffer empty. Reset to <Begin-of-Buffer>. - pMsgRead = pMsgWrite = pMsgBuffer; - - // Read document stream. - sal_uIntPtr nRead = pDocStrm->Read ( - pMsgBuffer, sizeof (pMsgBuffer)); - if (nRead > 0) - { - // Set read pointer. - pMsgRead += nRead; - } - else - { - // Premature end. - if (pMsgStrm) - { - // Assume end of requested part. - nCurIndex++; - } - else - { - // Requested part not found. - delete pDocStrm; - return sal_False; - } - } - } - } // while (nCurIndex < (nIndex + 1)) - } - else - { - // Encapsulated message body. Create message parser stream. - pMsgStrm = new INetMIMEMessageStream; - pMsgStrm->SetTargetMessage (&rChildMsg); - - // Initialize control variables. - INetMessageStreamState eState = INETMSG_EOL_BEGIN; - - // Go. - while (eState == INETMSG_EOL_BEGIN) - { - if ((pMsgRead - pMsgWrite) > 0) - { - // Bytes still in buffer. Put message down-stream. - int status = pMsgStrm->Write ( - pMsgBuffer, (pMsgRead - pMsgWrite)); - if (status != INETSTREAM_STATUS_OK) - { - // Cleanup. - delete pDocStrm; - delete pMsgStrm; - - // Finish. - return (!(status == INETSTREAM_STATUS_ERROR)); - } - pMsgWrite = pMsgBuffer + (pMsgRead - pMsgWrite); - } - else - { - // Buffer empty. Reset to <Begin-of-Buffer>. - pMsgRead = pMsgWrite = pMsgBuffer; - - // Read document stream. - sal_uIntPtr nRead = pDocStrm->Read ( - pMsgBuffer, sizeof (pMsgBuffer)); - if (nRead > 0) - { - // Set read pointer. - pMsgRead += nRead; - } - else - { - // Mark we're done. - eState = INETMSG_EOL_DONE; - } - } - } // while (eState == INETMSG_EOL_BEGIN) - } + aChildren.push_back( &rChildMsg ); - // Done. - if (pDocStrm) delete pDocStrm; - if (pMsgStrm) delete pMsgStrm; return sal_True; } return sal_False; @@ -1604,7 +1166,7 @@ SvStream& INetMIMEMessage::operator<< (SvStream& rStrm) const #else rStrm.WriteByteString (m_aBoundary); #endif - rStrm << static_cast<sal_uInt32>(nNumChildren); + rStrm << static_cast<sal_uInt32>(aChildren.size()); return rStrm; } @@ -1629,7 +1191,6 @@ SvStream& INetMIMEMessage::operator>> (SvStream& rStrm) rStrm.ReadByteString (m_aBoundary); #endif rStrm >> nTemp; - nNumChildren = nTemp; return rStrm; } diff --git a/tools/source/inet/inetstrm.cxx b/tools/source/inet/inetstrm.cxx index 07d404b090ad..7a04ea24af20 100644 --- a/tools/source/inet/inetstrm.cxx +++ b/tools/source/inet/inetstrm.cxx @@ -173,48 +173,6 @@ int INetIStream::Read (sal_Char *pData, sal_uIntPtr nSize) return GetData (pData, nSize); } -/* - * Decode64. - */ -void INetIStream::Decode64 (SvStream& rIn, SvStream& rOut) -{ - INetMessage aMsg; - aMsg.SetDocumentLB(new SvAsyncLockBytes(&rOut, sal_False)); - - INetMessageDecode64Stream_Impl aStream (8192); - aStream.SetTargetMessage (&aMsg); - - sal_Char* pBuf = new sal_Char[8192]; - - int nRead = 0; - while ((nRead = rIn.Read (pBuf, 8192)) > 0) - aStream.Write( pBuf, nRead ); - aStream.Write ("\r\n", 2); - - delete[] pBuf; -} - -/* - * Encode64. - */ -void INetIStream::Encode64 (SvStream& rIn, SvStream& rOut) -{ - INetMessage aMsg; - aMsg.SetDocumentLB ( - new SvLockBytes (&rIn, sal_False)); - - INetMessageEncode64Stream_Impl aStream (8192); - aStream.SetSourceMessage (&aMsg); - - sal_Char* pBuf = new sal_Char[8192]; - - int nRead = 0; - while ((nRead = aStream.Read (pBuf, 8192)) > 0) - rOut.Write( pBuf, nRead ); - - delete[] pBuf; -} - /*========================================================================= * * INetOStream Implementation. @@ -1621,7 +1579,6 @@ int INetMIMEMessageStream::PutMsgLine (const sal_Char *pData, sal_uIntPtr nSize) if( !pChildStrm ) { // Encapsulated message. - pMsg->SetChildCount( pMsg->GetChildCount() + 1); INetMIMEMessage* pNewMessage = new INetMIMEMessage; pNewMessage->SetDocumentLB ( new SvAsyncLockBytes(new SvCacheStream, sal_False)); @@ -1731,7 +1688,6 @@ int INetMIMEMessageStream::PutMsgLine (const sal_Char *pData, sal_uIntPtr nSize) != COMPARE_EQUAL ) { // Encapsulated message. - pMsg->SetChildCount(pMsg->GetChildCount() + 1); INetMIMEMessage* pNewMessage = new INetMIMEMessage; pNewMessage->SetDocumentLB ( |