Mercurial > trustbridge
comparison ui/downloader.h @ 32:d8e93fa1fc93
Downloader logic
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Wed, 12 Mar 2014 21:26:07 +0100 |
parents | 62cd56cea09b |
children | c6125d73faf4 |
comparison
equal
deleted
inserted
replaced
31:37fc66967517 | 32:d8e93fa1fc93 |
---|---|
47 ~Downloader(); | 47 ~Downloader(); |
48 | 48 |
49 enum ErrorCode { | 49 enum ErrorCode { |
50 NoError, | 50 NoError, |
51 NoConnection, | 51 NoConnection, |
52 SSLHandshakeFailed, | |
52 InvalidCertificate, | 53 InvalidCertificate, |
53 InvalidPinnedCertificate, | 54 InvalidPinnedCertificate, |
55 InvalidResponse, | |
54 ConnectionLost, | 56 ConnectionLost, |
55 Timeout, | 57 Timeout, |
56 ErrUnknown | 58 ErrUnknown |
57 }; | 59 }; |
58 | 60 |
90 /* Convienience to avoid having to parse all | 92 /* Convienience to avoid having to parse all |
91 * PolarSSL errors */ | 93 * PolarSSL errors */ |
92 ErrorCode mErrorState; | 94 ErrorCode mErrorState; |
93 | 95 |
94 bool mInitialized; | 96 bool mInitialized; |
97 bool mConnectionEstablished; | |
95 | 98 |
96 int mServerFD; | 99 int mServerFD; |
97 | 100 |
98 | 101 |
99 /* @brief: Initialize polarssl structures | 102 /* @brief: Initialize polarssl structures |
104 * | 107 * |
105 * @returns: 0 on success a polarssl error otherwise. | 108 * @returns: 0 on success a polarssl error otherwise. |
106 */ | 109 */ |
107 int init(); | 110 int init(); |
108 | 111 |
109 /** @brief: Establish the connection | 112 /** @brief: Establish the ssl connection |
113 * | |
114 * Modifies the error state. Before calling this the mServerFD should | |
115 * be set to a valid socket. | |
110 * | 116 * |
111 * @returns 0 on success otherwise a polarssl error or -1 is returned | 117 * @returns 0 on success otherwise a polarssl error or -1 is returned |
112 */ | 118 */ |
113 int establishSSLConnection(); | 119 int establishSSLConnection(); |
114 #ifdef Q_OS_WIN | 120 |
115 #endif | 121 /** @brief get the last modified header of a resource. |
122 * | |
123 * Connection should be established beforehand. | |
124 * Modifies the error state. | |
125 * | |
126 * @param[in] resource The resource to check | |
127 * | |
128 * @returns the last modified date or a null datetime in case of errors | |
129 */ | |
130 QDateTime getLastModifiedHeader(const QString &resource); | |
131 | |
132 /** @brief Download resource | |
133 * | |
134 * Download a resource with the established connection. | |
135 * Modifies the error state. | |
136 * | |
137 * @param[in] resource the resource to download | |
138 * @param[in] filename where the file should be saved. | |
139 * @param[in] maxSize maximum amount of bytes to download | |
140 * | |
141 * @returns True if the download was successful. | |
142 */ | |
143 bool downloadFile(const QString &resource, const QString &filename, | |
144 size_t maxSize); | |
116 | 145 |
117 Q_SIGNALS: | 146 Q_SIGNALS: |
118 /** | 147 /** |
119 * @brief software update is available | 148 * @brief software update is available |
120 */ | 149 */ |