xref: /trunk/main/ucb/source/ucp/gvfs/gvfs_content.hxx (revision 5d313e96)
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 _GVFS_UCP_CONTENT_HXX
24 #define _GVFS_UCP_CONTENT_HXX
25 
26 #include <memory>
27 #include <list>
28 #include <rtl/ref.hxx>
29 #include <com/sun/star/ucb/ContentCreationException.hpp>
30 #include <com/sun/star/ucb/XContentCreator.hpp>
31 #include <ucbhelper/contenthelper.hxx>
32 
33 #include <glib.h>
34 #include <libgnomevfs/gnome-vfs-ops.h>
35 #include <libgnomevfs/gnome-vfs-directory.h>
36 
37 namespace com { namespace sun { namespace star { namespace beans {
38     struct Property;
39     struct PropertyValue;
40 } } } }
41 
42 namespace com { namespace sun { namespace star { namespace io {
43     class XInputStream;
44     class XOutputStream;
45 } } } }
46 
47 namespace com { namespace sun { namespace star { namespace sdbc {
48     class XRow;
49 } } } }
50 
51 namespace com { namespace sun { namespace star { namespace ucb {
52     struct TransferInfo;
53 } } } }
54 
55 namespace gvfs
56 {
57 
58 class ContentProvider;
59 class ContentProperties;
60 
61 // Random made up names - AFAICS
62 #define GVFS_FILE_TYPE   "application/vnd.sun.staroffice.gvfs-file"
63 #define GVFS_FOLDER_TYPE "application/vnd.sun.staroffice.gvfs-folder"
64 
65 class Authentication
66 {
67 public:
68     // Helper class to make exceptions pleasant
69     Authentication( const com::sun::star::uno::Reference<
70                 com::sun::star::ucb::XCommandEnvironment > & xEnv );
71     ~Authentication();
72 };
73 
74 class Content : public ::ucbhelper::ContentImplHelper,
75         public com::sun::star::ucb::XContentCreator
76 {
77 //=========================================================================
78 //                             Internals
79 //=========================================================================
80 private:
81     typedef rtl::Reference< Content > ContentRef;
82     typedef std::list< ContentRef > ContentRefList;
83 
84     // Instance data
85     ContentProvider  *m_pProvider;  // No need for a ref, base class holds object
86     sal_Bool          m_bTransient; // A non-existant (as yet) item
87     GnomeVFSFileInfo  m_info;       // cached status information
88 
89     // Internal helpers
90     void                       queryChildren   ( ContentRefList& rChildren );
91     ::com::sun::star::uno::Any getBadArgExcept ();
92     GnomeVFSResult             getInfo         ( const ::com::sun::star::uno::Reference<
93                              ::com::sun::star::ucb::XCommandEnvironment >& xEnv );
94     sal_Bool                   isFolder        ( const ::com::sun::star::uno::Reference<
95                              ::com::sun::star::ucb::XCommandEnvironment >& xEnv );
96     sal_Bool                   exchangeIdentity( const ::com::sun::star::uno::Reference<
97                              ::com::sun::star::ucb::XContentIdentifier >&  xNewId);
98     GnomeVFSResult             doSetFileInfo   ( const GnomeVFSFileInfo                       *newInfo,
99                              GnomeVFSSetFileInfoMask                       setMask,
100                              const ::com::sun::star::uno::Reference<
101                              ::com::sun::star::ucb::XCommandEnvironment >& xEnv );
102     ::rtl::OUString            makeNewURL      ( const char *newName );
103     // End Internal helpers
104 
105     // For ucbhelper
106     virtual ::rtl::OUString getParentURL();
107     // For ucbhelper
108     virtual com::sun::star::uno::Sequence< com::sun::star::beans::Property >
109     getProperties( const com::sun::star::uno::Reference<
110                com::sun::star::ucb::XCommandEnvironment > & xEnv );
111     // For ucbhelper
112     virtual com::sun::star::uno::Sequence< com::sun::star::ucb::CommandInfo >
113     getCommands( const com::sun::star::uno::Reference<
114              com::sun::star::ucb::XCommandEnvironment > & xEnv );
115 
116 public:
117     // Command "getPropertyValues"
118     ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow >
119     getPropertyValues( const ::com::sun::star::uno::Sequence<
120                ::com::sun::star::beans::Property >& rProperties,
121                const ::com::sun::star::uno::Reference<
122                ::com::sun::star::ucb::XCommandEnvironment >& xEnv );
123 
124 private:
125     // Command "setPropertyValues"
126     ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >
127     setPropertyValues( const ::com::sun::star::uno::Sequence<
128                ::com::sun::star::beans::PropertyValue >& rValues,
129                const ::com::sun::star::uno::Reference<
130                ::com::sun::star::ucb::XCommandEnvironment >& xEnv );
131 
132     // Command "insert"
133     void insert( const ::com::sun::star::uno::Reference<
134                     ::com::sun::star::io::XInputStream > & xInputStream,
135                  sal_Bool bReplaceExisting,
136                  const com::sun::star::uno::Reference<
137                     com::sun::star::ucb::XCommandEnvironment >& xEnv )
138         throw( ::com::sun::star::uno::Exception );
139 
140     // Command "transfer"
141     void transfer( const ::com::sun::star::ucb::TransferInfo & rArgs,
142                const com::sun::star::uno::Reference<
143                     com::sun::star::ucb::XCommandEnvironment >& xEnv )
144         throw( ::com::sun::star::uno::Exception );
145 
146     // Command "delete"
147     void destroy( sal_Bool bDeletePhysical )
148         throw( ::com::sun::star::uno::Exception );
149 
150     // "open" helpers
151     void    copyData( ::com::sun::star::uno::Reference<
152                 ::com::sun::star::io::XInputStream > xIn,
153               ::com::sun::star::uno::Reference<
154                     ::com::sun::star::io::XOutputStream > xOut );
155 
156     ::com::sun::star::uno::Reference<
157         ::com::sun::star::io::XInputStream >
158         createTempStream(  const ::com::sun::star::uno::Reference<
159                     com::sun::star::ucb::XCommandEnvironment >& xEnv )
160         throw( ::com::sun::star::uno::Exception );
161     ::com::sun::star::uno::Reference<
162         ::com::sun::star::io::XInputStream >
163         createInputStream(  const ::com::sun::star::uno::Reference<
164                     com::sun::star::ucb::XCommandEnvironment >& xEnv )
165         throw( ::com::sun::star::uno::Exception );
166             sal_Bool feedSink( ::com::sun::star::uno::Reference<
167                 ::com::sun::star::uno::XInterface> aSink,
168                const ::com::sun::star::uno::Reference<
169                 com::sun::star::ucb::XCommandEnvironment >& xEnv );
170 
171     ::com::sun::star::uno::Any mapVFSException( const GnomeVFSResult result,
172                             sal_Bool bWrite );
173 
174     void cancelCommandExecution(const GnomeVFSResult result,
175                     const ::com::sun::star::uno::Reference<
176                     com::sun::star::ucb::XCommandEnvironment > & xEnv,
177                     sal_Bool bWrite = sal_False )
178         throw( ::com::sun::star::uno::Exception );
179 
180 
181 public:
182     // Non-interface bits
183     char         *getURI ();
184     rtl::OString  getOURI ();
185     rtl::OUString getOUURI ();
186 
187 //=========================================================================
188 //                            Externals
189 //=========================================================================
190 public:
191 
192     Content( const ::com::sun::star::uno::Reference<
193          ::com::sun::star::lang::XMultiServiceFactory >& rxSMgr,
194          ContentProvider                                *pProvider,
195          const ::com::sun::star::uno::Reference<
196          ::com::sun::star::ucb::XContentIdentifier >&    Identifier)
197             throw ( ::com::sun::star::ucb::ContentCreationException );
198     Content( const ::com::sun::star::uno::Reference<
199          ::com::sun::star::lang::XMultiServiceFactory >& rxSMgr,
200          ContentProvider                                *pProvider,
201          const ::com::sun::star::uno::Reference<
202          ::com::sun::star::ucb::XContentIdentifier >&    Identifier,
203          sal_Bool                                        isFolder)
204             throw ( ::com::sun::star::ucb::ContentCreationException );
205     virtual ~Content();
206 
207     // XInterface
208     XINTERFACE_DECL()
209 
210     // XTypeProvider
211     XTYPEPROVIDER_DECL()
212 
213         // XServiceInfo
214         virtual ::rtl::OUString SAL_CALL getImplementationName()
215         throw( ::com::sun::star::uno::RuntimeException );
216     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
217     getSupportedServiceNames()
218         throw( ::com::sun::star::uno::RuntimeException );
219 
220     // XContent
221     virtual rtl::OUString SAL_CALL
222     getContentType()
223         throw( com::sun::star::uno::RuntimeException );
224 
225     // XCommandProcessor
226     virtual com::sun::star::uno::Any SAL_CALL
227     execute( const com::sun::star::ucb::Command& aCommand,
228          sal_Int32 CommandId,
229          const com::sun::star::uno::Reference<
230          com::sun::star::ucb::XCommandEnvironment >& xEnv )
231         throw( com::sun::star::uno::Exception,
232                com::sun::star::ucb::CommandAbortedException,
233                com::sun::star::uno::RuntimeException );
234     virtual void SAL_CALL
235     abort( sal_Int32 CommandId )
236         throw( com::sun::star::uno::RuntimeException );
237 
238     //////////////////////////////////////////////////////////////////////
239     // Additional interfaces
240     //////////////////////////////////////////////////////////////////////
241 
242     // XContentCreator
243     virtual com::sun::star::uno::Sequence<
244         com::sun::star::ucb::ContentInfo > SAL_CALL
245     queryCreatableContentsInfo()
246         throw( com::sun::star::uno::RuntimeException );
247     virtual com::sun::star::uno::Reference<
248         com::sun::star::ucb::XContent > SAL_CALL
249     createNewContent( const com::sun::star::ucb::ContentInfo& Info )
250         throw( com::sun::star::uno::RuntimeException );
251 
252 
253     com::sun::star::uno::Sequence< com::sun::star::ucb::ContentInfo >
254     queryCreatableContentsInfo(
255         const com::sun::star::uno::Reference<
256             com::sun::star::ucb::XCommandEnvironment >& xEnv)
257         throw( com::sun::star::uno::RuntimeException );
258 };
259 
260 }
261 
262 extern "C" {
263     extern GPrivate *auth_queue;
264     extern void auth_queue_destroy( gpointer data );
265 }
266 
267 #endif
268