equal
deleted
inserted
replaced
1 /**************************************************************************** |
1 /**************************************************************************** |
2 ** |
2 ** |
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
4 ** All rights reserved. |
4 ** All rights reserved. |
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
6 ** |
6 ** |
7 ** This file is part of the examples of the Qt Toolkit. |
7 ** This file is part of the examples of the Qt Toolkit. |
8 ** |
8 ** |
41 |
41 |
42 #ifndef HTTPWINDOW_H |
42 #ifndef HTTPWINDOW_H |
43 #define HTTPWINDOW_H |
43 #define HTTPWINDOW_H |
44 |
44 |
45 #include <QDialog> |
45 #include <QDialog> |
|
46 #include <QNetworkAccessManager> |
|
47 #include <QUrl> |
46 |
48 |
47 QT_BEGIN_NAMESPACE |
49 QT_BEGIN_NAMESPACE |
48 class QDialogButtonBox; |
50 class QDialogButtonBox; |
49 class QFile; |
51 class QFile; |
50 class QHttp; |
|
51 class QHttpResponseHeader; |
|
52 class QLabel; |
52 class QLabel; |
53 class QLineEdit; |
53 class QLineEdit; |
54 class QProgressDialog; |
54 class QProgressDialog; |
55 class QPushButton; |
55 class QPushButton; |
56 class QSslError; |
56 class QSslError; |
57 class QAuthenticator; |
57 class QAuthenticator; |
|
58 class QNetworkReply; |
|
59 |
|
60 |
58 QT_END_NAMESPACE |
61 QT_END_NAMESPACE |
59 |
62 |
60 class HttpWindow : public QDialog |
63 class HttpWindow : public QDialog |
61 { |
64 { |
62 Q_OBJECT |
65 Q_OBJECT |
63 |
66 |
64 public: |
67 public: |
65 HttpWindow(QWidget *parent = 0); |
68 HttpWindow(QWidget *parent = 0); |
66 |
69 |
|
70 void startRequest(QUrl url); |
|
71 |
67 private slots: |
72 private slots: |
68 void downloadFile(); |
73 void downloadFile(); |
69 void cancelDownload(); |
74 void cancelDownload(); |
70 void httpRequestFinished(int requestId, bool error); |
75 void httpFinished(); |
71 void readResponseHeader(const QHttpResponseHeader &responseHeader); |
76 void httpReadyRead(); |
72 void updateDataReadProgress(int bytesRead, int totalBytes); |
77 void updateDataReadProgress(qint64 bytesRead, qint64 totalBytes); |
73 void enableDownloadButton(); |
78 void enableDownloadButton(); |
74 void slotAuthenticationRequired(const QString &, quint16, QAuthenticator *); |
79 void slotAuthenticationRequired(QNetworkReply*,QAuthenticator *); |
75 #ifndef QT_NO_OPENSSL |
80 #ifndef QT_NO_OPENSSL |
76 void sslErrors(const QList<QSslError> &errors); |
81 void sslErrors(QNetworkReply*,const QList<QSslError> &errors); |
77 #endif |
82 #endif |
78 |
83 |
79 private: |
84 private: |
80 QLabel *statusLabel; |
85 QLabel *statusLabel; |
81 QLabel *urlLabel; |
86 QLabel *urlLabel; |
83 QProgressDialog *progressDialog; |
88 QProgressDialog *progressDialog; |
84 QPushButton *downloadButton; |
89 QPushButton *downloadButton; |
85 QPushButton *quitButton; |
90 QPushButton *quitButton; |
86 QDialogButtonBox *buttonBox; |
91 QDialogButtonBox *buttonBox; |
87 |
92 |
88 QHttp *http; |
93 QUrl url; |
|
94 QNetworkAccessManager qnam; |
|
95 QNetworkReply *reply; |
89 QFile *file; |
96 QFile *file; |
90 int httpGetId; |
97 int httpGetId; |
91 bool httpRequestAborted; |
98 bool httpRequestAborted; |
92 }; |
99 }; |
93 |
100 |