|
1 /* |
|
2 * Copyright (c) 2002-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: Maps extended error values to correct values. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "TSatExtErrorUtils.h" |
|
20 #include <exterror.h> |
|
21 #include "SatLog.h" |
|
22 |
|
23 // In some cases return value needs to be zeroed |
|
24 const TUint8 KSatZeroError( 0x00 ); |
|
25 const TUint8 KHighBitInByte( 0x80 ); |
|
26 |
|
27 // ----------------------------------------------------------------------------- |
|
28 // TSatExtErrorUtils::MapError |
|
29 // (other items were commented in a header). |
|
30 // ----------------------------------------------------------------------------- |
|
31 // |
|
32 EXPORT_C TUint8 TSatExtErrorUtils::MapError( |
|
33 TInt aExtError, |
|
34 TBool aModifyMappedValue ) |
|
35 { |
|
36 LOG2( SIMPLE, "SATENGINE: TSatExtErrorUtils::MapError calling value: %i", |
|
37 aExtError ) |
|
38 |
|
39 TUint8 retValue( 0 ); |
|
40 TUint8 nwValue( 0 ); |
|
41 TInt baseError( 0 ); |
|
42 |
|
43 if ( IsExtendedError( aExtError ) ) |
|
44 { |
|
45 // Define the base error value |
|
46 if ( KErrGsmMobilityManagementBase < aExtError ) |
|
47 { |
|
48 LOG( NORMAL, "SATENGINE: TSatExtErrorUtils::MapError Base error" ) |
|
49 baseError = KErrEtelGsmBase; // Base error |
|
50 } |
|
51 else if ( KErrGsmCallControlBase < aExtError ) |
|
52 { |
|
53 LOG( NORMAL, "SATENGINE: TSatExtErrorUtils::MapError MM error" ) |
|
54 baseError = KErrGsmMobilityManagementBase; // MM error |
|
55 } |
|
56 else if ( KErrGsmSuppServiceBase < aExtError ) |
|
57 { |
|
58 LOG( NORMAL, "SATENGINE: TSatExtErrorUtils::MapError CallControl \ |
|
59 error" ) |
|
60 baseError = KErrGsmCallControlBase; // CallControl error |
|
61 } |
|
62 else if ( KErrGsmSmsBase < aExtError ) |
|
63 { |
|
64 LOG( NORMAL, "SATENGINE: TSatExtErrorUtils::MapError SS error" ) |
|
65 baseError = KErrGsmSuppServiceBase; // Ss error |
|
66 } |
|
67 else if ( KErrGsm0707Base < aExtError ) |
|
68 { |
|
69 LOG( NORMAL, "SATENGINE: TSatExtErrorUtils::MapError Sms error" ) |
|
70 baseError = KErrGsmSmsBase; // Sms error |
|
71 } |
|
72 else |
|
73 { |
|
74 LOG( NORMAL, "SATENGINE: TSatExtErrorUtils::MapError TE-TA error" ) |
|
75 baseError = KErrGsm0707Base; // TE-TA error |
|
76 } |
|
77 // Base error resolved, calculate error value |
|
78 nwValue = static_cast<TUint8>( baseError - aExtError ); |
|
79 } |
|
80 else |
|
81 { |
|
82 LOG( NORMAL, " Value not extended error, not mapped" ) |
|
83 } |
|
84 |
|
85 // Next, check specific cases |
|
86 CheckSpecificCases( aExtError, nwValue ); |
|
87 |
|
88 // Check do we have to modify the value |
|
89 if ( aModifyMappedValue && nwValue > KSatZeroError ) |
|
90 { |
|
91 LOG( NORMAL, "SATENGINE: TSatExtErrorUtils::MapError Modifying value" ) |
|
92 retValue = static_cast<TUint8>( KHighBitInByte | nwValue ); |
|
93 } |
|
94 else |
|
95 { |
|
96 retValue = nwValue; |
|
97 } |
|
98 |
|
99 LOG2( SIMPLE, "SATENGINE: TSatExtErrorUtils::MapError exiting value:%x", |
|
100 retValue ) |
|
101 |
|
102 return retValue; |
|
103 } |
|
104 |
|
105 // ----------------------------------------------------------------------------- |
|
106 // TSatExtErrorUtils::IsExtendedError |
|
107 // (other items were commented in a header). |
|
108 // ----------------------------------------------------------------------------- |
|
109 // |
|
110 EXPORT_C TBool TSatExtErrorUtils::IsExtendedError( TInt aExtError ) |
|
111 { |
|
112 LOG( SIMPLE, |
|
113 "SATENGINE: TSatExtErrorUtils::IsExtendedError calling-exiting" ) |
|
114 const TBool isExtError( |
|
115 ( KErrEtelGsmBase >= aExtError ) && |
|
116 ( KErrGsm0707UnknownError <= aExtError ) ); |
|
117 |
|
118 return isExtError; |
|
119 } |
|
120 |
|
121 // ----------------------------------------------------------------------------- |
|
122 // TSatExtErrorUtils::IsNetworkError |
|
123 // (other items were commented in a header). |
|
124 // ----------------------------------------------------------------------------- |
|
125 // |
|
126 EXPORT_C TBool TSatExtErrorUtils::IsNetworkError( TInt aExtError ) |
|
127 { |
|
128 LOG2( SIMPLE, "SATENGINE: TSatExtErrorUtils::IsNetworkError calling, \ |
|
129 aExtError: %d", aExtError ) |
|
130 TBool isNwError( ETrue ); |
|
131 |
|
132 switch ( aExtError ) |
|
133 { |
|
134 // Add errors here that are not supposed to handle as NW errors |
|
135 case KErrGsmSMSTemporaryFailure: |
|
136 case KErrGsmSSUnknownAlphabet: |
|
137 case KErrGsmSSSystemFailure: |
|
138 case KErrGsmSSUnexpectedDataValue: |
|
139 case KErrGsmSSIllegalOperation: |
|
140 case KErrGsm0707UnknownError: |
|
141 { |
|
142 isNwError = EFalse; |
|
143 break; |
|
144 } |
|
145 |
|
146 default: |
|
147 { |
|
148 LOG( NORMAL, "SATENGINE: TSatExtErrorUtils::IsNetworkError\ |
|
149 Is Network error" ) |
|
150 isNwError = ETrue; |
|
151 } |
|
152 } |
|
153 LOG2( SIMPLE, "SATENGINE: TSatExtErrorUtils::IsNetworkError exiting, \ |
|
154 isNwError: %d", isNwError ) |
|
155 return isNwError; |
|
156 } |
|
157 |
|
158 // ----------------------------------------------------------------------------- |
|
159 // TSatExtErrorUtils::CheckSpecificCases |
|
160 // (other items were commented in a header). |
|
161 // ----------------------------------------------------------------------------- |
|
162 // |
|
163 void TSatExtErrorUtils::CheckSpecificCases( |
|
164 TInt aExtError, TUint8& aNwError ) |
|
165 { |
|
166 LOG( SIMPLE, "SATENGINE: TSatExtErrorUtils::CheckSpecificCases calling" ) |
|
167 // Specific cases, where Extended error received by SAT differs from the |
|
168 // one that SIM expects |
|
169 if ( KErrGsmSMSCongestion == aExtError ) |
|
170 { |
|
171 LOG( NORMAL, "SATENGINE: TSatExtErrorUtils::CheckSpecificCases\ |
|
172 Changing Sms Congestion" ) |
|
173 // Change this into KErrGsmMmCongestion |
|
174 aNwError = static_cast<TUint8>( |
|
175 KErrGsmMobilityManagementBase - KErrGsmMMCongestion ); |
|
176 } |
|
177 else if ( KErrGsmSMSUnspecifiedProtocolError == aExtError || |
|
178 KErrGsmCCResourceNotAvailable == aExtError || |
|
179 KErrGsmSSIllegalOperation == aExtError || |
|
180 KErrGsmSMSNoNetworkService == aExtError || |
|
181 KErrGsmSSNotAvailable == aExtError || |
|
182 KErrGsm0707UnknownError == aExtError ) |
|
183 { |
|
184 LOG( NORMAL, "SATENGINE: TSatExtErrorUtils::CheckSpecificCases\ |
|
185 Changing unspecified protocol error to 0x00" ) |
|
186 // Change this into zero value |
|
187 aNwError = KSatZeroError; |
|
188 } |
|
189 else |
|
190 { |
|
191 LOG( NORMAL, "SATENGINE: TSatExtErrorUtils::CheckSpecificCases\ |
|
192 Not a special case" ) |
|
193 } |
|
194 LOG( SIMPLE, "SATENGINE: TSatExtErrorUtils::CheckSpecificCases exiting" ) |
|
195 } |
|
196 |
|
197 // End Of File |