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 // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_ucb.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include "ucbhelper/propertyvalueset.hxx"
28cdf0e10cSrcweir #include "rtl/ref.hxx"
29cdf0e10cSrcweir #include "com/sun/star/ucb/Command.hpp"
30cdf0e10cSrcweir #include "com/sun/star/ucb/XCommandEnvironment.hpp"
31cdf0e10cSrcweir #include "com/sun/star/ucb/XCommandProcessor.hpp"
32cdf0e10cSrcweir #include "com/sun/star/sdbc/XRow.hpp"
33cdf0e10cSrcweir #include "ftpresultsetI.hxx"
34cdf0e10cSrcweir #include "ftpcontent.hxx"
35cdf0e10cSrcweir
36cdf0e10cSrcweir
37cdf0e10cSrcweir using namespace std;
38cdf0e10cSrcweir using namespace ftp;
39cdf0e10cSrcweir using namespace com::sun::star::ucb;
40cdf0e10cSrcweir using namespace com::sun::star::lang;
41cdf0e10cSrcweir using namespace com::sun::star::uno;
42cdf0e10cSrcweir using namespace com::sun::star::beans;
43cdf0e10cSrcweir using namespace com::sun::star::sdbc;
44cdf0e10cSrcweir
45cdf0e10cSrcweir
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)46cdf0e10cSrcweir ResultSetI::ResultSetI(const Reference<XMultiServiceFactory>& xMSF,
47cdf0e10cSrcweir const Reference<XContentProvider>& xProvider,
48cdf0e10cSrcweir sal_Int32 nOpenMode,
49cdf0e10cSrcweir const Sequence<Property>& seqProp,
50cdf0e10cSrcweir const Sequence< NumberedSortingInfo >& seqSort,
51cdf0e10cSrcweir const std::vector<FTPDirentry>& dirvec)
52cdf0e10cSrcweir : ResultSetBase(xMSF,xProvider,nOpenMode,seqProp,seqSort)
53cdf0e10cSrcweir {
54cdf0e10cSrcweir for( unsigned int i = 0; i < dirvec.size(); ++i)
55cdf0e10cSrcweir m_aPath.push_back(dirvec[i].m_aURL);
56cdf0e10cSrcweir
57cdf0e10cSrcweir // m_aIdents holds the contentidentifiers
58cdf0e10cSrcweir
59cdf0e10cSrcweir m_aItems.resize( m_aPath.size() );
60cdf0e10cSrcweir m_aIdents.resize( m_aPath.size() );
61cdf0e10cSrcweir
62cdf0e10cSrcweir for(unsigned n = 0; n < m_aItems.size(); ++n) {
63cdf0e10cSrcweir rtl::Reference<ucbhelper::PropertyValueSet> xRow =
64cdf0e10cSrcweir new ucbhelper::PropertyValueSet(xMSF);
65cdf0e10cSrcweir
66cdf0e10cSrcweir for( int i = 0; i < seqProp.getLength(); ++i) {
67cdf0e10cSrcweir const rtl::OUString& Name = seqProp[i].Name;
68cdf0e10cSrcweir if(Name.compareToAscii("ContentType") == 0 )
69cdf0e10cSrcweir xRow->appendString(seqProp[i],
70cdf0e10cSrcweir rtl::OUString::createFromAscii(
71cdf0e10cSrcweir "application/ftp" ));
72cdf0e10cSrcweir else if(Name.compareToAscii("Title") == 0)
73cdf0e10cSrcweir xRow->appendString(seqProp[i],dirvec[n].m_aName);
74cdf0e10cSrcweir else if(Name.compareToAscii("IsReadOnly") == 0)
75cdf0e10cSrcweir xRow->appendBoolean(seqProp[i],
76cdf0e10cSrcweir sal_Bool(dirvec[n].m_nMode &
77cdf0e10cSrcweir INETCOREFTP_FILEMODE_WRITE));
78cdf0e10cSrcweir else if(Name.compareToAscii("IsDocument") == 0)
79cdf0e10cSrcweir xRow->appendBoolean(seqProp[i],
80cdf0e10cSrcweir ! sal_Bool(dirvec[n].m_nMode &
81cdf0e10cSrcweir INETCOREFTP_FILEMODE_ISDIR));
82cdf0e10cSrcweir else if(Name.compareToAscii("IsFolder") == 0)
83cdf0e10cSrcweir xRow->appendBoolean(seqProp[i],
84cdf0e10cSrcweir sal_Bool(dirvec[n].m_nMode &
85cdf0e10cSrcweir INETCOREFTP_FILEMODE_ISDIR));
86cdf0e10cSrcweir else if(Name.compareToAscii("Size") == 0)
87cdf0e10cSrcweir xRow->appendLong(seqProp[i],
88cdf0e10cSrcweir dirvec[n].m_nSize);
89cdf0e10cSrcweir else if(Name.compareToAscii("DateCreated") == 0)
90cdf0e10cSrcweir xRow->appendTimestamp(seqProp[i],
91cdf0e10cSrcweir dirvec[n].m_aDate);
92cdf0e10cSrcweir else if(Name.compareToAscii("CreatableContentsInfo") == 0)
93cdf0e10cSrcweir xRow->appendObject(
94cdf0e10cSrcweir seqProp[i],
95cdf0e10cSrcweir makeAny(FTPContent::queryCreatableContentsInfo_Static()));
96cdf0e10cSrcweir else
97cdf0e10cSrcweir xRow->appendVoid(seqProp[i]);
98cdf0e10cSrcweir }
99cdf0e10cSrcweir m_aItems[n] = Reference<XRow>(xRow.get());
100cdf0e10cSrcweir }
101cdf0e10cSrcweir }
102