Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/network/bearer/qnetworksession.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||
---|---|---|---|---|---|---|---|---|
1 | - | |||||||
2 | - | |||||||
3 | - | |||||||
4 | QNetworkSession::QNetworkSession(const QNetworkConfiguration &connectionConfig, QObject *parent) | - | ||||||
5 | : QObject(parent), d(0) | - | ||||||
6 | { | - | ||||||
7 | - | |||||||
8 | if (!connectionConfig.identifier().isEmpty()
| 2-78 | ||||||
9 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(qNetworkConfigurationManagerPrivate()->const auto engines ())>::type> _container_((= qNetworkConfigurationManagerPrivate()->engines())); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)(); | - | ||||||
10 | for (QBearerEngine *engine = *_container_.i; _container_.control; _container_.control = 0: engines) { | - | ||||||
11 | if (engine->hasIdentifier(connectionConfig.identifier())
| 8-78 | ||||||
12 | d = engine->createSessionBackend(); | - | ||||||
13 | d->q = this; | - | ||||||
14 | d->publicConfig = connectionConfig; | - | ||||||
15 | d->syncStateWithInterface(); | - | ||||||
16 | connect(d, qFlagLocation("2""quitPendingWaitsForOpened()" "\0" __FILE__ ":" "257""264"), this, qFlagLocation("2""opened()" "\0" __FILE__ ":" "257""264")); | - | ||||||
17 | connect(d, qFlagLocation("2""error(QNetworkSession::SessionError)" "\0" __FILE__ ":" "258""265"), | - | ||||||
18 | this, qFlagLocation("2""error(QNetworkSession::SessionError)" "\0" __FILE__ ":" "259""266")); | - | ||||||
19 | connect(d, qFlagLocation("2""stateChanged(QNetworkSession::State)" "\0" __FILE__ ":" "260""267"), | - | ||||||
20 | this, qFlagLocation("2""stateChanged(QNetworkSession::State)" "\0" __FILE__ ":" "261""268")); | - | ||||||
21 | connect(d, qFlagLocation("2""closed()" "\0" __FILE__ ":" "262""269"), this, qFlagLocation("2""closed()" "\0" __FILE__ ":" "262""269")); | - | ||||||
22 | connect(d, qFlagLocation("2""preferredConfigurationChanged(QNetworkConfiguration,bool)" "\0" __FILE__ ":" "263""270"), | - | ||||||
23 | this, qFlagLocation("2""preferredConfigurationChanged(QNetworkConfiguration,bool)" "\0" __FILE__ ":" "264""271")); | - | ||||||
24 | connect(d, qFlagLocation("2""newConfigurationActivated()" "\0" __FILE__ ":" "265""272"), | - | ||||||
25 | this, qFlagLocation("2""newConfigurationActivated()" "\0" __FILE__ ":" "266""273")); | - | ||||||
26 | connect(d, qFlagLocation("2""usagePoliciesChanged(QNetworkSession::UsagePolicies)" "\0" __FILE__ ":" "267""274"), | - | ||||||
27 | this, qFlagLocation("2""usagePoliciesChanged(QNetworkSession::UsagePolicies)" "\0" __FILE__ ":" "268""275")); | - | ||||||
28 | break; executed 78 times by 15 tests: break; Executed by:
| 78 | ||||||
29 | } | - | ||||||
30 | } executed 8 times by 2 tests: end of block Executed by:
| 8 | ||||||
31 | } executed 78 times by 15 tests: end of block Executed by:
| 78 | ||||||
32 | - | |||||||
33 | qRegisterMetaType<QNetworkSession::State>(); | - | ||||||
34 | qRegisterMetaType<QNetworkSession::SessionError>(); | - | ||||||
35 | qRegisterMetaType<QNetworkSession::UsagePolicies>(); | - | ||||||
36 | } executed 80 times by 15 tests: end of block Executed by:
| 80 | ||||||
37 | - | |||||||
38 | - | |||||||
39 | - | |||||||
40 | - | |||||||
41 | QNetworkSession::~QNetworkSession() | - | ||||||
42 | { | - | ||||||
43 | delete d; | - | ||||||
44 | } | - | ||||||
45 | void QNetworkSession::open() | - | ||||||
46 | { | - | ||||||
47 | if (d) | - | ||||||
48 | d->open(); | - | ||||||
49 | else | - | ||||||
50 | error(InvalidConfigurationError); | - | ||||||
51 | } | - | ||||||
52 | bool QNetworkSession::waitForOpened(int msecs) | - | ||||||
53 | { | - | ||||||
54 | if (!d) | - | ||||||
55 | return false; | - | ||||||
56 | - | |||||||
57 | if (d->isOpen) | - | ||||||
58 | return true; | - | ||||||
59 | - | |||||||
60 | if (!(d->state == Connecting || d->state == Connected)) { | - | ||||||
61 | return false; | - | ||||||
62 | } | - | ||||||
63 | - | |||||||
64 | QEventLoop loop; | - | ||||||
65 | QObject::connect(d, qFlagLocation("2""quitPendingWaitsForOpened()" "\0" __FILE__ ":" "342""349"), &loop, qFlagLocation("1""quit()" "\0" __FILE__ ":" "342""349")); | - | ||||||
66 | QObject::connect(this, qFlagLocation("2""error(QNetworkSession::SessionError)" "\0" __FILE__ ":" "343""350"), &loop, qFlagLocation("1""quit()" "\0" __FILE__ ":" "343""350")); | - | ||||||
67 | - | |||||||
68 | - | |||||||
69 | if (msecs >= 0) | - | ||||||
70 | QTimer::singleShot(msecs, &loop, qFlagLocation("1""quit()" "\0" __FILE__ ":" "347""354")); | - | ||||||
71 | - | |||||||
72 | - | |||||||
73 | loop.exec(QEventLoop::ExcludeUserInputEvents | QEventLoop::WaitForMoreEvents); | - | ||||||
74 | - | |||||||
75 | return d->isOpen; | - | ||||||
76 | } | - | ||||||
77 | void QNetworkSession::close() | - | ||||||
78 | { | - | ||||||
79 | if (d) | - | ||||||
80 | d->close(); | - | ||||||
81 | } | - | ||||||
82 | void QNetworkSession::stop() | - | ||||||
83 | { | - | ||||||
84 | if (d) | - | ||||||
85 | d->stop(); | - | ||||||
86 | } | - | ||||||
87 | - | |||||||
88 | - | |||||||
89 | - | |||||||
90 | - | |||||||
91 | - | |||||||
92 | - | |||||||
93 | QNetworkConfiguration QNetworkSession::configuration() const | - | ||||||
94 | { | - | ||||||
95 | return d ? d->publicConfig : QNetworkConfiguration(); | - | ||||||
96 | } | - | ||||||
97 | QNetworkInterface QNetworkSession::interface() const | - | ||||||
98 | { | - | ||||||
99 | return d ? d->currentInterface() : QNetworkInterface(); | - | ||||||
100 | } | - | ||||||
101 | bool QNetworkSession::isOpen() const | - | ||||||
102 | { | - | ||||||
103 | return d ? d->isOpen : false; | - | ||||||
104 | } | - | ||||||
105 | QNetworkSession::State QNetworkSession::state() const | - | ||||||
106 | { | - | ||||||
107 | return d ? d->state : QNetworkSession::Invalid; | - | ||||||
108 | } | - | ||||||
109 | - | |||||||
110 | - | |||||||
111 | - | |||||||
112 | - | |||||||
113 | - | |||||||
114 | - | |||||||
115 | QNetworkSession::SessionError QNetworkSession::error() const | - | ||||||
116 | { | - | ||||||
117 | return d ? d->error() : InvalidConfigurationError; | - | ||||||
118 | } | - | ||||||
119 | - | |||||||
120 | - | |||||||
121 | - | |||||||
122 | - | |||||||
123 | - | |||||||
124 | - | |||||||
125 | - | |||||||
126 | QString QNetworkSession::errorString() const | - | ||||||
127 | { | - | ||||||
128 | return d ? d->errorString() : tr("Invalid configuration."); | - | ||||||
129 | } | - | ||||||
130 | QVariant QNetworkSession::sessionProperty(const QString &key) const | - | ||||||
131 | { | - | ||||||
132 | if (!d || !d->publicConfig.isValid()) | - | ||||||
133 | return QVariant(); | - | ||||||
134 | - | |||||||
135 | if (key == QLatin1String("ActiveConfiguration")) | - | ||||||
136 | return d->isOpen ? d->activeConfig.identifier() : QString(); | - | ||||||
137 | - | |||||||
138 | if (key == QLatin1String("UserChoiceConfiguration")) { | - | ||||||
139 | if (!d->isOpen || d->publicConfig.type() != QNetworkConfiguration::UserChoice) | - | ||||||
140 | return QString(); | - | ||||||
141 | - | |||||||
142 | if (d->serviceConfig.isValid()) | - | ||||||
143 | return d->serviceConfig.identifier(); | - | ||||||
144 | else | - | ||||||
145 | return d->activeConfig.identifier(); | - | ||||||
146 | } | - | ||||||
147 | - | |||||||
148 | return d->sessionProperty(key); | - | ||||||
149 | } | - | ||||||
150 | void QNetworkSession::setSessionProperty(const QString &key, const QVariant &value) | - | ||||||
151 | { | - | ||||||
152 | if (!d) | - | ||||||
153 | return; | - | ||||||
154 | - | |||||||
155 | if (key == QLatin1String("ActiveConfiguration") || | - | ||||||
156 | key == QLatin1String("UserChoiceConfiguration")) { | - | ||||||
157 | return; | - | ||||||
158 | } | - | ||||||
159 | - | |||||||
160 | d->setSessionProperty(key, value); | - | ||||||
161 | } | - | ||||||
162 | void QNetworkSession::migrate() | - | ||||||
163 | { | - | ||||||
164 | if (d) | - | ||||||
165 | d->migrate(); | - | ||||||
166 | } | - | ||||||
167 | - | |||||||
168 | - | |||||||
169 | - | |||||||
170 | - | |||||||
171 | - | |||||||
172 | - | |||||||
173 | void QNetworkSession::ignore() | - | ||||||
174 | { | - | ||||||
175 | if (d) | - | ||||||
176 | d->ignore(); | - | ||||||
177 | } | - | ||||||
178 | void QNetworkSession::accept() | - | ||||||
179 | { | - | ||||||
180 | if (d) | - | ||||||
181 | d->accept(); | - | ||||||
182 | } | - | ||||||
183 | void QNetworkSession::reject() | - | ||||||
184 | { | - | ||||||
185 | if (d) | - | ||||||
186 | d->reject(); | - | ||||||
187 | } | - | ||||||
188 | quint64 QNetworkSession::bytesWritten() const | - | ||||||
189 | { | - | ||||||
190 | return d ? d->bytesWritten() : static_cast<unsigned long long>(0ULL); | - | ||||||
191 | } | - | ||||||
192 | quint64 QNetworkSession::bytesReceived() const | - | ||||||
193 | { | - | ||||||
194 | return d ? d->bytesReceived() : static_cast<unsigned long long>(0ULL); | - | ||||||
195 | } | - | ||||||
196 | - | |||||||
197 | - | |||||||
198 | - | |||||||
199 | - | |||||||
200 | quint64 QNetworkSession::activeTime() const | - | ||||||
201 | { | - | ||||||
202 | return d ? d->activeTime() : static_cast<unsigned long long>(0ULL); | - | ||||||
203 | } | - | ||||||
204 | - | |||||||
205 | - | |||||||
206 | - | |||||||
207 | - | |||||||
208 | QNetworkSession::UsagePolicies QNetworkSession::usagePolicies() const | - | ||||||
209 | { | - | ||||||
210 | return d ? d->usagePolicies() : QNetworkSession::NoPolicy; | - | ||||||
211 | } | - | ||||||
212 | - | |||||||
213 | - | |||||||
214 | - | |||||||
215 | - | |||||||
216 | - | |||||||
217 | - | |||||||
218 | void QNetworkSessionPrivate::setUsagePolicies(QNetworkSession &session, QNetworkSession::UsagePolicies policies) | - | ||||||
219 | { | - | ||||||
220 | if (!session.d) | - | ||||||
221 | return; | - | ||||||
222 | session.d->setUsagePolicies(policies); | - | ||||||
223 | } | - | ||||||
224 | void QNetworkSession::connectNotify(const QMetaMethod &signal) | - | ||||||
225 | { | - | ||||||
226 | QObject::connectNotify(signal); | - | ||||||
227 | - | |||||||
228 | if (!d) | - | ||||||
229 | return; | - | ||||||
230 | - | |||||||
231 | - | |||||||
232 | - | |||||||
233 | static const QMetaMethod preferredConfigurationChangedSignal = | - | ||||||
234 | QMetaMethod::fromSignal(&QNetworkSession::preferredConfigurationChanged); | - | ||||||
235 | if (signal == preferredConfigurationChangedSignal) | - | ||||||
236 | d->setALREnabled(true); | - | ||||||
237 | } | - | ||||||
238 | void QNetworkSession::disconnectNotify(const QMetaMethod &signal) | - | ||||||
239 | { | - | ||||||
240 | QObject::disconnectNotify(signal); | - | ||||||
241 | - | |||||||
242 | if (!d) | - | ||||||
243 | return; | - | ||||||
244 | - | |||||||
245 | - | |||||||
246 | - | |||||||
247 | static const QMetaMethod preferredConfigurationChangedSignal = | - | ||||||
248 | QMetaMethod::fromSignal(&QNetworkSession::preferredConfigurationChanged); | - | ||||||
249 | if (signal == preferredConfigurationChangedSignal) | - | ||||||
250 | d->setALREnabled(false); | - | ||||||
251 | } | - | ||||||
252 | - | |||||||
253 | - | |||||||
254 | - | |||||||
Switch to Source code | Preprocessed file |