|
1 /* |
|
2 * Copyright (c) 2002-2009 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: PSD fax connection information. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <utf.h> |
|
19 |
|
20 #include "ConnMonServ.h" |
|
21 #include "ConnMonIAP.h" |
|
22 #include "CEventQueue.h" |
|
23 #include "CPsdFax.h" |
|
24 #include "log.h" |
|
25 |
|
26 // ============================ MEMBER FUNCTIONS =============================== |
|
27 |
|
28 // ----------------------------------------------------------------------------- |
|
29 // CPsdFax::CPsdFax |
|
30 // ----------------------------------------------------------------------------- |
|
31 // |
|
32 CPsdFax::CPsdFax( |
|
33 CConnMonServer* aServer, |
|
34 RTelServer* aTelServer, |
|
35 RMobilePhone* aMobilePhone, |
|
36 RPacketService* aPacketService ) |
|
37 : |
|
38 iServer( aServer ), |
|
39 iTelServer( aTelServer ), |
|
40 iMobilePhone( aMobilePhone ), |
|
41 iPacketService( aPacketService ) |
|
42 { |
|
43 } |
|
44 |
|
45 // ----------------------------------------------------------------------------- |
|
46 // CPsdFax::ConstructL |
|
47 // ----------------------------------------------------------------------------- |
|
48 // |
|
49 void CPsdFax::ConstructL() |
|
50 { |
|
51 //LOGENTRFN("CPsdFax::ConstructL()") |
|
52 |
|
53 // Create external connection Up notifier object |
|
54 if ( !iConnUpNotifier ) |
|
55 { |
|
56 iConnUpNotifier = new( ELeave ) CPsdFaxUpNotifier( |
|
57 this, |
|
58 iServer, |
|
59 iPacketService ); |
|
60 // Set object to active scheduler |
|
61 iConnUpNotifier->Construct(); |
|
62 |
|
63 // Start listening events from RConnection |
|
64 iConnUpNotifier->Receive(); |
|
65 } |
|
66 |
|
67 //LOGEXITFN("CPsdFax::ConstructL()") |
|
68 } |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // CPsdFax::~CPsdFax |
|
72 // ----------------------------------------------------------------------------- |
|
73 // |
|
74 CPsdFax::~CPsdFax() |
|
75 { |
|
76 // Delete connection Up notifier object |
|
77 if ( iConnUpNotifier ) |
|
78 { |
|
79 iConnUpNotifier->Cancel(); |
|
80 delete iConnUpNotifier; |
|
81 iConnUpNotifier = NULL; |
|
82 } |
|
83 |
|
84 // Delete all ConnectionData objects |
|
85 for ( TUint index = 0; index < KMaxPsdConnectionCount; index++ ) |
|
86 { |
|
87 if ( iConnectionData[index] ) |
|
88 { |
|
89 if ( iConnectionData[index]->IsOpen() ) |
|
90 { |
|
91 iConnectionData[index]->CloseContext(); |
|
92 } |
|
93 |
|
94 delete iConnectionData[index]; |
|
95 iConnectionData[index] = NULL; |
|
96 } |
|
97 } |
|
98 } |
|
99 |
|
100 |
|
101 // ----------------------------------------------------------------------------- |
|
102 // CPsdFax::OpenContext |
|
103 // ----------------------------------------------------------------------------- |
|
104 // |
|
105 TInt CPsdFax::OpenContext( const TUint aIndex, const TDes& aName ) |
|
106 { |
|
107 LOGENTRFN("CPsdFax::OpenContext()") |
|
108 TInt err( KErrNone ); |
|
109 |
|
110 // Create ConnectionData object |
|
111 if ( !iConnectionData[aIndex] ) |
|
112 { |
|
113 // Leave left out intentionally, check for NULL instead |
|
114 iConnectionData[aIndex] = new CPsdFaxConnectionData( this, iServer, iPacketService ); // No (ELeave) |
|
115 if ( !iConnectionData[aIndex] ) |
|
116 { |
|
117 err = KErrNoMemory; |
|
118 } |
|
119 else |
|
120 { |
|
121 // Start external connection status notifier |
|
122 err = iConnectionData[aIndex]->Construct(); |
|
123 if ( err != KErrNone ) |
|
124 { |
|
125 // Free allocated resources if failed |
|
126 err = KErrNoMemory; |
|
127 delete iConnectionData[aIndex]; |
|
128 iConnectionData[aIndex] = NULL; |
|
129 } |
|
130 } |
|
131 } |
|
132 |
|
133 if ( KErrNone == err ) |
|
134 { |
|
135 // Open context to be used in queries |
|
136 err = iConnectionData[aIndex]->OpenContext( aName ); |
|
137 if ( KErrNone == err ) |
|
138 { |
|
139 // Set start time to current time |
|
140 iConnectionData[aIndex]->ResetStartTime(); |
|
141 } |
|
142 else |
|
143 { |
|
144 // Free allocated resources if failed |
|
145 delete iConnectionData[aIndex]; |
|
146 iConnectionData[aIndex] = NULL; |
|
147 } |
|
148 } |
|
149 |
|
150 LOGEXITFN1("CPsdFax::OpenContext()", err) |
|
151 return err; |
|
152 } |
|
153 |
|
154 |
|
155 // ----------------------------------------------------------------------------- |
|
156 // CPsdFax::IsValid |
|
157 // ----------------------------------------------------------------------------- |
|
158 // |
|
159 TBool CPsdFax::IsValid( const TUint aConnectionId ) |
|
160 { |
|
161 LOGENTRFN("CPsdFax::IsValid()") |
|
162 TBool result( EFalse ); |
|
163 |
|
164 TInt index = ConnectionIndex( aConnectionId ); |
|
165 if ( KErrNotFound != index && iConnectionData[index]->IsOpen() ) |
|
166 { |
|
167 LOGIT("IsValid: connection is valid (open)") |
|
168 result = ETrue; |
|
169 } |
|
170 else if ( !iConnUpNotifier->IsActive() ) |
|
171 { |
|
172 LOGIT("IsValid: connection up notifier is not active -> restart listening") |
|
173 iConnUpNotifier->Receive(); // Restart listening |
|
174 } |
|
175 |
|
176 LOGEXITFN1("CPsdFax::IsValid()", result) |
|
177 return result; |
|
178 } |
|
179 |
|
180 |
|
181 // ----------------------------------------------------------------------------- |
|
182 // CPsdFax::ConnectionIndex |
|
183 // ----------------------------------------------------------------------------- |
|
184 // |
|
185 TInt CPsdFax::ConnectionIndex( const TUint aConnectionId ) |
|
186 { |
|
187 LOGENTRFN("CPsdFax::ConnectionIndex()") |
|
188 |
|
189 // Check PSD connection IDs |
|
190 for ( TInt index = 0; index < KMaxPsdConnectionCount; index++ ) |
|
191 { |
|
192 if ( iConnectionData[index] ) |
|
193 { |
|
194 // Return connection table index if IDs match |
|
195 if ( iConnectionData[index]->ConnectionId() == aConnectionId ) |
|
196 { |
|
197 LOGIT2("CPsdFax::ConnectionIndex() - ConnID %d match, return index %d", aConnectionId, index) |
|
198 LOGEXITFN("CPsdFax::ConnectionIndex()") |
|
199 return index; |
|
200 } |
|
201 } |
|
202 } |
|
203 |
|
204 LOGEXITFN("CPsdFax::ConnectionIndex()") |
|
205 return KErrNotFound; |
|
206 } |
|
207 |
|
208 |
|
209 // ----------------------------------------------------------------------------- |
|
210 // CPsdFax::SetConnectionId |
|
211 // ----------------------------------------------------------------------------- |
|
212 // |
|
213 TInt CPsdFax::SetConnectionId( const TUint aIndex, const TUint aConnectionId ) |
|
214 { |
|
215 LOGENTRFN("CPsdFax::SetConnectionId()") |
|
216 TInt err( KErrNone ); |
|
217 |
|
218 // Check if connection is open |
|
219 if ( !iConnectionData[aIndex]->IsOpen() ) |
|
220 { |
|
221 err = KErrNotFound; |
|
222 } |
|
223 else |
|
224 { |
|
225 // Set connection ID |
|
226 iConnectionData[aIndex]->SetConnectionId( aConnectionId ); |
|
227 } |
|
228 |
|
229 LOGEXITFN1("CPsdFax::SetConnectionId()", err) |
|
230 return err; |
|
231 } |
|
232 |
|
233 |
|
234 // ----------------------------------------------------------------------------- |
|
235 // CPsdFax::GetBearer |
|
236 // ----------------------------------------------------------------------------- |
|
237 // |
|
238 TInt CPsdFax::GetBearer( TInt& aBearer, TBearerInfo& aBearerInfo ) |
|
239 { |
|
240 LOGENTRFN("CPsdFax::GetBearer()") |
|
241 TInt err( KErrNone ); |
|
242 RMobilePhone::TMobilePhoneNetworkMode mode; |
|
243 |
|
244 err = iMobilePhone->GetCurrentMode( mode ); |
|
245 if ( KErrNone == err ) |
|
246 { |
|
247 switch( mode ) |
|
248 { |
|
249 case RMobilePhone::ENetworkModeWcdma: |
|
250 aBearer = EBearerExternalWCDMA; |
|
251 aBearerInfo.iBearer = iServer->Iap()->HsxpaStatus(); |
|
252 aBearerInfo.iInternal = EFalse; |
|
253 break; |
|
254 case RMobilePhone::ENetworkModeCdma2000: |
|
255 aBearer = EBearerExternalCDMA2000; |
|
256 aBearerInfo.iBearer = EBearerInfoCDMA2000; |
|
257 aBearerInfo.iInternal = EFalse; |
|
258 break; |
|
259 case RMobilePhone::ENetworkModeGsm: |
|
260 if ( iServer->Iap()->IsEdgeCell() ) |
|
261 { |
|
262 aBearer = EBearerExternalEdgeGPRS; |
|
263 aBearerInfo.iBearer = EBearerInfoEdgeGPRS; |
|
264 aBearerInfo.iInternal = EFalse; |
|
265 } |
|
266 else |
|
267 { |
|
268 aBearer = EBearerExternalGPRS; |
|
269 aBearerInfo.iBearer = EBearerInfoGPRS; |
|
270 aBearerInfo.iInternal = EFalse; |
|
271 } |
|
272 break; |
|
273 default: |
|
274 err = KErrUnknown; |
|
275 break; |
|
276 } |
|
277 } |
|
278 |
|
279 LOGEXITFN1("CPsdFax::GetBearer()", err) |
|
280 return err; |
|
281 } |
|
282 |
|
283 |
|
284 // ----------------------------------------------------------------------------- |
|
285 // CPsdFax::GetAPN |
|
286 // ----------------------------------------------------------------------------- |
|
287 // |
|
288 TInt CPsdFax::GetApn( const TUint aConnectionId, TDes& aName ) |
|
289 { |
|
290 LOGENTRFN("CPsdFax::GetApn()") |
|
291 TInt err( KErrNone ); |
|
292 TInt bearer( 0 ); |
|
293 TBearerInfo bearerInfo; |
|
294 |
|
295 // Check if connection ID is valid and connection is open |
|
296 TInt index = ConnectionIndex( aConnectionId ); |
|
297 if ( KErrNotFound == index || !iConnectionData[index]->IsOpen() ) |
|
298 { |
|
299 err = KErrNotFound; |
|
300 } |
|
301 else |
|
302 { |
|
303 err = GetBearer( bearer, bearerInfo ); |
|
304 if ( KErrNone == err ) |
|
305 { |
|
306 if ( !( bearer != EBearerExternalCDMA2000 && |
|
307 ( bearerInfo.iBearer != EBearerInfoCDMA2000 && !bearerInfo.iInternal ) ) ) |
|
308 { |
|
309 err = KErrNotSupported; |
|
310 LOGIT("GetApn: bearer == EBearerExternalCDMA2000, returning KErrNotSupported") |
|
311 } |
|
312 else |
|
313 { |
|
314 // Get connection APN |
|
315 err = iConnectionData[index]->GetApn( aName ); |
|
316 } |
|
317 } |
|
318 } |
|
319 |
|
320 LOGEXITFN1("CPsdFax::GetApn()", err) |
|
321 return err; |
|
322 } |
|
323 |
|
324 |
|
325 // ----------------------------------------------------------------------------- |
|
326 // CPsdFax::GetProtocolType |
|
327 // ----------------------------------------------------------------------------- |
|
328 // |
|
329 TInt CPsdFax::GetProtocolType( const TUint aConnectionId, TInt& aProtocolType ) |
|
330 { |
|
331 LOGENTRFN("CPsdFax::GetProtocolType()") |
|
332 TInt err( KErrNone ); |
|
333 TInt bearer( 0 ); |
|
334 TBearerInfo bearerInfo; |
|
335 |
|
336 // Check if connection ID is valid and connection is open |
|
337 TInt index = ConnectionIndex( aConnectionId ); |
|
338 if ( KErrNotFound == index || !iConnectionData[index]->IsOpen() ) |
|
339 { |
|
340 err = KErrNotFound; |
|
341 } |
|
342 else |
|
343 { |
|
344 err = GetBearer( bearer, bearerInfo ); |
|
345 if ( KErrNone == err ) |
|
346 { |
|
347 if ( !( bearer != EBearerExternalCDMA2000 && |
|
348 ( bearerInfo.iBearer != EBearerInfoCDMA2000 && !bearerInfo.iInternal ) ) ) |
|
349 { |
|
350 aProtocolType = EProtocolTypeUnknown; |
|
351 LOGIT("GetProtocolType: bearer == EBearerExternalCDMA2000, returning KErrNone") |
|
352 } |
|
353 else |
|
354 { |
|
355 // Get connection protocol type |
|
356 err = iConnectionData[index]->GetProtocolType( aProtocolType ); |
|
357 } |
|
358 } |
|
359 } |
|
360 |
|
361 LOGEXITFN1("CPsdFax::GetProtocolType()", err) |
|
362 return err; |
|
363 } |
|
364 |
|
365 |
|
366 // ----------------------------------------------------------------------------- |
|
367 // CPsdFax::GetStatus |
|
368 // ----------------------------------------------------------------------------- |
|
369 // |
|
370 TInt CPsdFax::GetStatus( const TUint aConnectionId, TInt& aStatus ) |
|
371 { |
|
372 LOGENTRFN("CPsdFax::GetStatus()") |
|
373 TInt err( KErrNone ); |
|
374 |
|
375 // Check if connection ID is valid and connection is open |
|
376 TInt index = ConnectionIndex( aConnectionId ); |
|
377 if ( KErrNotFound == index || !iConnectionData[index]->IsOpen() ) |
|
378 { |
|
379 err = KErrNotFound; |
|
380 } |
|
381 else |
|
382 { |
|
383 // Get connection status |
|
384 err = iConnectionData[index]->GetStatus( aStatus ); |
|
385 } |
|
386 |
|
387 LOGEXITFN1("CPsdFax::GetStatus()", err) |
|
388 return err; |
|
389 } |
|
390 |
|
391 |
|
392 // ----------------------------------------------------------------------------- |
|
393 // CPsdFax::GetDataVolumes |
|
394 // ----------------------------------------------------------------------------- |
|
395 // |
|
396 TInt CPsdFax::GetDataVolumes( const TUint aConnectionId, TUint& aDLVolume, TUint& aULVolume ) |
|
397 { |
|
398 LOGENTRFN("CPsdFax::GetDataVolumes()") |
|
399 TInt err( KErrNone ); |
|
400 |
|
401 TInt index = ConnectionIndex( aConnectionId ); |
|
402 if ( KErrNotFound == index || !iConnectionData[index]->IsOpen() ) |
|
403 { |
|
404 err = KErrNotFound; |
|
405 } |
|
406 else |
|
407 { |
|
408 // Get data volumes |
|
409 err = iConnectionData[index]->GetDataVolumes( aDLVolume, aULVolume ); |
|
410 } |
|
411 |
|
412 LOGEXITFN1("CPsdFax::GetDataVolumes()", err) |
|
413 return err; |
|
414 } |
|
415 |
|
416 |
|
417 // ----------------------------------------------------------------------------- |
|
418 // CPsdFax::GetStartTime |
|
419 // ----------------------------------------------------------------------------- |
|
420 // |
|
421 TInt CPsdFax::GetStartTime( const TUint aConnectionId, TTime& aTime ) |
|
422 { |
|
423 LOGENTRFN("CPsdFax::GetStartTime()") |
|
424 TInt err( KErrNone ); |
|
425 |
|
426 // Check if connection ID is valid and connection is open |
|
427 TInt index = ConnectionIndex( aConnectionId ); |
|
428 if ( KErrNotFound == index || !iConnectionData[index]->IsOpen() ) |
|
429 { |
|
430 err = KErrNotFound; |
|
431 } |
|
432 else |
|
433 { |
|
434 // Get connection start time |
|
435 err = iConnectionData[index]->GetStartTime( aTime ); |
|
436 } |
|
437 |
|
438 LOGEXITFN1("CPsdFax::GetStartTime()", err) |
|
439 return err; |
|
440 } |
|
441 |
|
442 |
|
443 // ----------------------------------------------------------------------------- |
|
444 // CPsdFax::Stop |
|
445 // ----------------------------------------------------------------------------- |
|
446 // |
|
447 TInt CPsdFax::Stop( const TUint aConnectionId ) |
|
448 { |
|
449 LOGENTRFN("CPsdFax::Stop()") |
|
450 TInt err( KErrNone ); |
|
451 |
|
452 // Check if connection ID is valid and connection is open |
|
453 TInt index = ConnectionIndex( aConnectionId ); |
|
454 if ( index == KErrNotFound || !iConnectionData[index]->IsOpen() ) |
|
455 { |
|
456 LOGIT1("CPsdFax::Stop() connection not found, index %d", index) |
|
457 err = KErrNotFound; |
|
458 } |
|
459 else |
|
460 { |
|
461 // Stop connection |
|
462 err = iConnectionData[index]->Stop(); |
|
463 } |
|
464 |
|
465 LOGEXITFN1("CPsdFax::Stop()", err) |
|
466 return err; |
|
467 } |
|
468 |
|
469 |
|
470 // ----------------------------------------------------------------------------- |
|
471 // CPsdFax::DeleteConnections |
|
472 // ----------------------------------------------------------------------------- |
|
473 // |
|
474 void CPsdFax::DeleteConnections() |
|
475 { |
|
476 LOGENTRFN("CPsdFax::DeleteConnections()") |
|
477 |
|
478 // Delete all ended ConnectionData objects |
|
479 for ( TUint index = 0; index < KMaxPsdConnectionCount; index++ ) |
|
480 { |
|
481 if ( iConnectionData[index] ) |
|
482 { |
|
483 if ( iConnectionData[index]->IsEnded() ) |
|
484 { |
|
485 LOGIT1("DeleteConnections: deleting connection index %d", index) |
|
486 delete iConnectionData[index]; |
|
487 iConnectionData[index] = NULL; |
|
488 } |
|
489 } |
|
490 } |
|
491 LOGEXITFN("CPsdFax::DeleteConnections()") |
|
492 } |
|
493 |
|
494 |
|
495 // ============================ MEMBER FUNCTIONS =============================== |
|
496 |
|
497 // ----------------------------------------------------------------------------- |
|
498 // CPsdFaxUpNotifier::CPsdFaxUpNotifier |
|
499 // ----------------------------------------------------------------------------- |
|
500 // |
|
501 CPsdFaxUpNotifier::CPsdFaxUpNotifier( |
|
502 CPsdFax* aFaxModule, |
|
503 CConnMonServer* aServer, |
|
504 RPacketService* aPacketService ) |
|
505 : |
|
506 CActive( EConnMonPriorityNormal ), |
|
507 iFaxModule( aFaxModule ), |
|
508 iServer( aServer ), |
|
509 iPacketService( aPacketService ) |
|
510 { |
|
511 } |
|
512 |
|
513 // ----------------------------------------------------------------------------- |
|
514 // CPsdFaxUpNotifier::ConstructL |
|
515 // ----------------------------------------------------------------------------- |
|
516 // |
|
517 void CPsdFaxUpNotifier::Construct() |
|
518 { |
|
519 CActiveScheduler::Add( this ); |
|
520 } |
|
521 |
|
522 // ----------------------------------------------------------------------------- |
|
523 // CPsdFaxUpNotifier::~CPsdFaxUpNotifier |
|
524 // ----------------------------------------------------------------------------- |
|
525 // |
|
526 CPsdFaxUpNotifier::~CPsdFaxUpNotifier() |
|
527 { |
|
528 Cancel(); |
|
529 } |
|
530 |
|
531 // ----------------------------------------------------------------------------- |
|
532 // CPsdFaxUpNotifier::Receive |
|
533 // Requests a new event (connection up/down) from RConnection |
|
534 // ----------------------------------------------------------------------------- |
|
535 // |
|
536 void CPsdFaxUpNotifier::Receive() |
|
537 { |
|
538 if ( IsActive() ) |
|
539 { |
|
540 Cancel(); |
|
541 } |
|
542 |
|
543 iName.FillZ(); |
|
544 iName.Zero(); |
|
545 |
|
546 iPacketService->NotifyContextAdded( iStatus, iName ); |
|
547 SetActive(); |
|
548 } |
|
549 |
|
550 // ----------------------------------------------------------------------------- |
|
551 // CPsdFaxUpNotifier::DoCancel |
|
552 // Cancels the request from RConnection. |
|
553 // ----------------------------------------------------------------------------- |
|
554 // |
|
555 void CPsdFaxUpNotifier::DoCancel() |
|
556 { |
|
557 if ( IsActive() ) |
|
558 { |
|
559 iPacketService->CancelAsyncRequest( EPacketNotifyContextAdded ); |
|
560 } |
|
561 } |
|
562 |
|
563 // ----------------------------------------------------------------------------- |
|
564 // CPsdFaxUpNotifier::RunL |
|
565 // Handles the event that has arrived from RConnection |
|
566 // ----------------------------------------------------------------------------- |
|
567 // |
|
568 void CPsdFaxUpNotifier::RunL() |
|
569 { |
|
570 // All RunL()'s outside CServer-derived main class MUST NOT LEAVE. |
|
571 // Use TRAPD when needed. |
|
572 //LOGENTRFN("CPsdFaxUpNotifier::RunL()") |
|
573 |
|
574 LOGIT(".") |
|
575 LOGIT1("RunL: CPsdFaxUpNotifier, status %d", iStatus.Int()) |
|
576 |
|
577 if ( KErrNone != iStatus.Int() ) |
|
578 { |
|
579 LOGIT1("CPsdFaxUpNotifier: PSD context up event FAILED <%d>", iStatus.Int()) |
|
580 } |
|
581 else |
|
582 { |
|
583 // For external connection, context name must be "External, External2, External3 etc" |
|
584 LOGIT1("CPsdFaxUpNotifier: new PSD context name: %s", iName.PtrZ()) |
|
585 |
|
586 TName contextName = iName; |
|
587 contextName.LowerCase(); |
|
588 |
|
589 // Check which external connection created |
|
590 for ( TUint index = 0; index < KMaxPsdConnectionCount; index++ ) |
|
591 { |
|
592 TBuf<KMaxName> tempName( KExternalName ); |
|
593 |
|
594 // Add connection number to string if index is > 1 |
|
595 if ( index > 0) |
|
596 { |
|
597 tempName.AppendNum( index+1 ); |
|
598 } |
|
599 |
|
600 // Compare to context name |
|
601 TInt res = contextName.Compare( tempName ); |
|
602 if ( res == 0 ) |
|
603 { |
|
604 LOGIT1("CPsdFaxUpNotifier: new external PSD connection with index %d", index) |
|
605 |
|
606 // Open context |
|
607 TInt err = iFaxModule->OpenContext( index, iName ); |
|
608 |
|
609 // Break from loop |
|
610 break; |
|
611 } |
|
612 } |
|
613 |
|
614 // New request |
|
615 Receive(); |
|
616 } |
|
617 //LOGEXITFN("CPsdFaxUpNotifier::RunL()") |
|
618 } |
|
619 |
|
620 |
|
621 |
|
622 // ============================ MEMBER FUNCTIONS =============================== |
|
623 |
|
624 // ----------------------------------------------------------------------------- |
|
625 // CPsdFaxConnectionData::CPsdFaxConnectionData |
|
626 // ----------------------------------------------------------------------------- |
|
627 // |
|
628 CPsdFaxConnectionData::CPsdFaxConnectionData( |
|
629 CPsdFax* aFaxModule, |
|
630 CConnMonServer* aServer, |
|
631 RPacketService* aPacketService ) |
|
632 : |
|
633 iConnectionId ( 0 ), |
|
634 iOpen ( EFalse ), |
|
635 iTimeValid ( EFalse ), |
|
636 iEnded ( EFalse ), |
|
637 iFaxModule( aFaxModule ), |
|
638 iServer( aServer ), |
|
639 iPacketService( aPacketService ) |
|
640 { |
|
641 } |
|
642 |
|
643 |
|
644 // ----------------------------------------------------------------------------- |
|
645 // CPsdFaxConnectionData::ConstructL |
|
646 // ----------------------------------------------------------------------------- |
|
647 // |
|
648 void CPsdFaxConnectionData::ConstructL() |
|
649 { |
|
650 LOGENTRFN("CPsdFaxConnectionData::ConstructL()") |
|
651 |
|
652 // Create external connection Status notifier object |
|
653 if ( !iStatusNotifier ) |
|
654 { |
|
655 iStatusNotifier = new( ELeave ) CPsdFaxStatusNotifier( |
|
656 iFaxModule, |
|
657 iServer, |
|
658 iPacketService, |
|
659 this ); |
|
660 // Start external connection Status notifier |
|
661 iStatusNotifier->Construct(); |
|
662 } |
|
663 |
|
664 LOGEXITFN("CPsdFaxConnectionData::ConstructL()") |
|
665 } |
|
666 |
|
667 // ----------------------------------------------------------------------------- |
|
668 // CPsdFaxConnectionData::Construct |
|
669 // ----------------------------------------------------------------------------- |
|
670 // |
|
671 TInt CPsdFaxConnectionData::Construct() |
|
672 { |
|
673 LOGENTRFN("CPsdFaxConnectionData::Construct()") |
|
674 TInt err( KErrNone ); |
|
675 |
|
676 // Create external connection Status notifier object |
|
677 if ( !iStatusNotifier ) |
|
678 { |
|
679 // Leave left out intentionally, check for NULL instead |
|
680 iStatusNotifier = new CPsdFaxStatusNotifier( iFaxModule, iServer, iPacketService, this ); // No (ELeave) |
|
681 if ( !iStatusNotifier ) |
|
682 { |
|
683 err = KErrNoMemory; |
|
684 } |
|
685 else |
|
686 { |
|
687 // Start external connection Status notifier |
|
688 iStatusNotifier->Construct(); |
|
689 } |
|
690 } |
|
691 |
|
692 LOGEXITFN1("CPsdFaxConnectionData::Construct()", err) |
|
693 return err; |
|
694 } |
|
695 |
|
696 // ----------------------------------------------------------------------------- |
|
697 // CPsdFaxConnectionData::~CPsdFaxConnectionData |
|
698 // ----------------------------------------------------------------------------- |
|
699 // |
|
700 CPsdFaxConnectionData::~CPsdFaxConnectionData() |
|
701 { |
|
702 LOGENTRFN("CPsdFaxConnectionData::~CPsdFaxConnectionData()") |
|
703 |
|
704 if ( iOpen ) |
|
705 { |
|
706 CloseContext(); |
|
707 } |
|
708 |
|
709 if ( iStatusNotifier ) |
|
710 { |
|
711 iStatusNotifier->Cancel(); |
|
712 delete iStatusNotifier; |
|
713 iStatusNotifier = NULL; |
|
714 } |
|
715 |
|
716 LOGEXITFN("CPsdFaxConnectionData::~CPsdFaxConnectionData()") |
|
717 } |
|
718 |
|
719 |
|
720 // ----------------------------------------------------------------------------- |
|
721 // CPsdFaxConnectionData::OpenContext |
|
722 // ----------------------------------------------------------------------------- |
|
723 // |
|
724 TInt CPsdFaxConnectionData::OpenContext( const TDes& aName ) |
|
725 { |
|
726 LOGENTRFN("CPsdFaxConnectionData::OpenContext()") |
|
727 TInt err( KErrNone ); |
|
728 |
|
729 if ( iOpen ) |
|
730 { |
|
731 CloseContext(); |
|
732 } |
|
733 |
|
734 err = iContext.OpenExistingContext( *iPacketService, aName ); |
|
735 if ( KErrNone == err ) |
|
736 { |
|
737 iOpen = ETrue; |
|
738 |
|
739 // Start status notifier |
|
740 if ( !iStatusNotifier->IsActive() ) |
|
741 { |
|
742 LOGIT("OpenContext: start status notifier") |
|
743 iStatusNotifier->Start( iContext ); |
|
744 } |
|
745 } |
|
746 |
|
747 LOGEXITFN1("CPsdFaxConnectionData::OpenContext()", err) |
|
748 return err; |
|
749 } |
|
750 |
|
751 |
|
752 // ----------------------------------------------------------------------------- |
|
753 // CPsdFaxConnectionData::CloseContext |
|
754 // ----------------------------------------------------------------------------- |
|
755 // |
|
756 void CPsdFaxConnectionData::CloseContext() |
|
757 { |
|
758 LOGENTRFN("CPsdFaxConnectionData::CloseContext()") |
|
759 |
|
760 if ( iOpen ) |
|
761 { |
|
762 if ( iStatusNotifier && iStatusNotifier->IsActive() ) |
|
763 { |
|
764 LOGIT("CloseContext: cancel status notifier") |
|
765 iStatusNotifier->Cancel(); |
|
766 } |
|
767 |
|
768 LOGIT("CloseContext: close context") |
|
769 iContext.Close(); |
|
770 } |
|
771 |
|
772 iConnectionId = 0; |
|
773 iOpen = EFalse; |
|
774 iTimeValid = EFalse; |
|
775 iEnded = ETrue; |
|
776 |
|
777 LOGEXITFN("CPsdFaxConnectionData::CloseContext()") |
|
778 } |
|
779 |
|
780 |
|
781 // ----------------------------------------------------------------------------- |
|
782 // CPsdFaxConnectionData::IsOpen |
|
783 // ----------------------------------------------------------------------------- |
|
784 // |
|
785 TBool CPsdFaxConnectionData::IsOpen() |
|
786 { |
|
787 if ( iOpen ) |
|
788 { |
|
789 return ETrue; |
|
790 } |
|
791 return EFalse; |
|
792 } |
|
793 |
|
794 |
|
795 // ----------------------------------------------------------------------------- |
|
796 // CPsdFaxConnectionData::GetDataVolumes |
|
797 // ----------------------------------------------------------------------------- |
|
798 // |
|
799 TInt CPsdFaxConnectionData::GetDataVolumes( TUint& aDLVolume, TUint& aULVolume ) const |
|
800 { |
|
801 LOGENTRFN("CPsdFaxConnectionData::GetDataVolumes()") |
|
802 TInt err( KErrNone ); |
|
803 RPacketContext::TDataVolume volume; |
|
804 TRequestStatus status( KErrNone ); |
|
805 |
|
806 if ( !iOpen ) |
|
807 { |
|
808 err = KErrNotFound; |
|
809 } |
|
810 else |
|
811 { |
|
812 iContext.GetDataVolumeTransferred( status, volume ); |
|
813 User::WaitForRequest( status ); |
|
814 err = status.Int(); |
|
815 |
|
816 if ( KErrNone == err ) |
|
817 { |
|
818 #ifdef _DEBUG |
|
819 if ( volume.iOverflowCounterReceived || volume.iOverflowCounterSent ) |
|
820 { |
|
821 LOGIT2("ERROR: 4GB overflow (ignored), dl:%d ul:%d", |
|
822 volume.iOverflowCounterReceived, volume.iOverflowCounterSent) |
|
823 } |
|
824 #endif // _DEBUG |
|
825 |
|
826 // volume.iOverflowCounterReceived*(2^32) + volume.iBytesReceived |
|
827 aDLVolume = volume.iBytesReceived; |
|
828 |
|
829 // volume.iOverflowCounterSent*(2^32) + volume.iBytesSent |
|
830 aULVolume = volume.iBytesSent; |
|
831 } |
|
832 } |
|
833 |
|
834 LOGEXITFN1("CPsdFaxConnectionData::GetDataVolumes()", err) |
|
835 return err; |
|
836 } |
|
837 |
|
838 // ----------------------------------------------------------------------------- |
|
839 // CPsdFaxConnectionData::Stop |
|
840 // ----------------------------------------------------------------------------- |
|
841 // |
|
842 TInt CPsdFaxConnectionData::Stop() |
|
843 { |
|
844 LOGENTRFN("CPsdFaxConnectionData::Stop()") |
|
845 TInt err( KErrNone ); |
|
846 TRequestStatus status( KErrNone ); |
|
847 |
|
848 iContext.Deactivate( status ); |
|
849 User::WaitForRequest( status ); |
|
850 err = status.Int(); |
|
851 |
|
852 // Remove from server tables if status notifier is not active. |
|
853 if ( !iStatusNotifier->IsActive() ) |
|
854 { |
|
855 // Remove from server tables |
|
856 RemoveFromServer(); |
|
857 |
|
858 // Close the context |
|
859 CloseContext(); |
|
860 |
|
861 // Delete all old connection objects |
|
862 // This method should be used carefully |
|
863 // because it will delete ConnectionData |
|
864 // and statusnotifier objects. |
|
865 // Get out fast from Stop() |
|
866 iFaxModule->DeleteConnections(); |
|
867 } |
|
868 |
|
869 LOGEXITFN1("CPsdFaxConnectionData::Stop()", err) |
|
870 return err; |
|
871 } |
|
872 |
|
873 // ----------------------------------------------------------------------------- |
|
874 // CPsdFaxConnectionData::RemoveFromServer |
|
875 // ----------------------------------------------------------------------------- |
|
876 // |
|
877 void CPsdFaxConnectionData::RemoveFromServer() |
|
878 { |
|
879 LOGENTRFN("CPsdFaxConnectionData::RemoveFromServer()") |
|
880 |
|
881 // Remove the connection from internal table |
|
882 TInt bearer( 0 ); |
|
883 TBearerInfo bearerInfo; |
|
884 TConnInfo connInfo( 0, 0, iConnectionId, EBearerExternalGPRS, bearerInfo ); |
|
885 |
|
886 TInt err = iFaxModule->GetBearer( bearer, bearerInfo ); |
|
887 if ( KErrNone == err ) |
|
888 { |
|
889 connInfo.iBearer = bearer; |
|
890 connInfo.iBearerInfo = bearerInfo; |
|
891 } |
|
892 |
|
893 // Remove connection from server |
|
894 iServer->Iap()->RemoveConnection( connInfo ); |
|
895 |
|
896 LOGEXITFN("CPsdFaxConnectionData::RemoveFromServer()") |
|
897 } |
|
898 |
|
899 |
|
900 // ----------------------------------------------------------------------------- |
|
901 // CPsdFaxConnectionData::SetConnectionId |
|
902 // ----------------------------------------------------------------------------- |
|
903 // |
|
904 void CPsdFaxConnectionData::SetConnectionId( const TUint& aConnectionId ) |
|
905 { |
|
906 LOGIT1("CPsdFaxConnectionData::SetConnectionId() - ConnID <%d>", aConnectionId ) |
|
907 iConnectionId = aConnectionId; |
|
908 } |
|
909 |
|
910 // ----------------------------------------------------------------------------- |
|
911 // CPsdFaxConnectionData::ConnectionId |
|
912 // ----------------------------------------------------------------------------- |
|
913 // |
|
914 TUint CPsdFaxConnectionData::ConnectionId() const |
|
915 { |
|
916 //LOGIT1("CPsdFaxConnectionData::ConnectionId() - ConnID %d", iConnectionId) |
|
917 return iConnectionId; |
|
918 } |
|
919 |
|
920 // ----------------------------------------------------------------------------- |
|
921 // CPsdFaxConnectionData::ResetStartTime |
|
922 // ----------------------------------------------------------------------------- |
|
923 // |
|
924 void CPsdFaxConnectionData::ResetStartTime() |
|
925 { |
|
926 LOGENTRFN("CPsdFaxConnectionData::ResetStartTime()") |
|
927 iStartTime.UniversalTime(); |
|
928 iTimeValid = ETrue; |
|
929 LOGEXITFN("CPsdFaxConnectionData::ResetStartTime()") |
|
930 } |
|
931 |
|
932 // ----------------------------------------------------------------------------- |
|
933 // CPsdFaxConnectionData::GetStartTime |
|
934 // ----------------------------------------------------------------------------- |
|
935 // |
|
936 TInt CPsdFaxConnectionData::GetStartTime( TTime& aTime ) const |
|
937 { |
|
938 LOGENTRFN("CPsdFaxConnectionData::GetStartTime()") |
|
939 TInt err( KErrNone ); |
|
940 |
|
941 // Start time is not know for external connections that have been up before |
|
942 // connection monitor started |
|
943 if ( !iTimeValid ) |
|
944 { |
|
945 err = KErrUnknown; |
|
946 } |
|
947 else |
|
948 { |
|
949 aTime = iStartTime; |
|
950 } |
|
951 |
|
952 LOGEXITFN1("CPsdFaxConnectionData::GetStartTime()", err) |
|
953 return err; |
|
954 } |
|
955 |
|
956 |
|
957 // ----------------------------------------------------------------------------- |
|
958 // CPsdFaxConnectionData::GetAPN |
|
959 // ----------------------------------------------------------------------------- |
|
960 // |
|
961 TInt CPsdFaxConnectionData::GetApn( TDes& aName ) |
|
962 { |
|
963 LOGENTRFN("CPsdFaxConnectionData::GetApn()") |
|
964 TInt err( KErrNone ); |
|
965 TRequestStatus status( KErrNone ); |
|
966 RPacketContext::TContextConfigGPRS* getParams; |
|
967 |
|
968 // Leave left out intentionally, check for NULL instead |
|
969 getParams = new RPacketContext::TContextConfigGPRS(); // No (ELeave) |
|
970 if ( !getParams ) |
|
971 { |
|
972 err = KErrNoMemory; |
|
973 } |
|
974 else |
|
975 { |
|
976 TPckg<RPacketContext::TContextConfigGPRS> getContextConfigPckg( *getParams ); |
|
977 iContext.GetConfig( status, getContextConfigPckg ); |
|
978 User::WaitForRequest( status ); |
|
979 err = status.Int(); |
|
980 |
|
981 if ( KErrNone == err ) |
|
982 { |
|
983 // Access Point Name |
|
984 ConvertAPN( aName, getParams->iAccessPointName ); |
|
985 } |
|
986 delete getParams; |
|
987 } |
|
988 |
|
989 LOGEXITFN1("CPsdFaxConnectionData::GetApn()", err) |
|
990 return err; |
|
991 } |
|
992 |
|
993 // ----------------------------------------------------------------------------- |
|
994 // CPsdFaxConnectionData::ConvertAPN |
|
995 // ----------------------------------------------------------------------------- |
|
996 // |
|
997 void CPsdFaxConnectionData::ConvertAPN( TDes& aResult, const TDesC& aName ) const |
|
998 { |
|
999 aResult = aName; |
|
1000 } |
|
1001 |
|
1002 // ----------------------------------------------------------------------------- |
|
1003 // CPsdFaxConnectionData::ConvertAPN |
|
1004 // ----------------------------------------------------------------------------- |
|
1005 // |
|
1006 void CPsdFaxConnectionData::ConvertAPN( TDes& aResult, const TDesC8& aName ) const |
|
1007 { |
|
1008 CnvUtfConverter::ConvertToUnicodeFromUtf8( aResult, aName ); |
|
1009 } |
|
1010 |
|
1011 // ----------------------------------------------------------------------------- |
|
1012 // CPsdFaxConnectionData::GetProtocolType |
|
1013 // ----------------------------------------------------------------------------- |
|
1014 // |
|
1015 TInt CPsdFaxConnectionData::GetProtocolType( TInt& aProtocolType ) |
|
1016 { |
|
1017 LOGENTRFN("CPsdFaxConnectionData::GetProtocolType()") |
|
1018 TInt err( KErrNone ); |
|
1019 TRequestStatus status( KErrNone ); |
|
1020 RPacketContext::TContextConfigGPRS* getParams; |
|
1021 |
|
1022 // Leave left out intentionally, check for NULL instead |
|
1023 getParams = new RPacketContext::TContextConfigGPRS(); // No (ELeave) |
|
1024 if ( !getParams ) |
|
1025 { |
|
1026 err = KErrNoMemory; |
|
1027 } |
|
1028 |
|
1029 if ( KErrNone == err ) |
|
1030 { |
|
1031 TPckg<RPacketContext::TContextConfigGPRS> getContextConfigPckg( *getParams ); |
|
1032 iContext.GetConfig( status, getContextConfigPckg ); |
|
1033 User::WaitForRequest( status ); |
|
1034 err = status.Int(); |
|
1035 |
|
1036 if ( KErrNone == err ) |
|
1037 { |
|
1038 if ( getParams->iPdpType == RPacketContext::EPdpTypeIPv4 ) |
|
1039 { |
|
1040 aProtocolType = EProtocolTypeIPv4; |
|
1041 } |
|
1042 else if ( getParams->iPdpType == RPacketContext::EPdpTypeIPv6 ) |
|
1043 { |
|
1044 aProtocolType = EProtocolTypeIPv6; |
|
1045 } |
|
1046 else |
|
1047 { |
|
1048 aProtocolType = EProtocolTypeUnknown; |
|
1049 } |
|
1050 } |
|
1051 delete getParams; |
|
1052 } |
|
1053 |
|
1054 LOGEXITFN1("CPsdFaxConnectionData::GetProtocolType()", err) |
|
1055 return err; |
|
1056 } |
|
1057 |
|
1058 |
|
1059 // ----------------------------------------------------------------------------- |
|
1060 // CPsdFaxConnectionData::GetStatus |
|
1061 // ----------------------------------------------------------------------------- |
|
1062 // |
|
1063 TInt CPsdFaxConnectionData::GetStatus( TInt& aStatus ) const |
|
1064 { |
|
1065 LOGENTRFN("CPsdFaxConnectionData::GetStatus()") |
|
1066 |
|
1067 RPacketContext::TContextStatus status; |
|
1068 |
|
1069 TInt err = iContext.GetStatus( status ); |
|
1070 if ( KErrNone == err ) |
|
1071 { |
|
1072 aStatus = status; |
|
1073 err = MapStatus( aStatus ); |
|
1074 } |
|
1075 |
|
1076 LOGEXITFN("CPsdFaxConnectionData::GetStatus()") |
|
1077 return err; |
|
1078 } |
|
1079 |
|
1080 // ----------------------------------------------------------------------------- |
|
1081 // CPsdFaxConnectionData::MapStatus |
|
1082 // ----------------------------------------------------------------------------- |
|
1083 // |
|
1084 TInt CPsdFaxConnectionData::MapStatus( TInt& aStatus ) const |
|
1085 { |
|
1086 LOGENTRFN("CPsdFaxConnectionData::MapStatus()") |
|
1087 |
|
1088 // Map to internal PDP context status |
|
1089 switch( aStatus ) |
|
1090 { |
|
1091 case RPacketContext::EStatusUnknown: |
|
1092 return KErrUnknown; |
|
1093 |
|
1094 case RPacketContext::EStatusInactive: |
|
1095 return KErrUnknown; |
|
1096 |
|
1097 case RPacketContext::EStatusActivating: |
|
1098 aStatus = KPsdStartingActivation; |
|
1099 break; |
|
1100 |
|
1101 case RPacketContext::EStatusActive: |
|
1102 aStatus = KPsdFinishedActivation; |
|
1103 break; |
|
1104 |
|
1105 case RPacketContext::EStatusDeactivating: |
|
1106 aStatus = KPsdStartingDeactivation; |
|
1107 break; |
|
1108 |
|
1109 case RPacketContext::EStatusSuspended: |
|
1110 aStatus = KPsdSuspended; |
|
1111 break; |
|
1112 |
|
1113 case RPacketContext::EStatusDeleted: |
|
1114 aStatus = KPsdFinishedDeactivation; |
|
1115 break; |
|
1116 |
|
1117 default: |
|
1118 return KErrUnknown; |
|
1119 } |
|
1120 |
|
1121 LOGEXITFN("CPsdFaxConnectionData::MapStatus()") |
|
1122 return KErrNone; |
|
1123 } |
|
1124 |
|
1125 // ----------------------------------------------------------------------------- |
|
1126 // CPsdFaxConnectionData::IsEnded |
|
1127 // ----------------------------------------------------------------------------- |
|
1128 // |
|
1129 TBool CPsdFaxConnectionData::IsEnded() |
|
1130 { |
|
1131 if ( iEnded ) |
|
1132 { |
|
1133 return ETrue; |
|
1134 } |
|
1135 return EFalse; |
|
1136 } |
|
1137 |
|
1138 |
|
1139 |
|
1140 // ============================ MEMBER FUNCTIONS =============================== |
|
1141 |
|
1142 // ----------------------------------------------------------------------------- |
|
1143 // CPsdFaxStatusNotifier::CPsdFaxStatusNotifier |
|
1144 // ----------------------------------------------------------------------------- |
|
1145 // |
|
1146 CPsdFaxStatusNotifier::CPsdFaxStatusNotifier( |
|
1147 CPsdFax* aFaxModule, |
|
1148 CConnMonServer* aServer, |
|
1149 RPacketService* aPacketService, |
|
1150 CPsdFaxConnectionData* aConnDataModule ) |
|
1151 : |
|
1152 CActive( EConnMonPriorityNormal ), |
|
1153 iFaxModule( aFaxModule ), |
|
1154 iServer( aServer ), |
|
1155 iPacketService( aPacketService ), |
|
1156 iConnDataModule ( aConnDataModule ) |
|
1157 { |
|
1158 } |
|
1159 |
|
1160 // ----------------------------------------------------------------------------- |
|
1161 // CPsdFaxStatusNotifier::Construct |
|
1162 // ----------------------------------------------------------------------------- |
|
1163 // |
|
1164 void CPsdFaxStatusNotifier::Construct() |
|
1165 { |
|
1166 CActiveScheduler::Add( this ); |
|
1167 } |
|
1168 |
|
1169 // ----------------------------------------------------------------------------- |
|
1170 // CPsdFaxStatusNotifier::~CPsdFaxStatusNotifier |
|
1171 // ----------------------------------------------------------------------------- |
|
1172 // |
|
1173 CPsdFaxStatusNotifier::~CPsdFaxStatusNotifier() |
|
1174 { |
|
1175 Cancel(); |
|
1176 } |
|
1177 |
|
1178 // ----------------------------------------------------------------------------- |
|
1179 // CPsdFaxStatusNotifier::Start |
|
1180 // Requests a new event (connection up/down) from RConnection |
|
1181 // ----------------------------------------------------------------------------- |
|
1182 // |
|
1183 void CPsdFaxStatusNotifier::Start( const RPacketContext& aContext ) |
|
1184 { |
|
1185 iContext = aContext; |
|
1186 Receive(); |
|
1187 } |
|
1188 |
|
1189 // ----------------------------------------------------------------------------- |
|
1190 // CPsdFaxStatusNotifier::Receive |
|
1191 // Requests a new event (connection up/down) from RConnection |
|
1192 // ----------------------------------------------------------------------------- |
|
1193 // |
|
1194 void CPsdFaxStatusNotifier::Receive() |
|
1195 { |
|
1196 if ( IsActive() ) |
|
1197 { |
|
1198 Cancel(); |
|
1199 } |
|
1200 |
|
1201 iContext.NotifyStatusChange( iStatus, iContextStatus ); |
|
1202 SetActive(); |
|
1203 } |
|
1204 |
|
1205 // ----------------------------------------------------------------------------- |
|
1206 // CPsdFaxStatusNotifier::DoCancel |
|
1207 // Cancels the request from RConnection. |
|
1208 // ----------------------------------------------------------------------------- |
|
1209 // |
|
1210 void CPsdFaxStatusNotifier::DoCancel() |
|
1211 { |
|
1212 if ( IsActive() ) |
|
1213 { |
|
1214 iContext.CancelAsyncRequest( EPacketContextNotifyStatusChange ); |
|
1215 } |
|
1216 } |
|
1217 |
|
1218 // ----------------------------------------------------------------------------- |
|
1219 // CPsdFaxStatusNotifier::RunL |
|
1220 // Handles the event that has arrived from RConnection |
|
1221 // ----------------------------------------------------------------------------- |
|
1222 // |
|
1223 void CPsdFaxStatusNotifier::RunL() |
|
1224 { |
|
1225 // All RunL():s outside CServer-derived main class MUST NOT LEAVE. |
|
1226 // Use TRAPD when needed. |
|
1227 //LOGENTRFN("CPsdFaxStatusNotifier::RunL()") |
|
1228 |
|
1229 LOGIT(".") |
|
1230 LOGIT1("RunL: CPsdFaxStatusNotifier, status %d", iStatus.Int()) |
|
1231 |
|
1232 if ( iStatus.Int() != KErrNone ) |
|
1233 { |
|
1234 LOGIT1("CPsdFaxStatusNotifier: external PSD status event FAILED <%d>", iStatus.Int()) |
|
1235 } |
|
1236 else |
|
1237 { |
|
1238 LOGIT1("CPsdFaxStatusNotifier: external PSD connection status changed: %d", iContextStatus) |
|
1239 |
|
1240 iEventInfo.iConnectionId = iConnDataModule->ConnectionId(); |
|
1241 if ( iEventInfo.iConnectionId == 0 ) |
|
1242 { |
|
1243 // Send connection create event when the first status event arrives. |
|
1244 TInt ret = SendConnectionCreateEvent(); |
|
1245 if ( KErrNone != ret ) |
|
1246 { |
|
1247 // Close the context |
|
1248 iConnDataModule->CloseContext(); |
|
1249 |
|
1250 // Delete all old connection objects |
|
1251 iFaxModule->DeleteConnections(); |
|
1252 |
|
1253 // Stop listening |
|
1254 return; |
|
1255 } |
|
1256 } |
|
1257 |
|
1258 iEventInfo.Reset(); |
|
1259 iEventInfo.iEventType = EConnMonConnectionStatusChange; |
|
1260 iEventInfo.iConnectionId = iConnDataModule->ConnectionId(); |
|
1261 |
|
1262 TInt status = iContextStatus; |
|
1263 TInt err = iConnDataModule->MapStatus( status ); |
|
1264 iEventInfo.iData = status; |
|
1265 |
|
1266 if ( ( iServer->NumberOfListeners() > 0 ) && ( err == KErrNone ) ) |
|
1267 { |
|
1268 // Send event to all clients that are listening |
|
1269 iServer->EventQueue()->Add( iEventInfo ); |
|
1270 } |
|
1271 |
|
1272 if ( iContextStatus == RPacketContext::EStatusDeleted ) |
|
1273 { |
|
1274 // Send connection closed event to all clients that are listening |
|
1275 iEventInfo.Reset(); |
|
1276 iEventInfo.iEventType = EConnMonDeleteConnection; |
|
1277 iEventInfo.iConnectionId = iConnDataModule->ConnectionId(); |
|
1278 iConnDataModule->GetDataVolumes( iEventInfo.iData, iEventInfo.iData2 ); |
|
1279 iServer->EventQueue()->Add( iEventInfo ); |
|
1280 |
|
1281 // Remove from server tables |
|
1282 iConnDataModule->RemoveFromServer(); |
|
1283 |
|
1284 // Close the context |
|
1285 iConnDataModule->CloseContext(); |
|
1286 |
|
1287 // Delete all old connection objects. This method should be used |
|
1288 // carefully because it will delete ConnectionData and |
|
1289 // statusnotifier objects. Get out fast from RunL(). |
|
1290 iFaxModule->DeleteConnections(); |
|
1291 |
|
1292 // Stop listening |
|
1293 return; |
|
1294 } |
|
1295 |
|
1296 // New request |
|
1297 Receive(); |
|
1298 } |
|
1299 |
|
1300 //LOGEXITFN("CPsdFaxStatusNotifier::RunL()") |
|
1301 } |
|
1302 |
|
1303 // ----------------------------------------------------------------------------- |
|
1304 // CPsdFaxStatusNotifier::SendConnectionCreateEvent |
|
1305 // Send created event. |
|
1306 // ----------------------------------------------------------------------------- |
|
1307 // |
|
1308 TInt CPsdFaxStatusNotifier::SendConnectionCreateEvent() |
|
1309 { |
|
1310 TInt bearer( 0 ); |
|
1311 TBearerInfo bearerInfo; |
|
1312 TInt err( KErrNone ); |
|
1313 |
|
1314 LOGENTRFN("CPsdFaxStatusNotifier::SendConnectionCreateEvent()") |
|
1315 |
|
1316 // Get bearer info |
|
1317 err = iFaxModule->GetBearer( bearer, bearerInfo ); |
|
1318 |
|
1319 if ( KErrNone != err ) |
|
1320 { |
|
1321 bearer = EBearerExternalGPRS; |
|
1322 bearerInfo.iBearer = EBearerInfoGPRS; |
|
1323 bearerInfo.iInternal = EFalse; |
|
1324 } |
|
1325 |
|
1326 TConnInfo connInfo( 0, 0, 0, bearer, bearerInfo ); |
|
1327 |
|
1328 // Add to the connection table and fill in the new connectionId to connInfo |
|
1329 TRAPD( ret, ( err = iServer->Iap()->AddConnectionL( connInfo ) ) ); |
|
1330 if ( ret || ( err != KErrNone ) ) |
|
1331 { |
|
1332 LOGIT("AddConnectionL failed.") |
|
1333 LOGEXITFN("CPsdFaxStatusNotifier::SendConnectionCreateEvent()") |
|
1334 return KErrUnknown; |
|
1335 } |
|
1336 |
|
1337 // Send connection create event to all clients that are listening |
|
1338 iEventInfo.Reset(); |
|
1339 iEventInfo.iEventType = EConnMonCreateConnection; |
|
1340 iEventInfo.iConnectionId = connInfo.iConnectionId; |
|
1341 iConnDataModule->SetConnectionId( connInfo.iConnectionId ); |
|
1342 iServer->EventQueue()->Add( iEventInfo ); |
|
1343 |
|
1344 LOGEXITFN("CPsdFaxStatusNotifier::SendConnectionCreateEvent()") |
|
1345 return KErrNone; |
|
1346 } |
|
1347 |
|
1348 // End-of-file |