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