1 | /* $Id: UINetworkReply.h 106061 2024-09-16 14:03:52Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UINetworkReply stuff declaration.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2012-2024 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 <QObject>
|
---|
36 | #include <QPointer>
|
---|
37 | #include <QUrl>
|
---|
38 |
|
---|
39 | /* GUI includes: */
|
---|
40 | #include "UILibraryDefs.h"
|
---|
41 | #include "UINetworkDefs.h"
|
---|
42 |
|
---|
43 | /* Forward declarations: */
|
---|
44 | class UINetworkReplyPrivate;
|
---|
45 |
|
---|
46 | /** QObject extension
|
---|
47 | * used as network-reply interface. */
|
---|
48 | class SHARED_LIBRARY_STUFF UINetworkReply : public QObject
|
---|
49 | {
|
---|
50 | Q_OBJECT;
|
---|
51 |
|
---|
52 | signals:
|
---|
53 |
|
---|
54 | /** Notifies listeners about reply progress change.
|
---|
55 | * @param iBytesReceived Holds the current amount of bytes received.
|
---|
56 | * @param iBytesTotal Holds the total amount of bytes to be received. */
|
---|
57 | void downloadProgress(qint64 iBytesReceived, qint64 iBytesTotal);
|
---|
58 |
|
---|
59 | /** Notifies listeners about reply has finished processing. */
|
---|
60 | void finished();
|
---|
61 |
|
---|
62 | public:
|
---|
63 |
|
---|
64 | /** Known error codes.
|
---|
65 | * Came from QtNetwork module.
|
---|
66 | * More to go on demand when necessary. */
|
---|
67 | enum NetworkError
|
---|
68 | {
|
---|
69 | NoError,
|
---|
70 | ConnectionRefusedError,
|
---|
71 | RemoteHostClosedError,
|
---|
72 | UrlNotFoundError,
|
---|
73 | HostNotFoundError,
|
---|
74 | OperationCanceledError,
|
---|
75 | SslHandshakeFailedError,
|
---|
76 | ProxyNotFoundError,
|
---|
77 | ContentAccessDenied,
|
---|
78 | AuthenticationRequiredError,
|
---|
79 | ContentReSendError,
|
---|
80 | UnknownNetworkError,
|
---|
81 | ProtocolFailure,
|
---|
82 | };
|
---|
83 |
|
---|
84 | /** Known header types.
|
---|
85 | * Came from QtNetwork module.
|
---|
86 | * More to go on demand when necessary. */
|
---|
87 | enum KnownHeader
|
---|
88 | {
|
---|
89 | ContentTypeHeader,
|
---|
90 | ContentLengthHeader,
|
---|
91 | LastModifiedHeader,
|
---|
92 | LocationHeader,
|
---|
93 | };
|
---|
94 |
|
---|
95 | /** Constructs network-reply of the passed @a type for the passed @a url, @a strTarget and @a requestHeaders. */
|
---|
96 | UINetworkReply(UINetworkRequestType type, const QUrl &url, const QString &strTarget, const UserDictionary &requestHeaders);
|
---|
97 | /** Destructs reply. */
|
---|
98 | ~UINetworkReply();
|
---|
99 |
|
---|
100 | /** Aborts reply. */
|
---|
101 | void abort();
|
---|
102 |
|
---|
103 | /** Returns the URL of the reply. */
|
---|
104 | QUrl url() const;
|
---|
105 |
|
---|
106 | /** Returns the last cached error of the reply. */
|
---|
107 | NetworkError error() const;
|
---|
108 | /** Returns the user-oriented string corresponding to the last cached error of the reply. */
|
---|
109 | QString errorString() const;
|
---|
110 |
|
---|
111 | /** Returns binary content of the reply. */
|
---|
112 | QByteArray readAll() const;
|
---|
113 | /** Returns value for the cached reply header of the passed @a type. */
|
---|
114 | QVariant header(UINetworkReply::KnownHeader header) const;
|
---|
115 |
|
---|
116 | private:
|
---|
117 |
|
---|
118 | /** Holds the reply private data instance. */
|
---|
119 | UINetworkReplyPrivate *m_pReply;
|
---|
120 | };
|
---|
121 |
|
---|
122 | #endif /* !FEQT_INCLUDED_SRC_networking_UINetworkReply_h */
|
---|
123 |
|
---|