xref: /trunk/main/ucb/source/ucp/webdav/CurlInputStream.hxx (revision 914d351e5f5b84e4342a86d6ab8d4aca7308b9bd)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef INCLUDED_CURLINPUTSTREAM_HXX
24 #define INCLUDED_CURLINPUTSTREAM_HXX
25 
26 #include <sal/types.h>
27 #include <rtl/ustring.hxx>
28 #include <cppuhelper/weak.hxx>
29 #include <com/sun/star/io/XInputStream.hpp>
30 #include <com/sun/star/io/XSeekable.hpp>
31 
32 
33 namespace http_dav_ucp
34 {
35 
36 // -------------------------------------------------------------------
37 // CurlInputStream
38 // A simple XInputStream implementation provided specifically for use
39 // by the DAVSession::GET method.
40 // -------------------------------------------------------------------
41 class CurlInputStream : public ::com::sun::star::io::XInputStream,
42                         public ::com::sun::star::io::XSeekable,
43                         public ::cppu::OWeakObject
44 {
45     private:
46         com::sun::star::uno::Sequence< sal_Int8 > mInputBuffer;
47         sal_Int64 mLen;
48         sal_Int64 mPos;
49         sal_Int64 mCapacity;
50 
51     public:
52                  CurlInputStream( void );
53         virtual ~CurlInputStream();
54 
55         // Add some data to the end of the stream
56         void AddToStream( const char * inBuf, sal_Int32 inLen );
57 
58     // XInterface
59     virtual com::sun::star::uno::Any SAL_CALL queryInterface(
60                                         const ::com::sun::star::uno::Type & type )
61                             throw( ::com::sun::star::uno::RuntimeException );
62 
acquire(void)63     virtual void SAL_CALL acquire( void )
64                             throw ()
65                                 { OWeakObject::acquire(); }
66 
release(void)67     virtual void SAL_CALL release( void )
68                             throw()
69                                 { OWeakObject::release(); }
70 
71 
72     // XInputStream
73     virtual sal_Int32 SAL_CALL readBytes(
74             ::com::sun::star::uno::Sequence< sal_Int8 > & aData,
75             sal_Int32 nBytesToRead )
76                 throw( ::com::sun::star::io::NotConnectedException,
77                        ::com::sun::star::io::BufferSizeExceededException,
78                        ::com::sun::star::io::IOException,
79                        ::com::sun::star::uno::RuntimeException );
80 
81     virtual sal_Int32 SAL_CALL readSomeBytes(
82             ::com::sun::star::uno::Sequence< sal_Int8 > & aData,
83             sal_Int32 nMaxBytesToRead )
84                 throw( ::com::sun::star::io::NotConnectedException,
85                        ::com::sun::star::io::BufferSizeExceededException,
86                        ::com::sun::star::io::IOException,
87                        ::com::sun::star::uno::RuntimeException );
88 
89     virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip )
90                 throw( ::com::sun::star::io::NotConnectedException,
91                        ::com::sun::star::io::BufferSizeExceededException,
92                        ::com::sun::star::io::IOException,
93                        ::com::sun::star::uno::RuntimeException );
94 
95     virtual sal_Int32 SAL_CALL available( void )
96                 throw( ::com::sun::star::io::NotConnectedException,
97                        ::com::sun::star::io::IOException,
98                        ::com::sun::star::uno::RuntimeException );
99 
100     virtual void SAL_CALL closeInput( void )
101                 throw( ::com::sun::star::io::NotConnectedException,
102                        ::com::sun::star::io::IOException,
103                        ::com::sun::star::uno::RuntimeException );
104 
105     // XSeekable
106     virtual void SAL_CALL seek( sal_Int64 location )
107         throw( ::com::sun::star::lang::IllegalArgumentException,
108                ::com::sun::star::io::IOException,
109                ::com::sun::star::uno::RuntimeException );
110 
111     virtual sal_Int64 SAL_CALL getPosition()
112         throw( ::com::sun::star::io::IOException,
113                ::com::sun::star::uno::RuntimeException );
114 
115     virtual sal_Int64 SAL_CALL getLength()
116         throw( ::com::sun::star::io::IOException,
117                ::com::sun::star::uno::RuntimeException );
118 };
119 
120 } // namespace http_dav_ucp
121 
122 #endif // INCLUDED_CURLINPUTSTREAM_HXX
123