Update image downloading functionality 62/36762/7
authorYoonsang Lee <ysang114.lee@samsung.com>
Fri, 13 Mar 2015 06:33:00 +0000 (15:33 +0900)
committerYoonsang Lee <ysang114.lee@samsung.com>
Tue, 31 Mar 2015 00:54:39 +0000 (17:54 -0700)
- Support for https protocol.
- Set connection timeout to 30 sec.
- Log curl error code in failure cases.

Change-Id: If05803c12ed8619d49d4ae481d82f90eb710f650

platform-abstractions/tizen/resource-loader/resource-bitmap-requester.cpp
platform-abstractions/tizen/resource-loader/resource-thread-image.cpp

index 6a3217e..ff33ec9 100644 (file)
@@ -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
       {
index 381a953..5782286 100755 (executable)
 
 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;
       }
     }