1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ucbprops.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_ucb.hxx"
33 #include <osl/diagnose.h>
34 #include <com/sun/star/uno/Type.hxx>
35 #include <com/sun/star/uno/Sequence.hxx>
36 #include <com/sun/star/uno/Reference.hxx>
37 #include <com/sun/star/beans/PropertyAttribute.hpp>
38 #include <com/sun/star/ucb/CrossReference.hpp>
39 #include <com/sun/star/util/DateTime.hpp>
40 #include <com/sun/star/ucb/DocumentHeaderField.hpp>
41 #include <com/sun/star/ucb/RecipientInfo.hpp>
42 #include <com/sun/star/ucb/RuleSet.hpp>
43 #include <com/sun/star/ucb/SendInfo.hpp>
44 #include <com/sun/star/ucb/SendMediaTypes.hpp>
45 #include <com/sun/star/ucb/XDataContainer.hpp>
46 #include "ucbprops.hxx"
49 using namespace com::sun::star::beans
;
50 using namespace com::sun::star::lang
;
51 using namespace com::sun::star::ucb
;
52 using namespace com::sun::star::uno
;
53 using namespace com::sun::star::util
;
55 //=========================================================================
57 // struct PropertyTableEntry
59 //=========================================================================
61 struct PropertyTableEntry
65 sal_Int16 nAttributes
;
66 const com::sun::star::uno::Type
& (*pGetCppuType
)();
69 //////////////////////////////////////////////////////////////////////////
71 // CPPU type access functions.
73 //////////////////////////////////////////////////////////////////////////
75 static const com::sun::star::uno::Type
& OUString_getCppuType()
77 return getCppuType( static_cast< const rtl::OUString
* >( 0 ) );
80 static const com::sun::star::uno::Type
& sal_uInt16_getCppuType()
82 // ! uInt -> Int, because of Java !!!
83 return getCppuType( static_cast< const sal_Int16
* >( 0 ) );
86 static const com::sun::star::uno::Type
& sal_uInt32_getCppuType()
88 // ! uInt -> Int, because of Java !!!
89 return getCppuType( static_cast< const sal_Int32
* >( 0 ) );
92 static const com::sun::star::uno::Type
& sal_uInt64_getCppuType()
94 // ! uInt -> Int, because of Java !!!
95 return getCppuType( static_cast< const sal_Int64
* >( 0 ) );
98 static const com::sun::star::uno::Type
& enum_getCppuType()
100 // ! enum -> Int, because of Java !!!
101 return getCppuType( static_cast< const sal_Int16
* >( 0 ) );
104 static const com::sun::star::uno::Type
& sal_Bool_getCppuType()
106 return getCppuBooleanType();
109 static const com::sun::star::uno::Type
& byte_getCppuType()
111 return getCppuType( static_cast< const sal_Int8
* >( 0 ) );
114 static const com::sun::star::uno::Type
& Sequence_CrossReference_getCppuType()
117 static_cast< com::sun::star::uno::Sequence
<
118 com::sun::star::ucb::CrossReference
> * >( 0 ) );
121 static const com::sun::star::uno::Type
& DateTime_getCppuType()
124 static_cast< com::sun::star::util::DateTime
* >( 0 ) );
127 static const com::sun::star::uno::Type
& Sequence_byte_getCppuType()
130 static_cast< com::sun::star::uno::Sequence
< sal_Int8
> * >( 0 ) );
133 static const com::sun::star::uno::Type
& Sequence_DocumentHeaderField_getCppuType()
136 static_cast< com::sun::star::uno::Sequence
<
137 com::sun::star::ucb::DocumentHeaderField
> * >( 0 ) );
140 static const com::sun::star::uno::Type
& XDataContainer_getCppuType()
143 static_cast< com::sun::star::uno::Reference
<
144 com::sun::star::ucb::XDataContainer
> * >( 0 ) );
147 static const com::sun::star::uno::Type
& Sequence_RecipientInfo_getCppuType()
150 static_cast< com::sun::star::uno::Sequence
<
151 com::sun::star::ucb::RecipientInfo
> * >( 0 ) );
154 static const com::sun::star::uno::Type
& RuleSet_getCppuType()
157 static_cast< com::sun::star::ucb::RuleSet
* >( 0 ) );
160 static const com::sun::star::uno::Type
& Sequence_SendInfo_getCppuType()
163 static_cast< com::sun::star::uno::Sequence
<
164 com::sun::star::ucb::SendInfo
> * >( 0 ) );
167 static const com::sun::star::uno::Type
& Sequence_SendMediaTypes_getCppuType()
170 static_cast< com::sun::star::uno::Sequence
<
171 com::sun::star::ucb::SendMediaTypes
> * >( 0 ) );
174 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
175 // A table with all well-known UCB properties.
176 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
178 #define ATTR_DEFAULT ( PropertyAttribute::BOUND | PropertyAttribute::MAYBEVOID | PropertyAttribute::MAYBEDEFAULT )
180 static PropertyTableEntry __aPropertyTable
[] =
182 { "Account", -1 /* WID_ACCOUNT */, ATTR_DEFAULT
, &OUString_getCppuType
},
183 { "AutoUpdateInterval", -1 /* WID_AUTOUPDATE_INTERVAL */, ATTR_DEFAULT
, &sal_uInt32_getCppuType
},
184 { "ConfirmEmpty", -1 /* WID_TRASHCAN_FLAG_CONFIRMEMPTY */,
185 ATTR_DEFAULT
, &sal_Bool_getCppuType
},
186 { "ConnectionLimit", -1 /* WID_HTTP_CONNECTION_LIMIT */, ATTR_DEFAULT
, &byte_getCppuType
},
187 { "ConnectionMode", -1 /* WID_CONNECTION_MODE */, ATTR_DEFAULT
, &enum_getCppuType
},
188 { "ContentCountLimit", -1 /* WID_SHOW_MSGS_TIMELIMIT */, ATTR_DEFAULT
, &sal_uInt16_getCppuType
},
189 { "ContentType", -1 /* WID_CONTENT_TYPE */, ATTR_DEFAULT
, &OUString_getCppuType
},
190 { "Cookie", -1 /* WID_HTTP_COOKIE */, ATTR_DEFAULT
, &OUString_getCppuType
},
191 { "CrossReferences", -1 /* WID_NEWS_XREFLIST */, ATTR_DEFAULT
, &Sequence_CrossReference_getCppuType
},
192 { "DateCreated", -1 /* WID_DATE_CREATED */, ATTR_DEFAULT
, &DateTime_getCppuType
},
193 { "DateModified", -1 /* WID_DATE_MODIFIED */, ATTR_DEFAULT
, &DateTime_getCppuType
},
194 { "DeleteOnServer", -1 /* WID_DELETE_ON_SERVER */, ATTR_DEFAULT
, &sal_Bool_getCppuType
},
195 { "DocumentBody", -1 /* WID_DOCUMENT_BODY */, ATTR_DEFAULT
, &Sequence_byte_getCppuType
},
196 { "DocumentCount", -1 /* WID_TOTALCONTENTCOUNT */, ATTR_DEFAULT
| PropertyAttribute::READONLY
,
197 &sal_uInt32_getCppuType
},
198 { "DocumentCountMarked",
199 -1 /* WID_MARKED_DOCUMENT_COUNT */, ATTR_DEFAULT
| PropertyAttribute::READONLY
,
200 &sal_uInt32_getCppuType
},
201 { "DocumentHeader", -1 /* WID_DOCUMENT_HEADER */, ATTR_DEFAULT
, &Sequence_DocumentHeaderField_getCppuType
},
202 { "DocumentStoreMode", -1 /* WID_MESSAGE_STOREMODE */, ATTR_DEFAULT
, &enum_getCppuType
},
203 { "DocumentViewMode", -1 /* WID_MESSAGEVIEW_MODE */, ATTR_DEFAULT
, &enum_getCppuType
},
204 { "FTPAccount", -1 /* WID_FTP_ACCOUNT */, ATTR_DEFAULT
, &OUString_getCppuType
},
205 { "Flags", -1 /* WID_FSYS_FLAGS */, ATTR_DEFAULT
, &sal_uInt32_getCppuType
},
206 { "FolderCount", -1 /* WID_FOLDER_COUNT */, ATTR_DEFAULT
| PropertyAttribute::READONLY
,
207 &sal_uInt32_getCppuType
},
208 { "FolderViewMode", -1 /* WID_FOLDERVIEW_MODE */, ATTR_DEFAULT
, &enum_getCppuType
},
209 { "FreeSpace", -1 /* WID_FSYS_DISKSPACE_LEFT */, ATTR_DEFAULT
| PropertyAttribute::READONLY
,
210 &sal_uInt64_getCppuType
},
211 { "HasDocuments", -1 /* WID_FLAG_HAS_MESSAGES */, ATTR_DEFAULT
| PropertyAttribute::READONLY
,
212 &sal_Bool_getCppuType
},
213 { "HasFolders", -1 /* WID_FLAG_HAS_FOLDER */, ATTR_DEFAULT
| PropertyAttribute::READONLY
,
214 &sal_Bool_getCppuType
},
215 { "IsAutoDelete", -1 /* WID_TRASHCAN_FLAG_AUTODELETE */,
216 ATTR_DEFAULT
, &sal_Bool_getCppuType
},
217 { "IsAutoUpdate", -1 /* WID_UPDATE_ENABLED */, ATTR_DEFAULT
, &sal_Bool_getCppuType
},
218 { "IsDocument", -1 /* WID_FLAG_IS_MESSAGE */, ATTR_DEFAULT
| PropertyAttribute::READONLY
,
219 &sal_Bool_getCppuType
},
220 { "IsFolder", -1 /* WID_FLAG_IS_FOLDER */, ATTR_DEFAULT
| PropertyAttribute::READONLY
,
221 &sal_Bool_getCppuType
},
222 { "IsKeepExpired", -1 /* WID_HTTP_KEEP_EXPIRED */, ATTR_DEFAULT
, &sal_Bool_getCppuType
},
223 { "IsLimitedContentCount",
224 -1 /* WID_SHOW_MSGS_HAS_TIMELIMIT */,
225 ATTR_DEFAULT
, &sal_Bool_getCppuType
},
226 { "IsMarked", -1 /* WID_IS_MARKED */, ATTR_DEFAULT
, &sal_Bool_getCppuType
},
227 { "IsRead", -1 /* WID_IS_READ */, ATTR_DEFAULT
, &sal_Bool_getCppuType
},
228 { "IsReadOnly", -1 /* WID_FLAG_READONLY */, ATTR_DEFAULT
, &sal_Bool_getCppuType
},
229 { "IsSubscribed", -1 /* WID_FLAG_SUBSCRIBED */, ATTR_DEFAULT
, &sal_Bool_getCppuType
},
230 // { "IsThreaded", -1 /* WID_THREADED */, ATTR_DEFAULT, &sal_Bool_getCppuType },
231 { "IsTimeLimitedStore", -1 /* WID_STORE_MSGS_HAS_TIMELIMIT */,
232 ATTR_DEFAULT
, &sal_Bool_getCppuType
},
233 { "Keywords", -1 /* WID_KEYWORDS */, ATTR_DEFAULT
, &OUString_getCppuType
},
234 { "LocalBase", -1 /* WID_LOCALBASE */, ATTR_DEFAULT
, &OUString_getCppuType
},
235 { "MessageBCC", -1 /* WID_BCC */, ATTR_DEFAULT
, &OUString_getCppuType
},
236 { "MessageBody", -1 /* WID_MESSAGEBODY */, ATTR_DEFAULT
, &XDataContainer_getCppuType
},
237 { "MessageCC", -1 /* WID_CC */, ATTR_DEFAULT
, &OUString_getCppuType
},
238 { "MessageFrom", -1 /* WID_FROM */, ATTR_DEFAULT
, &OUString_getCppuType
},
239 { "MessageId", -1 /* WID_MESSAGE_ID */, ATTR_DEFAULT
, &OUString_getCppuType
},
240 { "MessageInReplyTo", -1 /* WID_IN_REPLY_TO */, ATTR_DEFAULT
, &OUString_getCppuType
},
241 { "MessageReplyTo", -1 /* WID_REPLY_TO */, ATTR_DEFAULT
, &OUString_getCppuType
},
242 { "MessageTo", -1 /* WID_TO */, ATTR_DEFAULT
, &OUString_getCppuType
},
243 { "NewsGroups", -1 /* WID_NEWSGROUPS */, ATTR_DEFAULT
, &OUString_getCppuType
},
244 { "NoCacheList", -1 /* WID_HTTP_NOCACHE_LIST */, ATTR_DEFAULT
, &OUString_getCppuType
},
245 { "Origin", -1 /* WID_TRASH_ORIGIN */, ATTR_DEFAULT
| PropertyAttribute::READONLY
,
246 &OUString_getCppuType
},
247 { "OutgoingMessageRecipients",
248 -1 /* WID_RECIPIENTLIST */, ATTR_DEFAULT
, &Sequence_RecipientInfo_getCppuType
},
249 { "OutgoingMessageState",
250 -1 /* WID_OUTMSGINTERNALSTATE */, ATTR_DEFAULT
| PropertyAttribute::READONLY
,
252 { "OutgoingMessageViewMode",
253 -1 /* WID_SENTMESSAGEVIEW_MODE */,
254 ATTR_DEFAULT
, &enum_getCppuType
},
255 // { "OwnURL", -1 /* WID_OWN_URL */, ATTR_DEFAULT, &OUString_getCppuType },
256 { "Password", -1 /* WID_PASSWORD */, ATTR_DEFAULT
, &OUString_getCppuType
},
257 // { "PresentationURL", -1 /* WID_REAL_URL */, ATTR_DEFAULT | PropertyAttribute::READONLY,
258 // &OUString_getCppuType },
259 { "Priority", -1 /* WID_PRIORITY */, ATTR_DEFAULT
, &enum_getCppuType
},
260 { "References", -1 /* WID_REFERENCES */, ATTR_DEFAULT
, &OUString_getCppuType
},
261 { "Referer", -1 /* WID_HTTP_REFERER */, ATTR_DEFAULT
, &OUString_getCppuType
},
262 { "Rules", -1 /* WID_RULES */, ATTR_DEFAULT
, &RuleSet_getCppuType
},
263 { "SearchCriteria", -1 /* WID_SEARCH_CRITERIA */, ATTR_DEFAULT
, &RuleSet_getCppuType
},
264 { "SearchIndirections", -1 /* WID_SEARCH_INDIRECTIONS */, ATTR_DEFAULT
, &sal_Bool_getCppuType
},
265 { "SearchLocations", -1 /* WID_SEARCH_LOCATIONS */, ATTR_DEFAULT
, &OUString_getCppuType
},
266 { "SearchRecursive", -1 /* WID_SEARCH_RECURSIVE */, ATTR_DEFAULT
, &sal_Bool_getCppuType
},
267 { "SeenCount", -1 /* WID_SEENCONTENTCOUNT */, ATTR_DEFAULT
| PropertyAttribute::READONLY
,
268 &sal_uInt32_getCppuType
},
269 { "SendCopyTarget", -1 /* WID_SEND_COPY_TARGET */, ATTR_DEFAULT
, &Sequence_SendInfo_getCppuType
},
270 { "SendFormats", -1 /* WID_SEND_FORMATS */, ATTR_DEFAULT
, &Sequence_SendMediaTypes_getCppuType
},
271 { "SendFroms", -1 /* WID_SEND_FROM_DEFAULT */, ATTR_DEFAULT
, &Sequence_SendInfo_getCppuType
},
272 { "SendPasswords", -1 /* WID_SEND_PASSWORD */, ATTR_DEFAULT
, &Sequence_SendInfo_getCppuType
},
273 { "SendProtocolPrivate",-1 /* WID_SEND_PRIVATE_PROT_ID */, ATTR_DEFAULT
, &sal_uInt16_getCppuType
},
274 { "SendProtocolPublic", -1 /* WID_SEND_PUBLIC_PROT_ID */, ATTR_DEFAULT
, &sal_uInt16_getCppuType
},
275 { "SendReplyTos", -1 /* WID_SEND_REPLY_TO_DEFAULT */, ATTR_DEFAULT
, &Sequence_SendInfo_getCppuType
},
276 { "SendServerNames", -1 /* WID_SEND_SERVERNAME */, ATTR_DEFAULT
, &Sequence_SendInfo_getCppuType
},
277 { "SendUserNames", -1 /* WID_SEND_USERNAME */, ATTR_DEFAULT
, &Sequence_SendInfo_getCppuType
},
278 { "SendVIMPostOfficePath",
279 -1 /* WID_SEND_VIM_POPATH */, ATTR_DEFAULT
, &OUString_getCppuType
},
280 { "ServerBase", -1 /* WID_SERVERBASE */, ATTR_DEFAULT
, &OUString_getCppuType
},
281 { "ServerName", -1 /* WID_SERVERNAME */, ATTR_DEFAULT
, &OUString_getCppuType
},
282 { "ServerPort", -1 /* WID_SERVERPORT */, ATTR_DEFAULT
, &sal_uInt16_getCppuType
},
283 { "Size", -1 /* WID_DOCUMENT_SIZE */, ATTR_DEFAULT
| PropertyAttribute::READONLY
,
284 &sal_uInt64_getCppuType
},
285 { "SizeLimit", -1 /* WID_SIZE_LIMIT */, ATTR_DEFAULT
, &sal_uInt64_getCppuType
},
286 { "SubscribedCount", -1 /* WID_SUBSCRNEWSGROUPCOUNT */, ATTR_DEFAULT
| PropertyAttribute::READONLY
,
287 &sal_uInt32_getCppuType
},
288 { "SynchronizePolicy", -1 /* WID_WHO_IS_MASTER */, ATTR_DEFAULT
, &enum_getCppuType
},
289 { "TargetFrames", -1 /* WID_TARGET_FRAMES */, ATTR_DEFAULT
, &OUString_getCppuType
},
290 { "TargetURL", -1 /* WID_TARGET_URL */, ATTR_DEFAULT
, &OUString_getCppuType
},
291 // { "ThreadingInfo", -1 /* WID_THREADING */, ATTR_DEFAULT, &Sequence_ThreadingInfo_getCppuType },
292 { "TimeLimitStore", -1 /* WID_STORE_MSGS_TIMELIMIT */, ATTR_DEFAULT
, &sal_uInt16_getCppuType
},
293 { "Title", -1 /* WID_TITLE */, ATTR_DEFAULT
, &OUString_getCppuType
},
294 { "UpdateOnOpen", -1 /* WID_FLAG_UPDATE_ON_OPEN */, ATTR_DEFAULT
, &sal_Bool_getCppuType
},
295 { "UseOutBoxPrivateProtocolSettings",
296 -1 /* WID_SEND_PRIVATE_OUTBOXPROPS */,
297 ATTR_DEFAULT
, &sal_Bool_getCppuType
},
298 { "UseOutBoxPublicProtocolSettings",
299 -1 /* WID_SEND_PUBLIC_OUTBOXPROPS */,
300 ATTR_DEFAULT
, &sal_Bool_getCppuType
},
301 { "UserName", -1 /* WID_USERNAME */, ATTR_DEFAULT
, &OUString_getCppuType
},
302 { "UserSortCriterium", -1 /* WID_USER_SORT_CRITERIUM */, ATTR_DEFAULT
, &OUString_getCppuType
},
303 { "VIMPostOfficePath", -1 /* WID_VIM_POPATH */, ATTR_DEFAULT
, &OUString_getCppuType
},
304 { "VerificationMode", -1 /* WID_HTTP_VERIFY_MODE */, ATTR_DEFAULT
, &enum_getCppuType
},
306 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
308 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
313 //=========================================================================
314 //=========================================================================
316 // UcbPropertiesManager Implementation.
318 //=========================================================================
319 //=========================================================================
321 UcbPropertiesManager::UcbPropertiesManager(
322 const Reference
< XMultiServiceFactory
>& )
327 //=========================================================================
329 UcbPropertiesManager::~UcbPropertiesManager()
334 //=========================================================================
336 // XInterface methods.
338 //=========================================================================
340 XINTERFACE_IMPL_3( UcbPropertiesManager
,
345 //=========================================================================
347 // XTypeProvider methods.
349 //=========================================================================
351 XTYPEPROVIDER_IMPL_3( UcbPropertiesManager
,
356 //=========================================================================
358 // XServiceInfo methods.
360 //=========================================================================
362 XSERVICEINFO_IMPL_1( UcbPropertiesManager
,
363 OUString::createFromAscii(
364 "com.sun.star.comp.ucb.UcbPropertiesManager" ),
365 OUString::createFromAscii(
366 PROPERTIES_MANAGER_SERVICE_NAME
) );
368 //=========================================================================
370 // Service factory implementation.
372 //=========================================================================
374 ONE_INSTANCE_SERVICE_FACTORY_IMPL( UcbPropertiesManager
);
376 //=========================================================================
378 // XPropertySetInfo methods.
380 //=========================================================================
383 Sequence
< Property
> SAL_CALL
UcbPropertiesManager::getProperties()
384 throw( RuntimeException
)
386 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
390 m_pProps
= new Sequence
< Property
>( 128 );
391 Property
* pProps
= m_pProps
->getArray();
393 sal_Int32 nSize
= m_pProps
->getLength();
395 //////////////////////////////////////////////////////////////////
396 // Get info for well-known properties.
397 //////////////////////////////////////////////////////////////////
399 const PropertyTableEntry
* pCurr
= &__aPropertyTable
[ 0 ];
400 while ( pCurr
->pName
)
404 OSL_ENSURE( sal_False
,
405 "UcbPropertiesManager::getProperties - "
406 "Initial size of property sequence too small!" );
408 m_pProps
->realloc( 128 );
412 Property
& rProp
= pProps
[ nPos
];
414 rProp
.Name
= OUString::createFromAscii( pCurr
->pName
);
415 rProp
.Handle
= pCurr
->nHandle
;
416 rProp
.Type
= pCurr
->pGetCppuType();
417 rProp
.Attributes
= pCurr
->nAttributes
;
425 m_pProps
->realloc( nPos
);
426 nSize
= m_pProps
->getLength();
432 //=========================================================================
434 Property SAL_CALL
UcbPropertiesManager::getPropertyByName( const OUString
& aName
)
435 throw( UnknownPropertyException
, RuntimeException
)
438 if ( queryProperty( aName
, aProp
) )
441 throw UnknownPropertyException();
444 //=========================================================================
446 sal_Bool SAL_CALL
UcbPropertiesManager::hasPropertyByName( const OUString
& Name
)
447 throw( RuntimeException
)
450 return queryProperty( Name
, aProp
);
453 //=========================================================================
455 // Non-Interface methods.
457 //=========================================================================
459 sal_Bool
UcbPropertiesManager::queryProperty(
460 const OUString
& rName
, Property
& rProp
)
462 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
466 const Property
* pProps
= m_pProps
->getConstArray();
467 sal_Int32 nCount
= m_pProps
->getLength();
468 for ( sal_Int32 n
= 0; n
< nCount
; ++n
)
470 const Property
& rCurrProp
= pProps
[ n
];
471 if ( rCurrProp
.Name
== rName
)