|
1 /* |
|
2 * Copyright (c) 2007-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 the License "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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef CMMSTATICUTILITY_H |
|
21 #define CMMSTATICUTILITY_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 #include <e32math.h> |
|
26 #include <etelpckt.h> |
|
27 #ifdef INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING |
|
28 #include "pn_const_for_uicc.h" |
|
29 #else /* INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING */ |
|
30 #include <pn_const.h> |
|
31 #endif /* INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING */ |
|
32 #include <ctsy/serviceapi/cmmutility.h> |
|
33 |
|
34 #include "tsylogger.h" |
|
35 |
|
36 // CONSTANTS |
|
37 const TUint8 KTsyNetCauseCommon = 0x00; |
|
38 const TUint8 KTsyNetCauseGsm = 0x01; |
|
39 const TUint8 KTsyNetCauseCdma = 0x02; |
|
40 const TUint8 KTsyNetCauseWcdma = 0x03; |
|
41 |
|
42 const TUint8 KNoCsCauseType = 0xFF; |
|
43 |
|
44 // SIM Status tables |
|
45 const TUint8 KSimStatusTable = 0x01; |
|
46 const TUint8 KSimPbStatusTable = 0x02; |
|
47 const TUint8 KSimStaTable = 0x03; |
|
48 const TUint8 KApduStatus = 0x04; |
|
49 const TUint8 KSimSbStaTable = 0x05; |
|
50 |
|
51 // IPV4 address length |
|
52 const TInt KIpv4AddressLen = 4; |
|
53 // IPV6 address length |
|
54 const TInt KIpv6AddressLen = 16; |
|
55 // Digits separator for IPv6 address format |
|
56 static const TUint8 KClientIPv6AddressDigitsSeparator = ':'; |
|
57 |
|
58 // PMM Group ID and indexes for storing NITZ and Call Life Timer. |
|
59 // Group ID for PMM (PMM_GROUP_NOKIA_TSY = 382). |
|
60 const TUint16 KPmmGroupNokiaTsy = 0x017E; |
|
61 // NITZ Name index value for PMM. Reserved index '0'. |
|
62 const TUint16 KNitzNamePmmIndexValue = 0x0000; |
|
63 // Call Life Timer index value for PMM. Reserver index '1'. |
|
64 const TUint16 KCallLifeTimerPmmIndexValue = 0x0001; |
|
65 |
|
66 // MACROS |
|
67 // None |
|
68 |
|
69 // DATA TYPES |
|
70 // None |
|
71 |
|
72 // FUNCTION PROTOTYPES |
|
73 // None |
|
74 |
|
75 // FORWARD DECLARATIONS |
|
76 class TInetAddr; |
|
77 |
|
78 // CLASS DECLARATION |
|
79 |
|
80 /** |
|
81 * CMmStaticUtility contains commmonly used static utility functions. |
|
82 */ |
|
83 class CMmStaticUtility : public CBase |
|
84 { |
|
85 public: // New functions |
|
86 |
|
87 /** |
|
88 * Stores the core error code to lower 16 bits and adds the extended |
|
89 * error code to higher 16 bits and returns the error code that can be |
|
90 * sent to ETel Server. |
|
91 * @param TInt aCoreErrorCode |
|
92 * @param TInt aExtendedErrorCode |
|
93 * @return TInt: KErrNone or error value |
|
94 */ |
|
95 static TInt EpocErrorCode( TInt aCoreErrorCode, |
|
96 TInt aExtendedErrorCode ); |
|
97 |
|
98 /** |
|
99 * Converts ISI cause to EPOC cause value |
|
100 * @param TInt aResource |
|
101 * @param TUint8 aIsiCauseType |
|
102 * @param TUint8 aIsiCauseValue |
|
103 * @return TInt: KErrNone or error value |
|
104 */ |
|
105 static TInt CSCauseToEpocError( TInt aResource, |
|
106 TUint8 aIsiCauseType, |
|
107 TUint8 aIsiCauseValue ); |
|
108 |
|
109 /** |
|
110 * Converts UICC cause to EPOC cause value |
|
111 * @param TUint8 aIsiCauseValue |
|
112 * @return TInt: KErrNone or error value |
|
113 */ |
|
114 static TInt UICCCSCauseToEpocError( TUint8 aIsiCauseValue ); |
|
115 |
|
116 /** |
|
117 * Converts Packet Data related ISI cause to EPOC cause value |
|
118 * @param TUint8 aIsiCauseValue: cause value |
|
119 * @param TInt aResource: resource |
|
120 * @param TUint8 aIsiCauseType: Cause type |
|
121 * @return TInt: EPOC error code |
|
122 */ |
|
123 static TInt PacketDataCSCauseToEpocError( TUint8 aIsiCauseValue, |
|
124 TInt aResource = PN_GPDS, |
|
125 TUint8 aIsiCauseType = 0x00 ); |
|
126 |
|
127 /** |
|
128 * Converts Gpds Pdp type to Packet API Pdp type |
|
129 * @param RPacketContext::TProtocolType& aPdpTypeClient: Pdp type to |
|
130 * client |
|
131 * @param TUint8 aPdpTypeServer: Pdp type from Gpds |
|
132 * @return TInt: EPOC error code |
|
133 */ |
|
134 static void MapPdpTypeToClient( |
|
135 RPacketContext::TProtocolType& aPdpTypeClient, |
|
136 TUint8 aPdpTypeServer ); |
|
137 /** |
|
138 * Converts GPDS IP address to Client format suitable to be used |
|
139 * with TInetAddr::Input. IPv4 and IPv6 are supported |
|
140 * @param TDesC8& aGPDSAddres: GPDS IP address |
|
141 * @param TDes8& aInetAddr: Clients IP address |
|
142 */ |
|
143 static void ConvertIPAddressToClient( |
|
144 const TDesC8& aGPDSAddres, |
|
145 TDes8& aInetAddr ); |
|
146 /** |
|
147 * Converts number string to integer |
|
148 * @param TUint& integer: integer value |
|
149 * @param TDesC& buffer: buffer containing the number string |
|
150 */ |
|
151 static void GetIntFromDescriptor( TUint& integer, TDesC& buffer ); |
|
152 |
|
153 // Network utility function |
|
154 /** |
|
155 * Form operator code from MNC and MCC codes. |
|
156 * @param TBuf8<3>& aOperatorCode: Buffer for MNC and MCC code |
|
157 * @param TBuf<4>* aMnc: Pointer to MNC code |
|
158 * @param TBuf<3>* aMcc: Pointer to MCC code |
|
159 */ |
|
160 static void FormOperatorCode( TBuf8<3>& aOperatorCode, |
|
161 const TBuf<4>* aMnc, |
|
162 const TBuf<3>* aMcc ); |
|
163 |
|
164 /** |
|
165 * Extract and return MCC codes from operator code. |
|
166 * @param TPtrC8 aOperatorCode: Combined MCC and MNC |
|
167 * @param TUint16* aMcc1: 1st number of MCC code |
|
168 * @param TUint16* aMcc2: 2nd number of MCC code |
|
169 * @param TUint16* aMcc3: 3rd number of MCC code |
|
170 */ |
|
171 static void GetMccCodes( TPtrC8 aOperatorCode, |
|
172 TUint16* aMcc1, |
|
173 TUint16* aMcc2, |
|
174 TUint16* aMcc3 ); |
|
175 |
|
176 /** |
|
177 * Extract and return MNC codes from operator code. |
|
178 * @param TPtrC8 aOperatorCode: Combined MCC and MNC |
|
179 * @param TUint16* aMnc1: 1st number of MNC code |
|
180 * @param TUint16* aMnc2: 2nd number of MNC code |
|
181 * @param TUint16* aMnc3: 3rd number of MNC code |
|
182 */ |
|
183 static void GetMncCodes( TPtrC8 aOperatorCode, |
|
184 TUint16* aMnc1, |
|
185 TUint16* aMnc2, |
|
186 TUint16* aMnc3 ); |
|
187 |
|
188 /** |
|
189 * Calculates mcc and mnc numbers from given digits |
|
190 * @param TUint& aMccNumber: Mcc number |
|
191 * @param TUint& aMncNumber: Mnc number |
|
192 * @param TUint16 aMcc1: first mcc digit |
|
193 * @param TUint16 aMcc2: second mcc digit |
|
194 * @param TUint16 aMcc3: third mcc digit |
|
195 * @param TUint16 aMnc1: first mnc digit |
|
196 * @param TUint16 aMnc2: second mnc digit |
|
197 * @param TUint16 aMnc3: third mnc digit |
|
198 */ |
|
199 static void CalculateMccMncNumbers( TUint& aMccNumber, |
|
200 TUint& aMncNumber, |
|
201 TUint16 aMcc1, |
|
202 TUint16 aMcc2, |
|
203 TUint16 aMcc3, |
|
204 TUint16 aMnc1, |
|
205 TUint16 aMnc2, |
|
206 TUint16 aMnc3 ); |
|
207 |
|
208 /** |
|
209 * Determine if operinfo is APAC |
|
210 * @return ETrue if APAC is in use |
|
211 */ |
|
212 static TBool IsOperinfoApac(); |
|
213 |
|
214 |
|
215 /** |
|
216 * Converts data to UCS format |
|
217 * @param aInputString Input string |
|
218 * @param aLength Length |
|
219 * @param aUcs2String Output string |
|
220 * @return None |
|
221 */ |
|
222 static void ConvertGsmDataToUcs2( |
|
223 TDes8& aInputString, |
|
224 TUint16 aLength, |
|
225 TDes8& aUcs2String ); |
|
226 |
|
227 /** |
|
228 * Get unicode character |
|
229 * @param aCharacter Input character |
|
230 * @return Unicode character |
|
231 */ |
|
232 static TUint16 GetUnicodeGsm( TUint8 aCharacter); |
|
233 |
|
234 /** |
|
235 * Set value for oper info |
|
236 * THIS IS ONLY FOR WINSCW TESTING USE |
|
237 */ |
|
238 #if __WINSCW__ |
|
239 IMPORT_C static void SetOperinfoApac( TBool aApac ); |
|
240 #endif // __WINSCW__ |
|
241 |
|
242 }; |
|
243 |
|
244 // INLINE FUNCTION IMPLEMENTATIONS |
|
245 |
|
246 // ----------------------------------------------------------------------------- |
|
247 // CMmStaticUtility::EpocErrorCode |
|
248 // Stores the core error code to lower 16 bits and adds the |
|
249 // extended error code to higher 16 bits and returns the error code that can |
|
250 // be sent to ETel Server. |
|
251 // (other items were commented in a header). |
|
252 // ----------------------------------------------------------------------------- |
|
253 // |
|
254 inline TInt CMmStaticUtility::EpocErrorCode |
|
255 ( |
|
256 TInt aCoreErrorCode, // core error |
|
257 TInt aExtendedErrorCode // extended error |
|
258 ) |
|
259 { |
|
260 TFLOGSTRING3("TSY: CMmStaticUtility::EpocErrorCode, Error mapping done,\ |
|
261 Core error: %d, Extended error: %d", |
|
262 aCoreErrorCode, |
|
263 aExtendedErrorCode); |
|
264 |
|
265 TInt errorCode = ( aCoreErrorCode & 0x0000FFFF ) | |
|
266 ( aExtendedErrorCode << 16 ); |
|
267 |
|
268 TFLOGSTRING2("TSY: CMmStaticUtility::EpocErrorCode. It was mapped\ |
|
269 to the following Symbian OS error: %d", |
|
270 errorCode); |
|
271 |
|
272 return errorCode; |
|
273 } |
|
274 |
|
275 #endif // CMMSTATICUTILITY_H |
|
276 |
|
277 // End of file |