Update ooo320-m1
[ooovba.git] / binfilter / inc / bf_so3 / transbnd.hxx
blob561093a1c2b16fe786c5c8e5b6e3e81ac08a53fd
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: transbnd.hxx,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _TRANSBND_HXX
32 #define _TRANSBND_HXX "$Revision: 1.5 $"
34 #ifndef _SOLAR_H
35 #include <tools/solar.h>
36 #endif
38 #ifndef _DATETIME_HXX
39 #include <tools/datetime.hxx>
40 #endif
42 #ifndef _ERRCODE_HXX
43 #include <tools/errcode.hxx>
44 #endif
46 #ifndef _LINK_HXX
47 #include <tools/link.hxx>
48 #endif
50 #ifndef _REF_HXX
51 #include <tools/ref.hxx>
52 #endif
54 #ifndef _STREAM_HXX
55 #include <tools/stream.hxx>
56 #endif
58 #ifndef _STRING_HXX
59 #include <tools/string.hxx>
60 #endif
62 #ifndef _URLOBJ_HXX
63 #include <tools/urlobj.hxx>
64 #endif
66 #ifndef _BINDING_HXX
67 #include <bf_so3/binding.hxx>
68 #endif
70 #ifndef _TRANSPRT_HXX
71 #include <bf_so3/transprt.hxx>
72 #endif
74 #ifndef INCLUDED_SO3DLLAPI_H
75 #include "bf_so3/so3dllapi.h"
76 #endif
78 namespace binfilter {
80 class SfxCancelManager;
81 class SfxCancellable;
83 class SvBindStatusCallback;
84 SV_DECL_REF(SvBindStatusCallback)
86 class SvKeyValueIterator;
87 SV_DECL_REF(SvKeyValueIterator)
89 #ifndef COPYCTOR_API
90 #define COPYCTOR_API(C) C (const C&); C& operator= (const C&)
91 #endif
93 /*========================================================================
95 * SvBinding interface.
97 *======================================================================*/
98 class SO3_DLLPUBLIC SvBinding : public SvBindingTransportCallback, public SvRefBase
100 /** Representation.
102 INetURLObject m_aUrlObj;
103 SvBindStatusCallbackRef m_xCallback;
105 SvBindingTransportContext m_aBindCtx;
106 SvBindingTransport *m_pTransport;
107 SfxCancellable *m_pCancelable;
109 ErrCode m_eErrCode;
110 String m_aMime;
111 DateTime m_aExpires;
112 SvKeyValueIteratorRef m_xHeadIter;
113 SvLockBytesRef m_xLockBytes;
115 BOOL m_bStarted : 1;
116 BOOL m_bComplete : 1;
117 BOOL m_bErrorDoc : 1;
118 BOOL m_bMimeAvail : 1;
120 /** SvBindingTransportCallback implementation.
122 SO3_DLLPRIVATE virtual void OnStart (void);
124 SO3_DLLPRIVATE virtual void OnError (
125 ErrCode eErrCode);
127 SO3_DLLPRIVATE virtual void OnMimeAvailable (
128 const String &rMime);
130 SO3_DLLPRIVATE virtual void OnExpiresAvailable (
131 const DateTime &rExpires);
133 SO3_DLLPRIVATE virtual void OnHeaderAvailable (
134 const String &rName, const String &rValue);
136 SO3_DLLPRIVATE virtual void OnDataAvailable (
137 SvStatusCallbackType eType,
138 ULONG nSize,
139 SvLockBytes *pLockBytes);
141 SO3_DLLPRIVATE virtual void OnProgress (
142 ULONG nNow, ULONG nEnd, SvBindStatus eStatus);
144 SO3_DLLPRIVATE virtual void OnRedirect (
145 const String &rUrl);
147 /** Not implemented.
149 SO3_DLLPRIVATE COPYCTOR_API(SvBinding);
151 protected:
152 /** Destruction (SvRefBase).
154 SO3_DLLPRIVATE virtual ~SvBinding (void);
156 public:
157 /** Callback.
159 SvBindStatusCallback* GetCallback (void) const
161 return m_xCallback;
164 /** BindContext.
166 SvBindingTransportContext & GetBindContext (void)
168 return m_aBindCtx;
171 /** Up/Download information.
173 ErrCode GetErrorCode (void) const { return m_eErrCode; }
174 BOOL IsComplete (void) const { return m_bComplete; }
175 BOOL IsErrorOutput (void) const { return m_bErrorDoc; }
177 /** RedirectedURL.
179 String GetRedirectedURL (void) const
181 return m_aUrlObj.GetMainURL(INetURLObject::DECODE_TO_IURI);
184 /** ExpireDateTime.
186 const DateTime& GetExpireDateTime (void) const
188 return m_aExpires;
191 /** Priority.
193 USHORT GetPriority (void) const
195 return m_aBindCtx.GetPriority();
197 void SetPriority (USHORT nPriority)
199 m_aBindCtx.SetPriority (nPriority);
202 /** Referer.
204 const String& GetReferer (void) const
206 return m_aBindCtx.GetReferer();
208 void SetReferer (const String &rReferer)
210 m_aBindCtx.SetReferer (rReferer);
213 /** SendMimeType.
215 const String& GetSendMimeType (void) const
217 return m_aBindCtx.GetSendMimeType();
219 void SetSendMimeType (const String &rMime)
221 m_aBindCtx.SetSendMimeType (rMime);
224 /** Proxy (FTP).
226 static BOOL ShouldUseFtpProxy (const String &rUrl);
229 SV_DECL_IMPL_REF(SvBinding);
231 /*========================================================================
233 * SvBindStatusCallback interface.
235 *======================================================================*/
236 struct SO3_DLLPRIVATE SvProgressArg
238 ULONG nProgress;
239 ULONG nMax;
240 SvBindStatus eStatus;
241 const String &rStatus;
242 float nRate;
244 SvProgressArg (const String& rStatusText) : rStatus (rStatusText) {}
247 class SO3_DLLPUBLIC SvBindStatusCallback : public SvRefBase
249 /** Representation.
251 static Link m_aProgressCallback;
253 Link m_aDoneLink;
254 Link m_aDataLink;
255 Link m_aReloadLink;
256 Link m_aPartLink;
258 ULONG m_nStartTicks;
260 BOOL m_bInAvailableCall : 1;
261 BOOL m_bDonePending : 1;
262 BOOL m_bDataPending : 1;
263 BOOL m_bReloadPending : 1;
264 BOOL m_bPartPending : 1;
266 public:
267 virtual ~SvBindStatusCallback (void);
269 static void SetProgressCallback (const Link &rLink);
270 void InitStartTime (void);
272 const Link& GetDoneLink (void) const { return m_aDoneLink; }
273 void SetDoneLink (const Link &rLink) { m_aDoneLink = rLink; }
275 const Link& GetDataAvailableLink (void) const { return m_aDataLink; }
276 void SetDataAvailableLink (const Link &rLink) { m_aDataLink = rLink; }
278 const Link& GetReloadAvailableLink (void) const { return m_aReloadLink; }
279 void SetReloadAvailableLink (const Link &rLink) { m_aReloadLink = rLink; }
281 const Link& GetNewPartAvailableLink (void) const { return m_aPartLink; }
282 void SetNewPartAvailableLink (const Link &rLink) { m_aPartLink = rLink; }
284 virtual void OnDataAvailable (
285 SvStatusCallbackType eType, ULONG, SvLockBytes&);
287 virtual void OnDataAvailable (
288 SvStatusCallbackType eType, ULONG, SvStream&);
290 virtual void OnProgress (
291 ULONG nProgress, ULONG nMax,
292 SvBindStatus eStatus, const String &rStatusText);
294 virtual void OnStopBinding (
295 ErrCode eErrCode, const String &rStatusText);
298 SV_IMPL_REF(SvBindStatusCallback);
300 /*========================================================================
302 * SvKeyValue.
304 *======================================================================*/
305 class SO3_DLLPUBLIC SvKeyValue
307 /** Representation.
309 String m_aKey;
310 String m_aValue;
312 public:
313 /** Construction.
315 SvKeyValue (void)
318 SvKeyValue (const String &rKey, const String &rValue)
319 : m_aKey (rKey), m_aValue (rValue)
322 SvKeyValue (const SvKeyValue &rOther)
323 : m_aKey (rOther.m_aKey), m_aValue (rOther.m_aValue)
326 /** Assignment.
328 SO3_DLLPRIVATE SvKeyValue& operator= (SvKeyValue &rOther)
330 m_aKey = rOther.m_aKey;
331 m_aValue = rOther.m_aValue;
332 return *this;
335 /** Operation.
337 const String& GetKey (void) const { return m_aKey; }
338 const String& GetValue (void) const { return m_aValue; }
340 void SetKey (const String &rKey ) { m_aKey = rKey; }
341 void SetValue (const String &rValue) { m_aValue = rValue; }
344 /*========================================================================
346 * SvKeyValueIterator.
348 *======================================================================*/
349 class SvKeyValueList_Impl;
350 class SO3_DLLPUBLIC SvKeyValueIterator : public SvRefBase
352 /** Representation.
354 SvKeyValueList_Impl* m_pList;
355 USHORT m_nPos;
357 /** Not implemented.
359 SO3_DLLPRIVATE COPYCTOR_API(SvKeyValueIterator);
361 public:
362 /** Construction/Destruction.
364 SvKeyValueIterator (void);
365 virtual ~SvKeyValueIterator (void);
367 /** Operation.
369 virtual BOOL GetFirst (SvKeyValue &rKeyVal);
370 virtual BOOL GetNext (SvKeyValue &rKeyVal);
371 virtual void Append (const SvKeyValue &rKeyVal);
374 SV_IMPL_REF(SvKeyValueIterator);
378 #endif /* _TRANSBND_HXX */