|
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: This module contains the implementation of |
|
15 CNWNetworkSelectionSettingMonitor class |
|
16 * member functions. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include "CNWMessageHandler.h" |
|
23 #include "cnwnetworkselectionsettingmonitor.h" |
|
24 #include "NWHandlingEngine.h" |
|
25 #include "NWPanic.pan" |
|
26 #include "NWLogger.h" |
|
27 |
|
28 |
|
29 |
|
30 // ================= MEMBER FUNCTIONS ========================================= |
|
31 |
|
32 // ---------------------------------------------------------------------------- |
|
33 // CNWNetworkSelectionSettingMonitor::CNWNetworkSelectionSettingMonitor |
|
34 // C++ default constructor can NOT contain any code, that |
|
35 // might leave. |
|
36 // ---------------------------------------------------------------------------- |
|
37 // |
|
38 CNWNetworkSelectionSettingMonitor::CNWNetworkSelectionSettingMonitor |
|
39 ( |
|
40 CNWMessageHandler& aOwner, // ref. to class owner |
|
41 RMobilePhone& aPhone, // ref. to mobile phone |
|
42 TNWInfo& aNetworkInfo, // ref. to network info struct |
|
43 RMmCustomAPI& aCustomAPI ) //ref. to customAPI |
|
44 : CNWNetworkMonitorBase( aOwner, |
|
45 aPhone, |
|
46 aNetworkInfo, |
|
47 aCustomAPI ), |
|
48 iNetworkSelectionPckg( iNetworkSelection ) |
|
49 { |
|
50 NWLOGSTRING( KNWOBJECT, |
|
51 "NW: CNWNetworkSelectionSettingMonitor::\ |
|
52 CNWNetworkSelectionSettingMonitor() Begin" ); |
|
53 |
|
54 CActiveScheduler::Add( this ); |
|
55 |
|
56 NWLOGSTRING( KNWOBJECT, |
|
57 "NW: CNWNetworkSelectionSettingMonitor::\ |
|
58 CNWNetworkSelectionSettingMonitor() End" ); |
|
59 } |
|
60 |
|
61 |
|
62 // ---------------------------------------------------------------------------- |
|
63 // CNWNetworkSelectionSettingMonitor::NewL |
|
64 // Two-phased constructor. |
|
65 // ---------------------------------------------------------------------------- |
|
66 // |
|
67 CNWNetworkSelectionSettingMonitor* |
|
68 CNWNetworkSelectionSettingMonitor::NewL( |
|
69 CNWMessageHandler& aOwner, |
|
70 RMobilePhone& aPhone, |
|
71 TNWInfo& aNetworkInfo, |
|
72 RMmCustomAPI& aCustomAPI ) |
|
73 { |
|
74 NWLOGSTRING( KNWOBJECT, |
|
75 "NW: CNWNetworkSelectionSettingMonitor::NewL() Begin" ); |
|
76 |
|
77 CNWNetworkSelectionSettingMonitor* self = |
|
78 new( ELeave ) CNWNetworkSelectionSettingMonitor( aOwner, |
|
79 aPhone, |
|
80 aNetworkInfo, |
|
81 aCustomAPI ); |
|
82 |
|
83 NWLOGSTRING( KNWOBJECT, |
|
84 "NW: CNWNetworkSelectionSettingMonitor::NewL() End" ); |
|
85 |
|
86 return self; |
|
87 } |
|
88 |
|
89 // Destructor |
|
90 CNWNetworkSelectionSettingMonitor::~CNWNetworkSelectionSettingMonitor() |
|
91 { |
|
92 NWLOGSTRING( KNWOBJECT, |
|
93 "NW: CNWNetworkSelectionSettingMonitor::\ |
|
94 ~CNWNetworkSelectionSettingMonitor() Begin" ); |
|
95 |
|
96 Cancel(); |
|
97 |
|
98 NWLOGSTRING( KNWOBJECT, |
|
99 "NW: CNWNetworkSelectionSettingMonitor::\ |
|
100 ~CNWNetworkSelectionSettingMonitor() End" ); |
|
101 } |
|
102 |
|
103 // ---------------------------------------------------------------------------- |
|
104 // CNWNetworkSelectionSettingMonitor::DoCancel |
|
105 // Cancels the pending async. command. |
|
106 // (other items were commented in a header). |
|
107 // ---------------------------------------------------------------------------- |
|
108 // |
|
109 void CNWNetworkSelectionSettingMonitor::DoCancel() |
|
110 { |
|
111 NWLOGSTRING( KNWOBJECT, |
|
112 "NW: CNWNetworkSelectionSettingMonitor::DoCancel() Begin" ); |
|
113 |
|
114 iPhone.CancelAsyncRequest( |
|
115 EMobilePhoneNotifyNetworkSelectionSettingChange ); |
|
116 |
|
117 NWLOGSTRING( KNWOBJECT, |
|
118 "NW: CNWNetworkSelectionSettingMonitor::DoCancel() End" ); |
|
119 } |
|
120 |
|
121 // ---------------------------------------------------------------------------- |
|
122 // CNWNetworkSelectionSettingMonitor::RunL |
|
123 // Receives the completion of the pending async. command, saves possible values |
|
124 // from async. function call and sends notification to CNWSession object. |
|
125 // (other items were commented in a header). |
|
126 // ---------------------------------------------------------------------------- |
|
127 // |
|
128 void CNWNetworkSelectionSettingMonitor::RunL() |
|
129 { |
|
130 NWLOGSTRING2( KNWOBJECT, |
|
131 "NW: CNWNetworkSelectionSettingMonitor::RunL() Begin,\ |
|
132 iStatus.Int() = %d", iStatus.Int() ); |
|
133 |
|
134 if ( iStatus != KErrNone ) |
|
135 { |
|
136 NWLOGSTRING2( KNWERROR, |
|
137 "NW: Net.Sel.Set.Monitor.RunL, Unknown error, iStatus = %d", |
|
138 iStatus.Int() ); |
|
139 iIsInitialised = EFalse; // Ensure we get current net info. |
|
140 } |
|
141 else |
|
142 { |
|
143 UpdateNetworkSelectionSetting(); |
|
144 iIsInitialised = ETrue; |
|
145 } |
|
146 // Check if monitor can be restarted. |
|
147 if ( iStatus != KErrCancel && iStatus != KErrServerTerminated ) |
|
148 { |
|
149 IssueRequest(); |
|
150 } |
|
151 |
|
152 NWLOGSTRING( KNWOBJECT, |
|
153 "NW: CNWNetworkSelectionSettingMonitor::RunL() End" ); |
|
154 } |
|
155 |
|
156 // ---------------------------------------------------------------------------- |
|
157 // CNWNetworkSelectionSettingMonitor::IssueRequest |
|
158 // Executes the async. NotifyNetworkSelectionSettingChange function. |
|
159 // If the network selection setting monitor is not yet initialised, |
|
160 // gets the initial Setting with sync. GetNetworkSelectionSetting function. |
|
161 // Then starts monitoring the setting changes. |
|
162 // (other items were commented in a header). |
|
163 // ---------------------------------------------------------------------------- |
|
164 void CNWNetworkSelectionSettingMonitor::IssueRequest() |
|
165 { |
|
166 NWLOGSTRING( KNWOBJECT, |
|
167 "NW: CNWNetworkSelectionSettingMonitor::IssueRequest() Begin" ); |
|
168 |
|
169 if ( !IsActive() ) |
|
170 { |
|
171 // Start monitoring mode changes. |
|
172 NWLOGSTRING( KNWREQOUT, "NW: Net.Sel.Set.Monitor.IssueRequest ->" ); |
|
173 iPhone.NotifyNetworkSelectionSettingChange( |
|
174 iStatus, iNetworkSelectionPckg ); |
|
175 SetActive(); |
|
176 |
|
177 // Get initial value for the mode, if not initialised yet. |
|
178 if ( !iIsInitialised ) |
|
179 { |
|
180 iIsInitialised = ETrue; |
|
181 TInt error = iPhone.GetNetworkSelectionSetting( |
|
182 iNetworkSelectionPckg ); |
|
183 if ( error == KErrNone ) |
|
184 { |
|
185 UpdateNetworkSelectionSetting(); |
|
186 NWLOGSTRING( KNWREQOUT, |
|
187 "NW: Net.Sel.Set.Monitor.IssueRequest <-" ); |
|
188 } |
|
189 else |
|
190 { |
|
191 NWLOGSTRING2( KNWERROR, |
|
192 "NW: Net.Sel.Set.Monitor.IssueRequest,Error = %d", error ); |
|
193 NWLOGSTRING( KNWREQOUT, |
|
194 "NW: Net.Sel.Set.Monitor.IssueRequest <-" ); |
|
195 } |
|
196 } |
|
197 } |
|
198 else |
|
199 { |
|
200 NWLOGSTRING( KNWERROR, |
|
201 "NW: Net.Sel.Set.Monitor.IssueRequest Already active <-" ); |
|
202 } |
|
203 |
|
204 NWLOGSTRING( KNWOBJECT, |
|
205 "NW: CNWNetworkSelectionSettingMonitor::IssueRequest() End" ); |
|
206 } |
|
207 |
|
208 // ---------------------------------------------------------------------------- |
|
209 // CNWNetworkSelectionSettingMonitor::UpdateNetworkSelectionSetting |
|
210 // Update network selection setting |
|
211 // ---------------------------------------------------------------------------- |
|
212 void CNWNetworkSelectionSettingMonitor::UpdateNetworkSelectionSetting() |
|
213 { |
|
214 NWLOGSTRING( KNWOBJECT, |
|
215 "NW: CNWNetworkSelectionSettingMonitor::\ |
|
216 UpdateNetworkSelectionSetting() Begin" ); |
|
217 |
|
218 iNetworkSelection = iNetworkSelectionPckg(); |
|
219 NWLOGSTRING2( KNWERROR, |
|
220 "NW: Net.Sel.Set.Monitor setting = %d", iNetworkSelection.iMethod ); |
|
221 switch ( iNetworkSelection.iMethod ) |
|
222 { |
|
223 case RMobilePhone::ENetworkSelectionUnknown: |
|
224 { |
|
225 iNWNetworkInfo.iSelectionSetting = ENWNetworkSelectionUnknown; |
|
226 break; |
|
227 } |
|
228 case RMobilePhone::ENetworkSelectionAutomatic: |
|
229 { |
|
230 iNWNetworkInfo.iSelectionSetting = ENWNetworkSelectionAutomatic; |
|
231 break; |
|
232 } |
|
233 case RMobilePhone::ENetworkSelectionManual: |
|
234 { |
|
235 iNWNetworkInfo.iSelectionSetting = ENWNetworkSelectionManual; |
|
236 break; |
|
237 } |
|
238 default: |
|
239 { |
|
240 iNWNetworkInfo.iSelectionSetting = ENWNetworkSelectionUnknown; |
|
241 break; |
|
242 } |
|
243 } |
|
244 NWLOGSTRING( KNWERROR, |
|
245 "NW: Net.Sel.Set.Monitor send ENWMessageNetworkSelectionSettingChange" ); |
|
246 iOwner.SendMessage ( |
|
247 MNWMessageObserver::ENWMessageNetworkSelectionSettingChange ); |
|
248 |
|
249 NWLOGSTRING( KNWOBJECT, |
|
250 "NW: CNWNetworkSelectionSettingMonitor::\ |
|
251 UpdateNetworkSelectionSetting() End" ); |
|
252 } |
|
253 |
|
254 // ---------------------------------------------------------------------------- |
|
255 // CNWNetworkSelectionSettingMonitor::RunError |
|
256 // ---------------------------------------------------------------------------- |
|
257 // |
|
258 TInt CNWNetworkSelectionSettingMonitor::RunError( TInt /*aError*/ ) |
|
259 { |
|
260 NWLOGSTRING( KNWERROR, |
|
261 "NW: CNWNetworkSelectionSettingMonitor::RunError() Called" ); |
|
262 |
|
263 return KErrNone; |
|
264 } |
|
265 |
|
266 |
|
267 // End of File |