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_NEONINPUTSTREAM_HXX 24 #define INCLUDED_NEONINPUTSTREAM_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 // SerfInputStream 38 // A simple XInputStream implementation provided specifically for use 39 // by the DAVSession::GET method. 40 // ------------------------------------------------------------------- 41 class SerfInputStream : 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 50 public: 51 SerfInputStream( void ); 52 virtual ~SerfInputStream(); 53 54 // Add some data to the end of the stream 55 void AddToStream( const char * inBuf, sal_Int32 inLen ); 56 57 // XInterface 58 virtual com::sun::star::uno::Any SAL_CALL queryInterface( 59 const ::com::sun::star::uno::Type & type ) 60 throw( ::com::sun::star::uno::RuntimeException ); 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 throw( ::com::sun::star::io::NotConnectedException, 76 ::com::sun::star::io::BufferSizeExceededException, 77 ::com::sun::star::io::IOException, 78 ::com::sun::star::uno::RuntimeException ); 79 80 virtual sal_Int32 SAL_CALL readSomeBytes( 81 ::com::sun::star::uno::Sequence< sal_Int8 > & aData, 82 sal_Int32 nMaxBytesToRead ) 83 throw( ::com::sun::star::io::NotConnectedException, 84 ::com::sun::star::io::BufferSizeExceededException, 85 ::com::sun::star::io::IOException, 86 ::com::sun::star::uno::RuntimeException ); 87 88 virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip ) 89 throw( ::com::sun::star::io::NotConnectedException, 90 ::com::sun::star::io::BufferSizeExceededException, 91 ::com::sun::star::io::IOException, 92 ::com::sun::star::uno::RuntimeException ); 93 94 virtual sal_Int32 SAL_CALL available( void ) 95 throw( ::com::sun::star::io::NotConnectedException, 96 ::com::sun::star::io::IOException, 97 ::com::sun::star::uno::RuntimeException ); 98 99 virtual void SAL_CALL closeInput( void ) 100 throw( ::com::sun::star::io::NotConnectedException, 101 ::com::sun::star::io::IOException, 102 ::com::sun::star::uno::RuntimeException ); 103 104 // XSeekable 105 virtual void SAL_CALL seek( sal_Int64 location ) 106 throw( ::com::sun::star::lang::IllegalArgumentException, 107 ::com::sun::star::io::IOException, 108 ::com::sun::star::uno::RuntimeException ); 109 110 virtual sal_Int64 SAL_CALL getPosition() 111 throw( ::com::sun::star::io::IOException, 112 ::com::sun::star::uno::RuntimeException ); 113 114 virtual sal_Int64 SAL_CALL getLength() 115 throw( ::com::sun::star::io::IOException, 116 ::com::sun::star::uno::RuntimeException ); 117 }; 118 119 } // namespace http_dav_ucp 120 121 #endif // INCLUDED_NEONINPUTSTREAM_HXX 122