|
1 /* |
|
2 * Copyright (c) 2004 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: CSysApEtelConnector implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <e32svr.h> |
|
21 #include <mmtsy_names.h> |
|
22 #include "SysApAppUi.h" |
|
23 #include "SysApEtelConnector.h" |
|
24 #include "SysApEtelNetworkStatusNspsObserver.h" |
|
25 #include "SysApEtelSmsStoreObserver.h" |
|
26 #include "SysApEtelNetworkBarObserver.h" |
|
27 #include "sysapeteldatabearerobserver.h" |
|
28 #include "sysapetelnetworkinfoobserver.h" |
|
29 #include "SysApFeatureManager.h" |
|
30 |
|
31 // ============================ MEMBER FUNCTIONS ============================== |
|
32 |
|
33 // ---------------------------------------------------------------------------- |
|
34 // C++ default constructor can NOT contain any code, that |
|
35 // might leave. |
|
36 // ---------------------------------------------------------------------------- |
|
37 |
|
38 CSysApEtelConnector::CSysApEtelConnector( CSysApAppUi& aSysApAppUi ) : |
|
39 iSysApEtelNetworkStatusNspsObserver( NULL ), |
|
40 iSysApAppUi( aSysApAppUi ), |
|
41 iSysApEtelNetworkBarObserver( NULL ), |
|
42 iSysApEtelSmsStoreObserver( NULL ), |
|
43 iSysApEtelDataBearerObserver( NULL ), |
|
44 iSysApEtelNetworkInfoObserver( NULL ) |
|
45 { |
|
46 } |
|
47 |
|
48 // ---------------------------------------------------------------------------- |
|
49 // CSysApEtelConnector::ConstructL() |
|
50 // ---------------------------------------------------------------------------- |
|
51 |
|
52 void CSysApEtelConnector::ConstructL() |
|
53 { |
|
54 TRACES( RDebug::Print( _L("CSysApEtelConnector::ConstructL: START") ) ); |
|
55 TInt err( KErrGeneral ); |
|
56 TInt thisTry( 0 ); |
|
57 /* Server connections are tried KTriesToConnectServer times because occasional |
|
58 fails on connections are possible at least on some servers */ |
|
59 |
|
60 TRACES( RDebug::Print( _L("CSysApEtelConnector::ConstructL: trying RTelServer::Connect()") ) ); |
|
61 while ( ( err = iEtelServer.Connect() ) != KErrNone && ( thisTry++ ) <= KTriesToConnectServer ) |
|
62 { |
|
63 TRACES( RDebug::Print( _L("CSysApEtelConnector::ConstructL: RTelServer::Connect() failed. Error: %d"), err ) ); |
|
64 User::After( KTimeBeforeRetryingServerConnection ); |
|
65 } |
|
66 User::LeaveIfError( err ); |
|
67 |
|
68 TRACES( RDebug::Print( _L("CSysApEtelConnector::ConstructL: trying RTelServer::LoadPhoneModule()") ) ); |
|
69 err = iEtelServer.LoadPhoneModule( KMmTsyModuleName ); |
|
70 while ( ( err != KErrNone ) && ( err != KErrAlreadyExists ) && ( thisTry++ ) <= KTriesToConnectServer ) |
|
71 { |
|
72 TRACES( RDebug::Print( _L("CSysApEtelConnector::ConstructL: RTelServer::LoadPhoneModule() failed. Error: %d"), err ) ); |
|
73 User::After( KTimeBeforeRetryingServerConnection ); |
|
74 err = iEtelServer.LoadPhoneModule( KMmTsyModuleName ); |
|
75 } |
|
76 User::LeaveIfError( err ); |
|
77 |
|
78 thisTry = 0; |
|
79 TRACES( RDebug::Print( _L("CSysApEtelConnector::ConstructL: trying RMobilePhone::Open()") ) ); |
|
80 while ( ( err = iPhone.Open( iEtelServer, KMmTsyPhoneName ) ) != KErrNone && ( thisTry++ ) <= KTriesToConnectServer ) |
|
81 { |
|
82 TRACES( RDebug::Print( _L("CSysApEtelConnector::ConstructL: RMobilePhone::Open() failed. Error: %d"), err ) ); |
|
83 User::After( KTimeBeforeRetryingServerConnection ); |
|
84 } |
|
85 User::LeaveIfError( err ); |
|
86 |
|
87 thisTry = 0; |
|
88 TRACES( RDebug::Print( _L("CSysApEtelConnector::ConstructL: trying RMmCustomAPI::Open()") ) ); |
|
89 while ( ( err = iCustomAPI.Open( iPhone ) ) != KErrNone && ( thisTry++ ) <= KTriesToConnectServer ) |
|
90 { |
|
91 TRACES( RDebug::Print( _L("CSysApEtelConnector::ConstructL: RMmCustomAPI::Open() failed. Error: %d"), err ) ); |
|
92 User::After( KTimeBeforeRetryingServerConnection ); |
|
93 } |
|
94 User::LeaveIfError( err ); |
|
95 |
|
96 // Connect to SMS messaging |
|
97 thisTry = 0; |
|
98 TRACES( RDebug::Print( _L("CSysApEtelConnector::ConstructL: trying RMobileSmsMessaging::Open()") ) ); |
|
99 while ( ( err = iSmsMessaging.Open( iPhone ) ) != KErrNone && ( thisTry++ ) <= KTriesToConnectServer ) |
|
100 { |
|
101 TRACES( RDebug::Print( _L("CSysApEtelConnector::ConstructL: RMobileSmsMessaging::Open() failed. Error: %d"), err ) ); |
|
102 User::After( KTimeBeforeRetryingServerConnection ); |
|
103 } |
|
104 User::LeaveIfError( err ); |
|
105 |
|
106 // Connect to SMS message store |
|
107 thisTry = 0; |
|
108 TRACES( RDebug::Print( _L("CSysApEtelConnector::ConstructL: trying RMobileSmsStore::Open()") ) ); |
|
109 while ( ( err = iSmsStore.Open( iSmsMessaging, KETelIccSmsStore ) ) != KErrNone && ( thisTry++ ) <= KTriesToConnectServer ) |
|
110 { |
|
111 TRACES( RDebug::Print( _L("CSysApEtelConnector::ConstructL: RMobileSmsStore::Open() failed. Error: %d"), err ) ); |
|
112 User::After( KTimeBeforeRetryingServerConnection ); |
|
113 } |
|
114 User::LeaveIfError( err ); |
|
115 |
|
116 // Initialize SMS Message store observer |
|
117 iSysApEtelSmsStoreObserver = CSysApEtelSmsStoreObserver::NewL( iSysApAppUi, iSmsStore ); |
|
118 |
|
119 iSysApEtelNetworkStatusNspsObserver = new( ELeave ) CSysApEtelNetworkStatusNspsObserver( iSysApAppUi, iCustomAPI ); |
|
120 |
|
121 iSysApEtelNetworkBarObserver = CSysApEtelNetworkBarObserver::NewL(iSysApAppUi, iPhone); |
|
122 |
|
123 iSysApEtelDataBearerObserver = CSysApEtelDataBearerObserver::NewL( iSysApAppUi, iPhone ); |
|
124 |
|
125 if ( iSysApAppUi.SysApFeatureManager().Supported( KSysApFeatureIdUseHsdpaAvailableIcon ) ) |
|
126 { |
|
127 iSysApEtelNetworkInfoObserver = CSysApEtelNetworkInfoObserver::NewL( iSysApAppUi, iPhone, iCustomAPI ); |
|
128 } |
|
129 |
|
130 TRACES( RDebug::Print( _L("CSysApEtelConnector::ConstructL: END") ) ); |
|
131 } |
|
132 |
|
133 // ---------------------------------------------------------------------------- |
|
134 // CSysApEtelConnector::CommandNetCsWakeupOnNsps() |
|
135 // ---------------------------------------------------------------------------- |
|
136 |
|
137 void CSysApEtelConnector::CommandNetCsWakeupOnNsps() |
|
138 { |
|
139 iSysApEtelNetworkStatusNspsObserver->CommandNetCsWakeupOnNsps(); |
|
140 } |
|
141 |
|
142 // ---------------------------------------------------------------------------- |
|
143 // CSysApEtelConnector::GetSignalBars() |
|
144 // ---------------------------------------------------------------------------- |
|
145 |
|
146 TInt CSysApEtelConnector::GetSignalBars() const |
|
147 { |
|
148 return iSysApEtelNetworkBarObserver->GetBarCount(); |
|
149 } |
|
150 |
|
151 // ---------------------------------------------------------------------------- |
|
152 // CSysApEtelConnector::GetTelServer() |
|
153 // ---------------------------------------------------------------------------- |
|
154 |
|
155 RTelServer* CSysApEtelConnector::GetTelServer() |
|
156 { |
|
157 return &iEtelServer; |
|
158 } |
|
159 |
|
160 // ---------------------------------------------------------------------------- |
|
161 // CSysApEtelConnector::NewL( CSysApAppUi& aSysApAppUi ) |
|
162 // ---------------------------------------------------------------------------- |
|
163 |
|
164 CSysApEtelConnector* CSysApEtelConnector::NewL( CSysApAppUi& aSysApAppUi ) |
|
165 { |
|
166 TRACES( RDebug::Print( _L("CSysApEtelConnector::NewL") ) ); |
|
167 CSysApEtelConnector* self = new (ELeave) CSysApEtelConnector( aSysApAppUi ); |
|
168 CleanupStack::PushL( self ); |
|
169 self->ConstructL(); |
|
170 CleanupStack::Pop(); |
|
171 return self; |
|
172 } |
|
173 |
|
174 // ---------------------------------------------------------------------------- |
|
175 // CSysApEtelConnector::~CSysApEtelConnector() |
|
176 // ---------------------------------------------------------------------------- |
|
177 |
|
178 CSysApEtelConnector::~CSysApEtelConnector() |
|
179 { |
|
180 TRACES( RDebug::Print( _L("CSysApEtelConnector::~CSysApEtelConnector") ) ); |
|
181 delete iSysApEtelNetworkStatusNspsObserver; |
|
182 delete iSysApEtelNetworkBarObserver; |
|
183 |
|
184 delete iSysApEtelSmsStoreObserver; |
|
185 |
|
186 iSmsStore.Close(); |
|
187 iSmsMessaging.Close(); |
|
188 |
|
189 delete iSysApEtelDataBearerObserver; |
|
190 delete iSysApEtelNetworkInfoObserver; |
|
191 |
|
192 iCustomAPI.Close(); |
|
193 iPhone.Close(); |
|
194 iEtelServer.Close(); |
|
195 } |
|
196 |
|
197 |
|
198 // ---------------------------------------------------------------------------- |
|
199 // CSysApEtelConnector::AlsSupported() |
|
200 // ---------------------------------------------------------------------------- |
|
201 |
|
202 TBool CSysApEtelConnector::AlsSupported() const |
|
203 { |
|
204 TBool alsSupported = AlsPpOnOff(); |
|
205 // if ALS product profile is TRUE then ALS supported and there |
|
206 // is no reason to check AlsSupported info. |
|
207 |
|
208 if ( !alsSupported ) |
|
209 { |
|
210 // ALS Product Profile is Off then we must check ALS support by |
|
211 // using AlsSimSupport since it check SIM ALS support information. |
|
212 alsSupported = AlsSimSupport(); |
|
213 } |
|
214 |
|
215 TRACES( RDebug::Print( _L("CSysApEtelConnector::AlsSupported: alsSupported=%d"), |
|
216 alsSupported ) ); |
|
217 |
|
218 return alsSupported; |
|
219 } |
|
220 |
|
221 // ---------------------------------------------------------------------------- |
|
222 // CSysApEtelConnector::IsBearerHsdpa() |
|
223 // ---------------------------------------------------------------------------- |
|
224 |
|
225 TBool CSysApEtelConnector::IsBearerHsdpa() const |
|
226 { |
|
227 return iSysApEtelDataBearerObserver->IsBearerHsdpa(); |
|
228 } |
|
229 |
|
230 // ---------------------------------------------------------------------------- |
|
231 // CSysApEtelConnector::HsdpaAvailable() |
|
232 // ---------------------------------------------------------------------------- |
|
233 |
|
234 TBool CSysApEtelConnector::HsdpaAvailable() const |
|
235 { |
|
236 if ( iSysApEtelNetworkInfoObserver ) // observer created only if availability icon is supported |
|
237 { |
|
238 return iSysApEtelNetworkInfoObserver->HsdpaAvailable(); |
|
239 } |
|
240 else |
|
241 { |
|
242 return EFalse; |
|
243 } |
|
244 } |
|
245 |
|
246 // ---------------------------------------------------------------------------- |
|
247 // CSysApEtelConnector::AlsPpOnOff() |
|
248 // ---------------------------------------------------------------------------- |
|
249 |
|
250 TBool CSysApEtelConnector::AlsPpOnOff() const |
|
251 { |
|
252 RMmCustomAPI::TAlsSupport ppAlsSupport; |
|
253 TBool alsPpOnOff(EFalse); |
|
254 TInt err = iCustomAPI.CheckAlsPpSupport( ppAlsSupport ); |
|
255 |
|
256 if ( ( err == KErrNone ) && ( ppAlsSupport == RMmCustomAPI::EAlsSupportOn ) ) |
|
257 { |
|
258 alsPpOnOff = ETrue; |
|
259 } |
|
260 |
|
261 TRACES( RDebug::Print( _L("CSysApEtelConnector::AlsPpOnOff: alsPpOnOff=%d, err=%d"), alsPpOnOff, err ) ); |
|
262 |
|
263 return alsPpOnOff; |
|
264 } |
|
265 |
|
266 // ---------------------------------------------------------------------------- |
|
267 // CSysApEtelConnector::AlsCspOnOff() |
|
268 // ---------------------------------------------------------------------------- |
|
269 |
|
270 TBool CSysApEtelConnector::AlsCspOnOff() const |
|
271 { |
|
272 TBool alsCspOnOff( EFalse ); |
|
273 RMobilePhone::TMobilePhoneCspFileV1 cspFile; |
|
274 RMobilePhone::TMobilePhoneCspFileV1Pckg cspFilePckg( cspFile ); |
|
275 TRequestStatus status; |
|
276 iPhone.GetCustomerServiceProfile( status, cspFilePckg ); |
|
277 User::WaitForRequest( status ); |
|
278 TInt err( status.Int() ); |
|
279 if ( err == KErrNone && ( cspFile.iCphsTeleservices & RMobilePhone::KCspALS ) ) |
|
280 { |
|
281 alsCspOnOff = ETrue; |
|
282 } |
|
283 |
|
284 TRACES( RDebug::Print( _L("CSysApEtelConnector::AlsCspOnOff: alsCspOnOff=%d, err=%d, cphs=%d"), |
|
285 alsCspOnOff, err, cspFile.iCphsTeleservices ) ); |
|
286 |
|
287 return alsCspOnOff; |
|
288 } |
|
289 |
|
290 // ---------------------------------------------------------------------------- |
|
291 // CSysApEtelConnector::AlsSimSupport() |
|
292 // ---------------------------------------------------------------------------- |
|
293 |
|
294 TBool CSysApEtelConnector::AlsSimSupport() const |
|
295 { |
|
296 RMobilePhone::TMobilePhoneALSLine alsLine( RMobilePhone::EAlternateLineNotAvailable ); |
|
297 TBool alsSupported( EFalse ); |
|
298 |
|
299 if ( AlsCspOnOff() ) |
|
300 { |
|
301 if ( iPhone.GetALSLine( alsLine ) == KErrNone ) |
|
302 { |
|
303 switch ( alsLine ) |
|
304 { |
|
305 case RMobilePhone::EAlternateLinePrimary: |
|
306 case RMobilePhone::EAlternateLineAuxiliary: |
|
307 case RMobilePhone::EAlternateLineUnknown: |
|
308 alsSupported = ETrue; |
|
309 break; |
|
310 |
|
311 default: |
|
312 case RMobilePhone::EAlternateLineNotAvailable: |
|
313 alsSupported = EFalse; |
|
314 break; |
|
315 } |
|
316 } |
|
317 } |
|
318 |
|
319 TRACES( RDebug::Print( _L("CSysApEtelConnector::AlsSimSupport: alsLine=%d, alsSupported=%d"), |
|
320 alsLine, alsSupported ) ); |
|
321 |
|
322 return alsSupported; |
|
323 } |
|
324 |
|
325 // ---------------------------------------------------------------------------- |
|
326 // CSysApEtelConnector::IsSimSmsStoreFull() |
|
327 // ---------------------------------------------------------------------------- |
|
328 |
|
329 TBool CSysApEtelConnector::IsSimSmsStoreFull() const |
|
330 { |
|
331 return iSysApEtelSmsStoreObserver->IsFull(); |
|
332 } |
|
333 |
|
334 // ---------------------------------------------------------------------------- |
|
335 // CSysApEtelConnector::ReadSimSmsStoreStatusInStartup() |
|
336 // ---------------------------------------------------------------------------- |
|
337 |
|
338 void CSysApEtelConnector::ReadSimSmsStoreStatusInStartup() |
|
339 { |
|
340 iSysApEtelSmsStoreObserver->ReadStatusInStartup(); |
|
341 } |
|
342 |
|
343 // ---------------------------------------------------------------------------- |
|
344 // CSysApEtelConnector::SimCallDivertEfSupported() |
|
345 // ---------------------------------------------------------------------------- |
|
346 |
|
347 TBool CSysApEtelConnector::SimCallDivertEfSupported() const |
|
348 { |
|
349 #ifndef __WINS__ // ETel panics due to TSY stub returning KErrNotSupported in emulator |
|
350 TRequestStatus status; |
|
351 RMmCustomAPI::TCFIndicators cfIndicators; |
|
352 RMmCustomAPI::TCFIndicatorsPckg cfIndicatorPckg( cfIndicators ); |
|
353 |
|
354 iCustomAPI.GetIccCallForwardingIndicatorStatus( status, cfIndicatorPckg ); |
|
355 User::WaitForRequest( status ); |
|
356 |
|
357 TInt err( status.Int() ); |
|
358 |
|
359 TRACES( RDebug::Print( _L("CSysApEtelConnector::SimCallDivertEfSupported: err=%d"), err ) ); |
|
360 |
|
361 // KErrNotFound explicitly states that CF-EF is not present in the SIM, but it is probably |
|
362 // safer to assume no support for CF-EF also with other error values |
|
363 return ( err == KErrNone ); |
|
364 #else // __WINS__ |
|
365 return EFalse; |
|
366 #endif // __WINS__ |
|
367 } |
|
368 |
|
369 // End of File |
|
370 |
|
371 |