xref: /aoo42x/main/ucb/source/ucp/gvfs/gvfs_content.hxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir #ifndef _GVFS_UCP_CONTENT_HXX
28*cdf0e10cSrcweir #define _GVFS_UCP_CONTENT_HXX
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #include <memory>
31*cdf0e10cSrcweir #include <list>
32*cdf0e10cSrcweir #include <rtl/ref.hxx>
33*cdf0e10cSrcweir #include <com/sun/star/ucb/ContentCreationException.hpp>
34*cdf0e10cSrcweir #include <com/sun/star/ucb/XContentCreator.hpp>
35*cdf0e10cSrcweir #include <ucbhelper/contenthelper.hxx>
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir #include <glib/gthread.h>
38*cdf0e10cSrcweir #include <libgnomevfs/gnome-vfs-ops.h>
39*cdf0e10cSrcweir #include <libgnomevfs/gnome-vfs-directory.h>
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir namespace com { namespace sun { namespace star { namespace beans {
42*cdf0e10cSrcweir     struct Property;
43*cdf0e10cSrcweir     struct PropertyValue;
44*cdf0e10cSrcweir } } } }
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir namespace com { namespace sun { namespace star { namespace io {
47*cdf0e10cSrcweir     class XInputStream;
48*cdf0e10cSrcweir     class XOutputStream;
49*cdf0e10cSrcweir } } } }
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir namespace com { namespace sun { namespace star { namespace sdbc {
52*cdf0e10cSrcweir     class XRow;
53*cdf0e10cSrcweir } } } }
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir namespace com { namespace sun { namespace star { namespace ucb {
56*cdf0e10cSrcweir     struct TransferInfo;
57*cdf0e10cSrcweir } } } }
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir namespace gvfs
60*cdf0e10cSrcweir {
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir class ContentProvider;
63*cdf0e10cSrcweir class ContentProperties;
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir // Random made up names - AFAICS
66*cdf0e10cSrcweir #define GVFS_FILE_TYPE   "application/vnd.sun.staroffice.gvfs-file"
67*cdf0e10cSrcweir #define GVFS_FOLDER_TYPE "application/vnd.sun.staroffice.gvfs-folder"
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir class Authentication
70*cdf0e10cSrcweir {
71*cdf0e10cSrcweir public:
72*cdf0e10cSrcweir     // Helper class to make exceptions pleasant
73*cdf0e10cSrcweir     Authentication( const com::sun::star::uno::Reference<
74*cdf0e10cSrcweir                 com::sun::star::ucb::XCommandEnvironment > & xEnv );
75*cdf0e10cSrcweir     ~Authentication();
76*cdf0e10cSrcweir };
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir class Content : public ::ucbhelper::ContentImplHelper,
79*cdf0e10cSrcweir         public com::sun::star::ucb::XContentCreator
80*cdf0e10cSrcweir {
81*cdf0e10cSrcweir //=========================================================================
82*cdf0e10cSrcweir //                             Internals
83*cdf0e10cSrcweir //=========================================================================
84*cdf0e10cSrcweir private:
85*cdf0e10cSrcweir     typedef rtl::Reference< Content > ContentRef;
86*cdf0e10cSrcweir     typedef std::list< ContentRef > ContentRefList;
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir     // Instance data
89*cdf0e10cSrcweir     ContentProvider  *m_pProvider;  // No need for a ref, base class holds object
90*cdf0e10cSrcweir     sal_Bool          m_bTransient; // A non-existant (as yet) item
91*cdf0e10cSrcweir     GnomeVFSFileInfo  m_info;       // cached status information
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir     // Internal helpers
94*cdf0e10cSrcweir     void                       queryChildren   ( ContentRefList& rChildren );
95*cdf0e10cSrcweir     ::com::sun::star::uno::Any getBadArgExcept ();
96*cdf0e10cSrcweir     GnomeVFSResult             getInfo         ( const ::com::sun::star::uno::Reference<
97*cdf0e10cSrcweir                              ::com::sun::star::ucb::XCommandEnvironment >& xEnv );
98*cdf0e10cSrcweir     sal_Bool                   isFolder        ( const ::com::sun::star::uno::Reference<
99*cdf0e10cSrcweir                              ::com::sun::star::ucb::XCommandEnvironment >& xEnv );
100*cdf0e10cSrcweir     sal_Bool                   exchangeIdentity( const ::com::sun::star::uno::Reference<
101*cdf0e10cSrcweir                              ::com::sun::star::ucb::XContentIdentifier >&  xNewId);
102*cdf0e10cSrcweir     GnomeVFSResult             doSetFileInfo   ( const GnomeVFSFileInfo                       *newInfo,
103*cdf0e10cSrcweir                              GnomeVFSSetFileInfoMask                       setMask,
104*cdf0e10cSrcweir                              const ::com::sun::star::uno::Reference<
105*cdf0e10cSrcweir                              ::com::sun::star::ucb::XCommandEnvironment >& xEnv );
106*cdf0e10cSrcweir     ::rtl::OUString            makeNewURL      ( const char *newName );
107*cdf0e10cSrcweir     // End Internal helpers
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir     // For ucbhelper
110*cdf0e10cSrcweir     virtual ::rtl::OUString getParentURL();
111*cdf0e10cSrcweir     // For ucbhelper
112*cdf0e10cSrcweir     virtual com::sun::star::uno::Sequence< com::sun::star::beans::Property >
113*cdf0e10cSrcweir     getProperties( const com::sun::star::uno::Reference<
114*cdf0e10cSrcweir                com::sun::star::ucb::XCommandEnvironment > & xEnv );
115*cdf0e10cSrcweir     // For ucbhelper
116*cdf0e10cSrcweir     virtual com::sun::star::uno::Sequence< com::sun::star::ucb::CommandInfo >
117*cdf0e10cSrcweir     getCommands( const com::sun::star::uno::Reference<
118*cdf0e10cSrcweir              com::sun::star::ucb::XCommandEnvironment > & xEnv );
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir public:
121*cdf0e10cSrcweir     // Command "getPropertyValues"
122*cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow >
123*cdf0e10cSrcweir     getPropertyValues( const ::com::sun::star::uno::Sequence<
124*cdf0e10cSrcweir                ::com::sun::star::beans::Property >& rProperties,
125*cdf0e10cSrcweir                const ::com::sun::star::uno::Reference<
126*cdf0e10cSrcweir                ::com::sun::star::ucb::XCommandEnvironment >& xEnv );
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir private:
129*cdf0e10cSrcweir     // Command "setPropertyValues"
130*cdf0e10cSrcweir     ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >
131*cdf0e10cSrcweir     setPropertyValues( const ::com::sun::star::uno::Sequence<
132*cdf0e10cSrcweir                ::com::sun::star::beans::PropertyValue >& rValues,
133*cdf0e10cSrcweir                const ::com::sun::star::uno::Reference<
134*cdf0e10cSrcweir                ::com::sun::star::ucb::XCommandEnvironment >& xEnv );
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir     // Command "insert"
137*cdf0e10cSrcweir     void insert( const ::com::sun::star::uno::Reference<
138*cdf0e10cSrcweir                     ::com::sun::star::io::XInputStream > & xInputStream,
139*cdf0e10cSrcweir                  sal_Bool bReplaceExisting,
140*cdf0e10cSrcweir                  const com::sun::star::uno::Reference<
141*cdf0e10cSrcweir                     com::sun::star::ucb::XCommandEnvironment >& xEnv )
142*cdf0e10cSrcweir         throw( ::com::sun::star::uno::Exception );
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir     // Command "transfer"
145*cdf0e10cSrcweir     void transfer( const ::com::sun::star::ucb::TransferInfo & rArgs,
146*cdf0e10cSrcweir                const com::sun::star::uno::Reference<
147*cdf0e10cSrcweir                     com::sun::star::ucb::XCommandEnvironment >& xEnv )
148*cdf0e10cSrcweir         throw( ::com::sun::star::uno::Exception );
149*cdf0e10cSrcweir 
150*cdf0e10cSrcweir     // Command "delete"
151*cdf0e10cSrcweir     void destroy( sal_Bool bDeletePhysical )
152*cdf0e10cSrcweir         throw( ::com::sun::star::uno::Exception );
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir     // "open" helpers
155*cdf0e10cSrcweir     void    copyData( ::com::sun::star::uno::Reference<
156*cdf0e10cSrcweir                 ::com::sun::star::io::XInputStream > xIn,
157*cdf0e10cSrcweir               ::com::sun::star::uno::Reference<
158*cdf0e10cSrcweir                     ::com::sun::star::io::XOutputStream > xOut );
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir     ::com::sun::star::uno::Reference<
161*cdf0e10cSrcweir         ::com::sun::star::io::XInputStream >
162*cdf0e10cSrcweir         createTempStream(  const ::com::sun::star::uno::Reference<
163*cdf0e10cSrcweir                     com::sun::star::ucb::XCommandEnvironment >& xEnv )
164*cdf0e10cSrcweir         throw( ::com::sun::star::uno::Exception );
165*cdf0e10cSrcweir     ::com::sun::star::uno::Reference<
166*cdf0e10cSrcweir         ::com::sun::star::io::XInputStream >
167*cdf0e10cSrcweir         createInputStream(  const ::com::sun::star::uno::Reference<
168*cdf0e10cSrcweir                     com::sun::star::ucb::XCommandEnvironment >& xEnv )
169*cdf0e10cSrcweir         throw( ::com::sun::star::uno::Exception );
170*cdf0e10cSrcweir             sal_Bool feedSink( ::com::sun::star::uno::Reference<
171*cdf0e10cSrcweir                 ::com::sun::star::uno::XInterface> aSink,
172*cdf0e10cSrcweir                const ::com::sun::star::uno::Reference<
173*cdf0e10cSrcweir                 com::sun::star::ucb::XCommandEnvironment >& xEnv );
174*cdf0e10cSrcweir 
175*cdf0e10cSrcweir     ::com::sun::star::uno::Any mapVFSException( const GnomeVFSResult result,
176*cdf0e10cSrcweir                             sal_Bool bWrite );
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir     void cancelCommandExecution(const GnomeVFSResult result,
179*cdf0e10cSrcweir                     const ::com::sun::star::uno::Reference<
180*cdf0e10cSrcweir                     com::sun::star::ucb::XCommandEnvironment > & xEnv,
181*cdf0e10cSrcweir                     sal_Bool bWrite = sal_False )
182*cdf0e10cSrcweir         throw( ::com::sun::star::uno::Exception );
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir public:
186*cdf0e10cSrcweir     // Non-interface bits
187*cdf0e10cSrcweir     char         *getURI ();
188*cdf0e10cSrcweir     rtl::OString  getOURI ();
189*cdf0e10cSrcweir     rtl::OUString getOUURI ();
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir //=========================================================================
192*cdf0e10cSrcweir //                            Externals
193*cdf0e10cSrcweir //=========================================================================
194*cdf0e10cSrcweir public:
195*cdf0e10cSrcweir 
196*cdf0e10cSrcweir     Content( const ::com::sun::star::uno::Reference<
197*cdf0e10cSrcweir          ::com::sun::star::lang::XMultiServiceFactory >& rxSMgr,
198*cdf0e10cSrcweir          ContentProvider                                *pProvider,
199*cdf0e10cSrcweir          const ::com::sun::star::uno::Reference<
200*cdf0e10cSrcweir          ::com::sun::star::ucb::XContentIdentifier >&    Identifier)
201*cdf0e10cSrcweir             throw ( ::com::sun::star::ucb::ContentCreationException );
202*cdf0e10cSrcweir     Content( const ::com::sun::star::uno::Reference<
203*cdf0e10cSrcweir          ::com::sun::star::lang::XMultiServiceFactory >& rxSMgr,
204*cdf0e10cSrcweir          ContentProvider                                *pProvider,
205*cdf0e10cSrcweir          const ::com::sun::star::uno::Reference<
206*cdf0e10cSrcweir          ::com::sun::star::ucb::XContentIdentifier >&    Identifier,
207*cdf0e10cSrcweir          sal_Bool                                        isFolder)
208*cdf0e10cSrcweir             throw ( ::com::sun::star::ucb::ContentCreationException );
209*cdf0e10cSrcweir     virtual ~Content();
210*cdf0e10cSrcweir 
211*cdf0e10cSrcweir     // XInterface
212*cdf0e10cSrcweir     XINTERFACE_DECL()
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir     // XTypeProvider
215*cdf0e10cSrcweir     XTYPEPROVIDER_DECL()
216*cdf0e10cSrcweir 
217*cdf0e10cSrcweir         // XServiceInfo
218*cdf0e10cSrcweir         virtual ::rtl::OUString SAL_CALL getImplementationName()
219*cdf0e10cSrcweir         throw( ::com::sun::star::uno::RuntimeException );
220*cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
221*cdf0e10cSrcweir     getSupportedServiceNames()
222*cdf0e10cSrcweir         throw( ::com::sun::star::uno::RuntimeException );
223*cdf0e10cSrcweir 
224*cdf0e10cSrcweir     // XContent
225*cdf0e10cSrcweir     virtual rtl::OUString SAL_CALL
226*cdf0e10cSrcweir     getContentType()
227*cdf0e10cSrcweir         throw( com::sun::star::uno::RuntimeException );
228*cdf0e10cSrcweir 
229*cdf0e10cSrcweir     // XCommandProcessor
230*cdf0e10cSrcweir     virtual com::sun::star::uno::Any SAL_CALL
231*cdf0e10cSrcweir     execute( const com::sun::star::ucb::Command& aCommand,
232*cdf0e10cSrcweir          sal_Int32 CommandId,
233*cdf0e10cSrcweir          const com::sun::star::uno::Reference<
234*cdf0e10cSrcweir          com::sun::star::ucb::XCommandEnvironment >& xEnv )
235*cdf0e10cSrcweir         throw( com::sun::star::uno::Exception,
236*cdf0e10cSrcweir                com::sun::star::ucb::CommandAbortedException,
237*cdf0e10cSrcweir                com::sun::star::uno::RuntimeException );
238*cdf0e10cSrcweir     virtual void SAL_CALL
239*cdf0e10cSrcweir     abort( sal_Int32 CommandId )
240*cdf0e10cSrcweir         throw( com::sun::star::uno::RuntimeException );
241*cdf0e10cSrcweir 
242*cdf0e10cSrcweir     //////////////////////////////////////////////////////////////////////
243*cdf0e10cSrcweir     // Additional interfaces
244*cdf0e10cSrcweir     //////////////////////////////////////////////////////////////////////
245*cdf0e10cSrcweir 
246*cdf0e10cSrcweir     // XContentCreator
247*cdf0e10cSrcweir     virtual com::sun::star::uno::Sequence<
248*cdf0e10cSrcweir         com::sun::star::ucb::ContentInfo > SAL_CALL
249*cdf0e10cSrcweir     queryCreatableContentsInfo()
250*cdf0e10cSrcweir         throw( com::sun::star::uno::RuntimeException );
251*cdf0e10cSrcweir     virtual com::sun::star::uno::Reference<
252*cdf0e10cSrcweir         com::sun::star::ucb::XContent > SAL_CALL
253*cdf0e10cSrcweir     createNewContent( const com::sun::star::ucb::ContentInfo& Info )
254*cdf0e10cSrcweir         throw( com::sun::star::uno::RuntimeException );
255*cdf0e10cSrcweir 
256*cdf0e10cSrcweir 
257*cdf0e10cSrcweir     com::sun::star::uno::Sequence< com::sun::star::ucb::ContentInfo >
258*cdf0e10cSrcweir     queryCreatableContentsInfo(
259*cdf0e10cSrcweir         const com::sun::star::uno::Reference<
260*cdf0e10cSrcweir             com::sun::star::ucb::XCommandEnvironment >& xEnv)
261*cdf0e10cSrcweir         throw( com::sun::star::uno::RuntimeException );
262*cdf0e10cSrcweir };
263*cdf0e10cSrcweir 
264*cdf0e10cSrcweir }
265*cdf0e10cSrcweir 
266*cdf0e10cSrcweir extern "C" {
267*cdf0e10cSrcweir     extern GPrivate *auth_queue;
268*cdf0e10cSrcweir     extern void auth_queue_destroy( gpointer data );
269*cdf0e10cSrcweir }
270*cdf0e10cSrcweir 
271*cdf0e10cSrcweir #endif
272