1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // PDP status change notifier |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @internalComponent |
|
21 */ |
|
22 |
|
23 #include <e32base.h> |
|
24 |
|
25 #include "cpdpstatuschangenotifier.h" |
|
26 #include "PDPFSM.h" |
|
27 #include "spudteldebuglogger.h" |
|
28 #include "pdpfsmnmspace.h" |
|
29 |
|
30 #include <pcktcs.h> |
|
31 |
|
32 |
|
33 /** |
|
34 @param aId - pdp context id |
|
35 @param aPacketContext - reference to etel packet context |
|
36 @param aPdpFsmInterface - reference to pdp fsm interface |
|
37 */ |
|
38 CPdpStatusChangeNotifier::CPdpStatusChangeNotifier(TContextId aId, |
|
39 RPacketContext& aPacketContext, |
|
40 CPdpFsmInterface& aPdpFsmInterface) |
|
41 : CEtelDriverNotifier(aPdpFsmInterface), |
|
42 iId(aId), |
|
43 iPacketContext(aPacketContext), |
|
44 iContextStatus(RPacketContext::EStatusUnknown) |
|
45 { |
|
46 } |
|
47 |
|
48 CPdpStatusChangeNotifier::~CPdpStatusChangeNotifier() |
|
49 { |
|
50 Cancel(); |
|
51 } |
|
52 |
|
53 /** initiates notification */ |
|
54 void CPdpStatusChangeNotifier::Start() |
|
55 { |
|
56 if (!IsActive() && (iContextStatus != RPacketContext::EStatusDeleted)) |
|
57 { |
|
58 iPacketContext.NotifyStatusChange(iStatus, iContextStatus); |
|
59 SetActive(); |
|
60 } |
|
61 } |
|
62 |
|
63 /** stops notification */ |
|
64 void CPdpStatusChangeNotifier::DoCancel() |
|
65 { |
|
66 if(IsActive()) |
|
67 { |
|
68 SPUDTELVERBOSE_INFO_LOG( |
|
69 _L("CPdpStatusChangeNotifier::DoCancel EPacketContextNotifyStatusChange")); |
|
70 iPacketContext.CancelAsyncRequest(EPacketContextNotifyStatusChange); |
|
71 } |
|
72 } |
|
73 |
|
74 /** notifies pdp fsm |
|
75 |
|
76 @param aStatus - request status |
|
77 */ |
|
78 void CPdpStatusChangeNotifier::Notify(const TRequestStatus& aStatus) |
|
79 { |
|
80 if(aStatus == KErrNone) |
|
81 { |
|
82 SPUDTELVERBOSE_INFO_LOG(_L("Notified of context status change")); |
|
83 RPacketContext::TContextStatus aOldContextStatus; |
|
84 iPdpFsmInterface.Get(iId, aOldContextStatus); |
|
85 // only notify of change if it has actually changed |
|
86 if (iContextStatus != aOldContextStatus) |
|
87 { |
|
88 SPUDTELVERBOSE_INFO_LOG(_L("FSM input EContextStatusChangeNetwork")); |
|
89 iPdpFsmInterface.Set(iId, iContextStatus); |
|
90 TInt err = KErrNone; |
|
91 iPacketContext.GetLastErrorCause(err); // Ignore error return code. |
|
92 iPdpFsmInterface.Input(iId, PdpFsm::EContextStatusChangeNetwork, err); |
|
93 } |
|
94 } |
|
95 else |
|
96 { |
|
97 SPUDTEL_ERROR_LOG(_L("CPdpStatusChangeNotifier::Notify(), error: %d"), |
|
98 aStatus.Int()); |
|
99 ASSERT(aStatus == KErrCancel); |
|
100 } |
|
101 } |
|