LCOV - code coverage report
Current view: top level - ucb/source/ucp/ftp - ftploaderthread.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 22 0.0 %
Date: 2014-04-14 Functions: 0 5 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             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : /**************************************************************************
      21             :                                 TODO
      22             :  **************************************************************************
      23             : 
      24             :  *************************************************************************/
      25             : #include "ftploaderthread.hxx"
      26             : #include "curl.hxx"
      27             : 
      28             : using namespace ftp;
      29             : 
      30             : 
      31             : /********************************************************************************/
      32             : /*                                                                              */
      33             : /*                cleanup function for thread specific data                     */
      34             : /*                                                                              */
      35             : /********************************************************************************/
      36             : 
      37             : 
      38             : #ifdef __cplusplus
      39             : extern "C" {
      40             : #endif
      41             : 
      42           0 :     int memory_write_dummy(void *,size_t,size_t,void *)
      43             :     {
      44           0 :         return 0;
      45             :     }
      46             : 
      47           0 :     void delete_CURL(void *pData)
      48             :     {
      49             :         // Otherwise response for QUIT will be sent to already destroyed
      50             :         // MemoryContainer via non-dummy memory_write function.
      51             :         curl_easy_setopt(static_cast<CURL*>(pData),
      52             :                          CURLOPT_HEADERFUNCTION,
      53           0 :                          memory_write_dummy);
      54           0 :         curl_easy_cleanup(static_cast<CURL*>(pData));
      55           0 :     }
      56             : 
      57             : #ifdef __cplusplus
      58             : }
      59             : #endif
      60             : 
      61             : 
      62             : /********************************************************************************/
      63             : /*                                                                              */
      64             : /*                  Member part of FTPLoaderThread                              */
      65             : /*                                                                              */
      66             : /********************************************************************************/
      67             : 
      68             : 
      69           0 : FTPLoaderThread::FTPLoaderThread()
      70           0 :     : m_threadKey(osl_createThreadKey(delete_CURL)) {
      71           0 : }
      72             : 
      73             : 
      74             : 
      75           0 : FTPLoaderThread::~FTPLoaderThread() {
      76           0 :     osl_destroyThreadKey(m_threadKey);
      77           0 : }
      78             : 
      79             : 
      80             : 
      81           0 : CURL* FTPLoaderThread::handle() {
      82           0 :     CURL* ret = osl_getThreadKeyData(m_threadKey);
      83           0 :     if(!ret) {
      84           0 :         ret = curl_easy_init();
      85           0 :         if (ret != 0) {
      86             :             // Make sure curl is not internally using environment variables like
      87             :             // "ftp_proxy":
      88           0 :             if (curl_easy_setopt(ret, CURLOPT_PROXY, "") != CURLE_OK) {
      89           0 :                 curl_easy_cleanup(ret);
      90           0 :                 ret = 0;
      91             :             }
      92             :         }
      93           0 :         osl_setThreadKeyData(m_threadKey,static_cast<void*>(ret));
      94             :     }
      95             : 
      96           0 :     return ret;
      97             : }
      98             : 
      99             : 
     100             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10