1 | /* $Id: UINetworkRequest.h 78665 2019-05-22 15:27:01Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UINetworkRequest class declaration.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2011-2019 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #ifndef FEQT_INCLUDED_SRC_net_UINetworkRequest_h
|
---|
19 | #define FEQT_INCLUDED_SRC_net_UINetworkRequest_h
|
---|
20 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
21 | # pragma once
|
---|
22 | #endif
|
---|
23 |
|
---|
24 | /* Qt includes: */
|
---|
25 | #include <QUuid>
|
---|
26 | #include <QPointer>
|
---|
27 |
|
---|
28 | /* GUI inludes: */
|
---|
29 | #include "UILibraryDefs.h"
|
---|
30 | #include "UINetworkDefs.h"
|
---|
31 | #include "UINetworkReply.h"
|
---|
32 |
|
---|
33 | /* Forward declarations: */
|
---|
34 | class UINetworkManager;
|
---|
35 | class UINetworkManagerDialog;
|
---|
36 | class UINetworkManagerIndicator;
|
---|
37 | class UINetworkRequestWidget;
|
---|
38 | class UINetworkCustomer;
|
---|
39 |
|
---|
40 | /** QObject extension used as network-request container. */
|
---|
41 | class SHARED_LIBRARY_STUFF UINetworkRequest : public QObject
|
---|
42 | {
|
---|
43 | Q_OBJECT;
|
---|
44 |
|
---|
45 | signals:
|
---|
46 |
|
---|
47 | /** Notifies common UINetworkManager about progress with @a uuid changed.
|
---|
48 | * @param iReceived Holds the amount of bytes received.
|
---|
49 | * @param iTotal Holds the amount of total bytes to receive. */
|
---|
50 | void sigProgress(const QUuid &uuid, qint64 iReceived, qint64 iTotal);
|
---|
51 | /** Notifies UINetworkManager about progress with @a uuid started. */
|
---|
52 | void sigStarted(const QUuid &uuid);
|
---|
53 | /** Notifies UINetworkManager about progress with @a uuid canceled. */
|
---|
54 | void sigCanceled(const QUuid &uuid);
|
---|
55 | /** Notifies UINetworkManager about progress with @a uuid finished. */
|
---|
56 | void sigFinished(const QUuid &uuid);
|
---|
57 | /** Notifies UINetworkManager about progress with @a uuid failed with @a strError. */
|
---|
58 | void sigFailed(const QUuid &uuid, const QString &strError);
|
---|
59 |
|
---|
60 | /** Notifies own UINetworkRequestWidget about progress changed.
|
---|
61 | * @param iReceived Holds the amount of bytes received.
|
---|
62 | * @param iTotal Holds the amount of total bytes to receive. */
|
---|
63 | void sigProgress(qint64 iReceived, qint64 iTotal);
|
---|
64 | /** Notifies own UINetworkRequestWidget about progress started. */
|
---|
65 | void sigStarted();
|
---|
66 | /** Notifies own UINetworkRequestWidget about progress finished. */
|
---|
67 | void sigFinished();
|
---|
68 | /** Notifies own UINetworkRequestWidget about progress failed with @a strError. */
|
---|
69 | void sigFailed(const QString &strError);
|
---|
70 |
|
---|
71 | public:
|
---|
72 |
|
---|
73 | /** Constructs network-request of the passed @a enmType
|
---|
74 | * on the basis of the passed @a urls, @a strTarget and the @a requestHeaders
|
---|
75 | * for the @a pCustomer and @a pNetworkManager specified. */
|
---|
76 | UINetworkRequest(UINetworkRequestType enmType,
|
---|
77 | const QList<QUrl> &urls,
|
---|
78 | const QString &strTarget,
|
---|
79 | const UserDictionary &requestHeaders,
|
---|
80 | UINetworkCustomer *pCustomer,
|
---|
81 | UINetworkManager *pNetworkManager);
|
---|
82 | /** Destructs network-request. */
|
---|
83 | ~UINetworkRequest();
|
---|
84 |
|
---|
85 | /** Returns the request description. */
|
---|
86 | const QString description() const;
|
---|
87 | /** Returns the request customer. */
|
---|
88 | UINetworkCustomer* customer() { return m_pCustomer; }
|
---|
89 | /** Returns the request manager. */
|
---|
90 | UINetworkManager* manager() const { return m_pNetworkManager; }
|
---|
91 | /** Returns unique request QUuid. */
|
---|
92 | const QUuid& uuid() const { return m_uuid; }
|
---|
93 | /** Returns the request reply. */
|
---|
94 | UINetworkReply* reply() { return m_pReply; }
|
---|
95 |
|
---|
96 | public slots:
|
---|
97 |
|
---|
98 | /** Initiates request retrying. */
|
---|
99 | void sltRetry();
|
---|
100 | /** Initiates request cancelling. */
|
---|
101 | void sltCancel();
|
---|
102 |
|
---|
103 | private slots:
|
---|
104 |
|
---|
105 | /** Handles reply about progress changed.
|
---|
106 | * @param iReceived Brings the amount of bytes received.
|
---|
107 | * @param iTotal Brings the amount of total bytes to receive. */
|
---|
108 | void sltHandleNetworkReplyProgress(qint64 iReceived, qint64 iTotal);
|
---|
109 | /** Handles reply about progress finished. */
|
---|
110 | void sltHandleNetworkReplyFinish();
|
---|
111 |
|
---|
112 | private:
|
---|
113 |
|
---|
114 | /** Prepares request. */
|
---|
115 | void prepare();
|
---|
116 | /** Prepares request's reply. */
|
---|
117 | void prepareNetworkReply();
|
---|
118 |
|
---|
119 | /** Cleanups request's reply. */
|
---|
120 | void cleanupNetworkReply();
|
---|
121 | /** Cleanups request. */
|
---|
122 | void cleanup();
|
---|
123 |
|
---|
124 | /** Holds the request type. */
|
---|
125 | const UINetworkRequestType m_enmType;
|
---|
126 | /** Holds the request urls. */
|
---|
127 | const QList<QUrl> m_urls;
|
---|
128 | /** Holds the request target. */
|
---|
129 | const QString m_strTarget;
|
---|
130 | /** Holds the request headers. */
|
---|
131 | const UserDictionary m_requestHeaders;
|
---|
132 | /** Holds the request customer. */
|
---|
133 | UINetworkCustomer *m_pCustomer;
|
---|
134 | /** Holds the request manager. */
|
---|
135 | UINetworkManager *m_pNetworkManager;
|
---|
136 | /** Holds unique request QUuid. */
|
---|
137 | const QUuid m_uuid;
|
---|
138 |
|
---|
139 | /** Holds current request url. */
|
---|
140 | QUrl m_url;
|
---|
141 | /** Holds index of current request url. */
|
---|
142 | int m_iUrlIndex;
|
---|
143 | /** Holds whether current request url is in progress. */
|
---|
144 | bool m_fRunning;
|
---|
145 |
|
---|
146 | /** Holds the request reply. */
|
---|
147 | QPointer<UINetworkReply> m_pReply;
|
---|
148 | };
|
---|
149 |
|
---|
150 | #endif /* !FEQT_INCLUDED_SRC_net_UINetworkRequest_h */
|
---|
151 |
|
---|