xref: /aoo42x/main/ucb/source/ucp/ftp/ftpinpstr.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 /**************************************************************************
29 								TODO
30  **************************************************************************
31 
32  *************************************************************************/
33 
34 #ifndef _FTP_FTPINPSTR_HXX_
35 #define _FTP_FTPINPSTR_HXX_
36 
37 
38 #include <rtl/ustring.hxx>
39 #include <osl/mutex.hxx>
40 #include <cppuhelper/weak.hxx>
41 #include <cppuhelper/queryinterface.hxx>
42 #include <com/sun/star/io/XInputStream.hpp>
43 #include <com/sun/star/io/XSeekable.hpp>
44 #include <stdio.h>
45 
46 
47 namespace ftp {
48 
49 
50 	/** Implements a seekable InputStream
51 	 *  working on a buffer.
52 	 */
53 
54 
55 	namespace css = com::sun::star;
56 
57 
58 	class FTPInputStream
59 		: public cppu::OWeakObject,
60 		  public com::sun::star::io::XInputStream,
61 		  public com::sun::star::io::XSeekable
62 	{
63 	public:
64 
65 		/** Defines the storage kind found
66 		 *  on which the inputstream acts.
67 		 */
68 
69 		FTPInputStream(FILE* tmpfl = 0);
70 
71 		~FTPInputStream();
72 
73 		virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type& rType)
74 			throw(css::uno::RuntimeException);
75 
76 		virtual void SAL_CALL acquire(void) throw();
77 
78 		virtual void SAL_CALL release(void) throw();
79 
80 		virtual sal_Int32 SAL_CALL
81 		readBytes(css::uno::Sequence< sal_Int8 >& aData,
82 				  sal_Int32 nBytesToRead)
83 			throw( css::io::NotConnectedException,
84 				   css::io::BufferSizeExceededException,
85 				   css::io::IOException,
86 				   css::uno::RuntimeException);
87 
88 		virtual sal_Int32 SAL_CALL
89 		readSomeBytes(css::uno::Sequence< sal_Int8 >& aData,
90 					  sal_Int32 nMaxBytesToRead )
91 			throw( css::io::NotConnectedException,
92 				   css::io::BufferSizeExceededException,
93 				   css::io::IOException,
94 				   css::uno::RuntimeException);
95 
96 		virtual void SAL_CALL
97 		skipBytes(sal_Int32 nBytesToSkip)
98 			throw(css::io::NotConnectedException,
99 				  css::io::BufferSizeExceededException,
100 				  css::io::IOException,
101 				  css::uno::RuntimeException );
102 
103 		virtual sal_Int32 SAL_CALL
104 		available(void)
105 			throw(css::io::NotConnectedException,
106 				  css::io::IOException,
107 				  css::uno::RuntimeException );
108 
109 		virtual void SAL_CALL
110 		closeInput(void)
111 			throw(css::io::NotConnectedException,
112 				  css::io::IOException,
113 				  css::uno::RuntimeException);
114 
115 
116 		/** XSeekable
117 		 */
118 
119 		virtual void SAL_CALL
120 		seek(sal_Int64 location)
121 			throw(css::lang::IllegalArgumentException,
122 				  css::io::IOException,
123 				  css::uno::RuntimeException);
124 
125 
126 		virtual sal_Int64 SAL_CALL
127 		getPosition(void)
128 			throw(css::io::IOException,
129 				  css::uno::RuntimeException);
130 
131 
132 		virtual sal_Int64 SAL_CALL
133 		getLength(void)
134 			throw(css::io::IOException,
135 				  css::uno::RuntimeException);
136 
137         // additional
138 
139 //          void append(const void* pBuffer,size_t size,size_t nmemb);
140 
141 	private:
142 
143 		osl::Mutex m_aMutex;
144 		FILE* m_tmpfl;
145 		sal_Int64 m_nLength;
146 	};
147 
148 
149 }
150 
151 #endif
152