LCOV - code coverage report
Current view: top level - ucb/source/ucp/webdav-neon - NeonHeadRequest.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 36 0.0 %
Date: 2014-04-14 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< 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 :         OUString aHeaderName( OUString::createFromAscii( name ) );
      49           0 :         OUString aHeaderValue( 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< OUString >::const_iterator it(
      58           0 :                 rHeaderNames.begin() );
      59             :             const std::vector< 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             : extern osl::Mutex aGlobalNeonMutex;
      91             : 
      92           0 : NeonHeadRequest::NeonHeadRequest( HttpSession * inSession,
      93             :                                   const OUString & inPath,
      94             :                                   const std::vector< OUString > &
      95             :                                     inHeaderNames,
      96             :                                   DAVResource & ioResource,
      97             :                                   int & nError )
      98             : {
      99           0 :     ioResource.uri = inPath;
     100           0 :     ioResource.properties.clear();
     101             : 
     102             :     // Create and dispatch HEAD request. Install catcher for all response
     103             :     // header fields.
     104             :     ne_request * req = ne_request_create( inSession,
     105             :                                           "HEAD",
     106             :                                           OUStringToOString(
     107             :                                             inPath,
     108           0 :                                             RTL_TEXTENCODING_UTF8 ).getStr() );
     109             : 
     110             :     {
     111           0 :         osl::Guard< osl::Mutex > theGlobalGuard( aGlobalNeonMutex );
     112           0 :         nError = ne_request_dispatch( req );
     113             :     }
     114             : 
     115           0 :     process_headers( req, ioResource, inHeaderNames );
     116             : 
     117           0 :     if ( nError == NE_OK && ne_get_status( req )->klass != 2 )
     118           0 :         nError = NE_ERROR;
     119             : 
     120           0 :     ne_request_destroy( req );
     121           0 : }
     122             : 
     123           0 : NeonHeadRequest::~NeonHeadRequest()
     124             : {
     125           0 : }
     126             : 
     127             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10