1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** All rights reserved.
|
---|
5 | ** Contact: Nokia Corporation ([email protected])
|
---|
6 | **
|
---|
7 | ** This file is part of the QtNetwork module of the Qt Toolkit.
|
---|
8 | **
|
---|
9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
10 | ** Commercial Usage
|
---|
11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
14 | ** a written agreement between you and Nokia.
|
---|
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 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you have questions regarding the use of this file, please contact
|
---|
37 | ** Nokia at [email protected].
|
---|
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 "qnetworksession.h"
|
---|
57 | #include "qnetworkconfiguration_p.h"
|
---|
58 |
|
---|
59 | #ifndef QT_NO_BEARERMANAGEMENT
|
---|
60 |
|
---|
61 | QT_BEGIN_NAMESPACE
|
---|
62 |
|
---|
63 | class Q_NETWORK_EXPORT QNetworkSessionPrivate : public QObject
|
---|
64 | {
|
---|
65 | Q_OBJECT
|
---|
66 |
|
---|
67 | friend class QNetworkSession;
|
---|
68 |
|
---|
69 | public:
|
---|
70 | QNetworkSessionPrivate()
|
---|
71 | : state(QNetworkSession::Invalid), isOpen(false)
|
---|
72 | {
|
---|
73 | }
|
---|
74 |
|
---|
75 | virtual ~QNetworkSessionPrivate()
|
---|
76 | {
|
---|
77 | }
|
---|
78 |
|
---|
79 | //called by QNetworkSession constructor and ensures
|
---|
80 | //that the state is immediately updated (w/o actually opening
|
---|
81 | //a session). Also this function should take care of
|
---|
82 | //notification hooks to discover future state changes.
|
---|
83 | virtual void syncStateWithInterface() = 0;
|
---|
84 |
|
---|
85 | #ifndef QT_NO_NETWORKINTERFACE
|
---|
86 | virtual QNetworkInterface currentInterface() const = 0;
|
---|
87 | #endif
|
---|
88 | virtual QVariant sessionProperty(const QString& key) const = 0;
|
---|
89 | virtual void setSessionProperty(const QString& key, const QVariant& value) = 0;
|
---|
90 |
|
---|
91 | virtual void open() = 0;
|
---|
92 | virtual void close() = 0;
|
---|
93 | virtual void stop() = 0;
|
---|
94 |
|
---|
95 | virtual void setALREnabled(bool /*enabled*/) { }
|
---|
96 | virtual void migrate() = 0;
|
---|
97 | virtual void accept() = 0;
|
---|
98 | virtual void ignore() = 0;
|
---|
99 | virtual void reject() = 0;
|
---|
100 |
|
---|
101 | virtual QString errorString() const = 0; //must return translated string
|
---|
102 | virtual QNetworkSession::SessionError error() const = 0;
|
---|
103 |
|
---|
104 | virtual quint64 bytesWritten() const = 0;
|
---|
105 | virtual quint64 bytesReceived() const = 0;
|
---|
106 | virtual quint64 activeTime() const = 0;
|
---|
107 |
|
---|
108 | protected:
|
---|
109 | inline QNetworkConfigurationPrivatePointer privateConfiguration(const QNetworkConfiguration &config) const
|
---|
110 | {
|
---|
111 | return config.d;
|
---|
112 | }
|
---|
113 |
|
---|
114 | inline void setPrivateConfiguration(QNetworkConfiguration &config,
|
---|
115 | QNetworkConfigurationPrivatePointer ptr) const
|
---|
116 | {
|
---|
117 | config.d = ptr;
|
---|
118 | }
|
---|
119 |
|
---|
120 | Q_SIGNALS:
|
---|
121 | //releases any pending waitForOpened() calls
|
---|
122 | void quitPendingWaitsForOpened();
|
---|
123 |
|
---|
124 | void error(QNetworkSession::SessionError error);
|
---|
125 | void stateChanged(QNetworkSession::State state);
|
---|
126 | void closed();
|
---|
127 | void newConfigurationActivated();
|
---|
128 | void preferredConfigurationChanged(const QNetworkConfiguration &config, bool isSeamless);
|
---|
129 |
|
---|
130 | protected:
|
---|
131 | QNetworkSession *q;
|
---|
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 |
|
---|
149 | QT_END_NAMESPACE
|
---|
150 |
|
---|
151 | #endif // QT_NO_BEARERMANAGEMENT
|
---|
152 |
|
---|
153 | #endif //QNETWORKSESSIONPRIVATE_H
|
---|
154 |
|
---|