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/uno/Reference.hxx>
24 #include <com/sun/star/beans/PropertyAttribute.hpp>
25 #include <com/sun/star/ucb/CrossReference.hpp>
26 #include <com/sun/star/util/DateTime.hpp>
27 #include <com/sun/star/ucb/DocumentHeaderField.hpp>
28 #include <com/sun/star/ucb/DocumentStoreMode.hpp>
29 #include <com/sun/star/ucb/Priority.hpp>
30 #include <com/sun/star/ucb/RecipientInfo.hpp>
31 #include <com/sun/star/ucb/RuleSet.hpp>
32 #include <com/sun/star/ucb/SendInfo.hpp>
33 #include <com/sun/star/ucb/SendMediaTypes.hpp>
34 #include <com/sun/star/ucb/SynchronizePolicy.hpp>
35 #include <com/sun/star/ucb/VerificationMode.hpp>
36 #include <com/sun/star/ucb/XDataContainer.hpp>
37 #include <ucbhelper/macros.hxx>
39 #include "ucbprops.hxx"
41 using namespace com::sun::star::beans
;
42 using namespace com::sun::star::lang
;
43 using namespace com::sun::star::uno
;
45 #define ATTR_DEFAULT ( PropertyAttribute::BOUND | PropertyAttribute::MAYBEVOID | PropertyAttribute::MAYBEDEFAULT )
47 UcbPropertiesManager::UcbPropertiesManager()
49 { "Account", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
50 { "AutoUpdateInterval", -1, cppu::UnoType
<sal_Int32
>::get(), ATTR_DEFAULT
},
51 { "ConfirmEmpty", -1, cppu::UnoType
<bool>::get(), ATTR_DEFAULT
},
52 { "ConnectionLimit", -1, cppu::UnoType
<sal_Int16
>::get(), ATTR_DEFAULT
},
53 { "ConnectionMode", -1, cppu::UnoType
<sal_Int16
>::get(), ATTR_DEFAULT
},
54 { "ContentCountLimit", -1, cppu::UnoType
<sal_Int16
>::get(), ATTR_DEFAULT
},
55 { "ContentType", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
56 { "Cookie", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
57 { "CrossReferences", -1,
58 cppu::UnoType
<css::uno::Sequence
<css::ucb::CrossReference
>>::get(),
60 { "DateCreated", -1, cppu::UnoType
<css::util::DateTime
>::get(),
62 { "DateModified", -1, cppu::UnoType
<css::util::DateTime
>::get(),
64 { "DeleteOnServer", -1, cppu::UnoType
<bool>::get(), ATTR_DEFAULT
},
65 { "DocumentBody", -1, cppu::UnoType
<css::uno::Sequence
<sal_Int8
>>::get(),
67 { "DocumentCount", -1, cppu::UnoType
<sal_Int32
>::get(),
68 ATTR_DEFAULT
| PropertyAttribute::READONLY
},
69 { "DocumentCountMarked", -1, cppu::UnoType
<sal_Int32
>::get(),
70 ATTR_DEFAULT
| PropertyAttribute::READONLY
},
71 { "DocumentHeader", -1,
72 cppu::UnoType
<css::uno::Sequence
<css::ucb::DocumentHeaderField
>>::get(),
74 { "DocumentStoreMode", -1,
75 cppu::UnoType
<css::ucb::DocumentStoreMode
>::get(), ATTR_DEFAULT
},
76 { "DocumentViewMode", -1, cppu::UnoType
<sal_Int16
>::get(), ATTR_DEFAULT
},
77 { "FTPAccount", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
78 { "Flags", -1, cppu::UnoType
<sal_Int32
>::get(), ATTR_DEFAULT
},
79 { "FolderCount", -1, cppu::UnoType
<sal_Int32
>::get(),
80 ATTR_DEFAULT
| PropertyAttribute::READONLY
},
81 { "FolderViewMode", -1, cppu::UnoType
<sal_Int16
>::get(), ATTR_DEFAULT
},
82 { "FreeSpace", -1, cppu::UnoType
<sal_Int64
>::get(),
83 ATTR_DEFAULT
| PropertyAttribute::READONLY
},
84 { "HasDocuments", -1, cppu::UnoType
<bool>::get(),
85 ATTR_DEFAULT
| PropertyAttribute::READONLY
},
86 { "HasFolders", -1, cppu::UnoType
<bool>::get(),
87 ATTR_DEFAULT
| PropertyAttribute::READONLY
},
88 { "IsAutoDelete", -1, cppu::UnoType
<bool>::get(), ATTR_DEFAULT
},
89 { "IsAutoUpdate", -1, cppu::UnoType
<bool>::get(), ATTR_DEFAULT
},
90 { "IsDocument", -1, cppu::UnoType
<bool>::get(),
91 ATTR_DEFAULT
| PropertyAttribute::READONLY
},
92 { "IsFolder", -1, cppu::UnoType
<bool>::get(),
93 ATTR_DEFAULT
| PropertyAttribute::READONLY
},
94 { "IsKeepExpired", -1, cppu::UnoType
<bool>::get(), ATTR_DEFAULT
},
95 { "IsLimitedContentCount", -1, cppu::UnoType
<bool>::get(), ATTR_DEFAULT
},
96 { "IsMarked", -1, cppu::UnoType
<bool>::get(), ATTR_DEFAULT
},
97 { "IsRead", -1, cppu::UnoType
<bool>::get(), ATTR_DEFAULT
},
98 { "IsReadOnly", -1, cppu::UnoType
<bool>::get(), ATTR_DEFAULT
},
99 { "IsSubscribed", -1, cppu::UnoType
<bool>::get(), ATTR_DEFAULT
},
100 { "IsTimeLimitedStore", -1, cppu::UnoType
<bool>::get(), ATTR_DEFAULT
},
101 { "Keywords", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
102 { "LocalBase", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
103 { "MessageBCC", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
104 { "MessageBody", -1, cppu::UnoType
<css::ucb::XDataContainer
>::get(),
106 { "MessageCC", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
107 { "MessageFrom", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
108 { "MessageId", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
109 { "MessageInReplyTo", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
110 { "MessageReplyTo", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
111 { "MessageTo", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
112 { "NewsGroups", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
113 { "NoCacheList", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
114 { "Origin", -1, cppu::UnoType
<OUString
>::get(),
115 ATTR_DEFAULT
| PropertyAttribute::READONLY
},
116 { "OutgoingMessageRecipients", -1,
117 cppu::UnoType
<css::uno::Sequence
<css::ucb::RecipientInfo
>>::get(),
119 { "OutgoingMessageState", -1,
120 cppu::UnoType
<css::ucb::OutgoingMessageState
>::get(),
121 ATTR_DEFAULT
| PropertyAttribute::READONLY
},
122 { "OutgoingMessageViewMode", -1, cppu::UnoType
<sal_Int16
>::get(),
124 { "Password", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
125 { "Priority", -1, cppu::UnoType
<css::ucb::Priority
>::get(), ATTR_DEFAULT
},
126 { "References", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
127 { "Referer", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
128 { "Rules", -1, cppu::UnoType
<css::ucb::RuleSet
>::get(), ATTR_DEFAULT
},
129 { "SearchCriteria", -1, cppu::UnoType
<css::ucb::RuleSet
>::get(),
131 { "SearchIndirections", -1, cppu::UnoType
<bool>::get(), ATTR_DEFAULT
},
132 { "SearchLocations", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
133 { "SearchRecursive", -1, cppu::UnoType
<bool>::get(), ATTR_DEFAULT
},
134 { "SeenCount", -1, cppu::UnoType
<sal_Int32
>::get(),
135 ATTR_DEFAULT
| PropertyAttribute::READONLY
},
136 { "SendCopyTarget", -1,
137 cppu::UnoType
<css::uno::Sequence
<css::ucb::SendInfo
>>::get(),
140 cppu::UnoType
<css::uno::Sequence
<css::ucb::SendMediaTypes
>>::get(),
143 cppu::UnoType
<css::uno::Sequence
<css::ucb::SendInfo
>>::get(),
145 { "SendPasswords", -1,
146 cppu::UnoType
<css::uno::Sequence
<css::ucb::SendInfo
>>::get(),
148 { "SendProtocolPrivate", -1, cppu::UnoType
<sal_Int16
>::get(),
150 { "SendProtocolPublic", -1, cppu::UnoType
<sal_Int16
>::get(), ATTR_DEFAULT
},
151 { "SendReplyTos", -1,
152 cppu::UnoType
<css::uno::Sequence
<css::ucb::SendInfo
>>::get(),
154 { "SendServerNames", -1,
155 cppu::UnoType
<css::uno::Sequence
<css::ucb::SendInfo
>>::get(),
157 { "SendUserNames", -1,
158 cppu::UnoType
<css::uno::Sequence
<css::ucb::SendInfo
>>::get(),
160 { "SendVIMPostOfficePath", -1, cppu::UnoType
<OUString
>::get(),
162 { "ServerBase", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
163 { "ServerName", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
164 { "ServerPort", -1, cppu::UnoType
<sal_Int16
>::get(), ATTR_DEFAULT
},
165 { "Size", -1, cppu::UnoType
<sal_Int64
>::get(),
166 ATTR_DEFAULT
| PropertyAttribute::READONLY
},
167 { "SizeLimit", -1, cppu::UnoType
<sal_Int64
>::get(), ATTR_DEFAULT
},
168 { "SubscribedCount", -1, cppu::UnoType
<sal_Int32
>::get(),
169 ATTR_DEFAULT
| PropertyAttribute::READONLY
},
170 { "SynchronizePolicy", -1,
171 cppu::UnoType
<css::ucb::SynchronizePolicy
>::get(), ATTR_DEFAULT
},
172 { "TargetFrames", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
173 { "TargetURL", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
174 { "TimeLimitStore", -1, cppu::UnoType
<sal_Int16
>::get(), ATTR_DEFAULT
},
175 { "Title", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
176 { "UpdateOnOpen", -1, cppu::UnoType
<bool>::get(), ATTR_DEFAULT
},
177 { "UseOutBoxPrivateProtocolSettings", -1, cppu::UnoType
<bool>::get(),
179 { "UseOutBoxPublicProtocolSettings", -1, cppu::UnoType
<bool>::get(),
181 { "UserName", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
182 { "UserSortCriterium", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
183 { "VIMPostOfficePath", -1, cppu::UnoType
<OUString
>::get(), ATTR_DEFAULT
},
184 { "VerificationMode", -1, cppu::UnoType
<css::ucb::VerificationMode
>::get(),
191 UcbPropertiesManager::~UcbPropertiesManager()
196 // XServiceInfo methods.
198 XSERVICEINFO_COMMOM_IMPL( UcbPropertiesManager
,
199 "com.sun.star.comp.ucb.UcbPropertiesManager" )
200 /// @throws css::uno::Exception
201 static css::uno::Reference
< css::uno::XInterface
>
202 UcbPropertiesManager_CreateInstance( const css::uno::Reference
< css::lang::XMultiServiceFactory
> & /*rSMgr*/ )
204 return static_cast<css::lang::XServiceInfo
*>(new UcbPropertiesManager
);
206 css::uno::Sequence
< OUString
>
207 UcbPropertiesManager::getSupportedServiceNames_Static()
209 return { PROPERTIES_MANAGER_SERVICE_NAME
};
212 // Service factory implementation.
215 ONE_INSTANCE_SERVICE_FACTORY_IMPL( UcbPropertiesManager
);
218 // XPropertySetInfo methods.
222 Sequence
< Property
> SAL_CALL
UcbPropertiesManager::getProperties()
229 Property SAL_CALL
UcbPropertiesManager::getPropertyByName( const OUString
& aName
)
232 if ( queryProperty( aName
, aProp
) )
235 throw UnknownPropertyException(aName
);
240 sal_Bool SAL_CALL
UcbPropertiesManager::hasPropertyByName( const OUString
& Name
)
243 return queryProperty( Name
, aProp
);
247 // Non-Interface methods.
250 bool UcbPropertiesManager::queryProperty(
251 const OUString
& rName
, Property
& rProp
)
253 auto pProp
= std::find_if(m_pProps
.begin(), m_pProps
.end(),
254 [&rName
](const Property
& rCurrProp
) { return rCurrProp
.Name
== rName
; });
255 if (pProp
!= m_pProps
.end())
264 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */