|
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 Qt Mobility Components. |
|
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 QNETWORKSESSIONPRIVATE_H |
|
43 #define QNETWORKSESSIONPRIVATE_H |
|
44 |
|
45 // |
|
46 // W A R N I N G |
|
47 // ------------- |
|
48 // |
|
49 // This file is not part of the Qt API. It exists purely as an |
|
50 // implementation detail. This header file may change from version to |
|
51 // version without notice, or even be removed. |
|
52 // |
|
53 // We mean it. |
|
54 // |
|
55 |
|
56 #include "qnetworkconfigmanager_p.h" |
|
57 #include "qnetworksession.h" |
|
58 #ifdef BEARER_ENGINE |
|
59 #include "qnetworksessionengine_p.h" |
|
60 #endif |
|
61 |
|
62 #include "qnetworksession.h" |
|
63 #include <QNetworkInterface> |
|
64 #include <QDateTime> |
|
65 |
|
66 QTM_BEGIN_NAMESPACE |
|
67 #ifdef BEARER_ENGINE |
|
68 class QNetworkSessionEngine; |
|
69 #endif |
|
70 |
|
71 class QNetworkSessionPrivate : public QObject |
|
72 { |
|
73 Q_OBJECT |
|
74 public: |
|
75 QNetworkSessionPrivate() : |
|
76 tx_data(0), rx_data(0), m_activeTime(0), isOpen(false) |
|
77 { |
|
78 } |
|
79 |
|
80 ~QNetworkSessionPrivate() |
|
81 { |
|
82 } |
|
83 |
|
84 //called by QNetworkSession constructor and ensures |
|
85 //that the state is immediately updated (w/o actually opening |
|
86 //a session). Also this function should take care of |
|
87 //notification hooks to discover future state changes. |
|
88 void syncStateWithInterface(); |
|
89 |
|
90 QNetworkInterface currentInterface() const; |
|
91 QVariant sessionProperty(const QString& key) const; |
|
92 void setSessionProperty(const QString& key, const QVariant& value); |
|
93 QString bearerName() const; |
|
94 |
|
95 void open(); |
|
96 void close(); |
|
97 void stop(); |
|
98 void migrate(); |
|
99 void accept(); |
|
100 void ignore(); |
|
101 void reject(); |
|
102 |
|
103 QString errorString() const; //must return translated string |
|
104 QNetworkSession::SessionError error() const; |
|
105 |
|
106 quint64 bytesWritten() const; |
|
107 quint64 bytesReceived() const; |
|
108 quint64 activeTime() const; |
|
109 |
|
110 private: |
|
111 void updateStateFromServiceNetwork(); |
|
112 void updateStateFromActiveConfig(); |
|
113 |
|
114 Q_SIGNALS: |
|
115 //releases any pending waitForOpened() calls |
|
116 void quitPendingWaitsForOpened(); |
|
117 |
|
118 private Q_SLOTS: |
|
119 #ifdef BEARER_ENGINE |
|
120 void networkConfigurationsChanged(); |
|
121 void configurationChanged(const QNetworkConfiguration &config); |
|
122 void forcedSessionClose(const QNetworkConfiguration &config); |
|
123 void connectionError(const QString &id, QNetworkSessionEngine::ConnectionError error); |
|
124 #endif |
|
125 |
|
126 private: |
|
127 QNetworkConfigurationManager manager; |
|
128 |
|
129 quint64 tx_data; |
|
130 quint64 rx_data; |
|
131 quint64 m_activeTime; |
|
132 |
|
133 // The config set on QNetworkSession. |
|
134 QNetworkConfiguration publicConfig; |
|
135 |
|
136 // If publicConfig is a ServiceNetwork this is a copy of publicConfig. |
|
137 // If publicConfig is an UserChoice that is resolved to a ServiceNetwork this is the actual |
|
138 // ServiceNetwork configuration. |
|
139 QNetworkConfiguration serviceConfig; |
|
140 |
|
141 // This is the actual active configuration currently in use by the session. |
|
142 // Either a copy of publicConfig or one of serviceConfig.children(). |
|
143 QNetworkConfiguration activeConfig; |
|
144 |
|
145 QNetworkSession::State state; |
|
146 bool isOpen; |
|
147 |
|
148 #ifdef BEARER_ENGINE |
|
149 bool opened; |
|
150 |
|
151 QNetworkSessionEngine *engine; |
|
152 #endif |
|
153 QNetworkSession::SessionError lastError; |
|
154 |
|
155 QNetworkSession* q; |
|
156 friend class QNetworkSession; |
|
157 |
|
158 #if defined(BEARER_ENGINE) && defined(BACKEND_NM) |
|
159 QDateTime startTime; |
|
160 void setActiveTimeStamp(); |
|
161 #endif |
|
162 }; |
|
163 |
|
164 QTM_END_NAMESPACE |
|
165 |
|
166 #endif //QNETWORKSESSIONPRIVATE_H |
|
167 |