xref: /AOO41X/main/ucb/source/ucp/gvfs/gvfs_directory.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
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 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_ucb.hxx"
30*cdf0e10cSrcweir /*
31*cdf0e10cSrcweir  * This file pinched from webdavdatasupplier (etc.)
32*cdf0e10cSrcweir  * cut & paste + new getData impl. & collate ResultSet code.
33*cdf0e10cSrcweir  */
34*cdf0e10cSrcweir #include <vector>
35*cdf0e10cSrcweir #include <osl/diagnose.h>
36*cdf0e10cSrcweir #include <com/sun/star/ucb/OpenMode.hpp>
37*cdf0e10cSrcweir #include <ucbhelper/contentidentifier.hxx>
38*cdf0e10cSrcweir #include <ucbhelper/providerhelper.hxx>
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir #include "gvfs_directory.hxx"
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir #include <libgnomevfs/gnome-vfs-utils.h>
43*cdf0e10cSrcweir #include <libgnomevfs/gnome-vfs-directory.h>
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir using namespace com::sun::star;
46*cdf0e10cSrcweir using namespace gvfs;
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir // DynamicResultSet Implementation.
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir DynamicResultSet::DynamicResultSet(
51*cdf0e10cSrcweir     const uno::Reference< lang::XMultiServiceFactory >& rxSMgr,
52*cdf0e10cSrcweir     const rtl::Reference< Content >& rxContent,
53*cdf0e10cSrcweir     const ucb::OpenCommandArgument2& rCommand,
54*cdf0e10cSrcweir     const uno::Reference< ucb::XCommandEnvironment >& rxEnv )
55*cdf0e10cSrcweir     : ResultSetImplHelper( rxSMgr, rCommand ),
56*cdf0e10cSrcweir       m_xContent( rxContent ),
57*cdf0e10cSrcweir       m_xEnv( rxEnv )
58*cdf0e10cSrcweir {
59*cdf0e10cSrcweir }
60*cdf0e10cSrcweir void DynamicResultSet::initStatic()
61*cdf0e10cSrcweir {
62*cdf0e10cSrcweir     m_xResultSet1
63*cdf0e10cSrcweir         = new ::ucbhelper::ResultSet( m_xSMgr,
64*cdf0e10cSrcweir                                       m_aCommand.Properties,
65*cdf0e10cSrcweir                                       new DataSupplier( m_xSMgr,
66*cdf0e10cSrcweir                                                         m_xContent,
67*cdf0e10cSrcweir                                                         m_aCommand.Mode ),
68*cdf0e10cSrcweir                                       m_xEnv );
69*cdf0e10cSrcweir }
70*cdf0e10cSrcweir void DynamicResultSet::initDynamic()
71*cdf0e10cSrcweir {
72*cdf0e10cSrcweir     initStatic();
73*cdf0e10cSrcweir     m_xResultSet2 = m_xResultSet1;
74*cdf0e10cSrcweir }
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir //=========================================================================
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir // DataSupplier Implementation.
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir struct ResultListEntry
84*cdf0e10cSrcweir {
85*cdf0e10cSrcweir     rtl::OUString                             aId;
86*cdf0e10cSrcweir     uno::Reference< ucb::XContentIdentifier > xId;
87*cdf0e10cSrcweir     uno::Reference< ucb::XContent >           xContent;
88*cdf0e10cSrcweir     uno::Reference< sdbc::XRow >              xRow;
89*cdf0e10cSrcweir     GnomeVFSFileInfo                          aInfo;
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir     ResultListEntry( const GnomeVFSFileInfo *fileInfo)
92*cdf0e10cSrcweir     {
93*cdf0e10cSrcweir         gnome_vfs_file_info_copy (&aInfo, fileInfo);
94*cdf0e10cSrcweir     }
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir     ~ResultListEntry()
97*cdf0e10cSrcweir     {
98*cdf0e10cSrcweir         gnome_vfs_file_info_clear (&aInfo);
99*cdf0e10cSrcweir     }
100*cdf0e10cSrcweir };
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir //=========================================================================
103*cdf0e10cSrcweir //
104*cdf0e10cSrcweir // ResultList.
105*cdf0e10cSrcweir //
106*cdf0e10cSrcweir //=========================================================================
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir typedef std::vector< ResultListEntry* > ResultList;
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir //=========================================================================
111*cdf0e10cSrcweir //
112*cdf0e10cSrcweir // struct DataSupplier_Impl.
113*cdf0e10cSrcweir //
114*cdf0e10cSrcweir //=========================================================================
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir struct gvfs::DataSupplier_Impl
117*cdf0e10cSrcweir {
118*cdf0e10cSrcweir     osl::Mutex                                   m_aMutex;
119*cdf0e10cSrcweir     ResultList                                   m_aResults;
120*cdf0e10cSrcweir     rtl::Reference< Content >                    m_xContent;
121*cdf0e10cSrcweir     uno::Reference< lang::XMultiServiceFactory > m_xSMgr;
122*cdf0e10cSrcweir     sal_Int32                                    m_nOpenMode;
123*cdf0e10cSrcweir     sal_Bool                                     m_bCountFinal;
124*cdf0e10cSrcweir 
125*cdf0e10cSrcweir     DataSupplier_Impl(
126*cdf0e10cSrcweir               const uno::Reference< lang::XMultiServiceFactory >& rxSMgr,
127*cdf0e10cSrcweir               const rtl::Reference< Content >& rContent,
128*cdf0e10cSrcweir               sal_Int32 nOpenMode )
129*cdf0e10cSrcweir         : m_xContent( rContent ), m_xSMgr( rxSMgr ),
130*cdf0e10cSrcweir           m_nOpenMode( nOpenMode ), m_bCountFinal( sal_False ) {}
131*cdf0e10cSrcweir     ~DataSupplier_Impl()
132*cdf0e10cSrcweir     {
133*cdf0e10cSrcweir         ResultList::const_iterator it  = m_aResults.begin();
134*cdf0e10cSrcweir         ResultList::const_iterator end = m_aResults.end();
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir         while ( it != end )
137*cdf0e10cSrcweir             {
138*cdf0e10cSrcweir                 delete (*it);
139*cdf0e10cSrcweir                 it++;
140*cdf0e10cSrcweir             }
141*cdf0e10cSrcweir     }
142*cdf0e10cSrcweir };
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir DataSupplier::DataSupplier(
145*cdf0e10cSrcweir             const uno::Reference< lang::XMultiServiceFactory >& rxSMgr,
146*cdf0e10cSrcweir             const rtl::Reference< Content >& rContent,
147*cdf0e10cSrcweir             sal_Int32 nOpenMode )
148*cdf0e10cSrcweir : m_pImpl( new DataSupplier_Impl( rxSMgr, rContent, nOpenMode ) )
149*cdf0e10cSrcweir {
150*cdf0e10cSrcweir }
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir //=========================================================================
153*cdf0e10cSrcweir // virtual
154*cdf0e10cSrcweir DataSupplier::~DataSupplier()
155*cdf0e10cSrcweir {
156*cdf0e10cSrcweir     delete m_pImpl;
157*cdf0e10cSrcweir }
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir // virtual
160*cdf0e10cSrcweir rtl::OUString DataSupplier::queryContentIdentifierString( sal_uInt32 nIndex )
161*cdf0e10cSrcweir {
162*cdf0e10cSrcweir     osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir     if ( nIndex < m_pImpl->m_aResults.size() ) {
165*cdf0e10cSrcweir         rtl::OUString aId = m_pImpl->m_aResults[ nIndex ]->aId;
166*cdf0e10cSrcweir         if ( aId.getLength() ) // cached
167*cdf0e10cSrcweir             return aId;
168*cdf0e10cSrcweir     }
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir     if ( getResult( nIndex ) ) {
171*cdf0e10cSrcweir         rtl::OUString aId = m_pImpl->m_xContent->getOUURI();
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir         char *escaped_name;
174*cdf0e10cSrcweir         escaped_name = gnome_vfs_escape_string( m_pImpl->m_aResults[ nIndex ]->aInfo.name );
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir         if ( ( aId.lastIndexOf( '/' ) + 1 ) != aId.getLength() )
177*cdf0e10cSrcweir             aId += rtl::OUString::createFromAscii( "/" );
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir         aId += rtl::OUString::createFromAscii( escaped_name );
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir         g_free( escaped_name );
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir         m_pImpl->m_aResults[ nIndex ]->aId = aId;
184*cdf0e10cSrcweir         return aId;
185*cdf0e10cSrcweir     }
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir     return rtl::OUString();
188*cdf0e10cSrcweir }
189*cdf0e10cSrcweir 
190*cdf0e10cSrcweir // virtual
191*cdf0e10cSrcweir uno::Reference< ucb::XContentIdentifier >
192*cdf0e10cSrcweir DataSupplier::queryContentIdentifier( sal_uInt32 nIndex )
193*cdf0e10cSrcweir {
194*cdf0e10cSrcweir     osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
195*cdf0e10cSrcweir 
196*cdf0e10cSrcweir     if ( nIndex < m_pImpl->m_aResults.size() ) {
197*cdf0e10cSrcweir         uno::Reference< ucb::XContentIdentifier > xId
198*cdf0e10cSrcweir             = m_pImpl->m_aResults[ nIndex ]->xId;
199*cdf0e10cSrcweir         if ( xId.is() ) // Already cached.
200*cdf0e10cSrcweir             return xId;
201*cdf0e10cSrcweir     }
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir     rtl::OUString aId = queryContentIdentifierString( nIndex );
204*cdf0e10cSrcweir     if ( aId.getLength() ) {
205*cdf0e10cSrcweir         uno::Reference< ucb::XContentIdentifier > xId
206*cdf0e10cSrcweir             = new ::ucbhelper::ContentIdentifier( aId );
207*cdf0e10cSrcweir         m_pImpl->m_aResults[ nIndex ]->xId = xId;
208*cdf0e10cSrcweir         return xId;
209*cdf0e10cSrcweir     }
210*cdf0e10cSrcweir 
211*cdf0e10cSrcweir     return uno::Reference< ucb::XContentIdentifier >();
212*cdf0e10cSrcweir }
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir // virtual
215*cdf0e10cSrcweir uno::Reference< ucb::XContent >
216*cdf0e10cSrcweir DataSupplier::queryContent( sal_uInt32 nIndex )
217*cdf0e10cSrcweir {
218*cdf0e10cSrcweir     osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
219*cdf0e10cSrcweir 
220*cdf0e10cSrcweir     if ( nIndex < m_pImpl->m_aResults.size() ) {
221*cdf0e10cSrcweir         uno::Reference< ucb::XContent > xContent
222*cdf0e10cSrcweir             = m_pImpl->m_aResults[ nIndex ]->xContent;
223*cdf0e10cSrcweir         if ( xContent.is() ) // Already cached.
224*cdf0e10cSrcweir             return xContent;
225*cdf0e10cSrcweir     }
226*cdf0e10cSrcweir 
227*cdf0e10cSrcweir     uno::Reference< ucb::XContentIdentifier > xId
228*cdf0e10cSrcweir         = queryContentIdentifier( nIndex );
229*cdf0e10cSrcweir     if ( xId.is() ) {
230*cdf0e10cSrcweir         try
231*cdf0e10cSrcweir         {
232*cdf0e10cSrcweir             // FIXME:
233*cdf0e10cSrcweir             // It would be really nice to propagate this information
234*cdf0e10cSrcweir             // to the Content, but we can't then register it with the
235*cdf0e10cSrcweir             // ContentProvider, and the ucbhelper hinders here.
236*cdf0e10cSrcweir             uno::Reference< ucb::XContent > xContent
237*cdf0e10cSrcweir                 = m_pImpl->m_xContent->getProvider()->queryContent( xId );
238*cdf0e10cSrcweir             m_pImpl->m_aResults[ nIndex ]->xContent = xContent;
239*cdf0e10cSrcweir             return xContent;
240*cdf0e10cSrcweir 
241*cdf0e10cSrcweir         }
242*cdf0e10cSrcweir         catch ( ucb::IllegalIdentifierException& ) {
243*cdf0e10cSrcweir         }
244*cdf0e10cSrcweir     }
245*cdf0e10cSrcweir     return uno::Reference< ucb::XContent >();
246*cdf0e10cSrcweir }
247*cdf0e10cSrcweir 
248*cdf0e10cSrcweir // virtual
249*cdf0e10cSrcweir sal_Bool DataSupplier::getResult( sal_uInt32 nIndex )
250*cdf0e10cSrcweir {
251*cdf0e10cSrcweir     osl::ClearableGuard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
252*cdf0e10cSrcweir 
253*cdf0e10cSrcweir     if ( m_pImpl->m_aResults.size() > nIndex ) // Result already present.
254*cdf0e10cSrcweir         return sal_True;
255*cdf0e10cSrcweir 
256*cdf0e10cSrcweir     if ( getData() && m_pImpl->m_aResults.size() > nIndex )
257*cdf0e10cSrcweir         return sal_True;
258*cdf0e10cSrcweir 
259*cdf0e10cSrcweir     return sal_False;
260*cdf0e10cSrcweir }
261*cdf0e10cSrcweir 
262*cdf0e10cSrcweir // virtual
263*cdf0e10cSrcweir sal_uInt32 DataSupplier::totalCount()
264*cdf0e10cSrcweir {
265*cdf0e10cSrcweir     getData();
266*cdf0e10cSrcweir 
267*cdf0e10cSrcweir     osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
268*cdf0e10cSrcweir 
269*cdf0e10cSrcweir     return m_pImpl->m_aResults.size();
270*cdf0e10cSrcweir }
271*cdf0e10cSrcweir 
272*cdf0e10cSrcweir // virtual
273*cdf0e10cSrcweir sal_uInt32 DataSupplier::currentCount()
274*cdf0e10cSrcweir {
275*cdf0e10cSrcweir     osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
276*cdf0e10cSrcweir     return m_pImpl->m_aResults.size();
277*cdf0e10cSrcweir }
278*cdf0e10cSrcweir 
279*cdf0e10cSrcweir // virtual
280*cdf0e10cSrcweir sal_Bool DataSupplier::isCountFinal()
281*cdf0e10cSrcweir {
282*cdf0e10cSrcweir     osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
283*cdf0e10cSrcweir     return m_pImpl->m_bCountFinal;
284*cdf0e10cSrcweir }
285*cdf0e10cSrcweir 
286*cdf0e10cSrcweir // virtual
287*cdf0e10cSrcweir uno::Reference< sdbc::XRow > DataSupplier::queryPropertyValues( sal_uInt32 nIndex )
288*cdf0e10cSrcweir {
289*cdf0e10cSrcweir     osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
290*cdf0e10cSrcweir 
291*cdf0e10cSrcweir     if ( nIndex < m_pImpl->m_aResults.size() ) {
292*cdf0e10cSrcweir         uno::Reference< sdbc::XRow > xRow = m_pImpl->m_aResults[ nIndex ]->xRow;
293*cdf0e10cSrcweir         if ( xRow.is() ) // Already cached.
294*cdf0e10cSrcweir             return xRow;
295*cdf0e10cSrcweir     }
296*cdf0e10cSrcweir 
297*cdf0e10cSrcweir     if ( getResult( nIndex ) ) {
298*cdf0e10cSrcweir         // Inefficient - but we can't create xContent's sensibly
299*cdf0e10cSrcweir         // nor can we do the property code sensibly cleanly staticaly.
300*cdf0e10cSrcweir         Content *pContent = static_cast< ::gvfs::Content * >(queryContent( nIndex ).get());
301*cdf0e10cSrcweir 
302*cdf0e10cSrcweir         uno::Reference< sdbc::XRow > xRow =
303*cdf0e10cSrcweir             pContent->getPropertyValues( getResultSet()->getProperties(),
304*cdf0e10cSrcweir                              getResultSet()->getEnvironment() );
305*cdf0e10cSrcweir 
306*cdf0e10cSrcweir         m_pImpl->m_aResults[ nIndex ]->xRow = xRow;
307*cdf0e10cSrcweir 
308*cdf0e10cSrcweir         return xRow;
309*cdf0e10cSrcweir     }
310*cdf0e10cSrcweir 
311*cdf0e10cSrcweir     return uno::Reference< sdbc::XRow >();
312*cdf0e10cSrcweir }
313*cdf0e10cSrcweir 
314*cdf0e10cSrcweir // virtual
315*cdf0e10cSrcweir void DataSupplier::releasePropertyValues( sal_uInt32 nIndex )
316*cdf0e10cSrcweir {
317*cdf0e10cSrcweir     osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
318*cdf0e10cSrcweir 
319*cdf0e10cSrcweir     if ( nIndex < m_pImpl->m_aResults.size() )
320*cdf0e10cSrcweir         m_pImpl->m_aResults[ nIndex ]->xRow = uno::Reference< sdbc::XRow >();
321*cdf0e10cSrcweir }
322*cdf0e10cSrcweir 
323*cdf0e10cSrcweir // virtual
324*cdf0e10cSrcweir void DataSupplier::close()
325*cdf0e10cSrcweir {
326*cdf0e10cSrcweir }
327*cdf0e10cSrcweir 
328*cdf0e10cSrcweir // virtual
329*cdf0e10cSrcweir void DataSupplier::validate()
330*cdf0e10cSrcweir     throw( ucb::ResultSetException )
331*cdf0e10cSrcweir {
332*cdf0e10cSrcweir }
333*cdf0e10cSrcweir 
334*cdf0e10cSrcweir sal_Bool DataSupplier::getData()
335*cdf0e10cSrcweir {
336*cdf0e10cSrcweir     osl::ClearableGuard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
337*cdf0e10cSrcweir 
338*cdf0e10cSrcweir     if ( !m_pImpl->m_bCountFinal ) {
339*cdf0e10cSrcweir         GnomeVFSResult result;
340*cdf0e10cSrcweir         GnomeVFSDirectoryHandle *dirHandle = NULL;
341*cdf0e10cSrcweir 
342*cdf0e10cSrcweir         {
343*cdf0e10cSrcweir             Authentication aAuth( getResultSet()->getEnvironment() );
344*cdf0e10cSrcweir             char *uri = m_pImpl->m_xContent->getURI();
345*cdf0e10cSrcweir             result = gnome_vfs_directory_open
346*cdf0e10cSrcweir                 ( &dirHandle, uri, GNOME_VFS_FILE_INFO_DEFAULT );
347*cdf0e10cSrcweir 
348*cdf0e10cSrcweir             if (result != GNOME_VFS_OK) {
349*cdf0e10cSrcweir #ifdef DEBUG
350*cdf0e10cSrcweir                 g_warning ("Failed open of '%s' with '%s'",
351*cdf0e10cSrcweir                        uri, gnome_vfs_result_to_string( result ));
352*cdf0e10cSrcweir #endif
353*cdf0e10cSrcweir                 g_free( uri );
354*cdf0e10cSrcweir                 return sal_False;
355*cdf0e10cSrcweir             }
356*cdf0e10cSrcweir 
357*cdf0e10cSrcweir             g_free( uri );
358*cdf0e10cSrcweir         }
359*cdf0e10cSrcweir 
360*cdf0e10cSrcweir         GnomeVFSFileInfo* fileInfo = gnome_vfs_file_info_new ();
361*cdf0e10cSrcweir 
362*cdf0e10cSrcweir         while ((result = gnome_vfs_directory_read_next (dirHandle, fileInfo)) == GNOME_VFS_OK) {
363*cdf0e10cSrcweir             if( fileInfo->name && fileInfo->name[0] == '.' &&
364*cdf0e10cSrcweir                 ( fileInfo->name[1] == '\0' ||
365*cdf0e10cSrcweir                   ( fileInfo->name[1] == '.' && fileInfo->name[2] == '\0' ) ) )
366*cdf0e10cSrcweir                 continue;
367*cdf0e10cSrcweir 
368*cdf0e10cSrcweir             switch ( m_pImpl->m_nOpenMode ) {
369*cdf0e10cSrcweir             case ucb::OpenMode::FOLDERS:
370*cdf0e10cSrcweir                 if ( !(fileInfo->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_TYPE) ||
371*cdf0e10cSrcweir                      fileInfo->type != GNOME_VFS_FILE_TYPE_DIRECTORY )
372*cdf0e10cSrcweir                     continue;
373*cdf0e10cSrcweir                 break;
374*cdf0e10cSrcweir 
375*cdf0e10cSrcweir             case ucb::OpenMode::DOCUMENTS:
376*cdf0e10cSrcweir                 if ( !(fileInfo->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_TYPE) ||
377*cdf0e10cSrcweir                      fileInfo->type != GNOME_VFS_FILE_TYPE_REGULAR )
378*cdf0e10cSrcweir                     continue;
379*cdf0e10cSrcweir                 break;
380*cdf0e10cSrcweir 
381*cdf0e10cSrcweir             case ucb::OpenMode::ALL:
382*cdf0e10cSrcweir             default:
383*cdf0e10cSrcweir                 break;
384*cdf0e10cSrcweir             }
385*cdf0e10cSrcweir 
386*cdf0e10cSrcweir             m_pImpl->m_aResults.push_back( new ResultListEntry( fileInfo ) );
387*cdf0e10cSrcweir         }
388*cdf0e10cSrcweir 
389*cdf0e10cSrcweir         gnome_vfs_file_info_unref (fileInfo);
390*cdf0e10cSrcweir 
391*cdf0e10cSrcweir #ifdef DEBUG
392*cdf0e10cSrcweir         g_warning ("Got %d directory entries", result);
393*cdf0e10cSrcweir #endif
394*cdf0e10cSrcweir 
395*cdf0e10cSrcweir         m_pImpl->m_bCountFinal = sal_True;
396*cdf0e10cSrcweir 
397*cdf0e10cSrcweir         // Callback possible, because listeners may be informed!
398*cdf0e10cSrcweir         aGuard.clear();
399*cdf0e10cSrcweir         getResultSet()->rowCountFinal();
400*cdf0e10cSrcweir 
401*cdf0e10cSrcweir         if (result != GNOME_VFS_ERROR_EOF) {
402*cdf0e10cSrcweir #ifdef DEBUG
403*cdf0e10cSrcweir             g_warning( "Failed read_next '%s'",
404*cdf0e10cSrcweir                    gnome_vfs_result_to_string( result ) );
405*cdf0e10cSrcweir #endif
406*cdf0e10cSrcweir             return sal_False;
407*cdf0e10cSrcweir         }
408*cdf0e10cSrcweir 
409*cdf0e10cSrcweir         result = gnome_vfs_directory_close (dirHandle);
410*cdf0e10cSrcweir         if (result != GNOME_VFS_OK) {
411*cdf0e10cSrcweir #ifdef DEBUG
412*cdf0e10cSrcweir             g_warning( "Failed close '%s'",
413*cdf0e10cSrcweir                    gnome_vfs_result_to_string( result ) );
414*cdf0e10cSrcweir #endif
415*cdf0e10cSrcweir             return sal_False;
416*cdf0e10cSrcweir         }
417*cdf0e10cSrcweir     }
418*cdf0e10cSrcweir 
419*cdf0e10cSrcweir     return sal_True;
420*cdf0e10cSrcweir }
421*cdf0e10cSrcweir 
422*cdf0e10cSrcweir 
423*cdf0e10cSrcweir 
424