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