1 | /** @file
|
---|
2 | *
|
---|
3 | * VBox frontends: Qt GUI ("VirtualBox"):
|
---|
4 | * UIDownloader class declaration
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2006-2007 Oracle Corporation
|
---|
9 | *
|
---|
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.
|
---|
17 | */
|
---|
18 |
|
---|
19 | #ifndef __UIDownloader_h__
|
---|
20 | #define __UIDownloader_h__
|
---|
21 |
|
---|
22 | /* Global includes */
|
---|
23 | #include <QUrl>
|
---|
24 | #include <QWidget>
|
---|
25 |
|
---|
26 | /* Local forward declarations */
|
---|
27 | class QIHttp;
|
---|
28 | class UIMiniCancelButton;
|
---|
29 |
|
---|
30 | /* Global forward declarations */
|
---|
31 | class QHttpResponseHeader;
|
---|
32 | class QProgressBar;
|
---|
33 |
|
---|
34 | class UIMiniProcessWidget : public QWidget
|
---|
35 | {
|
---|
36 | Q_OBJECT;
|
---|
37 |
|
---|
38 | public:
|
---|
39 |
|
---|
40 | UIMiniProcessWidget(QWidget *pParent = 0);
|
---|
41 |
|
---|
42 | void setCancelButtonText(const QString &strText);
|
---|
43 | QString cancelButtonText() const;
|
---|
44 |
|
---|
45 | void setCancelButtonToolTip(const QString &strText);
|
---|
46 | QString cancelButtonToolTip() const;
|
---|
47 |
|
---|
48 | void setProgressBarToolTip(const QString &strText);
|
---|
49 | QString progressBarToolTip() const;
|
---|
50 |
|
---|
51 | void setSource(const QString &strSource);
|
---|
52 | QString source() const;
|
---|
53 |
|
---|
54 | signals:
|
---|
55 |
|
---|
56 | void sigCancel();
|
---|
57 |
|
---|
58 | public slots:
|
---|
59 |
|
---|
60 | virtual void sltProcess(int cDone, int cTotal);
|
---|
61 |
|
---|
62 | private:
|
---|
63 |
|
---|
64 | /* Private member vars */
|
---|
65 | QProgressBar *m_pProgressBar;
|
---|
66 | UIMiniCancelButton *m_pCancelButton;
|
---|
67 |
|
---|
68 | QString m_strSource;
|
---|
69 | };
|
---|
70 |
|
---|
71 | /**
|
---|
72 | * The UIDownloader class is QWidget class re-implementation which embeds
|
---|
73 | * into the Dialog's status-bar and allows background http downloading.
|
---|
74 | * This class is not supposed to be used itself and made for sub-classing only.
|
---|
75 | *
|
---|
76 | * This class has two parts:
|
---|
77 | * 1. Acknowledging (getting information about target presence and size).
|
---|
78 | * 2. Downloading (starting and handling file downloading process).
|
---|
79 | * Every subclass can determine using or not those two parts and handling
|
---|
80 | * the result of those parts itself.
|
---|
81 | */
|
---|
82 | class UIDownloader : public QObject
|
---|
83 | {
|
---|
84 | Q_OBJECT;
|
---|
85 |
|
---|
86 | public:
|
---|
87 |
|
---|
88 | UIDownloader();
|
---|
89 |
|
---|
90 | virtual void setSource(const QString &strSource);
|
---|
91 | virtual QString source() const;
|
---|
92 | virtual void setTarget(const QString &strTarget);
|
---|
93 | virtual QString target() const;
|
---|
94 |
|
---|
95 | virtual void startDownload() = 0;
|
---|
96 |
|
---|
97 | signals:
|
---|
98 |
|
---|
99 | void sigDownloadProcess(int cDone, int cTotal);
|
---|
100 | void sigFinished();
|
---|
101 |
|
---|
102 | protected slots:
|
---|
103 |
|
---|
104 | /* Acknowledging part */
|
---|
105 | virtual void acknowledgeStart();
|
---|
106 | virtual void acknowledgeProcess(const QHttpResponseHeader &response);
|
---|
107 | virtual void acknowledgeFinished(bool fError);
|
---|
108 |
|
---|
109 | /* Downloading part */
|
---|
110 | virtual void downloadStart();
|
---|
111 | virtual void downloadProcess(int cDone, int cTotal);
|
---|
112 | virtual void downloadFinished(bool fError);
|
---|
113 |
|
---|
114 | /* Common slots */
|
---|
115 | virtual void cancelDownloading();
|
---|
116 | virtual void abortDownload(const QString &strError);
|
---|
117 | virtual void suicide();
|
---|
118 |
|
---|
119 | protected:
|
---|
120 |
|
---|
121 | /* In sub-class this function will show the user downloading object size
|
---|
122 | * and ask him about downloading confirmation. Returns user response. */
|
---|
123 | virtual bool confirmDownload() = 0;
|
---|
124 |
|
---|
125 | /* In sub-class this function will show the user which error happens
|
---|
126 | * in context of downloading file and executing his request. */
|
---|
127 | virtual void warnAboutError(const QString &strError) = 0;
|
---|
128 |
|
---|
129 | QUrl m_source;
|
---|
130 | QString m_strTarget;
|
---|
131 | QIHttp *m_pHttp;
|
---|
132 | };
|
---|
133 |
|
---|
134 | #endif // __UIDownloader_h__
|
---|
135 |
|
---|