LCOV - code coverage report
Current view: top level - ucb/source/ucp/webdav-neon - NeonSession.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 6 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 4 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             : #ifndef INCLUDED_UCB_SOURCE_UCP_WEBDAV_NEON_NEONSESSION_HXX
      30             : #define INCLUDED_UCB_SOURCE_UCP_WEBDAV_NEON_NEONSESSION_HXX
      31             : 
      32             : #include <config_lgpl.h>
      33             : #include <vector>
      34             : #include <osl/mutex.hxx>
      35             : #include "DAVSession.hxx"
      36             : #include "NeonTypes.hxx"
      37             : #include "NeonLockStore.hxx"
      38             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      39             : 
      40             : namespace ucbhelper { class ProxyDecider; }
      41             : 
      42             : namespace webdav_ucp
      43             : {
      44             : 
      45             : // A DAVSession implementation using the neon/expat library
      46             : class NeonSession : public DAVSession
      47             : {
      48             : private:
      49             :     osl::Mutex        m_aMutex;
      50             :     OUString     m_aScheme;
      51             :     OUString     m_aHostName;
      52             :     OUString     m_aProxyName;
      53             :     sal_Int32         m_nPort;
      54             :     sal_Int32         m_nProxyPort;
      55             :     ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > m_aFlags;
      56             :     HttpSession *     m_pHttpSession;
      57             :     void *            m_pRequestData;
      58             :     const ucbhelper::InternetProxyDecider & m_rProxyDecider;
      59             : 
      60             :     // @@@ This should really be per-request data. But Neon currently
      61             :     // (0.23.5) has no interface for passing per-request user data.
      62             :     // Theoretically, a NeonSession instance could handle multiple requests
      63             :     // at a time --currently it doesn't. Thus this is not an issue at the
      64             :     // moment.
      65             :     DAVRequestEnvironment m_aEnv;
      66             : 
      67             :     static bool          m_bGlobalsInited;
      68             :     static NeonLockStore m_aNeonLockStore;
      69             : 
      70             : protected:
      71             :     virtual ~NeonSession();
      72             : 
      73             : public:
      74             :     NeonSession( const rtl::Reference< DAVSessionFactory > & rSessionFactory,
      75             :                  const OUString& inUri,
      76             :                  const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& rFlags,
      77             :                  const ucbhelper::InternetProxyDecider & rProxyDecider )
      78             :         throw ( std::exception );
      79             : 
      80             :     // DAVSession methods
      81             :     virtual bool CanUse( const OUString & inPath,
      82             :                          const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& rFlags ) SAL_OVERRIDE;
      83             : 
      84             :     virtual bool UsesProxy() SAL_OVERRIDE;
      85             : 
      86           0 :     const DAVRequestEnvironment & getRequestEnvironment() const
      87           0 :     { return m_aEnv; }
      88             : 
      89             :     virtual void
      90             :     OPTIONS( const OUString &  inPath,
      91             :              DAVCapabilities & outCapabilities,
      92             :              const DAVRequestEnvironment & rEnv )
      93             :         throw ( std::exception ) SAL_OVERRIDE;
      94             : 
      95             :     // allprop & named
      96             :     virtual void
      97             :     PROPFIND( const OUString & inPath,
      98             :               const Depth inDepth,
      99             :               const std::vector< OUString > & inPropNames,
     100             :               std::vector< DAVResource > & ioResources,
     101             :               const DAVRequestEnvironment & rEnv )
     102             :         throw ( std::exception ) SAL_OVERRIDE;
     103             : 
     104             :     // propnames
     105             :     virtual void
     106             :     PROPFIND( const OUString & inPath,
     107             :               const Depth inDepth,
     108             :               std::vector< DAVResourceInfo >& ioResInfo,
     109             :               const DAVRequestEnvironment & rEnv )
     110             :         throw ( std::exception ) SAL_OVERRIDE;
     111             : 
     112             :     virtual void
     113             :     PROPPATCH( const OUString & inPath,
     114             :                const std::vector< ProppatchValue > & inValues,
     115             :                const DAVRequestEnvironment & rEnv )
     116             :         throw ( std::exception ) SAL_OVERRIDE;
     117             : 
     118             :     virtual void
     119             :     HEAD( const OUString &  inPath,
     120             :           const std::vector< OUString > & inHeaderNames,
     121             :           DAVResource & ioResource,
     122             :           const DAVRequestEnvironment & rEnv )
     123             :         throw ( std::exception ) SAL_OVERRIDE;
     124             : 
     125             :     virtual com::sun::star::uno::Reference< com::sun::star::io::XInputStream >
     126             :     GET( const OUString & inPath,
     127             :          const DAVRequestEnvironment & rEnv )
     128             :         throw ( std::exception ) SAL_OVERRIDE;
     129             : 
     130             :     virtual void
     131             :     GET( const OUString & inPath,
     132             :          com::sun::star::uno::Reference<
     133             :              com::sun::star::io::XOutputStream > &  ioOutputStream,
     134             :          const DAVRequestEnvironment & rEnv )
     135             :         throw ( std::exception ) SAL_OVERRIDE;
     136             : 
     137             :     virtual com::sun::star::uno::Reference< com::sun::star::io::XInputStream >
     138             :     GET( const OUString & inPath,
     139             :          const std::vector< OUString > & inHeaderNames,
     140             :          DAVResource & ioResource,
     141             :          const DAVRequestEnvironment & rEnv )
     142             :         throw ( std::exception ) SAL_OVERRIDE;
     143             : 
     144             :     virtual void
     145             :     GET( const OUString & inPath,
     146             :          com::sun::star::uno::Reference<
     147             :              com::sun::star::io::XOutputStream > & ioOutputStream,
     148             :          const std::vector< OUString > & inHeaderNames,
     149             :          DAVResource & ioResource,
     150             :          const DAVRequestEnvironment & rEnv )
     151             :         throw ( std::exception ) SAL_OVERRIDE;
     152             : 
     153             :     virtual void
     154             :     PUT( const OUString & inPath,
     155             :          const com::sun::star::uno::Reference<
     156             :              com::sun::star::io::XInputStream > & inInputStream,
     157             :          const DAVRequestEnvironment & rEnv )
     158             :         throw ( std::exception ) SAL_OVERRIDE;
     159             : 
     160             :     virtual com::sun::star::uno::Reference< com::sun::star::io::XInputStream >
     161             :     POST( const OUString & inPath,
     162             :           const OUString & rContentType,
     163             :           const OUString & rReferer,
     164             :           const com::sun::star::uno::Reference<
     165             :               com::sun::star::io::XInputStream > & inInputStream,
     166             :           const DAVRequestEnvironment & rEnv )
     167             :         throw ( std::exception ) SAL_OVERRIDE;
     168             : 
     169             :     virtual void
     170             :     POST( const OUString & inPath,
     171             :           const OUString & rContentType,
     172             :           const OUString & rReferer,
     173             :           const com::sun::star::uno::Reference<
     174             :               com::sun::star::io::XInputStream > & inInputStream,
     175             :           com::sun::star::uno::Reference<
     176             :               com::sun::star::io::XOutputStream > & oOutputStream,
     177             :           const DAVRequestEnvironment & rEnv )
     178             :         throw ( std::exception ) SAL_OVERRIDE;
     179             : 
     180             :     virtual void
     181             :     MKCOL( const OUString & inPath,
     182             :            const DAVRequestEnvironment & rEnv )
     183             :         throw ( std::exception ) SAL_OVERRIDE;
     184             : 
     185             :     virtual void
     186             :     COPY( const OUString & inSourceURL,
     187             :           const OUString & inDestinationURL,
     188             :           const DAVRequestEnvironment & rEnv,
     189             :           bool inOverWrite )
     190             :         throw ( std::exception ) SAL_OVERRIDE;
     191             : 
     192             :     virtual void
     193             :     MOVE( const OUString & inSourceURL,
     194             :           const OUString & inDestinationURL,
     195             :           const DAVRequestEnvironment & rEnv,
     196             :           bool inOverWrite )
     197             :         throw ( std::exception ) SAL_OVERRIDE;
     198             : 
     199             :     virtual void DESTROY( const OUString & inPath,
     200             :                           const DAVRequestEnvironment & rEnv )
     201             :         throw ( std::exception ) SAL_OVERRIDE;
     202             : 
     203             :     // set new lock.
     204             :     virtual void LOCK( const OUString & inURL,
     205             :                        com::sun::star::ucb::Lock & inLock,
     206             :                        const DAVRequestEnvironment & rEnv )
     207             :         throw ( std::exception ) SAL_OVERRIDE;
     208             : 
     209             :     // refresh existing lock.
     210             :     virtual sal_Int64 LOCK( const OUString & inURL,
     211             :                             sal_Int64 nTimeout,
     212             :                             const DAVRequestEnvironment & rEnv )
     213             :         throw ( std::exception ) SAL_OVERRIDE;
     214             : 
     215             :     virtual void UNLOCK( const OUString & inURL,
     216             :                          const DAVRequestEnvironment & rEnv )
     217             :         throw ( std::exception ) SAL_OVERRIDE;
     218             : 
     219             :     // helpers
     220             :     virtual void abort()
     221             :         throw ( std::exception ) SAL_OVERRIDE;
     222             : 
     223           0 :     const OUString & getHostName() const { return m_aHostName; }
     224             : 
     225           0 :     const ::uno::Reference< ::uno::XComponentContext > getComponentContext()
     226           0 :     { return m_xFactory->getComponentContext(); }
     227             : 
     228           0 :     const void * getRequestData() const { return m_pRequestData; }
     229             : 
     230             :     bool isDomainMatch( const OUString& certHostName );
     231             : 
     232             : private:
     233             :     friend class NeonLockStore;
     234             : 
     235             :     void Init()
     236             :         throw (css::uno::RuntimeException, std::exception);
     237             : 
     238             :     void Init( const DAVRequestEnvironment & rEnv )
     239             :         throw (css::uno::RuntimeException, std::exception);
     240             : 
     241             :     // ret: true => retry request.
     242             :     void HandleError( int nError,
     243             :                       const OUString & inPath,
     244             :                       const DAVRequestEnvironment & rEnv )
     245             :         throw ( std::exception );
     246             : 
     247             :     const ucbhelper::InternetProxyServer & getProxySettings() const;
     248             : 
     249             :     bool removeExpiredLocktoken( const OUString & inURL,
     250             :                                  const DAVRequestEnvironment & rEnv );
     251             : 
     252             :     // refresh lock, called by NeonLockStore::refreshLocks
     253             :     bool LOCK( NeonLock * pLock,
     254             :                sal_Int32 & rlastChanceToSendRefreshRequest );
     255             : 
     256             :     // unlock, called by NeonLockStore::~NeonLockStore
     257             :     bool UNLOCK( NeonLock * pLock );
     258             : 
     259             :     // low level GET implementation, used by public GET implementations
     260             :     static int GET( ne_session * sess,
     261             :                     const char * uri,
     262             :                     ne_block_reader reader,
     263             :                     bool getheaders,
     264             :                     void * userdata );
     265             : 
     266             :     // Buffer-based PUT implementation. Neon only has file descriptor-
     267             :     // based API.
     268             :     static int PUT( ne_session * sess,
     269             :                     const char * uri,
     270             :                     const char * buffer,
     271             :                     size_t size );
     272             : 
     273             :     // Buffer-based POST implementation. Neon only has file descriptor-
     274             :     // based API.
     275             :     int POST( ne_session * sess,
     276             :               const char * uri,
     277             :               const char * buffer,
     278             :               ne_block_reader reader,
     279             :               void * userdata,
     280             :               const OUString & rContentType,
     281             :               const OUString & rReferer );
     282             : 
     283             :     // Helper: XInputStream -> Sequence< sal_Int8 >
     284             :     static bool getDataFromInputStream(
     285             :         const com::sun::star::uno::Reference<
     286             :             com::sun::star::io::XInputStream > & xStream,
     287             :         com::sun::star::uno::Sequence< sal_Int8 > & rData,
     288             :         bool bAppendTrailingZeroByte );
     289             : 
     290             :     OUString makeAbsoluteURL( OUString const & rURL ) const;
     291             : };
     292             : 
     293             : } // namespace webdav_ucp
     294             : 
     295             : #endif // INCLUDED_UCB_SOURCE_UCP_WEBDAV_NEON_NEONSESSION_HXX
     296             : 
     297             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11