|
1 /* |
|
2 * Copyright (c) 2008 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: javamobinfo implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <e32base.h> |
|
20 #include <etelmm.h> |
|
21 #include <mmtsy_names.h> // TSY and Phone name |
|
22 #include <commsdattypesv1_1.h> |
|
23 #include <cdblen.h> |
|
24 #include <commdb.h> |
|
25 #include <rconnmon.h> |
|
26 |
|
27 #include <cmmanager.h> |
|
28 #include <cmconnectionmethoddef.h> |
|
29 #include <cmpluginpacketdatadef.h> |
|
30 #include <cmpluginwlandef.h> |
|
31 #include <cmpluginhscsddef.h> |
|
32 using namespace CMManager; |
|
33 |
|
34 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
35 #include <es_sock.h> |
|
36 #include <es_enum.h> |
|
37 #else |
|
38 #include <es_enum_internal.h> |
|
39 #include <es_sock_partner.h> |
|
40 #endif |
|
41 |
|
42 #include "logger.h" |
|
43 #include "s60commonutils.h" |
|
44 |
|
45 #include "com_nokia_mj_impl_properties_mobinfo_MobileInfoProperties.h" |
|
46 #include "mobinfoconstants.h" |
|
47 |
|
48 #include "javauids.h" |
|
49 |
|
50 using namespace std; |
|
51 using namespace CommsDat; |
|
52 |
|
53 _LIT(KNetworkAvailable, "available"); |
|
54 _LIT(KNetworkUnavailable, "unavailable"); |
|
55 |
|
56 _LIT(KNetworkAccessPdLAN, "lan"); // Local Area Network |
|
57 _LIT(KNetworkAccessPdGSM, "pd"); // Packet data in GSM network |
|
58 _LIT(KNetworkAccessPdEDGE, "pd.EDGE"); // Packet data in EDGE network |
|
59 _LIT(KNetworkAccessPd3G, "pd.3G"); // Packet data in 3G network |
|
60 _LIT(KNetworkAccessHSPDA, "pd.HSPDA"); // High speed downlink packet access for 3G networks |
|
61 _LIT(KNetworkAccessCSD, "csd"); // Circuit switched data, for example GSM CSD/HSCSD data call |
|
62 _LIT(KNetworkAccessBtPan, "bt_pan"); // Bluetooth PAN network |
|
63 _LIT(KNetworkAccessWLAN, "wlan"); // Wireless network, for example 802.11b, 802.11G or WiMaX |
|
64 _LIT(KNetworkAccessNa, "na"); // Not applicable, the implementation can’t determine the type |
|
65 |
|
66 _LIT(KNetworkStatusHome, "home"); // Home operator |
|
67 _LIT(KNetworkStatusRoaming, "roaming"); // Roaming |
|
68 _LIT(KNetworkStatusUnknown, "unknown"); // Unknown operator |
|
69 |
|
70 _LIT(KMSISDNSeparator, " "); // separator MSISDN numbers |
|
71 |
|
72 const TInt KMaxPropertySize = 50; |
|
73 const TInt KJVMProcessUid = KJavaMidp; |
|
74 |
|
75 // --------------------------------------------------------------------------- |
|
76 // forward declarations |
|
77 // --------------------------------------------------------------------------- |
|
78 HBufC* GetProperty(const TInt aProperty, const TUint32 aAppDefaultApn); |
|
79 HBufC* GetTelephonyPropertyL(const TInt aProperty); |
|
80 HBufC* GetDateTimePropertyL(const TInt aProperty); |
|
81 HBufC* GetNetworkAccessL(const TUint32 aAppDefaultApn); |
|
82 TUint32 GetUsedIapL(); |
|
83 HBufC* GetBearerTypeL(TUint32 aIapId); |
|
84 HBufC* TranslateBearerInfoToNetworkAccessL(TConnMonBearerInfo aBearerInfo); |
|
85 HBufC* GetDefIapBearerTypeL(TUint32 aMidSuiteId); |
|
86 |
|
87 /* |
|
88 * Class: com_nokia_mj_impl_properties_mobinfo_MobileInfoProperties |
|
89 * Method: _getProperty |
|
90 * Signature: (I)Ljava/lang/String; |
|
91 */ |
|
92 |
|
93 // --------------------------------------------------------------------------- |
|
94 // JNI function called from java side from MobileInfoProperties class. |
|
95 // Each mobinfo java property implementation calls the getPropertyMsid() |
|
96 // function of the MobileInfoProperties class. |
|
97 // @param aProperty name of the actual property |
|
98 // @param aAppDefaultApn Application default apn |
|
99 // ----------------------------------------------------------------------------- |
|
100 JNIEXPORT jstring JNICALL |
|
101 Java_com_nokia_mj_impl_properties_mobinfo_MobileInfoProperties__1getPropertyApn |
|
102 (JNIEnv* aJni, jclass, jint aProperty, jint aAppDefaultApn) |
|
103 { |
|
104 LOG1(ESOCKET, EInfo, "MOBINFO + getPropertyMsid(), msid: %D", aAppDefaultApn); |
|
105 HBufC* property = NULL; |
|
106 jstring str = NULL; |
|
107 property = GetProperty(aProperty, aAppDefaultApn); |
|
108 if (NULL != property) |
|
109 { |
|
110 LOG(ESOCKET,EInfo,"_getPropertyApn, property is not null"); |
|
111 str = java::util::S60CommonUtils::NativeToJavaString(*aJni, property->Des()); |
|
112 LOG(ESOCKET, EInfo,"MOBINFO - after nativetojavastring"); |
|
113 //LOG1( ESOCKET, EInfo,"MOBINFO returning value: %S", property->Des()); |
|
114 delete property; |
|
115 } |
|
116 LOG(ESOCKET, EInfo, "MOBINFO - getPropertyMsid()"); |
|
117 return str; |
|
118 } |
|
119 |
|
120 JNIEXPORT jstring JNICALL Java_com_nokia_mj_impl_properties_mobinfo_MobileInfoProperties__1getProperty |
|
121 (JNIEnv *aJni, jobject, jint aKey) |
|
122 { |
|
123 LOG1(ESOCKET, EInfo, "MOBINFO Key: %d", aKey); |
|
124 HBufC* property = NULL; |
|
125 jstring str = NULL; |
|
126 |
|
127 property = GetProperty(aKey,NULL); |
|
128 if (NULL != property) |
|
129 { |
|
130 TPtrC data(property->Des()); |
|
131 str = java::util::S60CommonUtils::NativeToJavaString(*aJni, data); |
|
132 delete property; |
|
133 } |
|
134 return str; |
|
135 } |
|
136 |
|
137 HBufC* GetProperty(const TInt aProperty, const TUint32 aAppDefaultApn) |
|
138 { |
|
139 JELOG2(ESOCKET); |
|
140 LOG(ESOCKET, EInfo, "MOBINFO + GetProperty()"); |
|
141 HBufC* property = NULL; |
|
142 TInt err; |
|
143 |
|
144 switch (aProperty) |
|
145 { |
|
146 case DATEFORMAT: |
|
147 case TIMEFORMAT: |
|
148 TRAP(err, property = GetDateTimePropertyL(aProperty)); |
|
149 break; |
|
150 case NETWORK_ACCESS: |
|
151 TRAP(err, property = GetNetworkAccessL(aAppDefaultApn)); |
|
152 LOG(ESOCKET, EInfo,"after GetNetworkAccessL"); |
|
153 break; |
|
154 |
|
155 default: |
|
156 TRAP(err, property = GetTelephonyPropertyL(aProperty)); |
|
157 break; |
|
158 } |
|
159 return property; |
|
160 } |
|
161 |
|
162 // --------------------------------------------------------------------------- |
|
163 // Finds the default TSY module name from the CommDB. The GlobalSettings |
|
164 // table contains a field: ModemForPhoneServicesAndSMS, this field point to |
|
165 // a record in the ModemBearer table. The function reads the TsyName from |
|
166 // this linked table. |
|
167 // @param aTsyName TSY name to be initialized |
|
168 // ----------------------------------------------------------------------------- |
|
169 void GetDefaultTSYL(TDes& aTsyName) |
|
170 { |
|
171 JELOG2(ESOCKET); |
|
172 |
|
173 CMDBSession* db = CMDBSession::NewL(KCDVersion1_1); |
|
174 CleanupStack::PushL(db); |
|
175 |
|
176 // Load Global Settings record (there is always only 1 record in it) |
|
177 CCDGlobalSettingsRecord |
|
178 * ptrSingleGlSettingRecord = |
|
179 static_cast<CCDGlobalSettingsRecord*>(CCDRecordBase::RecordFactoryL( |
|
180 KCDTIdGlobalSettingsRecord)); |
|
181 CleanupStack::PushL(ptrSingleGlSettingRecord); |
|
182 |
|
183 ptrSingleGlSettingRecord->iRecordTag.SetL(1); |
|
184 if (ptrSingleGlSettingRecord->FindL(*db)) |
|
185 { |
|
186 // Find record by RecordTag |
|
187 CCDModemBearerRecord |
|
188 * ptrModemRecord = |
|
189 static_cast<CCDModemBearerRecord*>(CCDRecordBase::RecordFactoryL( |
|
190 KCDTIdModemBearerRecord)); |
|
191 CleanupStack::PushL(ptrModemRecord); |
|
192 |
|
193 ptrModemRecord->iRecordTag.SetL( |
|
194 ptrSingleGlSettingRecord->iModemForPhoneServicesAndSMS); |
|
195 if (ptrModemRecord->FindL(*db)) |
|
196 { |
|
197 aTsyName.Copy(ptrModemRecord->iTsyName); |
|
198 } |
|
199 |
|
200 CleanupStack::PopAndDestroy(ptrModemRecord); |
|
201 } |
|
202 |
|
203 CleanupStack::PopAndDestroy(ptrSingleGlSettingRecord); |
|
204 CleanupStack::PopAndDestroy(db); |
|
205 } |
|
206 |
|
207 // --------------------------------------------------------------------------- |
|
208 // Initializes the given RTelServer with the default TSY (GetDefaultTSYL) |
|
209 // module and opens the corresponding RMobilePhone. The searching of the |
|
210 // correct phone is based on the TSY name. |
|
211 // @param aMobilePhone RMobilePhone to be opened |
|
212 // @param aTelServer RTelServer instance to be initialized |
|
213 // ----------------------------------------------------------------------------- |
|
214 void GetDefaultPhoneL(RMobilePhone& aMobilePhone, RTelServer& aTelServer) |
|
215 { |
|
216 JELOG2(ESOCKET); |
|
217 |
|
218 HBufC* tsyName = HBufC16::NewLC(KCommsDbSvrMaxFieldLength); |
|
219 TPtr tsyPtr(tsyName->Des()); |
|
220 GetDefaultTSYL(tsyPtr); |
|
221 //LOG1(ESOCKET, EInfo, "MOBINFO Default Tsy = %S", tsyPtr); |
|
222 |
|
223 User::LeaveIfError(aTelServer.LoadPhoneModule(*tsyName)); |
|
224 LOG(ESOCKET, EInfo, "MOBINFO TSY loaded..."); |
|
225 |
|
226 // Get the name of the first phone |
|
227 TInt numPhones = 0; |
|
228 User::LeaveIfError(aTelServer.EnumeratePhones(numPhones)); |
|
229 LOG1(ESOCKET, EInfo, "MOBINFO - Phone count %D", numPhones); |
|
230 |
|
231 // Iterate through the phones until we find the correct one |
|
232 while (numPhones > 0) |
|
233 { |
|
234 // The GetTsyName function requires the index of the phone |
|
235 // so we must decrease the number here |
|
236 --numPhones; |
|
237 TName phoneTsy; |
|
238 User::LeaveIfError(aTelServer.GetTsyName(numPhones, phoneTsy)); |
|
239 //LOG1(ESOCKET, EInfo, "MOBINFO Available phone...%S", phoneTsy); |
|
240 if (phoneTsy.CompareF(*tsyName) == KErrNone) |
|
241 { |
|
242 // Get the phone info |
|
243 RTelServer::TPhoneInfo info; |
|
244 User::LeaveIfError(aTelServer.GetPhoneInfo(numPhones, info)); |
|
245 |
|
246 //LOG1(ESOCKET, EInfo, "MOBINFO Opening phone...%S", info.iName); |
|
247 |
|
248 TInt error = aMobilePhone.Open(aTelServer, info.iName); |
|
249 LOG1(ESOCKET, EInfo, "MOBINFO Phone status %D", error); |
|
250 User::LeaveIfError(error); |
|
251 |
|
252 // We can finish the search here |
|
253 numPhones = 0; |
|
254 } |
|
255 } |
|
256 |
|
257 CleanupStack::PopAndDestroy(tsyName); |
|
258 } |
|
259 |
|
260 // --------------------------------------------------------------------------- |
|
261 // Retrieves the IMEI or IMSI number. |
|
262 // @param aMobilePhone initialized RMobilePhone instance. |
|
263 // @param aProperty the name of the actual property |
|
264 // @return percentage of battery charge level |
|
265 // ----------------------------------------------------------------------------- |
|
266 HBufC* GetIdentityPropertyL(RMobilePhone& aMobilePhone, const TInt aProperty) |
|
267 { |
|
268 JELOG2(ESOCKET); |
|
269 |
|
270 TUint32 identityCaps = 0; |
|
271 HBufC* telephonyProperty = NULL; |
|
272 TRequestStatus status; |
|
273 |
|
274 LOG(ESOCKET, EInfo, "MOBINFO + GetIdentityPropertyL()"); |
|
275 LOG(ESOCKET, EInfo, "MOBINFO Checking phone identitycaps"); |
|
276 |
|
277 TInt identityStatus = aMobilePhone.GetIdentityCaps(identityCaps); |
|
278 LOG1(ESOCKET, EInfo, "MOBINFO Checking identity caps status=%D", identityStatus); |
|
279 |
|
280 if ((identityCaps & RMobilePhone::KCapsGetSubscriberId) |
|
281 && (aProperty == IMSI)) |
|
282 { |
|
283 LOG(ESOCKET, EInfo, "MOBINFO retrieving IMSI"); |
|
284 |
|
285 // initialise a variable to hold IMSI |
|
286 RMobilePhone::TMobilePhoneSubscriberId imsi; |
|
287 |
|
288 // put values into variable |
|
289 aMobilePhone.GetSubscriberId(status, imsi); |
|
290 User::WaitForRequest(status); |
|
291 User::LeaveIfError(status.Int()); |
|
292 LOG(ESOCKET, EInfo, "MOBINFO returning property IMSI"); |
|
293 telephonyProperty = imsi.AllocL(); |
|
294 } |
|
295 |
|
296 if ((identityCaps & RMobilePhone::KCapsGetSerialNumber) |
|
297 && (aProperty == IMEI)) |
|
298 { |
|
299 LOG(ESOCKET, EInfo, "MOBINFO retrieving IMEI"); |
|
300 |
|
301 RMobilePhone::TMobilePhoneIdentityV1 phoneId; |
|
302 aMobilePhone.GetPhoneId(status, phoneId); |
|
303 User::WaitForRequest(status); |
|
304 User::LeaveIfError(status.Int()); |
|
305 LOG(ESOCKET, EInfo, "MOBINFO returning property IMEI"); |
|
306 telephonyProperty = (phoneId.iSerialNumber).AllocL(); |
|
307 } |
|
308 |
|
309 return telephonyProperty; |
|
310 } |
|
311 |
|
312 // --------------------------------------------------------------------------- |
|
313 // Retrieves the battery charge level in percentage. |
|
314 // @param aMobilePhone initialized RMobilePhone instance. |
|
315 // @return percentage of battery charge level |
|
316 // ----------------------------------------------------------------------------- |
|
317 HBufC* GetBatteryPropertyL(RMobilePhone& aMobilePhone) |
|
318 { |
|
319 JELOG2(ESOCKET); |
|
320 |
|
321 HBufC* telephonyProperty = NULL; |
|
322 LOG(ESOCKET, EInfo, "MOBINFO + GetBatteryPropertyL()"); |
|
323 |
|
324 // Check BatteryCaps |
|
325 TUint32 batteryCaps; |
|
326 LOG(ESOCKET, EInfo, "MOBINFO Checking phone BatteryCaps"); |
|
327 |
|
328 TInt batteryCapsStatus = aMobilePhone.GetBatteryCaps(batteryCaps); |
|
329 LOG1(ESOCKET, EInfo, "MOBINFO Checking Battery caps status=%D", |
|
330 batteryCapsStatus); |
|
331 |
|
332 if (batteryCapsStatus == KErrNone) |
|
333 { |
|
334 TRequestStatus status; |
|
335 |
|
336 LOG(ESOCKET, EInfo, "MOBINFO retrieving battery charge level"); |
|
337 RMobilePhone::TMobilePhoneBatteryInfoV1 info; |
|
338 aMobilePhone.GetBatteryInfo(status, info); |
|
339 User::WaitForRequest(status); |
|
340 User::LeaveIfError(status.Int()); |
|
341 LOG(ESOCKET, EInfo, "MOBINFO returning property Battery charge level"); |
|
342 |
|
343 TBuf<KMaxPropertySize> buf; // percentage of battery charge level |
|
344 buf.Num(info.iChargeLevel); |
|
345 telephonyProperty = buf.AllocL(); |
|
346 } |
|
347 |
|
348 LOG(ESOCKET, EInfo, "MOBINFO - GetBatteryPropertyL()"); |
|
349 return telephonyProperty; |
|
350 } |
|
351 |
|
352 // --------------------------------------------------------------------------- |
|
353 // Retrieves the network related properties. |
|
354 // @param aMobilePhone initialized RMobilePhone instance. |
|
355 // @param aProperty name of the actual property |
|
356 // @return property value |
|
357 // ----------------------------------------------------------------------------- |
|
358 HBufC* GetNetworkPropertyL(RMobilePhone& aMobilePhone, const TInt aProperty) |
|
359 { |
|
360 JELOG2(ESOCKET); |
|
361 |
|
362 HBufC* telephonyProperty = NULL; |
|
363 LOG(ESOCKET, EInfo, "MOBINFO + GetNetworkPropertyL()"); |
|
364 |
|
365 if ((aProperty == NETWORK_ID) || (aProperty == COUNTRY_CODE) || (aProperty |
|
366 == CELLID)) |
|
367 { |
|
368 // Check NetworkCaps |
|
369 TUint32 networkCaps; |
|
370 LOG(ESOCKET, EInfo, "MOBINFO Checking phone NetworkCaps"); |
|
371 |
|
372 TInt networkCapsStatus = aMobilePhone.GetNetworkCaps(networkCaps); |
|
373 LOG1(ESOCKET, EInfo, "MOBINFO Checking network caps status=%D", |
|
374 networkCapsStatus); |
|
375 if (networkCapsStatus == KErrNone) |
|
376 { |
|
377 TRequestStatus status; |
|
378 |
|
379 if ((networkCaps & RMobilePhone::KCapsGetCurrentNetwork) |
|
380 && (aProperty == NETWORK_ID)) |
|
381 { |
|
382 LOG(ESOCKET, EInfo, "MOBINFO retrieving NetworkId"); |
|
383 |
|
384 RMobilePhone::TMobilePhoneOPlmnV3 locInfo; |
|
385 RMobilePhone::TMobilePhoneOPlmnV3Pckg pckgLocInfo(locInfo); |
|
386 |
|
387 RMobilePhone::TMobilePhoneNetworkNameV3 networkName; |
|
388 RMobilePhone::TMobilePhoneNetworkNameV3Pckg pckgNetworkName( |
|
389 networkName); |
|
390 aMobilePhone.GetCurrentNetworkName(status, pckgNetworkName, |
|
391 pckgLocInfo); |
|
392 User::WaitForRequest(status); |
|
393 User::LeaveIfError(status.Int()); |
|
394 LOG(ESOCKET, EInfo, "MOBINFO returning property NetworkId"); |
|
395 _LIT(KStringFormat, "%S (%S)"); |
|
396 |
|
397 // 8 is the max length of MNC, + 3 chars needed for the |
|
398 // formatting chars like space, "(" and ")" |
|
399 TBuf<KMaxPropertySize + RMobilePhone::KMaxNetworkNameFieldSize> |
|
400 disp; |
|
401 disp.Format(KStringFormat, &locInfo.iNetworkId, |
|
402 &networkName.iShortName); |
|
403 telephonyProperty = disp.AllocL(); |
|
404 } |
|
405 else if ((networkCaps & RMobilePhone::KCapsGetCurrentNetwork) |
|
406 && (aProperty == CELLID)) |
|
407 { |
|
408 LOG(ESOCKET, EInfo, "MOBINFO retrieving CellId"); |
|
409 |
|
410 RMobilePhone::TMobilePhoneNetworkInfoV1 networkInfo; |
|
411 RMobilePhone::TMobilePhoneNetworkInfoV1Pckg networkInfoPckg( |
|
412 networkInfo); |
|
413 RMobilePhone::TMobilePhoneLocationAreaV1 locationArea; |
|
414 aMobilePhone.GetCurrentNetwork(status, networkInfoPckg, |
|
415 locationArea); |
|
416 |
|
417 User::WaitForRequest(status); |
|
418 User::LeaveIfError(status.Int()); |
|
419 |
|
420 LOG(ESOCKET, EInfo, "MOBINFO returning property CellId"); |
|
421 |
|
422 TBuf<KMaxPropertySize> disp; |
|
423 disp.Num(locationArea.iCellId, EDecimal); |
|
424 telephonyProperty = disp.AllocL(); |
|
425 } |
|
426 else // COUNTRY_CODE |
|
427 { |
|
428 LOG(ESOCKET, EInfo, "MOBINFO retrieving CountryCode"); |
|
429 |
|
430 RMobilePhone::TMobilePhoneOPlmnV3 locInfo; |
|
431 RMobilePhone::TMobilePhoneOPlmnV3Pckg pckgLocInfo(locInfo); |
|
432 |
|
433 RMobilePhone::TMobilePhoneNetworkNameV3 networkName; |
|
434 RMobilePhone::TMobilePhoneNetworkNameV3Pckg pckgNetworkName( |
|
435 networkName); |
|
436 aMobilePhone.GetCurrentNetworkName(status, pckgNetworkName, |
|
437 pckgLocInfo); |
|
438 User::WaitForRequest(status); |
|
439 User::LeaveIfError(status.Int()); |
|
440 LOG(ESOCKET, EInfo, "MOBINFO returning property CountryCode"); |
|
441 telephonyProperty = (locInfo.iCountryCode).AllocL(); |
|
442 } |
|
443 } |
|
444 } |
|
445 else if (aProperty == NETWORK_SIGNAL) |
|
446 { |
|
447 // Check Signal related Caps |
|
448 TUint32 signalCaps; |
|
449 LOG(ESOCKET, EInfo, "MOBINFO Checking phone SignalCaps"); |
|
450 |
|
451 TInt signalCapsStatus = aMobilePhone.GetSignalCaps(signalCaps); |
|
452 LOG1(ESOCKET, EInfo, "MOBINFO Checking signal caps status=%D", |
|
453 signalCapsStatus); |
|
454 if (signalCapsStatus == KErrNone) |
|
455 { |
|
456 TRequestStatus status; |
|
457 |
|
458 if (signalCaps & RMobilePhone::KCapsGetSignalStrength) |
|
459 { |
|
460 LOG(ESOCKET, EInfo, "MOBINFO retrieving SignalStrength"); |
|
461 |
|
462 TInt32 signalStrength; |
|
463 TInt8 bar; |
|
464 aMobilePhone.GetSignalStrength(status, signalStrength, bar); |
|
465 User::WaitForRequest(status); |
|
466 User::LeaveIfError(status.Int()); |
|
467 LOG(ESOCKET, EInfo, |
|
468 "MOBINFO returning property SignalStrength"); |
|
469 _LIT(KStringFormat, "%d (%d dBm)"); |
|
470 |
|
471 TBuf<KMaxPropertySize> disp; |
|
472 disp.Format(KStringFormat, bar, signalStrength); |
|
473 telephonyProperty = disp.AllocL(); |
|
474 } |
|
475 } |
|
476 } |
|
477 else if (aProperty == NETWORKSTATUS) |
|
478 { |
|
479 // Check network status |
|
480 LOG(ESOCKET, EInfo, "MOBINFO Checking network status"); |
|
481 |
|
482 // Check NetworkCaps |
|
483 TUint32 networkCaps; |
|
484 TInt networkCapsStatus = aMobilePhone.GetNetworkCaps(networkCaps); |
|
485 LOG1(ESOCKET, EInfo, "MOBINFO Checking network caps status=%D", |
|
486 networkCapsStatus); |
|
487 if (networkCapsStatus == KErrNone) |
|
488 { |
|
489 TRequestStatus status; |
|
490 RMobilePhone::TMobilePhoneRegistrationStatus networkStatus; |
|
491 |
|
492 aMobilePhone.GetNetworkRegistrationStatus(status, networkStatus); |
|
493 User::WaitForRequest(status); |
|
494 User::LeaveIfError(status.Int()); |
|
495 |
|
496 switch (networkStatus) |
|
497 { |
|
498 case RMobilePhone::ERegisteredOnHomeNetwork: |
|
499 case RMobilePhone::ERegisteredBusy: |
|
500 telephonyProperty = KNetworkStatusHome().AllocL(); |
|
501 break; |
|
502 |
|
503 case RMobilePhone::ERegisteredRoaming: |
|
504 telephonyProperty = KNetworkStatusRoaming().AllocL(); |
|
505 break; |
|
506 |
|
507 default: |
|
508 telephonyProperty = KNetworkStatusUnknown().AllocL(); |
|
509 break; |
|
510 } |
|
511 } |
|
512 LOG(ESOCKET, EInfo, "MOBINFO returning property NetworkStatus"); |
|
513 } |
|
514 else // NETWORK_AVAILABILITY |
|
515 { |
|
516 // Check NetworkAvailability related Caps |
|
517 TUint32 indCaps; |
|
518 TUint32 actionCaps; |
|
519 LOG(ESOCKET, EInfo, "MOBINFO Checking phone IndicatorCaps"); |
|
520 |
|
521 TInt indicatorCapsStatus = aMobilePhone.GetIndicatorCaps(actionCaps, |
|
522 indCaps); |
|
523 LOG1(ESOCKET, EInfo, "MOBINFO Checking IndicatorCaps status=%D", |
|
524 indicatorCapsStatus); |
|
525 if (indicatorCapsStatus == KErrNone) |
|
526 { |
|
527 TRequestStatus status; |
|
528 |
|
529 if (indCaps & RMobilePhone::KCapsGetIndicator) |
|
530 { |
|
531 LOG(ESOCKET, EInfo, "MOBINFO retrieving Network Availability"); |
|
532 |
|
533 TUint32 indicator; |
|
534 aMobilePhone.GetIndicator(status, indicator); |
|
535 User::WaitForRequest(status); |
|
536 User::LeaveIfError(status.Int()); |
|
537 LOG(ESOCKET, EInfo, |
|
538 "MOBINFO returning property NetworkAvailability"); |
|
539 if (indicator & RMobilePhone::KIndNetworkAvailable) |
|
540 { |
|
541 telephonyProperty = HBufC::NewL(KMaxPropertySize); |
|
542 telephonyProperty->Des().Append(KNetworkAvailable); |
|
543 } |
|
544 else |
|
545 { |
|
546 telephonyProperty = HBufC::NewL(KMaxPropertySize); |
|
547 telephonyProperty->Des().Append(KNetworkUnavailable); |
|
548 } |
|
549 } |
|
550 } |
|
551 } |
|
552 |
|
553 LOG(ESOCKET, EInfo, "MOBINFO - GetNetworkPropertyL()"); |
|
554 return telephonyProperty; |
|
555 } |
|
556 |
|
557 // --------------------------------------------------------------------------- |
|
558 // Retrieves the date and time format related properties. |
|
559 // @param aProperty name of the actual property |
|
560 // @return error code |
|
561 // ----------------------------------------------------------------------------- |
|
562 HBufC* GetDateTimePropertyL(const TInt aProperty) |
|
563 { |
|
564 JELOG2(ESOCKET); |
|
565 |
|
566 HBufC* property = HBufC::NewMax(KMaxPropertySize); |
|
567 TLocale locale; |
|
568 TDateFormat dformat; |
|
569 TChar dseparator; |
|
570 TTimeFormat tformat; |
|
571 TChar separator; |
|
572 |
|
573 switch (aProperty) |
|
574 { |
|
575 case DATEFORMAT: |
|
576 dformat = locale.DateFormat(); |
|
577 dseparator = locale.DateSeparator(1); |
|
578 |
|
579 switch (dformat) |
|
580 { |
|
581 case EDateAmerican: |
|
582 property->Des().Copy(_L("MM")); |
|
583 property->Des().Append(dseparator); |
|
584 property->Des().Append(_L("dd")); |
|
585 property->Des().Append(dseparator); |
|
586 property->Des().Append(_L("yyyy")); |
|
587 break; |
|
588 |
|
589 case EDateEuropean: |
|
590 property->Des().Copy(_L("dd")); |
|
591 property->Des().Append(dseparator); |
|
592 property->Des().Append(_L("MM")); |
|
593 property->Des().Append(dseparator); |
|
594 property->Des().Append(_L("yyyy")); |
|
595 break; |
|
596 |
|
597 case EDateJapanese: |
|
598 property->Des().Copy(_L("yyyy")); |
|
599 property->Des().Append(dseparator); |
|
600 property->Des().Append(_L("MM")); |
|
601 property->Des().Append(dseparator); |
|
602 property->Des().Append(_L("dd")); |
|
603 break; |
|
604 } |
|
605 break; |
|
606 |
|
607 case TIMEFORMAT: |
|
608 tformat = locale.TimeFormat(); |
|
609 separator = locale.TimeSeparator(1); |
|
610 |
|
611 switch (tformat) |
|
612 { |
|
613 case ETime12: |
|
614 property->Des().Copy(_L("hh")); |
|
615 property->Des().Append(separator); |
|
616 property->Des().Append(_L("mm a")); |
|
617 break; |
|
618 |
|
619 case ETime24: |
|
620 property->Des().Copy(_L("HH")); |
|
621 property->Des().Append(separator); |
|
622 property->Des().Append(_L("mm")); |
|
623 break; |
|
624 } |
|
625 } |
|
626 return property; |
|
627 } |
|
628 |
|
629 // --------------------------------------------------------------------------- |
|
630 // Retrieves the network related properties. |
|
631 // @param aMobilePhone initialized RMobilePhone instance. |
|
632 // @param aTelServer initialized RTelServer instance. |
|
633 // @return property value |
|
634 // --------------------------------------------------------------------------- |
|
635 HBufC* GetMSISDNPropertyL(RMobilePhone& aMobilePhone, RTelServer& aTelServer) |
|
636 { |
|
637 JELOG2(ESOCKET); |
|
638 LOG(ESOCKET, EInfo, "MOBINFO + GetMSISDNPropertyL()"); |
|
639 |
|
640 HBufC* property = NULL; |
|
641 |
|
642 // get default TSY name |
|
643 HBufC* tsyName = HBufC16::NewLC(KCommsDbSvrMaxFieldLength); |
|
644 TPtr tsyPtr(tsyName->Des()); |
|
645 GetDefaultTSYL(tsyPtr); // used in GetDefaultPhone() |
|
646 |
|
647 LOG(ESOCKET, EInfo, "MOBINFO Retrieving info about for own number store"); |
|
648 |
|
649 TBool supported; |
|
650 User::LeaveIfError(aTelServer.IsSupportedByModule(tsyPtr, |
|
651 KETelFuncMobileOwnNumberStore, supported)); |
|
652 |
|
653 LOG1( |
|
654 ESOCKET, |
|
655 EInfo, |
|
656 "MOBINFO Checking own number store suppport by TSY, supported = %D: ", |
|
657 (TInt) supported); |
|
658 CleanupStack::PopAndDestroy(tsyName); |
|
659 |
|
660 if (supported) |
|
661 { |
|
662 RMobileONStore ownNumberStore; |
|
663 User::LeaveIfError(ownNumberStore.Open(aMobilePhone)); |
|
664 CleanupClosePushL(ownNumberStore); |
|
665 |
|
666 RMobileONStore::TMobileONStoreInfoV1 ownStoreInfo; |
|
667 RMobileONStore::TMobileONStoreInfoV1Pckg ownStoreInfoPckg(ownStoreInfo); |
|
668 |
|
669 TRequestStatus status; |
|
670 ownNumberStore.GetInfo(status, ownStoreInfoPckg); |
|
671 User::WaitForRequest(status); |
|
672 |
|
673 LOG1(ESOCKET, EInfo, |
|
674 "MOBINFO Checking getting own number store info status = %D ", |
|
675 status.Int()); |
|
676 User::LeaveIfError(status.Int()); |
|
677 |
|
678 TInt ownStoreInfoUsedEntries = ownStoreInfo.iUsedEntries; |
|
679 LOG1(ESOCKET, EInfo, |
|
680 "MOBINFO Entries stored in own number store: %D ", |
|
681 ownStoreInfoUsedEntries); |
|
682 |
|
683 if (ownStoreInfoUsedEntries >= 1) |
|
684 { |
|
685 // calculate length for property |
|
686 TInt size = ownStoreInfoUsedEntries |
|
687 * RMobileONStore::KOwnNumberTextSize; |
|
688 // take into account separators if more than one entry stored |
|
689 size = size + ((ownStoreInfoUsedEntries - 1) |
|
690 * KMSISDNSeparator().Length()); |
|
691 property = HBufC::NewL(size); |
|
692 |
|
693 for (TInt index = 1; index <= ownStoreInfoUsedEntries; index++) |
|
694 { |
|
695 LOG(ESOCKET, EInfo, "MOBINFO Retrieving property MSISDN "); |
|
696 RMobileONStore::TMobileONEntryV1 ownNumberEntry; |
|
697 ownNumberEntry.iIndex = index; // = index |
|
698 RMobileONStore::TMobileONEntryV1Pckg ownNumberEntryPckg( |
|
699 ownNumberEntry); |
|
700 |
|
701 status = KRequestPending; |
|
702 ownNumberStore.Read(status, ownNumberEntryPckg); |
|
703 User::WaitForRequest(status); |
|
704 |
|
705 LOG1(ESOCKET, EInfo, |
|
706 "MOBINFO Checking reading entry status = ", |
|
707 status.Int()); |
|
708 User::LeaveIfError(status.Int()); |
|
709 |
|
710 LOG(ESOCKET, EInfo, "MOBINFO Returning property MSISDN"); |
|
711 |
|
712 property->Des().Append(ownNumberEntry.iNumber.iTelNumber); |
|
713 |
|
714 if (index < ownStoreInfoUsedEntries) |
|
715 { |
|
716 property->Des().Append(KMSISDNSeparator); |
|
717 } |
|
718 } |
|
719 } |
|
720 CleanupStack::PopAndDestroy(&ownNumberStore); |
|
721 } |
|
722 |
|
723 LOG(ESOCKET, EInfo, "MOBINFO - GetMSISDNPropertyL()"); |
|
724 return property; |
|
725 } |
|
726 |
|
727 // --------------------------------------------------------------------------- |
|
728 // The funtion used for "Telephony related" properties which are requires an |
|
729 // initialized RTel server and RMobilePhone. |
|
730 // @param aProperty name of the actual property |
|
731 // @return property value |
|
732 // ----------------------------------------------------------------------------- |
|
733 HBufC* GetTelephonyPropertyL(const TInt aProperty) |
|
734 { |
|
735 JELOG2(ESOCKET); |
|
736 LOG(ESOCKET, EInfo, "MOBINFO + GetTelephonyPropertyL"); |
|
737 |
|
738 // Construct a connection to the RTel server |
|
739 RTelServer telServer; |
|
740 User::LeaveIfError(telServer.Connect()); |
|
741 LOG(ESOCKET, EInfo, |
|
742 "MOBINFO GetTelephonyPropertyL: connected to the RTel server"); |
|
743 CleanupClosePushL(telServer); |
|
744 |
|
745 RMobilePhone mobilePhone; |
|
746 CleanupClosePushL(mobilePhone); |
|
747 GetDefaultPhoneL(mobilePhone, telServer); |
|
748 LOG(ESOCKET, EInfo, |
|
749 "MOBINFO GetTelephonyPropertyL: after get default phoneconnected to the RTel server"); |
|
750 |
|
751 HBufC* telephonyProperty = NULL; |
|
752 |
|
753 switch (aProperty) |
|
754 { |
|
755 case IMSI: |
|
756 case IMEI: |
|
757 telephonyProperty = GetIdentityPropertyL(mobilePhone, aProperty); |
|
758 break; |
|
759 |
|
760 case MSISDN: |
|
761 telephonyProperty = GetMSISDNPropertyL(mobilePhone, telServer); |
|
762 break; |
|
763 |
|
764 case BATTERY_LEVEL: |
|
765 telephonyProperty = GetBatteryPropertyL(mobilePhone); |
|
766 break; |
|
767 |
|
768 case NETWORK_ID: |
|
769 case NETWORK_SIGNAL: |
|
770 case NETWORK_AVAILABILITY: |
|
771 case COUNTRY_CODE: |
|
772 case CELLID: |
|
773 case NETWORKSTATUS: |
|
774 telephonyProperty = GetNetworkPropertyL(mobilePhone, aProperty); |
|
775 break; |
|
776 } |
|
777 |
|
778 CleanupStack::PopAndDestroy(&mobilePhone); |
|
779 CleanupStack::PopAndDestroy(&telServer); |
|
780 LOG(ESOCKET, EInfo, "MOBINFO - GetTelephonyPropertyL()"); |
|
781 return telephonyProperty; |
|
782 } |
|
783 |
|
784 // --------------------------------------------------------------------------- |
|
785 // Get type network access of currently used active connection |
|
786 // @return network access, ownership hand over |
|
787 // --------------------------------------------------------------------------- |
|
788 HBufC* GetNetworkAccessL(TUint32 aAppDefaultApn) |
|
789 { |
|
790 LOG(ESOCKET, EInfo, "MOBINFO + GetNetworkAccessL"); |
|
791 HBufC* bearerType = NULL; |
|
792 TUint32 iapId = GetUsedIapL(); |
|
793 if (iapId == 0) |
|
794 { |
|
795 bearerType = GetDefIapBearerTypeL(aAppDefaultApn); |
|
796 } |
|
797 else |
|
798 { |
|
799 bearerType = GetBearerTypeL(iapId); |
|
800 } |
|
801 LOG(ESOCKET, EInfo, "MOBINFO - GetNetworkAccessL"); |
|
802 return bearerType; |
|
803 } |
|
804 |
|
805 //// --------------------------------------------------------------------------- |
|
806 //// Get currently used Access point ID |
|
807 //// @return currently used Acess point ID |
|
808 //// --------------------------------------------------------------------------- |
|
809 TUint32 GetUsedIapL() |
|
810 { |
|
811 LOG(ESOCKET, EInfo, "MOBINFO + GetUsedIapL()"); |
|
812 |
|
813 RSocketServ socketServer; |
|
814 RConnection connection; |
|
815 TConnEnumArgBuf enumArgBuf; |
|
816 TConnGetClientInfoArgBuf clientInfoBuf; |
|
817 TUint connectionCount(0); |
|
818 TConnectionInfoBuf connInfoBuf; |
|
819 TUint32 iapId(0); |
|
820 |
|
821 // Get MIDlet process ID |
|
822 RProcess process; |
|
823 RThread thread; |
|
824 TProcessId currProcessId(process.Id()); |
|
825 TThreadId currThreadId(thread.Id()); |
|
826 //LOG1( ESOCKET, EInfo, "MOBINFO Current process ID: %D", currProcessId ); |
|
827 //LOG1( ESOCKET, EInfo, "MOBINFO Current thread ID: %D", currThreadId ); |
|
828 |
|
829 // Connect to socket server and use system global pool (-1) |
|
830 // for message slots. |
|
831 LOG(ESOCKET, EInfo, "MOBINFO Connecting to socket server"); |
|
832 User::LeaveIfError(socketServer.Connect(static_cast< TUint >(-1))); |
|
833 CleanupClosePushL(socketServer); |
|
834 LOG(ESOCKET, EInfo, "MOBINFO Connected to socket server"); |
|
835 |
|
836 // Open RConnection, |
|
837 // this object is not attached to any connection |
|
838 LOG(ESOCKET, EInfo, "MOBINFO Opening connection"); |
|
839 User::LeaveIfError(connection.Open(socketServer)); |
|
840 CleanupClosePushL(connection); |
|
841 LOG(ESOCKET, EInfo, "MOBINFO Connection opened"); |
|
842 |
|
843 // Get count of current active connections. |
|
844 LOG(ESOCKET, EInfo, "MOBINFO Getting count of current active connections"); |
|
845 User::LeaveIfError(connection.EnumerateConnections(connectionCount)); |
|
846 LOG1(ESOCKET, EInfo, "MOBINFO Count of active connections %D", connectionCount); |
|
847 |
|
848 // Go through all active connections |
|
849 for (TUint connIdx = 1; connIdx <= connectionCount && iapId == 0; connIdx++) |
|
850 { |
|
851 enumArgBuf().iIndex = connIdx; |
|
852 |
|
853 // Get the number of clients |
|
854 LOG1(ESOCKET, EInfo, "MOBINFO Getting number of clients for active connection %D.", connIdx); |
|
855 User::LeaveIfError(connection.Control |
|
856 ( |
|
857 KCOLConnection, |
|
858 KCoEnumerateConnectionClients, |
|
859 enumArgBuf |
|
860 ) |
|
861 ); |
|
862 LOG1(ESOCKET, EInfo, "MOBINFO Number of clients: %D", enumArgBuf().iCount); |
|
863 |
|
864 // Go through all clients |
|
865 for (TUint clientIdx = 1; |
|
866 clientIdx <= enumArgBuf().iCount && iapId == 0; clientIdx++) |
|
867 { |
|
868 clientInfoBuf().iIndex = clientIdx; |
|
869 LOG1(ESOCKET, EInfo, "MOBINFO Retreiving client %D. info", clientIdx); |
|
870 User::LeaveIfError(connection.Control |
|
871 ( |
|
872 KCOLConnection, |
|
873 KCoGetConnectionClientInfo, |
|
874 clientInfoBuf |
|
875 ) |
|
876 ); |
|
877 LOG(ESOCKET, EInfo, "MOBINFO Client info retreived: "); |
|
878 |
|
879 TUid uid(clientInfoBuf().iClientInfo.iUid); |
|
880 TProcessId processId(clientInfoBuf().iClientInfo.iProcessId); |
|
881 TThreadId threadId(clientInfoBuf().iClientInfo.iThreadId); |
|
882 LOG1(ESOCKET, EInfo, "MOBINFO Client UID: %D", uid.iUid); |
|
883 //LOG1( ESOCKET, EInfo, "MOBINFO Client process ID: %D", processId ); |
|
884 //LOG1( ESOCKET, EInfo, "MOBINFO Client thread ID: %D", threadId ); |
|
885 |
|
886 // MIDlet's active connection found |
|
887 if (uid.iUid == KJVMProcessUid && currProcessId == processId) |
|
888 { |
|
889 LOG(ESOCKET, EInfo, "MOBINFO Active connection of current MIDlet found"); |
|
890 TConnectionInfoBuf connInfoBuf; |
|
891 |
|
892 LOG1(ESOCKET, EInfo, "MOBINFO Getting connection info %D", clientIdx); |
|
893 User::LeaveIfError( |
|
894 connection.GetConnectionInfo(connIdx, connInfoBuf) |
|
895 ); |
|
896 LOG(ESOCKET, EInfo, "MOBINFO Connection info gotten"); |
|
897 iapId = connInfoBuf().iIapId; |
|
898 LOG1(ESOCKET, EInfo, "MOBINFO currently used IAP ID found: %D", iapId); |
|
899 } |
|
900 } |
|
901 } |
|
902 |
|
903 LOG1(ESOCKET, EInfo, "MOBINFO currently used IAP ID: %D", iapId); |
|
904 CleanupStack::PopAndDestroy(&connection); |
|
905 CleanupStack::PopAndDestroy(&socketServer); |
|
906 LOG(ESOCKET, EInfo, "MOBINFO - GetUsedIapL()"); |
|
907 return iapId; |
|
908 } |
|
909 |
|
910 // --------------------------------------------------------------------------- |
|
911 // Get IAP's bearer type |
|
912 // @param aIapId IAP ID |
|
913 // @return bearer type, ownership handed over |
|
914 // "LAN" Local area network |
|
915 // 'pd.GSM" Packet data in GSM network |
|
916 // "pd.EDGE" Packet data in EDGE network |
|
917 // "pd.3G" Packet data in 3G network |
|
918 // "csd" Circuit switched data, for example GSM CSD/HSCSD data call |
|
919 // "bt_pan" Bluetooth PAN network |
|
920 // "wlan" Wireless network, for example 802.11b, 802.11G or WiMaX |
|
921 // "hspda" High speed downlink packet access for 3G networks |
|
922 // "na" Not applicable, the implementation can’t determine the type |
|
923 // --------------------------------------------------------------------------- |
|
924 HBufC* GetBearerTypeL(TUint32 aIapId) |
|
925 { |
|
926 LOG(ESOCKET, EInfo, "MOBINFO + GetBearerTypeL()"); |
|
927 RConnectionMonitor monitor; |
|
928 TUint connectionCount(0); |
|
929 TUint iapId(0); |
|
930 TRequestStatus status(KErrNone); |
|
931 HBufC* bearerType(NULL); |
|
932 TUint connectionId(0); |
|
933 TUint subConnectionCount(0); |
|
934 TConnMonBearerInfo bearerInfo(EBearerInfoUnknown); |
|
935 |
|
936 LOG(ESOCKET, EInfo, "MOBINFO Connecting to Connection Monitor"); |
|
937 User::LeaveIfError(monitor.ConnectL()); |
|
938 CleanupClosePushL(monitor); |
|
939 LOG(ESOCKET, EInfo, "MOBINFO Connected to Connection Monitor"); |
|
940 |
|
941 LOG(ESOCKET, EInfo, "MOBINFO Getting count of active connections"); |
|
942 status = KRequestPending; |
|
943 monitor.GetConnectionCount(connectionCount, status); |
|
944 User::WaitForRequest(status); |
|
945 User::LeaveIfError(status.Int()); |
|
946 LOG1(ESOCKET, EInfo, "MOBINFO Count of active connections: %D", connectionCount); |
|
947 |
|
948 // Go through all connections |
|
949 for (TUint connIdx = 1; connIdx <= connectionCount && iapId == 0; |
|
950 ++connIdx) |
|
951 { |
|
952 connectionId = 0; |
|
953 subConnectionCount = 0; |
|
954 |
|
955 // Get connection ID |
|
956 LOG1(ESOCKET, EInfo, "MOBINFO Getting connection info %D", connIdx); |
|
957 monitor.GetConnectionInfo(connIdx, connectionId, subConnectionCount); |
|
958 User::LeaveIfError(connectionId); |
|
959 LOG(ESOCKET, EInfo, "MOBINFO Connection info gotten"); |
|
960 |
|
961 // Get connection IAP ID |
|
962 LOG1(ESOCKET, EInfo, "MOBINFO Getting connection %D IAP ID", connIdx); |
|
963 status = KRequestPending; |
|
964 monitor.GetUintAttribute(connectionId, 0, KIAPId, iapId, status); |
|
965 User::WaitForRequest(status); |
|
966 User::LeaveIfError(status.Int()); |
|
967 LOG1(ESOCKET, EInfo, "MOBINFO Connection 's IAP ID found: %D", iapId); |
|
968 |
|
969 if (iapId == aIapId) |
|
970 { |
|
971 // MIDlet's IAP found |
|
972 LOG(ESOCKET, EInfo, "MOBINFO Midlet's IAP found"); |
|
973 |
|
974 // Get bearer type |
|
975 LOG(ESOCKET, EInfo, "MOBINFO Getting bearer type"); |
|
976 status = KRequestPending; |
|
977 monitor.GetIntAttribute(connectionId, |
|
978 0, |
|
979 KBearerInfo, |
|
980 (TInt&)bearerInfo, |
|
981 status); |
|
982 User::WaitForRequest(status); |
|
983 User::LeaveIfError(status.Int()); |
|
984 LOG1(ESOCKET, EInfo, "MOBINFO Bearer type found: %D", bearerInfo); |
|
985 } |
|
986 } |
|
987 |
|
988 // Translate bearer type to type of network access |
|
989 bearerType = TranslateBearerInfoToNetworkAccessL(bearerInfo); |
|
990 |
|
991 CleanupStack::PopAndDestroy(&monitor); |
|
992 LOG(ESOCKET, EInfo, "MOBINFO - GetBearerTypeL()"); |
|
993 return bearerType; |
|
994 } |
|
995 |
|
996 // --------------------------------------------------------------------------- |
|
997 // Translate bearer info to type of network access |
|
998 // @param aBearerInfo bearer info |
|
999 // @return type of network access, ownership hand over |
|
1000 HBufC* TranslateBearerInfoToNetworkAccessL(TConnMonBearerInfo aBearerInfo) |
|
1001 { |
|
1002 LOG(ESOCKET, EInfo, "MOBINFO + TranslateBearerInfoToNetworkAccessL()"); |
|
1003 HBufC* bearerType(NULL); |
|
1004 switch (aBearerInfo) |
|
1005 { |
|
1006 case EBearerInfoLAN: |
|
1007 bearerType = KNetworkAccessPdLAN().AllocL(); |
|
1008 break; |
|
1009 case EBearerInfoGPRS: |
|
1010 bearerType = KNetworkAccessPdGSM().AllocL(); |
|
1011 break; |
|
1012 case EBearerInfoEdgeGPRS: |
|
1013 bearerType = KNetworkAccessPdEDGE().AllocL(); |
|
1014 break; |
|
1015 case EBearerInfoWCDMA: |
|
1016 bearerType = KNetworkAccessPd3G().AllocL(); |
|
1017 break; |
|
1018 case EBearerInfoCSD: |
|
1019 case EBearerInfoHSCSD: |
|
1020 case EBearerInfoWcdmaCSD: |
|
1021 bearerType = KNetworkAccessCSD().AllocL(); |
|
1022 break; |
|
1023 case EBearerInfoBluetooth: |
|
1024 bearerType = KNetworkAccessBtPan().AllocL(); |
|
1025 break; |
|
1026 case EBearerInfoWLAN: |
|
1027 bearerType = KNetworkAccessWLAN().AllocL(); |
|
1028 break; |
|
1029 case EBearerInfoHSDPA: |
|
1030 case EBearerInfoHSUPA: |
|
1031 case EBearerInfoHSxPA: |
|
1032 bearerType = KNetworkAccessHSPDA().AllocL(); |
|
1033 break; |
|
1034 case EBearerInfoUnknown: |
|
1035 case EBearerInfoCDMA2000: |
|
1036 case EBearerInfoVirtual: |
|
1037 case EBearerInfoVirtualVPN: |
|
1038 default: |
|
1039 bearerType = KNetworkAccessNa().AllocL(); |
|
1040 break; |
|
1041 } |
|
1042 LOG(ESOCKET, EInfo, "MOBINFO - TranslateBearerInfoToNetworkAccessL()"); |
|
1043 return bearerType; |
|
1044 } |
|
1045 |
|
1046 |
|
1047 |
|
1048 // -------------------------------------------------------------------- |
|
1049 // Get network access type of default access point set in MIDlet settings |
|
1050 // @param aAppDefaultApn MIDlet suite ID |
|
1051 // @return network access type, ownership hand over |
|
1052 HBufC* GetDefIapBearerTypeL(TUint32 aAppDefaultApn) |
|
1053 { |
|
1054 LOG(ESOCKET, EInfo, "MOBINFO + GetDefIapBearerTypeL"); |
|
1055 ELOG1(ESOCKET, "GetDefIapBearerTypeL %d", aAppDefaultApn); |
|
1056 HBufC* bearerType(NULL); |
|
1057 // MAPNSettings* apnTable = GetAPNSettingsLC(KAPNSettingsVersion); |
|
1058 //TUint32 apn = apnTable->GetAPNIdL( aMidSuiteId ); |
|
1059 //CleanupStack::PopAndDestroy(); //apnTable |
|
1060 LOG1(ESOCKET, EInfo, "MIDlet specific IAP ID gotten: %D", aAppDefaultApn); |
|
1061 if (aAppDefaultApn == 0 || aAppDefaultApn == (TUint32)-1) |
|
1062 { |
|
1063 bearerType = KNetworkAccessNa().AllocL(); |
|
1064 } |
|
1065 else |
|
1066 { |
|
1067 RCmManager localCmManager; |
|
1068 localCmManager.OpenL(); |
|
1069 TUint32 tmpval = localCmManager.GetConnectionMethodInfoIntL(aAppDefaultApn,ECmBearerType); |
|
1070 ELOG1(ESOCKET, "GetConnectionMethodInfoIntL: %d", tmpval); |
|
1071 switch (tmpval) |
|
1072 { |
|
1073 case KUidHSCSDBearerType: |
|
1074 bearerType = KNetworkAccessCSD().AllocL(); |
|
1075 break; |
|
1076 case KUidPacketDataBearerType: |
|
1077 bearerType = KNetworkAccessPdGSM().AllocL(); |
|
1078 break; |
|
1079 case KUidWlanBearerType : |
|
1080 bearerType = KNetworkAccessWLAN().AllocL(); |
|
1081 break; |
|
1082 |
|
1083 /* Bearer type LAN,LANModem currently not supported by cmmanager */ |
|
1084 default : |
|
1085 bearerType = KNetworkAccessNa().AllocL(); |
|
1086 break; |
|
1087 |
|
1088 |
|
1089 } |
|
1090 |
|
1091 } |
|
1092 LOG(ESOCKET, EInfo, "MOBINFO - GetDefIapBearerTypeL"); |
|
1093 return bearerType; |
|
1094 } |