CFx SDK Documentation  2020SP3
FxNANetworkReply.h
Go to the documentation of this file.
1 //
2 // (C) Copyright 2005-2020 by Graebert GmbH.
3 //
4 // Permission to use, copy, modify, and distribute this software in
5 // object code form for any purpose and without fee is hereby granted,
6 // provided that the above copyright notice appears in all copies and
7 // that both that copyright notice and the limited warranty and
8 // restricted rights notice below appear in all supporting
9 // documentation.
10 //
11 // GRAEBERT PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
12 // GRAEBERT SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
13 // MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. GRAEBERT GMBH
14 // DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
15 // UNINTERRUPTED OR ERROR FREE.
16 
17 #pragma once
18 
19 #include "../FxCommonFramework.h"
20 #include "../UI/FxUIObject.h"
21 #include "../UI/FxUISignal.h"
22 #include "FxNANetworkRequest.h"
23 
24 #include <QtCore/QByteArray>
25 #include <QtCore/QList>
26 #include <QtCore/QPair>
27 #include <QtCore/QSharedPointer>
28 #include <QtCore/QString>
29 #include <QtCore/QVariant>
30 
31 #include <cstddef>
32 
33 using CFxNAByteArray = QByteArray;
34 template< typename T >
35 using CFxNAList = QList< T >;
36 template< typename T1, typename T2 >
37 using CFxNAPair = QPair< T1, T2 >;
38 using CFxNAString = QString;
39 using CFxNAVariant = QVariant;
40 
45 {
46 public:
51  {
52  NoError = 0,
53 
54  // network layer errors [relating to the destination server] (1-99):
55  ConnectionRefusedError = 1,
66  UnknownNetworkError = 99,
67 
68  // proxy errors (101-199):
69  ProxyConnectionRefusedError = 101,
74  UnknownProxyError = 199,
75 
76  // content errors (201-299):
77  ContentAccessDenied = 201,
84  UnknownContentError = 299,
85 
86  // protocol errors
87  ProtocolUnknownError = 301,
89  ProtocolFailure = 399,
90 
91  // Server side errors (401-499)
92  InternalServerError = 401,
95  UnknownServerError = 499
96  };
97 
103  CFxNANetworkReply() = delete;
104 
106  explicit CFxNANetworkReply( FxNativeHandle nativeReply );
107 
109  CFxNANetworkReply( std::nullptr_t ) = delete;
110 
113 
119  void setRequest( const CFxNANetworkRequest& request );
120 
126  const CFxNANetworkRequest& request() const;
127 
133  bool isFinished() const;
134 
140  bool isRunning() const;
141 
148 
155 
163  long long bytesAvailable() const;
164 
171 
177  long long pos() const;
178 
186  bool seek( long long pos );
187 
196 
205 
213  bool hasRawHeader( const CFxNAByteArray& headerName ) const;
214 
222  CFxNAByteArray rawHeader( const CFxNAByteArray& headerName ) const;
223 
232 
235 
236  // Slots
237 
243  void abort();
244 
245  // Signals
246 
252  CFxUISignal<void( long long bytesReceived, long long bytesTotal )>& downloadProgress();
253 
261  CFxUISignal<void( long long bytesSent, long long bytesTotal )>& uploadProgress();
262 
269 
276 
282  CFxUISignal<void( void )>& finished();
283 
284  //...
285 };
CFxNANetworkReply::OperationNotImplementedError
@ OperationNotImplementedError
the server does not support the functionality required to fulfill the request.
Definition: FxNANetworkReply.h:93
CFxNANetworkReply::header
CFxNAVariant header(CFxNANetworkRequest::KnownHeaders header) const
CFxNANetworkReply::BackgroundRequestNotAllowedError
@ BackgroundRequestNotAllowedError
the background request is not currently allowed due to platform policy.
Definition: FxNANetworkReply.h:63
CFxNANetworkReply::HostNotFoundError
@ HostNotFoundError
the remote host name was not found (invalid hostname)
Definition: FxNANetworkReply.h:57
CFxNANetworkReply::CFxNANetworkReply
CFxNANetworkReply(std::nullptr_t)=delete
CFxNANetworkReply::SslHandshakeFailedError
@ SslHandshakeFailedError
the SSL/TLS handshake failed and the encrypted channel could not be established. The sslErrors() sign...
Definition: FxNANetworkReply.h:60
CFxNANetworkReply::request
const CFxNANetworkRequest & request() const
CFxNANetworkReply::hasRawHeader
bool hasRawHeader(const CFxNAByteArray &headerName) const
CFxNANetworkReply::ProxyConnectionClosedError
@ ProxyConnectionClosedError
the proxy server closed the connection prematurely, before the entire reply was received and processe...
Definition: FxNANetworkReply.h:70
CFxNANetworkReply::abort
void abort()
CFxNANetworkRequest::Attribute
Attribute
Definition: FxNANetworkRequest.h:77
CFxNANetworkReply::error
CFxUISignal< void(NetworkError)> & error()
CFxNANetworkReply::isFinished
bool isFinished() const
CFxNANetworkReply::NetworkError
NetworkError
Definition: FxNANetworkReply.h:51
CFxNANetworkReply::error
NetworkError error() const
CFxNANetworkReply::isRunning
bool isRunning() const
CFxNANetworkReply::downloadProgress
CFxUISignal< void(long long bytesReceived, long long bytesTotal)> & downloadProgress()
CFxNANetworkReply
Definition: FxNANetworkReply.h:45
CFxNANetworkReply::ProtocolInvalidOperationError
@ ProtocolInvalidOperationError
the requested operation is invalid for this protocol
Definition: FxNANetworkReply.h:88
CFxUISignal
Definition: FxUISignal.h:74
CFxNANetworkRequest
Definition: FxNANetworkRequest.h:54
CFxNANetworkReply::RemoteHostClosedError
@ RemoteHostClosedError
the remote server closed the connection prematurely, before the entire reply was received and process...
Definition: FxNANetworkReply.h:56
CFxNANetworkReply::ServiceUnavailableError
@ ServiceUnavailableError
the server is unable to handle the request at this time.
Definition: FxNANetworkReply.h:94
CFxNAString
QString CFxNAString
Definition: FxNANetworkReply.h:38
CFxNANetworkReply::AuthenticationRequiredError
@ AuthenticationRequiredError
the remote server requires authentication to serve the content but the credentials provided were not ...
Definition: FxNANetworkReply.h:80
CFxNANetworkReply::ContentGoneError
@ ContentGoneError
the requested resource is no longer available at the server.
Definition: FxNANetworkReply.h:83
CFxNANetworkReply::seek
bool seek(long long pos)
CFxNAByteArray
QByteArray CFxNAByteArray
Definition: FxNANetworkAccessManager.h:32
CFxNANetworkReply::ContentReSendError
@ ContentReSendError
the request needed to be sent again, but this failed for example because the upload data could not be...
Definition: FxNANetworkReply.h:81
CFxNANetworkReply::attribute
CFxNAVariant attribute(CFxNANetworkRequest::Attribute code) const
CFxNANetworkReply::setRequest
void setRequest(const CFxNANetworkRequest &request)
CFxNANetworkReply::finished
CFxUISignal< void(void)> & finished()
CFxNANetworkReply::rawHeaderList
CFxNAList< CFxNAByteArray > rawHeaderList() const
CFxNANetworkReply::CFxNANetworkReply
CFxNANetworkReply()=delete
CFxNANetworkReply::ProxyNotFoundError
@ ProxyNotFoundError
the proxy host name was not found (invalid proxy hostname)
Definition: FxNANetworkReply.h:71
CFxNANetworkRequest::KnownHeaders
KnownHeaders
Definition: FxNANetworkRequest.h:61
CFxNANetworkReply::TimeoutError
@ TimeoutError
the connection to the remote server timed out
Definition: FxNANetworkReply.h:58
CFxNANetworkReply::rawHeaderPairs
const CFxNAList< RawHeaderPair > & rawHeaderPairs() const
CFxNANetworkReply::InsecureRedirectError
@ InsecureRedirectError
while following redirects, the network access API detected a redirect from a encrypted protocol (http...
Definition: FxNANetworkReply.h:65
CFxNANetworkReply::errorString
CFxNAString errorString() const
FxNativeHandle
QObject * FxNativeHandle
Definition: FxUIObject.h:89
CFxNAList
QList< T > CFxNAList
Definition: FxNANetworkReply.h:35
CFxNANetworkReply::uploadProgress
CFxUISignal< void(long long bytesSent, long long bytesTotal)> & uploadProgress()
CFxNANetworkReply::TooManyRedirectsError
@ TooManyRedirectsError
while following redirects, the maximum limit was reached.
Definition: FxNANetworkReply.h:64
CFxNANetworkReply::encrypted
CFxUISignal< void(void)> & encrypted()
CFxNANetworkReply::ContentNotFoundError
@ ContentNotFoundError
the remote content was not found at the server (similar to HTTP error 404)
Definition: FxNANetworkReply.h:79
COMMONUI_API
#define COMMONUI_API
Definition: FxCommonFramework.h:4
CFxNANetworkReply::pos
long long pos() const
CFxNAPair
QPair< T1, T2 > CFxNAPair
Definition: FxNANetworkReply.h:37
CFxNANetworkReply::ContentConflictError
@ ContentConflictError
the request could not be completed due to a conflict with the current state of the resource.
Definition: FxNANetworkReply.h:82
CFxNANetworkReply::OperationCanceledError
@ OperationCanceledError
the operation was canceled via calls to abort() or close() before it was finished.
Definition: FxNANetworkReply.h:59
FxNANetworkRequest.h
CFxNAVariant
QVariant CFxNAVariant
Definition: FxNANetworkReply.h:39
CFxNANetworkReply::bytesAvailable
long long bytesAvailable() const
CFxNANetworkReply::ContentOperationNotPermittedError
@ ContentOperationNotPermittedError
the operation requested on the remote content is not permitted
Definition: FxNANetworkReply.h:78
CFxNANetworkReply::ProxyAuthenticationRequiredError
@ ProxyAuthenticationRequiredError
the proxy requires authentication in order to honour the request but did not accept any credentials o...
Definition: FxNANetworkReply.h:73
CFxNANetworkReply::ProxyTimeoutError
@ ProxyTimeoutError
the connection to the proxy timed out or the proxy did not reply in time to the request sent
Definition: FxNANetworkReply.h:72
CFxNANetworkReply::CFxNANetworkReply
CFxNANetworkReply(FxNativeHandle nativeReply)
CFxNANetworkReply::rawHeader
CFxNAByteArray rawHeader(const CFxNAByteArray &headerName) const
CFxUIObject
Definition: FxUIObject.h:101
void
typedef void(APIENTRYP PFNGLACTIVETEXTUREPROC)(GLenum texture)
CFxNANetworkReply::readAll
CFxNAByteArray readAll()
CFxNANetworkReply::NetworkSessionFailedError
@ NetworkSessionFailedError
the connection was broken due to disconnection from the network or failure to start the network.
Definition: FxNANetworkReply.h:62
CFxNANetworkReply::RawHeaderPair
CFxNAPair< CFxNAByteArray, CFxNAByteArray > RawHeaderPair
Definition: FxNANetworkReply.h:233
CFxNANetworkReply::TemporaryNetworkFailureError
@ TemporaryNetworkFailureError
the connection was broken due to disconnection from the network, however the system has initiated roa...
Definition: FxNANetworkReply.h:61
CFxNANetworkReply::~CFxNANetworkReply
~CFxNANetworkReply()