Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / ucb / source / core / ucbprops.cxx
blobfe52f20e135415141e63d6c5de5a4ac5c1a35a47
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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()
48 : m_pProps({
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(),
59 ATTR_DEFAULT },
60 { "DateCreated", -1, cppu::UnoType<css::util::DateTime>::get(),
61 ATTR_DEFAULT },
62 { "DateModified", -1, cppu::UnoType<css::util::DateTime>::get(),
63 ATTR_DEFAULT },
64 { "DeleteOnServer", -1, cppu::UnoType<bool>::get(), ATTR_DEFAULT },
65 { "DocumentBody", -1, cppu::UnoType<css::uno::Sequence<sal_Int8>>::get(),
66 ATTR_DEFAULT },
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(),
73 ATTR_DEFAULT },
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(),
105 ATTR_DEFAULT },
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(),
118 ATTR_DEFAULT },
119 { "OutgoingMessageState", -1,
120 cppu::UnoType<css::ucb::OutgoingMessageState>::get(),
121 ATTR_DEFAULT | PropertyAttribute::READONLY },
122 { "OutgoingMessageViewMode", -1, cppu::UnoType<sal_Int16>::get(),
123 ATTR_DEFAULT },
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(),
130 ATTR_DEFAULT },
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(),
138 ATTR_DEFAULT },
139 { "SendFormats", -1,
140 cppu::UnoType<css::uno::Sequence<css::ucb::SendMediaTypes>>::get(),
141 ATTR_DEFAULT },
142 { "SendFroms", -1,
143 cppu::UnoType<css::uno::Sequence<css::ucb::SendInfo>>::get(),
144 ATTR_DEFAULT },
145 { "SendPasswords", -1,
146 cppu::UnoType<css::uno::Sequence<css::ucb::SendInfo>>::get(),
147 ATTR_DEFAULT },
148 { "SendProtocolPrivate", -1, cppu::UnoType<sal_Int16>::get(),
149 ATTR_DEFAULT },
150 { "SendProtocolPublic", -1, cppu::UnoType<sal_Int16>::get(), ATTR_DEFAULT },
151 { "SendReplyTos", -1,
152 cppu::UnoType<css::uno::Sequence<css::ucb::SendInfo>>::get(),
153 ATTR_DEFAULT },
154 { "SendServerNames", -1,
155 cppu::UnoType<css::uno::Sequence<css::ucb::SendInfo>>::get(),
156 ATTR_DEFAULT },
157 { "SendUserNames", -1,
158 cppu::UnoType<css::uno::Sequence<css::ucb::SendInfo>>::get(),
159 ATTR_DEFAULT },
160 { "SendVIMPostOfficePath", -1, cppu::UnoType<OUString>::get(),
161 ATTR_DEFAULT },
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(),
178 ATTR_DEFAULT },
179 { "UseOutBoxPublicProtocolSettings", -1, cppu::UnoType<bool>::get(),
180 ATTR_DEFAULT },
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(),
185 ATTR_DEFAULT }})
190 // virtual
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.
221 // virtual
222 Sequence< Property > SAL_CALL UcbPropertiesManager::getProperties()
224 return m_pProps;
228 // virtual
229 Property SAL_CALL UcbPropertiesManager::getPropertyByName( const OUString& aName )
231 Property aProp;
232 if ( queryProperty( aName, aProp ) )
233 return aProp;
235 throw UnknownPropertyException(aName);
239 // virtual
240 sal_Bool SAL_CALL UcbPropertiesManager::hasPropertyByName( const OUString& Name )
242 Property aProp;
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())
257 rProp = *pProp;
258 return true;
261 return false;
264 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */