|
1 /* |
|
2 * Copyright (c) 2006-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 CSD. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "ConnMonBearerCSD.h" |
|
19 #include "connmoncommsdatcache.h" |
|
20 #include "ConnMonIAP.h" |
|
21 #include "log.h" |
|
22 |
|
23 // --------------------------------------------------------------------------- |
|
24 // Construction |
|
25 // --------------------------------------------------------------------------- |
|
26 // |
|
27 TConnMonBearerCSD::TConnMonBearerCSD( |
|
28 CConnMonIAP* aConnMonIAP, |
|
29 CConnMonCommsDatCache* aCommsDatCache ) |
|
30 : |
|
31 TConnMonBearer( aConnMonIAP, aCommsDatCache ) |
|
32 { |
|
33 } |
|
34 |
|
35 // --------------------------------------------------------------------------- |
|
36 // Is bearer available |
|
37 // --------------------------------------------------------------------------- |
|
38 // |
|
39 TInt TConnMonBearerCSD::GetAvailability( TBool& aAvailable ) const |
|
40 { |
|
41 //LOGENTRFN("TConnMonBearerCSD::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( EBearerIdCSD, byCell, byPhone ); |
|
60 break; |
|
61 case RMobilePhone::ENetworkModeWcdma: |
|
62 err = iConnMonIAP->GetBearerSupportInfo( EBearerIdWcdmaCSD, byCell, byPhone ); |
|
63 break; |
|
64 default: |
|
65 LOGEXITFN1("TConnMonBearerCSD::GetAvailability()", err) |
|
66 return err; // Return silently (KErrNone), report as not available |
|
67 } |
|
68 |
|
69 if ( KErrNone == err ) |
|
70 { |
|
71 if ( byCell && byPhone ) |
|
72 { |
|
73 aAvailable = ETrue; |
|
74 } |
|
75 } |
|
76 } |
|
77 |
|
78 // Make CSD available in wins |
|
79 #if defined(__WINSCW__) |
|
80 LOGIT2("GetAvailability: Emulator override, true values were %d <%d>", aAvailable, err) |
|
81 aAvailable = ETrue; |
|
82 err = KErrNone; |
|
83 #endif |
|
84 |
|
85 //LOGEXITFN1("TConnMonBearerCSD::GetAvailability()", err) |
|
86 return err; |
|
87 } |
|
88 |
|
89 // --------------------------------------------------------------------------- |
|
90 // Bearer ID getter |
|
91 // --------------------------------------------------------------------------- |
|
92 // |
|
93 TUint TConnMonBearerCSD::BearerId() const |
|
94 { |
|
95 return EBearerIdCSD; |
|
96 } |
|
97 |
|
98 // --------------------------------------------------------------------------- |
|
99 // ETrue if bearer is valid (internal state is correct) |
|
100 // --------------------------------------------------------------------------- |
|
101 // |
|
102 TBool TConnMonBearerCSD::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 TConnMonBearerCSD::FlagAvailableIaps() const |
|
112 { |
|
113 LOGENTRFN("TConnMonBearerCSD::FlagAvailableIaps()") |
|
114 |
|
115 RArray<TUint> idArray; |
|
116 iConnMonIAP->GetActiveConnectionsIds( EBearerIdCSD, idArray ); |
|
117 |
|
118 if ( idArray.Count() > 0 ) |
|
119 { |
|
120 LOGIT1("Found %d active CSD IAPs", idArray.Count()) |
|
121 for ( TInt i = 0; i < idArray.Count(); i++ ) |
|
122 { |
|
123 iCommsDatCache->SetAvailableIapWithId( idArray[i] ); |
|
124 } |
|
125 } |
|
126 else |
|
127 { |
|
128 TBool available( EFalse ); |
|
129 TInt err = GetAvailability( available ); |
|
130 LOGIT2("FlagAvailableIaps: CSD availability: %d (bool) <%d>", available, err) |
|
131 if ( KErrNone == err && available ) |
|
132 { |
|
133 iCommsDatCache->SetAvailableIapsWithBearerId( EBearerIdCSD ); |
|
134 } |
|
135 } |
|
136 idArray.Close(); |
|
137 |
|
138 LOGEXITFN("TConnMonBearerCSD::FlagAvailableIaps()") |
|
139 } |
|
140 |
|
141 // End-of-file |