|
1 /* |
|
2 * Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 |
|
22 #include "senmobilityobserver.h" |
|
23 #include <SenTransportProperties.h> |
|
24 #include "SenWSPattern.h" |
|
25 #include "MSenProperties.h" |
|
26 #include "SenLayeredTransportProperties.h" |
|
27 #include "SenLogger.h" |
|
28 #include "SenServiceManagerDefines.h" |
|
29 |
|
30 // ----------------------------------------------------------------------------- |
|
31 // CALRObserver::NewL |
|
32 // ----------------------------------------------------------------------------- |
|
33 // |
|
34 CALRObserver* CALRObserver::NewL(MMobilityProtocolResp& aMobilityObserver, CSenXmlReader &aReader) |
|
35 { |
|
36 CALRObserver* self = new ( ELeave ) CALRObserver(aMobilityObserver, aReader); |
|
37 CleanupStack::PushL( self ); |
|
38 self->ConstructL(); |
|
39 CleanupStack::Pop( self ); |
|
40 return self; |
|
41 } |
|
42 |
|
43 // ----------------------------------------------------------------------------- |
|
44 // CALRObserver::ConstructL |
|
45 // ----------------------------------------------------------------------------- |
|
46 // |
|
47 void CALRObserver::ConstructL() |
|
48 { |
|
49 #ifdef _SENDEBUG |
|
50 TFileName logFile; |
|
51 logFile.Append( KSenMobilityLog().Left(KSenMobilityLog().Length()-4) ); // exclude ".log" file extension |
|
52 TDateTime time; |
|
53 TTime start; |
|
54 start.HomeTime(); |
|
55 time=start.DateTime(); |
|
56 |
|
57 logFile.AppendNum( time.Hour() ); |
|
58 logFile.Append( KSenUnderline ); |
|
59 logFile.AppendNum( time.Minute() ); |
|
60 logFile.Append( KSenUnderline ); |
|
61 logFile.AppendNum( time.Second() ); |
|
62 logFile.Append( KSenMobilityLog().Right(4) ); // postfix with ".log" file extension |
|
63 TLSLOG_OPEN(KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel, KSenMobilityDir, logFile); |
|
64 #endif |
|
65 User::LeaveIfError( iSocketServer.Connect()); |
|
66 TLSLOG_L(KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , "CALRObserver::ConstructL()"); |
|
67 } |
|
68 |
|
69 // ----------------------------------------------------------------------------- |
|
70 // CALRObserver::CALRObserver |
|
71 // ----------------------------------------------------------------------------- |
|
72 CALRObserver::CALRObserver(MMobilityProtocolResp &aMobilityObserver, CSenXmlReader &aReader) |
|
73 : CActive( CActive::EPriorityStandard ), |
|
74 iMobilityObserver( aMobilityObserver ), |
|
75 iMobility(NULL), |
|
76 iIapId(0), |
|
77 iNewIapId(0), |
|
78 iSnapId(0), |
|
79 iReader(aReader) |
|
80 { |
|
81 CActiveScheduler::Add( this ); |
|
82 } |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // CALRObserver::~CALRObserver |
|
86 // ----------------------------------------------------------------------------- |
|
87 // |
|
88 CALRObserver::~CALRObserver() |
|
89 { |
|
90 TLSLOG_L(KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , "CALRObserver::~CALRObserver() started"); |
|
91 if (iMobility != NULL) |
|
92 { |
|
93 delete iMobility; |
|
94 TLSLOG_L(KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , "-iMobility deleted "); |
|
95 } |
|
96 Cancel(); |
|
97 TUint openCount(0); |
|
98 TInt retVal = iConnection.EnumerateConnections(openCount); |
|
99 if(retVal == KErrNone) |
|
100 { |
|
101 TLSLOG_FORMAT((KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , _L8("- connections count : [%d] "), openCount)); |
|
102 } |
|
103 iConnection.Close(); |
|
104 iSocketServer.Close(); |
|
105 TLSLOG_L(KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , "CALRObserver::~CALRObserver() completed"); |
|
106 #ifdef _SENDEBUG |
|
107 TLSLOG_CLOSE(KSenSenMobilityLogChannelBase); |
|
108 #endif |
|
109 } |
|
110 |
|
111 // ----------------------------------------------------------------------------- |
|
112 // CApplicationUsingSNAP::DoCancel |
|
113 // ----------------------------------------------------------------------------- |
|
114 // |
|
115 void CALRObserver::DoCancel() |
|
116 { |
|
117 iConnection.Close(); |
|
118 // iConnection.Stop() should be avoided: |
|
119 // other client applications' connection should not be terminated. |
|
120 } |
|
121 |
|
122 // ----------------------------------------------------------------------------- |
|
123 // CApplicationUsingSNAP::RunL |
|
124 // ----------------------------------------------------------------------------- |
|
125 // |
|
126 void CALRObserver::RunL() |
|
127 { |
|
128 if ( iStatus.Int() == KErrNone ) |
|
129 { |
|
130 TUint32 iap( 0 ); |
|
131 iConnection.GetIntSetting( _L( "IAP\\Id" ), iap ); |
|
132 iIapId = iap ; |
|
133 TLSLOG_FORMAT((KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , _L8("-RunL registering mobility using IAPID: %d "), iIapId)); |
|
134 TRAPD(err, iMobility = CActiveCommsMobilityApiExt::NewL( iConnection, *this )) ; |
|
135 TLSLOG_FORMAT((KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , _L8("- registered for mobility service returned : %d "), err)); |
|
136 } |
|
137 else |
|
138 { |
|
139 //RunL status error: " ) ); |
|
140 User::Leave(iStatus.Int()) ; |
|
141 } |
|
142 } |
|
143 |
|
144 // ----------------------------------------------------------------------------- |
|
145 // CALRObserver::RunError |
|
146 // ----------------------------------------------------------------------------- |
|
147 // |
|
148 TInt CALRObserver::RunError( TInt aError ) |
|
149 { |
|
150 TLSLOG_FORMAT((KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , _L8("-CALRObserver::RunError received with error = %d"), aError)); |
|
151 return KErrNone; |
|
152 } |
|
153 |
|
154 // ----------------------------------------------------------------------------- |
|
155 // CApplicationUsingSNAP::GetActiveIap |
|
156 // ----------------------------------------------------------------------------- |
|
157 // |
|
158 TUint32 CALRObserver::GetActiveIap() |
|
159 { |
|
160 TLSLOG_FORMAT((KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , _L8("- GetActiveIap (ID: %d) "), iIapId)); |
|
161 return iIapId ; |
|
162 } |
|
163 |
|
164 TUint32 CALRObserver::GetActiveSnap() |
|
165 { |
|
166 TLSLOG_FORMAT((KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , _L8("- GetActiveSnap (ID: %d) "), iSnapId)); |
|
167 return iSnapId ; |
|
168 } |
|
169 |
|
170 // ----------------------------------------------------------------------------- |
|
171 // CALRObserver::PreferredCarrierAvailable |
|
172 // ----------------------------------------------------------------------------- |
|
173 // |
|
174 void CALRObserver::PreferredCarrierAvailable( TAccessPointInfo aOldAPInfo, |
|
175 TAccessPointInfo aNewAPInfo, |
|
176 TBool aIsUpgrade, |
|
177 TBool aIsSeamless ) |
|
178 { |
|
179 TLSLOG_L(KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , "- PreferredCarrierAvailable callback received "); |
|
180 TLSLOG_FORMAT((KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , _L8("- PreferredCarrierAvailable with old iapid = %d"), aOldAPInfo.AccessPoint())); |
|
181 TLSLOG_FORMAT((KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , _L8("- PreferredCarrierAvailable with new iapid = %d"), aNewAPInfo.AccessPoint())); |
|
182 if ( aIsUpgrade ) |
|
183 { |
|
184 TLSLOG_L(KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , "- PreferredCarrierAvailable it is upgrade "); |
|
185 } |
|
186 else |
|
187 { |
|
188 TLSLOG_L(KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , "- PreferredCarrierAvailable it is not upgrade "); |
|
189 } |
|
190 if (aIsSeamless) |
|
191 { |
|
192 // in S60 3.2, this situation cannot occur. |
|
193 TLSLOG_L(KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , "-it is seemless in S60 3.2, this situation cannot occur. "); |
|
194 } |
|
195 if (iIapId != aOldAPInfo.AccessPoint()) |
|
196 { |
|
197 //we received callback for unwanted iap ids |
|
198 TLSLOG_L(KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , "- ASSERT ERROR PreferredCarrierAvailable callback received "); |
|
199 } |
|
200 else |
|
201 { |
|
202 if (iIapId != aNewAPInfo.AccessPoint()) |
|
203 { |
|
204 TLSLOG_FORMAT((KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , _L8("- forwarding call PreferredCarrierAvailable callback to observer with iapID %d"), aNewAPInfo.AccessPoint())); |
|
205 iMobilityObserver.PreferredCarrierAvailable( aOldAPInfo, |
|
206 aNewAPInfo, |
|
207 aIsUpgrade, |
|
208 aIsSeamless ) ; |
|
209 } |
|
210 else |
|
211 { |
|
212 TLSLOG_FORMAT((KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , _L8("- ASSERT ERROR iIapId cant be same with newIap as iIapId = %d, newIap = %d"), iIapId, aNewAPInfo.AccessPoint())); |
|
213 } |
|
214 } |
|
215 } |
|
216 |
|
217 // ----------------------------------------------------------------------------- |
|
218 // CALRObserver::NewCarrierActive |
|
219 // ----------------------------------------------------------------------------- |
|
220 // |
|
221 void CALRObserver::NewCarrierActive( TAccessPointInfo aNewAPInfo, TBool aIsSeamless ) |
|
222 { |
|
223 TLSLOG_L(KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , "- NewCarrierActive callback received "); |
|
224 TLSLOG_FORMAT((KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , _L8("- NewCarrierActive with new iapid = %d"), aNewAPInfo.AccessPoint())); |
|
225 if ( aIsSeamless ) |
|
226 { |
|
227 TLSLOG_L(KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , "- NewCarrierActive it is seemless "); |
|
228 } |
|
229 else |
|
230 { |
|
231 TLSLOG_L(KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , "- NewCarrierActive it is not seemless "); |
|
232 } |
|
233 if (iIapId != aNewAPInfo.AccessPoint()) |
|
234 { |
|
235 iNewIapId = aNewAPInfo.AccessPoint() ; |
|
236 TLSLOG_FORMAT((KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , _L8("- frowarding NewCarrierActive callback to observer with new IAPID = %d"), iNewIapId)); |
|
237 iMobilityObserver.NewCarrierActive( aNewAPInfo, aIsSeamless ) ; |
|
238 } |
|
239 else |
|
240 { |
|
241 TLSLOG_FORMAT((KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , _L8("- ASSERT ERROR NewCarrierActive callback received with oldIapId = %d, newIapInfo = %d "), iIapId, aNewAPInfo.AccessPoint() )); |
|
242 //we received callback for wrong PreferredCarrierAvailable call |
|
243 } |
|
244 } |
|
245 |
|
246 // ----------------------------------------------------------------------------- |
|
247 // CApplicationUsingSNAP::DoCancel |
|
248 // ----------------------------------------------------------------------------- |
|
249 // |
|
250 void CALRObserver::Error(TInt aError) |
|
251 { |
|
252 //iConnection.Stop(); |
|
253 if (aError != KErrCancel) |
|
254 { |
|
255 TLSLOG_FORMAT((KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , _L8("-CALRObserver::Error callback received with error = %d"), aError)); |
|
256 TLSLOG_L(KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , "-forwarding mobility Error callback to consumer"); |
|
257 iMobilityObserver.Error(aError) ; |
|
258 } |
|
259 else |
|
260 { |
|
261 TLSLOG_L(KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , "-User Canceled mobility Service"); |
|
262 } |
|
263 } |
|
264 |
|
265 void CALRObserver::MigrateToPreferredCarrier() |
|
266 { |
|
267 TLSLOG_L(KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , "- CALRObserver::MigrateToPreferredCarrier "); |
|
268 if (iMobility) |
|
269 { |
|
270 iMobility->MigrateToPreferredCarrier(); |
|
271 } |
|
272 else |
|
273 { |
|
274 TLSLOG_L(KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , "- iMobility object is NULL"); |
|
275 } |
|
276 } |
|
277 |
|
278 void CALRObserver::IgnorePreferredCarrier() |
|
279 { |
|
280 TLSLOG_L(KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , "- CALRObserver::IgnorePreferredCarrier "); |
|
281 if (iMobility) |
|
282 { |
|
283 iMobility->IgnorePreferredCarrier(); |
|
284 } |
|
285 else |
|
286 { |
|
287 TLSLOG_L(KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , "- iMobility object is NULL"); |
|
288 } |
|
289 } |
|
290 |
|
291 void CALRObserver::NewCarrierAccepted() |
|
292 { |
|
293 TLSLOG_L(KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , "- CALRObserver::NewCarrierAccepted "); |
|
294 if (iMobility) |
|
295 { |
|
296 iMobility->NewCarrierAccepted(); |
|
297 } |
|
298 else |
|
299 { |
|
300 TLSLOG_L(KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , "- iMobility object is NULL"); |
|
301 } |
|
302 } |
|
303 |
|
304 void CALRObserver::NewCarrierRejected() |
|
305 { |
|
306 TLSLOG_L(KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , "- CALRObserver::NewCarrierRejected "); |
|
307 if (iMobility) |
|
308 { |
|
309 iMobility->NewCarrierRejected(); |
|
310 } |
|
311 else |
|
312 { |
|
313 TLSLOG_L(KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , "- iMobility object is NULL"); |
|
314 } |
|
315 } |
|
316 |
|
317 // ----------------------------------------------------------------------------- |
|
318 // CALRObserver::OpenSocketSever |
|
319 // ----------------------------------------------------------------------------- |
|
320 // |
|
321 TInt CALRObserver::OpenSocketSever() |
|
322 { |
|
323 TLSLOG_L(KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , "- OpenSocketSever "); |
|
324 TInt err( KErrNone ); |
|
325 // If iConnection is already open don't reopen it. |
|
326 if( !iConnection.SubSessionHandle() ) |
|
327 { |
|
328 TLSLOG_L(KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , "- calling iConnection.Open "); |
|
329 err = iConnection.Open(iSocketServer); |
|
330 } |
|
331 return err; |
|
332 } |
|
333 |
|
334 HBufC8* CALRObserver::GetNewIapAsTransportPropertyL() |
|
335 { |
|
336 TLSLOG_L(KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , "- GetNewIapAsTransportPropertyL "); |
|
337 CSenTransportProperties * pTransportProperties = CSenTransportProperties::NewL(); |
|
338 if (iIapId != iNewIapId) |
|
339 { |
|
340 TLSLOG_FORMAT((KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , _L8("-GetNewIapAsTransportPropertyL filling up transport properties with iNewIapId = %d"), iNewIapId)); |
|
341 pTransportProperties->SetIapIdL(iNewIapId) ; |
|
342 iIapId = iNewIapId ; //reseting current iapid as the new iapid for internal purpose |
|
343 return pTransportProperties->AsUtf8L() ; |
|
344 } |
|
345 else |
|
346 { |
|
347 delete pTransportProperties ; |
|
348 return NULL ; |
|
349 } |
|
350 } |
|
351 |
|
352 TInt CALRObserver::OpenConnectionL(TDesC8& aAppTransportProperties, |
|
353 MSenTransport &aTransport, |
|
354 CSenWSDescription& aInitializer, |
|
355 HBufC8*& apNewTransportProperties) |
|
356 { |
|
357 TLSLOG_L(KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , "- CALRObserver::OpenConnectionL "); |
|
358 CSenTransportProperties * pTransportProperties = CSenTransportProperties::NewL(aAppTransportProperties, iReader); |
|
359 TUint32 id(0); |
|
360 TBool isSnap(EFalse) ; |
|
361 TBool isStartConnectionRequired(EFalse) ; |
|
362 |
|
363 TLSLOG_L(KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , "- trying to get SNAPID from pTransportProperties "); |
|
364 TInt error = pTransportProperties->SnapIdL(id) ; |
|
365 if(error || id >= (TUint)KErrNotFound) // |
|
366 { |
|
367 TLSLOG_L(KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , "- trying to get IAPID from pTransportProperties "); |
|
368 error = pTransportProperties->IapIdL(id); |
|
369 } |
|
370 else |
|
371 { |
|
372 isSnap = ETrue ; |
|
373 } |
|
374 |
|
375 if(error || id >= (TUint)KErrNotFound) |
|
376 { |
|
377 //Application Did not provide IAP ID through transport properties |
|
378 //Now we need to check consumer and provider policy of service description |
|
379 |
|
380 if( aInitializer.DescriptionClassType() == MSenServiceDescription::EWSPattern ) |
|
381 { |
|
382 // Check if <ConsumerPolicy/> was defined in SC aInitializer (constructor argument) |
|
383 // and if IAP was predefined |
|
384 CSenWSPattern* pConsumerPolicy = (CSenWSPattern*)&aInitializer; |
|
385 TLSLOG_L(KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , "- trying to get SNAPID from pConsumerPolicy "); |
|
386 error = pConsumerPolicy->ConsumerSnapId( id ); |
|
387 if(error || id >= (TUint)KErrNotFound) |
|
388 { |
|
389 TLSLOG_L(KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , "- trying to get IAPID from pConsumerPolicy "); |
|
390 error = pConsumerPolicy->ConsumerIapId( id ); |
|
391 } |
|
392 else |
|
393 { |
|
394 isSnap = ETrue ; |
|
395 } |
|
396 } |
|
397 if( error || id >= (TUint)KErrNotFound) // IAP ID must be 0...INT_MAX, since (TUInt)KErrNotFound == INT_MAX+1 |
|
398 { |
|
399 // Check if <ProviderPolicy/> was defined in SC aInitializer (constructor argument) |
|
400 // and if IAP was predefined |
|
401 TLSLOG_L(KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , "- trying to get SNAPID from aInitializer "); |
|
402 error = aInitializer.SnapId( id ); |
|
403 if(error || id >= (TUint)KErrNotFound) |
|
404 { |
|
405 TLSLOG_L(KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , "- trying to get IAPID from aInitializer "); |
|
406 error = aInitializer.IapId( id ); |
|
407 } |
|
408 else |
|
409 { |
|
410 isSnap = ETrue ; |
|
411 } |
|
412 } |
|
413 if( error || id >= (TUint)KErrNotFound) // IAP ID must be 0...INT_MAX, since (TUInt)KErrNotFound == INT_MAX+1 |
|
414 { |
|
415 //initialiser didnot provide iap/snap id |
|
416 //if another SC has already set up a transport we dont want to prompt |
|
417 MSenProperties& property = aTransport.PropertiesL() ; |
|
418 switch (property.PropertiesClassType()) |
|
419 { |
|
420 case MSenProperties::ESenLayeredTransportProperties: |
|
421 case MSenProperties::ESenLayeredHttpTransportProperties: |
|
422 case MSenProperties::ESenLayeredVtcpTransportProperties: |
|
423 { |
|
424 CSenLayeredTransportProperties& layerdPropery = (CSenLayeredTransportProperties&)property ; |
|
425 TLSLOG_L(KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , "- trying to get SNAPID from layerdPropery "); |
|
426 error = layerdPropery.SnapIdL(id) ; |
|
427 if(error || id >= (TUint)KErrNotFound) |
|
428 { |
|
429 TLSLOG_L(KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , "- trying to get IAPID from layerdPropery "); |
|
430 error = layerdPropery.IapIdL(id) ; |
|
431 } |
|
432 else |
|
433 { |
|
434 isSnap = ETrue ; |
|
435 } |
|
436 } |
|
437 break; |
|
438 } |
|
439 } |
|
440 } |
|
441 |
|
442 TUint32 openId(id); |
|
443 if (iIapId == 0 && iSnapId == 0) |
|
444 { |
|
445 //check with first Snapid |
|
446 isStartConnectionRequired = ETrue ; |
|
447 TLSLOG_FORMAT((KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , _L8("- StartConnection required as (iIapId == 0 && iSnapId == 0) openId = %d, isSnap = %d, iIapId = %d and iSnapId = %d "), openId, isSnap, iIapId, iSnapId)); |
|
448 } |
|
449 else if(isSnap != EFalse && openId != iSnapId) |
|
450 { |
|
451 isStartConnectionRequired = ETrue ; |
|
452 TLSLOG_FORMAT((KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , _L8("- StartConnection required as (isSnap == EFalse && openId != iIapId) openId = %d, isSnap = %d and iSnapId = %d "), openId, isSnap, iSnapId)); |
|
453 } |
|
454 else if(isSnap == EFalse && openId != iIapId) |
|
455 { |
|
456 isStartConnectionRequired = ETrue ; |
|
457 TLSLOG_FORMAT((KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , _L8("-StartConnection required aws (isSnap == EFalse && openId != iIapId) openId = %d, isSnap = %d and iIapId = %d"), openId, isSnap, iIapId)); |
|
458 } |
|
459 else |
|
460 { |
|
461 isStartConnectionRequired = EFalse ; |
|
462 TLSLOG_L(KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , "- call StartConnection not required "); |
|
463 } |
|
464 if (isStartConnectionRequired != EFalse) |
|
465 { |
|
466 TLSLOG_L(KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , "- calling StartConnection "); |
|
467 error = StartConnection(openId, isSnap) ; |
|
468 if (openId != id) |
|
469 { |
|
470 TLSLOG_FORMAT((KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , _L8("- OpenConnectionL setting up transport properties with iapid %d "), openId)); |
|
471 pTransportProperties->SetIapIdL(openId) ; |
|
472 apNewTransportProperties = pTransportProperties->AsUtf8LC() ; |
|
473 //CleanupStack::PopAndDestroy(pTransportProperties); |
|
474 delete pTransportProperties; |
|
475 pTransportProperties = NULL; |
|
476 CleanupStack::Pop(); |
|
477 } |
|
478 else |
|
479 { |
|
480 apNewTransportProperties = NULL ; |
|
481 } |
|
482 } |
|
483 else |
|
484 { |
|
485 TLSLOG_L(KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , "- OpenConnectionL returning apNewTransportProperties = NULL "); |
|
486 apNewTransportProperties = NULL ; |
|
487 if (iMobility) |
|
488 { |
|
489 //Already Registered for mobility service for the iap |
|
490 TLSLOG_L(KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , "- OpenConnectionL Already Registered for mobility service for the iap"); |
|
491 error = KErrNone ; |
|
492 } |
|
493 } |
|
494 TLSLOG_FORMAT((KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , _L8("- CALRObserver::OpenConnectionL returnd %d "), error)); |
|
495 return error ; |
|
496 } |
|
497 // ----------------------------------------------------------------------------- |
|
498 // CALRObserver::StartConnection |
|
499 // ----------------------------------------------------------------------------- |
|
500 // |
|
501 TInt CALRObserver::StartConnection(TUint32& aId, TBool aIsSnapId) |
|
502 { |
|
503 TLSLOG_L(KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , "- CALRObserver::StartConnection "); |
|
504 TLSLOG_FORMAT((KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , _L8("- CALRObserver::StartConnection aId(%d) aIsSnapId(%d) "), aId, aIsSnapId)); |
|
505 TInt errRet = KErrNone; |
|
506 if( !IsActive() ) |
|
507 { |
|
508 if (aIsSnapId == EFalse) |
|
509 { |
|
510 if (aId !=0 && aId != iIapId) |
|
511 { |
|
512 // IAP ID is provided and the new IAPID is not equal to the old IAP ID |
|
513 //we need to close old Connection and start the Connection with new |
|
514 //IAPID as application is interested to change it on fly |
|
515 //but openId must not be Zero (0) |
|
516 iConnection.Close(); |
|
517 TLSLOG_L(KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , "- CALRObserver::StartConnection iConnection closed as new IAPID for the same connection"); |
|
518 } |
|
519 } |
|
520 else |
|
521 { |
|
522 if (aId !=0 && aId != iSnapId) |
|
523 { |
|
524 // SNAP ID is provided and the new SNAPID is not equal to the old SNAP ID |
|
525 //we need to close old Connection and start the Connection with new |
|
526 //SNAPID as application is interested to change it on fly |
|
527 //but openId must not be Zero (0) |
|
528 iConnection.Close(); |
|
529 TLSLOG_L(KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , "- CALRObserver::StartConnection iConnection closed as new SNAPID for the same connection"); |
|
530 } |
|
531 } |
|
532 errRet = OpenSocketSever(); |
|
533 if (!errRet) |
|
534 { |
|
535 if(aIsSnapId != EFalse && aId) |
|
536 { |
|
537 iSnapId = aId ; |
|
538 iSNAPPrefs.SetSnap( aId ); |
|
539 // Start connecting with Snap |
|
540 errRet = iConnection.Start(iSNAPPrefs); |
|
541 TLSLOG_L(KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , "- CALRObserver::StartConnection iConnection Started with SNAP"); |
|
542 } |
|
543 else //default is iap |
|
544 { |
|
545 if( aId ) |
|
546 { |
|
547 iPrefs.SetIapId( aId ); |
|
548 SetDialogPref(EFalse) ; |
|
549 // Start connecting with IAP |
|
550 errRet = iConnection.Start(iPrefs); |
|
551 TLSLOG_FORMAT((KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , _L8("- CALRObserver::StartConnection connection started with iapid %d and preference"), aId)); |
|
552 } |
|
553 else |
|
554 { |
|
555 if (iIapId != 0) |
|
556 { |
|
557 //OpenSocketSever is already called for this iIapId When multiple |
|
558 //sendL are calld for the same IAPId StartConnection may be called |
|
559 //unintentionaly and may create crash |
|
560 //strange case StartConnection must not be called in this case |
|
561 TLSLOG_L(KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , "- CALRObserver::StartConnection connection StartConnection must not be called as aId == 0 and iIapId != 0"); |
|
562 } |
|
563 else |
|
564 { |
|
565 //Using Default Connection |
|
566 TLSLOG_L(KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , "- CALRObserver::StartConnection connection started Using Default Connection"); |
|
567 errRet = iConnection.Start(); |
|
568 } |
|
569 } |
|
570 } |
|
571 if (errRet == KErrNone) |
|
572 { |
|
573 //iConnection.GetIntSetting( _L( "IAP\\Id" ), aId ); |
|
574 _LIT( KIapId, "IAP\\Id"); |
|
575 iConnection.GetIntSetting( KIapId, aId ); |
|
576 TLSLOG_FORMAT((KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , _L8("- CALRObserver::StartConnection iConnection.GetIntSetting returned iapid = %d"), aId)); |
|
577 TRAPD(err, RefreshAvailabilityL()) ; |
|
578 if(err == KErrNone) |
|
579 { |
|
580 iIapId = aId ; |
|
581 } |
|
582 } |
|
583 //SetActive(); |
|
584 } |
|
585 } |
|
586 return errRet; |
|
587 } |
|
588 |
|
589 void CALRObserver::SetDialogPref(TBool aDialogPref) |
|
590 { |
|
591 if (aDialogPref == EFalse) |
|
592 { |
|
593 TLSLOG_L(KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , "- CALRObserver::SetDialogPref is FALSE"); |
|
594 iPrefs.SetDialogPreference( ECommDbDialogPrefDoNotPrompt ); |
|
595 } |
|
596 else |
|
597 { |
|
598 TLSLOG_L(KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel ,"- CALRObserver::SetDialogPref is TRUE"); |
|
599 iPrefs.SetDialogPreference( ECommDbDialogPrefPrompt ); |
|
600 } |
|
601 } |
|
602 |
|
603 // ----------------------------------------------------------------------------- |
|
604 // CALRObserver::RefreshAvailability |
|
605 // ----------------------------------------------------------------------------- |
|
606 // |
|
607 void CALRObserver::RefreshAvailabilityL() |
|
608 { |
|
609 TLSLOG_L(KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , "- CALRObserver::RefreshAvailabilityL"); |
|
610 if ( iMobility ) |
|
611 { |
|
612 delete iMobility; |
|
613 iMobility = NULL; |
|
614 } |
|
615 TRAPD(err, iMobility = CActiveCommsMobilityApiExt::NewL( iConnection, *this )) ; |
|
616 TLSLOG_FORMAT((KSenSenMobilityLogChannelBase, KSenSenMobilityLogLevel , _L8("- registered for mobility service returned : %d "), err)); |
|
617 } |
|
618 |
|
619 //End of File |