comparison ui/sslconnection_curl.h @ 910:eaed02defe6a

More SSLConnection refactoring. Fixes curl downloader.
author Andre Heinecke <andre.heinecke@intevation.de>
date Mon, 18 Aug 2014 18:51:33 +0200
parents d1c951b3012d
children 879a634d0a40
comparison
equal deleted inserted replaced
909:18e3ad073b38 910:eaed02defe6a
6 * This file is Free Software under the GNU GPL (v>=2) 6 * This file is Free Software under the GNU GPL (v>=2)
7 * and comes with ABSOLUTELY NO WARRANTY! 7 * and comes with ABSOLUTELY NO WARRANTY!
8 * See LICENSE.txt for details. 8 * See LICENSE.txt for details.
9 */ 9 */
10 10
11 /**
12 * @file sslconnection_curl.h
13 * @brief SSLConnection utilizing libcurl for http.
14 */
15
11 #include "sslconnection.h" 16 #include "sslconnection.h"
12 #include <curl/curl.h> 17 #include <curl/curl.h>
13 18
19 #include <QDateTime>
14 #include <QTemporaryFile> 20 #include <QTemporaryFile>
21
22 class QSaveFile;
15 23
16 class SSLConnectionCurl : public SSLConnection 24 class SSLConnectionCurl : public SSLConnection
17 { 25 {
18 public: 26 public:
19 SSLConnectionCurl(const QString& url, 27 SSLConnectionCurl(const QString& url,
20 const QByteArray& certificate = QByteArray()); 28 const QByteArray& certificate = QByteArray());
21 29
22 ~SSLConnectionCurl(); 30 ~SSLConnectionCurl();
23 31
24 /** @brief write */ 32 int connect();
25 int write(const QByteArray& request);
26 33
27 /** 34 QDateTime getLastModifiedHeader(const QString &resource);
28 * @brief read at most len bytes and reset the connection
29 *
30 * @param [in] len Amount of bytes to read.
31 *
32 * @returns a byte array containing the data or
33 * a NULL byte array on error*/
34 QByteArray read(size_t len);
35 35
36 /** @brief: Establish the connection 36 bool downloadFile(const QString &resource, const QString &filename,
37 * 37 size_t maxSize);
38 * @returns 0 on success otherwise an error or -1 is returned
39 */
40 int connect();
41 private: 38 private:
42 CURL *mCurl; 39 CURL *mCurl;
43 QTemporaryFile mCertFile; 40 QTemporaryFile mCertFile;
41 char mErrBuf[CURL_ERROR_SIZE + 1];
42
43 /** @brief Internal write function for curl */
44 }; 44 };
45 45
46 /** 46 size_t write_data(void *ptr, size_t size, size_t nmemb, QSaveFile *fp);
47 * @file sslconnection_curl.h 47
48 * @brief SSLConnection utilizing libcurl for http.
49 */
50 #endif // UI_SSLCONNECTION_CURL_H 48 #endif // UI_SSLCONNECTION_CURL_H

http://wald.intevation.org/projects/trustbridge/