3
* VBox frontends: Qt GUI ("VirtualBox"):
4
* UIDownloader class declaration
8
* Copyright (C) 2006-2012 Oracle Corporation
10
* This file is part of VirtualBox Open Source Edition (OSE), as
11
* available from http://www.virtualbox.org. This file is free software;
12
* you can redistribute it and/or modify it under the terms of the GNU
13
* General Public License (GPL) as published by the Free Software
14
* Foundation, in version 2 as it comes in the "COPYING" file of the
15
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
19
#ifndef __UIDownloader_h__
20
#define __UIDownloader_h__
22
/* Global includes: */
27
#include "UINetworkDefs.h"
28
#include "UINetworkCustomer.h"
30
/* Forward declarations: */
33
/* Downloader interface.
34
* UINetworkCustomer class extension which allows background http downloading. */
35
class UIDownloader : public UINetworkCustomer
41
/* Signal to start acknowledging: */
42
void sigToStartAcknowledging();
43
/* Signal to start downloading: */
44
void sigToStartDownloading();
48
/* Starting routine: */
53
/* Acknowledging part: */
54
void sltStartAcknowledging();
55
/* Downloading part: */
56
void sltStartDownloading();
60
/* UIDownloader states: */
61
enum UIDownloaderState
63
UIDownloaderState_Null,
64
UIDownloaderState_Acknowledging,
65
UIDownloaderState_Downloading
72
* allows to set/get one or more sources to try to download from: */
73
void addSource(const QString &strSource) { m_sources << QUrl(strSource); }
74
void setSource(const QString &strSource) { m_sources.clear(); addSource(strSource); }
75
const QList<QUrl>& sources() const { return m_sources; }
76
const QUrl& source() const { return m_source; }
79
* allows to set/get downloaded file destination: */
80
void setTarget(const QString &strTarget) { m_strTarget = strTarget; }
81
const QString& target() const { return m_strTarget; }
84
* allows to set/get Network Customer description for Network Access Manager: */
85
void setDescription(const QString &strDescription) { m_strDescription = strDescription; }
87
/* Start delayed acknowledging: */
88
void startDelayedAcknowledging() { emit sigToStartAcknowledging(); }
89
/* Start delayed downloading: */
90
void startDelayedDownloading() { emit sigToStartDownloading(); }
92
/* Network-reply progress handler: */
93
void processNetworkReplyProgress(qint64 iReceived, qint64 iTotal);
94
/* Network-reply cancel handler: */
95
void processNetworkReplyCanceled(UINetworkReply *pNetworkReply);
96
/* Network-reply finish handler: */
97
void processNetworkReplyFinished(UINetworkReply *pNetworkReply);
99
/* Handle acknowledging result: */
100
virtual void handleAcknowledgingResult(UINetworkReply *pNetworkReply);
101
/* Handle downloading result: */
102
virtual void handleDownloadingResult(UINetworkReply *pNetworkReply);
104
/* Pure virtual function to ask user about downloading confirmation: */
105
virtual bool askForDownloadingConfirmation(UINetworkReply *pNetworkReply) = 0;
106
/* Pure virtual function to handle downloaded object: */
107
virtual void handleDownloadedObject(UINetworkReply *pNetworkReply) = 0;
111
/* Private variables: */
112
UIDownloaderState m_state;
113
QList<QUrl> m_sources;
116
QString m_strDescription;
119
#endif // __UIDownloader_h__