LCOV - code coverage report
Current view: top level - ucb/source/ucp/webdav-neon - NeonHeadRequest.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 36 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 3 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*************************************************************************
       3             :  *
       4             :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5             :  *
       6             :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7             :  *
       8             :  * OpenOffice.org - a multi-platform office productivity suite
       9             :  *
      10             :  * This file is part of OpenOffice.org.
      11             :  *
      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.
      15             :  *
      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).
      21             :  *
      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.
      26             :  *
      27             :  ************************************************************************/
      28             : 
      29             : #include <osl/diagnose.h>
      30             : #include <osl/mutex.hxx>
      31             : #include <com/sun/star/beans/PropertyValue.hpp>
      32             : #include <com/sun/star/beans/PropertyState.hpp>
      33             : #include "NeonHeadRequest.hxx"
      34             : 
      35             : using namespace webdav_ucp;
      36             : using namespace com::sun::star;
      37             : 
      38             : namespace {
      39             : 
      40           0 : void process_headers( ne_request * req,
      41             :                       DAVResource & rResource,
      42             :                       const std::vector< OUString > & rHeaderNames )
      43             : {
      44           0 :     void * cursor = NULL;
      45             :     const char * name, *value;
      46             : 
      47           0 :     while ( ( cursor = ne_response_header_iterate( req, cursor,
      48             :                                                    &name, &value ) ) != NULL ) {
      49           0 :         OUString aHeaderName( OUString::createFromAscii( name ) );
      50           0 :         OUString aHeaderValue( OUString::createFromAscii( value ) );
      51             : 
      52             :         // Note: Empty vector means that all headers are requested.
      53           0 :         bool bIncludeIt = ( rHeaderNames.empty() );
      54             : 
      55           0 :         if ( !bIncludeIt )
      56             :         {
      57             :             // Check whether this header was requested.
      58             :             std::vector< OUString >::const_iterator it(
      59           0 :                 rHeaderNames.begin() );
      60             :             const std::vector< OUString >::const_iterator end(
      61           0 :                 rHeaderNames.end() );
      62             : 
      63           0 :             while ( it != end )
      64             :             {
      65           0 :                 if ( (*it) == aHeaderName )
      66           0 :                     break;
      67             : 
      68           0 :                 ++it;
      69             :             }
      70             : 
      71           0 :             if ( it != end )
      72           0 :                 bIncludeIt = true;
      73             :         }
      74             : 
      75           0 :         if ( bIncludeIt )
      76             :         {
      77             :             // Create & set the PropertyValue
      78           0 :             DAVPropertyValue thePropertyValue;
      79           0 :             thePropertyValue.Name = aHeaderName;
      80           0 :             thePropertyValue.IsCaseSensitive = false;
      81           0 :             thePropertyValue.Value <<= aHeaderValue;
      82             : 
      83             :             // Add the newly created PropertyValue
      84           0 :             rResource.properties.push_back( thePropertyValue );
      85             :         }
      86           0 :     }
      87           0 : }
      88             : 
      89             : } // namespace
      90             : 
      91             : extern osl::Mutex aGlobalNeonMutex;
      92             : 
      93           0 : NeonHeadRequest::NeonHeadRequest( HttpSession * inSession,
      94             :                                   const OUString & inPath,
      95             :                                   const std::vector< OUString > &
      96             :                                     inHeaderNames,
      97             :                                   DAVResource & ioResource,
      98             :                                   int & nError )
      99             : {
     100           0 :     ioResource.uri = inPath;
     101           0 :     ioResource.properties.clear();
     102             : 
     103             :     // Create and dispatch HEAD request. Install catcher for all response
     104             :     // header fields.
     105             :     ne_request * req = ne_request_create( inSession,
     106             :                                           "HEAD",
     107             :                                           OUStringToOString(
     108             :                                             inPath,
     109           0 :                                             RTL_TEXTENCODING_UTF8 ).getStr() );
     110             : 
     111             :     {
     112           0 :         osl::Guard< osl::Mutex > theGlobalGuard( aGlobalNeonMutex );
     113           0 :         nError = ne_request_dispatch( req );
     114             :     }
     115             : 
     116           0 :     process_headers( req, ioResource, inHeaderNames );
     117             : 
     118           0 :     if ( nError == NE_OK && ne_get_status( req )->klass != 2 )
     119           0 :         nError = NE_ERROR;
     120             : 
     121           0 :     ne_request_destroy( req );
     122           0 : }
     123             : 
     124           0 : NeonHeadRequest::~NeonHeadRequest()
     125             : {
     126           0 : }
     127             : 
     128             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11