xref: /aoo42x/main/ucb/source/ucp/gvfs/gvfs_stream.hxx (revision 6df1ea1f)
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 _GVFSSTREAM_HXX_
24 #define _GVFSSTREAM_HXX_
25 
26 #include <sal/types.h>
27 #include <rtl/ustring.hxx>
28 #include <cppuhelper/weak.hxx>
29 #include <com/sun/star/io/XStream.hpp>
30 #include <com/sun/star/io/XInputStream.hpp>
31 #include <com/sun/star/io/XOutputStream.hpp>
32 #include <com/sun/star/io/XTruncate.hpp>
33 #include <com/sun/star/io/XSeekable.hpp>
34 
35 #include <libgnomevfs/gnome-vfs-handle.h>
36 
37 namespace gvfs
38 {
39 
40 class Stream : public ::com::sun::star::io::XStream,
41 	       public ::com::sun::star::io::XInputStream,
42 	       public ::com::sun::star::io::XOutputStream,
43 	       public ::com::sun::star::io::XTruncate,
44 	       public ::com::sun::star::io::XSeekable,
45 	       public ::cppu::OWeakObject
46 {
47 private:
48 	GnomeVFSHandle  *m_handle;
49 	GnomeVFSFileInfo m_info;
50 	osl::Mutex       m_aMutex;
51 	sal_Bool         m_eof;
52 	sal_Bool         m_bInputStreamCalled;
53 	sal_Bool         m_bOutputStreamCalled;
54 
55 	void throwOnError( GnomeVFSResult result )
56 		throw( ::com::sun::star::io::NotConnectedException,
57 		       ::com::sun::star::io::BufferSizeExceededException,
58 		       ::com::sun::star::io::IOException,
59 		       ::com::sun::star::uno::RuntimeException );
60 
61 	void closeStream( void )
62 		throw( ::com::sun::star::io::NotConnectedException,
63 		       ::com::sun::star::io::IOException,
64 		       ::com::sun::star::uno::RuntimeException );
65 
66 public:
67 	Stream ( GnomeVFSHandle         *handle,
68 		 const GnomeVFSFileInfo *aInfo );
69 	virtual ~Stream();
70 
71 	// XInterface
72 	virtual com::sun::star::uno::Any SAL_CALL queryInterface(const ::com::sun::star::uno::Type & type )
73 		throw( ::com::sun::star::uno::RuntimeException );
acquire(void)74 	virtual void SAL_CALL acquire( void )
75 		throw ()
76 			{ OWeakObject::acquire(); }
release(void)77 	virtual void SAL_CALL release( void )
78 		throw()
79 			{ OWeakObject::release(); }
80 
81 	// XStream
82 	virtual com::sun::star::uno::Reference< com::sun::star::io::XInputStream > SAL_CALL getInputStream(  )
83 		throw( com::sun::star::uno::RuntimeException );
84 
85 	virtual com::sun::star::uno::Reference< com::sun::star::io::XOutputStream > SAL_CALL getOutputStream(  )
86 		throw( com::sun::star::uno::RuntimeException );
87 
88 	// XInputStream
89 	virtual sal_Int32 SAL_CALL readBytes(
90 	  		::com::sun::star::uno::Sequence< sal_Int8 > & aData,
91 			sal_Int32 nBytesToRead )
92 				throw( ::com::sun::star::io::NotConnectedException,
93 			   		   ::com::sun::star::io::BufferSizeExceededException,
94 			   		   ::com::sun::star::io::IOException,
95 			   		   ::com::sun::star::uno::RuntimeException );
96 
97 	virtual sal_Int32 SAL_CALL readSomeBytes(
98     		::com::sun::star::uno::Sequence< sal_Int8 > & aData,
99 			sal_Int32 nMaxBytesToRead )
100         		throw( ::com::sun::star::io::NotConnectedException,
101                		   ::com::sun::star::io::BufferSizeExceededException,
102                		   ::com::sun::star::io::IOException,
103                		   ::com::sun::star::uno::RuntimeException );
104 
105 	virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip )
106         		throw( ::com::sun::star::io::NotConnectedException,
107                		   ::com::sun::star::io::BufferSizeExceededException,
108                		   ::com::sun::star::io::IOException,
109                		   ::com::sun::star::uno::RuntimeException );
110 
111 	virtual sal_Int32 SAL_CALL available( void )
112         		throw( ::com::sun::star::io::NotConnectedException,
113                		   ::com::sun::star::io::IOException,
114                		   ::com::sun::star::uno::RuntimeException );
115 
116 	virtual void SAL_CALL closeInput( void )
117         		throw( ::com::sun::star::io::NotConnectedException,
118                		   ::com::sun::star::io::IOException,
119                		   ::com::sun::star::uno::RuntimeException );
120 
121 	// XSeekable
122 	virtual void SAL_CALL seek(	sal_Int64 location )
123 		throw( ::com::sun::star::lang::IllegalArgumentException,
124 			   ::com::sun::star::io::IOException,
125 			   ::com::sun::star::uno::RuntimeException );
126 
127 	virtual sal_Int64 SAL_CALL getPosition()
128 		throw( ::com::sun::star::io::IOException,
129 			   ::com::sun::star::uno::RuntimeException );
130 
131 	virtual sal_Int64 SAL_CALL getLength()
132 		throw( ::com::sun::star::io::IOException,
133 			   ::com::sun::star::uno::RuntimeException );
134 
135         // XOutputStream
136 	virtual void SAL_CALL writeBytes( const com::sun::star::uno::Sequence< sal_Int8 >& aData )
137 		throw( com::sun::star::io::NotConnectedException,
138 		       com::sun::star::io::BufferSizeExceededException,
139 		       com::sun::star::io::IOException,
140 		       com::sun::star::uno::RuntimeException);
141 
142 	virtual void SAL_CALL flush( void )
143 		throw( com::sun::star::io::NotConnectedException,
144 		       com::sun::star::io::BufferSizeExceededException,
145 		       com::sun::star::io::IOException,
146 		       com::sun::star::uno::RuntimeException);
147 
148 
149         virtual void SAL_CALL closeOutput( void )
150 		throw( com::sun::star::io::NotConnectedException,
151 		       com::sun::star::io::IOException,
152 		       com::sun::star::uno::RuntimeException );
153 
154 	// XTruncate
155 	virtual void SAL_CALL truncate( void )
156 		throw( com::sun::star::io::IOException,
157 		       com::sun::star::uno::RuntimeException );
158 };
159 
160 } // namespace gvfs
161 #endif // _GVFSSTREAM_HXX_
162