LCOV - code coverage report
Current view: top level - ucb/source/ucp/webdav - NeonSession.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 6 0.0 %
Date: 2012-08-25 Functions: 0 4 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

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

Generated by: LCOV version 1.10