fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / include / tools / inetstrm.hxx
blobd7b4e149d7982c557a490ce2995531498f9a09a4
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 _TOOLS_INETSTRM_HXX
20 #define _TOOLS_INETSTRM_HXX
22 #include "tools/toolsdllapi.h"
23 #include <sal/types.h>
24 #include <tools/string.hxx>
26 class INetMessage;
27 class INetMIMEMessage;
28 class SvMemoryStream;
29 class SvStream;
31 enum INetStreamStatus
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
41 // Not implemented.
42 INetIStream (const INetIStream& rStrm);
43 INetIStream& operator= (const INetIStream& rStrm);
45 protected:
46 virtual int GetData (sal_Char *pData, sal_uIntPtr nSize) = 0;
48 public:
49 INetIStream ();
50 virtual ~INetIStream (void);
52 int Read (sal_Char *pData, sal_uIntPtr nSize);
55 class INetOStream
57 // Not implemented.
58 INetOStream (const INetOStream& rStrm);
59 INetOStream& operator= (const INetOStream& rStrm);
61 protected:
62 virtual int PutData (
63 const sal_Char *pData, sal_uIntPtr nSize) = 0;
65 public:
66 INetOStream ();
67 virtual ~INetOStream (void);
69 int Write (const sal_Char *pData, sal_uIntPtr nSize);
72 enum INetMessageStreamState
74 INETMSG_EOL_BEGIN,
75 INETMSG_EOL_DONE,
76 INETMSG_EOL_SCR,
77 INETMSG_EOL_FCR,
78 INETMSG_EOL_FLF,
79 INETMSG_EOL_FSP,
80 INETMSG_EOL_FESC
83 /// Message Generator Interface.
84 class INetMessageIStream : public INetIStream
86 INetMessage *pSourceMsg;
87 sal_Bool bHeaderGenerated;
89 sal_uIntPtr nBufSiz;
90 sal_Char *pBuffer;
91 sal_Char *pRead;
92 sal_Char *pWrite;
94 SvStream *pMsgStrm;
95 SvMemoryStream *pMsgBuffer;
96 sal_Char *pMsgRead;
97 sal_Char *pMsgWrite;
99 virtual int GetData (sal_Char *pData, sal_uIntPtr nSize);
101 // Not implemented.
102 INetMessageIStream (const INetMessageIStream& rStrm);
103 INetMessageIStream& operator= (const INetMessageIStream& rStrm);
105 protected:
106 virtual int GetMsgLine (sal_Char *pData, sal_uIntPtr nSize);
108 public:
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);
131 // Not implemented.
132 INetMessageOStream (const INetMessageOStream& rStrm);
133 INetMessageOStream& operator= (const INetMessageOStream& rStrm);
135 protected:
136 virtual int PutMsgLine (const sal_Char *pData, sal_uIntPtr nSize);
138 public:
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
153 // Not implemented.
154 INetMessageIOStream (const INetMessageIOStream& rStrm);
155 INetMessageIOStream& operator= (const INetMessageIOStream& rStrm);
157 public:
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
173 int eState;
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);
187 // Not implemented.
188 INetMIMEMessageStream (const INetMIMEMessageStream& rStrm);
189 INetMIMEMessageStream& operator= (const INetMIMEMessageStream& rStrm);
191 protected:
192 virtual int GetMsgLine (sal_Char *pData, sal_uIntPtr nSize);
193 virtual int PutMsgLine (const sal_Char *pData, sal_uIntPtr nSize);
195 public:
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());
220 #endif
222 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */