xref: /trunk/main/ucb/source/ucp/gvfs/gvfs_content.hxx (revision 45c5a00162811bd03b87fcb4fe9996782f2b59ec)
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 
139     // Command "transfer"
140     void transfer( const ::com::sun::star::ucb::TransferInfo & rArgs,
141                const com::sun::star::uno::Reference<
142                     com::sun::star::ucb::XCommandEnvironment >& xEnv );
143 
144     // Command "delete"
145     void destroy( sal_Bool bDeletePhysical );
146 
147     // "open" helpers
148     void    copyData( ::com::sun::star::uno::Reference<
149                 ::com::sun::star::io::XInputStream > xIn,
150               ::com::sun::star::uno::Reference<
151                     ::com::sun::star::io::XOutputStream > xOut );
152 
153     ::com::sun::star::uno::Reference<
154         ::com::sun::star::io::XInputStream >
155         createTempStream(  const ::com::sun::star::uno::Reference<
156                     com::sun::star::ucb::XCommandEnvironment >& xEnv );
157     ::com::sun::star::uno::Reference<
158         ::com::sun::star::io::XInputStream >
159         createInputStream(  const ::com::sun::star::uno::Reference<
160                     com::sun::star::ucb::XCommandEnvironment >& xEnv );
161             sal_Bool feedSink( ::com::sun::star::uno::Reference<
162                 ::com::sun::star::uno::XInterface> aSink,
163                const ::com::sun::star::uno::Reference<
164                 com::sun::star::ucb::XCommandEnvironment >& xEnv );
165 
166     ::com::sun::star::uno::Any mapVFSException( const GnomeVFSResult result,
167                             sal_Bool bWrite );
168 
169     void cancelCommandExecution(const GnomeVFSResult result,
170                     const ::com::sun::star::uno::Reference<
171                     com::sun::star::ucb::XCommandEnvironment > & xEnv,
172                     sal_Bool bWrite = sal_False );
173 
174 
175 public:
176     // Non-interface bits
177     char         *getURI ();
178     rtl::OString  getOURI ();
179     rtl::OUString getOUURI ();
180 
181 //=========================================================================
182 //                            Externals
183 //=========================================================================
184 public:
185 
186     Content( const ::com::sun::star::uno::Reference<
187          ::com::sun::star::lang::XMultiServiceFactory >& rxSMgr,
188          ContentProvider                                *pProvider,
189          const ::com::sun::star::uno::Reference<
190          ::com::sun::star::ucb::XContentIdentifier >&    Identifier);
191     Content( const ::com::sun::star::uno::Reference<
192          ::com::sun::star::lang::XMultiServiceFactory >& rxSMgr,
193          ContentProvider                                *pProvider,
194          const ::com::sun::star::uno::Reference<
195          ::com::sun::star::ucb::XContentIdentifier >&    Identifier,
196          sal_Bool                                        isFolder);
197     virtual ~Content();
198 
199     // XInterface
200     XINTERFACE_DECL()
201 
202     // XTypeProvider
203     XTYPEPROVIDER_DECL()
204 
205         // XServiceInfo
206         virtual ::rtl::OUString SAL_CALL getImplementationName();
207     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
208     getSupportedServiceNames();
209 
210     // XContent
211     virtual rtl::OUString SAL_CALL
212     getContentType();
213 
214     // XCommandProcessor
215     virtual com::sun::star::uno::Any SAL_CALL
216     execute( const com::sun::star::ucb::Command& aCommand,
217          sal_Int32 CommandId,
218          const com::sun::star::uno::Reference<
219          com::sun::star::ucb::XCommandEnvironment >& xEnv );
220     virtual void SAL_CALL
221     abort( sal_Int32 CommandId );
222 
223     //////////////////////////////////////////////////////////////////////
224     // Additional interfaces
225     //////////////////////////////////////////////////////////////////////
226 
227     // XContentCreator
228     virtual com::sun::star::uno::Sequence<
229         com::sun::star::ucb::ContentInfo > SAL_CALL
230     queryCreatableContentsInfo();
231     virtual com::sun::star::uno::Reference<
232         com::sun::star::ucb::XContent > SAL_CALL
233     createNewContent( const com::sun::star::ucb::ContentInfo& Info );
234 
235 
236     com::sun::star::uno::Sequence< com::sun::star::ucb::ContentInfo >
237     queryCreatableContentsInfo(
238         const com::sun::star::uno::Reference<
239             com::sun::star::ucb::XCommandEnvironment >& xEnv);
240 };
241 
242 }
243 
244 extern "C" {
245     extern GPrivate *auth_queue;
246     extern void auth_queue_destroy( gpointer data );
247 }
248 
249 #endif
250