| 1 |
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 2 |
/* |
| 3 |
* This file is part of the LibreOffice project. |
| 4 |
* |
| 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/. |
| 8 |
* |
| 9 |
* This file incorporates work covered by the following license notice: |
| 10 |
* |
| 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 . |
| 18 |
*/ |
| 19 |
|
| 20 |
#include <memory> |
| 21 |
#include <set> |
| 22 |
#include <com/sun/star/beans/Property.hpp> |
| 23 |
#include <com/sun/star/beans/PropertyAttribute.hpp> |
| 24 |
#include <com/sun/star/beans/PropertyValue.hpp> |
| 25 |
#include <com/sun/star/ucb/CommandInfo.hpp> |
| 26 |
#include <com/sun/star/ucb/ContentInfo.hpp> |
| 27 |
#include <com/sun/star/ucb/OpenCommandArgument2.hpp> |
| 28 |
#include <com/sun/star/ucb/InsertCommandArgument.hpp> |
| 29 |
#include <com/sun/star/ucb/PostCommandArgument2.hpp> |
| 30 |
#include <com/sun/star/ucb/PropertyCommandArgument.hpp> |
| 31 |
#include <com/sun/star/ucb/TransferInfo.hpp> |
| 32 |
#include <com/sun/star/uno/Sequence.hxx> |
| 33 |
#include <com/sun/star/util/DateTime.hpp> |
| 34 |
#include <com/sun/star/ucb/Lock.hpp> |
| 35 |
#include <com/sun/star/ucb/LockEntry.hpp> |
| 36 |
#include "webdavcontent.hxx" |
| 37 |
#include "webdavprovider.hxx" |
| 38 |
#include "DAVProperties.hxx" |
| 39 |
#include "ContentProperties.hxx" |
| 40 |
#include "PropfindCache.hxx" |
| 41 |
|
| 42 |
using namespace com::sun::star; |
| 43 |
using namespace http_dav_ucp; |
| 44 |
|
| 45 |
|
| 46 |
// ContentProvider implementation. |
| 47 |
|
| 48 |
|
| 49 |
bool ContentProvider::getProperty( |
| 50 |
const OUString & rPropName, beans::Property & rProp ) |
| 51 |
{ |
| 52 |
if ( !m_pProps ) |
| 53 |
{ |
| 54 |
osl::MutexGuard aGuard( m_aMutex ); |
| 55 |
if ( !m_pProps ) |
| 56 |
{ |
| 57 |
m_pProps = std::make_unique<PropertyMap>(); |
| 58 |
|
| 59 |
|
| 60 |
// Fill map of known properties... |
| 61 |
|
| 62 |
|
| 63 |
// Mandatory UCB properties. |
| 64 |
m_pProps->insert( |
| 65 |
beans::Property( |
| 66 |
u"ContentType"_ustr, |
| 67 |
-1, |
| 68 |
cppu::UnoType<OUString>::get(), |
| 69 |
beans::PropertyAttribute::BOUND |
| 70 |
| beans::PropertyAttribute::READONLY ) ); |
| 71 |
|
| 72 |
m_pProps->insert( |
| 73 |
beans::Property( |
| 74 |
u"IsDocument"_ustr, |
| 75 |
-1, |
| 76 |
cppu::UnoType<bool>::get(), |
| 77 |
beans::PropertyAttribute::BOUND |
| 78 |
| beans::PropertyAttribute::READONLY ) ); |
| 79 |
|
| 80 |
m_pProps->insert( |
| 81 |
beans::Property( |
| 82 |
u"IsFolder"_ustr, |
| 83 |
-1, |
| 84 |
cppu::UnoType<bool>::get(), |
| 85 |
beans::PropertyAttribute::BOUND |
| 86 |
| beans::PropertyAttribute::READONLY ) ); |
| 87 |
|
| 88 |
m_pProps->insert( |
| 89 |
beans::Property( |
| 90 |
u"Title"_ustr, |
| 91 |
-1, |
| 92 |
cppu::UnoType<OUString>::get(), |
| 93 |
beans::PropertyAttribute::BOUND ) ); |
| 94 |
|
| 95 |
// Optional UCB properties. |
| 96 |
|
| 97 |
m_pProps->insert( |
| 98 |
beans::Property( |
| 99 |
u"DateCreated"_ustr, |
| 100 |
-1, |
| 101 |
cppu::UnoType<util::DateTime>::get(), |
| 102 |
beans::PropertyAttribute::BOUND |
| 103 |
| beans::PropertyAttribute::READONLY ) ); |
| 104 |
|
| 105 |
m_pProps->insert( |
| 106 |
beans::Property( |
| 107 |
u"DateModified"_ustr, |
| 108 |
-1, |
| 109 |
cppu::UnoType<util::DateTime>::get(), |
| 110 |
beans::PropertyAttribute::BOUND |
| 111 |
| beans::PropertyAttribute::READONLY ) ); |
| 112 |
|
| 113 |
m_pProps->insert( |
| 114 |
beans::Property( |
| 115 |
u"MediaType"_ustr, |
| 116 |
-1, |
| 117 |
cppu::UnoType<OUString>::get(), |
| 118 |
beans::PropertyAttribute::BOUND |
| 119 |
| beans::PropertyAttribute::READONLY ) ); |
| 120 |
|
| 121 |
m_pProps->insert( |
| 122 |
beans::Property( |
| 123 |
u"Size"_ustr, |
| 124 |
-1, |
| 125 |
cppu::UnoType<sal_Int64>::get(), |
| 126 |
beans::PropertyAttribute::BOUND |
| 127 |
| beans::PropertyAttribute::READONLY ) ); |
| 128 |
|
| 129 |
m_pProps->insert( |
| 130 |
beans::Property( |
| 131 |
u"BaseURI"_ustr, |
| 132 |
-1, |
| 133 |
cppu::UnoType<OUString>::get(), |
| 134 |
beans::PropertyAttribute::BOUND |
| 135 |
| beans::PropertyAttribute::READONLY ) ); |
| 136 |
|
| 137 |
m_pProps->insert( |
| 138 |
beans::Property( |
| 139 |
u"CreatableContentsInfo"_ustr, |
| 140 |
-1, |
| 141 |
cppu::UnoType<uno::Sequence< ucb::ContentInfo >>::get(), |
| 142 |
beans::PropertyAttribute::BOUND |
| 143 |
| beans::PropertyAttribute::READONLY ) ); |
| 144 |
|
| 145 |
// Standard DAV properties. |
| 146 |
|
| 147 |
m_pProps->insert( |
| 148 |
beans::Property( |
| 149 |
DAVProperties::CREATIONDATE, |
| 150 |
-1, |
| 151 |
cppu::UnoType<OUString>::get(), |
| 152 |
beans::PropertyAttribute::BOUND |
| 153 |
| beans::PropertyAttribute::READONLY ) ); |
| 154 |
|
| 155 |
m_pProps->insert( |
| 156 |
beans::Property( |
| 157 |
DAVProperties::DISPLAYNAME, |
| 158 |
-1, |
| 159 |
cppu::UnoType<OUString>::get(), |
| 160 |
beans::PropertyAttribute::BOUND ) ); |
| 161 |
|
| 162 |
m_pProps->insert( |
| 163 |
beans::Property( |
| 164 |
DAVProperties::GETCONTENTLANGUAGE, |
| 165 |
-1, |
| 166 |
cppu::UnoType<OUString>::get(), |
| 167 |
beans::PropertyAttribute::BOUND |
| 168 |
| beans::PropertyAttribute::READONLY ) ); |
| 169 |
|
| 170 |
m_pProps->insert( |
| 171 |
beans::Property( |
| 172 |
DAVProperties::GETCONTENTLENGTH, |
| 173 |
-1, |
| 174 |
cppu::UnoType<OUString>::get(), |
| 175 |
beans::PropertyAttribute::BOUND |
| 176 |
| beans::PropertyAttribute::READONLY ) ); |
| 177 |
|
| 178 |
m_pProps->insert( |
| 179 |
beans::Property( |
| 180 |
DAVProperties::GETCONTENTTYPE , |
| 181 |
-1, |
| 182 |
cppu::UnoType<OUString>::get(), |
| 183 |
beans::PropertyAttribute::BOUND |
| 184 |
| beans::PropertyAttribute::READONLY ) ); |
| 185 |
|
| 186 |
m_pProps->insert( |
| 187 |
beans::Property( |
| 188 |
DAVProperties::GETETAG, |
| 189 |
-1, |
| 190 |
cppu::UnoType<OUString>::get(), |
| 191 |
beans::PropertyAttribute::BOUND |
| 192 |
| beans::PropertyAttribute::READONLY ) ); |
| 193 |
|
| 194 |
m_pProps->insert( |
| 195 |
beans::Property( |
| 196 |
DAVProperties::GETLASTMODIFIED, |
| 197 |
-1, |
| 198 |
cppu::UnoType<OUString>::get(), |
| 199 |
beans::PropertyAttribute::BOUND |
| 200 |
| beans::PropertyAttribute::READONLY ) ); |
| 201 |
|
| 202 |
m_pProps->insert( |
| 203 |
beans::Property( |
| 204 |
DAVProperties::LOCKDISCOVERY, |
| 205 |
-1, |
| 206 |
cppu::UnoType<uno::Sequence< ucb::Lock >>::get(), |
| 207 |
beans::PropertyAttribute::BOUND |
| 208 |
| beans::PropertyAttribute::READONLY ) ); |
| 209 |
|
| 210 |
m_pProps->insert( |
| 211 |
beans::Property( |
| 212 |
DAVProperties::RESOURCETYPE, |
| 213 |
-1, |
| 214 |
cppu::UnoType<OUString>::get(), |
| 215 |
beans::PropertyAttribute::BOUND |
| 216 |
| beans::PropertyAttribute::READONLY ) ); |
| 217 |
|
| 218 |
m_pProps->insert( |
| 219 |
beans::Property( |
| 220 |
DAVProperties::SUPPORTEDLOCK, |
| 221 |
-1, |
| 222 |
cppu::UnoType<uno::Sequence< ucb::LockEntry >>::get(), |
| 223 |
beans::PropertyAttribute::BOUND |
| 224 |
| beans::PropertyAttribute::READONLY ) ); |
| 225 |
|
| 226 |
m_pProps->insert( |
| 227 |
beans::Property( |
| 228 |
DAVProperties::EXECUTABLE, |
| 229 |
-1, |
| 230 |
cppu::UnoType<OUString>::get(), |
| 231 |
beans::PropertyAttribute::BOUND ) ); |
| 232 |
} |
| 233 |
} |
| 234 |
|
| 235 |
|
| 236 |
// Lookup property. |
| 237 |
|
| 238 |
|
| 239 |
beans::Property aProp; |
| 240 |
aProp.Name = rPropName; |
| 241 |
const PropertyMap::const_iterator it = m_pProps->find( aProp ); |
| 242 |
if ( it != m_pProps->end() ) |
| 243 |
{ |
| 244 |
rProp = *it; |
| 245 |
} |
| 246 |
else |
| 247 |
{ |
| 248 |
// All unknown props are treated as: |
| 249 |
rProp = beans::Property( |
| 250 |
rPropName, |
| 251 |
- 1, |
| 252 |
cppu::UnoType<OUString>::get(), |
| 253 |
beans::PropertyAttribute::BOUND ); |
| 254 |
} |
| 255 |
|
| 256 |
return true; |
| 257 |
} |
| 258 |
|
| 259 |
|
| 260 |
static PropertyNamesCache aStaticPropertyNamesCache; |
| 261 |
|
| 262 |
// static |
| 263 |
void Content::removeCachedPropertyNames( const OUString & rURL ) |
| 264 |
{ |
| 265 |
aStaticPropertyNamesCache.removeCachedPropertyNames( rURL ); |
| 266 |
} |
| 267 |
|
| 268 |
// Content implementation. |
| 269 |
|
| 270 |
|
| 271 |
// virtual |
| 272 |
uno::Sequence< beans::Property > Content::getProperties( |
| 273 |
const uno::Reference< ucb::XCommandEnvironment > & xEnv ) |
| 274 |
{ |
| 275 |
bool bTransient; |
| 276 |
std::unique_ptr< DAVResourceAccess > xResAccess; |
| 277 |
std::unique_ptr< ContentProperties > xCachedProps; |
| 278 |
rtl::Reference< ContentProvider > xProvider; |
| 279 |
|
| 280 |
{ |
| 281 |
osl::Guard< osl::Mutex > aGuard( m_aMutex ); |
| 282 |
|
| 283 |
bTransient = m_bTransient; |
| 284 |
xResAccess.reset( new DAVResourceAccess( *m_xResAccess ) ); |
| 285 |
if (m_xCachedProps) |
| 286 |
xCachedProps.reset( |
| 287 |
new ContentProperties( *m_xCachedProps ) ); |
| 288 |
xProvider.set( m_pProvider ); |
| 289 |
} |
| 290 |
|
| 291 |
std::set< OUString > aPropSet; |
| 292 |
|
| 293 |
// No server access for just created (not yet committed) objects. |
| 294 |
// Only a minimal set of properties supported at this stage. |
| 295 |
if ( !bTransient ) |
| 296 |
{ |
| 297 |
// Obtain all properties supported for this resource from server. |
| 298 |
DAVOptions aDAVOptions; |
| 299 |
getResourceOptions( xEnv, aDAVOptions, xResAccess ); |
| 300 |
// only Class 1 is needed for PROPFIND |
| 301 |
if ( aDAVOptions.isClass1() ) |
| 302 |
{ |
| 303 |
try |
| 304 |
{ |
| 305 |
std::vector< DAVResourceInfo > props; |
| 306 |
OUString aTheURL( xResAccess->getURL() ); |
| 307 |
PropertyNames aPropsNames( aTheURL ); |
| 308 |
|
| 309 |
if( !aStaticPropertyNamesCache.getCachedPropertyNames( aTheURL, aPropsNames ) ) |
| 310 |
{ |
| 311 |
|
| 312 |
xResAccess->PROPFIND( DAVZERO, props, xEnv ); |
| 313 |
aPropsNames.setPropertiesNames( props ); |
| 314 |
|
| 315 |
aStaticPropertyNamesCache.addCachePropertyNames( aPropsNames, 10 ); |
| 316 |
} |
| 317 |
else |
| 318 |
{ |
| 319 |
props = aPropsNames.getPropertiesNames(); |
| 320 |
} |
| 321 |
|
| 322 |
// Note: vector should contain exactly one resource info, because |
| 323 |
// we used a depth of DAVZERO for PROPFIND. |
| 324 |
if (props.size() == 1) |
| 325 |
{ |
| 326 |
aPropSet.insert( (*props.begin()).properties.begin(), |
| 327 |
(*props.begin()).properties.end() ); |
| 328 |
} |
| 329 |
} |
| 330 |
catch ( DAVException const & ) |
| 331 |
{ |
| 332 |
} |
| 333 |
} |
| 334 |
} |
| 335 |
|
| 336 |
// Add DAV properties, map DAV properties to UCB properties. |
| 337 |
bool bHasCreationDate = false; // creationdate <-> DateCreated |
| 338 |
bool bHasGetLastModified = false; // getlastmodified <-> DateModified |
| 339 |
bool bHasGetContentType = false; // getcontenttype <-> MediaType |
| 340 |
bool bHasGetContentLength = false; // getcontentlength <-> Size |
| 341 |
|
| 342 |
bool bHasContentType = false; |
| 343 |
bool bHasIsDocument = false; |
| 344 |
bool bHasIsFolder = false; |
| 345 |
bool bHasTitle = false; |
| 346 |
bool bHasBaseURI = false; |
| 347 |
bool bHasDateCreated = false; |
| 348 |
bool bHasDateModified = false; |
| 349 |
bool bHasMediaType = false; |
| 350 |
bool bHasSize = false; |
| 351 |
bool bHasCreatableInfos = false; |
| 352 |
|
| 353 |
{ |
| 354 |
for ( const auto& rProp : aPropSet ) |
| 355 |
{ |
| 356 |
if ( !bHasCreationDate && |
| 357 |
( rProp == DAVProperties::CREATIONDATE ) ) |
| 358 |
{ |
| 359 |
bHasCreationDate = true; |
| 360 |
} |
| 361 |
else if ( !bHasGetLastModified && |
| 362 |
( rProp == DAVProperties::GETLASTMODIFIED ) ) |
| 363 |
{ |
| 364 |
bHasGetLastModified = true; |
| 365 |
} |
| 366 |
else if ( !bHasGetContentType && |
| 367 |
( rProp == DAVProperties::GETCONTENTTYPE ) ) |
| 368 |
{ |
| 369 |
bHasGetContentType = true; |
| 370 |
} |
| 371 |
else if ( !bHasGetContentLength && |
| 372 |
( rProp == DAVProperties::GETCONTENTLENGTH ) ) |
| 373 |
{ |
| 374 |
bHasGetContentLength = true; |
| 375 |
} |
| 376 |
else if ( !bHasContentType && rProp == "ContentType" ) |
| 377 |
{ |
| 378 |
bHasContentType = true; |
| 379 |
} |
| 380 |
else if ( !bHasIsDocument && rProp == "IsDocument" ) |
| 381 |
{ |
| 382 |
bHasIsDocument = true; |
| 383 |
} |
| 384 |
else if ( !bHasIsFolder && rProp == "IsFolder" ) |
| 385 |
{ |
| 386 |
bHasIsFolder = true; |
| 387 |
} |
| 388 |
else if ( !bHasTitle && rProp == "Title" ) |
| 389 |
{ |
| 390 |
bHasTitle = true; |
| 391 |
} |
| 392 |
else if ( !bHasBaseURI && rProp == "BaseURI" ) |
| 393 |
{ |
| 394 |
bHasBaseURI = true; |
| 395 |
} |
| 396 |
else if ( !bHasDateCreated && rProp == "DateCreated" ) |
| 397 |
{ |
| 398 |
bHasDateCreated = true; |
| 399 |
} |
| 400 |
else if ( !bHasDateModified && rProp == "DateModified" ) |
| 401 |
{ |
| 402 |
bHasDateModified = true; |
| 403 |
} |
| 404 |
else if ( !bHasMediaType && rProp == "MediaType" ) |
| 405 |
{ |
| 406 |
bHasMediaType = true; |
| 407 |
} |
| 408 |
else if ( !bHasSize && rProp == "Size" ) |
| 409 |
{ |
| 410 |
bHasSize = true; |
| 411 |
} |
| 412 |
else if ( !bHasCreatableInfos && rProp == "CreatableContentsInfo" ) |
| 413 |
{ |
| 414 |
bHasCreatableInfos = true; |
| 415 |
} |
| 416 |
} |
| 417 |
} |
| 418 |
|
| 419 |
// Add mandatory properties. |
| 420 |
if ( !bHasContentType ) |
| 421 |
aPropSet.insert( |
| 422 |
u"ContentType"_ustr ); |
| 423 |
|
| 424 |
if ( !bHasIsDocument ) |
| 425 |
aPropSet.insert( |
| 426 |
u"IsDocument"_ustr ); |
| 427 |
|
| 428 |
if ( !bHasIsFolder ) |
| 429 |
aPropSet.insert( |
| 430 |
u"IsFolder"_ustr ); |
| 431 |
|
| 432 |
if ( !bHasTitle ) |
| 433 |
{ |
| 434 |
// Always present since it can be calculated from content's URI. |
| 435 |
aPropSet.insert( |
| 436 |
u"Title"_ustr ); |
| 437 |
} |
| 438 |
|
| 439 |
// Add optional properties. |
| 440 |
|
| 441 |
if ( !bHasBaseURI ) |
| 442 |
{ |
| 443 |
// Always present since it can be calculated from content's URI. |
| 444 |
aPropSet.insert( |
| 445 |
u"BaseURI"_ustr ); |
| 446 |
} |
| 447 |
|
| 448 |
if ( !bHasDateCreated && bHasCreationDate ) |
| 449 |
aPropSet.insert( |
| 450 |
u"DateCreated"_ustr ); |
| 451 |
|
| 452 |
if ( !bHasDateModified && bHasGetLastModified ) |
| 453 |
aPropSet.insert( |
| 454 |
u"DateModified"_ustr ); |
| 455 |
|
| 456 |
if ( !bHasMediaType && bHasGetContentType ) |
| 457 |
aPropSet.insert( |
| 458 |
u"MediaType"_ustr ); |
| 459 |
|
| 460 |
if ( !bHasSize && bHasGetContentLength ) |
| 461 |
aPropSet.insert( |
| 462 |
u"Size"_ustr ); |
| 463 |
|
| 464 |
if ( !bHasCreatableInfos ) |
| 465 |
aPropSet.insert( |
| 466 |
u"CreatableContentsInfo"_ustr ); |
| 467 |
|
| 468 |
// Add cached properties, if present and still missing. |
| 469 |
if (xCachedProps) |
| 470 |
{ |
| 471 |
const std::unique_ptr< PropertyValueMap > & xProps |
| 472 |
= xCachedProps->getProperties(); |
| 473 |
|
| 474 |
for ( const auto& rEntry : *xProps ) |
| 475 |
aPropSet.insert( rEntry.first ); |
| 476 |
} |
| 477 |
|
| 478 |
// std::set -> uno::Sequence |
| 479 |
sal_Int32 nCount = aPropSet.size(); |
| 480 |
uno::Sequence< beans::Property > aProperties( nCount ); |
| 481 |
auto aPropertiesRange = asNonConstRange(aProperties); |
| 482 |
|
| 483 |
beans::Property aProp; |
| 484 |
sal_Int32 n = 0; |
| 485 |
|
| 486 |
for ( const auto& rProp : aPropSet ) |
| 487 |
{ |
| 488 |
xProvider->getProperty( rProp, aProp ); |
| 489 |
aPropertiesRange[ n++ ] = aProp; |
| 490 |
} |
| 491 |
|
| 492 |
return aProperties; |
| 493 |
} |
| 494 |
|
| 495 |
|
| 496 |
// virtual |
| 497 |
uno::Sequence< ucb::CommandInfo > Content::getCommands( |
| 498 |
const uno::Reference< ucb::XCommandEnvironment > & xEnv ) |
| 499 |
{ |
| 500 |
osl::Guard< osl::Mutex > aGuard( m_aMutex ); |
| 501 |
|
| 502 |
uno::Sequence< ucb::CommandInfo > aCmdInfo( 10 ); |
| 503 |
auto pCmdInfo = aCmdInfo.getArray(); |
| 504 |
|
| 505 |
|
| 506 |
// Mandatory commands |
| 507 |
|
| 508 |
|
| 509 |
pCmdInfo[ 0 ] = |
| 510 |
ucb::CommandInfo( |
| 511 |
u"getCommandInfo"_ustr, |
| 512 |
-1, |
| 513 |
cppu::UnoType<void>::get() ); |
| 514 |
pCmdInfo[ 1 ] = |
| 515 |
ucb::CommandInfo( |
| 516 |
u"getPropertySetInfo"_ustr, |
| 517 |
-1, |
| 518 |
cppu::UnoType<void>::get() ); |
| 519 |
pCmdInfo[ 2 ] = |
| 520 |
ucb::CommandInfo( |
| 521 |
u"getPropertyValues"_ustr, |
| 522 |
-1, |
| 523 |
cppu::UnoType<uno::Sequence< beans::Property >>::get()); |
| 524 |
pCmdInfo[ 3 ] = |
| 525 |
ucb::CommandInfo( |
| 526 |
u"setPropertyValues"_ustr, |
| 527 |
-1, |
| 528 |
cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()); |
| 529 |
|
| 530 |
|
| 531 |
// Optional standard commands |
| 532 |
|
| 533 |
|
| 534 |
pCmdInfo[ 4 ] = |
| 535 |
ucb::CommandInfo( |
| 536 |
u"delete"_ustr, |
| 537 |
-1, |
| 538 |
cppu::UnoType<bool>::get() ); |
| 539 |
pCmdInfo[ 5 ] = |
| 540 |
ucb::CommandInfo( |
| 541 |
u"insert"_ustr, |
| 542 |
-1, |
| 543 |
cppu::UnoType<ucb::InsertCommandArgument>::get() ); |
| 544 |
pCmdInfo[ 6 ] = |
| 545 |
ucb::CommandInfo( |
| 546 |
u"open"_ustr, |
| 547 |
-1, |
| 548 |
cppu::UnoType<ucb::OpenCommandArgument2>::get() ); |
| 549 |
|
| 550 |
|
| 551 |
// New commands |
| 552 |
|
| 553 |
|
| 554 |
pCmdInfo[ 7 ] = |
| 555 |
ucb::CommandInfo( |
| 556 |
u"post"_ustr, |
| 557 |
-1, |
| 558 |
cppu::UnoType<ucb::PostCommandArgument2>::get() ); |
| 559 |
pCmdInfo[ 8 ] = |
| 560 |
ucb::CommandInfo( |
| 561 |
u"addProperty"_ustr, |
| 562 |
-1, |
| 563 |
cppu::UnoType<ucb::PropertyCommandArgument>::get() ); |
| 564 |
pCmdInfo[ 9 ] = |
| 565 |
ucb::CommandInfo( |
| 566 |
u"removeProperty"_ustr, |
| 567 |
-1, |
| 568 |
cppu::UnoType<OUString>::get() ); |
| 569 |
|
| 570 |
bool bFolder = false; |
| 571 |
|
| 572 |
try |
| 573 |
{ |
| 574 |
bFolder = isFolder( xEnv ); |
| 575 |
} |
| 576 |
catch ( uno::Exception const & ) |
| 577 |
{ |
| 578 |
return aCmdInfo; |
| 579 |
} |
| 580 |
|
| 581 |
ResourceType eType = resourceTypeForLocks( xEnv ); |
| 582 |
bool bSupportsLocking = ( eType == NOT_FOUND || eType == DAV ); |
| 583 |
|
| 584 |
sal_Int32 nPos = aCmdInfo.getLength(); |
| 585 |
sal_Int32 nMoreCmds = ( bFolder ? 2 : 0 ) + ( bSupportsLocking ? 2 : 0 ); |
| 586 |
if ( nMoreCmds ) |
| 587 |
aCmdInfo.realloc( nPos + nMoreCmds ); |
| 588 |
else |
| 589 |
return aCmdInfo; |
| 590 |
|
| 591 |
pCmdInfo = aCmdInfo.getArray(); |
| 592 |
|
| 593 |
if ( bFolder ) |
| 594 |
{ |
| 595 |
|
| 596 |
// Optional standard commands |
| 597 |
|
| 598 |
|
| 599 |
pCmdInfo[ nPos ] = |
| 600 |
ucb::CommandInfo( |
| 601 |
u"transfer"_ustr, |
| 602 |
-1, |
| 603 |
cppu::UnoType<ucb::TransferInfo>::get() ); |
| 604 |
nPos++; |
| 605 |
pCmdInfo[ nPos ] = |
| 606 |
ucb::CommandInfo( |
| 607 |
u"createNewContent"_ustr, |
| 608 |
-1, |
| 609 |
cppu::UnoType<ucb::ContentInfo>::get() ); |
| 610 |
nPos++; |
| 611 |
} |
| 612 |
else |
| 613 |
{ |
| 614 |
// no document-only commands at the moment. |
| 615 |
} |
| 616 |
|
| 617 |
if ( bSupportsLocking ) |
| 618 |
{ |
| 619 |
pCmdInfo[ nPos ] = |
| 620 |
ucb::CommandInfo( |
| 621 |
u"lock"_ustr, |
| 622 |
-1, |
| 623 |
cppu::UnoType<void>::get() ); |
| 624 |
nPos++; |
| 625 |
pCmdInfo[ nPos ] = |
| 626 |
ucb::CommandInfo( |
| 627 |
u"unlock"_ustr, |
| 628 |
-1, |
| 629 |
cppu::UnoType<void>::get() ); |
| 630 |
nPos++; |
| 631 |
} |
| 632 |
return aCmdInfo; |
| 633 |
} |
| 634 |
|
| 635 |
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |