xref: /aoo41x/main/ucb/source/ucp/ftp/ftpresultsetI.cxx (revision 2f86921c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_ucb.hxx"
26 
27 #include "ucbhelper/propertyvalueset.hxx"
28 #include "rtl/ref.hxx"
29 #include "com/sun/star/ucb/Command.hpp"
30 #include "com/sun/star/ucb/XCommandEnvironment.hpp"
31 #include "com/sun/star/ucb/XCommandProcessor.hpp"
32 #include "com/sun/star/sdbc/XRow.hpp"
33 #include "ftpresultsetI.hxx"
34 #include "ftpcontent.hxx"
35 
36 
37 using namespace std;
38 using namespace ftp;
39 using namespace com::sun::star::ucb;
40 using namespace com::sun::star::lang;
41 using namespace com::sun::star::uno;
42 using namespace com::sun::star::beans;
43 using namespace com::sun::star::sdbc;
44 
45 
ResultSetI(const Reference<XMultiServiceFactory> & xMSF,const Reference<XContentProvider> & xProvider,sal_Int32 nOpenMode,const Sequence<Property> & seqProp,const Sequence<NumberedSortingInfo> & seqSort,const std::vector<FTPDirentry> & dirvec)46 ResultSetI::ResultSetI(const Reference<XMultiServiceFactory>&  xMSF,
47                        const Reference<XContentProvider>&  xProvider,
48                        sal_Int32 nOpenMode,
49                        const Sequence<Property>& seqProp,
50                        const Sequence< NumberedSortingInfo >& seqSort,
51                        const std::vector<FTPDirentry>&  dirvec)
52     : ResultSetBase(xMSF,xProvider,nOpenMode,seqProp,seqSort)
53 {
54     for( unsigned int i = 0; i < dirvec.size(); ++i)
55         m_aPath.push_back(dirvec[i].m_aURL);
56 
57     // m_aIdents holds the contentidentifiers
58 
59     m_aItems.resize( m_aPath.size() );
60     m_aIdents.resize( m_aPath.size() );
61 
62     for(unsigned n = 0; n < m_aItems.size(); ++n) {
63         rtl::Reference<ucbhelper::PropertyValueSet> xRow =
64             new ucbhelper::PropertyValueSet(xMSF);
65 
66         for( int i = 0; i < seqProp.getLength(); ++i) {
67             const rtl::OUString& Name = seqProp[i].Name;
68             if(Name.compareToAscii("ContentType") == 0 )
69                 xRow->appendString(seqProp[i],
70                                    rtl::OUString::createFromAscii(
71                                        "application/ftp" ));
72             else if(Name.compareToAscii("Title") == 0)
73                 xRow->appendString(seqProp[i],dirvec[n].m_aName);
74             else if(Name.compareToAscii("IsReadOnly") == 0)
75                 xRow->appendBoolean(seqProp[i],
76                                     sal_Bool(dirvec[n].m_nMode &
77                                              INETCOREFTP_FILEMODE_WRITE));
78             else if(Name.compareToAscii("IsDocument") == 0)
79                 xRow->appendBoolean(seqProp[i],
80                                     ! sal_Bool(dirvec[n].m_nMode &
81                                                INETCOREFTP_FILEMODE_ISDIR));
82             else if(Name.compareToAscii("IsFolder") == 0)
83                 xRow->appendBoolean(seqProp[i],
84                                     sal_Bool(dirvec[n].m_nMode &
85                                              INETCOREFTP_FILEMODE_ISDIR));
86             else if(Name.compareToAscii("Size") == 0)
87                 xRow->appendLong(seqProp[i],
88                                  dirvec[n].m_nSize);
89             else if(Name.compareToAscii("DateCreated") == 0)
90                 xRow->appendTimestamp(seqProp[i],
91                                       dirvec[n].m_aDate);
92             else if(Name.compareToAscii("CreatableContentsInfo") == 0)
93                 xRow->appendObject(
94                     seqProp[i],
95                     makeAny(FTPContent::queryCreatableContentsInfo_Static()));
96             else
97                 xRow->appendVoid(seqProp[i]);
98         }
99         m_aItems[n] = Reference<XRow>(xRow.get());
100     }
101 }
102