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