|
1 /* |
|
2 * Copyright (c) 2010 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: This module contains the implementation of |
|
15 * CNWDynamicCapsMonitor |
|
16 * |
|
17 */ |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <pcktcs.h> // for EPacketGetDynamicCaps |
|
21 #include <etelpckt.h> // for RPacketService |
|
22 #include "CNWDynamicCapsMonitor.h" |
|
23 #include "CNWMessageHandler.h" |
|
24 #include "NWLogger.h" |
|
25 |
|
26 // ================= MEMBER FUNCTIONS ======================================= |
|
27 |
|
28 // ----------------------------------------------------------------------------- |
|
29 // CNWDynamicCapsMonitor::CNWDynamicCapsMonitor |
|
30 // C++ default constructor can NOT contain any code, that might leave. |
|
31 // ----------------------------------------------------------------------------- |
|
32 // |
|
33 CNWDynamicCapsMonitor::CNWDynamicCapsMonitor( |
|
34 CNWMessageHandler& aOwner, // ref. to owner class |
|
35 RMobilePhone& aPhone, // ref. to phone |
|
36 TNWInfo& aNetworkInfo, // ref. to network info struct |
|
37 RMmCustomAPI& aCustomAPI ) //ref. to customAPI |
|
38 : CNWNetworkMonitorBase( aOwner, |
|
39 aPhone, |
|
40 aNetworkInfo, |
|
41 aCustomAPI ) |
|
42 { |
|
43 NWLOGSTRING( KNWOBJECT, "NW: CNWDynamicCapsMonitor::CNWDynamicCapsMonitor -START" ); |
|
44 CActiveScheduler::Add( this ); |
|
45 } |
|
46 |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // CNWDynamicCapsMonitor::ConstructL |
|
50 // Symbian 2nd phase constructor can leave. |
|
51 // ----------------------------------------------------------------------------- |
|
52 // |
|
53 void CNWDynamicCapsMonitor::ConstructL() |
|
54 { |
|
55 NWLOGSTRING( KNWOBJECT, "NW: CNWDynamicCapsMonitor::ConstructL -START" ); |
|
56 User::LeaveIfError( iPacketService.Open( iPhone ) ); |
|
57 // Assign lower priority than other networkhandling monitors. |
|
58 // (Default in CNWNetworkMonitorBase is EPriorityStandard) |
|
59 SetPriority( EPriorityIdle ); |
|
60 |
|
61 NWLOGSTRING( KNWOBJECT, "NW: CNWDynamicCapsMonitor::ConstructL -END" ); |
|
62 } |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // CNWDynamicCapsMonitor::NewL |
|
66 // Two-phased constructor. |
|
67 // ----------------------------------------------------------------------------- |
|
68 // |
|
69 CNWDynamicCapsMonitor* CNWDynamicCapsMonitor::NewL( |
|
70 CNWMessageHandler& aOwner, |
|
71 RMobilePhone& aPhone, |
|
72 TNWInfo& aNetworkInfo, |
|
73 RMmCustomAPI& aCustomAPI ) |
|
74 { |
|
75 NWLOGSTRING( KNWOBJECT, "NW: CNWDynamicCapsMonitor::NewL -START" ); |
|
76 CNWDynamicCapsMonitor* self = |
|
77 new( ELeave ) CNWDynamicCapsMonitor( aOwner, |
|
78 aPhone, |
|
79 aNetworkInfo, |
|
80 aCustomAPI ); |
|
81 |
|
82 CleanupStack::PushL( self ); |
|
83 self->ConstructL(); |
|
84 CleanupStack::Pop( self ); |
|
85 NWLOGSTRING( KNWOBJECT, "NW: CNWDynamicCapsMonitor::NewL -END" ); |
|
86 return self; |
|
87 } |
|
88 |
|
89 |
|
90 // Destructor |
|
91 CNWDynamicCapsMonitor::~CNWDynamicCapsMonitor() |
|
92 { |
|
93 Cancel(); |
|
94 iPacketService.Close(); |
|
95 |
|
96 NWLOGSTRING( KNWOBJECT, "NW: CNWDynamicCapsMonitor::~CNWDynamicCapsMonitor -END" ); |
|
97 } |
|
98 |
|
99 // ----------------------------------------------------------------------------- |
|
100 // CNWDynamicCapsMonitor::DoCancel |
|
101 // Cancels the pending async. command. |
|
102 // ----------------------------------------------------------------------------- |
|
103 // |
|
104 void CNWDynamicCapsMonitor::DoCancel() |
|
105 { |
|
106 NWLOGSTRING( KNWREQEND, "NW: CNWDynamicCapsMonitor::DoCancel: Request CancelAsyncRequest( EPacketNotifyDynamicCapsChange )" ); |
|
107 iPacketService.CancelAsyncRequest( EPacketNotifyDynamicCapsChange ); |
|
108 } |
|
109 |
|
110 // ----------------------------------------------------------------------------- |
|
111 // CNWDynamicCapsMonitor::RunL |
|
112 // Receives notification that the dynamic packet data capabilities changed. |
|
113 // Saves new value in TNWInfo object. (This will be used by active idle to |
|
114 // hide the alpha tag if CS registration is unsuccessful.) |
|
115 // ----------------------------------------------------------------------------- |
|
116 // |
|
117 void CNWDynamicCapsMonitor::RunL() |
|
118 { |
|
119 NWLOGSTRING2( KNWREQEND, |
|
120 "NW: CNWDynamicCapsMonitor::RunL, iStatus = %d", iStatus.Int() ); |
|
121 |
|
122 if( iStatus.Int() == KErrNone ) |
|
123 { |
|
124 if ( iNWNetworkInfo.iDynamicCapsFlags != iDynamicCapsFlags ) |
|
125 { |
|
126 // Update dynamic caps info |
|
127 UpdateDynamicCapsFlags( iDynamicCapsFlags ); |
|
128 iOwner.SendMessage( |
|
129 MNWMessageObserver::ENWMessageDynamicCapsChange ); |
|
130 } |
|
131 IssueRequest(); |
|
132 } |
|
133 // Check if monitor can be restarted. |
|
134 else if ( iStatus != KErrCancel && iStatus != KErrServerTerminated ) |
|
135 { |
|
136 NWLOGSTRING2( KNWERROR, |
|
137 "NW: CNWDynamicCapsMonitor::RunL, Unknown error situation, iStatus = %d", iStatus.Int() ); |
|
138 IssueRequest(); |
|
139 } |
|
140 else |
|
141 { |
|
142 NWLOGSTRING2( KNWERROR, |
|
143 "NW: CNWDynamicCapsMonitor::RunL, Server Terminated or request Cancelled, iStatus = %d", iStatus.Int() ); |
|
144 } |
|
145 } |
|
146 |
|
147 |
|
148 // ----------------------------------------------------------------------------- |
|
149 // CNWDynamicCapsMonitor::IssueRequest |
|
150 // Request a notification when the dynamic packet data capabilities change. |
|
151 // ----------------------------------------------------------------------------- |
|
152 // |
|
153 void CNWDynamicCapsMonitor::IssueRequest() |
|
154 { |
|
155 NWLOGSTRING( KNWOBJECT, "NW: CNWDynamicCapsMonitor::IssueRequest() -START" ); |
|
156 |
|
157 if( !IsActive() ) |
|
158 { |
|
159 NWLOGSTRING( KNWREQIN, |
|
160 "NW:CNWDynamicCapsMonitor::IssueRequest > RPacketService::NotifyDynamicCapsChange" ); |
|
161 iPacketService.NotifyDynamicCapsChange( iStatus, iDynamicCapsFlags ); |
|
162 SetActive(); |
|
163 } |
|
164 else |
|
165 { |
|
166 NWLOGSTRING( KNWERROR, |
|
167 "NW: CNWDynamicCapsMonitor::IssueRequest: Already active" ); |
|
168 } |
|
169 |
|
170 NWLOGSTRING( KNWOBJECT, "NW: CNWDynamicCapsMonitor::IssueRequest() -END" ); |
|
171 } |
|
172 |
|
173 |
|
174 // ----------------------------------------------------------------------------- |
|
175 // CNWDynamicCapsMonitor::UpdateDynamicCapsFlags() |
|
176 // Update the value of iNWNetworkInfo.iDynamicCapsFlags |
|
177 // ----------------------------------------------------------------------------- |
|
178 // |
|
179 void CNWDynamicCapsMonitor::UpdateDynamicCapsFlags( |
|
180 const RPacketService::TDynamicCapsFlags aDynamicCapsFlags ) |
|
181 { |
|
182 NWLOGSTRING( KNWOBJECT, "NW: CNWDynamicCapsMonitor::UpdateDynamicCapsFlags()" ); |
|
183 iNWNetworkInfo.iDynamicCapsFlags = aDynamicCapsFlags; |
|
184 } |
|
185 |
|
186 |
|
187 // ----------------------------------------------------------------------------- |
|
188 // CNWDynamicCapsMonitor::RunError() |
|
189 // Processes any errors. |
|
190 // ----------------------------------------------------------------------------- |
|
191 // |
|
192 TInt CNWDynamicCapsMonitor::RunError( TInt /*aError*/ ) |
|
193 { |
|
194 return KErrNone; // Handled the error fully |
|
195 } |
|
196 |
|
197 // end of file |