52 } |
52 } |
53 else if ( msg.iValue == TCFControlProvider::TDataClientStatusChange::EStarted && |
53 else if ( msg.iValue == TCFControlProvider::TDataClientStatusChange::EStarted && |
54 node.RequestPermissionToSendStarted() ) |
54 node.RequestPermissionToSendStarted() ) |
55 { |
55 { |
56 S60MCPRLOGSTRING2("S60MCPR<%x>::THandleMPMStatusChange::DoL() calling IAPConnectionStartedL IAP %d",(TInt*)&iContext.Node(),iapid) |
56 S60MCPRLOGSTRING2("S60MCPR<%x>::THandleMPMStatusChange::DoL() calling IAPConnectionStartedL IAP %d",(TInt*)&iContext.Node(),iapid) |
57 // TODO use progress notification KLinkLayerOpen once Symbian provides them. |
|
58 node.Policy()->IAPConnectionStartedL( iapid ); // codescanner::leave |
57 node.Policy()->IAPConnectionStartedL( iapid ); // codescanner::leave |
59 } |
58 } |
60 else if ( msg.iValue == TCFControlProvider::TDataClientStatusChange::EStopped && |
59 else if ( msg.iValue == TCFControlProvider::TDataClientStatusChange::EStopped && |
61 node.RequestPermissionToSendStopped() ) |
60 node.RequestPermissionToSendStopped() ) |
62 { |
61 { |
112 // We have AP that will go down. |
111 // We have AP that will go down. |
113 // And the other AP that will go up. |
112 // And the other AP that will go up. |
114 RNodeInterface* stoppingSP = NULL; |
113 RNodeInterface* stoppingSP = NULL; |
115 RNodeInterface* startingSP = NULL; |
114 RNodeInterface* startingSP = NULL; |
116 |
115 |
117 // The one that will be started is the one MPM selected. |
116 // Get the MCPR |
118 // Both must be present in the MCPR -plane. |
117 CS60MetaConnectionProvider& node = (CS60MetaConnectionProvider&)iContext.Node(); |
|
118 |
|
119 // At this point MCPR has selected two active IPProtoMCPRs. |
|
120 // The one that will be started is the one MPM selected and |
|
121 // the one which doesn't match the policy preferences is the |
|
122 // old selection and needs to be disconnected. |
|
123 // |
|
124 TUint32 newAP = node.PolicyPrefs().IapId(); |
|
125 ASSERT( newAP > 0 ); |
119 |
126 |
120 // Choose Service Providers to work on |
127 // Choose Service Providers to work on |
121 TClientIter<TDefaultClientMatchPolicy> iter = |
128 TClientIter<TDefaultClientMatchPolicy> iter = |
122 iContext.Node().GetClientIter<TDefaultClientMatchPolicy>(TClientType(TCFClientType::EServProvider)); |
129 iContext.Node().GetClientIter<TDefaultClientMatchPolicy>(TClientType(TCFClientType::EServProvider)); |
123 |
130 |
124 RNodeInterface* itf = NULL; |
131 RMetaServiceProviderInterface* itf = NULL; |
125 for ( itf = iter++; ( itf != NULL && ( stoppingSP == NULL || startingSP == NULL ) ); itf = iter++ ) |
132 //RNodeInterface* itf = NULL; |
126 { |
133 |
127 // Only one of the selected MCPRs can be EStarted. |
134 for ( itf = (RMetaServiceProviderInterface*)iter++; |
128 // |
135 ( itf != NULL && ( stoppingSP == NULL || startingSP == NULL ) ); |
129 if ( itf->Flags() & TCFClientType::EStarted ) |
136 itf = (RMetaServiceProviderInterface*)iter++ ) |
130 { |
137 { |
131 stoppingSP = itf; //Our current started Service Provider. |
138 if ( itf->Flags() & TCFClientType::EActive ) |
132 itf->ClearFlags( TCFClientType::EActive ); |
139 { |
133 } |
140 // Select one that shall be stopped. |
134 // The other which is not EStarted must be EActive. |
141 // |
135 // |
142 if ( itf->ProviderInfo().APId() != newAP ) |
136 else if ( itf->Flags() & TCFClientType::EActive ) |
143 { |
137 { |
144 stoppingSP = itf; |
138 startingSP = itf; //And the new one to try next |
145 itf->ClearFlags( TCFClientType::EActive ); |
|
146 } |
|
147 // Select one that shall be started |
|
148 // |
|
149 else if ( itf->ProviderInfo().APId() == newAP ) |
|
150 { |
|
151 startingSP = itf; |
|
152 itf->ClearFlags( TCFClientType::EActive ); |
|
153 } |
|
154 // no else. |
|
155 // |
139 } |
156 } |
140 } |
157 } |
141 // One must be started since this is already a reconnection |
158 // One must be started since this is already a reconnection |
142 if ( stoppingSP==NULL ) |
159 if ( stoppingSP==NULL ) |
143 { |
160 { |
145 S60MCPRLOGSTRING1("S60MCPR<%x>::TRequestReConnect::DoL() - started service provider not found.",(TInt*)&iContext.Node()) |
162 S60MCPRLOGSTRING1("S60MCPR<%x>::TRequestReConnect::DoL() - started service provider not found.",(TInt*)&iContext.Node()) |
146 ASSERT( EFalse ); |
163 ASSERT( EFalse ); |
147 User::Leave( KErrCorrupt ); // codescanner::leave |
164 User::Leave( KErrCorrupt ); // codescanner::leave |
148 } |
165 } |
149 |
166 |
150 //Sanity check. |
|
151 //The new provider must not be started, there can be only one started at a time. |
|
152 ASSERT( startingSP == NULL || ( startingSP->Flags() & TCFClientType::EStarted ) == 0 ); |
|
153 |
|
154 //If there is no other Service Provider to try, return KErrNotFound |
167 //If there is no other Service Provider to try, return KErrNotFound |
155 if ( startingSP == NULL ) |
168 if ( startingSP == NULL ) |
156 { |
169 { |
157 S60MCPRLOGSTRING1("S60MCPR<%x>::TRequestReConnect::DoL() - no more choices, abandoning recovery.",(TInt*)&iContext.Node()) |
170 S60MCPRLOGSTRING1("S60MCPR<%x>::TRequestReConnect::DoL() - no more choices, abandoning recovery.",(TInt*)&iContext.Node()) |
158 User::Leave( KErrNotFound ); // codescanner::leave |
171 User::Leave( KErrNotFound ); // codescanner::leave |