Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : : #ifndef _GVFSSTREAM_HXX_
20 : : #define _GVFSSTREAM_HXX_
21 : :
22 : : #include <sal/types.h>
23 : : #include <rtl/ustring.hxx>
24 : : #include <cppuhelper/weak.hxx>
25 : : #include <com/sun/star/io/XStream.hpp>
26 : : #include <com/sun/star/io/XInputStream.hpp>
27 : : #include <com/sun/star/io/XOutputStream.hpp>
28 : : #include <com/sun/star/io/XTruncate.hpp>
29 : : #include <com/sun/star/io/XSeekable.hpp>
30 : :
31 : : #include <libgnomevfs/gnome-vfs-handle.h>
32 : :
33 : : namespace gvfs
34 : : {
35 : :
36 : : class Stream : public ::com::sun::star::io::XStream,
37 : : public ::com::sun::star::io::XInputStream,
38 : : public ::com::sun::star::io::XOutputStream,
39 : : public ::com::sun::star::io::XTruncate,
40 : : public ::com::sun::star::io::XSeekable,
41 : : public ::cppu::OWeakObject
42 : : {
43 : : private:
44 : : GnomeVFSHandle *m_handle;
45 : : GnomeVFSFileInfo m_info;
46 : : osl::Mutex m_aMutex;
47 : : sal_Bool m_eof;
48 : : sal_Bool m_bInputStreamCalled;
49 : : sal_Bool m_bOutputStreamCalled;
50 : :
51 : : void throwOnError( GnomeVFSResult result )
52 : : throw( ::com::sun::star::io::NotConnectedException,
53 : : ::com::sun::star::io::BufferSizeExceededException,
54 : : ::com::sun::star::io::IOException,
55 : : ::com::sun::star::uno::RuntimeException );
56 : :
57 : : void closeStream( void )
58 : : throw( ::com::sun::star::io::NotConnectedException,
59 : : ::com::sun::star::io::IOException,
60 : : ::com::sun::star::uno::RuntimeException );
61 : :
62 : : public:
63 : : Stream ( GnomeVFSHandle *handle,
64 : : const GnomeVFSFileInfo *aInfo );
65 : : virtual ~Stream();
66 : :
67 : : // XInterface
68 : : virtual com::sun::star::uno::Any SAL_CALL queryInterface(const ::com::sun::star::uno::Type & type )
69 : : throw( ::com::sun::star::uno::RuntimeException );
70 : 0 : virtual void SAL_CALL acquire( void )
71 : : throw ()
72 : 0 : { OWeakObject::acquire(); }
73 : 0 : virtual void SAL_CALL release( void )
74 : : throw()
75 : 0 : { OWeakObject::release(); }
76 : :
77 : : // XStream
78 : : virtual com::sun::star::uno::Reference< com::sun::star::io::XInputStream > SAL_CALL getInputStream( )
79 : : throw( com::sun::star::uno::RuntimeException );
80 : :
81 : : virtual com::sun::star::uno::Reference< com::sun::star::io::XOutputStream > SAL_CALL getOutputStream( )
82 : : throw( com::sun::star::uno::RuntimeException );
83 : :
84 : : // XInputStream
85 : : virtual sal_Int32 SAL_CALL readBytes(
86 : : ::com::sun::star::uno::Sequence< sal_Int8 > & aData,
87 : : sal_Int32 nBytesToRead )
88 : : throw( ::com::sun::star::io::NotConnectedException,
89 : : ::com::sun::star::io::BufferSizeExceededException,
90 : : ::com::sun::star::io::IOException,
91 : : ::com::sun::star::uno::RuntimeException );
92 : :
93 : : virtual sal_Int32 SAL_CALL readSomeBytes(
94 : : ::com::sun::star::uno::Sequence< sal_Int8 > & aData,
95 : : sal_Int32 nMaxBytesToRead )
96 : : throw( ::com::sun::star::io::NotConnectedException,
97 : : ::com::sun::star::io::BufferSizeExceededException,
98 : : ::com::sun::star::io::IOException,
99 : : ::com::sun::star::uno::RuntimeException );
100 : :
101 : : virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip )
102 : : throw( ::com::sun::star::io::NotConnectedException,
103 : : ::com::sun::star::io::BufferSizeExceededException,
104 : : ::com::sun::star::io::IOException,
105 : : ::com::sun::star::uno::RuntimeException );
106 : :
107 : : virtual sal_Int32 SAL_CALL available( void )
108 : : throw( ::com::sun::star::io::NotConnectedException,
109 : : ::com::sun::star::io::IOException,
110 : : ::com::sun::star::uno::RuntimeException );
111 : :
112 : : virtual void SAL_CALL closeInput( void )
113 : : throw( ::com::sun::star::io::NotConnectedException,
114 : : ::com::sun::star::io::IOException,
115 : : ::com::sun::star::uno::RuntimeException );
116 : :
117 : : // XSeekable
118 : : virtual void SAL_CALL seek( sal_Int64 location )
119 : : throw( ::com::sun::star::lang::IllegalArgumentException,
120 : : ::com::sun::star::io::IOException,
121 : : ::com::sun::star::uno::RuntimeException );
122 : :
123 : : virtual sal_Int64 SAL_CALL getPosition()
124 : : throw( ::com::sun::star::io::IOException,
125 : : ::com::sun::star::uno::RuntimeException );
126 : :
127 : : virtual sal_Int64 SAL_CALL getLength()
128 : : throw( ::com::sun::star::io::IOException,
129 : : ::com::sun::star::uno::RuntimeException );
130 : :
131 : : // XOutputStream
132 : : virtual void SAL_CALL writeBytes( const com::sun::star::uno::Sequence< sal_Int8 >& aData )
133 : : throw( com::sun::star::io::NotConnectedException,
134 : : com::sun::star::io::BufferSizeExceededException,
135 : : com::sun::star::io::IOException,
136 : : com::sun::star::uno::RuntimeException);
137 : :
138 : : virtual void SAL_CALL flush( void )
139 : : throw( com::sun::star::io::NotConnectedException,
140 : : com::sun::star::io::BufferSizeExceededException,
141 : : com::sun::star::io::IOException,
142 : : com::sun::star::uno::RuntimeException);
143 : :
144 : :
145 : : virtual void SAL_CALL closeOutput( void )
146 : : throw( com::sun::star::io::NotConnectedException,
147 : : com::sun::star::io::IOException,
148 : : com::sun::star::uno::RuntimeException );
149 : :
150 : : // XTruncate
151 : : virtual void SAL_CALL truncate( void )
152 : : throw( com::sun::star::io::IOException,
153 : : com::sun::star::uno::RuntimeException );
154 : : };
155 : :
156 : : } // namespace gvfs
157 : : #endif // _GVFSSTREAM_HXX_
158 : :
159 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|