1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: transbnd.hxx,v $
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 ************************************************************************/
32 #define _TRANSBND_HXX "$Revision: 1.5 $"
35 #include <tools/solar.h>
39 #include <tools/datetime.hxx>
43 #include <tools/errcode.hxx>
47 #include <tools/link.hxx>
51 #include <tools/ref.hxx>
55 #include <tools/stream.hxx>
59 #include <tools/string.hxx>
63 #include <tools/urlobj.hxx>
67 #include <bf_so3/binding.hxx>
71 #include <bf_so3/transprt.hxx>
74 #ifndef INCLUDED_SO3DLLAPI_H
75 #include "bf_so3/so3dllapi.h"
80 class SfxCancelManager
;
83 class SvBindStatusCallback
;
84 SV_DECL_REF(SvBindStatusCallback
)
86 class SvKeyValueIterator
;
87 SV_DECL_REF(SvKeyValueIterator
)
90 #define COPYCTOR_API(C) C (const C&); C& operator= (const C&)
93 /*========================================================================
95 * SvBinding interface.
97 *======================================================================*/
98 class SO3_DLLPUBLIC SvBinding
: public SvBindingTransportCallback
, public SvRefBase
102 INetURLObject m_aUrlObj
;
103 SvBindStatusCallbackRef m_xCallback
;
105 SvBindingTransportContext m_aBindCtx
;
106 SvBindingTransport
*m_pTransport
;
107 SfxCancellable
*m_pCancelable
;
112 SvKeyValueIteratorRef m_xHeadIter
;
113 SvLockBytesRef m_xLockBytes
;
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 (
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
,
139 SvLockBytes
*pLockBytes
);
141 SO3_DLLPRIVATE
virtual void OnProgress (
142 ULONG nNow
, ULONG nEnd
, SvBindStatus eStatus
);
144 SO3_DLLPRIVATE
virtual void OnRedirect (
149 SO3_DLLPRIVATE
COPYCTOR_API(SvBinding
);
152 /** Destruction (SvRefBase).
154 SO3_DLLPRIVATE
virtual ~SvBinding (void);
159 SvBindStatusCallback
* GetCallback (void) const
166 SvBindingTransportContext
& GetBindContext (void)
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
; }
179 String
GetRedirectedURL (void) const
181 return m_aUrlObj
.GetMainURL(INetURLObject::DECODE_TO_IURI
);
186 const DateTime
& GetExpireDateTime (void) const
193 USHORT
GetPriority (void) const
195 return m_aBindCtx
.GetPriority();
197 void SetPriority (USHORT nPriority
)
199 m_aBindCtx
.SetPriority (nPriority
);
204 const String
& GetReferer (void) const
206 return m_aBindCtx
.GetReferer();
208 void SetReferer (const String
&rReferer
)
210 m_aBindCtx
.SetReferer (rReferer
);
215 const String
& GetSendMimeType (void) const
217 return m_aBindCtx
.GetSendMimeType();
219 void SetSendMimeType (const String
&rMime
)
221 m_aBindCtx
.SetSendMimeType (rMime
);
226 static BOOL
ShouldUseFtpProxy (const String
&rUrl
);
229 SV_DECL_IMPL_REF(SvBinding
);
231 /*========================================================================
233 * SvBindStatusCallback interface.
235 *======================================================================*/
236 struct SO3_DLLPRIVATE SvProgressArg
240 SvBindStatus eStatus
;
241 const String
&rStatus
;
244 SvProgressArg (const String
& rStatusText
) : rStatus (rStatusText
) {}
247 class SO3_DLLPUBLIC SvBindStatusCallback
: public SvRefBase
251 static Link m_aProgressCallback
;
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;
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 /*========================================================================
304 *======================================================================*/
305 class SO3_DLLPUBLIC SvKeyValue
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
)
328 SO3_DLLPRIVATE SvKeyValue
& operator= (SvKeyValue
&rOther
)
330 m_aKey
= rOther
.m_aKey
;
331 m_aValue
= rOther
.m_aValue
;
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
354 SvKeyValueList_Impl
* m_pList
;
359 SO3_DLLPRIVATE
COPYCTOR_API(SvKeyValueIterator
);
362 /** Construction/Destruction.
364 SvKeyValueIterator (void);
365 virtual ~SvKeyValueIterator (void);
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 */