|
1 /* |
|
2 * Copyright (c) 2005-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: Implementation for bearer GPRS. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "ConnMonBearerGPRS.h" |
|
19 #include "connmoncommsdatcache.h" |
|
20 #include "ConnMonIAP.h" |
|
21 #include "log.h" |
|
22 |
|
23 // --------------------------------------------------------------------------- |
|
24 // Construction |
|
25 // --------------------------------------------------------------------------- |
|
26 // |
|
27 TConnMonBearerGPRS::TConnMonBearerGPRS( |
|
28 CConnMonIAP* aConnMonIAP, |
|
29 CConnMonCommsDatCache* aCommsDatCache ) |
|
30 : |
|
31 TConnMonBearer( aConnMonIAP, aCommsDatCache ) |
|
32 { |
|
33 } |
|
34 |
|
35 // --------------------------------------------------------------------------- |
|
36 // Is bearer available |
|
37 // --------------------------------------------------------------------------- |
|
38 // |
|
39 TInt TConnMonBearerGPRS::GetAvailability( TBool& aAvailable ) const |
|
40 { |
|
41 //LOGENTRFN("TConnMonBearerGPRS::GetAvailability()") |
|
42 TInt err( KErrNone ); |
|
43 aAvailable = EFalse; |
|
44 |
|
45 // Is bearer available |
|
46 TBool byCell( EFalse ); |
|
47 TBool byPhone( EFalse ); |
|
48 |
|
49 // Find out if we are in 2G or in 3G - it is needed for calculating bearer availability |
|
50 RMobilePhone::TMobilePhoneNetworkMode mode; |
|
51 err = iConnMonIAP->MobilePhone()->GetCurrentMode( mode ); |
|
52 |
|
53 if ( KErrNone == err ) |
|
54 { |
|
55 switch ( mode ) |
|
56 { |
|
57 case RMobilePhone::ENetworkModeGsm: |
|
58 case RMobilePhone::ENetworkModeUnknown: // Emulator default |
|
59 err = iConnMonIAP->GetBearerSupportInfo( EBearerIdGPRS, byCell, byPhone ); |
|
60 break; |
|
61 case RMobilePhone::ENetworkModeWcdma: |
|
62 err = iConnMonIAP->GetBearerSupportInfo( EBearerIdWCDMA, byCell, byPhone ); |
|
63 break; |
|
64 default: |
|
65 LOGEXITFN1("TConnMonBearerGPRS::GetAvailability()", err) |
|
66 return err; // Return silently, report not available |
|
67 } |
|
68 |
|
69 if ( KErrNone == err ) |
|
70 { |
|
71 if ( byCell && byPhone ) |
|
72 { |
|
73 aAvailable = ETrue; |
|
74 } |
|
75 } |
|
76 } |
|
77 |
|
78 // Make GPRS available in wins |
|
79 #if defined(__WINSCW__) |
|
80 LOGIT2("GetAvailability: Emulator override, true values were %d <%d>", aAvailable, err) |
|
81 err = KErrNone; |
|
82 aAvailable = ETrue; |
|
83 #endif |
|
84 |
|
85 //LOGEXITFN1("TConnMonBearerGPRS::GetAvailability()", err) |
|
86 return err; |
|
87 } |
|
88 |
|
89 // --------------------------------------------------------------------------- |
|
90 // Bearer ID getter |
|
91 // --------------------------------------------------------------------------- |
|
92 // |
|
93 TUint TConnMonBearerGPRS::BearerId() const |
|
94 { |
|
95 return EBearerIdGPRS; |
|
96 } |
|
97 |
|
98 // --------------------------------------------------------------------------- |
|
99 // ETrue if bearer is valid (internal state is correct) |
|
100 // --------------------------------------------------------------------------- |
|
101 // |
|
102 TBool TConnMonBearerGPRS::Valid() const |
|
103 { |
|
104 return ETrue; |
|
105 } |
|
106 |
|
107 // --------------------------------------------------------------------------- |
|
108 // Sets available IAPs of this type as available in CommsDat cache |
|
109 // --------------------------------------------------------------------------- |
|
110 // |
|
111 void TConnMonBearerGPRS::FlagAvailableIaps() const |
|
112 { |
|
113 LOGENTRFN("TConnMonBearerGPRS::FlagAvailableIaps()") |
|
114 |
|
115 TBool bearerAvailable( EFalse ); |
|
116 TInt err = GetAvailability( bearerAvailable ); |
|
117 LOGIT2("FlagAvailableIaps: GPRS availability: %d (bool) <%d>", bearerAvailable, err) |
|
118 if ( !err && bearerAvailable ) |
|
119 { |
|
120 iCommsDatCache->SetAvailableIapsWithBearerId( EBearerIdGPRS ); |
|
121 } |
|
122 |
|
123 LOGEXITFN("TConnMonBearerGPRS::FlagAvailableIaps()") |
|
124 } |
|
125 |
|
126 // End-of-file |