Fold INetRFC822Message into INetMIMEMessage

Change-Id: I9b02b8f758c3f0613a7b017d8822fc16ebfc9dec
This commit is contained in:
Stephan Bergmann
2015-02-11 16:14:14 +01:00
parent 3939b6d64d
commit ca6be614e2
6 changed files with 169 additions and 268 deletions

View File

@@ -99,7 +99,29 @@ typedef ::std::vector< INetMessageHeader* > HeaderList_impl;
#define INETMSG_RFC822_RETURN_RECEIPT_TO 15 #define INETMSG_RFC822_RETURN_RECEIPT_TO 15
#define INETMSG_RFC822_NUMHDR 16 #define INETMSG_RFC822_NUMHDR 16
class TOOLS_DLLPUBLIC INetRFC822Message #define INETMSG_MIME_VERSION 0
#define INETMSG_MIME_CONTENT_DESCRIPTION 1
#define INETMSG_MIME_CONTENT_DISPOSITION 2
#define INETMSG_MIME_CONTENT_ID 3
#define INETMSG_MIME_CONTENT_TYPE 4
#define INETMSG_MIME_CONTENT_TRANSFER_ENCODING 5
#define INETMSG_MIME_NUMHDR 6
enum INetMessageContainerType
{
INETMSG_MESSAGE_RFC822,
INETMSG_MULTIPART_MIXED,
INETMSG_MULTIPART_ALTERNATIVE,
INETMSG_MULTIPART_DIGEST,
INETMSG_MULTIPART_PARALLEL,
INETMSG_MULTIPART_RELATED,
INETMSG_MULTIPART_FORM_DATA
};
class INetMIMEMessage;
typedef ::std::vector< INetMIMEMessage* > INetMIMEMessgeList_impl;
class TOOLS_DLLPUBLIC INetMIMEMessage
{ {
HeaderList_impl m_aHeaderList; HeaderList_impl m_aHeaderList;
@@ -108,11 +130,25 @@ class TOOLS_DLLPUBLIC INetRFC822Message
SvLockBytesRef m_xDocLB; SvLockBytesRef m_xDocLB;
void ListCleanup_Impl(); void ListCleanup_Impl();
void ListCopy (const INetRFC822Message& rMsg); void ListCopy (const INetMIMEMessage& rMsg);
sal_uIntPtr m_nIndex[INETMSG_RFC822_NUMHDR]; sal_uIntPtr m_nRFC822Index[INETMSG_RFC822_NUMHDR];
sal_uIntPtr m_nMIMEIndex[INETMSG_MIME_NUMHDR];
INetMIMEMessage* pParent;
INetMIMEMessgeList_impl aChildren;
OString m_aBoundary;
bool bHeaderParsed;
friend class INetMIMEMessageStream;
const OString& GetMultipartBoundary() const { return m_aBoundary; }
void SetMultipartBoundary (const OString& rBnd) { m_aBoundary = rBnd; }
void CleanupImp();
void CopyImp (const INetMIMEMessage& rMsg);
void SetHeaderParsed() { bHeaderParsed = true; }
protected:
OUString GetHeaderName_Impl ( OUString GetHeaderName_Impl (
sal_uIntPtr nIndex, rtl_TextEncoding eEncoding) const sal_uIntPtr nIndex, rtl_TextEncoding eEncoding) const
{ {
@@ -155,15 +191,15 @@ protected:
const OUString &rValue, const OUString &rValue,
sal_uIntPtr &rnIndex); sal_uIntPtr &rnIndex);
virtual SvStream& operator<< (SvStream& rStrm) const; sal_uIntPtr SetRFC822HeaderField (
virtual SvStream& operator>> (SvStream& rStrm); const INetMessageHeader &rHeader, sal_uIntPtr nNewIndex);
public: public:
INetRFC822Message(); INetMIMEMessage();
INetRFC822Message (const INetRFC822Message& rMsg); INetMIMEMessage (const INetMIMEMessage& rMsg);
virtual ~INetRFC822Message(); ~INetMIMEMessage();
INetRFC822Message& operator= (const INetRFC822Message& rMsg); INetMIMEMessage& operator= (const INetMIMEMessage& rMsg);
sal_uIntPtr GetHeaderCount() const { return m_aHeaderList.size(); } sal_uIntPtr GetHeaderCount() const { return m_aHeaderList.size(); }
@@ -186,7 +222,7 @@ public:
} }
} }
virtual sal_uIntPtr SetHeaderField ( sal_uIntPtr SetHeaderField (
const INetMessageHeader &rField, const INetMessageHeader &rField,
sal_uIntPtr nIndex = ((sal_uIntPtr)-1) sal_uIntPtr nIndex = ((sal_uIntPtr)-1)
); );
@@ -203,235 +239,150 @@ public:
static bool ParseDateField ( static bool ParseDateField (
const OUString& rDateField, DateTime& rDateTime); const OUString& rDateField, DateTime& rDateTime);
bool HeaderParsed() const { return bHeaderParsed; }
INetMIMEMessage* CreateMessage (
const INetMIMEMessage& rMsg) const;
// Header fields. // Header fields.
OUString GetBCC() const OUString GetBCC() const
{ {
return GetHeaderValue_Impl ( return GetHeaderValue_Impl (
m_nIndex[INETMSG_RFC822_BCC], m_nRFC822Index[INETMSG_RFC822_BCC],
INetMIME::HEADER_FIELD_ADDRESS); INetMIME::HEADER_FIELD_ADDRESS);
} }
OUString GetCC() const OUString GetCC() const
{ {
return GetHeaderValue_Impl ( return GetHeaderValue_Impl (
m_nIndex[INETMSG_RFC822_CC], m_nRFC822Index[INETMSG_RFC822_CC],
INetMIME::HEADER_FIELD_ADDRESS); INetMIME::HEADER_FIELD_ADDRESS);
} }
OUString GetComments() const OUString GetComments() const
{ {
return GetHeaderValue_Impl ( return GetHeaderValue_Impl (
m_nIndex[INETMSG_RFC822_COMMENTS], m_nRFC822Index[INETMSG_RFC822_COMMENTS],
INetMIME::HEADER_FIELD_TEXT); INetMIME::HEADER_FIELD_TEXT);
} }
OUString GetDate() const OUString GetDate() const
{ {
return GetHeaderValue_Impl ( return GetHeaderValue_Impl (
m_nIndex[INETMSG_RFC822_DATE], m_nRFC822Index[INETMSG_RFC822_DATE],
INetMIME::HEADER_FIELD_STRUCTURED); INetMIME::HEADER_FIELD_STRUCTURED);
} }
OUString GetFrom() const OUString GetFrom() const
{ {
return GetHeaderValue_Impl ( return GetHeaderValue_Impl (
m_nIndex[INETMSG_RFC822_FROM], m_nRFC822Index[INETMSG_RFC822_FROM],
INetMIME::HEADER_FIELD_ADDRESS); INetMIME::HEADER_FIELD_ADDRESS);
} }
OUString GetInReplyTo() const OUString GetInReplyTo() const
{ {
return GetHeaderValue_Impl ( return GetHeaderValue_Impl (
m_nIndex[INETMSG_RFC822_IN_REPLY_TO], m_nRFC822Index[INETMSG_RFC822_IN_REPLY_TO],
INetMIME::HEADER_FIELD_ADDRESS); // ??? MESSAGE_ID ??? INetMIME::HEADER_FIELD_ADDRESS); // ??? MESSAGE_ID ???
} }
OUString GetKeywords() const OUString GetKeywords() const
{ {
return GetHeaderValue_Impl ( return GetHeaderValue_Impl (
m_nIndex[INETMSG_RFC822_KEYWORDS], m_nRFC822Index[INETMSG_RFC822_KEYWORDS],
INetMIME::HEADER_FIELD_PHRASE); INetMIME::HEADER_FIELD_PHRASE);
} }
OUString GetMessageID() const OUString GetMessageID() const
{ {
return GetHeaderValue_Impl ( return GetHeaderValue_Impl (
m_nIndex[INETMSG_RFC822_MESSAGE_ID], m_nRFC822Index[INETMSG_RFC822_MESSAGE_ID],
INetMIME::HEADER_FIELD_MESSAGE_ID); INetMIME::HEADER_FIELD_MESSAGE_ID);
} }
OUString GetReferences() const OUString GetReferences() const
{ {
return GetHeaderValue_Impl ( return GetHeaderValue_Impl (
m_nIndex[INETMSG_RFC822_REFERENCES], m_nRFC822Index[INETMSG_RFC822_REFERENCES],
INetMIME::HEADER_FIELD_ADDRESS); INetMIME::HEADER_FIELD_ADDRESS);
} }
OUString GetReplyTo() const OUString GetReplyTo() const
{ {
return GetHeaderValue_Impl ( return GetHeaderValue_Impl (
m_nIndex[INETMSG_RFC822_REPLY_TO], m_nRFC822Index[INETMSG_RFC822_REPLY_TO],
INetMIME::HEADER_FIELD_ADDRESS); INetMIME::HEADER_FIELD_ADDRESS);
} }
OUString GetReturnPath() const OUString GetReturnPath() const
{ {
return GetHeaderValue_Impl ( return GetHeaderValue_Impl (
m_nIndex[INETMSG_RFC822_RETURN_PATH], m_nRFC822Index[INETMSG_RFC822_RETURN_PATH],
INetMIME::HEADER_FIELD_ADDRESS); INetMIME::HEADER_FIELD_ADDRESS);
} }
OUString GetReturnReceiptTo() const OUString GetReturnReceiptTo() const
{ {
return GetHeaderValue_Impl ( return GetHeaderValue_Impl (
m_nIndex[INETMSG_RFC822_RETURN_RECEIPT_TO], m_nRFC822Index[INETMSG_RFC822_RETURN_RECEIPT_TO],
INetMIME::HEADER_FIELD_ADDRESS); INetMIME::HEADER_FIELD_ADDRESS);
} }
OUString GetSender() const OUString GetSender() const
{ {
return GetHeaderValue_Impl ( return GetHeaderValue_Impl (
m_nIndex[INETMSG_RFC822_SENDER], m_nRFC822Index[INETMSG_RFC822_SENDER],
INetMIME::HEADER_FIELD_ADDRESS); INetMIME::HEADER_FIELD_ADDRESS);
} }
OUString GetSubject() const OUString GetSubject() const
{ {
return GetHeaderValue_Impl ( return GetHeaderValue_Impl (
m_nIndex[INETMSG_RFC822_SUBJECT], m_nRFC822Index[INETMSG_RFC822_SUBJECT],
INetMIME::HEADER_FIELD_TEXT); INetMIME::HEADER_FIELD_TEXT);
} }
OUString GetTo() const OUString GetTo() const
{ {
return GetHeaderValue_Impl ( return GetHeaderValue_Impl (
m_nIndex[INETMSG_RFC822_TO], m_nRFC822Index[INETMSG_RFC822_TO],
INetMIME::HEADER_FIELD_TEXT); INetMIME::HEADER_FIELD_TEXT);
} }
// Stream operators.
friend SvStream& WriteINetMessage(
SvStream& rStrm, const INetRFC822Message& rMsg)
{
return rMsg.operator<< (rStrm);
}
friend SvStream& ReadINetMessage (
SvStream& rStrm, INetRFC822Message& rMsg)
{
return rMsg.operator>> (rStrm);
}
friend SvStream& operator<< (
SvStream& rStrm, const INetRFC822Message& rMsg)
{
return rMsg.operator<< (rStrm);
}
friend SvStream& operator>> (
SvStream& rStrm, INetRFC822Message& rMsg)
{
return rMsg.operator>> (rStrm);
}
};
#define INETMSG_MIME_VERSION 0
#define INETMSG_MIME_CONTENT_DESCRIPTION 1
#define INETMSG_MIME_CONTENT_DISPOSITION 2
#define INETMSG_MIME_CONTENT_ID 3
#define INETMSG_MIME_CONTENT_TYPE 4
#define INETMSG_MIME_CONTENT_TRANSFER_ENCODING 5
#define INETMSG_MIME_NUMHDR 6
enum INetMessageContainerType
{
INETMSG_MESSAGE_RFC822,
INETMSG_MULTIPART_MIXED,
INETMSG_MULTIPART_ALTERNATIVE,
INETMSG_MULTIPART_DIGEST,
INETMSG_MULTIPART_PARALLEL,
INETMSG_MULTIPART_RELATED,
INETMSG_MULTIPART_FORM_DATA
};
class INetMIMEMessage;
typedef ::std::vector< INetMIMEMessage* > INetMIMEMessgeList_impl;
class TOOLS_DLLPUBLIC INetMIMEMessage : public INetRFC822Message
{
sal_uIntPtr m_nIndex[INETMSG_MIME_NUMHDR];
INetMIMEMessage* pParent;
INetMIMEMessgeList_impl aChildren;
OString m_aBoundary;
bool bHeaderParsed;
friend class INetMIMEMessageStream;
const OString& GetMultipartBoundary() const { return m_aBoundary; }
void SetMultipartBoundary (const OString& rBnd) { m_aBoundary = rBnd; }
void CleanupImp();
void CopyImp (const INetMIMEMessage& rMsg);
void SetHeaderParsed() { bHeaderParsed = true; }
protected:
virtual SvStream& operator<< (SvStream& rStrm) const SAL_OVERRIDE;
virtual SvStream& operator>> (SvStream& rStrm) SAL_OVERRIDE;
public:
INetMIMEMessage();
INetMIMEMessage (const INetMIMEMessage& rMsg);
virtual ~INetMIMEMessage();
INetMIMEMessage& operator= (const INetMIMEMessage& rMsg);
bool HeaderParsed() const { return bHeaderParsed; }
INetMIMEMessage* CreateMessage (
const INetMIMEMessage& rMsg) const;
using INetRFC822Message::SetHeaderField;
virtual sal_uIntPtr SetHeaderField (
const INetMessageHeader &rHeader,
sal_uIntPtr nIndex = ((sal_uIntPtr)-1)
) SAL_OVERRIDE;
// Header fields.
void SetMIMEVersion (const OUString& rVersion); void SetMIMEVersion (const OUString& rVersion);
OUString GetMIMEVersion() const OUString GetMIMEVersion() const
{ {
return GetHeaderValue (m_nIndex[INETMSG_MIME_VERSION]); return GetHeaderValue (m_nMIMEIndex[INETMSG_MIME_VERSION]);
} }
OUString GetContentDescription() const OUString GetContentDescription() const
{ {
return GetHeaderValue (m_nIndex[INETMSG_MIME_CONTENT_DESCRIPTION]); return GetHeaderValue (m_nMIMEIndex[INETMSG_MIME_CONTENT_DESCRIPTION]);
} }
void SetContentDisposition (const OUString& rDisposition); void SetContentDisposition (const OUString& rDisposition);
OUString GetContentDisposition() const OUString GetContentDisposition() const
{ {
return GetHeaderValue (m_nIndex[INETMSG_MIME_CONTENT_DISPOSITION]); return GetHeaderValue (m_nMIMEIndex[INETMSG_MIME_CONTENT_DISPOSITION]);
} }
OUString GetContentID() const OUString GetContentID() const
{ {
return GetHeaderValue (m_nIndex[INETMSG_MIME_CONTENT_ID]); return GetHeaderValue (m_nMIMEIndex[INETMSG_MIME_CONTENT_ID]);
} }
void SetContentType (const OUString& rType); void SetContentType (const OUString& rType);
OUString GetContentType() const OUString GetContentType() const
{ {
return GetHeaderValue (m_nIndex[INETMSG_MIME_CONTENT_TYPE]); return GetHeaderValue (m_nMIMEIndex[INETMSG_MIME_CONTENT_TYPE]);
} }
void SetContentTransferEncoding (const OUString& rEncoding); void SetContentTransferEncoding (const OUString& rEncoding);
OUString GetContentTransferEncoding() const OUString GetContentTransferEncoding() const
{ {
return GetHeaderValue (m_nIndex[INETMSG_MIME_CONTENT_TRANSFER_ENCODING]); return GetHeaderValue (m_nMIMEIndex[INETMSG_MIME_CONTENT_TRANSFER_ENCODING]);
} }
OUString GetDefaultContentType (); OUString GetDefaultContentType ();
@@ -466,17 +417,9 @@ public:
// Stream operators. // Stream operators.
friend SvStream& operator<< ( friend SvStream& operator <<(SvStream& rStrm, const INetMIMEMessage& rMsg);
SvStream& rStrm, const INetMIMEMessage& rMsg)
{
return rMsg.operator<< (rStrm);
}
friend SvStream& operator>> ( friend SvStream& operator >>(SvStream& rStrm, INetMIMEMessage& rMsg);
SvStream& rStrm, INetMIMEMessage& rMsg)
{
return rMsg.operator>> (rStrm);
}
}; };
#endif #endif

View File

@@ -23,7 +23,6 @@
#include <sal/types.h> #include <sal/types.h>
#include <rtl/ustring.hxx> #include <rtl/ustring.hxx>
class INetRFC822Message;
class INetMIMEMessage; class INetMIMEMessage;
class SvMemoryStream; class SvMemoryStream;
class SvStream; class SvStream;
@@ -81,7 +80,7 @@ enum INetMessageStreamState
/// Message Generator Interface. /// Message Generator Interface.
class INetMessageIStream : public INetIStream class INetMessageIStream : public INetIStream
{ {
INetRFC822Message *pSourceMsg; INetMIMEMessage *pSourceMsg;
bool bHeaderGenerated; bool bHeaderGenerated;
sal_uIntPtr nBufSiz; sal_uIntPtr nBufSiz;
@@ -106,8 +105,8 @@ public:
INetMessageIStream (sal_uIntPtr nBufferSize = 2048); INetMessageIStream (sal_uIntPtr nBufferSize = 2048);
virtual ~INetMessageIStream (void); virtual ~INetMessageIStream (void);
INetRFC822Message *GetSourceMessage (void) const { return pSourceMsg; } INetMIMEMessage *GetSourceMessage (void) const { return pSourceMsg; }
void SetSourceMessage (INetRFC822Message *pMsg) { pSourceMsg = pMsg; } void SetSourceMessage (INetMIMEMessage *pMsg) { pSourceMsg = pMsg; }
void GenerateHeader (bool bGen = true) { bHeaderGenerated = !bGen; } void GenerateHeader (bool bGen = true) { bHeaderGenerated = !bGen; }
bool IsHeaderGenerated (void) const { return bHeaderGenerated; } bool IsHeaderGenerated (void) const { return bHeaderGenerated; }
@@ -116,7 +115,7 @@ public:
/// Message Parser Interface. /// Message Parser Interface.
class INetMessageOStream : public INetOStream class INetMessageOStream : public INetOStream
{ {
INetRFC822Message *pTargetMsg; INetMIMEMessage *pTargetMsg;
bool bHeaderParsed; bool bHeaderParsed;
INetMessageStreamState eOState; INetMessageStreamState eOState;
@@ -135,8 +134,8 @@ public:
INetMessageOStream (void); INetMessageOStream (void);
virtual ~INetMessageOStream (void); virtual ~INetMessageOStream (void);
INetRFC822Message *GetTargetMessage (void) const { return pTargetMsg; } INetMIMEMessage *GetTargetMessage (void) const { return pTargetMsg; }
void SetTargetMessage (INetRFC822Message *pMsg) { pTargetMsg = pMsg; } void SetTargetMessage (INetMIMEMessage *pMsg) { pTargetMsg = pMsg; }
void ParseHeader (bool bParse = true) { bHeaderParsed = !bParse; } void ParseHeader (bool bParse = true) { bHeaderParsed = !bParse; }
bool IsHeaderParsed (void) const { return bHeaderParsed; } bool IsHeaderParsed (void) const { return bHeaderParsed; }
@@ -193,7 +192,7 @@ public:
using INetMessageIStream::SetSourceMessage; using INetMessageIStream::SetSourceMessage;
void SetSourceMessage (INetMIMEMessage *pMsg) void SetSourceMessage (INetMIMEMessage *pMsg)
{ {
INetMessageIStream::SetSourceMessage ((INetRFC822Message *)pMsg); INetMessageIStream::SetSourceMessage (pMsg);
} }
INetMIMEMessage *GetSourceMessage (void) const INetMIMEMessage *GetSourceMessage (void) const
{ {
@@ -203,7 +202,7 @@ public:
using INetMessageOStream::SetTargetMessage; using INetMessageOStream::SetTargetMessage;
void SetTargetMessage (INetMIMEMessage *pMsg) void SetTargetMessage (INetMIMEMessage *pMsg)
{ {
INetMessageOStream::SetTargetMessage ((INetRFC822Message *)pMsg); INetMessageOStream::SetTargetMessage (pMsg);
} }
INetMIMEMessage *GetTargetMessage (void) const INetMIMEMessage *GetTargetMessage (void) const
{ {

View File

@@ -1638,7 +1638,7 @@ void SfxHeaderAttributes_Impl::SetAttribute( const SvKeyValue& rKV )
else if( rKV.GetKey().equalsIgnoreAsciiCase( "expires" ) ) else if( rKV.GetKey().equalsIgnoreAsciiCase( "expires" ) )
{ {
DateTime aDateTime( DateTime::EMPTY ); DateTime aDateTime( DateTime::EMPTY );
if( INetRFC822Message::ParseDateField( rKV.GetValue(), aDateTime ) ) if( INetMIMEMessage::ParseDateField( rKV.GetValue(), aDateTime ) )
{ {
aDateTime.ConvertToLocalTime(); aDateTime.ConvertToLocalTime();
pDoc->GetMedium()->SetExpired_Impl( aDateTime ); pDoc->GetMedium()->SetExpired_Impl( aDateTime );

View File

@@ -48,7 +48,7 @@ inline sal_Unicode ascii_toLowerCase( sal_Unicode ch )
return ch; return ch;
} }
void INetRFC822Message::ListCleanup_Impl() void INetMIMEMessage::ListCleanup_Impl()
{ {
// Cleanup. // Cleanup.
sal_uIntPtr i, n = m_aHeaderList.size(); sal_uIntPtr i, n = m_aHeaderList.size();
@@ -57,7 +57,7 @@ void INetRFC822Message::ListCleanup_Impl()
m_aHeaderList.clear(); m_aHeaderList.clear();
} }
void INetRFC822Message::ListCopy (const INetRFC822Message &rMsg) void INetMIMEMessage::ListCopy (const INetMIMEMessage &rMsg)
{ {
if (!(this == &rMsg)) if (!(this == &rMsg))
{ {
@@ -74,7 +74,7 @@ void INetRFC822Message::ListCopy (const INetRFC822Message &rMsg)
} }
} }
void INetRFC822Message::SetHeaderField_Impl ( void INetMIMEMessage::SetHeaderField_Impl (
INetMIME::HeaderFieldType eType, INetMIME::HeaderFieldType eType,
const OString &rName, const OString &rName,
const OUString &rValue, const OUString &rValue,
@@ -121,42 +121,6 @@ enum _ImplINetRFC822MessageHeaderState
INETMSG_RFC822_LETTER_S INETMSG_RFC822_LETTER_S
}; };
INetRFC822Message::INetRFC822Message()
: m_nDocSize(0)
{
for (sal_uInt16 i = 0; i < INETMSG_RFC822_NUMHDR; i++)
m_nIndex[i] = CONTAINER_ENTRY_NOTFOUND;
}
INetRFC822Message::INetRFC822Message (const INetRFC822Message& rMsg)
: m_nDocSize (rMsg.m_nDocSize),
m_aDocName (rMsg.m_aDocName),
m_xDocLB (rMsg.m_xDocLB)
{
ListCopy (rMsg);
for (sal_uInt16 i = 0; i < INETMSG_RFC822_NUMHDR; i++)
m_nIndex[i] = rMsg.m_nIndex[i];
}
INetRFC822Message& INetRFC822Message::operator= (const INetRFC822Message& rMsg)
{
if (this != &rMsg)
{
m_nDocSize = rMsg.m_nDocSize;
m_aDocName = rMsg.m_aDocName;
m_xDocLB = rMsg.m_xDocLB;
ListCopy (rMsg);
for (sal_uInt16 i = 0; i < INETMSG_RFC822_NUMHDR; i++)
m_nIndex[i] = rMsg.m_nIndex[i];
}
return *this;
}
INetRFC822Message::~INetRFC822Message()
{
ListCleanup_Impl();
}
/* ParseDateField and local helper functions. /* ParseDateField and local helper functions.
* *
* Parses a String in (implied) GMT format into class Date and tools::Time objects. * Parses a String in (implied) GMT format into class Date and tools::Time objects.
@@ -200,7 +164,7 @@ static sal_uInt16 ParseMonth(const OString& rStr, sal_uInt16& nIndex)
return (i + 1); return (i + 1);
} }
bool INetRFC822Message::ParseDateField ( bool INetMIMEMessage::ParseDateField (
const OUString& rDateFieldW, DateTime& rDateTime) const OUString& rDateFieldW, DateTime& rDateTime)
{ {
OString aDateField(OUStringToOString(rDateFieldW, OString aDateField(OUStringToOString(rDateFieldW,
@@ -310,7 +274,7 @@ bool INetRFC822Message::ParseDateField (
} }
// Header Field Parser // Header Field Parser
sal_uIntPtr INetRFC822Message::SetHeaderField ( sal_uIntPtr INetMIMEMessage::SetRFC822HeaderField (
const INetMessageHeader &rHeader, sal_uIntPtr nNewIndex) const INetMessageHeader &rHeader, sal_uIntPtr nNewIndex)
{ {
OString aName (rHeader.GetName()); OString aName (rHeader.GetName());
@@ -528,8 +492,8 @@ sal_uIntPtr INetRFC822Message::SetHeaderField (
pData = pStop; pData = pStop;
SetHeaderField_Impl ( SetHeaderField_Impl (
INetMessageHeader( ImplINetRFC822MessageHeaderData[nIdx], rHeader.GetValue() ), INetMessageHeader( ImplINetRFC822MessageHeaderData[nIdx], rHeader.GetValue() ),
m_nIndex[nIdx]); m_nRFC822Index[nIdx]);
nNewIndex = m_nIndex[nIdx]; nNewIndex = m_nRFC822Index[nIdx];
break; break;
default: // INETMSG_RFC822_JUNK default: // INETMSG_RFC822_JUNK
@@ -541,57 +505,6 @@ sal_uIntPtr INetRFC822Message::SetHeaderField (
return nNewIndex; return nNewIndex;
} }
SvStream& INetRFC822Message::operator<< (SvStream& rStrm) const
{
rStrm.WriteUInt32( m_nDocSize );
write_uInt16_lenPrefixed_uInt8s_FromOUString(rStrm, m_aDocName, RTL_TEXTENCODING_UTF8);
sal_uIntPtr n = m_aHeaderList.size();
rStrm.WriteUInt32( n );
for (sal_uIntPtr i = 0; i < n; i++)
WriteINetMessageHeader( rStrm, *( m_aHeaderList[ i ] ) );
for (sal_uInt16 i = 0; i < INETMSG_RFC822_NUMHDR; i++)
rStrm.WriteUInt32( m_nIndex[i] );
return rStrm;
}
SvStream& INetRFC822Message::operator>> (SvStream& rStrm)
{
// Cleanup.
m_nDocSize = 0;
m_xDocLB.Clear();
ListCleanup_Impl();
sal_uInt32 nTemp;
// Copy.
rStrm.ReadUInt32( nTemp );
m_nDocSize = nTemp;
m_aDocName = read_uInt16_lenPrefixed_uInt8s_ToOUString(rStrm, RTL_TEXTENCODING_UTF8);
sal_uIntPtr n = 0;
rStrm.ReadUInt32( nTemp );
n = nTemp;
for (sal_uIntPtr i = 0; i < n; i++)
{
INetMessageHeader *p = new INetMessageHeader();
ReadINetMessageHeader( rStrm, *p );
m_aHeaderList.push_back( p );
}
for (sal_uInt16 i = 0; i < INETMSG_RFC822_NUMHDR; i++)
{
rStrm.ReadUInt32( nTemp );
m_nIndex[i] = nTemp;
}
return rStrm;
}
static const char* ImplINetMIMEMessageHeaderData[] = static const char* ImplINetMIMEMessageHeaderData[] =
{ {
"MIME-Version", "MIME-Version",
@@ -615,18 +528,25 @@ enum _ImplINetMIMEMessageHeaderState
}; };
INetMIMEMessage::INetMIMEMessage() INetMIMEMessage::INetMIMEMessage()
: INetRFC822Message (), : m_nDocSize(0),
pParent(NULL), pParent(NULL),
bHeaderParsed(false) bHeaderParsed(false)
{ {
for (sal_uInt16 i = 0; i < INETMSG_RFC822_NUMHDR; i++)
m_nRFC822Index[i] = CONTAINER_ENTRY_NOTFOUND;
for (sal_uInt16 i = 0; i < INETMSG_MIME_NUMHDR; i++) for (sal_uInt16 i = 0; i < INETMSG_MIME_NUMHDR; i++)
m_nIndex[i] = CONTAINER_ENTRY_NOTFOUND; m_nMIMEIndex[i] = CONTAINER_ENTRY_NOTFOUND;
} }
INetMIMEMessage::INetMIMEMessage (const INetMIMEMessage& rMsg) INetMIMEMessage::INetMIMEMessage (const INetMIMEMessage& rMsg)
: INetRFC822Message (rMsg) : m_nDocSize(rMsg.m_nDocSize),
, pParent(NULL) m_aDocName(rMsg.m_aDocName),
m_xDocLB(rMsg.m_xDocLB),
pParent(NULL)
{ {
ListCopy (rMsg);
for (sal_uInt16 i = 0; i < INETMSG_RFC822_NUMHDR; i++)
m_nRFC822Index[i] = rMsg.m_nRFC822Index[i];
CopyImp (rMsg); CopyImp (rMsg);
} }
@@ -635,9 +555,12 @@ INetMIMEMessage& INetMIMEMessage::operator= (
{ {
if (this != &rMsg) if (this != &rMsg)
{ {
// Assign base. m_nDocSize = rMsg.m_nDocSize;
INetRFC822Message::operator= (rMsg); m_aDocName = rMsg.m_aDocName;
m_xDocLB = rMsg.m_xDocLB;
ListCopy (rMsg);
for (sal_uInt16 i = 0; i < INETMSG_RFC822_NUMHDR; i++)
m_nRFC822Index[i] = rMsg.m_nRFC822Index[i];
CleanupImp(); CleanupImp();
CopyImp (rMsg); CopyImp (rMsg);
} }
@@ -646,6 +569,7 @@ INetMIMEMessage& INetMIMEMessage::operator= (
INetMIMEMessage::~INetMIMEMessage() INetMIMEMessage::~INetMIMEMessage()
{ {
ListCleanup_Impl();
CleanupImp(); CleanupImp();
} }
@@ -663,7 +587,7 @@ void INetMIMEMessage::CopyImp (const INetMIMEMessage& rMsg)
size_t i; size_t i;
for (i = 0; i < INETMSG_MIME_NUMHDR; i++) for (i = 0; i < INETMSG_MIME_NUMHDR; i++)
m_nIndex[i] = rMsg.m_nIndex[i]; m_nMIMEIndex[i] = rMsg.m_nMIMEIndex[i];
m_aBoundary = rMsg.m_aBoundary; m_aBoundary = rMsg.m_aBoundary;
@@ -819,14 +743,13 @@ sal_uIntPtr INetMIMEMessage::SetHeaderField (
pData = pStop; pData = pStop;
SetHeaderField_Impl ( SetHeaderField_Impl (
INetMessageHeader( ImplINetMIMEMessageHeaderData[nIdx], rHeader.GetValue()), INetMessageHeader( ImplINetMIMEMessageHeaderData[nIdx], rHeader.GetValue()),
m_nIndex[nIdx]); m_nMIMEIndex[nIdx]);
nNewIndex = m_nIndex[nIdx]; nNewIndex = m_nMIMEIndex[nIdx];
break; break;
default: // INETMSG_MIME_JUNK default: // INETMSG_MIME_JUNK
pData = pStop; pData = pStop;
nNewIndex = INetRFC822Message::SetHeaderField ( nNewIndex = SetRFC822HeaderField(rHeader, nNewIndex);
rHeader, nNewIndex);
break; break;
} }
} }
@@ -838,7 +761,7 @@ void INetMIMEMessage::SetMIMEVersion (const OUString& rVersion)
SetHeaderField_Impl ( SetHeaderField_Impl (
INetMIME::HEADER_FIELD_TEXT, INetMIME::HEADER_FIELD_TEXT,
ImplINetMIMEMessageHeaderData[INETMSG_MIME_VERSION], rVersion, ImplINetMIMEMessageHeaderData[INETMSG_MIME_VERSION], rVersion,
m_nIndex[INETMSG_MIME_VERSION]); m_nMIMEIndex[INETMSG_MIME_VERSION]);
} }
void INetMIMEMessage::SetContentDisposition (const OUString& rDisposition) void INetMIMEMessage::SetContentDisposition (const OUString& rDisposition)
@@ -846,7 +769,7 @@ void INetMIMEMessage::SetContentDisposition (const OUString& rDisposition)
SetHeaderField_Impl ( SetHeaderField_Impl (
INetMIME::HEADER_FIELD_TEXT, INetMIME::HEADER_FIELD_TEXT,
ImplINetMIMEMessageHeaderData[INETMSG_MIME_CONTENT_DISPOSITION], rDisposition, ImplINetMIMEMessageHeaderData[INETMSG_MIME_CONTENT_DISPOSITION], rDisposition,
m_nIndex[INETMSG_MIME_CONTENT_DISPOSITION]); m_nMIMEIndex[INETMSG_MIME_CONTENT_DISPOSITION]);
} }
void INetMIMEMessage::SetContentType (const OUString& rType) void INetMIMEMessage::SetContentType (const OUString& rType)
@@ -854,7 +777,7 @@ void INetMIMEMessage::SetContentType (const OUString& rType)
SetHeaderField_Impl ( SetHeaderField_Impl (
INetMIME::HEADER_FIELD_TEXT, INetMIME::HEADER_FIELD_TEXT,
ImplINetMIMEMessageHeaderData[INETMSG_MIME_CONTENT_TYPE], rType, ImplINetMIMEMessageHeaderData[INETMSG_MIME_CONTENT_TYPE], rType,
m_nIndex[INETMSG_MIME_CONTENT_TYPE]); m_nMIMEIndex[INETMSG_MIME_CONTENT_TYPE]);
} }
void INetMIMEMessage::SetContentTransferEncoding ( void INetMIMEMessage::SetContentTransferEncoding (
@@ -863,7 +786,7 @@ void INetMIMEMessage::SetContentTransferEncoding (
SetHeaderField_Impl ( SetHeaderField_Impl (
INetMIME::HEADER_FIELD_TEXT, INetMIME::HEADER_FIELD_TEXT,
ImplINetMIMEMessageHeaderData[INETMSG_MIME_CONTENT_TRANSFER_ENCODING], rEncoding, ImplINetMIMEMessageHeaderData[INETMSG_MIME_CONTENT_TRANSFER_ENCODING], rEncoding,
m_nIndex[INETMSG_MIME_CONTENT_TRANSFER_ENCODING]); m_nMIMEIndex[INETMSG_MIME_CONTENT_TRANSFER_ENCODING]);
} }
OUString INetMIMEMessage::GetDefaultContentType() OUString INetMIMEMessage::GetDefaultContentType()
@@ -959,31 +882,67 @@ bool INetMIMEMessage::AttachChild(INetMIMEMessage& rChildMsg, bool bOwner)
return false; return false;
} }
SvStream& INetMIMEMessage::operator<< (SvStream& rStrm) const SvStream& operator <<(SvStream& rStrm, const INetMIMEMessage& rMsg)
{ {
INetRFC822Message::operator<< (rStrm); rStrm.WriteUInt32( rMsg.m_nDocSize );
write_uInt16_lenPrefixed_uInt8s_FromOUString(rStrm, rMsg.m_aDocName, RTL_TEXTENCODING_UTF8);
sal_uIntPtr n = rMsg.m_aHeaderList.size();
rStrm.WriteUInt32( n );
for (sal_uIntPtr i = 0; i < n; i++)
WriteINetMessageHeader( rStrm, *( rMsg.m_aHeaderList[ i ] ) );
for (sal_uInt16 i = 0; i < INETMSG_RFC822_NUMHDR; i++)
rStrm.WriteUInt32( rMsg.m_nRFC822Index[i] );
for (sal_uInt16 i = 0; i < INETMSG_MIME_NUMHDR; i++) for (sal_uInt16 i = 0; i < INETMSG_MIME_NUMHDR; i++)
rStrm.WriteUInt32( m_nIndex[i] ); rStrm.WriteUInt32( rMsg.m_nMIMEIndex[i] );
write_uInt16_lenPrefixed_uInt8s_FromOString(rStrm, m_aBoundary); write_uInt16_lenPrefixed_uInt8s_FromOString(rStrm, rMsg.m_aBoundary);
rStrm.WriteUInt32( aChildren.size() ); rStrm.WriteUInt32( rMsg.aChildren.size() );
return rStrm; return rStrm;
} }
SvStream& INetMIMEMessage::operator>> (SvStream& rStrm) SvStream& operator >>(SvStream& rStrm, INetMIMEMessage& rMsg)
{ {
INetRFC822Message::operator>> (rStrm); // Cleanup.
rMsg.m_nDocSize = 0;
rMsg.m_xDocLB.Clear();
rMsg.ListCleanup_Impl();
sal_uInt32 nTemp; sal_uInt32 nTemp;
// Copy.
rStrm.ReadUInt32( nTemp );
rMsg.m_nDocSize = nTemp;
rMsg.m_aDocName = read_uInt16_lenPrefixed_uInt8s_ToOUString(rStrm, RTL_TEXTENCODING_UTF8);
sal_uIntPtr n = 0;
rStrm.ReadUInt32( nTemp );
n = nTemp;
for (sal_uIntPtr i = 0; i < n; i++)
{
INetMessageHeader *p = new INetMessageHeader();
ReadINetMessageHeader( rStrm, *p );
rMsg.m_aHeaderList.push_back( p );
}
for (sal_uInt16 i = 0; i < INETMSG_RFC822_NUMHDR; i++)
{
rStrm.ReadUInt32( nTemp );
rMsg.m_nRFC822Index[i] = nTemp;
}
for (sal_uInt16 i = 0; i < INETMSG_MIME_NUMHDR; i++) for (sal_uInt16 i = 0; i < INETMSG_MIME_NUMHDR; i++)
{ {
rStrm.ReadUInt32( nTemp ); rStrm.ReadUInt32( nTemp );
m_nIndex[i] = nTemp; rMsg.m_nMIMEIndex[i] = nTemp;
} }
m_aBoundary = read_uInt16_lenPrefixed_uInt8s_ToOString(rStrm); rMsg.m_aBoundary = read_uInt16_lenPrefixed_uInt8s_ToOString(rStrm);
rStrm.ReadUInt32( nTemp ); rStrm.ReadUInt32( nTemp );

View File

@@ -485,7 +485,7 @@ INetMessageEncodeQPStream_Impl::~INetMessageEncodeQPStream_Impl(void)
int INetMessageEncodeQPStream_Impl::GetMsgLine(sal_Char* pData, sal_uIntPtr nSize) int INetMessageEncodeQPStream_Impl::GetMsgLine(sal_Char* pData, sal_uIntPtr nSize)
{ {
INetRFC822Message* pMsg = GetSourceMessage(); INetMIMEMessage* pMsg = GetSourceMessage();
if (pMsg == NULL) return INETSTREAM_STATUS_ERROR; if (pMsg == NULL) return INETSTREAM_STATUS_ERROR;
if (pMsg->GetDocumentLB() == NULL) return 0; if (pMsg->GetDocumentLB() == NULL) return 0;
@@ -693,7 +693,7 @@ INetMessageDecodeQPStream_Impl::~INetMessageDecodeQPStream_Impl(void)
int INetMessageDecodeQPStream_Impl::PutMsgLine( const sal_Char* pData, int INetMessageDecodeQPStream_Impl::PutMsgLine( const sal_Char* pData,
sal_uIntPtr nSize) sal_uIntPtr nSize)
{ {
INetRFC822Message* pMsg = GetTargetMessage(); INetMIMEMessage* pMsg = GetTargetMessage();
if (pMsg == NULL) return INETSTREAM_STATUS_ERROR; if (pMsg == NULL) return INETSTREAM_STATUS_ERROR;
SvOpenLockBytes* pLB = PTR_CAST(SvOpenLockBytes, pMsg->GetDocumentLB()); SvOpenLockBytes* pLB = PTR_CAST(SvOpenLockBytes, pMsg->GetDocumentLB());
@@ -807,7 +807,7 @@ INetMessageEncode64Stream_Impl::~INetMessageEncode64Stream_Impl(void)
int INetMessageEncode64Stream_Impl::GetMsgLine(sal_Char* pData, sal_uIntPtr nSize) int INetMessageEncode64Stream_Impl::GetMsgLine(sal_Char* pData, sal_uIntPtr nSize)
{ {
INetRFC822Message* pMsg = GetSourceMessage(); INetMIMEMessage* pMsg = GetSourceMessage();
if (pMsg == NULL) return INETSTREAM_STATUS_ERROR; if (pMsg == NULL) return INETSTREAM_STATUS_ERROR;
if (pMsg->GetDocumentLB() == NULL) return 0; if (pMsg->GetDocumentLB() == NULL) return 0;
@@ -993,7 +993,7 @@ INetMessageDecode64Stream_Impl::~INetMessageDecode64Stream_Impl(void)
int INetMessageDecode64Stream_Impl::PutMsgLine(const sal_Char* pData, int INetMessageDecode64Stream_Impl::PutMsgLine(const sal_Char* pData,
sal_uIntPtr nSize) sal_uIntPtr nSize)
{ {
INetRFC822Message* pMsg = GetTargetMessage(); INetMIMEMessage* pMsg = GetTargetMessage();
if (pMsg == NULL) return INETSTREAM_STATUS_ERROR; if (pMsg == NULL) return INETSTREAM_STATUS_ERROR;
SvOpenLockBytes* pLB = PTR_CAST(SvOpenLockBytes, pMsg->GetDocumentLB()); SvOpenLockBytes* pLB = PTR_CAST(SvOpenLockBytes, pMsg->GetDocumentLB());

View File

@@ -196,7 +196,7 @@ void SAL_CALL UcbPropertiesChangeListener_Impl::propertiesChange ( const Sequenc
if (aName.compareToIgnoreAsciiCaseAscii("Expires") == 0) if (aName.compareToIgnoreAsciiCaseAscii("Expires") == 0)
{ {
DateTime aExpires (0, 0); DateTime aExpires (0, 0);
if (INetRFC822Message::ParseDateField (aValue, aExpires)) if (INetMIMEMessage::ParseDateField (aValue, aExpires))
{ {
aExpires.ConvertToLocalTime(); aExpires.ConvertToLocalTime();
m_xLockBytes->SetExpireDate_Impl( aExpires ); m_xLockBytes->SetExpireDate_Impl( aExpires );