1 | /** @file
|
---|
2 | *
|
---|
3 | * VBox frontends: Qt GUI ("VirtualBox"):
|
---|
4 | * VBoxDownloaderWgt class declaration
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2006-2007 innotek GmbH
|
---|
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 as published by the Free Software Foundation,
|
---|
14 | * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
15 | * distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
16 | * be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | */
|
---|
18 |
|
---|
19 | #ifndef __VBoxDownloaderWgt_h__
|
---|
20 | #define __VBoxDownloaderWgt_h__
|
---|
21 |
|
---|
22 | #include "qwidget.h"
|
---|
23 | #include "qurl.h"
|
---|
24 | class QStatusBar;
|
---|
25 | class QAction;
|
---|
26 | class QHttpResponseHeader;
|
---|
27 | class QHttp;
|
---|
28 | class QProgressBar;
|
---|
29 | class QToolButton;
|
---|
30 |
|
---|
31 | /** class VBoxDownloaderWgt
|
---|
32 | *
|
---|
33 | * The VBoxDownloaderWgt class is an QWidget class for Guest Additions
|
---|
34 | * http backgroung downloading. This class is also used to display the
|
---|
35 | * Guest Additions download state through the progress dialog integrated
|
---|
36 | * into the VM console status bar.
|
---|
37 | */
|
---|
38 | class VBoxDownloaderWgt : public QWidget
|
---|
39 | {
|
---|
40 | Q_OBJECT
|
---|
41 |
|
---|
42 | public:
|
---|
43 |
|
---|
44 | VBoxDownloaderWgt (QStatusBar *aStatusBar, QAction *aAction,
|
---|
45 | const QString &aUrl, const QString &aTarget);
|
---|
46 |
|
---|
47 | void languageChange();
|
---|
48 |
|
---|
49 | private slots:
|
---|
50 |
|
---|
51 | /* This slot is used to handle the progress of the file-downloading
|
---|
52 | * procedure. It also checks the downloading status for the file
|
---|
53 | * presence verifying purposes. */
|
---|
54 | void processProgress (int aRead, int aTotal);
|
---|
55 |
|
---|
56 | /* This slot is used to handle the finish signal of every operation's
|
---|
57 | * response. It is used to display the errors occurred during the download
|
---|
58 | * operation and for the received-buffer serialization procedure. */
|
---|
59 | void processFinished (int, bool aError);
|
---|
60 |
|
---|
61 | /* This slot is used to handle the header responses about the
|
---|
62 | * requested operations. Watches for the header's status-code. */
|
---|
63 | void processResponse (const QHttpResponseHeader &aHeader);
|
---|
64 |
|
---|
65 | /* This slot is used to control the connection timeout. */
|
---|
66 | void processTimeout();
|
---|
67 |
|
---|
68 | /* This slot is used to process cancel-button clicking signal. */
|
---|
69 | void processAbort();
|
---|
70 |
|
---|
71 | /* This slot is used to terminate the downloader, activate the
|
---|
72 | * Install Guest Additions action and removing the downloader's
|
---|
73 | * sub-widgets from the VM Console status-bar. */
|
---|
74 | void suicide();
|
---|
75 |
|
---|
76 | private:
|
---|
77 |
|
---|
78 | /* This function is used to make a request to get a file */
|
---|
79 | void getFile();
|
---|
80 |
|
---|
81 | /* This function is used to ask the user about he wants to download the
|
---|
82 | * founded Guest Additions image or not. It also shows the progress-bar
|
---|
83 | * and Cancel-button widgets. */
|
---|
84 | void processFile (int aSize);
|
---|
85 |
|
---|
86 | /* This wrapper displays an error message box (unless @aReason is
|
---|
87 | * QString::null) with the cause of the download procedure
|
---|
88 | * termination. After the message box is dismissed, the downloader signals
|
---|
89 | * to close itself on the next event loop iteration. */
|
---|
90 | void abortDownload (const QString &aReason = QString::null);
|
---|
91 |
|
---|
92 | QStatusBar *mStatusBar;
|
---|
93 | QUrl mUrl;
|
---|
94 | QString mTarget;
|
---|
95 | QHttp *mHttp;
|
---|
96 | bool mIsChecking;
|
---|
97 | QProgressBar *mProgressBar;
|
---|
98 | QToolButton *mCancelButton;
|
---|
99 | QAction *mAction;
|
---|
100 | int mStatus;
|
---|
101 | bool mConnectDone;
|
---|
102 | bool mSuicide;
|
---|
103 | };
|
---|
104 |
|
---|
105 | #endif
|
---|
106 |
|
---|