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 <osl/diagnose.h>
21 #include <com/sun/star/uno/Type.hxx>
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/RecipientInfo.hpp>
29 #include <com/sun/star/ucb/RuleSet.hpp>
30 #include <com/sun/star/ucb/SendInfo.hpp>
31 #include <com/sun/star/ucb/SendMediaTypes.hpp>
32 #include <com/sun/star/ucb/XDataContainer.hpp>
33 #include "ucbprops.hxx"
35 using namespace com::sun::star::beans
;
36 using namespace com::sun::star::lang
;
37 using namespace com::sun::star::ucb
;
38 using namespace com::sun::star::uno
;
39 using namespace com::sun::star::util
;
42 //=========================================================================
44 // struct PropertyTableEntry
46 //=========================================================================
48 struct PropertyTableEntry
52 sal_Int16 nAttributes
;
53 const com::sun::star::uno::Type
& (*pGetCppuType
)();
56 //////////////////////////////////////////////////////////////////////////
58 // CPPU type access functions.
60 //////////////////////////////////////////////////////////////////////////
62 static const com::sun::star::uno::Type
& OUString_getCppuType()
64 return getCppuType( static_cast< const OUString
* >( 0 ) );
67 static const com::sun::star::uno::Type
& sal_uInt16_getCppuType()
69 // ! uInt -> Int, because of Java !!!
70 return getCppuType( static_cast< const sal_Int16
* >( 0 ) );
73 static const com::sun::star::uno::Type
& sal_uInt32_getCppuType()
75 // ! uInt -> Int, because of Java !!!
76 return getCppuType( static_cast< const sal_Int32
* >( 0 ) );
79 static const com::sun::star::uno::Type
& sal_uInt64_getCppuType()
81 // ! uInt -> Int, because of Java !!!
82 return getCppuType( static_cast< const sal_Int64
* >( 0 ) );
85 static const com::sun::star::uno::Type
& enum_getCppuType()
87 // ! enum -> Int, because of Java !!!
88 return getCppuType( static_cast< const sal_Int16
* >( 0 ) );
91 static const com::sun::star::uno::Type
& sal_Bool_getCppuType()
93 return getCppuBooleanType();
96 static const com::sun::star::uno::Type
& byte_getCppuType()
98 return getCppuType( static_cast< const sal_Int8
* >( 0 ) );
101 static const com::sun::star::uno::Type
& Sequence_CrossReference_getCppuType()
104 static_cast< com::sun::star::uno::Sequence
<
105 com::sun::star::ucb::CrossReference
> * >( 0 ) );
108 static const com::sun::star::uno::Type
& DateTime_getCppuType()
111 static_cast< com::sun::star::util::DateTime
* >( 0 ) );
114 static const com::sun::star::uno::Type
& Sequence_byte_getCppuType()
117 static_cast< com::sun::star::uno::Sequence
< sal_Int8
> * >( 0 ) );
120 static const com::sun::star::uno::Type
& Sequence_DocumentHeaderField_getCppuType()
123 static_cast< com::sun::star::uno::Sequence
<
124 com::sun::star::ucb::DocumentHeaderField
> * >( 0 ) );
127 static const com::sun::star::uno::Type
& XDataContainer_getCppuType()
130 static_cast< com::sun::star::uno::Reference
<
131 com::sun::star::ucb::XDataContainer
> * >( 0 ) );
134 static const com::sun::star::uno::Type
& Sequence_RecipientInfo_getCppuType()
137 static_cast< com::sun::star::uno::Sequence
<
138 com::sun::star::ucb::RecipientInfo
> * >( 0 ) );
141 static const com::sun::star::uno::Type
& RuleSet_getCppuType()
144 static_cast< com::sun::star::ucb::RuleSet
* >( 0 ) );
147 static const com::sun::star::uno::Type
& Sequence_SendInfo_getCppuType()
150 static_cast< com::sun::star::uno::Sequence
<
151 com::sun::star::ucb::SendInfo
> * >( 0 ) );
154 static const com::sun::star::uno::Type
& Sequence_SendMediaTypes_getCppuType()
157 static_cast< com::sun::star::uno::Sequence
<
158 com::sun::star::ucb::SendMediaTypes
> * >( 0 ) );
161 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
162 // A table with all well-known UCB properties.
163 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
165 #define ATTR_DEFAULT ( PropertyAttribute::BOUND | PropertyAttribute::MAYBEVOID | PropertyAttribute::MAYBEDEFAULT )
167 static const PropertyTableEntry __aPropertyTable
[] =
169 { "Account", -1, ATTR_DEFAULT
, &OUString_getCppuType
},
170 { "AutoUpdateInterval", -1, ATTR_DEFAULT
, &sal_uInt32_getCppuType
},
171 { "ConfirmEmpty", -1, ATTR_DEFAULT
, &sal_Bool_getCppuType
},
172 { "ConnectionLimit", -1, ATTR_DEFAULT
, &byte_getCppuType
},
173 { "ConnectionMode", -1, ATTR_DEFAULT
, &enum_getCppuType
},
174 { "ContentCountLimit", -1, ATTR_DEFAULT
, &sal_uInt16_getCppuType
},
175 { "ContentType", -1, ATTR_DEFAULT
, &OUString_getCppuType
},
176 { "Cookie", -1, ATTR_DEFAULT
, &OUString_getCppuType
},
177 { "CrossReferences", -1, ATTR_DEFAULT
, &Sequence_CrossReference_getCppuType
},
178 { "DateCreated", -1, ATTR_DEFAULT
, &DateTime_getCppuType
},
179 { "DateModified", -1, ATTR_DEFAULT
, &DateTime_getCppuType
},
180 { "DeleteOnServer", -1, ATTR_DEFAULT
, &sal_Bool_getCppuType
},
181 { "DocumentBody", -1, ATTR_DEFAULT
, &Sequence_byte_getCppuType
},
182 { "DocumentCount", -1, ATTR_DEFAULT
| PropertyAttribute::READONLY
,
183 &sal_uInt32_getCppuType
},
184 { "DocumentCountMarked",
185 -1, ATTR_DEFAULT
| PropertyAttribute::READONLY
,
186 &sal_uInt32_getCppuType
},
187 { "DocumentHeader", -1, ATTR_DEFAULT
, &Sequence_DocumentHeaderField_getCppuType
},
188 { "DocumentStoreMode", -1, ATTR_DEFAULT
, &enum_getCppuType
},
189 { "DocumentViewMode", -1, ATTR_DEFAULT
, &enum_getCppuType
},
190 { "FTPAccount", -1, ATTR_DEFAULT
, &OUString_getCppuType
},
191 { "Flags", -1, ATTR_DEFAULT
, &sal_uInt32_getCppuType
},
192 { "FolderCount", -1, ATTR_DEFAULT
| PropertyAttribute::READONLY
,
193 &sal_uInt32_getCppuType
},
194 { "FolderViewMode", -1, ATTR_DEFAULT
, &enum_getCppuType
},
195 { "FreeSpace", -1, ATTR_DEFAULT
| PropertyAttribute::READONLY
,
196 &sal_uInt64_getCppuType
},
197 { "HasDocuments", -1, ATTR_DEFAULT
| PropertyAttribute::READONLY
,
198 &sal_Bool_getCppuType
},
199 { "HasFolders", -1, ATTR_DEFAULT
| PropertyAttribute::READONLY
,
200 &sal_Bool_getCppuType
},
201 { "IsAutoDelete", -1, ATTR_DEFAULT
, &sal_Bool_getCppuType
},
202 { "IsAutoUpdate", -1, ATTR_DEFAULT
, &sal_Bool_getCppuType
},
203 { "IsDocument", -1, ATTR_DEFAULT
| PropertyAttribute::READONLY
,
204 &sal_Bool_getCppuType
},
205 { "IsFolder", -1, ATTR_DEFAULT
| PropertyAttribute::READONLY
,
206 &sal_Bool_getCppuType
},
207 { "IsKeepExpired", -1, ATTR_DEFAULT
, &sal_Bool_getCppuType
},
208 { "IsLimitedContentCount",
209 -1, ATTR_DEFAULT
, &sal_Bool_getCppuType
},
210 { "IsMarked", -1, ATTR_DEFAULT
, &sal_Bool_getCppuType
},
211 { "IsRead", -1, ATTR_DEFAULT
, &sal_Bool_getCppuType
},
212 { "IsReadOnly", -1, ATTR_DEFAULT
, &sal_Bool_getCppuType
},
213 { "IsSubscribed", -1, ATTR_DEFAULT
, &sal_Bool_getCppuType
},
214 { "IsTimeLimitedStore", -1, ATTR_DEFAULT
, &sal_Bool_getCppuType
},
215 { "Keywords", -1, ATTR_DEFAULT
, &OUString_getCppuType
},
216 { "LocalBase", -1, ATTR_DEFAULT
, &OUString_getCppuType
},
217 { "MessageBCC", -1, ATTR_DEFAULT
, &OUString_getCppuType
},
218 { "MessageBody", -1, ATTR_DEFAULT
, &XDataContainer_getCppuType
},
219 { "MessageCC", -1, ATTR_DEFAULT
, &OUString_getCppuType
},
220 { "MessageFrom", -1, ATTR_DEFAULT
, &OUString_getCppuType
},
221 { "MessageId", -1, ATTR_DEFAULT
, &OUString_getCppuType
},
222 { "MessageInReplyTo", -1, ATTR_DEFAULT
, &OUString_getCppuType
},
223 { "MessageReplyTo", -1, ATTR_DEFAULT
, &OUString_getCppuType
},
224 { "MessageTo", -1, ATTR_DEFAULT
, &OUString_getCppuType
},
225 { "NewsGroups", -1, ATTR_DEFAULT
, &OUString_getCppuType
},
226 { "NoCacheList", -1, ATTR_DEFAULT
, &OUString_getCppuType
},
227 { "Origin", -1, ATTR_DEFAULT
| PropertyAttribute::READONLY
,
228 &OUString_getCppuType
},
229 { "OutgoingMessageRecipients",
230 -1, ATTR_DEFAULT
, &Sequence_RecipientInfo_getCppuType
},
231 { "OutgoingMessageState",
232 -1, ATTR_DEFAULT
| PropertyAttribute::READONLY
,
234 { "OutgoingMessageViewMode",
235 -1, ATTR_DEFAULT
, &enum_getCppuType
},
236 { "Password", -1, ATTR_DEFAULT
, &OUString_getCppuType
},
237 { "Priority", -1, ATTR_DEFAULT
, &enum_getCppuType
},
238 { "References", -1, ATTR_DEFAULT
, &OUString_getCppuType
},
239 { "Referer", -1, ATTR_DEFAULT
, &OUString_getCppuType
},
240 { "Rules", -1, ATTR_DEFAULT
, &RuleSet_getCppuType
},
241 { "SearchCriteria", -1, ATTR_DEFAULT
, &RuleSet_getCppuType
},
242 { "SearchIndirections", -1, ATTR_DEFAULT
, &sal_Bool_getCppuType
},
243 { "SearchLocations", -1, ATTR_DEFAULT
, &OUString_getCppuType
},
244 { "SearchRecursive", -1, ATTR_DEFAULT
, &sal_Bool_getCppuType
},
245 { "SeenCount", -1, ATTR_DEFAULT
| PropertyAttribute::READONLY
,
246 &sal_uInt32_getCppuType
},
247 { "SendCopyTarget", -1, ATTR_DEFAULT
, &Sequence_SendInfo_getCppuType
},
248 { "SendFormats", -1, ATTR_DEFAULT
, &Sequence_SendMediaTypes_getCppuType
},
249 { "SendFroms", -1, ATTR_DEFAULT
, &Sequence_SendInfo_getCppuType
},
250 { "SendPasswords", -1, ATTR_DEFAULT
, &Sequence_SendInfo_getCppuType
},
251 { "SendProtocolPrivate",-1, ATTR_DEFAULT
, &sal_uInt16_getCppuType
},
252 { "SendProtocolPublic", -1, ATTR_DEFAULT
, &sal_uInt16_getCppuType
},
253 { "SendReplyTos", -1, ATTR_DEFAULT
, &Sequence_SendInfo_getCppuType
},
254 { "SendServerNames", -1, ATTR_DEFAULT
, &Sequence_SendInfo_getCppuType
},
255 { "SendUserNames", -1, ATTR_DEFAULT
, &Sequence_SendInfo_getCppuType
},
256 { "SendVIMPostOfficePath",
257 -1, ATTR_DEFAULT
, &OUString_getCppuType
},
258 { "ServerBase", -1, ATTR_DEFAULT
, &OUString_getCppuType
},
259 { "ServerName", -1, ATTR_DEFAULT
, &OUString_getCppuType
},
260 { "ServerPort", -1, ATTR_DEFAULT
, &sal_uInt16_getCppuType
},
261 { "Size", -1, ATTR_DEFAULT
| PropertyAttribute::READONLY
,
262 &sal_uInt64_getCppuType
},
263 { "SizeLimit", -1, ATTR_DEFAULT
, &sal_uInt64_getCppuType
},
264 { "SubscribedCount", -1, ATTR_DEFAULT
| PropertyAttribute::READONLY
,
265 &sal_uInt32_getCppuType
},
266 { "SynchronizePolicy", -1, ATTR_DEFAULT
, &enum_getCppuType
},
267 { "TargetFrames", -1, ATTR_DEFAULT
, &OUString_getCppuType
},
268 { "TargetURL", -1, ATTR_DEFAULT
, &OUString_getCppuType
},
269 { "TimeLimitStore", -1, ATTR_DEFAULT
, &sal_uInt16_getCppuType
},
270 { "Title", -1, ATTR_DEFAULT
, &OUString_getCppuType
},
271 { "UpdateOnOpen", -1, ATTR_DEFAULT
, &sal_Bool_getCppuType
},
272 { "UseOutBoxPrivateProtocolSettings",
273 -1, ATTR_DEFAULT
, &sal_Bool_getCppuType
},
274 { "UseOutBoxPublicProtocolSettings",
275 -1, ATTR_DEFAULT
, &sal_Bool_getCppuType
},
276 { "UserName", -1, ATTR_DEFAULT
, &OUString_getCppuType
},
277 { "UserSortCriterium", -1, ATTR_DEFAULT
, &OUString_getCppuType
},
278 { "VIMPostOfficePath", -1, ATTR_DEFAULT
, &OUString_getCppuType
},
279 { "VerificationMode", -1, ATTR_DEFAULT
, &enum_getCppuType
},
281 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
283 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
288 //=========================================================================
289 //=========================================================================
291 // UcbPropertiesManager Implementation.
293 //=========================================================================
294 //=========================================================================
296 UcbPropertiesManager::UcbPropertiesManager(
297 const Reference
< XMultiServiceFactory
>& )
302 //=========================================================================
304 UcbPropertiesManager::~UcbPropertiesManager()
309 //=========================================================================
311 // XInterface methods.
313 //=========================================================================
315 XINTERFACE_IMPL_3( UcbPropertiesManager
,
320 //=========================================================================
322 // XTypeProvider methods.
324 //=========================================================================
326 XTYPEPROVIDER_IMPL_3( UcbPropertiesManager
,
331 //=========================================================================
333 // XServiceInfo methods.
335 //=========================================================================
337 XSERVICEINFO_IMPL_1( UcbPropertiesManager
,
338 OUString( "com.sun.star.comp.ucb.UcbPropertiesManager" ),
339 OUString( PROPERTIES_MANAGER_SERVICE_NAME
) );
341 //=========================================================================
343 // Service factory implementation.
345 //=========================================================================
347 ONE_INSTANCE_SERVICE_FACTORY_IMPL( UcbPropertiesManager
);
349 //=========================================================================
351 // XPropertySetInfo methods.
353 //=========================================================================
356 Sequence
< Property
> SAL_CALL
UcbPropertiesManager::getProperties()
357 throw( RuntimeException
)
359 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
363 m_pProps
= new Sequence
< Property
>( 128 );
364 Property
* pProps
= m_pProps
->getArray();
366 sal_Int32 nSize
= m_pProps
->getLength();
368 //////////////////////////////////////////////////////////////////
369 // Get info for well-known properties.
370 //////////////////////////////////////////////////////////////////
372 const PropertyTableEntry
* pCurr
= &__aPropertyTable
[ 0 ];
373 while ( pCurr
->pName
)
377 OSL_FAIL( "UcbPropertiesManager::getProperties - "
378 "Initial size of property sequence too small!" );
380 m_pProps
->realloc( 128 );
384 Property
& rProp
= pProps
[ nPos
];
386 rProp
.Name
= OUString::createFromAscii( pCurr
->pName
);
387 rProp
.Handle
= pCurr
->nHandle
;
388 rProp
.Type
= pCurr
->pGetCppuType();
389 rProp
.Attributes
= pCurr
->nAttributes
;
397 m_pProps
->realloc( nPos
);
398 nSize
= m_pProps
->getLength();
404 //=========================================================================
406 Property SAL_CALL
UcbPropertiesManager::getPropertyByName( const OUString
& aName
)
407 throw( UnknownPropertyException
, RuntimeException
)
410 if ( queryProperty( aName
, aProp
) )
413 throw UnknownPropertyException();
416 //=========================================================================
418 sal_Bool SAL_CALL
UcbPropertiesManager::hasPropertyByName( const OUString
& Name
)
419 throw( RuntimeException
)
422 return queryProperty( Name
, aProp
);
425 //=========================================================================
427 // Non-Interface methods.
429 //=========================================================================
431 sal_Bool
UcbPropertiesManager::queryProperty(
432 const OUString
& rName
, Property
& rProp
)
434 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
438 const Property
* pProps
= m_pProps
->getConstArray();
439 sal_Int32 nCount
= m_pProps
->getLength();
440 for ( sal_Int32 n
= 0; n
< nCount
; ++n
)
442 const Property
& rCurrProp
= pProps
[ n
];
443 if ( rCurrProp
.Name
== rName
)
453 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */