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 _TOOLS_INETSTRM_HXX
20 #define _TOOLS_INETSTRM_HXX
22 #include "tools/toolsdllapi.h"
23 #include <sal/types.h>
24 #include <tools/string.hxx>
27 class INetMIMEMessage
;
33 INETSTREAM_STATUS_LOADED
= -4,
34 INETSTREAM_STATUS_WOULDBLOCK
= -3,
35 INETSTREAM_STATUS_OK
= -2,
36 INETSTREAM_STATUS_ERROR
= -1
39 class TOOLS_DLLPUBLIC INetIStream
42 INetIStream (const INetIStream
& rStrm
);
43 INetIStream
& operator= (const INetIStream
& rStrm
);
46 virtual int GetData (sal_Char
*pData
, sal_uIntPtr nSize
) = 0;
50 virtual ~INetIStream (void);
52 int Read (sal_Char
*pData
, sal_uIntPtr nSize
);
58 INetOStream (const INetOStream
& rStrm
);
59 INetOStream
& operator= (const INetOStream
& rStrm
);
63 const sal_Char
*pData
, sal_uIntPtr nSize
) = 0;
67 virtual ~INetOStream (void);
69 int Write (const sal_Char
*pData
, sal_uIntPtr nSize
);
72 enum INetMessageStreamState
83 /// Message Generator Interface.
84 class INetMessageIStream
: public INetIStream
86 INetMessage
*pSourceMsg
;
87 sal_Bool bHeaderGenerated
;
95 SvMemoryStream
*pMsgBuffer
;
99 virtual int GetData (sal_Char
*pData
, sal_uIntPtr nSize
);
102 INetMessageIStream (const INetMessageIStream
& rStrm
);
103 INetMessageIStream
& operator= (const INetMessageIStream
& rStrm
);
106 virtual int GetMsgLine (sal_Char
*pData
, sal_uIntPtr nSize
);
109 INetMessageIStream (sal_uIntPtr nBufferSize
= 2048);
110 virtual ~INetMessageIStream (void);
112 INetMessage
*GetSourceMessage (void) const { return pSourceMsg
; }
113 void SetSourceMessage (INetMessage
*pMsg
) { pSourceMsg
= pMsg
; }
115 void GenerateHeader (sal_Bool bGen
= sal_True
) { bHeaderGenerated
= !bGen
; }
116 sal_Bool
IsHeaderGenerated (void) const { return bHeaderGenerated
; }
119 /// Message Parser Interface.
120 class INetMessageOStream
: public INetOStream
122 INetMessage
*pTargetMsg
;
123 sal_Bool bHeaderParsed
;
125 INetMessageStreamState eOState
;
127 SvMemoryStream
*pMsgBuffer
;
129 virtual int PutData (const sal_Char
*pData
, sal_uIntPtr nSize
);
132 INetMessageOStream (const INetMessageOStream
& rStrm
);
133 INetMessageOStream
& operator= (const INetMessageOStream
& rStrm
);
136 virtual int PutMsgLine (const sal_Char
*pData
, sal_uIntPtr nSize
);
139 INetMessageOStream (void);
140 virtual ~INetMessageOStream (void);
142 INetMessage
*GetTargetMessage (void) const { return pTargetMsg
; }
143 void SetTargetMessage (INetMessage
*pMsg
) { pTargetMsg
= pMsg
; }
145 void ParseHeader (sal_Bool bParse
= sal_True
) { bHeaderParsed
= !bParse
; }
146 sal_Bool
IsHeaderParsed (void) const { return bHeaderParsed
; }
149 class INetMessageIOStream
150 : public INetMessageIStream
,
151 public INetMessageOStream
154 INetMessageIOStream (const INetMessageIOStream
& rStrm
);
155 INetMessageIOStream
& operator= (const INetMessageIOStream
& rStrm
);
158 INetMessageIOStream (sal_uIntPtr nBufferSize
= 2048);
159 virtual ~INetMessageIOStream (void);
162 enum INetMessageEncoding
164 INETMSG_ENCODING_7BIT
,
165 INETMSG_ENCODING_8BIT
,
166 INETMSG_ENCODING_BINARY
,
167 INETMSG_ENCODING_QUOTED
,
168 INETMSG_ENCODING_BASE64
171 class TOOLS_DLLPUBLIC INetMIMEMessageStream
: public INetMessageIOStream
175 sal_uIntPtr nChildIndex
;
176 INetMIMEMessageStream
*pChildStrm
;
178 INetMessageEncoding eEncoding
;
179 INetMessageIStream
*pEncodeStrm
;
180 INetMessageOStream
*pDecodeStrm
;
182 SvMemoryStream
*pMsgBuffer
;
184 static INetMessageEncoding
GetMsgEncoding (
185 const String
& rContentType
);
188 INetMIMEMessageStream (const INetMIMEMessageStream
& rStrm
);
189 INetMIMEMessageStream
& operator= (const INetMIMEMessageStream
& rStrm
);
192 virtual int GetMsgLine (sal_Char
*pData
, sal_uIntPtr nSize
);
193 virtual int PutMsgLine (const sal_Char
*pData
, sal_uIntPtr nSize
);
196 INetMIMEMessageStream (sal_uIntPtr nBufferSize
= 2048);
197 virtual ~INetMIMEMessageStream (void);
199 using INetMessageIStream::SetSourceMessage
;
200 void SetSourceMessage (INetMIMEMessage
*pMsg
)
202 INetMessageIStream::SetSourceMessage ((INetMessage
*)pMsg
);
204 INetMIMEMessage
*GetSourceMessage (void) const
206 return ((INetMIMEMessage
*)INetMessageIStream::GetSourceMessage());
209 using INetMessageOStream::SetTargetMessage
;
210 void SetTargetMessage (INetMIMEMessage
*pMsg
)
212 INetMessageOStream::SetTargetMessage ((INetMessage
*)pMsg
);
214 INetMIMEMessage
*GetTargetMessage (void) const
216 return ((INetMIMEMessage
*)INetMessageOStream::GetTargetMessage());
222 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */