|
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 } |
|
102 |
|
103 |
|
104 |
|
105 |
|
106 |
|
107 /** |
|
108 @param aId - pdp context id |
|
109 @param aPacketContext - reference to etel packet context |
|
110 @param aPdpFsmInterface - reference to pdp fsm interface |
|
111 */ |
|
112 CMbmsPdpStatusChangeNotifier::CMbmsPdpStatusChangeNotifier(TContextId aId, |
|
113 RPacketMbmsContext& aMbmsPacketContext, |
|
114 CPdpFsmInterface& aPdpFsmInterface) |
|
115 : CEtelDriverNotifier(aPdpFsmInterface), |
|
116 iId(aId), |
|
117 iMbmsPacketContext(aMbmsPacketContext), |
|
118 iContextStatus(RPacketContext::EStatusUnknown) |
|
119 { |
|
120 } |
|
121 |
|
122 CMbmsPdpStatusChangeNotifier::~CMbmsPdpStatusChangeNotifier() |
|
123 { |
|
124 Cancel(); |
|
125 } |
|
126 |
|
127 /** initiates notification */ |
|
128 void CMbmsPdpStatusChangeNotifier::Start() |
|
129 { |
|
130 if (!IsActive() && (iContextStatus != RPacketContext::EStatusDeleted)) |
|
131 { |
|
132 iMbmsPacketContext.NotifyStatusChange(iStatus, iContextStatus); |
|
133 SetActive(); |
|
134 } |
|
135 } |
|
136 |
|
137 /** stops notification */ |
|
138 void CMbmsPdpStatusChangeNotifier::DoCancel() |
|
139 { |
|
140 if(IsActive()) |
|
141 { |
|
142 SPUDTELVERBOSE_INFO_LOG( |
|
143 _L("CMbmsPdpStatusChangeNotifier::DoCancel EPacketContextNotifyStatusChange")); |
|
144 iMbmsPacketContext.CancelAsyncRequest(EPacketContextNotifyStatusChange); |
|
145 } |
|
146 } |
|
147 |
|
148 /** notifies pdp fsm |
|
149 |
|
150 @param aStatus - request status |
|
151 */ |
|
152 void CMbmsPdpStatusChangeNotifier::Notify(const TRequestStatus& aStatus) |
|
153 { |
|
154 if(aStatus == KErrNone) |
|
155 { |
|
156 SPUDTELVERBOSE_INFO_LOG(_L("Notified of context status change")); |
|
157 RPacketContext::TContextStatus aOldContextStatus; |
|
158 iPdpFsmInterface.Get(iId,aOldContextStatus); |
|
159 // only notify of change if it has actually changed |
|
160 if (iContextStatus != aOldContextStatus) |
|
161 { |
|
162 SPUDTELVERBOSE_INFO_LOG(_L("FSM input EContextStatusChangeNetwork")); |
|
163 iPdpFsmInterface.Set(iId, iContextStatus); |
|
164 TInt err = KErrNone; |
|
165 iMbmsPacketContext.GetLastErrorCause(err); // Ignore error return code. |
|
166 iPdpFsmInterface.Input(iId, PdpFsm::EContextStatusChangeNetwork, err); |
|
167 } |
|
168 } |
|
169 else |
|
170 { |
|
171 SPUDTEL_ERROR_LOG(_L("CMbmsPdpStatusChangeNotifier::Notify(), error: %d"), |
|
172 aStatus.Int()); |
|
173 ASSERT(aStatus == KErrCancel); |
|
174 } |
|
175 } |
|
176 |