1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef INCLUDED_TOOLS_INETSTRM_HXX
20 #define INCLUDED_TOOLS_INETSTRM_HXX
22 #include <tools/toolsdllapi.h>
23 #include <sal/types.h>
24 #include <rtl/ustring.hxx>
26 class INetMIMEMessage
;
32 INETSTREAM_STATUS_LOADED
= -4,
33 INETSTREAM_STATUS_WOULDBLOCK
= -3,
34 INETSTREAM_STATUS_OK
= -2,
35 INETSTREAM_STATUS_ERROR
= -1
38 enum INetMessageStreamState
49 /// Message Generator Interface.
50 class INetMessageIStream
52 INetMIMEMessage
*pSourceMsg
;
53 bool bHeaderGenerated
;
61 SvMemoryStream
*pMsgBuffer
;
65 INetMessageIStream (const INetMessageIStream
& rStrm
) SAL_DELETED_FUNCTION
;
66 INetMessageIStream
& operator= (const INetMessageIStream
& rStrm
) SAL_DELETED_FUNCTION
;
69 virtual int GetMsgLine (sal_Char
*pData
, sal_uIntPtr nSize
);
72 INetMessageIStream (sal_uIntPtr nBufferSize
= 2048);
73 virtual ~INetMessageIStream();
75 TOOLS_DLLPUBLIC
int Read (sal_Char
*pData
, sal_uIntPtr nSize
);
77 INetMIMEMessage
*GetSourceMessage() const { return pSourceMsg
; }
78 void SetSourceMessage (INetMIMEMessage
*pMsg
) { pSourceMsg
= pMsg
; }
80 void SetHeaderGenerated() { bHeaderGenerated
= true; }
81 bool IsHeaderGenerated() const { return bHeaderGenerated
; }
84 /// Message Parser Interface.
85 class INetMessageOStream
87 INetMIMEMessage
*pTargetMsg
;
90 INetMessageStreamState eOState
;
92 SvMemoryStream
*pMsgBuffer
;
94 INetMessageOStream (const INetMessageOStream
& rStrm
) SAL_DELETED_FUNCTION
;
95 INetMessageOStream
& operator= (const INetMessageOStream
& rStrm
) SAL_DELETED_FUNCTION
;
98 virtual int PutMsgLine (const sal_Char
*pData
, sal_uIntPtr nSize
);
101 INetMessageOStream();
102 virtual ~INetMessageOStream();
104 int Write (const sal_Char
*pData
, sal_uIntPtr nSize
);
106 INetMIMEMessage
*GetTargetMessage() const { return pTargetMsg
; }
107 void SetTargetMessage (INetMIMEMessage
*pMsg
) { pTargetMsg
= pMsg
; }
109 void ParseHeader (bool bParse
= true) { bHeaderParsed
= !bParse
; }
110 bool IsHeaderParsed() const { return bHeaderParsed
; }
113 enum INetMessageEncoding
115 INETMSG_ENCODING_7BIT
,
116 INETMSG_ENCODING_BINARY
,
117 INETMSG_ENCODING_QUOTED
,
118 INETMSG_ENCODING_BASE64
121 class TOOLS_DLLPUBLIC INetMIMEMessageStream
122 : public INetMessageIStream
,
123 public INetMessageOStream
127 sal_uIntPtr nChildIndex
;
128 INetMIMEMessageStream
*pChildStrm
;
130 INetMessageEncoding eEncoding
;
131 INetMessageIStream
*pEncodeStrm
;
132 INetMessageOStream
*pDecodeStrm
;
134 SvMemoryStream
*pMsgBuffer
;
136 static INetMessageEncoding
GetMsgEncoding (
137 const OUString
& rContentType
);
139 INetMIMEMessageStream (const INetMIMEMessageStream
& rStrm
) SAL_DELETED_FUNCTION
;
140 INetMIMEMessageStream
& operator= (const INetMIMEMessageStream
& rStrm
) SAL_DELETED_FUNCTION
;
143 virtual int GetMsgLine (sal_Char
*pData
, sal_uIntPtr nSize
) SAL_OVERRIDE
;
144 virtual int PutMsgLine (const sal_Char
*pData
, sal_uIntPtr nSize
) SAL_OVERRIDE
;
147 INetMIMEMessageStream (sal_uIntPtr nBufferSize
= 2048);
148 virtual ~INetMIMEMessageStream();
153 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */