1 /* |
|
2 * Copyright (c) 2007-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: account creation plugin params source file |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <f32file.h> |
|
20 #include <mmtsy_names.h> // For getting network information. |
|
21 |
|
22 #include "acpbrowserparams.h" |
|
23 #include "accountcreationpluginlogger.h" |
|
24 #include "accountcreationengineconstants.h" |
|
25 |
|
26 |
|
27 // --------------------------------------------------------------------------- |
|
28 // CACPBrowserParams::NewL |
|
29 // --------------------------------------------------------------------------- |
|
30 // |
|
31 CACPBrowserParams* CACPBrowserParams::NewL() |
|
32 { |
|
33 CACPBrowserParams* self = NewLC(); |
|
34 CleanupStack::Pop(self); |
|
35 return self; |
|
36 } |
|
37 |
|
38 // --------------------------------------------------------------------------- |
|
39 // CACPBrowserParams::NewLC |
|
40 // --------------------------------------------------------------------------- |
|
41 // |
|
42 CACPBrowserParams* CACPBrowserParams::NewLC() |
|
43 { |
|
44 CACPBrowserParams* self = new (ELeave) CACPBrowserParams(); |
|
45 CleanupStack::PushL(self); |
|
46 self->ConstructL( ); |
|
47 return self; |
|
48 } |
|
49 |
|
50 // --------------------------------------------------------------------------- |
|
51 // CACPBrowserParams::CACPBrowserParams |
|
52 // --------------------------------------------------------------------------- |
|
53 // |
|
54 CACPBrowserParams::CACPBrowserParams() |
|
55 { |
|
56 } |
|
57 |
|
58 // --------------------------------------------------------------------------- |
|
59 // CACPBrowserParams::~CACPBrowserParams |
|
60 // --------------------------------------------------------------------------- |
|
61 // |
|
62 CACPBrowserParams::~CACPBrowserParams() |
|
63 { |
|
64 iPhone.Close(); |
|
65 iTelServer.Close(); |
|
66 |
|
67 #ifdef __PLUG_AND_PLAY_MOBILE_SERVICES |
|
68 delete iPnpUtil; |
|
69 #endif |
|
70 } |
|
71 |
|
72 // --------------------------------------------------------------------------- |
|
73 // CACPBrowserParams::ConstructL |
|
74 // --------------------------------------------------------------------------- |
|
75 // |
|
76 void CACPBrowserParams::ConstructL( ) |
|
77 { |
|
78 ACPLOG( "CACPBrowserParams::ConstructL begin" ); |
|
79 |
|
80 #ifdef __PLUG_AND_PLAY_MOBILE_SERVICES |
|
81 // Create PnP utility class instance. |
|
82 iPnpUtil = CPnpUtilImpl::NewLC(); |
|
83 CleanupStack::Pop( iPnpUtil ); |
|
84 #endif |
|
85 |
|
86 // Initialize the telephone server |
|
87 User::LeaveIfError( iTelServer.Connect() ); |
|
88 User::LeaveIfError( iTelServer.LoadPhoneModule( KPhoneModuleName ) ); |
|
89 User::LeaveIfError( iPhone.Open( iTelServer, KPhoneName ) ); |
|
90 |
|
91 RetrieveParamsL(); |
|
92 |
|
93 ACPLOG( "CACPBrowserParams::ConstructL end" ); |
|
94 } |
|
95 |
|
96 // --------------------------------------------------------------------------- |
|
97 // CACPBrowserParams::RetrieveParamsL |
|
98 // --------------------------------------------------------------------------- |
|
99 // |
|
100 void CACPBrowserParams::RetrieveParamsL() |
|
101 { |
|
102 ACPLOG( "CACPBrowserParams::RetrieveParamsL begin" ); |
|
103 |
|
104 RetrievePhoneModel(); |
|
105 RetrieveHomeNetworkInfoL(); |
|
106 RetrieveSigningParamsL(); |
|
107 RetrieveWlanMacAddress(); |
|
108 RetrievePhoneInfoL(); |
|
109 |
|
110 ACPLOG( "CACPBrowserParams::RetrieveParamsL end" ); |
|
111 } |
|
112 |
|
113 // --------------------------------------------------------------------------- |
|
114 // CACPBrowserParams::RetrievePhoneModel |
|
115 // --------------------------------------------------------------------------- |
|
116 // |
|
117 void CACPBrowserParams::RetrievePhoneModel() |
|
118 { |
|
119 ACPLOG( "CACPBrowserParams::RetrievePhoneModelL begin" ); |
|
120 |
|
121 RMobilePhone::TMobilePhoneIdentityV1 phoneIdentity; |
|
122 TRequestStatus status( KRequestPending ); |
|
123 iPhone.GetPhoneId( status, phoneIdentity ); |
|
124 User::WaitForRequest( status ); |
|
125 |
|
126 iPhoneModel.Copy( phoneIdentity.iModel ); |
|
127 |
|
128 ACPLOG( "CACPBrowserParams::RetrievePhoneModelL end" ); |
|
129 } |
|
130 |
|
131 // --------------------------------------------------------------------------- |
|
132 // CACPBrowserParams::RetrieveHomeNetworkInfoL |
|
133 // --------------------------------------------------------------------------- |
|
134 // |
|
135 void CACPBrowserParams::RetrieveHomeNetworkInfoL() |
|
136 { |
|
137 ACPLOG( "CACPBrowserParams::RetrieveHomeNetworkInfoL begin" ); |
|
138 |
|
139 RMobilePhone::TMobilePhoneNetworkCountryCode homeMcc( KNullDesC ); |
|
140 RMobilePhone::TMobilePhoneNetworkIdentity homeMnc( KNullDesC ); |
|
141 |
|
142 if ( RegisteredInNetwork() ) |
|
143 { |
|
144 ACPLOG( " - registered in network, fetch info" ); |
|
145 iPnpUtil->FetchHomeNetworkInfoL(); |
|
146 homeMcc = iPnpUtil->HomeMccL(); |
|
147 homeMnc = iPnpUtil->HomeMncL(); |
|
148 } |
|
149 |
|
150 _LIT( KZero, "0" ); |
|
151 if ( homeMcc.Length() ) |
|
152 { |
|
153 iHomeMcc.Copy( homeMcc ); |
|
154 } |
|
155 else |
|
156 { |
|
157 iHomeMcc.Copy( KZero ); |
|
158 } |
|
159 |
|
160 if ( homeMnc.Length() ) |
|
161 { |
|
162 iHomeMnc.Copy( homeMnc ); |
|
163 } |
|
164 else |
|
165 { |
|
166 iHomeMnc.Copy( KZero ); |
|
167 } |
|
168 |
|
169 ACPLOG( "CACPBrowserParams::RetrieveHomeNetworkInfoL end" ); |
|
170 } |
|
171 |
|
172 // --------------------------------------------------------------------------- |
|
173 // CACPBrowserParams::RetrieveSigningParamsL |
|
174 // --------------------------------------------------------------------------- |
|
175 // |
|
176 void CACPBrowserParams::RetrieveSigningParamsL() |
|
177 { |
|
178 ACPLOG( "CACPBrowserParams::RetrieveSigningParamsL begin" ); |
|
179 |
|
180 // First reset nonce. |
|
181 iNonce.Zero(); |
|
182 |
|
183 #ifdef __PLUG_AND_PLAY_MOBILE_SERVICES |
|
184 // Create new nonce. |
|
185 iPnpUtil->CreateNewNonceL( 0, iNonce ); |
|
186 |
|
187 // Get key info. |
|
188 iPnpUtil->GetKeyInfoL( iKeyInfo ); |
|
189 #endif |
|
190 |
|
191 ACPLOG( "CACPBrowserParams::RetrieveSigningParamsL end" ); |
|
192 } |
|
193 |
|
194 // --------------------------------------------------------------------------- |
|
195 // CACPBrowserParams::RetrieveWlanMacAddressL |
|
196 // --------------------------------------------------------------------------- |
|
197 // |
|
198 void CACPBrowserParams::RetrieveWlanMacAddress() |
|
199 { |
|
200 ACPLOG( "CACPBrowserParams::RetrieveWlanMacAddress begin" ); |
|
201 |
|
202 TBuf8<KPSWlanMacAddressLength> address; |
|
203 |
|
204 RProperty::Get( |
|
205 KPSUidWlan, |
|
206 KPSWlanMacAddress, |
|
207 address ); |
|
208 |
|
209 for ( TInt counter = 0; counter < address.Length(); counter++ ) |
|
210 { |
|
211 TUint a = (TUint)address[counter]; |
|
212 iWlanMACAddress.AppendNumFixedWidthUC( a, EHex, 2 ); |
|
213 iWlanMACAddress.Append( KHyph ); |
|
214 iWlanMACAddress.LowerCase(); |
|
215 } |
|
216 |
|
217 // Delete the last ColonMark. |
|
218 if ( iWlanMACAddress.Length() ) |
|
219 { |
|
220 iWlanMACAddress.Delete( iWlanMACAddress.Length() -1, 1 ); |
|
221 } |
|
222 |
|
223 ACPLOG( "CACPBrowserParams::RetrieveWlanMacAddress end" ); |
|
224 } |
|
225 |
|
226 // --------------------------------------------------------------------------- |
|
227 // CACPBrowserParams::GetParameters |
|
228 // --------------------------------------------------------------------------- |
|
229 // |
|
230 void CACPBrowserParams::GetParameters( TDes& aUrl ) |
|
231 { |
|
232 ACPLOG2( "CACPBrowserParams::GetParameters begin: %S", &aUrl ); |
|
233 |
|
234 if ( aUrl.Find( KQuestionMark ) != KErrNotFound ) |
|
235 { |
|
236 aUrl.Append( KAmperSand ); |
|
237 } |
|
238 else |
|
239 { |
|
240 aUrl.Append( KQuestionMark ); |
|
241 } |
|
242 |
|
243 // Home MNC. |
|
244 aUrl.Append( KMnc ); |
|
245 aUrl.Append( KPlacing ); |
|
246 if( iHomeMnc != KNullDesC ) |
|
247 { |
|
248 aUrl.Append( iHomeMnc ); |
|
249 } |
|
250 else |
|
251 { |
|
252 aUrl.Append( _L("0") ); |
|
253 } |
|
254 |
|
255 aUrl.Append( KAmperSand ); |
|
256 |
|
257 // Home MCC. |
|
258 aUrl.Append( KMcc ); |
|
259 aUrl.Append( KPlacing ); |
|
260 if( iHomeMcc != KNullDesC ) |
|
261 { |
|
262 aUrl.Append( iHomeMcc ); |
|
263 } |
|
264 else |
|
265 { |
|
266 aUrl.Append( _L("0") ); |
|
267 } |
|
268 |
|
269 aUrl.Append( KAmperSand ); |
|
270 |
|
271 // Nonce. |
|
272 aUrl.Append( KNonce ); |
|
273 aUrl.Append( KPlacing ); |
|
274 |
|
275 TBuf<KNonceLength> nonce16; |
|
276 nonce16.Copy( iNonce ); |
|
277 aUrl.Append( nonce16 ); |
|
278 |
|
279 aUrl.Append( KAmperSand ); |
|
280 |
|
281 // Key Info. |
|
282 aUrl.Append( KKeyInfo ); |
|
283 aUrl.Append( KPlacing ); |
|
284 |
|
285 TBuf<KMaxKeyInfoLength> keyInfo16; |
|
286 keyInfo16.Copy( iKeyInfo ); |
|
287 aUrl.Append( keyInfo16 ); |
|
288 |
|
289 aUrl.Append( KAmperSand ); |
|
290 |
|
291 // Phone Model. |
|
292 aUrl.Append( KDeviceInfo ); |
|
293 aUrl.Append( KPlacing ); |
|
294 aUrl.Append( iPhoneModel ); |
|
295 |
|
296 // SType value is 2 |
|
297 aUrl.Append( KAmperSand ); |
|
298 aUrl.Append( KsType ); |
|
299 aUrl.Append( KPlacing ); |
|
300 aUrl.Append( KCharacterTwo ); |
|
301 |
|
302 // client version |
|
303 aUrl.Append( KAmperSand ); |
|
304 aUrl.Append( KcVersion ); |
|
305 aUrl.Append( KPlacing ); |
|
306 aUrl.Append( KValuecVersion ); |
|
307 |
|
308 // IMEI |
|
309 aUrl.Append( KAmperSand ); |
|
310 aUrl.Append( KImei ); |
|
311 aUrl.Append( KPlacing ); |
|
312 aUrl.Append( iImei ); |
|
313 |
|
314 // Variant |
|
315 aUrl.Append( KAmperSand ); |
|
316 aUrl.Append( KVariant ); |
|
317 aUrl.Append( KPlacing ); |
|
318 aUrl.Append( iVariant ); |
|
319 |
|
320 ACPLOG2( "CACPBrowserParams::GetParameters end: %S", &aUrl ); |
|
321 } |
|
322 |
|
323 // --------------------------------------------------------------------------- |
|
324 // CACPBrowserParams::RetrievePhoneInfoL |
|
325 // --------------------------------------------------------------------------- |
|
326 // |
|
327 void CACPBrowserParams::RetrievePhoneInfoL() |
|
328 { |
|
329 ACPLOG( "CACPBrowserParams::RetrievePhoneInfoL begin" ); |
|
330 |
|
331 // Get IMEI. |
|
332 RMobilePhone::TMobilePhoneIdentityV1 id; |
|
333 |
|
334 TRequestStatus status; |
|
335 iPhone.GetPhoneId( status, id ); |
|
336 User::WaitForRequest( status ); |
|
337 |
|
338 iImei.Copy( id.iSerialNumber ); |
|
339 |
|
340 // Get product code. |
|
341 SysVersionInfo::GetVersionInfo( SysVersionInfo::EProductCode, iVariant ); |
|
342 |
|
343 ACPLOG( "CACPBrowserParams::RetrievePhoneInfoL end" ); |
|
344 } |
|
345 |
|
346 // --------------------------------------------------------------------------- |
|
347 // CACPBrowserParams::RegisteredInNetworkL |
|
348 // --------------------------------------------------------------------------- |
|
349 // |
|
350 TBool CACPBrowserParams::RegisteredInNetwork() |
|
351 { |
|
352 ACPLOG( "CACPBrowserParams::RegisteredInNetwork begin" ); |
|
353 // Get registeration status |
|
354 TRequestStatus status; |
|
355 RMobilePhone::TMobilePhoneRegistrationStatus regStatus( |
|
356 RMobilePhone::ERegistrationUnknown ); |
|
357 iPhone.GetNetworkRegistrationStatus( status, regStatus ); |
|
358 ACPLOG2( " - network registration status %d", regStatus ); |
|
359 User::WaitForRequest( status ); |
|
360 if ( RMobilePhone::ERegistrationUnknown == regStatus || |
|
361 RMobilePhone::ENotRegisteredNoService == regStatus || |
|
362 RMobilePhone::ENotRegisteredEmergencyOnly == regStatus || |
|
363 RMobilePhone::ENotRegisteredSearching == regStatus ) |
|
364 { |
|
365 ACPLOG( "CACPBrowserParams::RegisteredInNetwork end" ); |
|
366 return EFalse; |
|
367 } |
|
368 ACPLOG( "CACPBrowserParams::RegisteredInNetwork end" ); |
|
369 return ETrue; |
|
370 } |
|
371 |
|
372 |
|
373 // End of file. |
|