LCOV - code coverage report
Current view: top level - libreoffice/ucb/source/ucp/webdav-neon - NeonHeadRequest.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 36 0.0 %
Date: 2012-12-27 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 <com/sun/star/beans/PropertyValue.hpp>
      31             : #include <com/sun/star/beans/PropertyState.hpp>
      32             : #include "NeonHeadRequest.hxx"
      33             : 
      34             : using namespace webdav_ucp;
      35             : using namespace com::sun::star;
      36             : 
      37             : namespace {
      38             : 
      39           0 : void process_headers( ne_request * req,
      40             :                       DAVResource & rResource,
      41             :                       const std::vector< ::rtl::OUString > & rHeaderNames )
      42             : {
      43           0 :     void * cursor = NULL;
      44             :     const char * name, *value;
      45             : 
      46           0 :     while ( ( cursor = ne_response_header_iterate( req, cursor,
      47             :                                                    &name, &value ) ) != NULL ) {
      48           0 :         rtl::OUString aHeaderName( rtl::OUString::createFromAscii( name ) );
      49           0 :         rtl::OUString aHeaderValue( rtl::OUString::createFromAscii( value ) );
      50             : 
      51             :         // Note: Empty vector means that all headers are requested.
      52           0 :         bool bIncludeIt = ( rHeaderNames.empty() );
      53             : 
      54           0 :         if ( !bIncludeIt )
      55             :         {
      56             :             // Check whether this header was requested.
      57             :             std::vector< ::rtl::OUString >::const_iterator it(
      58           0 :                 rHeaderNames.begin() );
      59             :             const std::vector< ::rtl::OUString >::const_iterator end(
      60           0 :                 rHeaderNames.end() );
      61             : 
      62           0 :             while ( it != end )
      63             :             {
      64           0 :                 if ( (*it) == aHeaderName )
      65           0 :                     break;
      66             : 
      67           0 :                 ++it;
      68             :             }
      69             : 
      70           0 :             if ( it != end )
      71           0 :                 bIncludeIt = true;
      72             :         }
      73             : 
      74           0 :         if ( bIncludeIt )
      75             :         {
      76             :             // Create & set the PropertyValue
      77           0 :             DAVPropertyValue thePropertyValue;
      78           0 :             thePropertyValue.Name = aHeaderName;
      79           0 :             thePropertyValue.IsCaseSensitive = false;
      80           0 :             thePropertyValue.Value <<= aHeaderValue;
      81             : 
      82             :             // Add the newly created PropertyValue
      83           0 :             rResource.properties.push_back( thePropertyValue );
      84             :         }
      85           0 :     }
      86           0 : }
      87             : 
      88             : } // namespace
      89             : 
      90             : // -------------------------------------------------------------------
      91             : // Constructor
      92             : // -------------------------------------------------------------------
      93             : 
      94             : extern osl::Mutex aGlobalNeonMutex;
      95             : 
      96           0 : NeonHeadRequest::NeonHeadRequest( HttpSession * inSession,
      97             :                                   const rtl::OUString & inPath,
      98             :                                   const std::vector< ::rtl::OUString > &
      99             :                                     inHeaderNames,
     100             :                                   DAVResource & ioResource,
     101             :                                   int & nError )
     102             : {
     103           0 :     ioResource.uri = inPath;
     104           0 :     ioResource.properties.clear();
     105             : 
     106             :     // Create and dispatch HEAD request. Install catcher for all response
     107             :     // header fields.
     108             :     ne_request * req = ne_request_create( inSession,
     109             :                                           "HEAD",
     110             :                                           rtl::OUStringToOString(
     111             :                                             inPath,
     112           0 :                                             RTL_TEXTENCODING_UTF8 ).getStr() );
     113             : 
     114             :     {
     115           0 :         osl::Guard< osl::Mutex > theGlobalGuard( aGlobalNeonMutex );
     116           0 :         nError = ne_request_dispatch( req );
     117             :     }
     118             : 
     119           0 :     process_headers( req, ioResource, inHeaderNames );
     120             : 
     121           0 :     if ( nError == NE_OK && ne_get_status( req )->klass != 2 )
     122           0 :         nError = NE_ERROR;
     123             : 
     124           0 :     ne_request_destroy( req );
     125           0 : }
     126             : 
     127             : // -------------------------------------------------------------------
     128             : // Destructor
     129             : // -------------------------------------------------------------------
     130           0 : NeonHeadRequest::~NeonHeadRequest()
     131             : {
     132           0 : }
     133             : 
     134             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10