OpendTect  6.3
i_odhttpconn.h
Go to the documentation of this file.
1 #ifndef qnetworkaccessconn_h
2 #define qnetworkaccessconn_h
3 
4 /*+
5 ________________________________________________________________________
6 
7  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
8  Author: Nanne Hemstra
9  Date: January 2012
10 ________________________________________________________________________
11 
12 -*/
13 
14 
15 #include "odhttp.h"
16 
17 #include <QNetworkAccessManager>
18 #include <QNetworkReply>
19 #include <QNetworkRequest>
20 #include <QEvent>
21 #include <ptrman.h>
22 #include <thread.h>
23 
24 QT_BEGIN_NAMESPACE
25 
26 
27 class QNetworkReplyConn : public QObject
28 {
29 public:
30  static void setReadEventType(int);
31 
32 private:
33  Q_OBJECT
35  static int readeventtype;
36 
37 protected:
38 
39 QNetworkReplyConn( QNetworkReply* sndr, Network::HttpRequestProcess* rec )
40  : sender_(sndr), receiver_(rec)
41 {
42  connect( sender_, SIGNAL(downloadProgress(qint64,qint64)),
43  this, SLOT(downloadProgress(qint64,qint64)) );
44  connect( sender_, SIGNAL(sslErrors(const QList<QSslError> &)),
45  this, SLOT(sslErrors(const QList<QSslError> &)) );
46  connect( sender_, SIGNAL(error(QNetworkReply::NetworkError)),
47  this, SLOT(error(QNetworkReply::NetworkError)) );
48  connect( sender_, SIGNAL(finished()),
49  this, SLOT(finished()) );
50  connect( sender_, SIGNAL(metaDataChanged()),
51  this, SLOT(metaDataChanged()) );
52  connect( sender_, SIGNAL(uploadProgress(qint64,qint64)),
53  this, SLOT(uploadProgress(qint64,qint64)) );
54 
55  // From QIODevice
56  connect( sender_, SIGNAL(aboutToClose()),
57  this, SLOT(aboutToClose()) );
58  connect( sender_, SIGNAL(bytesWritten(qint64)),
59  this, SLOT(bytesWritten(qint64)) );
60  connect( sender_, SIGNAL(readyRead()),
61  this, SLOT(readyRead()) );
62  connect( sender_, SIGNAL(readChannelFinished()),
63  this, SLOT(readChannelFinished()) );
64 }
65 
66 
67 private slots:
68 
69 void downloadProgress(qint64 bytes,qint64 totalbytes)
70 {
72  if ( receiver ) receiver->reportDownloadProgress( bytes, totalbytes );
73 }
74 
75 
76 void error(QNetworkReply::NetworkError)
77 {
79  if ( receiver ) receiver->reportError();
80 }
81 
82 void sslErrors(const QList<QSslError>& errors)
83 {
85  if ( receiver ) receiver->reportSSLErrors( errors );
86 }
87 
88 
89 void finished()
90 {
92  if ( receiver ) receiver->reportFinished();
93 }
94 
96 {
98  if ( receiver ) receiver->reportMetaDataChanged();
99 }
100 
101 void uploadProgress(qint64 bytes,qint64 totalbytes)
102 {
104  if ( receiver ) receiver->reportUploadProgress( bytes, totalbytes );
105 }
106 
108 {}
109 
110 void bytesWritten(qint64)
111 {}
112 
114 {}
115 
116 void readyRead()
117 {
119  if ( receiver ) receiver->reportReadyRead();
120 }
121 
122 
123 private:
124 
125  QNetworkReply* sender_;
127 
128 };
129 
130 QT_END_NAMESPACE
131 
132 #endif
Definition: odhttp.h:116
void bytesWritten(qint64)
Definition: i_odhttpconn.h:110
void uploadProgress(qint64 bytes, qint64 totalbytes)
Definition: i_odhttpconn.h:101
void aboutToClose()
Definition: i_odhttpconn.h:107
void readChannelFinished()
Definition: i_odhttpconn.h:113
void downloadProgress(qint64 bytes, qint64 totalbytes)
Definition: i_odhttpconn.h:69
WeakPtr< Network::HttpRequestProcess > receiver_
Definition: i_odhttpconn.h:126
void error(QNetworkReply::NetworkError)
Definition: i_odhttpconn.h:76
Definition: i_odhttpconn.h:27
void metaDataChanged()
Definition: i_odhttpconn.h:95
void finished()
Definition: i_odhttpconn.h:89
static void setReadEventType(int)
QNetworkReplyConn(QNetworkReply *sndr, Network::HttpRequestProcess *rec)
Definition: i_odhttpconn.h:39
static int readeventtype
Definition: i_odhttpconn.h:35
QNetworkReply * sender_
Definition: i_odhttpconn.h:125
void readyRead()
Definition: i_odhttpconn.h:116
void sslErrors(const QList< QSslError > &errors)
Definition: i_odhttpconn.h:82
Definition: odhttp.h:31

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B. V. 2017