1 --- ucb/source/ucp/gvfs/provider.hxx 2003-04-24 16:24:35.000000000 +0100
2 +++ ucb/source/ucp/gvfs/provider.hxx 2003-04-24 16:24:35.000000000 +0100
4 +#ifndef _PROVIDER_HXX_
5 +#define _PROVIDER_HXX_
10 +#include <rtl/ref.hxx>
13 +#ifndef _COM_SUN_STAR_BEANS_PROPERTY_HPP_
14 +#include <com/sun/star/beans/Property.hpp>
17 +#ifndef _UCBHELPER_PROVIDERHELPER_HXX
18 +#include <ucbhelper/providerhelper.hxx>
23 +class ContentProvider : public ::ucb::ContentProviderImplHelper
26 + ContentProvider( const ::com::sun::star::uno::Reference<
27 + ::com::sun::star::lang::XMultiServiceFactory >& rSMgr );
28 + virtual ~ContentProvider();
34 + XTYPEPROVIDER_DECL()
40 + virtual ::com::sun::star::uno::Reference<
41 + ::com::sun::star::ucb::XContent > SAL_CALL
42 + queryContent( const ::com::sun::star::uno::Reference<
43 + ::com::sun::star::ucb::XContentIdentifier >& Identifier )
44 + throw( ::com::sun::star::ucb::IllegalIdentifierException,
45 + ::com::sun::star::uno::RuntimeException );
49 +}; /* namespace gvfs */
51 +#endif /* _PROVIDER_HXX_ */
53 --- ucb/source/ucp/gvfs/provider.cxx 2003-04-28 14:13:04.000000000 +0100
54 +++ ucb/source/ucp/gvfs/provider.cxx 2003-04-28 14:13:04.000000000 +0100
56 +#include <tools/urlobj.hxx>
57 +#include <ucbhelper/contentidentifier.hxx>
58 +#include <libgnomevfs/gnome-vfs-init.h>
59 +#include "provider.hxx"
60 +#include "content.hxx"
62 +using namespace com::sun::star;
63 +using namespace gvfs;
65 +//=========================================================================
66 +//=========================================================================
68 +// ContentProvider Implementation.
70 +//=========================================================================
71 +//=========================================================================
73 +ContentProvider::ContentProvider(const uno::Reference< lang::XMultiServiceFactory >& rSMgr )
74 + : ::ucb::ContentProviderImplHelper( rSMgr )
78 +//=========================================================================
80 +ContentProvider::~ContentProvider()
84 +//=========================================================================
86 +// XInterface methods.
88 +//=========================================================================
90 +XINTERFACE_IMPL_3( ContentProvider,
91 + lang::XTypeProvider,
93 + com::sun::star::ucb::XContentProvider );
95 +//=========================================================================
97 +// XTypeProvider methods.
99 +//=========================================================================
101 +XTYPEPROVIDER_IMPL_3( ContentProvider,
102 + lang::XTypeProvider,
103 + lang::XServiceInfo,
104 + com::sun::star::ucb::XContentProvider );
106 +//=========================================================================
108 +// XServiceInfo methods.
110 +//=========================================================================
112 +XSERVICEINFO_IMPL_1( ContentProvider,
113 + rtl::OUString::createFromAscii(
114 + "com.sun.star.comp.GnomeVFSContentProvider" ),
115 + rtl::OUString::createFromAscii(
116 + "com.sun.star.ucb.GnomeVFSContentProvider" ) );
117 +//=========================================================================
119 +// Service factory implementation.
121 +//=========================================================================
123 +ONE_INSTANCE_SERVICE_FACTORY_IMPL( ContentProvider );
125 +//=========================================================================
127 +// XContentProvider methods.
129 +//=========================================================================
131 +uno::Reference< com::sun::star::ucb::XContent > SAL_CALL
132 +ContentProvider::queryContent(
133 + const uno::Reference<
134 + com::sun::star::ucb::XContentIdentifier >& Identifier )
135 + throw( com::sun::star::ucb::IllegalIdentifierException,
136 + uno::RuntimeException )
139 + g_warning ("QueryContent: '%s'",
140 + (const sal_Char *)rtl::OUStringToOString
141 + (Identifier->getContentIdentifier(), RTL_TEXTENCODING_UTF8));
144 + // It sucks to depend on 'tools' but ...
145 + INetURLObject url( Identifier->getContentIdentifier() );
146 + if ( url.GetProtocol() < INET_PROT_END ) {
148 + g_warning ("Not one of ours ... '%s'",
149 + (const sal_Char *)rtl::OUStringToOString
150 + (Identifier->getContentIdentifier(), RTL_TEXTENCODING_UTF8));
152 + throw com::sun::star::ucb::IllegalIdentifierException();
155 + vos::OGuard aGuard( m_aMutex );
157 + // Check, if a content with given id already exists...
158 + uno::Reference< com::sun::star::ucb::XContent > xContent
159 + = queryExistingContent( Identifier ).getBodyPtr();
160 + if ( xContent.is() )
165 + xContent = new ::gvfs::Content(m_xSMgr, this, Identifier );
167 + catch ( com::sun::star::ucb::ContentCreationException const & )
169 + throw com::sun::star::ucb::IllegalIdentifierException();
172 + if ( !xContent->getIdentifier().is() )
173 + throw com::sun::star::ucb::IllegalIdentifierException();
179 +//============================ shlib entry points =============================================
182 +// cut and paste verbatim from webdav (that sucks).
184 +writeInfo( void *pRegistryKey,
185 + const rtl::OUString &rImplementationName,
186 + uno::Sequence< rtl::OUString > const &rServiceNames )
188 + rtl::OUString aKeyName( rtl::OUString::createFromAscii( "/" ) );
189 + aKeyName += rImplementationName;
190 + aKeyName += rtl::OUString::createFromAscii( "/UNO/SERVICES" );
192 + uno::Reference< registry::XRegistryKey > xKey;
194 + xKey = static_cast< registry::XRegistryKey * >
195 + (pRegistryKey )->createKey( aKeyName );
197 + catch ( registry::InvalidRegistryException const & ) {
203 + sal_Bool bSuccess = sal_True;
205 + for ( sal_Int32 n = 0; n < rServiceNames.getLength(); ++n ) {
207 + xKey->createKey( rServiceNames[ n ] );
209 + } catch ( registry::InvalidRegistryException const & ) {
210 + bSuccess = sal_False;
217 +extern "C" void SAL_CALL
218 +component_getImplementationEnvironment( const sal_Char **ppEnvTypeName,
219 + uno_Environment **ppEnv )
221 + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
224 +extern "C" sal_Bool SAL_CALL
225 +component_writeInfo( void *pServiceManager,
226 + void *pRegistryKey )
228 + return pRegistryKey &&
229 + writeInfo( pRegistryKey,
230 + ::gvfs::ContentProvider::getImplementationName_Static(),
231 + ::gvfs::ContentProvider::getSupportedServiceNames_Static() );
233 +extern "C" void * SAL_CALL
234 +component_getFactory( const sal_Char *pImplName,
235 + void *pServiceManager,
236 + void *pRegistryKey )
241 + osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
242 + if (!gnome_vfs_initialized ())
245 + auth_queue = g_private_new( auth_queue_destroy );
248 + uno::Reference< lang::XMultiServiceFactory > xSMgr
249 + (reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ) );
250 + uno::Reference< lang::XSingleServiceFactory > xFactory;
252 + if ( !::gvfs::ContentProvider::getImplementationName_Static().compareToAscii( pImplName ) )
253 + xFactory = ::gvfs::ContentProvider::createServiceFactory( xSMgr );
255 + if ( xFactory.is() ) {
256 + xFactory->acquire();
257 + pRet = xFactory.get();