summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2015-02-11 15:14:23 +0100
committerStephan Bergmann <sbergman@redhat.com>2015-02-11 17:09:08 +0100
commit3939b6d64df3b7ca495d0afb06876e5f5a492116 (patch)
treec8f0a6b113c7eb8893b8a31c1533767e2e93251f
parentd8f74fb158a69016ec6fe5858e9eff53beb8d9fa (diff)
Fold INetMessage into INetRFC822Message
Change-Id: I89ba13c02954364044b215ba7df7c563720b92f9
-rw-r--r--include/tools/inetmsg.hxx110
-rw-r--r--include/tools/inetstrm.hxx18
-rw-r--r--tools/source/inet/inetmsg.cxx109
-rw-r--r--tools/source/inet/inetstrm.cxx8
4 files changed, 94 insertions, 151 deletions
diff --git a/include/tools/inetmsg.hxx b/include/tools/inetmsg.hxx
index 912595cab622..fb6370a4d107 100644
--- a/include/tools/inetmsg.hxx
+++ b/include/tools/inetmsg.hxx
@@ -81,7 +81,25 @@ public:
typedef ::std::vector< INetMessageHeader* > HeaderList_impl;
-class INetMessage
+#define INETMSG_RFC822_BCC 0
+#define INETMSG_RFC822_CC 1
+#define INETMSG_RFC822_COMMENTS 2
+#define INETMSG_RFC822_DATE 3
+#define INETMSG_RFC822_FROM 4
+#define INETMSG_RFC822_IN_REPLY_TO 5
+#define INETMSG_RFC822_KEYWORDS 6
+#define INETMSG_RFC822_MESSAGE_ID 7
+#define INETMSG_RFC822_REFERENCES 8
+#define INETMSG_RFC822_REPLY_TO 9
+#define INETMSG_RFC822_RETURN_PATH 10
+#define INETMSG_RFC822_SENDER 11
+#define INETMSG_RFC822_SUBJECT 12
+#define INETMSG_RFC822_TO 13
+#define INETMSG_RFC822_X_MAILER 14
+#define INETMSG_RFC822_RETURN_RECEIPT_TO 15
+#define INETMSG_RFC822_NUMHDR 16
+
+class TOOLS_DLLPUBLIC INetRFC822Message
{
HeaderList_impl m_aHeaderList;
@@ -90,7 +108,9 @@ class INetMessage
SvLockBytesRef m_xDocLB;
void ListCleanup_Impl();
- void ListCopy (const INetMessage& rMsg);
+ void ListCopy (const INetRFC822Message& rMsg);
+
+ sal_uIntPtr m_nIndex[INETMSG_RFC822_NUMHDR];
protected:
OUString GetHeaderName_Impl (
@@ -139,25 +159,11 @@ protected:
virtual SvStream& operator>> (SvStream& rStrm);
public:
- INetMessage() : m_nDocSize(0) {}
- virtual ~INetMessage();
-
- INetMessage (const INetMessage& rMsg)
- : m_nDocSize (rMsg.m_nDocSize),
- m_aDocName (rMsg.m_aDocName),
- m_xDocLB (rMsg.m_xDocLB)
- {
- ListCopy (rMsg);
- }
+ INetRFC822Message();
+ INetRFC822Message (const INetRFC822Message& rMsg);
+ virtual ~INetRFC822Message();
- INetMessage& operator= (const INetMessage& rMsg)
- {
- m_nDocSize = rMsg.m_nDocSize;
- m_aDocName = rMsg.m_aDocName;
- m_xDocLB = rMsg.m_xDocLB;
- ListCopy (rMsg);
- return *this;
- }
+ INetRFC822Message& operator= (const INetRFC822Message& rMsg);
sal_uIntPtr GetHeaderCount() const { return m_aHeaderList.size(); }
@@ -194,61 +200,9 @@ public:
SvLockBytes* GetDocumentLB() const { return m_xDocLB; }
void SetDocumentLB (SvLockBytes *pDocLB) { m_xDocLB = pDocLB; }
- friend SvStream& WriteINetMessage(
- SvStream& rStrm, const INetMessage& rMsg)
- {
- return rMsg.operator<< (rStrm);
- }
-
- friend SvStream& ReadINetMessage (
- SvStream& rStrm, INetMessage& rMsg)
- {
- return rMsg.operator>> (rStrm);
- }
-};
-
-#define INETMSG_RFC822_BCC 0
-#define INETMSG_RFC822_CC 1
-#define INETMSG_RFC822_COMMENTS 2
-#define INETMSG_RFC822_DATE 3
-#define INETMSG_RFC822_FROM 4
-#define INETMSG_RFC822_IN_REPLY_TO 5
-#define INETMSG_RFC822_KEYWORDS 6
-#define INETMSG_RFC822_MESSAGE_ID 7
-#define INETMSG_RFC822_REFERENCES 8
-#define INETMSG_RFC822_REPLY_TO 9
-#define INETMSG_RFC822_RETURN_PATH 10
-#define INETMSG_RFC822_SENDER 11
-#define INETMSG_RFC822_SUBJECT 12
-#define INETMSG_RFC822_TO 13
-#define INETMSG_RFC822_X_MAILER 14
-#define INETMSG_RFC822_RETURN_RECEIPT_TO 15
-#define INETMSG_RFC822_NUMHDR 16
-
-class TOOLS_DLLPUBLIC INetRFC822Message : public INetMessage
-{
- sal_uIntPtr m_nIndex[INETMSG_RFC822_NUMHDR];
-
-protected:
- virtual SvStream& operator<< (SvStream& rStrm) const SAL_OVERRIDE;
- virtual SvStream& operator>> (SvStream& rStrm) SAL_OVERRIDE;
-
-public:
- INetRFC822Message();
- INetRFC822Message (const INetRFC822Message& rMsg);
- virtual ~INetRFC822Message();
-
- INetRFC822Message& operator= (const INetRFC822Message& rMsg);
-
static bool ParseDateField (
const OUString& rDateField, DateTime& rDateTime);
- using INetMessage::SetHeaderField;
- virtual sal_uIntPtr SetHeaderField (
- const INetMessageHeader &rHeader,
- sal_uIntPtr nIndex = ((sal_uIntPtr)-1)
- ) SAL_OVERRIDE;
-
// Header fields.
OUString GetBCC() const
@@ -358,6 +312,18 @@ public:
// 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)
{
diff --git a/include/tools/inetstrm.hxx b/include/tools/inetstrm.hxx
index 6801293b4b16..b5c4e04b873c 100644
--- a/include/tools/inetstrm.hxx
+++ b/include/tools/inetstrm.hxx
@@ -23,7 +23,7 @@
#include <sal/types.h>
#include <rtl/ustring.hxx>
-class INetMessage;
+class INetRFC822Message;
class INetMIMEMessage;
class SvMemoryStream;
class SvStream;
@@ -81,7 +81,7 @@ enum INetMessageStreamState
/// Message Generator Interface.
class INetMessageIStream : public INetIStream
{
- INetMessage *pSourceMsg;
+ INetRFC822Message *pSourceMsg;
bool bHeaderGenerated;
sal_uIntPtr nBufSiz;
@@ -106,8 +106,8 @@ public:
INetMessageIStream (sal_uIntPtr nBufferSize = 2048);
virtual ~INetMessageIStream (void);
- INetMessage *GetSourceMessage (void) const { return pSourceMsg; }
- void SetSourceMessage (INetMessage *pMsg) { pSourceMsg = pMsg; }
+ INetRFC822Message *GetSourceMessage (void) const { return pSourceMsg; }
+ void SetSourceMessage (INetRFC822Message *pMsg) { pSourceMsg = pMsg; }
void GenerateHeader (bool bGen = true) { bHeaderGenerated = !bGen; }
bool IsHeaderGenerated (void) const { return bHeaderGenerated; }
@@ -116,7 +116,7 @@ public:
/// Message Parser Interface.
class INetMessageOStream : public INetOStream
{
- INetMessage *pTargetMsg;
+ INetRFC822Message *pTargetMsg;
bool bHeaderParsed;
INetMessageStreamState eOState;
@@ -135,8 +135,8 @@ public:
INetMessageOStream (void);
virtual ~INetMessageOStream (void);
- INetMessage *GetTargetMessage (void) const { return pTargetMsg; }
- void SetTargetMessage (INetMessage *pMsg) { pTargetMsg = pMsg; }
+ INetRFC822Message *GetTargetMessage (void) const { return pTargetMsg; }
+ void SetTargetMessage (INetRFC822Message *pMsg) { pTargetMsg = pMsg; }
void ParseHeader (bool bParse = true) { bHeaderParsed = !bParse; }
bool IsHeaderParsed (void) const { return bHeaderParsed; }
@@ -193,7 +193,7 @@ public:
using INetMessageIStream::SetSourceMessage;
void SetSourceMessage (INetMIMEMessage *pMsg)
{
- INetMessageIStream::SetSourceMessage ((INetMessage *)pMsg);
+ INetMessageIStream::SetSourceMessage ((INetRFC822Message *)pMsg);
}
INetMIMEMessage *GetSourceMessage (void) const
{
@@ -203,7 +203,7 @@ public:
using INetMessageOStream::SetTargetMessage;
void SetTargetMessage (INetMIMEMessage *pMsg)
{
- INetMessageOStream::SetTargetMessage ((INetMessage *)pMsg);
+ INetMessageOStream::SetTargetMessage ((INetRFC822Message *)pMsg);
}
INetMIMEMessage *GetTargetMessage (void) const
{
diff --git a/tools/source/inet/inetmsg.cxx b/tools/source/inet/inetmsg.cxx
index 42c7a5fe43c3..a710bc229320 100644
--- a/tools/source/inet/inetmsg.cxx
+++ b/tools/source/inet/inetmsg.cxx
@@ -48,12 +48,7 @@ inline sal_Unicode ascii_toLowerCase( sal_Unicode ch )
return ch;
}
-INetMessage::~INetMessage()
-{
- ListCleanup_Impl();
-}
-
-void INetMessage::ListCleanup_Impl()
+void INetRFC822Message::ListCleanup_Impl()
{
// Cleanup.
sal_uIntPtr i, n = m_aHeaderList.size();
@@ -62,7 +57,7 @@ void INetMessage::ListCleanup_Impl()
m_aHeaderList.clear();
}
-void INetMessage::ListCopy (const INetMessage &rMsg)
+void INetRFC822Message::ListCopy (const INetRFC822Message &rMsg)
{
if (!(this == &rMsg))
{
@@ -79,7 +74,7 @@ void INetMessage::ListCopy (const INetMessage &rMsg)
}
}
-void INetMessage::SetHeaderField_Impl (
+void INetRFC822Message::SetHeaderField_Impl (
INetMIME::HeaderFieldType eType,
const OString &rName,
const OUString &rValue,
@@ -92,57 +87,6 @@ void INetMessage::SetHeaderField_Impl (
INetMessageHeader (rName, aSink.takeBuffer()), rnIndex);
}
-sal_uIntPtr INetMessage::SetHeaderField (
- const INetMessageHeader &rHeader, sal_uIntPtr nIndex)
-{
- sal_uIntPtr nResult = nIndex;
- SetHeaderField_Impl (rHeader, nResult);
- return nResult;
-}
-
-SvStream& INetMessage::operator<< (SvStream& rStrm) const
-{
- rStrm.WriteUInt32( m_nDocSize );
- write_uInt16_lenPrefixed_uInt8s_FromOUString(rStrm, m_aDocName, RTL_TEXTENCODING_UTF8);
-
- sal_uIntPtr i, n = m_aHeaderList.size();
- rStrm.WriteUInt32( n );
-
- for (i = 0; i < n; i++)
- WriteINetMessageHeader( rStrm, *( m_aHeaderList[ i ] ) );
-
- return rStrm;
-}
-
-SvStream& INetMessage::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 i, n = 0;
- rStrm.ReadUInt32( nTemp );
- n = nTemp;
-
- for (i = 0; i < n; i++)
- {
- INetMessageHeader *p = new INetMessageHeader();
- ReadINetMessageHeader( rStrm, *p );
- m_aHeaderList.push_back( p );
- }
-
- // Done.
- return rStrm;
-}
-
static const char * ImplINetRFC822MessageHeaderData[] =
{
"BCC",
@@ -178,15 +122,18 @@ enum _ImplINetRFC822MessageHeaderState
};
INetRFC822Message::INetRFC822Message()
- : INetMessage()
+ : m_nDocSize(0)
{
for (sal_uInt16 i = 0; i < INETMSG_RFC822_NUMHDR; i++)
m_nIndex[i] = CONTAINER_ENTRY_NOTFOUND;
}
INetRFC822Message::INetRFC822Message (const INetRFC822Message& rMsg)
- : INetMessage (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];
}
@@ -195,8 +142,10 @@ INetRFC822Message& INetRFC822Message::operator= (const INetRFC822Message& rMsg)
{
if (this != &rMsg)
{
- INetMessage::operator= (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];
}
@@ -205,6 +154,7 @@ INetRFC822Message& INetRFC822Message::operator= (const INetRFC822Message& rMsg)
INetRFC822Message::~INetRFC822Message()
{
+ ListCleanup_Impl();
}
/* ParseDateField and local helper functions.
@@ -584,7 +534,7 @@ sal_uIntPtr INetRFC822Message::SetHeaderField (
default: // INETMSG_RFC822_JUNK
pData = pStop;
- nNewIndex = INetMessage::SetHeaderField (rHeader, nNewIndex);
+ SetHeaderField_Impl(rHeader, nNewIndex);
break;
}
}
@@ -593,7 +543,14 @@ sal_uIntPtr INetRFC822Message::SetHeaderField (
SvStream& INetRFC822Message::operator<< (SvStream& rStrm) const
{
- INetMessage::operator<< (rStrm);
+ 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] );
@@ -603,9 +560,29 @@ SvStream& INetRFC822Message::operator<< (SvStream& rStrm) const
SvStream& INetRFC822Message::operator>> (SvStream& rStrm)
{
- INetMessage::operator>> (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 );
diff --git a/tools/source/inet/inetstrm.cxx b/tools/source/inet/inetstrm.cxx
index bb3437494595..87646228127e 100644
--- a/tools/source/inet/inetstrm.cxx
+++ b/tools/source/inet/inetstrm.cxx
@@ -485,7 +485,7 @@ INetMessageEncodeQPStream_Impl::~INetMessageEncodeQPStream_Impl(void)
int INetMessageEncodeQPStream_Impl::GetMsgLine(sal_Char* pData, sal_uIntPtr nSize)
{
- INetMessage* pMsg = GetSourceMessage();
+ INetRFC822Message* pMsg = GetSourceMessage();
if (pMsg == NULL) return INETSTREAM_STATUS_ERROR;
if (pMsg->GetDocumentLB() == NULL) return 0;
@@ -693,7 +693,7 @@ INetMessageDecodeQPStream_Impl::~INetMessageDecodeQPStream_Impl(void)
int INetMessageDecodeQPStream_Impl::PutMsgLine( const sal_Char* pData,
sal_uIntPtr nSize)
{
- INetMessage* pMsg = GetTargetMessage();
+ INetRFC822Message* pMsg = GetTargetMessage();
if (pMsg == NULL) return INETSTREAM_STATUS_ERROR;
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)
{
- INetMessage* pMsg = GetSourceMessage();
+ INetRFC822Message* pMsg = GetSourceMessage();
if (pMsg == NULL) return INETSTREAM_STATUS_ERROR;
if (pMsg->GetDocumentLB() == NULL) return 0;
@@ -993,7 +993,7 @@ INetMessageDecode64Stream_Impl::~INetMessageDecode64Stream_Impl(void)
int INetMessageDecode64Stream_Impl::PutMsgLine(const sal_Char* pData,
sal_uIntPtr nSize)
{
- INetMessage* pMsg = GetTargetMessage();
+ INetRFC822Message* pMsg = GetTargetMessage();
if (pMsg == NULL) return INETSTREAM_STATUS_ERROR;
SvOpenLockBytes* pLB = PTR_CAST(SvOpenLockBytes, pMsg->GetDocumentLB());