Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 :
21 : #include "comphelper/processfactory.hxx"
22 : #include "ucbhelper/propertyvalueset.hxx"
23 : #include "rtl/ref.hxx"
24 : #include "com/sun/star/ucb/Command.hpp"
25 : #include "com/sun/star/ucb/XCommandEnvironment.hpp"
26 : #include "com/sun/star/ucb/XCommandProcessor.hpp"
27 : #include "com/sun/star/sdbc/XRow.hpp"
28 : #include "ftpresultsetI.hxx"
29 : #include "ftpcontent.hxx"
30 :
31 :
32 : using namespace std;
33 : using namespace ftp;
34 : using namespace com::sun::star::ucb;
35 : using namespace com::sun::star::lang;
36 : using namespace com::sun::star::uno;
37 : using namespace com::sun::star::beans;
38 : using namespace com::sun::star::sdbc;
39 :
40 :
41 0 : ResultSetI::ResultSetI(const Reference<XComponentContext>& rxContext,
42 : const Reference<XContentProvider>& xProvider,
43 : sal_Int32 nOpenMode,
44 : const Sequence<Property>& seqProp,
45 : const Sequence< NumberedSortingInfo >& seqSort,
46 : const std::vector<FTPDirentry>& dirvec)
47 0 : : ResultSetBase(rxContext,xProvider,nOpenMode,seqProp,seqSort)
48 : {
49 0 : for( size_t i = 0; i < dirvec.size(); ++i)
50 0 : m_aPath.push_back(dirvec[i].m_aURL);
51 :
52 : // m_aIdents holds the contentidentifiers
53 :
54 0 : m_aItems.resize( m_aPath.size() );
55 0 : m_aIdents.resize( m_aPath.size() );
56 :
57 0 : for(size_t n = 0; n < m_aItems.size(); ++n) {
58 : rtl::Reference<ucbhelper::PropertyValueSet> xRow =
59 0 : new ucbhelper::PropertyValueSet(rxContext);
60 :
61 0 : for( int i = 0; i < seqProp.getLength(); ++i) {
62 0 : const OUString& Name = seqProp[i].Name;
63 0 : if(Name == "ContentType")
64 0 : xRow->appendString(seqProp[i],
65 0 : OUString( "application/ftp" ));
66 0 : else if(Name == "Title")
67 0 : xRow->appendString(seqProp[i],dirvec[n].m_aName);
68 0 : else if(Name == "IsReadOnly")
69 0 : xRow->appendBoolean(seqProp[i],
70 0 : (dirvec[n].m_nMode &
71 0 : INETCOREFTP_FILEMODE_WRITE) == INETCOREFTP_FILEMODE_WRITE);
72 0 : else if(Name == "IsDocument")
73 0 : xRow->appendBoolean(seqProp[i],
74 0 : (dirvec[n].m_nMode &
75 0 : INETCOREFTP_FILEMODE_ISDIR) != INETCOREFTP_FILEMODE_ISDIR);
76 0 : else if(Name == "IsFolder")
77 0 : xRow->appendBoolean(seqProp[i],
78 0 : ( dirvec[n].m_nMode &
79 0 : INETCOREFTP_FILEMODE_ISDIR) == INETCOREFTP_FILEMODE_ISDIR);
80 0 : else if(Name == "Size")
81 0 : xRow->appendLong(seqProp[i],
82 0 : dirvec[n].m_nSize);
83 0 : else if(Name == "DateCreated")
84 0 : xRow->appendTimestamp(seqProp[i],
85 0 : dirvec[n].m_aDate);
86 0 : else if(Name == "CreatableContentsInfo")
87 : xRow->appendObject(
88 0 : seqProp[i],
89 0 : makeAny(FTPContent::queryCreatableContentsInfo_Static()));
90 : else
91 0 : xRow->appendVoid(seqProp[i]);
92 : }
93 0 : m_aItems[n] = Reference<XRow>(xRow.get());
94 0 : }
95 0 : }
96 :
97 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|