LCOV - code coverage report
Current view: top level - ucb/source/ucp/cmis - cmis_url.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 46 0.0 %
Date: 2012-08-25 Functions: 0 10 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                 :            :  * Version: MPL 1.1 / GPLv3+ / LGPLv3+
       4                 :            :  *
       5                 :            :  * The contents of this file are subject to the Mozilla Public License Version
       6                 :            :  * 1.1 (the "License"); you may not use this file except in compliance with
       7                 :            :  * the License or as specified alternatively below. You may obtain a copy of
       8                 :            :  * the License at http://www.mozilla.org/MPL/
       9                 :            :  *
      10                 :            :  * Software distributed under the License is distributed on an "AS IS" basis,
      11                 :            :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12                 :            :  * for the specific language governing rights and limitations under the
      13                 :            :  * License.
      14                 :            :  *
      15                 :            :  * Major Contributor(s):
      16                 :            :  * [ Copyright (C) 2011 SUSE <cbosdonnat@suse.com> (initial developer) ]
      17                 :            :  *
      18                 :            :  * All Rights Reserved.
      19                 :            :  *
      20                 :            :  * For minor contributions see the git repository.
      21                 :            :  *
      22                 :            :  * Alternatively, the contents of this file may be used under the terms of
      23                 :            :  * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
      24                 :            :  * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
      25                 :            :  * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
      26                 :            :  * instead of those above.
      27                 :            :  */
      28                 :            : 
      29                 :            : #include <libcmis/session-factory.hxx>
      30                 :            : 
      31                 :            : #include <rtl/uri.hxx>
      32                 :            : 
      33                 :            : #include "cmis_url.hxx"
      34                 :            : 
      35                 :            : using namespace std;
      36                 :            : 
      37                 :            : #define OUSTR_TO_STDSTR(s) string( rtl::OUStringToOString( s, RTL_TEXTENCODING_UTF8 ).getStr() )
      38                 :            : 
      39                 :            : 
      40                 :            : namespace cmis
      41                 :            : {
      42                 :          0 :     URL::URL( rtl::OUString const & urlStr )
      43                 :            :     {
      44                 :          0 :         rtl::OUString sBindingUrl;
      45                 :          0 :         rtl::OUString sRepositoryId;
      46                 :            : 
      47                 :          0 :         INetURLObject aUrl( urlStr );
      48                 :            : 
      49                 :            :         // Decode the authority to get the binding URL and repository id
      50                 :          0 :         rtl::OUString sDecodedHost = aUrl.GetHost( INetURLObject::DECODE_WITH_CHARSET );
      51                 :          0 :         INetURLObject aHostUrl( sDecodedHost );
      52                 :          0 :         m_sBindingUrl = aHostUrl.GetURLNoMark( );
      53                 :          0 :         m_sRepositoryId = aHostUrl.GetMark( );
      54                 :            : 
      55                 :          0 :         m_sUser = aUrl.GetUser( );
      56                 :          0 :         m_sPass = aUrl.GetPass( );
      57                 :            : 
      58                 :            :         // Store the path to the object
      59                 :          0 :         m_sPath = aUrl.GetURLPath( INetURLObject::DECODE_WITH_CHARSET );
      60                 :          0 :         m_sId = aUrl.GetMark( );
      61                 :            : 
      62                 :          0 :         if ( !m_sId.isEmpty( ) )
      63                 :          0 :             m_sPath = rtl::OUString( );
      64                 :          0 :     }
      65                 :            : 
      66                 :          0 :     map< int, string > URL::getSessionParams( )
      67                 :            :     {
      68                 :          0 :         map< int, string > params;
      69                 :          0 :         params[ATOMPUB_URL] = OUSTR_TO_STDSTR( m_sBindingUrl );
      70                 :          0 :         params[REPOSITORY_ID] = OUSTR_TO_STDSTR( m_sRepositoryId );
      71                 :          0 :         params[USERNAME] = OUSTR_TO_STDSTR( m_sUser );
      72                 :          0 :         params[PASSWORD] = OUSTR_TO_STDSTR( m_sPass );
      73                 :            : 
      74                 :          0 :         return params;
      75                 :            :     }
      76                 :            : 
      77                 :          0 :     rtl::OUString& URL::getObjectPath( )
      78                 :            :     {
      79                 :          0 :         return m_sPath;
      80                 :            :     }
      81                 :            : 
      82                 :          0 :     rtl::OUString& URL::getObjectId( )
      83                 :            :     {
      84                 :          0 :         return m_sId;
      85                 :            :     }
      86                 :            : 
      87                 :          0 :     rtl::OUString& URL::getBindingUrl( )
      88                 :            :     {
      89                 :          0 :         return m_sBindingUrl;
      90                 :            :     }
      91                 :            : 
      92                 :          0 :     rtl::OUString& URL::getRepositoryId( )
      93                 :            :     {
      94                 :          0 :         return m_sRepositoryId;
      95                 :            :     }
      96                 :            : 
      97                 :          0 :     void URL::setObjectPath( rtl::OUString sPath )
      98                 :            :     {
      99                 :          0 :         m_sPath = sPath;
     100                 :          0 :         m_sId = rtl::OUString( );
     101                 :          0 :     }
     102                 :            : 
     103                 :          0 :     rtl::OUString URL::asString( )
     104                 :            :     {
     105                 :          0 :         rtl::OUString sUrl;
     106                 :            :         rtl::OUString sEncodedBinding = rtl::Uri::encode(
     107                 :            :                 m_sBindingUrl + "#" + m_sRepositoryId,
     108                 :            :                 rtl_UriCharClassRelSegment,
     109                 :            :                 rtl_UriEncodeKeepEscapes,
     110                 :          0 :                 RTL_TEXTENCODING_UTF8 );
     111                 :          0 :         sUrl = "vnd.libreoffice.cmis+atom://" + sEncodedBinding;
     112                 :            : 
     113                 :          0 :         if ( !m_sPath.isEmpty( ) )
     114                 :            :         {
     115                 :          0 :             if ( m_sPath[0] != '/' )
     116                 :          0 :                 sUrl += "/";
     117                 :          0 :             sUrl += m_sPath;
     118                 :            :         }
     119                 :          0 :         else if ( !m_sId.isEmpty( ) )
     120                 :            :         {
     121                 :          0 :             sUrl += "#" + m_sId;
     122                 :            :         }
     123                 :            : 
     124                 :          0 :         return sUrl;
     125                 :            :     }
     126                 :          0 : }
     127                 :            : 
     128                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10