50 #include <stdapis/net/if.h> |
50 #include <stdapis/net/if.h> |
51 |
51 |
52 QTM_BEGIN_NAMESPACE |
52 QTM_BEGIN_NAMESPACE |
53 |
53 |
54 QNetworkSessionPrivate::QNetworkSessionPrivate() |
54 QNetworkSessionPrivate::QNetworkSessionPrivate() |
55 : CActive(CActive::EPriorityStandard), state(QNetworkSession::Invalid), |
55 : CActive(CActive::EPriorityUserInput), state(QNetworkSession::Invalid), |
56 isOpen(false), ipConnectionNotifier(0), iError(QNetworkSession::UnknownSessionError), |
56 isOpen(false), ipConnectionNotifier(0), iHandleStateNotificationsFromManager(false), |
57 iALREnabled(0), iConnectInBackground(false) |
57 iFirstSync(true), iStoppedByUser(false), iClosedByUser(false), iDeprecatedConnectionId(0), |
|
58 iError(QNetworkSession::UnknownSessionError), iALREnabled(0), iConnectInBackground(false) |
58 { |
59 { |
59 CActiveScheduler::Add(this); |
60 CActiveScheduler::Add(this); |
60 |
61 |
61 #ifdef SNAP_FUNCTIONALITY_AVAILABLE |
62 #ifdef SNAP_FUNCTIONALITY_AVAILABLE |
62 iMobility = NULL; |
63 iMobility = NULL; |
63 #endif |
64 #endif |
|
65 |
64 TRAP_IGNORE(iConnectionMonitor.ConnectL()); |
66 TRAP_IGNORE(iConnectionMonitor.ConnectL()); |
65 } |
67 } |
66 |
68 |
67 QNetworkSessionPrivate::~QNetworkSessionPrivate() |
69 QNetworkSessionPrivate::~QNetworkSessionPrivate() |
68 { |
70 { |
87 iConnection.Close(); |
89 iConnection.Close(); |
88 iSocketServ.Close(); |
90 iSocketServ.Close(); |
89 |
91 |
90 // Close global 'Open C' RConnection |
92 // Close global 'Open C' RConnection |
91 setdefaultif(0); |
93 setdefaultif(0); |
92 |
94 |
93 iConnectionMonitor.CancelNotifications(); |
|
94 iConnectionMonitor.Close(); |
95 iConnectionMonitor.Close(); |
|
96 } |
|
97 |
|
98 void QNetworkSessionPrivate::configurationStateChanged(TUint32 accessPointId, TUint32 connMonId, QNetworkSession::State newState) |
|
99 { |
|
100 if (iHandleStateNotificationsFromManager) { |
|
101 #ifdef QT_BEARERMGMT_SYMBIAN_DEBUG |
|
102 qDebug() << "QNS this : " << QString::number((uint)this) << " - " |
|
103 << "configurationStateChanged from manager for IAP : " << QString::number(accessPointId) |
|
104 << "configurationStateChanged connMon ID : " << QString::number(connMonId) |
|
105 << " : to a state: " << newState |
|
106 << " whereas my current state is: " << state; |
|
107 #endif |
|
108 if (connMonId == iDeprecatedConnectionId) { |
|
109 #ifdef QT_BEARERMGMT_SYMBIAN_DEBUG |
|
110 qDebug() << "QNS this : " << QString::number((uint)this) << " - " |
|
111 << "however status update from manager ignored because it related to already closed connection."; |
|
112 #endif |
|
113 return; |
|
114 } |
|
115 this->newState(newState, accessPointId); |
|
116 } |
|
117 } |
|
118 |
|
119 void QNetworkSessionPrivate::configurationRemoved(const QNetworkConfiguration& config) |
|
120 { |
|
121 if (!publicConfig.d.data()) { |
|
122 return; |
|
123 } |
|
124 if (config.d.data()->numericId == publicConfig.d.data()->numericId) { |
|
125 #ifdef QT_BEARERMGMT_SYMBIAN_DEBUG |
|
126 qDebug() << "QNS this : " << QString::number((uint)this) << " - " |
|
127 << "configurationRemoved IAP: " << QString::number(publicConfig.d.data()->numericId) << " : going to State: Invalid"; |
|
128 #endif |
|
129 this->newState(QNetworkSession::Invalid, publicConfig.d.data()->numericId); |
|
130 } |
95 } |
131 } |
96 |
132 |
97 void QNetworkSessionPrivate::syncStateWithInterface() |
133 void QNetworkSessionPrivate::syncStateWithInterface() |
98 { |
134 { |
99 if (!publicConfig.d) { |
135 if (!publicConfig.d) { |
100 return; |
136 return; |
101 } |
137 } |
102 |
138 |
103 // Start monitoring changes in IAP states |
139 if (iFirstSync && publicConfig.d.data()) { |
104 TRAP_IGNORE(iConnectionMonitor.NotifyEventL(*this)); |
140 QObject::connect(((QNetworkConfigurationManagerPrivate*)publicConfig.d.data()->manager), SIGNAL(configurationStateChanged(TUint32, TUint32, QNetworkSession::State)), |
|
141 this, SLOT(configurationStateChanged(TUint32, TUint32, QNetworkSession::State))); |
|
142 // Listen to configuration removals, so that in case the configuration |
|
143 // this session is based on is removed, session knows to enter Invalid -state. |
|
144 QObject::connect(((QNetworkConfigurationManagerPrivate*)publicConfig.d.data()->manager), |
|
145 SIGNAL(configurationRemoved(QNetworkConfiguration)), |
|
146 this, SLOT(configurationRemoved(QNetworkConfiguration))); |
|
147 } |
|
148 // Start listening IAP state changes from QNetworkConfigurationManagerPrivate |
|
149 iHandleStateNotificationsFromManager = true; |
105 |
150 |
106 // Check open connections to see if there is already |
151 // Check open connections to see if there is already |
107 // an open connection to selected IAP or SNAP |
152 // an open connection to selected IAP or SNAP |
108 TUint count; |
153 TUint count; |
109 TRequestStatus status; |
154 TRequestStatus status; |
240 return iError; |
281 return iError; |
241 } |
282 } |
242 |
283 |
243 void QNetworkSessionPrivate::open() |
284 void QNetworkSessionPrivate::open() |
244 { |
285 { |
|
286 #ifdef QT_BEARERMGMT_SYMBIAN_DEBUG |
|
287 qDebug() << "QNS this : " << QString::number((uint)this) << " - " |
|
288 << "open() called, session state is: " << state << " and isOpen is: " |
|
289 << isOpen; |
|
290 #endif |
245 if (isOpen || (state == QNetworkSession::Connecting)) { |
291 if (isOpen || (state == QNetworkSession::Connecting)) { |
246 return; |
292 return; |
247 } |
293 } |
248 |
294 |
249 // Cancel notifications from RConnectionMonitor |
295 // Stop handling IAP state change signals from QNetworkConfigurationManagerPrivate |
250 // => RConnection::ProgressNotification will be used for IAP/SNAP monitoring |
296 // => RConnection::ProgressNotification will be used for IAP/SNAP monitoring |
251 iConnectionMonitor.CancelNotifications(); |
297 iHandleStateNotificationsFromManager = false; |
252 |
298 |
253 // Configuration may have been invalidated after session creation by platform |
299 // Configuration may have been invalidated after session creation by platform |
254 // (e.g. configuration has been deleted). |
300 // (e.g. configuration has been deleted). |
255 if (!publicConfig.isValid()) { |
301 if (!publicConfig.isValid()) { |
256 newState(QNetworkSession::Invalid); |
302 newState(QNetworkSession::Invalid); |
257 iError = QNetworkSession::InvalidConfigurationError; |
303 iError = QNetworkSession::InvalidConfigurationError; |
258 emit q->error(iError); |
304 emit q->error(iError); |
259 syncStateWithInterface(); |
|
260 return; |
305 return; |
261 } |
306 } |
262 // If opening a (un)defined configuration, session emits error and enters |
307 // If opening a undefined configuration, session emits error and enters |
263 // NotAvailable -state. |
308 // NotAvailable -state. Note that we will try ones in 'defined' state to avoid excessive |
264 if (publicConfig.state() == QNetworkConfiguration::Undefined || |
309 // need for WLAN scans (via updateConfigurations()), because user may have walked |
265 publicConfig.state() == QNetworkConfiguration::Defined) { |
310 // into a WLAN range, but periodic background scan has not occurred yet --> |
|
311 // we don't want to force application to make frequent updateConfigurations() calls |
|
312 // to be able to try if e.g. home WLAN is available. |
|
313 if (publicConfig.state() == QNetworkConfiguration::Undefined) { |
266 newState(QNetworkSession::NotAvailable); |
314 newState(QNetworkSession::NotAvailable); |
267 iError = QNetworkSession::InvalidConfigurationError; |
315 iError = QNetworkSession::InvalidConfigurationError; |
268 emit q->error(iError); |
316 emit q->error(iError); |
269 return; |
317 return; |
270 } |
318 } |
271 |
319 // Clear possible previous states |
|
320 iStoppedByUser = false; |
|
321 iClosedByUser = false; |
|
322 iDeprecatedConnectionId = 0; |
|
323 |
272 TInt error = iSocketServ.Connect(); |
324 TInt error = iSocketServ.Connect(); |
273 if (error != KErrNone) { |
325 if (error != KErrNone) { |
274 // Could not open RSocketServ |
326 // Could not open RSocketServ |
275 newState(QNetworkSession::Invalid); |
327 newState(QNetworkSession::Invalid); |
276 iError = QNetworkSession::UnknownSessionError; |
328 iError = QNetworkSession::UnknownSessionError; |
454 #endif |
517 #endif |
455 (publicConfig.type() == QNetworkConfiguration::UserChoice)) { |
518 (publicConfig.type() == QNetworkConfiguration::UserChoice)) { |
456 newState(QNetworkSession::Closing); |
519 newState(QNetworkSession::Closing); |
457 } |
520 } |
458 |
521 |
459 syncStateWithInterface(); |
|
460 if (allowSignals) { |
522 if (allowSignals) { |
461 if (publicConfig.type() == QNetworkConfiguration::UserChoice) { |
523 if (publicConfig.type() == QNetworkConfiguration::UserChoice) { |
462 newState(QNetworkSession::Disconnected); |
524 newState(QNetworkSession::Disconnected); |
463 } |
525 } |
464 emit q->closed(); |
526 emit q->closed(); |
465 } |
527 } |
466 } |
528 } |
467 |
529 |
468 void QNetworkSessionPrivate::stop() |
530 void QNetworkSessionPrivate::stop() |
469 { |
531 { |
|
532 #ifdef QT_BEARERMGMT_SYMBIAN_DEBUG |
|
533 qDebug() << "QNS this : " << QString::number((uint)this) << " - " |
|
534 << "stop() called, session state is: " << state << " and isOpen is : " |
|
535 << isOpen; |
|
536 #endif |
470 if (!isOpen && |
537 if (!isOpen && |
471 publicConfig.isValid() && |
538 publicConfig.isValid() && |
472 publicConfig.type() == QNetworkConfiguration::InternetAccessPoint) { |
539 publicConfig.type() == QNetworkConfiguration::InternetAccessPoint) { |
|
540 #ifdef QT_BEARERMGMT_SYMBIAN_DEBUG |
|
541 qDebug() << "QNS this : " << QString::number((uint)this) << " - " |
|
542 << "since session is not open, using RConnectionMonitor to stop() the interface"; |
|
543 #endif |
|
544 iStoppedByUser = true; |
473 // If the publicConfig is type of IAP, enumerate through connections at |
545 // If the publicConfig is type of IAP, enumerate through connections at |
474 // connection monitor. If publicConfig is active in that list, stop it. |
546 // connection monitor. If publicConfig is active in that list, stop it. |
475 // Otherwise there is nothing to stop. Note: because this QNetworkSession is not open, |
547 // Otherwise there is nothing to stop. Note: because this QNetworkSession is not open, |
476 // activeConfig is not usable. |
548 // activeConfig is not usable. |
477 TUint count; |
549 TUint count; |
493 0, // subConnectionId don't care |
565 0, // subConnectionId don't care |
494 KConnectionStop, |
566 KConnectionStop, |
495 ETrue); |
567 ETrue); |
496 } |
568 } |
497 } |
569 } |
|
570 // Enter disconnected state right away since the session is not even open. |
|
571 // Symbian^3 connection monitor does not emit KLinkLayerClosed when |
|
572 // connection is stopped via connection monitor. |
|
573 newState(QNetworkSession::Disconnected); |
498 } |
574 } |
499 } else if (isOpen) { |
575 } else if (isOpen) { |
|
576 #ifdef QT_BEARERMGMT_SYMBIAN_DEBUG |
|
577 qDebug() << "QNS this : " << QString::number((uint)this) << " - " |
|
578 << "since session is open, using RConnection to stop() the interface"; |
|
579 #endif |
500 // Since we are open, use RConnection to stop the interface |
580 // Since we are open, use RConnection to stop the interface |
501 isOpen = false; |
581 isOpen = false; |
|
582 iStoppedByUser = true; |
502 newState(QNetworkSession::Closing); |
583 newState(QNetworkSession::Closing); |
|
584 if (ipConnectionNotifier) { |
|
585 ipConnectionNotifier->StopNotifications(); |
|
586 // Start handling IAP state change signals from QNetworkConfigurationManagerPrivate |
|
587 iHandleStateNotificationsFromManager = true; |
|
588 } |
503 iConnection.Stop(RConnection::EStopAuthoritative); |
589 iConnection.Stop(RConnection::EStopAuthoritative); |
504 isOpen = true; |
590 isOpen = true; |
505 close(false); |
591 close(false); |
506 emit q->closed(); |
592 emit q->closed(); |
507 } |
593 } |
916 void QNetworkSessionPrivate::DoCancel() |
1016 void QNetworkSessionPrivate::DoCancel() |
917 { |
1017 { |
918 iConnection.Close(); |
1018 iConnection.Close(); |
919 } |
1019 } |
920 |
1020 |
|
1021 // Enters newState if feasible according to current state. |
|
1022 // AccessPointId may be given as parameter. If it is zero, state-change is assumed to |
|
1023 // concern this session's configuration. If non-zero, the configuration is looked up |
|
1024 // and checked if it matches the configuration this session is based on. |
921 bool QNetworkSessionPrivate::newState(QNetworkSession::State newState, TUint accessPointId) |
1025 bool QNetworkSessionPrivate::newState(QNetworkSession::State newState, TUint accessPointId) |
922 { |
1026 { |
|
1027 #ifdef QT_BEARERMGMT_SYMBIAN_DEBUG |
|
1028 qDebug() << "QNS this : " << QString::number((uint)this) << " - " |
|
1029 << "NEW STATE, IAP ID : " << QString::number(accessPointId) << " , newState : " << QString::number(newState); |
|
1030 #endif |
923 // Make sure that activeConfig is always updated when SNAP is signaled to be |
1031 // Make sure that activeConfig is always updated when SNAP is signaled to be |
924 // connected. |
1032 // connected. |
925 if (isOpen && publicConfig.type() == QNetworkConfiguration::ServiceNetwork && |
1033 if (isOpen && publicConfig.type() == QNetworkConfiguration::ServiceNetwork && |
926 newState == QNetworkSession::Connected) { |
1034 newState == QNetworkSession::Connected) { |
927 activeConfig = activeConfiguration(accessPointId); |
1035 activeConfig = activeConfiguration(accessPointId); |
935 |
1043 |
936 // Make sure that Connecting state does not overwrite Roaming state |
1044 // Make sure that Connecting state does not overwrite Roaming state |
937 if (state == QNetworkSession::Roaming && newState == QNetworkSession::Connecting) { |
1045 if (state == QNetworkSession::Roaming && newState == QNetworkSession::Connecting) { |
938 return false; |
1046 return false; |
939 } |
1047 } |
|
1048 |
|
1049 // Make sure that Connected state is not reported when Connection is |
|
1050 // already Closing. |
|
1051 // Note: Stopping connection results sometimes KLinkLayerOpen |
|
1052 // to be reported first (just before KLinkLayerClosed). |
|
1053 if (state == QNetworkSession::Closing && newState == QNetworkSession::Connected) { |
|
1054 return false; |
|
1055 } |
|
1056 |
|
1057 // Make sure that some lagging 'closing' state-changes do not overwrite |
|
1058 // if we are already disconnected or closed. |
|
1059 if (state == QNetworkSession::Disconnected && newState == QNetworkSession::Closing) { |
|
1060 return false; |
|
1061 } |
940 |
1062 |
941 bool emitSessionClosed = false; |
1063 bool emitSessionClosed = false; |
942 if (isOpen && state == QNetworkSession::Connected && newState == QNetworkSession::Disconnected) { |
1064 |
|
1065 // If we abruptly go down and user hasn't closed the session, we've been aborted. |
|
1066 // Note that session may be in 'closing' state and not in 'connected' state, because |
|
1067 // depending on platform the platform may report KConfigDaemonStartingDeregistration |
|
1068 // event before KLinkLayerClosed |
|
1069 if ((isOpen && state == QNetworkSession::Connected && newState == QNetworkSession::Disconnected) || |
|
1070 (isOpen && !iClosedByUser && newState == QNetworkSession::Disconnected)) { |
943 // Active & Connected state should change directly to Disconnected state |
1071 // Active & Connected state should change directly to Disconnected state |
944 // only when something forces connection to close (eg. when another |
1072 // only when something forces connection to close (eg. when another |
945 // application or session stops connection or when network drops |
1073 // application or session stops connection or when network drops |
946 // unexpectedly). |
1074 // unexpectedly). |
947 isOpen = false; |
1075 isOpen = false; |
951 emit q->error(iError); |
1079 emit q->error(iError); |
952 Cancel(); |
1080 Cancel(); |
953 if (ipConnectionNotifier) { |
1081 if (ipConnectionNotifier) { |
954 ipConnectionNotifier->StopNotifications(); |
1082 ipConnectionNotifier->StopNotifications(); |
955 } |
1083 } |
956 // Start monitoring changes in IAP states |
1084 // Start handling IAP state change signals from QNetworkConfigurationManagerPrivate |
957 TRAP_IGNORE(iConnectionMonitor.NotifyEventL(*this)); |
1085 iHandleStateNotificationsFromManager = true; |
958 emitSessionClosed = true; // Emit SessionClosed after state change has been reported |
1086 emitSessionClosed = true; // Emit SessionClosed after state change has been reported |
959 } |
1087 } |
960 |
1088 |
961 bool retVal = false; |
1089 bool retVal = false; |
962 if (accessPointId == 0) { |
1090 if (accessPointId == 0) { |
963 state = newState; |
1091 state = newState; |
|
1092 #ifdef QT_BEARERMGMT_SYMBIAN_DEBUG |
|
1093 qDebug() << "QNS this : " << QString::number((uint)this) << " - " << "===> EMIT State changed A to: " << state; |
|
1094 #endif |
964 emit q->stateChanged(state); |
1095 emit q->stateChanged(state); |
965 retVal = true; |
1096 retVal = true; |
966 } else { |
1097 } else { |
967 if (publicConfig.type() == QNetworkConfiguration::InternetAccessPoint) { |
1098 if (publicConfig.type() == QNetworkConfiguration::InternetAccessPoint) { |
968 if (publicConfig.d.data()->numericId == accessPointId) { |
1099 if (publicConfig.d.data()->numericId == accessPointId) { |
969 state = newState; |
1100 state = newState; |
|
1101 #ifdef QT_BEARERMGMT_SYMBIAN_DEBUG |
|
1102 qDebug() << "QNS this : " << QString::number((uint)this) << " - " << "===> EMIT State changed B to: " << state; |
|
1103 #endif |
970 emit q->stateChanged(state); |
1104 emit q->stateChanged(state); |
971 retVal = true; |
1105 retVal = true; |
972 } |
1106 } |
973 } else if (publicConfig.type() == QNetworkConfiguration::UserChoice && isOpen) { |
1107 } else if (publicConfig.type() == QNetworkConfiguration::UserChoice && isOpen) { |
974 if (activeConfig.d.data()->numericId == accessPointId) { |
1108 if (activeConfig.d.data()->numericId == accessPointId) { |
975 state = newState; |
1109 state = newState; |
|
1110 #ifdef QT_BEARERMGMT_SYMBIAN_DEBUG |
|
1111 qDebug() << "QNS this : " << QString::number((uint)this) << " - " << "===> EMIT State changed C to: " << state; |
|
1112 #endif |
976 emit q->stateChanged(state); |
1113 emit q->stateChanged(state); |
977 retVal = true; |
1114 retVal = true; |
978 } |
1115 } |
979 } else if (publicConfig.type() == QNetworkConfiguration::ServiceNetwork) { |
1116 } else if (publicConfig.type() == QNetworkConfiguration::ServiceNetwork) { |
980 QList<QNetworkConfiguration> subConfigurations = publicConfig.children(); |
1117 QList<QNetworkConfiguration> subConfigurations = publicConfig.children(); |
981 for (int i = 0; i < subConfigurations.count(); i++) { |
1118 for (int i = 0; i < subConfigurations.count(); i++) { |
982 if (subConfigurations[i].d.data()->numericId == accessPointId) { |
1119 if (subConfigurations[i].d.data()->numericId == accessPointId) { |
983 if (newState == QNetworkSession::Connected) { |
1120 if (newState == QNetworkSession::Connected) { |
984 // Make sure that when AccessPoint is reported to be Connected |
|
985 // also state of the related configuration changes to Active. |
|
986 subConfigurations[i].d.data()->state = QNetworkConfiguration::Active; |
|
987 |
|
988 state = newState; |
1121 state = newState; |
|
1122 #ifdef QT_BEARERMGMT_SYMBIAN_DEBUG |
|
1123 qDebug() << "QNS this : " << QString::number((uint)this) << " - " << "===> EMIT State changed D to: " << state; |
|
1124 #endif |
989 emit q->stateChanged(state); |
1125 emit q->stateChanged(state); |
990 retVal = true; |
1126 retVal = true; |
991 } else { |
1127 } else { |
992 if (newState == QNetworkSession::Disconnected) { |
|
993 // Make sure that when AccessPoint is reported to be disconnected |
|
994 // also state of the related configuration changes from Active to Defined. |
|
995 subConfigurations[i].d.data()->state = QNetworkConfiguration::Defined; |
|
996 } |
|
997 QNetworkConfiguration config = bestConfigFromSNAP(publicConfig); |
1128 QNetworkConfiguration config = bestConfigFromSNAP(publicConfig); |
998 if ((config.state() == QNetworkConfiguration::Defined) || |
1129 if ((config.state() == QNetworkConfiguration::Defined) || |
999 (config.state() == QNetworkConfiguration::Discovered)) { |
1130 (config.state() == QNetworkConfiguration::Discovered)) { |
1000 state = newState; |
1131 state = newState; |
|
1132 #ifdef QT_BEARERMGMT_SYMBIAN_DEBUG |
|
1133 qDebug() << "QNS this : " << QString::number((uint)this) << " - " << "===> EMIT State changed E to: " << state; |
|
1134 #endif |
1001 emit q->stateChanged(state); |
1135 emit q->stateChanged(state); |
1002 retVal = true; |
1136 retVal = true; |
1003 } |
1137 } |
1004 } |
1138 } |
1005 } |
1139 } |
1008 } |
1142 } |
1009 |
1143 |
1010 if (emitSessionClosed) { |
1144 if (emitSessionClosed) { |
1011 emit q->closed(); |
1145 emit q->closed(); |
1012 } |
1146 } |
|
1147 if (state == QNetworkSession::Disconnected) { |
|
1148 // The connection has gone down, and processing of status updates must be |
|
1149 // stopped. Depending on platform, there may come 'connecting/connected' states |
|
1150 // considerably later (almost a second). Connection id is an increasing |
|
1151 // number, so this does not affect next _real_ 'conneting/connected' states. |
|
1152 iDeprecatedConnectionId = publicConfig.d.data()->connectionId; |
|
1153 } |
1013 |
1154 |
1014 return retVal; |
1155 return retVal; |
1015 } |
1156 } |
1016 |
1157 |
1017 void QNetworkSessionPrivate::handleSymbianConnectionStatusChange(TInt aConnectionStatus, |
1158 void QNetworkSessionPrivate::handleSymbianConnectionStatusChange(TInt aConnectionStatus, |
1018 TInt aError, |
1159 TInt aError, |
1019 TUint accessPointId) |
1160 TUint accessPointId) |
1020 { |
1161 { |
|
1162 #ifdef QT_BEARERMGMT_SYMBIAN_DEBUG |
|
1163 qDebug() << "QNS this : " << QString::number((uint)this) << " - " << QString::number(accessPointId) << " , status : " << QString::number(aConnectionStatus); |
|
1164 #endif |
1021 switch (aConnectionStatus) |
1165 switch (aConnectionStatus) |
1022 { |
1166 { |
1023 // Connection unitialised |
1167 // Connection unitialised |
1024 case KConnectionUninitialised: |
1168 case KConnectionUninitialised: |
1025 break; |
1169 break; |
1080 |
1225 |
1081 // Connection blocked or suspended |
1226 // Connection blocked or suspended |
1082 case KDataTransferTemporarilyBlocked: |
1227 case KDataTransferTemporarilyBlocked: |
1083 break; |
1228 break; |
1084 |
1229 |
|
1230 case KConfigDaemonStartingDeregistration: |
1085 // Hangup or GRPS deactivation |
1231 // Hangup or GRPS deactivation |
1086 case KConnectionStartingClose: |
1232 case KConnectionStartingClose: |
1087 newState(QNetworkSession::Closing,accessPointId); |
1233 newState(QNetworkSession::Closing,accessPointId); |
1088 break; |
1234 break; |
1089 |
1235 |
1090 // Connection closed |
1236 // Connection closed |
1091 case KConnectionClosed: |
1237 case KConnectionClosed: |
1092 break; |
|
1093 |
|
1094 case KLinkLayerClosed: |
1238 case KLinkLayerClosed: |
1095 newState(QNetworkSession::Disconnected,accessPointId); |
1239 newState(QNetworkSession::Disconnected,accessPointId); |
1096 break; |
1240 // Report manager about this to make sure this event |
1097 |
1241 // is received by all interseted parties (mediated by |
|
1242 // manager because it does always receive all events from |
|
1243 // connection monitor). |
|
1244 #ifdef QT_BEARERMGMT_SYMBIAN_DEBUG |
|
1245 qDebug() << "QNS this : " << QString::number((uint)this) << " - " << "reporting disconnection to manager."; |
|
1246 #endif |
|
1247 if (publicConfig.d.data()) { |
|
1248 ((QNetworkConfigurationManagerPrivate*)publicConfig.d.data()->manager)->configurationStateChangeReport(publicConfig.d.data()->numericId, QNetworkSession::Disconnected); |
|
1249 } |
|
1250 break; |
1098 // Unhandled state |
1251 // Unhandled state |
1099 default: |
1252 default: |
1100 break; |
1253 break; |
1101 } |
1254 } |
1102 } |
1255 } |
1103 |
1256 |
1104 void QNetworkSessionPrivate::EventL(const CConnMonEventBase& aEvent) |
|
1105 { |
|
1106 switch (aEvent.EventType()) |
|
1107 { |
|
1108 case EConnMonConnectionStatusChange: |
|
1109 { |
|
1110 CConnMonConnectionStatusChange* realEvent; |
|
1111 realEvent = (CConnMonConnectionStatusChange*) &aEvent; |
|
1112 |
|
1113 TUint connectionId = realEvent->ConnectionId(); |
|
1114 TInt connectionStatus = realEvent->ConnectionStatus(); |
|
1115 |
|
1116 // Try to Find IAP Id using connection Id |
|
1117 TUint apId = 0; |
|
1118 if (publicConfig.type() == QNetworkConfiguration::ServiceNetwork) { |
|
1119 QList<QNetworkConfiguration> subConfigurations = publicConfig.children(); |
|
1120 for (int i = 0; i < subConfigurations.count(); i++ ) { |
|
1121 if (subConfigurations[i].d.data()->connectionId == connectionId) { |
|
1122 apId = subConfigurations[i].d.data()->numericId; |
|
1123 break; |
|
1124 } |
|
1125 } |
|
1126 } else if (publicConfig.type() == QNetworkConfiguration::InternetAccessPoint) { |
|
1127 if (publicConfig.d.data()->connectionId == connectionId) { |
|
1128 apId = publicConfig.d.data()->numericId; |
|
1129 } |
|
1130 } |
|
1131 |
|
1132 if (apId > 0) { |
|
1133 handleSymbianConnectionStatusChange(connectionStatus, KErrNone, apId); |
|
1134 } |
|
1135 } |
|
1136 break; |
|
1137 |
|
1138 case EConnMonCreateConnection: |
|
1139 { |
|
1140 CConnMonCreateConnection* realEvent; |
|
1141 realEvent = (CConnMonCreateConnection*) &aEvent; |
|
1142 TUint apId; |
|
1143 TUint connectionId = realEvent->ConnectionId(); |
|
1144 TRequestStatus status; |
|
1145 iConnectionMonitor.GetUintAttribute(connectionId, 0, KIAPId, apId, status); |
|
1146 User::WaitForRequest(status); |
|
1147 if (status.Int() == KErrNone) { |
|
1148 // Store connection id to related AccessPoint Configuration |
|
1149 if (publicConfig.type() == QNetworkConfiguration::ServiceNetwork) { |
|
1150 QList<QNetworkConfiguration> subConfigurations = publicConfig.children(); |
|
1151 for (int i = 0; i < subConfigurations.count(); i++ ) { |
|
1152 if (subConfigurations[i].d.data()->numericId == apId) { |
|
1153 subConfigurations[i].d.data()->connectionId = connectionId; |
|
1154 break; |
|
1155 } |
|
1156 } |
|
1157 } else if (publicConfig.type() == QNetworkConfiguration::InternetAccessPoint) { |
|
1158 if (publicConfig.d.data()->numericId == apId) { |
|
1159 publicConfig.d.data()->connectionId = connectionId; |
|
1160 } |
|
1161 } |
|
1162 } |
|
1163 } |
|
1164 break; |
|
1165 |
|
1166 case EConnMonDeleteConnection: |
|
1167 { |
|
1168 CConnMonDeleteConnection* realEvent; |
|
1169 realEvent = (CConnMonDeleteConnection*) &aEvent; |
|
1170 TUint connectionId = realEvent->ConnectionId(); |
|
1171 // Remove connection id from related AccessPoint Configuration |
|
1172 if (publicConfig.type() == QNetworkConfiguration::ServiceNetwork) { |
|
1173 QList<QNetworkConfiguration> subConfigurations = publicConfig.children(); |
|
1174 for (int i = 0; i < subConfigurations.count(); i++ ) { |
|
1175 if (subConfigurations[i].d.data()->connectionId == connectionId) { |
|
1176 subConfigurations[i].d.data()->connectionId = 0; |
|
1177 break; |
|
1178 } |
|
1179 } |
|
1180 } else if (publicConfig.type() == QNetworkConfiguration::InternetAccessPoint) { |
|
1181 if (publicConfig.d.data()->connectionId == connectionId) { |
|
1182 publicConfig.d.data()->connectionId = 0; |
|
1183 } |
|
1184 } |
|
1185 } |
|
1186 break; |
|
1187 |
|
1188 default: |
|
1189 // For unrecognized events |
|
1190 break; |
|
1191 } |
|
1192 } |
|
1193 |
|
1194 ConnectionProgressNotifier::ConnectionProgressNotifier(QNetworkSessionPrivate& owner, RConnection& connection) |
1257 ConnectionProgressNotifier::ConnectionProgressNotifier(QNetworkSessionPrivate& owner, RConnection& connection) |
1195 : CActive(CActive::EPriorityStandard), iOwner(owner), iConnection(connection) |
1258 : CActive(CActive::EPriorityUserInput), iOwner(owner), iConnection(connection) |
1196 { |
1259 { |
1197 CActiveScheduler::Add(this); |
1260 CActiveScheduler::Add(this); |
1198 } |
1261 } |
1199 |
1262 |
1200 ConnectionProgressNotifier::~ConnectionProgressNotifier() |
1263 ConnectionProgressNotifier::~ConnectionProgressNotifier() |