Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <ucbhelper/contentidentifier.hxx>
31 : : #include <libgnomevfs/gnome-vfs-init.h>
32 : : #include "gvfs_provider.hxx"
33 : : #include "gvfs_content.hxx"
34 : :
35 : : using namespace com::sun::star;
36 : : using namespace gvfs;
37 : :
38 : : //=========================================================================
39 : : //=========================================================================
40 : : //
41 : : // ContentProvider Implementation.
42 : : //
43 : : //=========================================================================
44 : : //=========================================================================
45 : :
46 : 0 : ContentProvider::ContentProvider(
47 : : const uno::Reference< lang::XMultiServiceFactory >& rSMgr )
48 : 0 : : ::ucbhelper::ContentProviderImplHelper( rSMgr )
49 : : {
50 : 0 : }
51 : : // sdafas
52 : : //=========================================================================
53 : : // virtual
54 : 0 : ContentProvider::~ContentProvider()
55 : : {
56 : 0 : }
57 : :
58 : : //=========================================================================
59 : : //
60 : : // XInterface methods.
61 : : //
62 : : //=========================================================================
63 : :
64 : 0 : XINTERFACE_IMPL_3( ContentProvider,
65 : : lang::XTypeProvider,
66 : : lang::XServiceInfo,
67 : : com::sun::star::ucb::XContentProvider );
68 : :
69 : : //=========================================================================
70 : : //
71 : : // XTypeProvider methods.
72 : : //
73 : : //=========================================================================
74 : :
75 : 0 : XTYPEPROVIDER_IMPL_3( ContentProvider,
76 : : lang::XTypeProvider,
77 : : lang::XServiceInfo,
78 : : com::sun::star::ucb::XContentProvider );
79 : :
80 : : //=========================================================================
81 : : //
82 : : // XServiceInfo methods.
83 : : //
84 : : //=========================================================================
85 : :
86 : 0 : XSERVICEINFO_IMPL_1( ContentProvider,
87 : : rtl::OUString( "com.sun.star.comp.GnomeVFSContentProvider" ),
88 : 0 : rtl::OUString( "com.sun.star.ucb.GnomeVFSContentProvider" ) );
89 : : //=========================================================================
90 : : //
91 : : // Service factory implementation.
92 : : //
93 : : //=========================================================================
94 : :
95 : 0 : ONE_INSTANCE_SERVICE_FACTORY_IMPL( ContentProvider );
96 : :
97 : : //=========================================================================
98 : : //
99 : : // XContentProvider methods.
100 : : //
101 : : //=========================================================================
102 : :
103 : : uno::Reference< com::sun::star::ucb::XContent > SAL_CALL
104 : 0 : ContentProvider::queryContent(
105 : : const uno::Reference<
106 : : com::sun::star::ucb::XContentIdentifier >& Identifier )
107 : : throw( com::sun::star::ucb::IllegalIdentifierException,
108 : : uno::RuntimeException )
109 : : {
110 : : #if OSL_DEBUG_LEVEL > 1
111 : : g_warning ("QueryContent: '%s'",
112 : : rtl::OUStringToOString (Identifier->getContentIdentifier(),
113 : : RTL_TEXTENCODING_UTF8).getStr() );
114 : : #endif
115 : :
116 : 0 : osl::MutexGuard aGuard( m_aMutex );
117 : :
118 : : // Check, if a content with given id already exists...
119 : : uno::Reference< com::sun::star::ucb::XContent > xContent
120 : 0 : = queryExistingContent( Identifier ).get();
121 : 0 : if ( xContent.is() )
122 : : return xContent;
123 : :
124 : : try
125 : : {
126 : 0 : xContent = new ::gvfs::Content(m_xSMgr, this, Identifier );
127 : 0 : registerNewContent( xContent );
128 : : }
129 : 0 : catch ( com::sun::star::ucb::ContentCreationException const & )
130 : : {
131 : 0 : throw com::sun::star::ucb::IllegalIdentifierException();
132 : : }
133 : :
134 : 0 : if ( !xContent->getIdentifier().is() )
135 : 0 : throw com::sun::star::ucb::IllegalIdentifierException();
136 : :
137 : 0 : return xContent;
138 : : }
139 : :
140 : :
141 : : //============================ shlib entry points =============================================
142 : :
143 : 0 : extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory( const sal_Char *pImplName,
144 : : void *pServiceManager,
145 : : void */*pRegistryKey*/ )
146 : : {
147 : 0 : void * pRet = 0;
148 : :
149 : : {
150 : 0 : osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
151 : 0 : if (!gnome_vfs_initialized ())
152 : 0 : gnome_vfs_init ();
153 : 0 : if (!auth_queue)
154 : 0 : auth_queue = g_private_new( auth_queue_destroy );
155 : : }
156 : :
157 : : uno::Reference< lang::XMultiServiceFactory > xSMgr
158 : 0 : (reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ) );
159 : 0 : uno::Reference< lang::XSingleServiceFactory > xFactory;
160 : :
161 : 0 : if ( !::gvfs::ContentProvider::getImplementationName_Static().compareToAscii( pImplName ) )
162 : 0 : xFactory = ::gvfs::ContentProvider::createServiceFactory( xSMgr );
163 : :
164 : 0 : if ( xFactory.is() ) {
165 : 0 : xFactory->acquire();
166 : 0 : pRet = xFactory.get();
167 : : }
168 : :
169 : 0 : return pRet;
170 : : }
171 : :
172 : :
173 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|