From: Yoonsang Lee Date: Fri, 13 Mar 2015 06:33:00 +0000 (+0900) Subject: Update image downloading functionality X-Git-Tag: dali_1.0.38~7^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8ae8ea85f230fc3d6465c62ef85f360937e9230d;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git Update image downloading functionality - Support for https protocol. - Set connection timeout to 30 sec. - Log curl error code in failure cases. Change-Id: If05803c12ed8619d49d4ae481d82f90eb710f650 --- diff --git a/platform-abstractions/tizen/resource-loader/resource-bitmap-requester.cpp b/platform-abstractions/tizen/resource-loader/resource-bitmap-requester.cpp index 6a3217e..ff33ec9 100644 --- a/platform-abstractions/tizen/resource-loader/resource-bitmap-requester.cpp +++ b/platform-abstractions/tizen/resource-loader/resource-bitmap-requester.cpp @@ -71,10 +71,20 @@ void ResourceBitmapRequester::LoadResource( Integration::ResourceRequest& reques else { const std::string& resourcePath = request.GetPath(); - if( resourcePath.length() > 7 && strncasecmp( resourcePath.c_str(), "http://", 7 ) == 0 ) + if( strncasecmp( resourcePath.c_str(), "http", 4 ) == 0 ) { - requestType = ResourceThreadBase::RequestDownload; - workerThread = remoteImageThread; + if( resourcePath.size() > 4 && + ( strncasecmp( &resourcePath.c_str()[4], "://", 3 ) == 0 || + strncasecmp( &resourcePath.c_str()[4], "s://", 4) == 0 ) ) + { + requestType = ResourceThreadBase::RequestDownload; + workerThread = remoteImageThread; + } + else + { + requestType = ResourceThreadBase::RequestLoad; + workerThread = localImageThread; + } } else { diff --git a/platform-abstractions/tizen/resource-loader/resource-thread-image.cpp b/platform-abstractions/tizen/resource-loader/resource-thread-image.cpp index 381a953..5782286 100755 --- a/platform-abstractions/tizen/resource-loader/resource-thread-image.cpp +++ b/platform-abstractions/tizen/resource-loader/resource-thread-image.cpp @@ -27,6 +27,11 @@ using namespace Dali::Integration; +namespace +{ +const int CONNECTION_TIMEOUT( 30 ); +} + namespace Dali { @@ -106,6 +111,7 @@ bool ResourceThreadImage::DownloadRemoteImageIntoMemory(const Integration::Resou curl_easy_setopt( curl_handle, CURLOPT_VERBOSE, 0 ); curl_easy_setopt( curl_handle, CURLOPT_URL, request.GetPath().c_str() ); curl_easy_setopt( curl_handle, CURLOPT_FAILONERROR, 1 ); + curl_easy_setopt( curl_handle, CURLOPT_CONNECTTIMEOUT, CONNECTION_TIMEOUT ); // Download header first to get data size char* headerBytes = NULL; @@ -126,7 +132,7 @@ bool ResourceThreadImage::DownloadRemoteImageIntoMemory(const Integration::Resou } else { - DALI_LOG_WARNING( "Failed to download file to load \"%s\"\n", request.GetPath().c_str() ); + DALI_LOG_WARNING( "Failed to download http header for \"%s\" with error code %d\n", request.GetPath().c_str(), cresult ); succeeded = false; } @@ -160,7 +166,7 @@ bool ResourceThreadImage::DownloadRemoteImageIntoMemory(const Integration::Resou cresult = curl_easy_perform( curl_handle ); if( CURLE_OK != cresult ) { - DALI_LOG_WARNING( "Failed to download file to load \"%s\"\n", request.GetPath().c_str() ); + DALI_LOG_WARNING( "Failed to download image file \"%s\" with error code %d\n", request.GetPath().c_str(), cresult ); succeeded = false; } }