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: transprt.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 _TRANSPRT_HXX "$Revision: 1.5 $"
35 #include <tools/solar.h>
39 #include <tools/errcode.hxx>
43 #include <tools/stream.hxx>
47 #include <tools/string.hxx>
51 #include <bf_so3/binding.hxx>
54 #ifndef INCLUDED_SO3DLLAPI_H
55 #include "bf_so3/so3dllapi.h"
61 class SvBindingTransport
;
62 class SvBindingTransportFactory
;
63 class SvBindingTransportCallback
;
64 class SvBindingTransportContext
;
67 #define COPYCTOR_API(C) C (const C&); C& operator= (const C&)
70 /*========================================================================
72 * SvBindingTransport interface.
74 *======================================================================*/
75 class SO3_DLLPUBLIC SvBindingTransport
79 SO3_DLLPRIVATE
COPYCTOR_API(SvBindingTransport
);
82 SvBindingTransport (void);
83 virtual ~SvBindingTransport (void);
85 virtual void Start (void) = 0;
86 virtual void Abort (void) = 0;
89 /*========================================================================
91 * SvBindingTransportFactory interface.
93 *======================================================================*/
94 class SO3_DLLPUBLIC SvBindingTransportFactory
98 SO3_DLLPRIVATE
COPYCTOR_API(SvBindingTransportFactory
);
101 SvBindingTransportFactory (void);
102 virtual ~SvBindingTransportFactory (void);
104 virtual BOOL
HasTransport (
105 const String
&rUrl
) = 0;
107 virtual SvBindingTransport
* CreateTransport (
109 SvBindingTransportContext
&rCtx
,
110 SvBindingTransportCallback
*pCallback
) = 0;
113 /*========================================================================
115 * SvBindingTransportCallback interface.
117 *======================================================================*/
118 class SO3_DLLPUBLIC SvBindingTransportCallback
121 virtual void OnStart (void) = 0;
123 virtual void OnError (ErrCode eErrCode
) = 0;
125 virtual void OnMimeAvailable (const String
&rMime
) = 0;
127 virtual void OnExpiresAvailable (const DateTime
&rExpires
) = 0;
129 virtual void OnHeaderAvailable (
130 const String
&rName
, const String
&rValue
) = 0;
132 virtual void OnDataAvailable (
133 SvStatusCallbackType eType
,
134 ULONG nSize
, SvLockBytes
*pLockBytes
) = 0;
136 virtual void OnProgress (
137 ULONG nNow
, ULONG nEnd
, SvBindStatus eStatus
) = 0;
139 virtual void OnRedirect (const String
&rUrl
) = 0;
142 /*========================================================================
144 * SvBindingTransportContext.
146 *======================================================================*/
147 class SO3_DLLPUBLIC SvBindingTransportContext
151 SvBindAction m_eBindAction
;
152 SvBindMode m_eBindMode
;
153 StreamMode m_eStrmMode
;
156 String m_aSendMimeType
;
157 SvLockBytesRef m_xPostLockBytes
;
160 virtual ~SvBindingTransportContext (void);
164 SvBindAction
GetBindAction (void) const { return m_eBindAction
; }
165 void SetBindAction (SvBindAction eAction
) { m_eBindAction
= eAction
; }
169 SvBindMode
GetBindMode (void) const { return m_eBindMode
; }
170 void SetBindMode (SvBindMode eMode
) { m_eBindMode
= eMode
; }
174 StreamMode
GetStreamMode (void) const { return m_eStrmMode
; }
175 void SetStreamMode (StreamMode eMode
) { m_eStrmMode
= eMode
; }
179 USHORT
GetPriority (void) const { return m_nPriority
; }
180 void SetPriority (USHORT nPriority
) { m_nPriority
= nPriority
; }
184 const String
& GetReferer (void) const { return m_aReferer
; }
185 void SetReferer (const String
&rReferer
) { m_aReferer
= rReferer
; }
187 /** SendMimeType (actions PUT and POST).
189 const String
& GetSendMimeType (void) const
191 return m_aSendMimeType
;
193 void SetSendMimeType (const String
&rSendMimeType
)
195 m_aSendMimeType
= rSendMimeType
;
198 /** PostLockBytes (actions PUT and POST).
200 SvLockBytes
* GetPostLockBytes (void) const
202 return m_xPostLockBytes
;
204 void SetPostLockBytes (SvLockBytesRef
&rxPostLockBytes
)
206 m_xPostLockBytes
= rxPostLockBytes
;
210 /*========================================================================
212 * SvLockBytesFactory interface.
214 *======================================================================*/
215 class SO3_DLLPUBLIC SvLockBytesFactory
223 SO3_DLLPRIVATE
COPYCTOR_API(SvLockBytesFactory
);
226 virtual ~SvLockBytesFactory (void);
228 virtual SvLockBytesRef
CreateLockBytes (
229 const String
&rUrl
, String
&rMime
) = 0;
231 static SvLockBytesFactory
* GetFactory (const String
&rUrl
);
233 const String
& GetWildcard (void) const { return m_aWildcard
; }
236 /*========================================================================
238 * SfxSimpleLockBytesFactory interface.
240 *======================================================================*/
241 class SO3_DLLPUBLIC SfxSimpleLockBytesFactory
:
242 public SvLockBytesFactory
, public SvRefBase
246 SvLockBytesRef m_xLockBytes
;
249 static USHORT m_nCounter
;
253 SO3_DLLPRIVATE
COPYCTOR_API(SfxSimpleLockBytesFactory
);
256 /** Destruction (protected) (SvRefBase).
258 virtual ~SfxSimpleLockBytesFactory (void);
261 virtual SvLockBytesRef
CreateLockBytes (
262 const String
&rUrl
, String
&rMime
);
265 SV_DECL_IMPL_REF(SfxSimpleLockBytesFactory
);
267 /*========================================================================
269 * SvLockBytesTransportFactory interface.
271 *======================================================================*/
272 class SO3_DLLPUBLIC SvLockBytesTransportFactory
: public SvBindingTransportFactory
276 SO3_DLLPRIVATE
COPYCTOR_API(SvLockBytesTransportFactory
);
279 SvLockBytesTransportFactory (void);
280 virtual ~SvLockBytesTransportFactory (void);
282 virtual BOOL
HasTransport (
285 virtual SvBindingTransport
* CreateTransport (
287 SvBindingTransportContext
&rCtx
,
288 SvBindingTransportCallback
*pCB
);
291 /*========================================================================
293 * CntTransportFactory interface.
295 *======================================================================*/
296 class SO3_DLLPUBLIC CntTransportFactory
: public SvBindingTransportFactory
300 SO3_DLLPRIVATE
COPYCTOR_API(CntTransportFactory
);
303 CntTransportFactory (void);
304 virtual ~CntTransportFactory (void);
306 virtual BOOL
HasTransport (
309 virtual SvBindingTransport
* CreateTransport (
311 SvBindingTransportContext
&rCtx
,
312 SvBindingTransportCallback
*pCB
);
315 /*========================================================================
319 *======================================================================*/
323 #endif /* _TRANSPRT_HXX */