|
1 /* |
|
2 * Copyright (c) 2007 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: Implementation of Notifier class of ETel |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "epos_comasupltrace.h" |
|
22 #include "epos_comasupletelnotifier.h" |
|
23 #include "epos_comasupllocationid.h" |
|
24 |
|
25 _LIT(KTraceFileName,"SUPL_OMA_SESSION::EPos_COMASuplETelNotifier.cpp"); |
|
26 |
|
27 // ============================ MEMBER FUNCTIONS OF COMASuplETelNotifier =============================== |
|
28 |
|
29 // ----------------------------------------------------------------------------- |
|
30 // COMASuplETelNotifier::COMASuplETelNotifier,constuctor |
|
31 // (other items were commented in a header). |
|
32 // ----------------------------------------------------------------------------- |
|
33 // |
|
34 |
|
35 COMASuplETelNotifier::COMASuplETelNotifier(MOMASuplETelNotifierObserver& aObserver,RMobilePhone& aPhone) |
|
36 : CActive(EPriorityStandard), |
|
37 iPhone(aPhone), |
|
38 iNetworkInfoPkg( iNetworkInfo), |
|
39 iHomeNetworkInfoPkg( iHomeNetworkInfo), |
|
40 iObserver(aObserver) |
|
41 { |
|
42 CActiveScheduler::Add(this); |
|
43 } |
|
44 |
|
45 // ----------------------------------------------------------------------------- |
|
46 // COMASuplETelNotifier::ConstructL,two phase constuctor |
|
47 // (other items were commented in a header). |
|
48 // ----------------------------------------------------------------------------- |
|
49 // |
|
50 void COMASuplETelNotifier::ConstructL() |
|
51 { |
|
52 iCellMode = EOMASuplNone; |
|
53 iTrace = COMASuplTrace::NewL(); |
|
54 iTrace->Trace(_L("COMASuplETelNotifier::ConstructL"), KTraceFileName, __LINE__); |
|
55 } |
|
56 |
|
57 // ----------------------------------------------------------------------------- |
|
58 // COMASuplETelNotifier::NewL,two phase constuctor |
|
59 // (other items were commented in a header). |
|
60 // ----------------------------------------------------------------------------- |
|
61 // |
|
62 COMASuplETelNotifier* COMASuplETelNotifier::NewL(MOMASuplETelNotifierObserver& aObserver, |
|
63 RMobilePhone& aPhone) |
|
64 { |
|
65 COMASuplETelNotifier* self = new( ELeave ) COMASuplETelNotifier(aObserver,aPhone); |
|
66 |
|
67 CleanupStack::PushL( self ); |
|
68 self->ConstructL(); |
|
69 CleanupStack::Pop(self); |
|
70 |
|
71 return self; |
|
72 } |
|
73 |
|
74 |
|
75 // ----------------------------------------------------------------------------- |
|
76 // COMASuplETelNotifier::DoCancel |
|
77 // (other items were commented in a header). |
|
78 // ----------------------------------------------------------------------------- |
|
79 // |
|
80 void COMASuplETelNotifier::DoCancel() |
|
81 { |
|
82 if(iCellMode == EOMASuplCellIdHome) |
|
83 { |
|
84 iTrace->Trace(_L("COMASuplETelNotifier, cancel home"), KTraceFileName, __LINE__); |
|
85 iPhone.CancelAsyncRequest(EMobilePhoneGetCurrentNetwork); |
|
86 } |
|
87 else if(iCellMode == EOMASuplCellIdCurrent) |
|
88 { |
|
89 iTrace->Trace(_L("COMASuplETelNotifier, cancel current"), KTraceFileName, __LINE__); |
|
90 iPhone.CancelAsyncRequest(EMobilePhoneGetHomeNetwork); |
|
91 } |
|
92 else if (iCellMode == EOMASuplCellIdNotify) |
|
93 { |
|
94 iTrace->Trace(_L("COMASuplETelNotifier, cancel notify"), KTraceFileName, __LINE__); |
|
95 iPhone.CancelAsyncRequest(EMobilePhoneNotifyCurrentNetworkChange); |
|
96 } |
|
97 } |
|
98 |
|
99 // ----------------------------------------------------------------------------- |
|
100 // COMASuplETelNotifier::~COMASuplETelNotifier,Destructor |
|
101 // (other items were commented in a header). |
|
102 // ----------------------------------------------------------------------------- |
|
103 // |
|
104 COMASuplETelNotifier::~COMASuplETelNotifier() |
|
105 { |
|
106 if (IsActive()) |
|
107 Cancel(); |
|
108 delete iTrace; |
|
109 } |
|
110 |
|
111 // ----------------------------------------------------------------------------- |
|
112 // COMASuplETelNotifier::CheckForRoaming,For retriving the cell id information |
|
113 // (other items were commented in a header). |
|
114 // ----------------------------------------------------------------------------- |
|
115 // |
|
116 void COMASuplETelNotifier::CheckForRoaming() |
|
117 { |
|
118 iCellMode = EOMASuplCellIdHome; |
|
119 iTrace->Trace(_L("COMASuplETelNotifier::CheckForRoaming..."),KTraceFileName, __LINE__); |
|
120 iPhone.GetHomeNetwork( iStatus, iHomeNetworkInfoPkg); |
|
121 SetActive(); |
|
122 } |
|
123 |
|
124 // ----------------------------------------------------------------------------- |
|
125 // COMASuplETelNotifier::CheckForRoaming,For retriving the cell id information |
|
126 // (other items were commented in a header). |
|
127 // ----------------------------------------------------------------------------- |
|
128 // |
|
129 void COMASuplETelNotifier::GetCurrentNetwork() |
|
130 { |
|
131 iCellMode = EOMASuplCellIdCurrent; |
|
132 iTrace->Trace(_L("COMASuplETelNotifier::GetCurrentNetwork..."),KTraceFileName, __LINE__); |
|
133 iPhone.GetCurrentNetwork( iStatus, iNetworkInfoPkg, iLocationInfo ); |
|
134 SetActive(); |
|
135 } |
|
136 |
|
137 // ----------------------------------------------------------------------------- |
|
138 // COMASuplETelNotifier::CheckForRoaming,For retriving the cell id information |
|
139 // (other items were commented in a header). |
|
140 // ----------------------------------------------------------------------------- |
|
141 // |
|
142 void COMASuplETelNotifier::NotifyCurrentNetworkChange() |
|
143 { |
|
144 iCellMode = EOMASuplCellIdNotify; |
|
145 iTrace->Trace(_L("COMASuplETelNotifier::NotifyCurrentNetworkChange..."),KTraceFileName, __LINE__); |
|
146 iPhone.NotifyCurrentNetworkChange( iStatus, iNetworkInfoPkg, iLocationInfo ); |
|
147 SetActive(); |
|
148 } |
|
149 |
|
150 // ----------------------------------------------------------------------------- |
|
151 // COMASuplETelNotifier::RunL |
|
152 // (other items were commented in a header). |
|
153 // ----------------------------------------------------------------------------- |
|
154 // |
|
155 void COMASuplETelNotifier::RunL() |
|
156 { |
|
157 if (iStatus == KErrNone) |
|
158 { |
|
159 if(iCellMode == EOMASuplCellIdHome) |
|
160 { |
|
161 GetCurrentNetwork(); |
|
162 } |
|
163 else if (iCellMode == EOMASuplCellIdCurrent) |
|
164 { |
|
165 CompeteRoamingCheckL(); |
|
166 } |
|
167 else |
|
168 { |
|
169 NotifyCurrentNetworkChange(); |
|
170 CompareForRoamingL(); |
|
171 } |
|
172 } |
|
173 else |
|
174 { |
|
175 if(iCellMode == EOMASuplCellIdHome) |
|
176 { |
|
177 // Error while processing |
|
178 iTrace->Trace(_L("Error in getting Home network"),KTraceFileName, __LINE__); |
|
179 iObserver.HandleCurrentNetworkChangeL(iStatus.Int(), ETrue); |
|
180 } |
|
181 if(iCellMode == EOMASuplCellIdCurrent) |
|
182 { |
|
183 // Error while processing |
|
184 iTrace->Trace(_L("Error in getting Current network"),KTraceFileName, __LINE__); |
|
185 iObserver.HandleCurrentNetworkChangeL(iStatus.Int(), ETrue); |
|
186 } |
|
187 else |
|
188 { |
|
189 // Error while processing |
|
190 iTrace->Trace(_L("Error in getting Notify Current network change"),KTraceFileName, __LINE__); |
|
191 iObserver.HandleCurrentNetworkChangeL(iStatus.Int(), ETrue); |
|
192 } |
|
193 } |
|
194 } |
|
195 |
|
196 // ----------------------------------------------------------------------------- |
|
197 // COMASuplETelNotifier::RunError, Will be called by framework,if RunL leaves. |
|
198 // (other items were commented in a header). |
|
199 // ----------------------------------------------------------------------------- |
|
200 // |
|
201 TInt COMASuplETelNotifier::RunError(TInt aError) |
|
202 { |
|
203 if(iCellMode == EOMASuplCellIdHome) |
|
204 { |
|
205 // Error while processing |
|
206 iTrace->Trace(_L("RunL leaved for Home Network"),KTraceFileName, __LINE__); |
|
207 } |
|
208 else if(iCellMode == EOMASuplCellIdCurrent) |
|
209 { |
|
210 // Error while processing |
|
211 iTrace->Trace(_L("RunL leaved for Current Network"),KTraceFileName, __LINE__); |
|
212 } |
|
213 { |
|
214 // Error while processing |
|
215 iTrace->Trace(_L("RunL leaved for Current Network change notification"),KTraceFileName, __LINE__); |
|
216 } |
|
217 TRAP_IGNORE(iObserver.HandleCurrentNetworkChangeL(aError, ETrue)); |
|
218 |
|
219 return KErrNone; |
|
220 } |
|
221 |
|
222 void COMASuplETelNotifier::CompareForRoamingL() |
|
223 { |
|
224 TInt64 currMNC=0; |
|
225 TLex LexcurrMNC(iNetworkInfo.iNetworkId); |
|
226 LexcurrMNC.Val(currMNC); |
|
227 |
|
228 TInt64 homeMNC=0; |
|
229 TLex LexhomeMNC(iHomeNetworkInfo.iNetworkId); |
|
230 LexhomeMNC.Val(homeMNC); |
|
231 |
|
232 if (currMNC != homeMNC) |
|
233 iObserver.HandleCurrentNetworkChangeL(KErrNone, EFalse); |
|
234 else |
|
235 iObserver.HandleCurrentNetworkChangeL(KErrNone, ETrue); |
|
236 } |
|
237 |
|
238 void COMASuplETelNotifier::CompeteRoamingCheckL() |
|
239 { |
|
240 TInt64 currMNC=0; |
|
241 TLex LexcurrMNC(iNetworkInfo.iNetworkId); |
|
242 LexcurrMNC.Val(currMNC); |
|
243 |
|
244 TInt64 homeMNC=0; |
|
245 TLex LexhomeMNC(iHomeNetworkInfo.iNetworkId); |
|
246 LexhomeMNC.Val(homeMNC); |
|
247 |
|
248 if (currMNC != homeMNC) |
|
249 iObserver.HandleRoamingCheckCompleteL(KErrNone, EFalse); |
|
250 else |
|
251 iObserver.HandleRoamingCheckCompleteL(KErrNone, ETrue); |
|
252 } |
|
253 // End of File |