Branch libreoffice-5-0-4
[LibreOffice.git] / include / tools / inetstrm.hxx
blobea6be1f9c0fed792eed5b0ccb7a16d3b5ef98197
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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;
27 class SvMemoryStream;
28 class SvStream;
30 enum INetStreamStatus
32 INETSTREAM_STATUS_LOADED = -4,
33 INETSTREAM_STATUS_WOULDBLOCK = -3,
34 INETSTREAM_STATUS_OK = -2,
35 INETSTREAM_STATUS_ERROR = -1
38 enum INetMessageStreamState
40 INETMSG_EOL_BEGIN,
41 INETMSG_EOL_DONE,
42 INETMSG_EOL_SCR,
43 INETMSG_EOL_FCR,
44 INETMSG_EOL_FLF,
45 INETMSG_EOL_FSP,
46 INETMSG_EOL_FESC
49 /// Message Generator Interface.
50 class INetMessageIStream
52 INetMIMEMessage *pSourceMsg;
53 bool bHeaderGenerated;
55 sal_uIntPtr nBufSiz;
56 sal_Char *pBuffer;
57 sal_Char *pRead;
58 sal_Char *pWrite;
60 SvStream *pMsgStrm;
61 SvMemoryStream *pMsgBuffer;
62 sal_Char *pMsgRead;
63 sal_Char *pMsgWrite;
65 INetMessageIStream (const INetMessageIStream& rStrm) SAL_DELETED_FUNCTION;
66 INetMessageIStream& operator= (const INetMessageIStream& rStrm) SAL_DELETED_FUNCTION;
68 protected:
69 virtual int GetMsgLine (sal_Char *pData, sal_uIntPtr nSize);
71 public:
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;
88 bool bHeaderParsed;
90 INetMessageStreamState eOState;
92 SvMemoryStream *pMsgBuffer;
94 INetMessageOStream (const INetMessageOStream& rStrm) SAL_DELETED_FUNCTION;
95 INetMessageOStream& operator= (const INetMessageOStream& rStrm) SAL_DELETED_FUNCTION;
97 protected:
98 virtual int PutMsgLine (const sal_Char *pData, sal_uIntPtr nSize);
100 public:
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
125 int eState;
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;
142 protected:
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;
146 public:
147 INetMIMEMessageStream (sal_uIntPtr nBufferSize = 2048);
148 virtual ~INetMIMEMessageStream();
151 #endif
153 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */