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 acquire(void)62 virtual void SAL_CALL acquire( void ) 63 throw () 64 { OWeakObject::acquire(); } 65 release(void)66 virtual void SAL_CALL release( void ) 67 throw() 68 { OWeakObject::release(); } 69 70 71 // XInputStream 72 virtual sal_Int32 SAL_CALL readBytes( 73 ::com::sun::star::uno::Sequence< sal_Int8 > & aData, 74 sal_Int32 nBytesToRead ); 75 76 virtual sal_Int32 SAL_CALL readSomeBytes( 77 ::com::sun::star::uno::Sequence< sal_Int8 > & aData, 78 sal_Int32 nMaxBytesToRead ); 79 80 virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip ); 81 82 virtual sal_Int32 SAL_CALL available( void ); 83 84 virtual void SAL_CALL closeInput( void ); 85 86 // XSeekable 87 virtual void SAL_CALL seek( sal_Int64 location ); 88 89 virtual sal_Int64 SAL_CALL getPosition(); 90 91 virtual sal_Int64 SAL_CALL getLength(); 92 }; 93 94 } // namespace http_dav_ucp 95 96 #endif // INCLUDED_CURLINPUTSTREAM_HXX 97