1*8b851043SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*8b851043SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*8b851043SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*8b851043SAndrew Rist * distributed with this work for additional information 6*8b851043SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*8b851043SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*8b851043SAndrew Rist * "License"); you may not use this file except in compliance 9*8b851043SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*8b851043SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*8b851043SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*8b851043SAndrew Rist * software distributed under the License is distributed on an 15*8b851043SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*8b851043SAndrew Rist * KIND, either express or implied. See the License for the 17*8b851043SAndrew Rist * specific language governing permissions and limitations 18*8b851043SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*8b851043SAndrew Rist *************************************************************/ 21*8b851043SAndrew Rist 22*8b851043SAndrew Rist 23cdf0e10cSrcweir #ifndef _TOOLS_INETMSG_HXX 24cdf0e10cSrcweir #define _TOOLS_INETMSG_HXX 25cdf0e10cSrcweir 26cdf0e10cSrcweir #include "tools/toolsdllapi.h" 27cdf0e10cSrcweir #include <sal/types.h> 28cdf0e10cSrcweir 29cdf0e10cSrcweir #ifndef _RTL_TEXTENC_H_ 30cdf0e10cSrcweir #include <rtl/textenc.h> 31cdf0e10cSrcweir #endif 32cdf0e10cSrcweir 33cdf0e10cSrcweir #ifndef _TOOLS_INETMIME_HXX 34cdf0e10cSrcweir #include <tools/inetmime.hxx> 35cdf0e10cSrcweir #endif 36cdf0e10cSrcweir #include <tools/list.hxx> 37cdf0e10cSrcweir #include <tools/stream.hxx> 38cdf0e10cSrcweir #include <tools/string.hxx> 39cdf0e10cSrcweir 40cdf0e10cSrcweir class DateTime; 41cdf0e10cSrcweir 42cdf0e10cSrcweir /*======================================================================= 43cdf0e10cSrcweir * 44cdf0e10cSrcweir * INetMessageHeader Interface. 45cdf0e10cSrcweir * 46cdf0e10cSrcweir *=====================================================================*/ 47cdf0e10cSrcweir class INetMessageHeader 48cdf0e10cSrcweir { 49cdf0e10cSrcweir ByteString m_aName; 50cdf0e10cSrcweir ByteString m_aValue; 51cdf0e10cSrcweir 52cdf0e10cSrcweir public: INetMessageHeader(void)53cdf0e10cSrcweir INetMessageHeader (void) 54cdf0e10cSrcweir {} 55cdf0e10cSrcweir INetMessageHeader(const ByteString & rName,const ByteString & rValue)56cdf0e10cSrcweir INetMessageHeader ( 57cdf0e10cSrcweir const ByteString& rName, const ByteString& rValue) 58cdf0e10cSrcweir : m_aName (rName), m_aValue (rValue) 59cdf0e10cSrcweir {} 60cdf0e10cSrcweir INetMessageHeader(const INetMessageHeader & rHdr)61cdf0e10cSrcweir INetMessageHeader ( 62cdf0e10cSrcweir const INetMessageHeader& rHdr) 63cdf0e10cSrcweir : m_aName (rHdr.m_aName), m_aValue (rHdr.m_aValue) 64cdf0e10cSrcweir {} 65cdf0e10cSrcweir ~INetMessageHeader(void)66cdf0e10cSrcweir ~INetMessageHeader (void) 67cdf0e10cSrcweir {} 68cdf0e10cSrcweir operator =(const INetMessageHeader & rHdr)69cdf0e10cSrcweir INetMessageHeader& operator= (const INetMessageHeader& rHdr) 70cdf0e10cSrcweir { 71cdf0e10cSrcweir m_aName = rHdr.m_aName; 72cdf0e10cSrcweir m_aValue = rHdr.m_aValue; 73cdf0e10cSrcweir return *this; 74cdf0e10cSrcweir } 75cdf0e10cSrcweir GetName(void) const76cdf0e10cSrcweir const ByteString& GetName (void) const { return m_aName; } GetValue(void) const77cdf0e10cSrcweir const ByteString& GetValue (void) const { return m_aValue; } 78cdf0e10cSrcweir operator <<(SvStream & rStrm,const INetMessageHeader & rHdr)79cdf0e10cSrcweir friend SvStream& operator<< ( 80cdf0e10cSrcweir SvStream& rStrm, const INetMessageHeader& rHdr) 81cdf0e10cSrcweir { 82cdf0e10cSrcweir #ifdef ENABLE_BYTESTRING_STREAM_OPERATORS 83cdf0e10cSrcweir rStrm << rHdr.m_aName; 84cdf0e10cSrcweir rStrm << rHdr.m_aValue; 85cdf0e10cSrcweir #else 86cdf0e10cSrcweir rStrm.WriteByteString (rHdr.m_aName); 87cdf0e10cSrcweir rStrm.WriteByteString (rHdr.m_aValue); 88cdf0e10cSrcweir #endif 89cdf0e10cSrcweir return rStrm; 90cdf0e10cSrcweir } 91cdf0e10cSrcweir operator >>(SvStream & rStrm,INetMessageHeader & rHdr)92cdf0e10cSrcweir friend SvStream& operator>> ( 93cdf0e10cSrcweir SvStream& rStrm, INetMessageHeader& rHdr) 94cdf0e10cSrcweir { 95cdf0e10cSrcweir #ifdef ENABLE_BYTESTRING_STREAM_OPERATORS 96cdf0e10cSrcweir rStrm >> rHdr.m_aName; 97cdf0e10cSrcweir rStrm >> rHdr.m_aValue; 98cdf0e10cSrcweir #else 99cdf0e10cSrcweir rStrm.ReadByteString (rHdr.m_aName); 100cdf0e10cSrcweir rStrm.ReadByteString (rHdr.m_aValue); 101cdf0e10cSrcweir #endif 102cdf0e10cSrcweir return rStrm; 103cdf0e10cSrcweir } 104cdf0e10cSrcweir }; 105cdf0e10cSrcweir 106cdf0e10cSrcweir /*======================================================================= 107cdf0e10cSrcweir * 108cdf0e10cSrcweir * INetMessage Interface. 109cdf0e10cSrcweir * 110cdf0e10cSrcweir *=====================================================================*/ 111cdf0e10cSrcweir class INetMessage 112cdf0e10cSrcweir { 113cdf0e10cSrcweir List m_aHeaderList; 114cdf0e10cSrcweir 115cdf0e10cSrcweir sal_uIntPtr m_nDocSize; 116cdf0e10cSrcweir UniString m_aDocName; 117cdf0e10cSrcweir SvLockBytesRef m_xDocLB; 118cdf0e10cSrcweir 119cdf0e10cSrcweir void ListCleanup_Impl (void); 120cdf0e10cSrcweir void ListCopy (const INetMessage& rMsg); 121cdf0e10cSrcweir 122cdf0e10cSrcweir protected: GetHeaderName_Impl(sal_uIntPtr nIndex,rtl_TextEncoding eEncoding) const123cdf0e10cSrcweir UniString GetHeaderName_Impl ( 124cdf0e10cSrcweir sal_uIntPtr nIndex, rtl_TextEncoding eEncoding) const 125cdf0e10cSrcweir { 126cdf0e10cSrcweir INetMessageHeader *p = 127cdf0e10cSrcweir (INetMessageHeader*)(m_aHeaderList.GetObject(nIndex)); 128cdf0e10cSrcweir if (p) 129cdf0e10cSrcweir return UniString(p->GetName(), eEncoding); 130cdf0e10cSrcweir else 131cdf0e10cSrcweir return UniString(); 132cdf0e10cSrcweir } 133cdf0e10cSrcweir GetHeaderValue_Impl(sal_uIntPtr nIndex,INetMIME::HeaderFieldType eType) const134cdf0e10cSrcweir UniString GetHeaderValue_Impl ( 135cdf0e10cSrcweir sal_uIntPtr nIndex, INetMIME::HeaderFieldType eType) const 136cdf0e10cSrcweir { 137cdf0e10cSrcweir INetMessageHeader *p = 138cdf0e10cSrcweir (INetMessageHeader*)(m_aHeaderList.GetObject(nIndex)); 139cdf0e10cSrcweir if (p) 140cdf0e10cSrcweir return INetMIME::decodeHeaderFieldBody (eType, p->GetValue()); 141cdf0e10cSrcweir else 142cdf0e10cSrcweir return UniString(); 143cdf0e10cSrcweir } 144cdf0e10cSrcweir SetHeaderField_Impl(const INetMessageHeader & rHeader,sal_uIntPtr & rnIndex)145cdf0e10cSrcweir void SetHeaderField_Impl ( 146cdf0e10cSrcweir const INetMessageHeader &rHeader, sal_uIntPtr &rnIndex) 147cdf0e10cSrcweir { 148cdf0e10cSrcweir INetMessageHeader *p = new INetMessageHeader (rHeader); 149cdf0e10cSrcweir if (m_aHeaderList.Count() <= rnIndex) 150cdf0e10cSrcweir { 151cdf0e10cSrcweir m_aHeaderList.Insert (p, LIST_APPEND); 152cdf0e10cSrcweir rnIndex = m_aHeaderList.Count() - 1; 153cdf0e10cSrcweir } 154cdf0e10cSrcweir else 155cdf0e10cSrcweir { 156cdf0e10cSrcweir p = (INetMessageHeader*)(m_aHeaderList.Replace(p, rnIndex)); 157cdf0e10cSrcweir delete p; 158cdf0e10cSrcweir } 159cdf0e10cSrcweir } 160cdf0e10cSrcweir 161cdf0e10cSrcweir void SetHeaderField_Impl ( 162cdf0e10cSrcweir INetMIME::HeaderFieldType eType, 163cdf0e10cSrcweir const ByteString &rName, 164cdf0e10cSrcweir const UniString &rValue, 165cdf0e10cSrcweir sal_uIntPtr &rnIndex); 166cdf0e10cSrcweir 167cdf0e10cSrcweir virtual SvStream& operator<< (SvStream& rStrm) const; 168cdf0e10cSrcweir virtual SvStream& operator>> (SvStream& rStrm); 169cdf0e10cSrcweir 170cdf0e10cSrcweir public: INetMessage(void)171cdf0e10cSrcweir INetMessage (void) : m_nDocSize(0) {} 172cdf0e10cSrcweir virtual ~INetMessage (void); 173cdf0e10cSrcweir INetMessage(const INetMessage & rMsg)174cdf0e10cSrcweir INetMessage (const INetMessage& rMsg) 175cdf0e10cSrcweir : m_nDocSize (rMsg.m_nDocSize), 176cdf0e10cSrcweir m_aDocName (rMsg.m_aDocName), 177cdf0e10cSrcweir m_xDocLB (rMsg.m_xDocLB) 178cdf0e10cSrcweir { 179cdf0e10cSrcweir ListCopy (rMsg); 180cdf0e10cSrcweir } 181cdf0e10cSrcweir operator =(const INetMessage & rMsg)182cdf0e10cSrcweir INetMessage& operator= (const INetMessage& rMsg) 183cdf0e10cSrcweir { 184cdf0e10cSrcweir m_nDocSize = rMsg.m_nDocSize; 185cdf0e10cSrcweir m_aDocName = rMsg.m_aDocName; 186cdf0e10cSrcweir m_xDocLB = rMsg.m_xDocLB; 187cdf0e10cSrcweir ListCopy (rMsg); 188cdf0e10cSrcweir return *this; 189cdf0e10cSrcweir } 190cdf0e10cSrcweir GetHeaderCount(void) const191cdf0e10cSrcweir sal_uIntPtr GetHeaderCount (void) const { return m_aHeaderList.Count(); } 192cdf0e10cSrcweir GetHeaderName(sal_uIntPtr nIndex) const193cdf0e10cSrcweir UniString GetHeaderName (sal_uIntPtr nIndex) const 194cdf0e10cSrcweir { 195cdf0e10cSrcweir return GetHeaderName_Impl (nIndex, RTL_TEXTENCODING_ASCII_US); 196cdf0e10cSrcweir } 197cdf0e10cSrcweir GetHeaderValue(sal_uIntPtr nIndex) const198cdf0e10cSrcweir UniString GetHeaderValue (sal_uIntPtr nIndex) const 199cdf0e10cSrcweir { 200cdf0e10cSrcweir return GetHeaderValue_Impl (nIndex, INetMIME::HEADER_FIELD_TEXT); 201cdf0e10cSrcweir } 202cdf0e10cSrcweir GetHeaderField(sal_uIntPtr nIndex) const203cdf0e10cSrcweir INetMessageHeader GetHeaderField (sal_uIntPtr nIndex) const 204cdf0e10cSrcweir { 205cdf0e10cSrcweir INetMessageHeader *p = 206cdf0e10cSrcweir (INetMessageHeader*)(m_aHeaderList.GetObject(nIndex)); 207cdf0e10cSrcweir if (p) 208cdf0e10cSrcweir return INetMessageHeader(*p); 209cdf0e10cSrcweir else 210cdf0e10cSrcweir return INetMessageHeader(); 211cdf0e10cSrcweir } 212cdf0e10cSrcweir 213cdf0e10cSrcweir sal_uIntPtr SetHeaderField ( 214cdf0e10cSrcweir const UniString& rName, 215cdf0e10cSrcweir const UniString& rValue, 216cdf0e10cSrcweir sal_uIntPtr nIndex = LIST_APPEND); 217cdf0e10cSrcweir 218cdf0e10cSrcweir virtual sal_uIntPtr SetHeaderField ( 219cdf0e10cSrcweir const INetMessageHeader &rField, sal_uIntPtr nIndex = LIST_APPEND); 220cdf0e10cSrcweir GetDocumentSize(void) const221cdf0e10cSrcweir sal_uIntPtr GetDocumentSize (void) const { return m_nDocSize; } SetDocumentSize(sal_uIntPtr nSize)222cdf0e10cSrcweir void SetDocumentSize (sal_uIntPtr nSize) { m_nDocSize = nSize; } 223cdf0e10cSrcweir GetDocumentName(void) const224cdf0e10cSrcweir const UniString& GetDocumentName (void) const { return m_aDocName; } SetDocumentName(const UniString & rName)225cdf0e10cSrcweir void SetDocumentName (const UniString& rName) { m_aDocName = rName; } 226cdf0e10cSrcweir GetDocumentLB(void) const227cdf0e10cSrcweir SvLockBytes* GetDocumentLB (void) const { return m_xDocLB; } SetDocumentLB(SvLockBytes * pDocLB)228cdf0e10cSrcweir void SetDocumentLB (SvLockBytes *pDocLB) { m_xDocLB = pDocLB; } 229cdf0e10cSrcweir operator <<(SvStream & rStrm,const INetMessage & rMsg)230cdf0e10cSrcweir friend SvStream& operator<< ( 231cdf0e10cSrcweir SvStream& rStrm, const INetMessage& rMsg) 232cdf0e10cSrcweir { 233cdf0e10cSrcweir return rMsg.operator<< (rStrm); 234cdf0e10cSrcweir } 235cdf0e10cSrcweir operator >>(SvStream & rStrm,INetMessage & rMsg)236cdf0e10cSrcweir friend SvStream& operator>> ( 237cdf0e10cSrcweir SvStream& rStrm, INetMessage& rMsg) 238cdf0e10cSrcweir { 239cdf0e10cSrcweir return rMsg.operator>> (rStrm); 240cdf0e10cSrcweir } 241cdf0e10cSrcweir }; 242cdf0e10cSrcweir 243cdf0e10cSrcweir /*======================================================================= 244cdf0e10cSrcweir * 245cdf0e10cSrcweir * INetMessageHeaderIterator Interface. 246cdf0e10cSrcweir * 247cdf0e10cSrcweir *=====================================================================*/ 248cdf0e10cSrcweir class INetMessageHeaderIterator 249cdf0e10cSrcweir { 250cdf0e10cSrcweir sal_uIntPtr nValueCount; 251cdf0e10cSrcweir List aValueList; 252cdf0e10cSrcweir UniString aEmptyString; 253cdf0e10cSrcweir 254cdf0e10cSrcweir public: 255cdf0e10cSrcweir INetMessageHeaderIterator ( 256cdf0e10cSrcweir const INetMessage& rMsg, const UniString& rHdrName); 257cdf0e10cSrcweir virtual ~INetMessageHeaderIterator (void); 258cdf0e10cSrcweir GetValueCount(void) const259cdf0e10cSrcweir sal_uIntPtr GetValueCount (void) const { return nValueCount; } GetValue(sal_uIntPtr nIndex) const260cdf0e10cSrcweir const UniString& GetValue (sal_uIntPtr nIndex) const 261cdf0e10cSrcweir { 262cdf0e10cSrcweir if (nIndex < nValueCount) 263cdf0e10cSrcweir { 264cdf0e10cSrcweir return *((UniString*)(aValueList.GetObject(nIndex))); 265cdf0e10cSrcweir } 266cdf0e10cSrcweir else 267cdf0e10cSrcweir { 268cdf0e10cSrcweir return aEmptyString; 269cdf0e10cSrcweir } 270cdf0e10cSrcweir } 271cdf0e10cSrcweir }; 272cdf0e10cSrcweir 273cdf0e10cSrcweir /*======================================================================= 274cdf0e10cSrcweir * 275cdf0e10cSrcweir * INetRFC822Message Interface. 276cdf0e10cSrcweir * 277cdf0e10cSrcweir *=====================================================================*/ 278cdf0e10cSrcweir #define INETMSG_RFC822_BCC 0 279cdf0e10cSrcweir #define INETMSG_RFC822_CC 1 280cdf0e10cSrcweir #define INETMSG_RFC822_COMMENTS 2 281cdf0e10cSrcweir #define INETMSG_RFC822_DATE 3 282cdf0e10cSrcweir #define INETMSG_RFC822_FROM 4 283cdf0e10cSrcweir #define INETMSG_RFC822_IN_REPLY_TO 5 284cdf0e10cSrcweir #define INETMSG_RFC822_KEYWORDS 6 285cdf0e10cSrcweir #define INETMSG_RFC822_MESSAGE_ID 7 286cdf0e10cSrcweir #define INETMSG_RFC822_REFERENCES 8 287cdf0e10cSrcweir #define INETMSG_RFC822_REPLY_TO 9 288cdf0e10cSrcweir #define INETMSG_RFC822_RETURN_PATH 10 289cdf0e10cSrcweir #define INETMSG_RFC822_SENDER 11 290cdf0e10cSrcweir #define INETMSG_RFC822_SUBJECT 12 291cdf0e10cSrcweir #define INETMSG_RFC822_TO 13 292cdf0e10cSrcweir 293cdf0e10cSrcweir #define INETMSG_RFC822_X_MAILER 14 294cdf0e10cSrcweir #define INETMSG_RFC822_RETURN_RECEIPT_TO 15 295cdf0e10cSrcweir 296cdf0e10cSrcweir #define INETMSG_RFC822_NUMHDR 16 297cdf0e10cSrcweir 298cdf0e10cSrcweir class TOOLS_DLLPUBLIC INetRFC822Message : public INetMessage 299cdf0e10cSrcweir { 300cdf0e10cSrcweir sal_uIntPtr m_nIndex[INETMSG_RFC822_NUMHDR]; 301cdf0e10cSrcweir 302cdf0e10cSrcweir protected: 303cdf0e10cSrcweir virtual SvStream& operator<< (SvStream& rStrm) const; 304cdf0e10cSrcweir virtual SvStream& operator>> (SvStream& rStrm); 305cdf0e10cSrcweir 306cdf0e10cSrcweir public: 307cdf0e10cSrcweir INetRFC822Message (void); 308cdf0e10cSrcweir INetRFC822Message (const INetRFC822Message& rMsg); 309cdf0e10cSrcweir virtual ~INetRFC822Message (void); 310cdf0e10cSrcweir 311cdf0e10cSrcweir INetRFC822Message& operator= (const INetRFC822Message& rMsg); 312cdf0e10cSrcweir 313cdf0e10cSrcweir static sal_Bool GenerateDateField ( 314cdf0e10cSrcweir const DateTime& rDateTime, UniString& rDateField); 315cdf0e10cSrcweir static sal_Bool ParseDateField ( 316cdf0e10cSrcweir const UniString& rDateField, DateTime& rDateTime); 317cdf0e10cSrcweir 318cdf0e10cSrcweir using INetMessage::SetHeaderField; 319cdf0e10cSrcweir virtual sal_uIntPtr SetHeaderField ( 320cdf0e10cSrcweir const INetMessageHeader &rHeader, sal_uIntPtr nIndex = LIST_APPEND); 321cdf0e10cSrcweir 322cdf0e10cSrcweir /** Header fields. 323cdf0e10cSrcweir */ 324cdf0e10cSrcweir void SetBCC (const UniString& rBCC); GetBCC(void) const325cdf0e10cSrcweir UniString GetBCC (void) const 326cdf0e10cSrcweir { 327cdf0e10cSrcweir return GetHeaderValue_Impl ( 328cdf0e10cSrcweir m_nIndex[INETMSG_RFC822_BCC], 329cdf0e10cSrcweir INetMIME::HEADER_FIELD_ADDRESS); 330cdf0e10cSrcweir } 331cdf0e10cSrcweir 332cdf0e10cSrcweir void SetCC (const UniString& rCC); GetCC(void) const333cdf0e10cSrcweir UniString GetCC (void) const 334cdf0e10cSrcweir { 335cdf0e10cSrcweir return GetHeaderValue_Impl ( 336cdf0e10cSrcweir m_nIndex[INETMSG_RFC822_CC], 337cdf0e10cSrcweir INetMIME::HEADER_FIELD_ADDRESS); 338cdf0e10cSrcweir } 339cdf0e10cSrcweir 340cdf0e10cSrcweir void SetComments (const UniString& rComments); GetComments(void) const341cdf0e10cSrcweir UniString GetComments (void) const 342cdf0e10cSrcweir { 343cdf0e10cSrcweir return GetHeaderValue_Impl ( 344cdf0e10cSrcweir m_nIndex[INETMSG_RFC822_COMMENTS], 345cdf0e10cSrcweir INetMIME::HEADER_FIELD_TEXT); 346cdf0e10cSrcweir } 347cdf0e10cSrcweir 348cdf0e10cSrcweir void SetDate (const UniString& rDate); GetDate(void) const349cdf0e10cSrcweir UniString GetDate (void) const 350cdf0e10cSrcweir { 351cdf0e10cSrcweir return GetHeaderValue_Impl ( 352cdf0e10cSrcweir m_nIndex[INETMSG_RFC822_DATE], 353cdf0e10cSrcweir INetMIME::HEADER_FIELD_STRUCTURED); 354cdf0e10cSrcweir } 355cdf0e10cSrcweir 356cdf0e10cSrcweir void SetFrom (const UniString& rFrom); GetFrom(void) const357cdf0e10cSrcweir UniString GetFrom (void) const 358cdf0e10cSrcweir { 359cdf0e10cSrcweir return GetHeaderValue_Impl ( 360cdf0e10cSrcweir m_nIndex[INETMSG_RFC822_FROM], 361cdf0e10cSrcweir INetMIME::HEADER_FIELD_ADDRESS); 362cdf0e10cSrcweir } 363cdf0e10cSrcweir 364cdf0e10cSrcweir void SetInReplyTo (const UniString& rInReplyTo); GetInReplyTo(void) const365cdf0e10cSrcweir UniString GetInReplyTo (void) const 366cdf0e10cSrcweir { 367cdf0e10cSrcweir return GetHeaderValue_Impl ( 368cdf0e10cSrcweir m_nIndex[INETMSG_RFC822_IN_REPLY_TO], 369cdf0e10cSrcweir INetMIME::HEADER_FIELD_ADDRESS); // ??? MESSAGE_ID ??? 370cdf0e10cSrcweir } 371cdf0e10cSrcweir 372cdf0e10cSrcweir void SetKeywords (const UniString& rKeywords); GetKeywords(void) const373cdf0e10cSrcweir UniString GetKeywords (void) const 374cdf0e10cSrcweir { 375cdf0e10cSrcweir return GetHeaderValue_Impl ( 376cdf0e10cSrcweir m_nIndex[INETMSG_RFC822_KEYWORDS], 377cdf0e10cSrcweir INetMIME::HEADER_FIELD_PHRASE); 378cdf0e10cSrcweir } 379cdf0e10cSrcweir 380cdf0e10cSrcweir void SetMessageID (const UniString& rMessageID); GetMessageID(void) const381cdf0e10cSrcweir UniString GetMessageID (void) const 382cdf0e10cSrcweir { 383cdf0e10cSrcweir return GetHeaderValue_Impl ( 384cdf0e10cSrcweir m_nIndex[INETMSG_RFC822_MESSAGE_ID], 385cdf0e10cSrcweir INetMIME::HEADER_FIELD_MESSAGE_ID); 386cdf0e10cSrcweir } 387cdf0e10cSrcweir 388cdf0e10cSrcweir void SetReferences (const UniString& rReferences); GetReferences(void) const389cdf0e10cSrcweir UniString GetReferences (void) const 390cdf0e10cSrcweir { 391cdf0e10cSrcweir return GetHeaderValue_Impl ( 392cdf0e10cSrcweir m_nIndex[INETMSG_RFC822_REFERENCES], 393cdf0e10cSrcweir INetMIME::HEADER_FIELD_ADDRESS); 394cdf0e10cSrcweir } 395cdf0e10cSrcweir 396cdf0e10cSrcweir void SetReplyTo (const UniString& rReplyTo); GetReplyTo(void) const397cdf0e10cSrcweir UniString GetReplyTo (void) const 398cdf0e10cSrcweir { 399cdf0e10cSrcweir return GetHeaderValue_Impl ( 400cdf0e10cSrcweir m_nIndex[INETMSG_RFC822_REPLY_TO], 401cdf0e10cSrcweir INetMIME::HEADER_FIELD_ADDRESS); 402cdf0e10cSrcweir } 403cdf0e10cSrcweir 404cdf0e10cSrcweir void SetReturnPath (const UniString& rReturnPath); GetReturnPath(void) const405cdf0e10cSrcweir UniString GetReturnPath (void) const 406cdf0e10cSrcweir { 407cdf0e10cSrcweir return GetHeaderValue_Impl ( 408cdf0e10cSrcweir m_nIndex[INETMSG_RFC822_RETURN_PATH], 409cdf0e10cSrcweir INetMIME::HEADER_FIELD_ADDRESS); 410cdf0e10cSrcweir } 411cdf0e10cSrcweir 412cdf0e10cSrcweir void SetReturnReceiptTo (const UniString& rReturnReceiptTo); GetReturnReceiptTo(void) const413cdf0e10cSrcweir UniString GetReturnReceiptTo (void) const 414cdf0e10cSrcweir { 415cdf0e10cSrcweir return GetHeaderValue_Impl ( 416cdf0e10cSrcweir m_nIndex[INETMSG_RFC822_RETURN_RECEIPT_TO], 417cdf0e10cSrcweir INetMIME::HEADER_FIELD_ADDRESS); 418cdf0e10cSrcweir } 419cdf0e10cSrcweir 420cdf0e10cSrcweir void SetSender (const UniString& rSender); GetSender(void) const421cdf0e10cSrcweir UniString GetSender (void) const 422cdf0e10cSrcweir { 423cdf0e10cSrcweir return GetHeaderValue_Impl ( 424cdf0e10cSrcweir m_nIndex[INETMSG_RFC822_SENDER], 425cdf0e10cSrcweir INetMIME::HEADER_FIELD_ADDRESS); 426cdf0e10cSrcweir } 427cdf0e10cSrcweir 428cdf0e10cSrcweir void SetSubject (const UniString& rSubject); GetSubject(void) const429cdf0e10cSrcweir UniString GetSubject (void) const 430cdf0e10cSrcweir { 431cdf0e10cSrcweir return GetHeaderValue_Impl ( 432cdf0e10cSrcweir m_nIndex[INETMSG_RFC822_SUBJECT], 433cdf0e10cSrcweir INetMIME::HEADER_FIELD_TEXT); 434cdf0e10cSrcweir } 435cdf0e10cSrcweir 436cdf0e10cSrcweir void SetTo (const UniString& rTo); GetTo(void) const437cdf0e10cSrcweir UniString GetTo (void) const 438cdf0e10cSrcweir { 439cdf0e10cSrcweir return GetHeaderValue_Impl ( 440cdf0e10cSrcweir m_nIndex[INETMSG_RFC822_TO], 441cdf0e10cSrcweir INetMIME::HEADER_FIELD_TEXT); 442cdf0e10cSrcweir } 443cdf0e10cSrcweir 444cdf0e10cSrcweir void SetXMailer (const UniString& rXMailer); GetXMailer(void) const445cdf0e10cSrcweir UniString GetXMailer (void) const 446cdf0e10cSrcweir { 447cdf0e10cSrcweir return GetHeaderValue_Impl ( 448cdf0e10cSrcweir m_nIndex[INETMSG_RFC822_X_MAILER], 449cdf0e10cSrcweir INetMIME::HEADER_FIELD_TEXT); 450cdf0e10cSrcweir } 451cdf0e10cSrcweir 452cdf0e10cSrcweir /** Stream operators. 453cdf0e10cSrcweir */ operator <<(SvStream & rStrm,const INetRFC822Message & rMsg)454cdf0e10cSrcweir friend SvStream& operator<< ( 455cdf0e10cSrcweir SvStream& rStrm, const INetRFC822Message& rMsg) 456cdf0e10cSrcweir { 457cdf0e10cSrcweir return rMsg.operator<< (rStrm); 458cdf0e10cSrcweir } 459cdf0e10cSrcweir operator >>(SvStream & rStrm,INetRFC822Message & rMsg)460cdf0e10cSrcweir friend SvStream& operator>> ( 461cdf0e10cSrcweir SvStream& rStrm, INetRFC822Message& rMsg) 462cdf0e10cSrcweir { 463cdf0e10cSrcweir return rMsg.operator>> (rStrm); 464cdf0e10cSrcweir } 465cdf0e10cSrcweir }; 466cdf0e10cSrcweir 467cdf0e10cSrcweir /*======================================================================= 468cdf0e10cSrcweir * 469cdf0e10cSrcweir * INetMIMEMessage Interface. 470cdf0e10cSrcweir * 471cdf0e10cSrcweir *=====================================================================*/ 472cdf0e10cSrcweir #define INETMSG_MIME_VERSION 0 473cdf0e10cSrcweir #define INETMSG_MIME_CONTENT_DESCRIPTION 1 474cdf0e10cSrcweir #define INETMSG_MIME_CONTENT_DISPOSITION 2 475cdf0e10cSrcweir #define INETMSG_MIME_CONTENT_ID 3 476cdf0e10cSrcweir #define INETMSG_MIME_CONTENT_TYPE 4 477cdf0e10cSrcweir #define INETMSG_MIME_CONTENT_TRANSFER_ENCODING 5 478cdf0e10cSrcweir 479cdf0e10cSrcweir #define INETMSG_MIME_NUMHDR 6 480cdf0e10cSrcweir 481cdf0e10cSrcweir enum INetMessageContainerType 482cdf0e10cSrcweir { 483cdf0e10cSrcweir INETMSG_MESSAGE_RFC822, 484cdf0e10cSrcweir INETMSG_MULTIPART_MIXED, 485cdf0e10cSrcweir INETMSG_MULTIPART_ALTERNATIVE, 486cdf0e10cSrcweir INETMSG_MULTIPART_DIGEST, 487cdf0e10cSrcweir INETMSG_MULTIPART_PARALLEL, 488cdf0e10cSrcweir INETMSG_MULTIPART_RELATED, 489cdf0e10cSrcweir INETMSG_MULTIPART_FORM_DATA 490cdf0e10cSrcweir }; 491cdf0e10cSrcweir 492cdf0e10cSrcweir class TOOLS_DLLPUBLIC INetMIMEMessage : public INetRFC822Message 493cdf0e10cSrcweir { 494cdf0e10cSrcweir sal_uIntPtr m_nIndex[INETMSG_MIME_NUMHDR]; 495cdf0e10cSrcweir 496cdf0e10cSrcweir INetMIMEMessage *pParent; 497cdf0e10cSrcweir sal_uIntPtr nNumChildren; 498cdf0e10cSrcweir List aChildren; 499cdf0e10cSrcweir ByteString m_aBoundary; 500cdf0e10cSrcweir sal_Bool bHeaderParsed; 501cdf0e10cSrcweir 502cdf0e10cSrcweir friend class INetMIMEMessageStream; 503cdf0e10cSrcweir SetChildCount(sal_uIntPtr nCount)504cdf0e10cSrcweir void SetChildCount (sal_uIntPtr nCount) { nNumChildren = nCount; } GetMultipartBoundary(void) const505cdf0e10cSrcweir const ByteString& GetMultipartBoundary (void) const { return m_aBoundary; } SetMultipartBoundary(const ByteString & rBnd)506cdf0e10cSrcweir void SetMultipartBoundary (const ByteString& rBnd) { m_aBoundary = rBnd; } 507cdf0e10cSrcweir 508cdf0e10cSrcweir void CleanupImp (void); 509cdf0e10cSrcweir void CopyImp (const INetMIMEMessage& rMsg); SetHeaderParsed()510cdf0e10cSrcweir void SetHeaderParsed() { bHeaderParsed = sal_True; } 511cdf0e10cSrcweir 512cdf0e10cSrcweir protected: 513cdf0e10cSrcweir virtual SvStream& operator<< (SvStream& rStrm) const; 514cdf0e10cSrcweir virtual SvStream& operator>> (SvStream& rStrm); 515cdf0e10cSrcweir 516cdf0e10cSrcweir public: 517cdf0e10cSrcweir INetMIMEMessage (void); 518cdf0e10cSrcweir INetMIMEMessage (const INetMIMEMessage& rMsg); 519cdf0e10cSrcweir virtual ~INetMIMEMessage (void); 520cdf0e10cSrcweir 521cdf0e10cSrcweir INetMIMEMessage& operator= (const INetMIMEMessage& rMsg); 522cdf0e10cSrcweir HeaderParsed() const523cdf0e10cSrcweir sal_Bool HeaderParsed() const { return bHeaderParsed; } 524cdf0e10cSrcweir 525cdf0e10cSrcweir virtual INetMIMEMessage* CreateMessage ( 526cdf0e10cSrcweir const INetMIMEMessage& rMsg) const; 527cdf0e10cSrcweir 528cdf0e10cSrcweir using INetRFC822Message::SetHeaderField; 529cdf0e10cSrcweir virtual sal_uIntPtr SetHeaderField ( 530cdf0e10cSrcweir const INetMessageHeader &rHeader, sal_uIntPtr nIndex = LIST_APPEND); 531cdf0e10cSrcweir 532cdf0e10cSrcweir /** Header fields. 533cdf0e10cSrcweir */ 534cdf0e10cSrcweir void SetMIMEVersion (const UniString& rVersion); GetMIMEVersion(void) const535cdf0e10cSrcweir UniString GetMIMEVersion (void) const 536cdf0e10cSrcweir { 537cdf0e10cSrcweir return GetHeaderValue (m_nIndex[INETMSG_MIME_VERSION]); 538cdf0e10cSrcweir } 539cdf0e10cSrcweir 540cdf0e10cSrcweir void SetContentDescription (const UniString& rDescription); GetContentDescription(void) const541cdf0e10cSrcweir UniString GetContentDescription (void) const 542cdf0e10cSrcweir { 543cdf0e10cSrcweir return GetHeaderValue (m_nIndex[INETMSG_MIME_CONTENT_DESCRIPTION]); 544cdf0e10cSrcweir } 545cdf0e10cSrcweir 546cdf0e10cSrcweir void SetContentDisposition (const UniString& rDisposition); GetContentDisposition(void) const547cdf0e10cSrcweir UniString GetContentDisposition (void) const 548cdf0e10cSrcweir { 549cdf0e10cSrcweir return GetHeaderValue (m_nIndex[INETMSG_MIME_CONTENT_DISPOSITION]); 550cdf0e10cSrcweir } 551cdf0e10cSrcweir 552cdf0e10cSrcweir void SetContentID (const UniString& rID); GetContentID(void) const553cdf0e10cSrcweir UniString GetContentID (void) const 554cdf0e10cSrcweir { 555cdf0e10cSrcweir return GetHeaderValue (m_nIndex[INETMSG_MIME_CONTENT_ID]); 556cdf0e10cSrcweir } 557cdf0e10cSrcweir 558cdf0e10cSrcweir void SetContentType (const UniString& rType); GetContentType(void) const559cdf0e10cSrcweir UniString GetContentType (void) const 560cdf0e10cSrcweir { 561cdf0e10cSrcweir return GetHeaderValue (m_nIndex[INETMSG_MIME_CONTENT_TYPE]); 562cdf0e10cSrcweir } 563cdf0e10cSrcweir 564cdf0e10cSrcweir void SetContentTransferEncoding (const UniString& rEncoding); GetContentTransferEncoding(void) const565cdf0e10cSrcweir UniString GetContentTransferEncoding (void) const 566cdf0e10cSrcweir { 567cdf0e10cSrcweir return GetHeaderValue (m_nIndex[INETMSG_MIME_CONTENT_TRANSFER_ENCODING]); 568cdf0e10cSrcweir } 569cdf0e10cSrcweir 570cdf0e10cSrcweir virtual void GetDefaultContentType (UniString& rContentType); 571cdf0e10cSrcweir 572cdf0e10cSrcweir /** Message container methods. 573cdf0e10cSrcweir */ IsContainer(void) const574cdf0e10cSrcweir sal_Bool IsContainer (void) const 575cdf0e10cSrcweir { 576cdf0e10cSrcweir return (IsMessage() || IsMultipart()); 577cdf0e10cSrcweir } IsMessage(void) const578cdf0e10cSrcweir sal_Bool IsMessage (void) const 579cdf0e10cSrcweir { 580cdf0e10cSrcweir UniString aType (GetContentType()); 581cdf0e10cSrcweir return (aType.CompareIgnoreCaseToAscii("message/", 8) == 0); 582cdf0e10cSrcweir } IsMultipart(void) const583cdf0e10cSrcweir sal_Bool IsMultipart (void) const 584cdf0e10cSrcweir { 585cdf0e10cSrcweir UniString aType (GetContentType()); 586cdf0e10cSrcweir return (aType.CompareIgnoreCaseToAscii("multipart/", 10) == 0); 587cdf0e10cSrcweir } 588cdf0e10cSrcweir GetChildCount(void) const589cdf0e10cSrcweir sal_uIntPtr GetChildCount (void) const { return nNumChildren; } GetChild(sal_uIntPtr nIndex) const590cdf0e10cSrcweir INetMIMEMessage* GetChild (sal_uIntPtr nIndex) const 591cdf0e10cSrcweir { 592cdf0e10cSrcweir return ((INetMIMEMessage *)(aChildren.GetObject (nIndex))); 593cdf0e10cSrcweir } GetParent(void) const594cdf0e10cSrcweir INetMIMEMessage* GetParent (void) const { return pParent; } 595cdf0e10cSrcweir 596cdf0e10cSrcweir sal_Bool EnableAttachChild ( 597cdf0e10cSrcweir INetMessageContainerType eType = INETMSG_MULTIPART_MIXED); 598cdf0e10cSrcweir sal_Bool AttachChild ( 599cdf0e10cSrcweir INetMIMEMessage& rChildMsg, sal_Bool bOwner = sal_True); 600cdf0e10cSrcweir sal_Bool DetachChild ( 601cdf0e10cSrcweir sal_uIntPtr nIndex, INetMIMEMessage& rChildMsg) const; 602cdf0e10cSrcweir 603cdf0e10cSrcweir /** Stream operators. 604cdf0e10cSrcweir */ operator <<(SvStream & rStrm,const INetMIMEMessage & rMsg)605cdf0e10cSrcweir friend SvStream& operator<< ( 606cdf0e10cSrcweir SvStream& rStrm, const INetMIMEMessage& rMsg) 607cdf0e10cSrcweir { 608cdf0e10cSrcweir return rMsg.operator<< (rStrm); 609cdf0e10cSrcweir } 610cdf0e10cSrcweir operator >>(SvStream & rStrm,INetMIMEMessage & rMsg)611cdf0e10cSrcweir friend SvStream& operator>> ( 612cdf0e10cSrcweir SvStream& rStrm, INetMIMEMessage& rMsg) 613cdf0e10cSrcweir { 614cdf0e10cSrcweir return rMsg.operator>> (rStrm); 615cdf0e10cSrcweir } 616cdf0e10cSrcweir }; 617cdf0e10cSrcweir 618cdf0e10cSrcweir #endif /* !_TOOLS_INETMSG_HXX */ 619