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 PropertyTableEntry __aPropertyTable
[] =
169 { "Account", -1 /* WID_ACCOUNT */, ATTR_DEFAULT
, &OUString_getCppuType
},
170 { "AutoUpdateInterval", -1 /* WID_AUTOUPDATE_INTERVAL */, ATTR_DEFAULT
, &sal_uInt32_getCppuType
},
171 { "ConfirmEmpty", -1 /* WID_TRASHCAN_FLAG_CONFIRMEMPTY */,
172 ATTR_DEFAULT
, &sal_Bool_getCppuType
},
173 { "ConnectionLimit", -1 /* WID_HTTP_CONNECTION_LIMIT */, ATTR_DEFAULT
, &byte_getCppuType
},
174 { "ConnectionMode", -1 /* WID_CONNECTION_MODE */, ATTR_DEFAULT
, &enum_getCppuType
},
175 { "ContentCountLimit", -1 /* WID_SHOW_MSGS_TIMELIMIT */, ATTR_DEFAULT
, &sal_uInt16_getCppuType
},
176 { "ContentType", -1 /* WID_CONTENT_TYPE */, ATTR_DEFAULT
, &OUString_getCppuType
},
177 { "Cookie", -1 /* WID_HTTP_COOKIE */, ATTR_DEFAULT
, &OUString_getCppuType
},
178 { "CrossReferences", -1 /* WID_NEWS_XREFLIST */, ATTR_DEFAULT
, &Sequence_CrossReference_getCppuType
},
179 { "DateCreated", -1 /* WID_DATE_CREATED */, ATTR_DEFAULT
, &DateTime_getCppuType
},
180 { "DateModified", -1 /* WID_DATE_MODIFIED */, ATTR_DEFAULT
, &DateTime_getCppuType
},
181 { "DeleteOnServer", -1 /* WID_DELETE_ON_SERVER */, ATTR_DEFAULT
, &sal_Bool_getCppuType
},
182 { "DocumentBody", -1 /* WID_DOCUMENT_BODY */, ATTR_DEFAULT
, &Sequence_byte_getCppuType
},
183 { "DocumentCount", -1 /* WID_TOTALCONTENTCOUNT */, ATTR_DEFAULT
| PropertyAttribute::READONLY
,
184 &sal_uInt32_getCppuType
},
185 { "DocumentCountMarked",
186 -1 /* WID_MARKED_DOCUMENT_COUNT */, ATTR_DEFAULT
| PropertyAttribute::READONLY
,
187 &sal_uInt32_getCppuType
},
188 { "DocumentHeader", -1 /* WID_DOCUMENT_HEADER */, ATTR_DEFAULT
, &Sequence_DocumentHeaderField_getCppuType
},
189 { "DocumentStoreMode", -1 /* WID_MESSAGE_STOREMODE */, ATTR_DEFAULT
, &enum_getCppuType
},
190 { "DocumentViewMode", -1 /* WID_MESSAGEVIEW_MODE */, ATTR_DEFAULT
, &enum_getCppuType
},
191 { "FTPAccount", -1 /* WID_FTP_ACCOUNT */, ATTR_DEFAULT
, &OUString_getCppuType
},
192 { "Flags", -1 /* WID_FSYS_FLAGS */, ATTR_DEFAULT
, &sal_uInt32_getCppuType
},
193 { "FolderCount", -1 /* WID_FOLDER_COUNT */, ATTR_DEFAULT
| PropertyAttribute::READONLY
,
194 &sal_uInt32_getCppuType
},
195 { "FolderViewMode", -1 /* WID_FOLDERVIEW_MODE */, ATTR_DEFAULT
, &enum_getCppuType
},
196 { "FreeSpace", -1 /* WID_FSYS_DISKSPACE_LEFT */, ATTR_DEFAULT
| PropertyAttribute::READONLY
,
197 &sal_uInt64_getCppuType
},
198 { "HasDocuments", -1 /* WID_FLAG_HAS_MESSAGES */, ATTR_DEFAULT
| PropertyAttribute::READONLY
,
199 &sal_Bool_getCppuType
},
200 { "HasFolders", -1 /* WID_FLAG_HAS_FOLDER */, ATTR_DEFAULT
| PropertyAttribute::READONLY
,
201 &sal_Bool_getCppuType
},
202 { "IsAutoDelete", -1 /* WID_TRASHCAN_FLAG_AUTODELETE */,
203 ATTR_DEFAULT
, &sal_Bool_getCppuType
},
204 { "IsAutoUpdate", -1 /* WID_UPDATE_ENABLED */, ATTR_DEFAULT
, &sal_Bool_getCppuType
},
205 { "IsDocument", -1 /* WID_FLAG_IS_MESSAGE */, ATTR_DEFAULT
| PropertyAttribute::READONLY
,
206 &sal_Bool_getCppuType
},
207 { "IsFolder", -1 /* WID_FLAG_IS_FOLDER */, ATTR_DEFAULT
| PropertyAttribute::READONLY
,
208 &sal_Bool_getCppuType
},
209 { "IsKeepExpired", -1 /* WID_HTTP_KEEP_EXPIRED */, ATTR_DEFAULT
, &sal_Bool_getCppuType
},
210 { "IsLimitedContentCount",
211 -1 /* WID_SHOW_MSGS_HAS_TIMELIMIT */,
212 ATTR_DEFAULT
, &sal_Bool_getCppuType
},
213 { "IsMarked", -1 /* WID_IS_MARKED */, ATTR_DEFAULT
, &sal_Bool_getCppuType
},
214 { "IsRead", -1 /* WID_IS_READ */, ATTR_DEFAULT
, &sal_Bool_getCppuType
},
215 { "IsReadOnly", -1 /* WID_FLAG_READONLY */, ATTR_DEFAULT
, &sal_Bool_getCppuType
},
216 { "IsSubscribed", -1 /* WID_FLAG_SUBSCRIBED */, ATTR_DEFAULT
, &sal_Bool_getCppuType
},
217 // { "IsThreaded", -1 /* WID_THREADED */, ATTR_DEFAULT, &sal_Bool_getCppuType },
218 { "IsTimeLimitedStore", -1 /* WID_STORE_MSGS_HAS_TIMELIMIT */,
219 ATTR_DEFAULT
, &sal_Bool_getCppuType
},
220 { "Keywords", -1 /* WID_KEYWORDS */, ATTR_DEFAULT
, &OUString_getCppuType
},
221 { "LocalBase", -1 /* WID_LOCALBASE */, ATTR_DEFAULT
, &OUString_getCppuType
},
222 { "MessageBCC", -1 /* WID_BCC */, ATTR_DEFAULT
, &OUString_getCppuType
},
223 { "MessageBody", -1 /* WID_MESSAGEBODY */, ATTR_DEFAULT
, &XDataContainer_getCppuType
},
224 { "MessageCC", -1 /* WID_CC */, ATTR_DEFAULT
, &OUString_getCppuType
},
225 { "MessageFrom", -1 /* WID_FROM */, ATTR_DEFAULT
, &OUString_getCppuType
},
226 { "MessageId", -1 /* WID_MESSAGE_ID */, ATTR_DEFAULT
, &OUString_getCppuType
},
227 { "MessageInReplyTo", -1 /* WID_IN_REPLY_TO */, ATTR_DEFAULT
, &OUString_getCppuType
},
228 { "MessageReplyTo", -1 /* WID_REPLY_TO */, ATTR_DEFAULT
, &OUString_getCppuType
},
229 { "MessageTo", -1 /* WID_TO */, ATTR_DEFAULT
, &OUString_getCppuType
},
230 { "NewsGroups", -1 /* WID_NEWSGROUPS */, ATTR_DEFAULT
, &OUString_getCppuType
},
231 { "NoCacheList", -1 /* WID_HTTP_NOCACHE_LIST */, ATTR_DEFAULT
, &OUString_getCppuType
},
232 { "Origin", -1 /* WID_TRASH_ORIGIN */, ATTR_DEFAULT
| PropertyAttribute::READONLY
,
233 &OUString_getCppuType
},
234 { "OutgoingMessageRecipients",
235 -1 /* WID_RECIPIENTLIST */, ATTR_DEFAULT
, &Sequence_RecipientInfo_getCppuType
},
236 { "OutgoingMessageState",
237 -1 /* WID_OUTMSGINTERNALSTATE */, ATTR_DEFAULT
| PropertyAttribute::READONLY
,
239 { "OutgoingMessageViewMode",
240 -1 /* WID_SENTMESSAGEVIEW_MODE */,
241 ATTR_DEFAULT
, &enum_getCppuType
},
242 // { "OwnURL", -1 /* WID_OWN_URL */, ATTR_DEFAULT, &OUString_getCppuType },
243 { "Password", -1 /* WID_PASSWORD */, ATTR_DEFAULT
, &OUString_getCppuType
},
244 // { "PresentationURL", -1 /* WID_REAL_URL */, ATTR_DEFAULT | PropertyAttribute::READONLY,
245 // &OUString_getCppuType },
246 { "Priority", -1 /* WID_PRIORITY */, ATTR_DEFAULT
, &enum_getCppuType
},
247 { "References", -1 /* WID_REFERENCES */, ATTR_DEFAULT
, &OUString_getCppuType
},
248 { "Referer", -1 /* WID_HTTP_REFERER */, ATTR_DEFAULT
, &OUString_getCppuType
},
249 { "Rules", -1 /* WID_RULES */, ATTR_DEFAULT
, &RuleSet_getCppuType
},
250 { "SearchCriteria", -1 /* WID_SEARCH_CRITERIA */, ATTR_DEFAULT
, &RuleSet_getCppuType
},
251 { "SearchIndirections", -1 /* WID_SEARCH_INDIRECTIONS */, ATTR_DEFAULT
, &sal_Bool_getCppuType
},
252 { "SearchLocations", -1 /* WID_SEARCH_LOCATIONS */, ATTR_DEFAULT
, &OUString_getCppuType
},
253 { "SearchRecursive", -1 /* WID_SEARCH_RECURSIVE */, ATTR_DEFAULT
, &sal_Bool_getCppuType
},
254 { "SeenCount", -1 /* WID_SEENCONTENTCOUNT */, ATTR_DEFAULT
| PropertyAttribute::READONLY
,
255 &sal_uInt32_getCppuType
},
256 { "SendCopyTarget", -1 /* WID_SEND_COPY_TARGET */, ATTR_DEFAULT
, &Sequence_SendInfo_getCppuType
},
257 { "SendFormats", -1 /* WID_SEND_FORMATS */, ATTR_DEFAULT
, &Sequence_SendMediaTypes_getCppuType
},
258 { "SendFroms", -1 /* WID_SEND_FROM_DEFAULT */, ATTR_DEFAULT
, &Sequence_SendInfo_getCppuType
},
259 { "SendPasswords", -1 /* WID_SEND_PASSWORD */, ATTR_DEFAULT
, &Sequence_SendInfo_getCppuType
},
260 { "SendProtocolPrivate",-1 /* WID_SEND_PRIVATE_PROT_ID */, ATTR_DEFAULT
, &sal_uInt16_getCppuType
},
261 { "SendProtocolPublic", -1 /* WID_SEND_PUBLIC_PROT_ID */, ATTR_DEFAULT
, &sal_uInt16_getCppuType
},
262 { "SendReplyTos", -1 /* WID_SEND_REPLY_TO_DEFAULT */, ATTR_DEFAULT
, &Sequence_SendInfo_getCppuType
},
263 { "SendServerNames", -1 /* WID_SEND_SERVERNAME */, ATTR_DEFAULT
, &Sequence_SendInfo_getCppuType
},
264 { "SendUserNames", -1 /* WID_SEND_USERNAME */, ATTR_DEFAULT
, &Sequence_SendInfo_getCppuType
},
265 { "SendVIMPostOfficePath",
266 -1 /* WID_SEND_VIM_POPATH */, ATTR_DEFAULT
, &OUString_getCppuType
},
267 { "ServerBase", -1 /* WID_SERVERBASE */, ATTR_DEFAULT
, &OUString_getCppuType
},
268 { "ServerName", -1 /* WID_SERVERNAME */, ATTR_DEFAULT
, &OUString_getCppuType
},
269 { "ServerPort", -1 /* WID_SERVERPORT */, ATTR_DEFAULT
, &sal_uInt16_getCppuType
},
270 { "Size", -1 /* WID_DOCUMENT_SIZE */, ATTR_DEFAULT
| PropertyAttribute::READONLY
,
271 &sal_uInt64_getCppuType
},
272 { "SizeLimit", -1 /* WID_SIZE_LIMIT */, ATTR_DEFAULT
, &sal_uInt64_getCppuType
},
273 { "SubscribedCount", -1 /* WID_SUBSCRNEWSGROUPCOUNT */, ATTR_DEFAULT
| PropertyAttribute::READONLY
,
274 &sal_uInt32_getCppuType
},
275 { "SynchronizePolicy", -1 /* WID_WHO_IS_MASTER */, ATTR_DEFAULT
, &enum_getCppuType
},
276 { "TargetFrames", -1 /* WID_TARGET_FRAMES */, ATTR_DEFAULT
, &OUString_getCppuType
},
277 { "TargetURL", -1 /* WID_TARGET_URL */, ATTR_DEFAULT
, &OUString_getCppuType
},
278 // { "ThreadingInfo", -1 /* WID_THREADING */, ATTR_DEFAULT, &Sequence_ThreadingInfo_getCppuType },
279 { "TimeLimitStore", -1 /* WID_STORE_MSGS_TIMELIMIT */, ATTR_DEFAULT
, &sal_uInt16_getCppuType
},
280 { "Title", -1 /* WID_TITLE */, ATTR_DEFAULT
, &OUString_getCppuType
},
281 { "UpdateOnOpen", -1 /* WID_FLAG_UPDATE_ON_OPEN */, ATTR_DEFAULT
, &sal_Bool_getCppuType
},
282 { "UseOutBoxPrivateProtocolSettings",
283 -1 /* WID_SEND_PRIVATE_OUTBOXPROPS */,
284 ATTR_DEFAULT
, &sal_Bool_getCppuType
},
285 { "UseOutBoxPublicProtocolSettings",
286 -1 /* WID_SEND_PUBLIC_OUTBOXPROPS */,
287 ATTR_DEFAULT
, &sal_Bool_getCppuType
},
288 { "UserName", -1 /* WID_USERNAME */, ATTR_DEFAULT
, &OUString_getCppuType
},
289 { "UserSortCriterium", -1 /* WID_USER_SORT_CRITERIUM */, ATTR_DEFAULT
, &OUString_getCppuType
},
290 { "VIMPostOfficePath", -1 /* WID_VIM_POPATH */, ATTR_DEFAULT
, &OUString_getCppuType
},
291 { "VerificationMode", -1 /* WID_HTTP_VERIFY_MODE */, ATTR_DEFAULT
, &enum_getCppuType
},
293 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
295 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
300 //=========================================================================
301 //=========================================================================
303 // UcbPropertiesManager Implementation.
305 //=========================================================================
306 //=========================================================================
308 UcbPropertiesManager::UcbPropertiesManager(
309 const Reference
< XMultiServiceFactory
>& )
314 //=========================================================================
316 UcbPropertiesManager::~UcbPropertiesManager()
321 //=========================================================================
323 // XInterface methods.
325 //=========================================================================
327 XINTERFACE_IMPL_3( UcbPropertiesManager
,
332 //=========================================================================
334 // XTypeProvider methods.
336 //=========================================================================
338 XTYPEPROVIDER_IMPL_3( UcbPropertiesManager
,
343 //=========================================================================
345 // XServiceInfo methods.
347 //=========================================================================
349 XSERVICEINFO_IMPL_1( UcbPropertiesManager
,
350 OUString( "com.sun.star.comp.ucb.UcbPropertiesManager" ),
351 OUString( PROPERTIES_MANAGER_SERVICE_NAME
) );
353 //=========================================================================
355 // Service factory implementation.
357 //=========================================================================
359 ONE_INSTANCE_SERVICE_FACTORY_IMPL( UcbPropertiesManager
);
361 //=========================================================================
363 // XPropertySetInfo methods.
365 //=========================================================================
368 Sequence
< Property
> SAL_CALL
UcbPropertiesManager::getProperties()
369 throw( RuntimeException
)
371 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
375 m_pProps
= new Sequence
< Property
>( 128 );
376 Property
* pProps
= m_pProps
->getArray();
378 sal_Int32 nSize
= m_pProps
->getLength();
380 //////////////////////////////////////////////////////////////////
381 // Get info for well-known properties.
382 //////////////////////////////////////////////////////////////////
384 const PropertyTableEntry
* pCurr
= &__aPropertyTable
[ 0 ];
385 while ( pCurr
->pName
)
389 OSL_FAIL( "UcbPropertiesManager::getProperties - "
390 "Initial size of property sequence too small!" );
392 m_pProps
->realloc( 128 );
396 Property
& rProp
= pProps
[ nPos
];
398 rProp
.Name
= OUString::createFromAscii( pCurr
->pName
);
399 rProp
.Handle
= pCurr
->nHandle
;
400 rProp
.Type
= pCurr
->pGetCppuType();
401 rProp
.Attributes
= pCurr
->nAttributes
;
409 m_pProps
->realloc( nPos
);
410 nSize
= m_pProps
->getLength();
416 //=========================================================================
418 Property SAL_CALL
UcbPropertiesManager::getPropertyByName( const OUString
& aName
)
419 throw( UnknownPropertyException
, RuntimeException
)
422 if ( queryProperty( aName
, aProp
) )
425 throw UnknownPropertyException();
428 //=========================================================================
430 sal_Bool SAL_CALL
UcbPropertiesManager::hasPropertyByName( const OUString
& Name
)
431 throw( RuntimeException
)
434 return queryProperty( Name
, aProp
);
437 //=========================================================================
439 // Non-Interface methods.
441 //=========================================================================
443 sal_Bool
UcbPropertiesManager::queryProperty(
444 const OUString
& rName
, Property
& rProp
)
446 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
450 const Property
* pProps
= m_pProps
->getConstArray();
451 sal_Int32 nCount
= m_pProps
->getLength();
452 for ( sal_Int32 n
= 0; n
< nCount
; ++n
)
454 const Property
& rCurrProp
= pProps
[ n
];
455 if ( rCurrProp
.Name
== rName
)
465 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */