1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include <osl/diagnose.h>
30 #include <com/sun/star/uno/Type.hxx>
31 #include <com/sun/star/uno/Sequence.hxx>
32 #include <com/sun/star/uno/Reference.hxx>
33 #include <com/sun/star/beans/PropertyAttribute.hpp>
34 #include <com/sun/star/ucb/CrossReference.hpp>
35 #include <com/sun/star/util/DateTime.hpp>
36 #include <com/sun/star/ucb/DocumentHeaderField.hpp>
37 #include <com/sun/star/ucb/RecipientInfo.hpp>
38 #include <com/sun/star/ucb/RuleSet.hpp>
39 #include <com/sun/star/ucb/SendInfo.hpp>
40 #include <com/sun/star/ucb/SendMediaTypes.hpp>
41 #include <com/sun/star/ucb/XDataContainer.hpp>
42 #include "ucbprops.hxx"
44 using namespace com::sun::star::beans
;
45 using namespace com::sun::star::lang
;
46 using namespace com::sun::star::ucb
;
47 using namespace com::sun::star::uno
;
48 using namespace com::sun::star::util
;
50 using ::rtl::OUString
;
52 //=========================================================================
54 // struct PropertyTableEntry
56 //=========================================================================
58 struct PropertyTableEntry
62 sal_Int16 nAttributes
;
63 const com::sun::star::uno::Type
& (*pGetCppuType
)();
66 //////////////////////////////////////////////////////////////////////////
68 // CPPU type access functions.
70 //////////////////////////////////////////////////////////////////////////
72 static const com::sun::star::uno::Type
& OUString_getCppuType()
74 return getCppuType( static_cast< const rtl::OUString
* >( 0 ) );
77 static const com::sun::star::uno::Type
& sal_uInt16_getCppuType()
79 // ! uInt -> Int, because of Java !!!
80 return getCppuType( static_cast< const sal_Int16
* >( 0 ) );
83 static const com::sun::star::uno::Type
& sal_uInt32_getCppuType()
85 // ! uInt -> Int, because of Java !!!
86 return getCppuType( static_cast< const sal_Int32
* >( 0 ) );
89 static const com::sun::star::uno::Type
& sal_uInt64_getCppuType()
91 // ! uInt -> Int, because of Java !!!
92 return getCppuType( static_cast< const sal_Int64
* >( 0 ) );
95 static const com::sun::star::uno::Type
& enum_getCppuType()
97 // ! enum -> Int, because of Java !!!
98 return getCppuType( static_cast< const sal_Int16
* >( 0 ) );
101 static const com::sun::star::uno::Type
& sal_Bool_getCppuType()
103 return getCppuBooleanType();
106 static const com::sun::star::uno::Type
& byte_getCppuType()
108 return getCppuType( static_cast< const sal_Int8
* >( 0 ) );
111 static const com::sun::star::uno::Type
& Sequence_CrossReference_getCppuType()
114 static_cast< com::sun::star::uno::Sequence
<
115 com::sun::star::ucb::CrossReference
> * >( 0 ) );
118 static const com::sun::star::uno::Type
& DateTime_getCppuType()
121 static_cast< com::sun::star::util::DateTime
* >( 0 ) );
124 static const com::sun::star::uno::Type
& Sequence_byte_getCppuType()
127 static_cast< com::sun::star::uno::Sequence
< sal_Int8
> * >( 0 ) );
130 static const com::sun::star::uno::Type
& Sequence_DocumentHeaderField_getCppuType()
133 static_cast< com::sun::star::uno::Sequence
<
134 com::sun::star::ucb::DocumentHeaderField
> * >( 0 ) );
137 static const com::sun::star::uno::Type
& XDataContainer_getCppuType()
140 static_cast< com::sun::star::uno::Reference
<
141 com::sun::star::ucb::XDataContainer
> * >( 0 ) );
144 static const com::sun::star::uno::Type
& Sequence_RecipientInfo_getCppuType()
147 static_cast< com::sun::star::uno::Sequence
<
148 com::sun::star::ucb::RecipientInfo
> * >( 0 ) );
151 static const com::sun::star::uno::Type
& RuleSet_getCppuType()
154 static_cast< com::sun::star::ucb::RuleSet
* >( 0 ) );
157 static const com::sun::star::uno::Type
& Sequence_SendInfo_getCppuType()
160 static_cast< com::sun::star::uno::Sequence
<
161 com::sun::star::ucb::SendInfo
> * >( 0 ) );
164 static const com::sun::star::uno::Type
& Sequence_SendMediaTypes_getCppuType()
167 static_cast< com::sun::star::uno::Sequence
<
168 com::sun::star::ucb::SendMediaTypes
> * >( 0 ) );
171 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
172 // A table with all well-known UCB properties.
173 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
175 #define ATTR_DEFAULT ( PropertyAttribute::BOUND | PropertyAttribute::MAYBEVOID | PropertyAttribute::MAYBEDEFAULT )
177 static PropertyTableEntry __aPropertyTable
[] =
179 { "Account", -1 /* WID_ACCOUNT */, ATTR_DEFAULT
, &OUString_getCppuType
},
180 { "AutoUpdateInterval", -1 /* WID_AUTOUPDATE_INTERVAL */, ATTR_DEFAULT
, &sal_uInt32_getCppuType
},
181 { "ConfirmEmpty", -1 /* WID_TRASHCAN_FLAG_CONFIRMEMPTY */,
182 ATTR_DEFAULT
, &sal_Bool_getCppuType
},
183 { "ConnectionLimit", -1 /* WID_HTTP_CONNECTION_LIMIT */, ATTR_DEFAULT
, &byte_getCppuType
},
184 { "ConnectionMode", -1 /* WID_CONNECTION_MODE */, ATTR_DEFAULT
, &enum_getCppuType
},
185 { "ContentCountLimit", -1 /* WID_SHOW_MSGS_TIMELIMIT */, ATTR_DEFAULT
, &sal_uInt16_getCppuType
},
186 { "ContentType", -1 /* WID_CONTENT_TYPE */, ATTR_DEFAULT
, &OUString_getCppuType
},
187 { "Cookie", -1 /* WID_HTTP_COOKIE */, ATTR_DEFAULT
, &OUString_getCppuType
},
188 { "CrossReferences", -1 /* WID_NEWS_XREFLIST */, ATTR_DEFAULT
, &Sequence_CrossReference_getCppuType
},
189 { "DateCreated", -1 /* WID_DATE_CREATED */, ATTR_DEFAULT
, &DateTime_getCppuType
},
190 { "DateModified", -1 /* WID_DATE_MODIFIED */, ATTR_DEFAULT
, &DateTime_getCppuType
},
191 { "DeleteOnServer", -1 /* WID_DELETE_ON_SERVER */, ATTR_DEFAULT
, &sal_Bool_getCppuType
},
192 { "DocumentBody", -1 /* WID_DOCUMENT_BODY */, ATTR_DEFAULT
, &Sequence_byte_getCppuType
},
193 { "DocumentCount", -1 /* WID_TOTALCONTENTCOUNT */, ATTR_DEFAULT
| PropertyAttribute::READONLY
,
194 &sal_uInt32_getCppuType
},
195 { "DocumentCountMarked",
196 -1 /* WID_MARKED_DOCUMENT_COUNT */, ATTR_DEFAULT
| PropertyAttribute::READONLY
,
197 &sal_uInt32_getCppuType
},
198 { "DocumentHeader", -1 /* WID_DOCUMENT_HEADER */, ATTR_DEFAULT
, &Sequence_DocumentHeaderField_getCppuType
},
199 { "DocumentStoreMode", -1 /* WID_MESSAGE_STOREMODE */, ATTR_DEFAULT
, &enum_getCppuType
},
200 { "DocumentViewMode", -1 /* WID_MESSAGEVIEW_MODE */, ATTR_DEFAULT
, &enum_getCppuType
},
201 { "FTPAccount", -1 /* WID_FTP_ACCOUNT */, ATTR_DEFAULT
, &OUString_getCppuType
},
202 { "Flags", -1 /* WID_FSYS_FLAGS */, ATTR_DEFAULT
, &sal_uInt32_getCppuType
},
203 { "FolderCount", -1 /* WID_FOLDER_COUNT */, ATTR_DEFAULT
| PropertyAttribute::READONLY
,
204 &sal_uInt32_getCppuType
},
205 { "FolderViewMode", -1 /* WID_FOLDERVIEW_MODE */, ATTR_DEFAULT
, &enum_getCppuType
},
206 { "FreeSpace", -1 /* WID_FSYS_DISKSPACE_LEFT */, ATTR_DEFAULT
| PropertyAttribute::READONLY
,
207 &sal_uInt64_getCppuType
},
208 { "HasDocuments", -1 /* WID_FLAG_HAS_MESSAGES */, ATTR_DEFAULT
| PropertyAttribute::READONLY
,
209 &sal_Bool_getCppuType
},
210 { "HasFolders", -1 /* WID_FLAG_HAS_FOLDER */, ATTR_DEFAULT
| PropertyAttribute::READONLY
,
211 &sal_Bool_getCppuType
},
212 { "IsAutoDelete", -1 /* WID_TRASHCAN_FLAG_AUTODELETE */,
213 ATTR_DEFAULT
, &sal_Bool_getCppuType
},
214 { "IsAutoUpdate", -1 /* WID_UPDATE_ENABLED */, ATTR_DEFAULT
, &sal_Bool_getCppuType
},
215 { "IsDocument", -1 /* WID_FLAG_IS_MESSAGE */, ATTR_DEFAULT
| PropertyAttribute::READONLY
,
216 &sal_Bool_getCppuType
},
217 { "IsFolder", -1 /* WID_FLAG_IS_FOLDER */, ATTR_DEFAULT
| PropertyAttribute::READONLY
,
218 &sal_Bool_getCppuType
},
219 { "IsKeepExpired", -1 /* WID_HTTP_KEEP_EXPIRED */, ATTR_DEFAULT
, &sal_Bool_getCppuType
},
220 { "IsLimitedContentCount",
221 -1 /* WID_SHOW_MSGS_HAS_TIMELIMIT */,
222 ATTR_DEFAULT
, &sal_Bool_getCppuType
},
223 { "IsMarked", -1 /* WID_IS_MARKED */, ATTR_DEFAULT
, &sal_Bool_getCppuType
},
224 { "IsRead", -1 /* WID_IS_READ */, ATTR_DEFAULT
, &sal_Bool_getCppuType
},
225 { "IsReadOnly", -1 /* WID_FLAG_READONLY */, ATTR_DEFAULT
, &sal_Bool_getCppuType
},
226 { "IsSubscribed", -1 /* WID_FLAG_SUBSCRIBED */, ATTR_DEFAULT
, &sal_Bool_getCppuType
},
227 // { "IsThreaded", -1 /* WID_THREADED */, ATTR_DEFAULT, &sal_Bool_getCppuType },
228 { "IsTimeLimitedStore", -1 /* WID_STORE_MSGS_HAS_TIMELIMIT */,
229 ATTR_DEFAULT
, &sal_Bool_getCppuType
},
230 { "Keywords", -1 /* WID_KEYWORDS */, ATTR_DEFAULT
, &OUString_getCppuType
},
231 { "LocalBase", -1 /* WID_LOCALBASE */, ATTR_DEFAULT
, &OUString_getCppuType
},
232 { "MessageBCC", -1 /* WID_BCC */, ATTR_DEFAULT
, &OUString_getCppuType
},
233 { "MessageBody", -1 /* WID_MESSAGEBODY */, ATTR_DEFAULT
, &XDataContainer_getCppuType
},
234 { "MessageCC", -1 /* WID_CC */, ATTR_DEFAULT
, &OUString_getCppuType
},
235 { "MessageFrom", -1 /* WID_FROM */, ATTR_DEFAULT
, &OUString_getCppuType
},
236 { "MessageId", -1 /* WID_MESSAGE_ID */, ATTR_DEFAULT
, &OUString_getCppuType
},
237 { "MessageInReplyTo", -1 /* WID_IN_REPLY_TO */, ATTR_DEFAULT
, &OUString_getCppuType
},
238 { "MessageReplyTo", -1 /* WID_REPLY_TO */, ATTR_DEFAULT
, &OUString_getCppuType
},
239 { "MessageTo", -1 /* WID_TO */, ATTR_DEFAULT
, &OUString_getCppuType
},
240 { "NewsGroups", -1 /* WID_NEWSGROUPS */, ATTR_DEFAULT
, &OUString_getCppuType
},
241 { "NoCacheList", -1 /* WID_HTTP_NOCACHE_LIST */, ATTR_DEFAULT
, &OUString_getCppuType
},
242 { "Origin", -1 /* WID_TRASH_ORIGIN */, ATTR_DEFAULT
| PropertyAttribute::READONLY
,
243 &OUString_getCppuType
},
244 { "OutgoingMessageRecipients",
245 -1 /* WID_RECIPIENTLIST */, ATTR_DEFAULT
, &Sequence_RecipientInfo_getCppuType
},
246 { "OutgoingMessageState",
247 -1 /* WID_OUTMSGINTERNALSTATE */, ATTR_DEFAULT
| PropertyAttribute::READONLY
,
249 { "OutgoingMessageViewMode",
250 -1 /* WID_SENTMESSAGEVIEW_MODE */,
251 ATTR_DEFAULT
, &enum_getCppuType
},
252 // { "OwnURL", -1 /* WID_OWN_URL */, ATTR_DEFAULT, &OUString_getCppuType },
253 { "Password", -1 /* WID_PASSWORD */, ATTR_DEFAULT
, &OUString_getCppuType
},
254 // { "PresentationURL", -1 /* WID_REAL_URL */, ATTR_DEFAULT | PropertyAttribute::READONLY,
255 // &OUString_getCppuType },
256 { "Priority", -1 /* WID_PRIORITY */, ATTR_DEFAULT
, &enum_getCppuType
},
257 { "References", -1 /* WID_REFERENCES */, ATTR_DEFAULT
, &OUString_getCppuType
},
258 { "Referer", -1 /* WID_HTTP_REFERER */, ATTR_DEFAULT
, &OUString_getCppuType
},
259 { "Rules", -1 /* WID_RULES */, ATTR_DEFAULT
, &RuleSet_getCppuType
},
260 { "SearchCriteria", -1 /* WID_SEARCH_CRITERIA */, ATTR_DEFAULT
, &RuleSet_getCppuType
},
261 { "SearchIndirections", -1 /* WID_SEARCH_INDIRECTIONS */, ATTR_DEFAULT
, &sal_Bool_getCppuType
},
262 { "SearchLocations", -1 /* WID_SEARCH_LOCATIONS */, ATTR_DEFAULT
, &OUString_getCppuType
},
263 { "SearchRecursive", -1 /* WID_SEARCH_RECURSIVE */, ATTR_DEFAULT
, &sal_Bool_getCppuType
},
264 { "SeenCount", -1 /* WID_SEENCONTENTCOUNT */, ATTR_DEFAULT
| PropertyAttribute::READONLY
,
265 &sal_uInt32_getCppuType
},
266 { "SendCopyTarget", -1 /* WID_SEND_COPY_TARGET */, ATTR_DEFAULT
, &Sequence_SendInfo_getCppuType
},
267 { "SendFormats", -1 /* WID_SEND_FORMATS */, ATTR_DEFAULT
, &Sequence_SendMediaTypes_getCppuType
},
268 { "SendFroms", -1 /* WID_SEND_FROM_DEFAULT */, ATTR_DEFAULT
, &Sequence_SendInfo_getCppuType
},
269 { "SendPasswords", -1 /* WID_SEND_PASSWORD */, ATTR_DEFAULT
, &Sequence_SendInfo_getCppuType
},
270 { "SendProtocolPrivate",-1 /* WID_SEND_PRIVATE_PROT_ID */, ATTR_DEFAULT
, &sal_uInt16_getCppuType
},
271 { "SendProtocolPublic", -1 /* WID_SEND_PUBLIC_PROT_ID */, ATTR_DEFAULT
, &sal_uInt16_getCppuType
},
272 { "SendReplyTos", -1 /* WID_SEND_REPLY_TO_DEFAULT */, ATTR_DEFAULT
, &Sequence_SendInfo_getCppuType
},
273 { "SendServerNames", -1 /* WID_SEND_SERVERNAME */, ATTR_DEFAULT
, &Sequence_SendInfo_getCppuType
},
274 { "SendUserNames", -1 /* WID_SEND_USERNAME */, ATTR_DEFAULT
, &Sequence_SendInfo_getCppuType
},
275 { "SendVIMPostOfficePath",
276 -1 /* WID_SEND_VIM_POPATH */, ATTR_DEFAULT
, &OUString_getCppuType
},
277 { "ServerBase", -1 /* WID_SERVERBASE */, ATTR_DEFAULT
, &OUString_getCppuType
},
278 { "ServerName", -1 /* WID_SERVERNAME */, ATTR_DEFAULT
, &OUString_getCppuType
},
279 { "ServerPort", -1 /* WID_SERVERPORT */, ATTR_DEFAULT
, &sal_uInt16_getCppuType
},
280 { "Size", -1 /* WID_DOCUMENT_SIZE */, ATTR_DEFAULT
| PropertyAttribute::READONLY
,
281 &sal_uInt64_getCppuType
},
282 { "SizeLimit", -1 /* WID_SIZE_LIMIT */, ATTR_DEFAULT
, &sal_uInt64_getCppuType
},
283 { "SubscribedCount", -1 /* WID_SUBSCRNEWSGROUPCOUNT */, ATTR_DEFAULT
| PropertyAttribute::READONLY
,
284 &sal_uInt32_getCppuType
},
285 { "SynchronizePolicy", -1 /* WID_WHO_IS_MASTER */, ATTR_DEFAULT
, &enum_getCppuType
},
286 { "TargetFrames", -1 /* WID_TARGET_FRAMES */, ATTR_DEFAULT
, &OUString_getCppuType
},
287 { "TargetURL", -1 /* WID_TARGET_URL */, ATTR_DEFAULT
, &OUString_getCppuType
},
288 // { "ThreadingInfo", -1 /* WID_THREADING */, ATTR_DEFAULT, &Sequence_ThreadingInfo_getCppuType },
289 { "TimeLimitStore", -1 /* WID_STORE_MSGS_TIMELIMIT */, ATTR_DEFAULT
, &sal_uInt16_getCppuType
},
290 { "Title", -1 /* WID_TITLE */, ATTR_DEFAULT
, &OUString_getCppuType
},
291 { "UpdateOnOpen", -1 /* WID_FLAG_UPDATE_ON_OPEN */, ATTR_DEFAULT
, &sal_Bool_getCppuType
},
292 { "UseOutBoxPrivateProtocolSettings",
293 -1 /* WID_SEND_PRIVATE_OUTBOXPROPS */,
294 ATTR_DEFAULT
, &sal_Bool_getCppuType
},
295 { "UseOutBoxPublicProtocolSettings",
296 -1 /* WID_SEND_PUBLIC_OUTBOXPROPS */,
297 ATTR_DEFAULT
, &sal_Bool_getCppuType
},
298 { "UserName", -1 /* WID_USERNAME */, ATTR_DEFAULT
, &OUString_getCppuType
},
299 { "UserSortCriterium", -1 /* WID_USER_SORT_CRITERIUM */, ATTR_DEFAULT
, &OUString_getCppuType
},
300 { "VIMPostOfficePath", -1 /* WID_VIM_POPATH */, ATTR_DEFAULT
, &OUString_getCppuType
},
301 { "VerificationMode", -1 /* WID_HTTP_VERIFY_MODE */, ATTR_DEFAULT
, &enum_getCppuType
},
303 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
305 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
310 //=========================================================================
311 //=========================================================================
313 // UcbPropertiesManager Implementation.
315 //=========================================================================
316 //=========================================================================
318 UcbPropertiesManager::UcbPropertiesManager(
319 const Reference
< XMultiServiceFactory
>& )
324 //=========================================================================
326 UcbPropertiesManager::~UcbPropertiesManager()
331 //=========================================================================
333 // XInterface methods.
335 //=========================================================================
337 XINTERFACE_IMPL_3( UcbPropertiesManager
,
342 //=========================================================================
344 // XTypeProvider methods.
346 //=========================================================================
348 XTYPEPROVIDER_IMPL_3( UcbPropertiesManager
,
353 //=========================================================================
355 // XServiceInfo methods.
357 //=========================================================================
359 XSERVICEINFO_IMPL_1( UcbPropertiesManager
,
360 OUString( "com.sun.star.comp.ucb.UcbPropertiesManager" ),
361 OUString( PROPERTIES_MANAGER_SERVICE_NAME
) );
363 //=========================================================================
365 // Service factory implementation.
367 //=========================================================================
369 ONE_INSTANCE_SERVICE_FACTORY_IMPL( UcbPropertiesManager
);
371 //=========================================================================
373 // XPropertySetInfo methods.
375 //=========================================================================
378 Sequence
< Property
> SAL_CALL
UcbPropertiesManager::getProperties()
379 throw( RuntimeException
)
381 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
385 m_pProps
= new Sequence
< Property
>( 128 );
386 Property
* pProps
= m_pProps
->getArray();
388 sal_Int32 nSize
= m_pProps
->getLength();
390 //////////////////////////////////////////////////////////////////
391 // Get info for well-known properties.
392 //////////////////////////////////////////////////////////////////
394 const PropertyTableEntry
* pCurr
= &__aPropertyTable
[ 0 ];
395 while ( pCurr
->pName
)
399 OSL_FAIL( "UcbPropertiesManager::getProperties - "
400 "Initial size of property sequence too small!" );
402 m_pProps
->realloc( 128 );
406 Property
& rProp
= pProps
[ nPos
];
408 rProp
.Name
= OUString::createFromAscii( pCurr
->pName
);
409 rProp
.Handle
= pCurr
->nHandle
;
410 rProp
.Type
= pCurr
->pGetCppuType();
411 rProp
.Attributes
= pCurr
->nAttributes
;
419 m_pProps
->realloc( nPos
);
420 nSize
= m_pProps
->getLength();
426 //=========================================================================
428 Property SAL_CALL
UcbPropertiesManager::getPropertyByName( const OUString
& aName
)
429 throw( UnknownPropertyException
, RuntimeException
)
432 if ( queryProperty( aName
, aProp
) )
435 throw UnknownPropertyException();
438 //=========================================================================
440 sal_Bool SAL_CALL
UcbPropertiesManager::hasPropertyByName( const OUString
& Name
)
441 throw( RuntimeException
)
444 return queryProperty( Name
, aProp
);
447 //=========================================================================
449 // Non-Interface methods.
451 //=========================================================================
453 sal_Bool
UcbPropertiesManager::queryProperty(
454 const OUString
& rName
, Property
& rProp
)
456 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
460 const Property
* pProps
= m_pProps
->getConstArray();
461 sal_Int32 nCount
= m_pProps
->getLength();
462 for ( sal_Int32 n
= 0; n
< nCount
; ++n
)
464 const Property
& rCurrProp
= pProps
[ n
];
465 if ( rCurrProp
.Name
== rName
)
475 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */