diff 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
line wrap: on
line diff
--- a/ui/downloader.h	Thu Mar 13 18:12:16 2014 +0000
+++ b/ui/downloader.h	Wed Mar 12 21:26:07 2014 +0100
@@ -49,8 +49,10 @@
     enum ErrorCode {
         NoError,
         NoConnection,
+        SSLHandshakeFailed,
         InvalidCertificate,
         InvalidPinnedCertificate,
+        InvalidResponse,
         ConnectionLost,
         Timeout,
         ErrUnknown
@@ -92,6 +94,7 @@
     ErrorCode mErrorState;
 
     bool mInitialized;
+    bool mConnectionEstablished;
 
     int mServerFD;
 
@@ -106,13 +109,39 @@
      */
     int init();
 
-    /** @brief: Establish the connection
+    /** @brief: Establish the ssl connection
+     *
+     * Modifies the error state. Before calling this the mServerFD should
+     * be set to a valid socket.
      *
      * @returns 0 on success otherwise a polarssl error or -1 is returned
      */
     int establishSSLConnection();
-#ifdef Q_OS_WIN
-#endif
+
+    /** @brief get the last modified header of a resource.
+     *
+     * Connection should be established beforehand.
+     * Modifies the error state.
+     *
+     * @param[in] resource The resource to check
+     *
+     * @returns the last modified date or a null datetime in case of errors
+     */
+    QDateTime getLastModifiedHeader(const QString &resource);
+
+    /** @brief Download resource
+     *
+     * Download a resource with the established connection.
+     * Modifies the error state.
+     *
+     * @param[in] resource the resource to download
+     * @param[in] filename where the file should be saved.
+     * @param[in] maxSize maximum amount of bytes to download
+     *
+     * @returns True if the download was successful.
+     */
+    bool downloadFile(const QString &resource, const QString &filename,
+                      size_t maxSize);
 
 Q_SIGNALS:
     /**

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