1 | /* $Id: UINetworkReply.h 98103 2023-01-17 14:15:46Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UINetworkReply stuff declaration.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2012-2023 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
26 | */
|
---|
27 |
|
---|
28 | #ifndef FEQT_INCLUDED_SRC_networking_UINetworkReply_h
|
---|
29 | #define FEQT_INCLUDED_SRC_networking_UINetworkReply_h
|
---|
30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
31 | # pragma once
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | /* Qt includes: */
|
---|
35 | #include <QPointer>
|
---|
36 | #include <QUrl>
|
---|
37 |
|
---|
38 | /* GUI includes: */
|
---|
39 | #include "UILibraryDefs.h"
|
---|
40 | #include "UINetworkDefs.h"
|
---|
41 |
|
---|
42 | /* Forward declarations: */
|
---|
43 | class UINetworkReplyPrivate;
|
---|
44 |
|
---|
45 | /** QObject extension
|
---|
46 | * used as network-reply interface. */
|
---|
47 | class SHARED_LIBRARY_STUFF UINetworkReply : public QObject
|
---|
48 | {
|
---|
49 | Q_OBJECT;
|
---|
50 |
|
---|
51 | signals:
|
---|
52 |
|
---|
53 | /** Notifies listeners about reply progress change.
|
---|
54 | * @param iBytesReceived Holds the current amount of bytes received.
|
---|
55 | * @param iBytesTotal Holds the total amount of bytes to be received. */
|
---|
56 | void downloadProgress(qint64 iBytesReceived, qint64 iBytesTotal);
|
---|
57 |
|
---|
58 | /** Notifies listeners about reply has finished processing. */
|
---|
59 | void finished();
|
---|
60 |
|
---|
61 | public:
|
---|
62 |
|
---|
63 | /** Known error codes.
|
---|
64 | * Came from QtNetwork module.
|
---|
65 | * More to go on demand when necessary. */
|
---|
66 | enum NetworkError
|
---|
67 | {
|
---|
68 | NoError,
|
---|
69 | ConnectionRefusedError,
|
---|
70 | RemoteHostClosedError,
|
---|
71 | UrlNotFoundError,
|
---|
72 | HostNotFoundError,
|
---|
73 | OperationCanceledError,
|
---|
74 | SslHandshakeFailedError,
|
---|
75 | ProxyNotFoundError,
|
---|
76 | ContentAccessDenied,
|
---|
77 | AuthenticationRequiredError,
|
---|
78 | ContentReSendError,
|
---|
79 | UnknownNetworkError,
|
---|
80 | ProtocolFailure,
|
---|
81 | };
|
---|
82 |
|
---|
83 | /** Known header types.
|
---|
84 | * Came from QtNetwork module.
|
---|
85 | * More to go on demand when necessary. */
|
---|
86 | enum KnownHeader
|
---|
87 | {
|
---|
88 | ContentTypeHeader,
|
---|
89 | ContentLengthHeader,
|
---|
90 | LastModifiedHeader,
|
---|
91 | LocationHeader,
|
---|
92 | };
|
---|
93 |
|
---|
94 | /** Constructs network-reply of the passed @a type for the passed @a url, @a strTarget and @a requestHeaders. */
|
---|
95 | UINetworkReply(UINetworkRequestType type, const QUrl &url, const QString &strTarget, const UserDictionary &requestHeaders);
|
---|
96 | /** Destructs reply. */
|
---|
97 | ~UINetworkReply();
|
---|
98 |
|
---|
99 | /** Aborts reply. */
|
---|
100 | void abort();
|
---|
101 |
|
---|
102 | /** Returns the URL of the reply. */
|
---|
103 | QUrl url() const;
|
---|
104 |
|
---|
105 | /** Returns the last cached error of the reply. */
|
---|
106 | NetworkError error() const;
|
---|
107 | /** Returns the user-oriented string corresponding to the last cached error of the reply. */
|
---|
108 | QString errorString() const;
|
---|
109 |
|
---|
110 | /** Returns binary content of the reply. */
|
---|
111 | QByteArray readAll() const;
|
---|
112 | /** Returns value for the cached reply header of the passed @a type. */
|
---|
113 | QVariant header(UINetworkReply::KnownHeader header) const;
|
---|
114 |
|
---|
115 | private:
|
---|
116 |
|
---|
117 | /** Holds the reply private data instance. */
|
---|
118 | UINetworkReplyPrivate *m_pReply;
|
---|
119 | };
|
---|
120 |
|
---|
121 | #endif /* !FEQT_INCLUDED_SRC_networking_UINetworkReply_h */
|
---|
122 |
|
---|