comparison ui/sslconnection.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
49 mServerFD(-1), 49 mServerFD(-1),
50 mErrorState(NoError) {}; 50 mErrorState(NoError) {};
51 51
52 virtual ~SSLConnection() {}; 52 virtual ~SSLConnection() {};
53 53
54 /** @brief write */
55 virtual int write(const QByteArray& request) = 0;
56
57 /**
58 * @brief read at most len bytes and reset the connection
59 *
60 * @param [in] len Amount of bytes to read.
61 *
62 * @returns a byte array containing the data or
63 * a NULL byte array on error*/
64 virtual QByteArray read(size_t len) = 0;
65
66 bool initialized() { return mInitialized; } 54 bool initialized() { return mInitialized; }
67 bool connected() { return mConnected; } 55 bool connected() { return mConnected; }
68 56
69 ErrorCode getLastError() { return mErrorState; } 57 ErrorCode getLastError() { return mErrorState; }
70 58
72 * 60 *
73 * @returns 0 on success otherwise an error or -1 is returned 61 * @returns 0 on success otherwise an error or -1 is returned
74 */ 62 */
75 virtual int connect() = 0; 63 virtual int connect() = 0;
76 64
65 /** @brief get the last modified header of a resource.
66 *
67 * Connection should be established beforehand.
68 * Modifies the error state.
69 *
70 * @param[in] resource The resource to check
71 *
72 * @returns the last modified date or a null datetime in case of errors
73 */
74 virtual QDateTime getLastModifiedHeader(const QString &resource) = 0;
75
76 /** @brief Download resource
77 *
78 * Download a resource with the established connection.
79 * Modifies the error state.
80 *
81 * @param[in] resource the resource to download
82 * @param[in] filename where the file should be saved.
83 * @param[in] maxSize maximum amount of bytes to download
84 *
85 * @returns True if the download was successful.
86 */
87 virtual bool downloadFile(const QString &resource, const QString &filename,
88 size_t maxSize) = 0;
77 protected: 89 protected:
78 QUrl mUrl; 90 QUrl mUrl;
79 QByteArray mPinnedCert; 91 QByteArray mPinnedCert;
80 bool mInitialized; 92 bool mInitialized;
81 bool mConnected; /* A connection was established */ 93 bool mConnected; /* A connection was established */

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