]> git.pld-linux.org Git - packages/libreoffice.git/blob - openoffice-vfs-provider.patch
- DON'T hardcode java paths!
[packages/libreoffice.git] / openoffice-vfs-provider.patch
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
3 @@ -0,0 +1,49 @@
4 +#ifndef _PROVIDER_HXX_
5 +#define _PROVIDER_HXX_
6 +
7 +#include <hash_set>
8 +
9 +#ifndef _RTL_REF_HXX_
10 +#include <rtl/ref.hxx>
11 +#endif
12 +
13 +#ifndef _COM_SUN_STAR_BEANS_PROPERTY_HPP_
14 +#include <com/sun/star/beans/Property.hpp>
15 +#endif
16 +
17 +#ifndef _UCBHELPER_PROVIDERHELPER_HXX
18 +#include <ucbhelper/providerhelper.hxx>
19 +#endif
20 +
21 +namespace gvfs {
22 +
23 +class ContentProvider : public ::ucb::ContentProviderImplHelper
24 +{
25 +public:
26 +       ContentProvider( const ::com::sun::star::uno::Reference<
27 +                        ::com::sun::star::lang::XMultiServiceFactory >& rSMgr );
28 +       virtual ~ContentProvider();
29 +
30 +       // XInterface
31 +       XINTERFACE_DECL()
32 +
33 +       // XTypeProvider
34 +       XTYPEPROVIDER_DECL()
35 +
36 +       // XServiceInfo
37 +       XSERVICEINFO_DECL()
38 +
39 +       // XContentProvider
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 );
46 +
47 +};
48 +
49 +}; /* namespace gvfs */
50 +
51 +#endif /* _PROVIDER_HXX_ */
52 +
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
55 @@ -0,0 +1,208 @@
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"
61 +
62 +using namespace com::sun::star;
63 +using namespace gvfs;
64 +
65 +//=========================================================================
66 +//=========================================================================
67 +//
68 +// ContentProvider Implementation.
69 +//
70 +//=========================================================================
71 +//=========================================================================
72 +
73 +ContentProvider::ContentProvider(const uno::Reference< lang::XMultiServiceFactory >& rSMgr )
74 +       : ::ucb::ContentProviderImplHelper( rSMgr )
75 +{
76 +}
77 +
78 +//=========================================================================
79 +// virtual
80 +ContentProvider::~ContentProvider()
81 +{
82 +}
83 +
84 +//=========================================================================
85 +//
86 +// XInterface methods.
87 +//
88 +//=========================================================================
89 +
90 +XINTERFACE_IMPL_3( ContentProvider,
91 +                   lang::XTypeProvider,
92 +                   lang::XServiceInfo,
93 +                   com::sun::star::ucb::XContentProvider );
94 +
95 +//=========================================================================
96 +//
97 +// XTypeProvider methods.
98 +//
99 +//=========================================================================
100 +
101 +XTYPEPROVIDER_IMPL_3( ContentProvider,
102 +                      lang::XTypeProvider,
103 +                      lang::XServiceInfo,
104 +                      com::sun::star::ucb::XContentProvider );
105 +
106 +//=========================================================================
107 +//
108 +// XServiceInfo methods.
109 +//
110 +//=========================================================================
111 +
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 +//=========================================================================
118 +//
119 +// Service factory implementation.
120 +//
121 +//=========================================================================
122 +
123 +ONE_INSTANCE_SERVICE_FACTORY_IMPL( ContentProvider );
124 +
125 +//=========================================================================
126 +//
127 +// XContentProvider methods.
128 +//
129 +//=========================================================================
130 +
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 )
137 +{
138 +#ifdef DEBUG
139 +       g_warning ("QueryContent: '%s'", 
140 +                  (const sal_Char *)rtl::OUStringToOString
141 +                  (Identifier->getContentIdentifier(), RTL_TEXTENCODING_UTF8));
142 +#endif
143 +
144 +       // It sucks to depend on 'tools' but ...
145 +       INetURLObject url( Identifier->getContentIdentifier() );
146 +       if ( url.GetProtocol() < INET_PROT_END ) {
147 +#ifdef DEBUG
148 +               g_warning ("Not one of ours ... '%s'",
149 +                          (const sal_Char *)rtl::OUStringToOString
150 +                          (Identifier->getContentIdentifier(), RTL_TEXTENCODING_UTF8));
151 +#endif
152 +               throw com::sun::star::ucb::IllegalIdentifierException();
153 +       }
154 +
155 +       vos::OGuard aGuard( m_aMutex );
156 +
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() )
161 +               return xContent;
162 +
163 +       try
164 +       {
165 +               xContent = new ::gvfs::Content(m_xSMgr, this, Identifier );
166 +       }
167 +       catch ( com::sun::star::ucb::ContentCreationException const & )
168 +       {
169 +               throw com::sun::star::ucb::IllegalIdentifierException();
170 +       }
171 +
172 +       if ( !xContent->getIdentifier().is() )
173 +               throw com::sun::star::ucb::IllegalIdentifierException();
174 +
175 +       return xContent;
176 +}
177 +
178 +
179 +//============================ shlib entry points =============================================
180 +
181 +
182 +// cut and paste verbatim from webdav (that sucks).
183 +static sal_Bool
184 +writeInfo( void                                 *pRegistryKey,
185 +          const rtl::OUString                  &rImplementationName,
186 +          uno::Sequence< rtl::OUString > const &rServiceNames )
187 +{
188 +       rtl::OUString aKeyName( rtl::OUString::createFromAscii( "/" ) );
189 +       aKeyName += rImplementationName;
190 +       aKeyName += rtl::OUString::createFromAscii( "/UNO/SERVICES" );
191 +
192 +       uno::Reference< registry::XRegistryKey > xKey;
193 +       try {
194 +               xKey = static_cast< registry::XRegistryKey * >
195 +                       (pRegistryKey )->createKey( aKeyName );
196 +       }
197 +       catch ( registry::InvalidRegistryException const & ) {
198 +       }
199 +
200 +       if ( !xKey.is() )
201 +               return sal_False;
202 +
203 +       sal_Bool bSuccess = sal_True;
204 +
205 +       for ( sal_Int32 n = 0; n < rServiceNames.getLength(); ++n ) {
206 +               try {
207 +                       xKey->createKey( rServiceNames[ n ] );
208 +
209 +               } catch ( registry::InvalidRegistryException const & ) {
210 +                       bSuccess = sal_False;
211 +                       break;
212 +               }
213 +       }
214 +       return bSuccess;
215 +}
216 +
217 +extern "C" void SAL_CALL 
218 +component_getImplementationEnvironment( const sal_Char  **ppEnvTypeName,
219 +                                       uno_Environment **ppEnv )
220 +{
221 +       *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
222 +}
223 +
224 +extern "C" sal_Bool SAL_CALL 
225 +component_writeInfo( void *pServiceManager,
226 +                    void *pRegistryKey )
227 +{
228 +       return pRegistryKey &&
229 +               writeInfo( pRegistryKey,
230 +                          ::gvfs::ContentProvider::getImplementationName_Static(),
231 +                          ::gvfs::ContentProvider::getSupportedServiceNames_Static() );
232 +}
233 +extern "C" void * SAL_CALL
234 +component_getFactory( const sal_Char *pImplName,
235 +                     void           *pServiceManager,
236 +                     void           *pRegistryKey )
237 +{
238 +       void * pRet = 0;
239 +
240 +       {
241 +               osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
242 +               if (!gnome_vfs_initialized ())
243 +                       gnome_vfs_init ();
244 +               if (!auth_queue)
245 +                       auth_queue = g_private_new( auth_queue_destroy );
246 +       }
247 +
248 +       uno::Reference< lang::XMultiServiceFactory > xSMgr
249 +               (reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ) );
250 +       uno::Reference< lang::XSingleServiceFactory > xFactory;
251 +
252 +       if ( !::gvfs::ContentProvider::getImplementationName_Static().compareToAscii( pImplName ) )
253 +               xFactory = ::gvfs::ContentProvider::createServiceFactory( xSMgr );
254 +
255 +       if ( xFactory.is() ) {
256 +               xFactory->acquire();
257 +               pRet = xFactory.get();
258 +       }
259 +
260 +       return pRet;
261 +}
262 +
263 +
This page took 0.078495 seconds and 3 git commands to generate.