|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the test suite of the Qt Toolkit. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #ifndef DATATRANSFERER_H |
|
43 #define DATATRANSFERER_H |
|
44 |
|
45 #include <QObject> |
|
46 #include <QString> |
|
47 #include <QNetworkReply> |
|
48 #include <QNetworkAccessManager> |
|
49 #include <QTcpSocket> |
|
50 #include <QHttp> |
|
51 #include <QDebug> |
|
52 |
|
53 // Interface-class for data transferring object |
|
54 |
|
55 class DataTransferer : public QObject |
|
56 { |
|
57 Q_OBJECT |
|
58 public: |
|
59 explicit DataTransferer(QObject *parent = 0); |
|
60 virtual ~DataTransferer() { |
|
61 if (m_dataTransferOngoing) { |
|
62 qDebug("BearerEx Warning: dataobjects transfer was ongoing when destroyed."); |
|
63 } |
|
64 } |
|
65 virtual bool transferData() = 0; |
|
66 bool dataTransferOngoing(); |
|
67 |
|
68 signals: |
|
69 void finished(quint32 errorCode, qint64 dataReceived, QString errorType); |
|
70 |
|
71 public slots: |
|
72 |
|
73 protected: |
|
74 bool m_dataTransferOngoing; |
|
75 }; |
|
76 |
|
77 |
|
78 // Specializations/concrete classes |
|
79 |
|
80 class DataTransfererQTcp : public DataTransferer |
|
81 { |
|
82 Q_OBJECT |
|
83 public: |
|
84 DataTransfererQTcp(QObject* parent = 0); |
|
85 ~DataTransfererQTcp(); |
|
86 |
|
87 virtual bool transferData(); |
|
88 |
|
89 public slots: |
|
90 void readyRead(); |
|
91 void error(QAbstractSocket::SocketError socketError); |
|
92 void connected(); |
|
93 |
|
94 private: |
|
95 QTcpSocket m_qsocket; |
|
96 }; |
|
97 |
|
98 class DataTransfererQNam : public DataTransferer |
|
99 { |
|
100 Q_OBJECT |
|
101 public: |
|
102 DataTransfererQNam(QObject* parent = 0); |
|
103 ~DataTransfererQNam(); |
|
104 |
|
105 virtual bool transferData(); |
|
106 |
|
107 public slots: |
|
108 void replyFinished(QNetworkReply* reply); |
|
109 |
|
110 private: |
|
111 QNetworkAccessManager m_qnam; |
|
112 }; |
|
113 |
|
114 class DataTransfererQHttp : public DataTransferer |
|
115 { |
|
116 Q_OBJECT |
|
117 public: |
|
118 DataTransfererQHttp(QObject* parent = 0); |
|
119 ~DataTransfererQHttp(); |
|
120 |
|
121 virtual bool transferData(); |
|
122 |
|
123 public slots: |
|
124 void done(bool error); |
|
125 |
|
126 private: |
|
127 QHttp m_qhttp; |
|
128 }; |
|
129 |
|
130 #endif // DATATRANSFERER_H |