Fix some typos in comments.
[dcpomatic.git] / src / lib / curl_uploader.cc
index 6fe7aba145c40ecfa2fd91f2ae035dee0d6f0a5b..389a5d6de50b45859401feb829713f6e793a6ccd 100644 (file)
@@ -20,6 +20,7 @@
 
 
 #include "curl_uploader.h"
+#include "dcpomatic_log.h"
 #include "exceptions.h"
 #include "config.h"
 #include "cross.h"
@@ -43,6 +44,13 @@ read_callback (void* ptr, size_t size, size_t nmemb, void* object)
 }
 
 
+static int
+curl_debug_shim (CURL* curl, curl_infotype type, char* data, size_t size, void* userp)
+{
+       return reinterpret_cast<CurlUploader*>(userp)->debug(curl, type, data, size);
+}
+
+
 CurlUploader::CurlUploader (function<void (string)> set_status, function<void (float)> set_progress)
        : Uploader (set_status, set_progress)
 {
@@ -58,6 +66,12 @@ CurlUploader::CurlUploader (function<void (string)> set_status, function<void (f
        curl_easy_setopt (_curl, CURLOPT_READDATA, this);
        curl_easy_setopt (_curl, CURLOPT_USERNAME, Config::instance()->tms_user().c_str());
        curl_easy_setopt (_curl, CURLOPT_PASSWORD, Config::instance()->tms_password().c_str());
+       if (!Config::instance()->tms_passive()) {
+               curl_easy_setopt(_curl, CURLOPT_FTPPORT, "-");
+       }
+       curl_easy_setopt(_curl, CURLOPT_VERBOSE, 1L);
+       curl_easy_setopt(_curl, CURLOPT_DEBUGFUNCTION, curl_debug_shim);
+       curl_easy_setopt(_curl, CURLOPT_DEBUGDATA, this);
 }
 
 
@@ -113,3 +127,14 @@ CurlUploader::read_callback (void* ptr, size_t size, size_t nmemb)
 
        return r;
 }
+
+
+int
+CurlUploader::debug(CURL *, curl_infotype type, char* data, size_t size)
+{
+       if (type == CURLINFO_TEXT && size > 0) {
+               LOG_GENERAL("CurlUploader: %1", string(data, size - 1));
+       }
+       return 0;
+}
+