diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-03-18 14:53:25 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-03-18 14:53:25 +0100 |
commit | 5c01a197f0fd90f611ed376e2165547a72771eb4 (patch) | |
tree | 1a9a057a0852ef67285804a7f02bc8021bb81899 /examples | |
parent | b503f64acd67c77e009a3e13af151d4fae82b994 (diff) | |
download | sink-5c01a197f0fd90f611ed376e2165547a72771eb4.tar.gz sink-5c01a197f0fd90f611ed376e2165547a72771eb4.zip |
Mailtransport
Diffstat (limited to 'examples')
-rw-r--r-- | examples/mailtransportresource/mailtransport.cpp | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/examples/mailtransportresource/mailtransport.cpp b/examples/mailtransportresource/mailtransport.cpp index 985ebcc..84c1556 100644 --- a/examples/mailtransportresource/mailtransport.cpp +++ b/examples/mailtransportresource/mailtransport.cpp | |||
@@ -41,17 +41,17 @@ static size_t payload_source(void *ptr, size_t size, size_t nmemb, void *userp) | |||
41 | struct upload_status *upload_ctx = (struct upload_status *)userp; | 41 | struct upload_status *upload_ctx = (struct upload_status *)userp; |
42 | const char *data; | 42 | const char *data; |
43 | 43 | ||
44 | if((size == 0) || (nmemb == 0) || ((size*nmemb) < 1)) { | 44 | if ((size == 0) || (nmemb == 0) || ((size*nmemb) < 1)) { |
45 | return 0; | 45 | return 0; |
46 | } | 46 | } |
47 | 47 | ||
48 | data = &upload_ctx->data[upload_ctx->offset]; | 48 | data = &upload_ctx->data[upload_ctx->offset]; |
49 | if(data) { | 49 | if (data) { |
50 | size_t len = strlen(data); | 50 | size_t len = strlen(data); |
51 | if (len > size * nmemb) { | 51 | if (len > size * nmemb) { |
52 | len = size * nmemb; | 52 | len = size * nmemb; |
53 | } | 53 | } |
54 | fprintf(stderr, "read n bytes: %d\n", int(len)); | 54 | fprintf(stdout, "read n bytes: %d\n", int(len)); |
55 | memcpy(ptr, data, len); | 55 | memcpy(ptr, data, len); |
56 | upload_ctx->offset += len; | 56 | upload_ctx->offset += len; |
57 | return len; | 57 | return len; |
@@ -69,6 +69,15 @@ static int progress_callback(void *clientp, curl_off_t dltotal, curl_off_t dlnow | |||
69 | return 0; | 69 | return 0; |
70 | } | 70 | } |
71 | 71 | ||
72 | static int debug_callback(CURL *handle, | ||
73 | curl_infotype type, | ||
74 | char *data, | ||
75 | size_t size, | ||
76 | void *userptr) | ||
77 | { | ||
78 | fprintf(stdout, "CURL_DEBUG: %s", data); | ||
79 | return 0; | ||
80 | } | ||
72 | 81 | ||
73 | bool sendMessageCurl(const char *to[], int numTos, const char *cc[], int numCcs, const char *msg, bool useTls, const char* from, const char *username, const char *password, const char *server, bool verifyPeer, const QByteArray &cacert, QByteArray &errorMessage) | 82 | bool sendMessageCurl(const char *to[], int numTos, const char *cc[], int numCcs, const char *msg, bool useTls, const char* from, const char *username, const char *password, const char *server, bool verifyPeer, const QByteArray &cacert, QByteArray &errorMessage) |
74 | { | 83 | { |
@@ -121,11 +130,12 @@ bool sendMessageCurl(const char *to[], int numTos, const char *cc[], int numCcs, | |||
121 | /* Since the traffic will be encrypted, it is very useful to turn on debug | 130 | /* Since the traffic will be encrypted, it is very useful to turn on debug |
122 | * information within libcurl to see what is happening during the transfer. | 131 | * information within libcurl to see what is happening during the transfer. |
123 | */ | 132 | */ |
124 | curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); | 133 | // curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); |
134 | curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, debug_callback); | ||
125 | 135 | ||
126 | // curl_easy_setopt(curl, CURLOPT_TIMEOUT, 1L); | 136 | // curl_easy_setopt(curl, CURLOPT_TIMEOUT, 1L); |
127 | //Connection timeout of 10s | 137 | //Connection timeout of 40s |
128 | curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 10L); | 138 | curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 40L); |
129 | 139 | ||
130 | curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0); | 140 | curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0); |
131 | curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, progress_callback); | 141 | curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, progress_callback); |