2 * Copyright (c) 2018 Samsung Electronics Co., Ltd.
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
19 #include <curl/curl.h>
\r
21 #include <dali/internal/imaging/common/file-download.h>
\r
22 #include <Win32WindowSystem.h>
\r
23 #include <dali/integration-api/debug.h>
\r
24 #include <dali/internal/system/common/file-closer.h>
\r
29 namespace TizenPlatform
\r
32 const int CONNECTION_TIMEOUT_SECONDS( 30L );
\r
33 const long VERBOSE_MODE = 0L; // 0 == off, 1 == on
\r
34 const long CLOSE_CONNECTION_ON_ERROR = 1L; // 0 == off, 1 == on
\r
35 const long EXCLUDE_HEADER = 0L;
\r
36 const long INCLUDE_HEADER = 1L;
\r
37 const long INCLUDE_BODY = 0L;
\r
38 const long EXCLUDE_BODY = 1L;
\r
43 unsigned long CurlEnvironment::GetThreadId()
\r
45 // If dali uses c++ thread, we may replace pthread_self() to this_thread::get_id()
\r
46 return Win32WindowSystem::GetCurrentThreadId();
\r
49 void CurlEnvironment::ConfigureCurlOptions( void* curlHandle, const std::string& url )
\r
51 curl_easy_setopt( curlHandle, CURLOPT_URL, url.c_str() );
\r
52 //curl_easy_setopt( curlHandle, CURLOPT_VERBOSE, VERBOSE_MODE );
\r
53 curl_easy_setopt( curlHandle, CURLOPT_PROXY, "109.123.100.31:3128" );
\r
55 // CURLOPT_FAILONERROR is not fail-safe especially when authentication is involved ( see manual )
\r
56 // Removed CURLOPT_FAILONERROR option
\r
57 curl_easy_setopt( curlHandle, CURLOPT_CONNECTTIMEOUT, CONNECTION_TIMEOUT_SECONDS );
\r
58 curl_easy_setopt( curlHandle, CURLOPT_HEADER, INCLUDE_HEADER );
\r
59 curl_easy_setopt( curlHandle, CURLOPT_NOBODY, EXCLUDE_BODY );
\r
62 static size_t WriteFunction( void *input, size_t uSize, size_t uCount, void *avg )
\r
64 Internal::Platform::InternalFile::fwrite( input, uSize, uCount, (FILE*)avg );
\r
65 return uSize * uCount;
\r
68 void CurlEnvironment::InitWriteFunction( void* curlHandle )
\r
70 curl_easy_setopt( curlHandle, CURLOPT_WRITEFUNCTION, WriteFunction );
\r