1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <sal/config.h>
22 #include <com/sun/star/uno/Sequence.hxx>
23 #include <com/sun/star/beans/PropertyAttribute.hpp>
24 #include <com/sun/star/ucb/CrossReference.hpp>
25 #include <com/sun/star/util/DateTime.hpp>
26 #include <com/sun/star/ucb/DocumentHeaderField.hpp>
27 #include <com/sun/star/ucb/DocumentStoreMode.hpp>
28 #include <com/sun/star/ucb/Priority.hpp>
29 #include <com/sun/star/ucb/RecipientInfo.hpp>
30 #include <com/sun/star/ucb/RuleSet.hpp>
31 #include <com/sun/star/ucb/SendInfo.hpp>
32 #include <com/sun/star/ucb/SendMediaTypes.hpp>
33 #include <com/sun/star/ucb/SynchronizePolicy.hpp>
34 #include <com/sun/star/ucb/VerificationMode.hpp>
35 #include <com/sun/star/ucb/XDataContainer.hpp>
36 #include <com/sun/star/uno/XComponentContext.hpp>
37 #include <cppuhelper/supportsservice.hxx>
38 #include <cppuhelper/weak.hxx>
40 #include "ucbprops.hxx"
42 using namespace com::sun::star::beans
;
43 using namespace com::sun::star::lang
;
44 using namespace com::sun::star::uno
;
46 #define ATTR_DEFAULT ( PropertyAttribute::BOUND | PropertyAttribute::MAYBEVOID | PropertyAttribute::MAYBEDEFAULT )
48 UcbPropertiesManager::UcbPropertiesManager()
50 { "Account", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
51 { "AutoUpdateInterval", -1, cppu::UnoType
<sal_Int32
>::get(), ATTR_DEFAULT
},
52 { "ConfirmEmpty", -1, cppu::UnoType
<bool>::get(), ATTR_DEFAULT
},
53 { "ConnectionLimit", -1, cppu::UnoType
<sal_Int16
>::get(), ATTR_DEFAULT
},
54 { "ConnectionMode", -1, cppu::UnoType
<sal_Int16
>::get(), ATTR_DEFAULT
},
55 { "ContentCountLimit", -1, cppu::UnoType
<sal_Int16
>::get(), ATTR_DEFAULT
},
56 { "ContentType", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
57 { "Cookie", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
58 { "CrossReferences", -1,
59 cppu::UnoType
<css::uno::Sequence
<css::ucb::CrossReference
>>::get(),
61 { "DateCreated", -1, cppu::UnoType
<css::util::DateTime
>::get(),
63 { "DateModified", -1, cppu::UnoType
<css::util::DateTime
>::get(),
65 { "DeleteOnServer", -1, cppu::UnoType
<bool>::get(), ATTR_DEFAULT
},
66 { "DocumentBody", -1, cppu::UnoType
<css::uno::Sequence
<sal_Int8
>>::get(),
68 { "DocumentCount", -1, cppu::UnoType
<sal_Int32
>::get(),
69 ATTR_DEFAULT
| PropertyAttribute::READONLY
},
70 { "DocumentCountMarked", -1, cppu::UnoType
<sal_Int32
>::get(),
71 ATTR_DEFAULT
| PropertyAttribute::READONLY
},
72 { "DocumentHeader", -1,
73 cppu::UnoType
<css::uno::Sequence
<css::ucb::DocumentHeaderField
>>::get(),
75 { "DocumentStoreMode", -1,
76 cppu::UnoType
<css::ucb::DocumentStoreMode
>::get(), ATTR_DEFAULT
},
77 { "DocumentViewMode", -1, cppu::UnoType
<sal_Int16
>::get(), ATTR_DEFAULT
},
78 { "FTPAccount", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
79 { "Flags", -1, cppu::UnoType
<sal_Int32
>::get(), ATTR_DEFAULT
},
80 { "FolderCount", -1, cppu::UnoType
<sal_Int32
>::get(),
81 ATTR_DEFAULT
| PropertyAttribute::READONLY
},
82 { "FolderViewMode", -1, cppu::UnoType
<sal_Int16
>::get(), ATTR_DEFAULT
},
83 { "FreeSpace", -1, cppu::UnoType
<sal_Int64
>::get(),
84 ATTR_DEFAULT
| PropertyAttribute::READONLY
},
85 { "HasDocuments", -1, cppu::UnoType
<bool>::get(),
86 ATTR_DEFAULT
| PropertyAttribute::READONLY
},
87 { "HasFolders", -1, cppu::UnoType
<bool>::get(),
88 ATTR_DEFAULT
| PropertyAttribute::READONLY
},
89 { "IsAutoDelete", -1, cppu::UnoType
<bool>::get(), ATTR_DEFAULT
},
90 { "IsAutoUpdate", -1, cppu::UnoType
<bool>::get(), ATTR_DEFAULT
},
91 { "IsDocument", -1, cppu::UnoType
<bool>::get(),
92 ATTR_DEFAULT
| PropertyAttribute::READONLY
},
93 { "IsFolder", -1, cppu::UnoType
<bool>::get(),
94 ATTR_DEFAULT
| PropertyAttribute::READONLY
},
95 { "IsKeepExpired", -1, cppu::UnoType
<bool>::get(), ATTR_DEFAULT
},
96 { "IsLimitedContentCount", -1, cppu::UnoType
<bool>::get(), ATTR_DEFAULT
},
97 { "IsMarked", -1, cppu::UnoType
<bool>::get(), ATTR_DEFAULT
},
98 { "IsRead", -1, cppu::UnoType
<bool>::get(), ATTR_DEFAULT
},
99 { "IsReadOnly", -1, cppu::UnoType
<bool>::get(), ATTR_DEFAULT
},
100 { "IsSubscribed", -1, cppu::UnoType
<bool>::get(), ATTR_DEFAULT
},
101 { "IsTimeLimitedStore", -1, cppu::UnoType
<bool>::get(), ATTR_DEFAULT
},
102 { "Keywords", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
103 { "LocalBase", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
104 { "MessageBCC", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
105 { "MessageBody", -1, cppu::UnoType
<css::ucb::XDataContainer
>::get(),
107 { "MessageCC", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
108 { "MessageFrom", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
109 { "MessageId", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
110 { "MessageInReplyTo", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
111 { "MessageReplyTo", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
112 { "MessageTo", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
113 { "NewsGroups", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
114 { "NoCacheList", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
115 { "Origin", -1, cppu::UnoType
<OUString
>::get(),
116 ATTR_DEFAULT
| PropertyAttribute::READONLY
},
117 { "OutgoingMessageRecipients", -1,
118 cppu::UnoType
<css::uno::Sequence
<css::ucb::RecipientInfo
>>::get(),
120 { "OutgoingMessageState", -1,
121 cppu::UnoType
<css::ucb::OutgoingMessageState
>::get(),
122 ATTR_DEFAULT
| PropertyAttribute::READONLY
},
123 { "OutgoingMessageViewMode", -1, cppu::UnoType
<sal_Int16
>::get(),
125 { "Password", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
126 { "Priority", -1, cppu::UnoType
<css::ucb::Priority
>::get(), ATTR_DEFAULT
},
127 { "References", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
128 { "Referer", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
129 { "Rules", -1, cppu::UnoType
<css::ucb::RuleSet
>::get(), ATTR_DEFAULT
},
130 { "SearchCriteria", -1, cppu::UnoType
<css::ucb::RuleSet
>::get(),
132 { "SearchIndirections", -1, cppu::UnoType
<bool>::get(), ATTR_DEFAULT
},
133 { "SearchLocations", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
134 { "SearchRecursive", -1, cppu::UnoType
<bool>::get(), ATTR_DEFAULT
},
135 { "SeenCount", -1, cppu::UnoType
<sal_Int32
>::get(),
136 ATTR_DEFAULT
| PropertyAttribute::READONLY
},
137 { "SendCopyTarget", -1,
138 cppu::UnoType
<css::uno::Sequence
<css::ucb::SendInfo
>>::get(),
141 cppu::UnoType
<css::uno::Sequence
<css::ucb::SendMediaTypes
>>::get(),
144 cppu::UnoType
<css::uno::Sequence
<css::ucb::SendInfo
>>::get(),
146 { "SendPasswords", -1,
147 cppu::UnoType
<css::uno::Sequence
<css::ucb::SendInfo
>>::get(),
149 { "SendProtocolPrivate", -1, cppu::UnoType
<sal_Int16
>::get(),
151 { "SendProtocolPublic", -1, cppu::UnoType
<sal_Int16
>::get(), ATTR_DEFAULT
},
152 { "SendReplyTos", -1,
153 cppu::UnoType
<css::uno::Sequence
<css::ucb::SendInfo
>>::get(),
155 { "SendServerNames", -1,
156 cppu::UnoType
<css::uno::Sequence
<css::ucb::SendInfo
>>::get(),
158 { "SendUserNames", -1,
159 cppu::UnoType
<css::uno::Sequence
<css::ucb::SendInfo
>>::get(),
161 { "SendVIMPostOfficePath", -1, cppu::UnoType
<OUString
>::get(),
163 { "ServerBase", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
164 { "ServerName", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
165 { "ServerPort", -1, cppu::UnoType
<sal_Int16
>::get(), ATTR_DEFAULT
},
166 { "Size", -1, cppu::UnoType
<sal_Int64
>::get(),
167 ATTR_DEFAULT
| PropertyAttribute::READONLY
},
168 { "SizeLimit", -1, cppu::UnoType
<sal_Int64
>::get(), ATTR_DEFAULT
},
169 { "SubscribedCount", -1, cppu::UnoType
<sal_Int32
>::get(),
170 ATTR_DEFAULT
| PropertyAttribute::READONLY
},
171 { "SynchronizePolicy", -1,
172 cppu::UnoType
<css::ucb::SynchronizePolicy
>::get(), ATTR_DEFAULT
},
173 { "TargetFrames", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
174 { "TargetURL", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
175 { "TimeLimitStore", -1, cppu::UnoType
<sal_Int16
>::get(), ATTR_DEFAULT
},
176 { "Title", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
177 { "UpdateOnOpen", -1, cppu::UnoType
<bool>::get(), ATTR_DEFAULT
},
178 { "UseOutBoxPrivateProtocolSettings", -1, cppu::UnoType
<bool>::get(),
180 { "UseOutBoxPublicProtocolSettings", -1, cppu::UnoType
<bool>::get(),
182 { "UserName", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
183 { "UserSortCriterium", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
184 { "VIMPostOfficePath", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
185 { "VerificationMode", -1, cppu::UnoType
<css::ucb::VerificationMode
>::get(),
192 UcbPropertiesManager::~UcbPropertiesManager()
196 // XServiceInfo methods.
198 OUString SAL_CALL
UcbPropertiesManager::getImplementationName()
200 return "com.sun.star.comp.ucb.UcbPropertiesManager";
202 sal_Bool SAL_CALL
UcbPropertiesManager::supportsService( const OUString
& ServiceName
)
204 return cppu::supportsService( this, ServiceName
);
206 css::uno::Sequence
< OUString
> SAL_CALL
UcbPropertiesManager::getSupportedServiceNames()
208 return { "com.sun.star.ucb.PropertiesManager" };
213 // Service factory implementation.
215 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
216 ucb_UcbPropertiesManager_get_implementation(
217 css::uno::XComponentContext
* , css::uno::Sequence
<css::uno::Any
> const&)
219 return cppu::acquire(new UcbPropertiesManager());
222 // XPropertySetInfo methods.
226 Sequence
< Property
> SAL_CALL
UcbPropertiesManager::getProperties()
233 Property SAL_CALL
UcbPropertiesManager::getPropertyByName( const OUString
& aName
)
236 if ( queryProperty( aName
, aProp
) )
239 throw UnknownPropertyException(aName
);
244 sal_Bool SAL_CALL
UcbPropertiesManager::hasPropertyByName( const OUString
& Name
)
247 return queryProperty( Name
, aProp
);
251 // Non-Interface methods.
254 bool UcbPropertiesManager::queryProperty(
255 const OUString
& rName
, Property
& rProp
)
257 auto pProp
= std::find_if(std::cbegin(m_pProps
), std::cend(m_pProps
),
258 [&rName
](const Property
& rCurrProp
) { return rCurrProp
.Name
== rName
; });
259 if (pProp
!= std::cend(m_pProps
))
268 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */