|
1 /* |
|
2 * Copyright (c) 2006 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 of CNcdProtocol |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "ncdprotocolimpl.h" |
|
20 #include "ncdparserfactory.h" |
|
21 #include "ncdparser.h" |
|
22 #include "ncdsessionhandler.h" |
|
23 #include "catalogsdebug.h" |
|
24 #include "ncdrequestbase.h" |
|
25 #include "ncddeviceinteractionfactory.h" |
|
26 #include "ncddeviceservice.h" |
|
27 #include "ncdrequestconfiguration.h" |
|
28 #include "ncdrequestconfigurationdata.h" |
|
29 #include "catalogssmsutils.h" |
|
30 #include "catalogscontext.h" |
|
31 #include "ncdkeyvaluemap.h" |
|
32 #include "ncdutils.h" |
|
33 #include "ncdstoragemanager.h" |
|
34 #include "ncdproviderdefines.h" |
|
35 #include "ncdstorage.h" |
|
36 #include "ncdconfigurationmanager.h" |
|
37 #include "ncdprotocoldefaultobserverimpl.h" |
|
38 #include "catalogsutils.h" |
|
39 #include "ncd_cp_cookieimpl.h" |
|
40 #include "ncd_cp_detailimpl.h" |
|
41 #include "ncdinternalconfigurationkeys.h" |
|
42 #include "ncdcapabilities.h" |
|
43 #include "ncdserverdetails.h" |
|
44 #include "catalogsuids.h" |
|
45 #include "ncdproviderutils.h" |
|
46 #include "ncdengineconfiguration.h" |
|
47 #include "ncdinstallationserviceimpl.h" |
|
48 #include "ncdprotocolstrings.h" |
|
49 #include "catalogs_device_config.h" |
|
50 |
|
51 // Hardcoded platforminfo |
|
52 |
|
53 _LIT( KPlatformInfo, "Series60" ); |
|
54 |
|
55 // --------------------------------------------------------------------------- |
|
56 // CContextData::CContextData |
|
57 // --------------------------------------------------------------------------- |
|
58 // |
|
59 CNcdProtocol::CContextData::CContextData( const MCatalogsContext& aContext, |
|
60 CNcdSessionHandler* aSessionHandler ) : CBase(), |
|
61 iFamilyId( aContext.FamilyId() ), |
|
62 iSessionHandler( aSessionHandler ) |
|
63 { |
|
64 } |
|
65 |
|
66 // --------------------------------------------------------------------------- |
|
67 // CContextData::~CContextData |
|
68 // --------------------------------------------------------------------------- |
|
69 // |
|
70 CNcdProtocol::CContextData::~CContextData() |
|
71 { |
|
72 delete iSessionHandler; |
|
73 } |
|
74 |
|
75 |
|
76 |
|
77 // --------------------------------------------------------------------------- |
|
78 // CContextData::SessionHandler |
|
79 // --------------------------------------------------------------------------- |
|
80 // |
|
81 MNcdSessionHandler& CNcdProtocol::CContextData::SessionHandler() const |
|
82 { |
|
83 DASSERT( iSessionHandler ); |
|
84 return *iSessionHandler; |
|
85 } |
|
86 |
|
87 |
|
88 // --------------------------------------------------------------------------- |
|
89 // CContextData::Context |
|
90 // --------------------------------------------------------------------------- |
|
91 // |
|
92 TUid CNcdProtocol::CContextData::FamilyId() const |
|
93 { |
|
94 return iFamilyId; |
|
95 } |
|
96 |
|
97 // --------------------------------------------------------------------------- |
|
98 // CContextData::SessionL |
|
99 // --------------------------------------------------------------------------- |
|
100 // |
|
101 void CNcdProtocol::CContextData::SessionL( const TDesC& aSessionId, |
|
102 const TDesC& aServerUri, const TDesC& aNameSpace ) |
|
103 { |
|
104 DLTRACEIN(( _L("Session Id: %S, server URI: %S, name space: %S"), |
|
105 &aSessionId, &aServerUri, &aNameSpace )); |
|
106 |
|
107 // Remove old session if any |
|
108 iSessionHandler->RemoveSession( aServerUri, aNameSpace ); |
|
109 |
|
110 // Create a new session |
|
111 DLTRACE( ( "Creating a new session" ) ); |
|
112 iSessionHandler->CreateSessionL( aServerUri, aNameSpace, aSessionId ); |
|
113 |
|
114 DLTRACEOUT(( "" )); |
|
115 } |
|
116 |
|
117 |
|
118 // --------------------------------------------------------------------------- |
|
119 // Constructor |
|
120 // --------------------------------------------------------------------------- |
|
121 // |
|
122 CNcdProtocol::CNcdProtocol( MNcdConfigurationManager& aConfigurationManager, |
|
123 CNcdSubscriptionManager& aSubscriptionManager ) : |
|
124 iConfigurationManager( aConfigurationManager ), |
|
125 iSubscriptionManager( aSubscriptionManager ) |
|
126 { |
|
127 } |
|
128 |
|
129 |
|
130 // --------------------------------------------------------------------------- |
|
131 // Destructor |
|
132 // --------------------------------------------------------------------------- |
|
133 // |
|
134 CNcdProtocol::~CNcdProtocol() |
|
135 { |
|
136 DLTRACEIN(("")); |
|
137 delete iSmsUtils; |
|
138 |
|
139 iContexts.ResetAndDestroy(); |
|
140 DLTRACEOUT(("")); |
|
141 } |
|
142 |
|
143 |
|
144 // --------------------------------------------------------------------------- |
|
145 // NewL |
|
146 // --------------------------------------------------------------------------- |
|
147 // |
|
148 CNcdProtocol* CNcdProtocol::NewL( MNcdConfigurationManager& aConfigurationManager, |
|
149 CNcdSubscriptionManager& aSubscriptionManager ) |
|
150 { |
|
151 CNcdProtocol* self = new(ELeave) CNcdProtocol( aConfigurationManager, |
|
152 aSubscriptionManager ); |
|
153 CleanupStack::PushL( self ); |
|
154 self->ConstructL(); |
|
155 CleanupStack::Pop( self ); |
|
156 return self; |
|
157 } |
|
158 |
|
159 |
|
160 // --------------------------------------------------------------------------- |
|
161 // ConstructL |
|
162 // --------------------------------------------------------------------------- |
|
163 // |
|
164 void CNcdProtocol::ConstructL() |
|
165 { |
|
166 DLTRACEIN(("")); |
|
167 iSmsUtils = CCatalogsSmsUtils::NewL(); |
|
168 iDeviceService = &CNcdProviderUtils::DeviceService(); |
|
169 |
|
170 // This gets the firmware string and appends it with the variant |
|
171 // string |
|
172 iDeviceService->AppendVariantToFirmwareL( |
|
173 CNcdProviderUtils::FileSession() ); |
|
174 |
|
175 // Get home MCC and MNC so they don't have to be acquired separately |
|
176 // for every session |
|
177 iDeviceService->HomeNetworkInfoL( iHomeMcc, iHomeMnc ); |
|
178 } |
|
179 |
|
180 |
|
181 // --------------------------------------------------------------------------- |
|
182 // CreateParserL |
|
183 // --------------------------------------------------------------------------- |
|
184 // |
|
185 MNcdParser* CNcdProtocol::CreateParserL( MCatalogsContext& aContext, |
|
186 const TDesC& aServerUri ) |
|
187 { |
|
188 CContextData& data = CreateContextDataL( aContext ); |
|
189 |
|
190 // Create default observer |
|
191 CNcdProtocolDefaultObserver* protocolDefaultObserver = |
|
192 CNcdProtocolDefaultObserver::NewL( aContext, |
|
193 iConfigurationManager, |
|
194 iSubscriptionManager, |
|
195 aServerUri ); |
|
196 |
|
197 CleanupStack::PushL( protocolDefaultObserver ); |
|
198 |
|
199 // Ownership of the default observer is transferred |
|
200 MNcdParser* parser = NcdParserFactory::CreateParserL( |
|
201 protocolDefaultObserver ); |
|
202 |
|
203 CleanupStack::Pop( protocolDefaultObserver ); |
|
204 |
|
205 |
|
206 // Set all default observers here! Clients may override them. |
|
207 parser->Observers().SetSessionObserver( &data ); |
|
208 |
|
209 CleanupDeletePushL( parser ); |
|
210 // The following is used in session observer callback, |
|
211 // and entityreference building: |
|
212 parser->SetOriginL( aServerUri ); |
|
213 |
|
214 CleanupStack::Pop( parser ); |
|
215 return parser; |
|
216 } |
|
217 |
|
218 // --------------------------------------------------------------------------- |
|
219 // Preminet protocol request processor |
|
220 // --------------------------------------------------------------------------- |
|
221 // |
|
222 HBufC8* CNcdProtocol::ProcessPreminetRequestL( |
|
223 const MCatalogsContext& aContext, |
|
224 CNcdRequestBase& aRequest, const TDesC& aServerUri, |
|
225 TBool aForceConfigurationData ) |
|
226 { |
|
227 DLTRACEIN(("")); |
|
228 |
|
229 // Get or create context data for the context |
|
230 CContextData& contextData( CreateContextDataL( aContext ) ); |
|
231 HBufC* nameSpace = aRequest.NamespaceLC(); |
|
232 TBool sessionExists = |
|
233 contextData.SessionHandler().DoesSessionExist( aServerUri, *nameSpace ); |
|
234 |
|
235 if ( aForceConfigurationData || !sessionExists ) |
|
236 { |
|
237 DLTRACE(( _L("Session starts for server: %S, ns: %S"), &aServerUri, |
|
238 nameSpace )); |
|
239 CNcdRequestConfigurationData* config = |
|
240 CNcdRequestConfigurationData::NewLC(); |
|
241 |
|
242 aRequest.SetConfigurationL( config ); |
|
243 CleanupStack::Pop( config ); |
|
244 |
|
245 // Common common processing for the request: add client-info etc. |
|
246 AddClientInfoToRequestL( aContext, *config ); |
|
247 |
|
248 // Add engine's client-info |
|
249 AddEngineClientInfoToRequestL( *config ); |
|
250 |
|
251 // Array for the cookies that are sent to the server |
|
252 RPointerArray<MNcdConfigurationProtocolCookie> cookies; |
|
253 CleanupResetAndDestroyPushL( cookies ); |
|
254 |
|
255 // Add CGW cookies if there are any |
|
256 TBool cookiesChanged = AddCookiesL( |
|
257 aContext, |
|
258 cookies, |
|
259 aServerUri, |
|
260 *nameSpace ); |
|
261 |
|
262 // Add CDB cookies, these override existing server cookies |
|
263 cookiesChanged |= AddCookiesL( |
|
264 aContext, |
|
265 cookies, |
|
266 iConfigurationManager.MasterServerAddressL( aContext ), |
|
267 NcdProviderDefines::KConfigNamespace ); |
|
268 |
|
269 // Finally add the cookies to the request |
|
270 AddCookiesToRequestL( aRequest, cookies ); |
|
271 |
|
272 CleanupStack::PopAndDestroy( &cookies ); |
|
273 |
|
274 // Remove expired cookies from db |
|
275 if ( cookiesChanged ) |
|
276 { |
|
277 DLTRACE(("Cookies had expired, update the config to db")); |
|
278 iConfigurationManager.SaveConfigurationToDbL( aContext ); |
|
279 } |
|
280 } |
|
281 |
|
282 if ( sessionExists ) |
|
283 { |
|
284 // Set session id for a continuing session |
|
285 aRequest.SetSessionL( contextData.SessionHandler().Session( |
|
286 aServerUri, *nameSpace ) ); |
|
287 } |
|
288 CleanupStack::PopAndDestroy( nameSpace ); |
|
289 HBufC8* req = aRequest.CreateRequestL(); |
|
290 DLINFO(("request=%S",req)); |
|
291 DLTRACEOUT(("")); |
|
292 return req; |
|
293 } |
|
294 |
|
295 |
|
296 // --------------------------------------------------------------------------- |
|
297 // Configuration protocol request processor |
|
298 // --------------------------------------------------------------------------- |
|
299 // |
|
300 HBufC8* CNcdProtocol::ProcessConfigurationRequestL( |
|
301 const MCatalogsContext& aContext, |
|
302 CNcdRequestConfiguration& aRequest ) |
|
303 { |
|
304 DLTRACEIN(("")); |
|
305 // Get or create context data for the context |
|
306 CContextData& contextData( CreateContextDataL( aContext ) ); |
|
307 |
|
308 CNcdRequestConfigurationData* config = |
|
309 CNcdRequestConfigurationData::NewLC(); |
|
310 |
|
311 aRequest.SetConfigurationL( config ); |
|
312 CleanupStack::Pop( config ); |
|
313 |
|
314 |
|
315 // Common common processing for the request: add client-info etc. |
|
316 AddClientInfoToRequestL( aContext, *config ); |
|
317 |
|
318 // Add engine's client-info |
|
319 AddEngineClientInfoToRequestL( *config ); |
|
320 |
|
321 // Array for the cookies that are sent to the server |
|
322 RPointerArray<MNcdConfigurationProtocolCookie> cookies; |
|
323 CleanupResetAndDestroyPushL( cookies ); |
|
324 |
|
325 // Add cookies if there any |
|
326 TBool cookiesChanged = AddCookiesL( aContext, |
|
327 cookies, |
|
328 iConfigurationManager.MasterServerAddressL( aContext ), |
|
329 NcdProviderDefines::KConfigNamespace ); |
|
330 |
|
331 AddCookiesToConfigRequestL( *config, cookies ); |
|
332 CleanupStack::PopAndDestroy( &cookies ); |
|
333 |
|
334 // Remove expired cookies from db |
|
335 if ( cookiesChanged ) |
|
336 { |
|
337 DLTRACE(("Cookies had expired, update the config to db")); |
|
338 iConfigurationManager.SaveConfigurationToDbL( aContext ); |
|
339 } |
|
340 |
|
341 HBufC8* req = aRequest.CreateRequestL(); |
|
342 //DLINFO(("request=%S",req)); |
|
343 DLTRACEOUT(("")); |
|
344 return req; |
|
345 } |
|
346 |
|
347 |
|
348 // --------------------------------------------------------------------------- |
|
349 // Session handler getter |
|
350 // --------------------------------------------------------------------------- |
|
351 // |
|
352 MNcdSessionHandler& CNcdProtocol::SessionHandlerL( |
|
353 const MCatalogsContext& aContext ) const |
|
354 { |
|
355 TInt index = FindContextData( aContext ); |
|
356 if ( index == KErrNotFound ) |
|
357 { |
|
358 User::Leave( KErrNotFound ); |
|
359 } |
|
360 return iContexts[index]->SessionHandler(); |
|
361 } |
|
362 |
|
363 |
|
364 // --------------------------------------------------------------------------- |
|
365 // Protocol options setter |
|
366 // --------------------------------------------------------------------------- |
|
367 // |
|
368 void CNcdProtocol::SetProtocolOptions( TUint32 aOptions ) |
|
369 { |
|
370 DLTRACEIN(("aOptions: %d", aOptions )); |
|
371 iProtocolOptions = aOptions; |
|
372 } |
|
373 |
|
374 // --------------------------------------------------------------------------- |
|
375 // Add client-info to the request configuration |
|
376 // --------------------------------------------------------------------------- |
|
377 // |
|
378 void CNcdProtocol::AddClientInfoToRequestL( |
|
379 const MCatalogsContext& aContext, |
|
380 CNcdRequestConfigurationData& aConfig ) |
|
381 { |
|
382 DLTRACEIN(("")); |
|
383 |
|
384 // Connect to telephony services so it won't have to be done in each |
|
385 // deviceinteraction method that require such services |
|
386 iDeviceService->ConnectL(); |
|
387 |
|
388 CNcdKeyValueMap *userConfig = NULL; |
|
389 // Search for the user configuration |
|
390 TRAPD( err, |
|
391 userConfig = &iConfigurationManager.ConfigurationsL( aContext, |
|
392 MNcdUserConfiguration::ENcdConfigurationClientInfo ) ); |
|
393 if ( err != KErrNone ) |
|
394 { |
|
395 // @ Error handling! |
|
396 } |
|
397 |
|
398 RPointerArray<CNcdKeyValuePair> configPairs; |
|
399 |
|
400 // Using close since configPairs won't own the data it points to |
|
401 CleanupClosePushL( configPairs ); |
|
402 if ( userConfig ) |
|
403 { |
|
404 configPairs.ReserveL( userConfig->Pairs().Count() ); |
|
405 |
|
406 for ( TInt i = 0; i < userConfig->Pairs().Count(); ++i ) |
|
407 { |
|
408 configPairs.AppendL( userConfig->Pairs()[i] ); |
|
409 } |
|
410 } |
|
411 |
|
412 // Add network info to the request |
|
413 SetNetworkInfoL( aConfig ); |
|
414 |
|
415 CNcdRequestConfigurationClient* client = |
|
416 CNcdRequestConfigurationClient::NewLC(); |
|
417 |
|
418 // Add hardware configuration info to the request |
|
419 SetHardwareConfigurationL( client->Hardware(), configPairs ); |
|
420 |
|
421 // Add software configuration info to the request |
|
422 AddSoftwareConfigurationL( aContext, *client, configPairs ); |
|
423 |
|
424 |
|
425 DLTRACE(("Add client-info to request")); |
|
426 aConfig.AddClientL( client ); |
|
427 CleanupStack::Pop( client ); |
|
428 |
|
429 CleanupStack::PopAndDestroy( &configPairs ); |
|
430 |
|
431 // Close telephony services |
|
432 User::LeaveIfError( iDeviceService->Close() ); |
|
433 } |
|
434 |
|
435 |
|
436 // --------------------------------------------------------------------------- |
|
437 // AddEngineClientInfoToRequestL |
|
438 // Adds a client info element describing the engine |
|
439 // --------------------------------------------------------------------------- |
|
440 // |
|
441 void CNcdProtocol::AddEngineClientInfoToRequestL( |
|
442 CNcdRequestConfigurationData& aConfig ) |
|
443 { |
|
444 DLTRACEIN(("")); |
|
445 |
|
446 // Create a new client-element |
|
447 CNcdRequestConfigurationClient* client = |
|
448 CNcdRequestConfigurationClient::NewLC(); |
|
449 |
|
450 // Create a new software element |
|
451 CNcdRequestConfigurationSoftware* software = |
|
452 CNcdRequestConfigurationSoftware::NewLC(); |
|
453 |
|
454 |
|
455 // Set type, version and UID |
|
456 software->SetSoftwareTypeL( |
|
457 CNcdProviderUtils::EngineConfig().EngineType() ); |
|
458 |
|
459 software->SetSoftwareVersionL( |
|
460 CNcdProviderUtils::EngineConfig().EngineVersion() ); |
|
461 |
|
462 software->SetSoftwareIdsL( |
|
463 CNcdProviderUtils::EngineConfig().EngineUid(), |
|
464 KNullDesC, |
|
465 KNullDesC8 ); |
|
466 |
|
467 |
|
468 //Set provisioning for the engine |
|
469 if ( CNcdProviderUtils::EngineConfig().EngineProvisioning().Length() ) |
|
470 { |
|
471 CNcdConfigurationProtocolDetailImpl* detail = |
|
472 CreateDetailLC( NcdConfigurationKeys::KProvisioning, |
|
473 CNcdProviderUtils::EngineConfig().EngineProvisioning() ); |
|
474 software->AddSoftwareDetailsL( detail ); |
|
475 CleanupStack::Pop( detail ); |
|
476 } |
|
477 |
|
478 // engine install drive |
|
479 CNcdConfigurationProtocolDetailImpl* drive = |
|
480 CreateDetailLC( NcdConfigurationKeys::KInstallDrive, |
|
481 CNcdProviderUtils::EngineConfig().EngineInstallDrive() ); |
|
482 software->AddSoftwareDetailsL( drive ); |
|
483 CleanupStack::Pop( drive ); |
|
484 |
|
485 |
|
486 client->AddSoftwareL( software ); |
|
487 CleanupStack::Pop( software ); |
|
488 |
|
489 aConfig.AddClientL( client ); |
|
490 CleanupStack::Pop( client ); |
|
491 |
|
492 } |
|
493 |
|
494 // --------------------------------------------------------------------------- |
|
495 // SetNetworkInfoL |
|
496 // Fills the network information |
|
497 // --------------------------------------------------------------------------- |
|
498 // |
|
499 void CNcdProtocol::SetNetworkInfoL( CNcdRequestConfigurationData& aConfig ) |
|
500 { |
|
501 DLTRACEIN(( "" )); |
|
502 { |
|
503 DLTRACE(( "Setting MCC & MNC" )); |
|
504 // Get & set current MCC and MNC |
|
505 aConfig.SetNetworkMccL( iHomeMcc, iDeviceService->CurrentMccL() ); |
|
506 aConfig.SetNetworkMncL( iHomeMnc, iDeviceService->CurrentMncL() ); |
|
507 } |
|
508 |
|
509 // Set service provider name |
|
510 { |
|
511 DLTRACE(( "Setting service provider name" )); |
|
512 TBuf<MNcdDeviceService::KServiceProviderMaxLength> spName; |
|
513 iDeviceService->ServiceProviderL( spName ); |
|
514 DLINFO(( _L("SP: %S"), &spName )); |
|
515 aConfig.SetNetworkProviderL( spName ); |
|
516 } |
|
517 |
|
518 // IMSI not set on purpose |
|
519 |
|
520 |
|
521 // Set SMS center number |
|
522 HBufC* smsc = iSmsUtils->SmsCenterNumberLC(); |
|
523 aConfig.SetNetworkSmscL( *smsc ); |
|
524 CleanupStack::PopAndDestroy( smsc ); |
|
525 |
|
526 /** |
|
527 * @ Add: gid1/2, msisdn, operatorname |
|
528 */ |
|
529 |
|
530 |
|
531 DLTRACEOUT(( "" )); |
|
532 } |
|
533 |
|
534 |
|
535 // --------------------------------------------------------------------------- |
|
536 // AddSoftwareConfigurationL |
|
537 // Fills the client software information |
|
538 // --------------------------------------------------------------------------- |
|
539 // |
|
540 void CNcdProtocol::AddSoftwareConfigurationL( const MCatalogsContext& aContext, |
|
541 CNcdRequestConfigurationClient& aClient, |
|
542 RPointerArray<CNcdKeyValuePair>& aConfigPairs ) |
|
543 { |
|
544 DLTRACEIN(("")); |
|
545 |
|
546 /* |
|
547 |
|
548 RArray<TString> testmodes; |
|
549 |
|
550 RArray<TNcdRequestCustomDetails> details; |
|
551 KInstallDrive |
|
552 |
|
553 Done: |
|
554 TString uid; |
|
555 // Quasi-unique client id. |
|
556 TString id; |
|
557 |
|
558 //SIM-sensitive client id obtained by hashing the client id and IMSI code. |
|
559 TString sid; |
|
560 TString language; |
|
561 TString type; |
|
562 TString version; |
|
563 RArray<TString> capabilities; |
|
564 |
|
565 */ |
|
566 |
|
567 DLTRACE(("Hashing client ID with IMSI")); |
|
568 const TDesC& clientId( iConfigurationManager.ClientIdL( aContext ) ); |
|
569 |
|
570 DLTRACE(("Getting SSID")); |
|
571 TPtrC8 ssidPtr( iConfigurationManager.SsidL( aContext ) ); |
|
572 DLTRACE(( "SSID: %S, length: %d", &ssidPtr, ssidPtr.Length() )); |
|
573 |
|
574 // Generate the SSID if it doesn't already exist |
|
575 /* |
|
576 if ( !ssidPtr.Length() ) |
|
577 { |
|
578 DLTRACE(("Creating a new SSID")); |
|
579 HBufC8* ssid = NULL; |
|
580 //ssid = HashImsiAndIdLC( clientId ); |
|
581 ssid = HashImsiLC(); |
|
582 |
|
583 DLTRACE(("Setting uid, client id and hash to request")); |
|
584 |
|
585 // Ownership is transferred to the manager |
|
586 iConfigurationManager.SetSsidL( aContext, ssid ); |
|
587 |
|
588 CleanupStack::Pop( ssid ); |
|
589 ssidPtr.Set( *ssid ); |
|
590 |
|
591 DLTRACE(( "Hashed SSID: %S", &ssidPtr )); |
|
592 |
|
593 } |
|
594 */ |
|
595 |
|
596 CNcdRequestConfigurationSoftware* software = |
|
597 CNcdRequestConfigurationSoftware::NewLC(); |
|
598 |
|
599 // Use secureId as the client UID |
|
600 software->SetSoftwareIdsL( CleanUidName( aContext.SecureId() ), |
|
601 clientId, ssidPtr ); |
|
602 |
|
603 DLTRACE(( _L("Client ID: %S"), &clientId )); |
|
604 |
|
605 |
|
606 // Add client & engine capabilities (must be done before |
|
607 // AddConfigurationsToSoftwareDetailsL) |
|
608 AddCapabilitiesL( *software, aConfigPairs ); |
|
609 |
|
610 |
|
611 if ( FindKey( NcdConfigurationKeys::KSoftwareType(), aConfigPairs ) |
|
612 != KErrNotFound ) |
|
613 { |
|
614 DLTRACE(("Front-end overrides type")); |
|
615 // Add software type |
|
616 AddSoftwareUserConfigurationL( *software, |
|
617 &CNcdRequestConfigurationSoftware::SetSoftwareTypeL, aConfigPairs, |
|
618 NcdConfigurationKeys::KSoftwareType() ); |
|
619 } |
|
620 else |
|
621 { |
|
622 DLTRACE(("Using type from engine")); |
|
623 software->SetSoftwareTypeL( |
|
624 CNcdProviderUtils::EngineConfig().EngineType() ); |
|
625 } |
|
626 |
|
627 |
|
628 // Add software language |
|
629 AddSoftwareUserConfigurationL( *software, |
|
630 &CNcdRequestConfigurationSoftware::SetSoftwareLanguageL, aConfigPairs, |
|
631 NcdConfigurationKeys::KSoftwareLanguage() ); |
|
632 |
|
633 |
|
634 #ifdef CATALOGS_OVERRIDE_LANGUAGE |
|
635 DLINFO(("Overriding software language")); |
|
636 software->SetSoftwareLanguageL( KCatalogsOverrideSoftwareLanguage() ); |
|
637 #endif |
|
638 |
|
639 // Add software version |
|
640 AddSoftwareUserConfigurationL( *software, |
|
641 &CNcdRequestConfigurationSoftware::SetSoftwareVersionL, aConfigPairs, |
|
642 NcdConfigurationKeys::KSoftwareVersion() ); |
|
643 |
|
644 |
|
645 // Add unused configurations as details |
|
646 // Note: This MUST be done only after all AddUserConfigurationL calls |
|
647 AddConfigurationsToSoftwareDetailsL( *software, aConfigPairs ); |
|
648 |
|
649 aClient.AddSoftwareL( software ); |
|
650 CleanupStack::Pop( software ); |
|
651 DLTRACEOUT(("")); |
|
652 } |
|
653 |
|
654 |
|
655 // --------------------------------------------------------------------------- |
|
656 // SetHardwareConfigurationL |
|
657 // Fills the client hardware information |
|
658 // --------------------------------------------------------------------------- |
|
659 // |
|
660 void CNcdProtocol::SetHardwareConfigurationL( |
|
661 CNcdRequestConfigurationHardware& aConfig, |
|
662 RPointerArray<CNcdKeyValuePair>& aConfigPairs ) |
|
663 { |
|
664 DLTRACEIN(("")); |
|
665 /* |
|
666 TString uaProfileUri; |
|
667 |
|
668 TString manufacturer; |
|
669 TString model; |
|
670 RArray<TNcdConfigurationDisplay> displays; |
|
671 RArray<TNcdRequestCustomDetails> details; |
|
672 KFreeStorage |
|
673 |
|
674 Done: |
|
675 //TString identification; |
|
676 //TString language; |
|
677 //TString platform; |
|
678 //TString firmwareVersion; |
|
679 |
|
680 */ |
|
681 // Set device identification |
|
682 aConfig.SetHardwareIdentificationL( |
|
683 *iDeviceService->DeviceIdentificationLC() ); |
|
684 CleanupStack::PopAndDestroy(); |
|
685 |
|
686 // Set device language |
|
687 aConfig.SetHardwareLanguageL( *iDeviceService->DeviceLanguageLC() ); |
|
688 CleanupStack::PopAndDestroy(); // Device language |
|
689 |
|
690 // Set platform |
|
691 aConfig.SetHardwarePlatformL( KPlatformInfo ); |
|
692 |
|
693 // Set firmware |
|
694 aConfig.SetHardwareFirmwareL( iDeviceService->FirmwareL() ); |
|
695 |
|
696 // Set device model and manufacturer |
|
697 aConfig.SetHardwareModelL( iDeviceService->DeviceModelL() ); |
|
698 aConfig.SetHardwareManufacturerL( iDeviceService->DeviceManufacturerL() ); |
|
699 |
|
700 // Get free space for the temp drive used for downloads |
|
701 TInt64 freeSpace = FreeDiskSpaceL( CNcdProviderUtils::FileSession(), |
|
702 CNcdProviderUtils::EngineConfig().EngineTempDrive() ); |
|
703 |
|
704 // Format the integer and add to hardware details |
|
705 RBuf formatBuffer; |
|
706 CleanupClosePushL( formatBuffer ); |
|
707 formatBuffer.CreateL( 128 ); |
|
708 _LIT( KInt64, "%li" ); |
|
709 |
|
710 formatBuffer.Format( KInt64, freeSpace ); |
|
711 DLTRACE(("Adding free space to hardware details")); |
|
712 CNcdConfigurationProtocolDetailImpl* freeSpaceDetail = CreateDetailLC( |
|
713 NcdInternalConfigurationKeys::KFreeStorage(), formatBuffer ); |
|
714 aConfig.AddHardwareDetailsL( freeSpaceDetail ); |
|
715 CleanupStack::Pop( freeSpaceDetail ); |
|
716 CleanupStack::PopAndDestroy( &formatBuffer ); |
|
717 |
|
718 // Add flash-player details |
|
719 DLTRACE(("Adding flash-player to hardware details")); |
|
720 TUid flashUid; |
|
721 TCatalogsVersion flashVersion; |
|
722 TBool flashInstalled = FlashPlayerDataL( flashUid, flashVersion ); |
|
723 if ( flashInstalled ) |
|
724 { |
|
725 CNcdConfigurationProtocolDetailImpl* flashPlayerDetail = CreateDetailLC( |
|
726 NcdInternalConfigurationKeys::KFlashPlayer(), KNullDesC() ); |
|
727 CNcdConfigurationProtocolContentImpl* fpVersion = |
|
728 CNcdConfigurationProtocolContentImpl::NewLC(); |
|
729 NcdProtocolUtils::AssignDesL( |
|
730 fpVersion->iKey, KFlashPlayerVersion ); |
|
731 NcdProtocolUtils::AssignDesL( |
|
732 fpVersion->iValue, *TCatalogsVersion::ConvertLC( flashVersion ) ); |
|
733 CleanupStack::PopAndDestroy(); |
|
734 flashPlayerDetail->iContents.AppendL( fpVersion ); |
|
735 CleanupStack::Pop( fpVersion ); |
|
736 |
|
737 CNcdConfigurationProtocolContentImpl* fpUid = |
|
738 CNcdConfigurationProtocolContentImpl::NewLC(); |
|
739 NcdProtocolUtils::AssignDesL( fpUid->iKey, KFlashPlayerUid ); |
|
740 TUidName fpUidName = CleanUidName( flashUid ); |
|
741 NcdProtocolUtils::AssignDesL( fpUid->iValue, fpUidName ); |
|
742 flashPlayerDetail->iContents.AppendL( fpUid ); |
|
743 CleanupStack::Pop( fpUid ); |
|
744 |
|
745 aConfig.AddHardwareDetailsL( flashPlayerDetail ); |
|
746 CleanupStack::Pop( flashPlayerDetail ); |
|
747 } |
|
748 |
|
749 // Add IMEI if necessary |
|
750 if ( iProtocolOptions & ESendImei ) |
|
751 { |
|
752 const TDesC& imei = iDeviceService->ImeiL(); |
|
753 DLINFO(( _L("Adding IMEI: %S"), &imei )); |
|
754 CNcdConfigurationProtocolDetailImpl* imeiDetail = |
|
755 CreateDetailLC( NcdInternalConfigurationKeys::KImei(), imei ); |
|
756 aConfig.AddHardwareDetailsL( imeiDetail ); |
|
757 CleanupStack::Pop( imeiDetail ); |
|
758 } |
|
759 |
|
760 // Add all displays |
|
761 while ( AddDisplayDetailsL( aConfig, aConfigPairs ) == KErrNone ) |
|
762 { |
|
763 // Empty on purpose |
|
764 } |
|
765 |
|
766 AddProductCodeToHardwareDetailsL( aConfig, aConfigPairs ); |
|
767 AddFirmwareDetailsToHardwareDetailsL( aConfig ); |
|
768 DLTRACEOUT(("")); |
|
769 } |
|
770 |
|
771 |
|
772 |
|
773 // --------------------------------------------------------------------------- |
|
774 // Adds a configuration from the user to the request configuration |
|
775 // --------------------------------------------------------------------------- |
|
776 // |
|
777 void CNcdProtocol::AddConfigurationsToSoftwareDetailsL( |
|
778 CNcdRequestConfigurationSoftware& aConfig, |
|
779 RPointerArray<CNcdKeyValuePair>& aUserConfig ) const |
|
780 { |
|
781 DLTRACEIN(("Config count: %d", aUserConfig.Count() )); |
|
782 |
|
783 // All leftover key-value -pairs are added as details |
|
784 for ( TInt i = 0; i < aUserConfig.Count(); ++i ) |
|
785 { |
|
786 CNcdConfigurationProtocolDetailImpl* detail = |
|
787 CreateDetailLC( aUserConfig[i]->Key(), aUserConfig[i]->Value() ); |
|
788 aConfig.AddSoftwareDetailsL( detail ); |
|
789 CleanupStack::Pop( detail ); |
|
790 } |
|
791 DLTRACEOUT(("")); |
|
792 } |
|
793 |
|
794 |
|
795 // --------------------------------------------------------------------------- |
|
796 // Creates a detail object |
|
797 // --------------------------------------------------------------------------- |
|
798 // |
|
799 CNcdConfigurationProtocolDetailImpl* CNcdProtocol::CreateDetailLC( |
|
800 const TDesC& aKey, const TDesC& aValue ) const |
|
801 { |
|
802 CNcdConfigurationProtocolDetailImpl* details = |
|
803 CNcdConfigurationProtocolDetailImpl::NewLC(); |
|
804 |
|
805 delete details->iId; |
|
806 details->iId = NULL; |
|
807 details->iId = aKey.AllocL(); |
|
808 |
|
809 delete details->iValue; |
|
810 details->iValue = NULL; |
|
811 details->iValue = aValue.AllocL(); |
|
812 return details; |
|
813 } |
|
814 |
|
815 // --------------------------------------------------------------------------- |
|
816 // Adds a configuration from the user to the request configuration |
|
817 // --------------------------------------------------------------------------- |
|
818 // |
|
819 void CNcdProtocol::AddSoftwareUserConfigurationL( |
|
820 CNcdRequestConfigurationSoftware& aConfig, |
|
821 void (CNcdRequestConfigurationSoftware::*aValueSetter)( const TDesC& ), |
|
822 RPointerArray<CNcdKeyValuePair>& aUserConfig, |
|
823 const TDesC& aKey ) const |
|
824 { |
|
825 DLTRACEIN(( _L("Count: %d, Key: %S"), aUserConfig.Count(), &aKey )); |
|
826 DASSERT( aValueSetter ); |
|
827 |
|
828 TInt index = FindKey( aKey, aUserConfig ); |
|
829 if ( index != KErrNotFound ) |
|
830 { |
|
831 DLTRACE(( _L("Calling the setter with value: %S"), |
|
832 &aUserConfig[index]->Value() )); |
|
833 |
|
834 const TDesC& value = aUserConfig[index]->Value(); |
|
835 (aConfig.*aValueSetter )( value ); |
|
836 |
|
837 aUserConfig.Remove( index ); |
|
838 } |
|
839 |
|
840 DLTRACEOUT(("")); |
|
841 } |
|
842 |
|
843 |
|
844 // --------------------------------------------------------------------------- |
|
845 // Adds client capabilities to the request |
|
846 // --------------------------------------------------------------------------- |
|
847 // |
|
848 void CNcdProtocol::AddCapabilitiesL( |
|
849 CNcdRequestConfigurationSoftware& aConfig, |
|
850 RPointerArray<CNcdKeyValuePair>& aUserConfig ) const |
|
851 { |
|
852 DLTRACEIN(("")); |
|
853 TInt i = aUserConfig.Count() - 1; |
|
854 while( i >= 0 ) |
|
855 { |
|
856 // Check if the configuration is actually a capability |
|
857 if ( aUserConfig[i]->Key().Compare( |
|
858 NcdConfigurationKeys::KCapability ) == 0 ) |
|
859 { |
|
860 // Checks that the capability is supported by the engine |
|
861 if ( IsCapabilitySupported( aUserConfig[i]->Value() ) ) |
|
862 { |
|
863 DLTRACE(( _L("Adding capability: %S"), &aUserConfig[i]->Value() )); |
|
864 aConfig.AddSoftwareCapabilityL( aUserConfig[i]->Value() ); |
|
865 } |
|
866 |
|
867 // Just remove since the pairs are not owned by the array |
|
868 aUserConfig.Remove( i ); |
|
869 } |
|
870 --i; |
|
871 } |
|
872 |
|
873 DLTRACEOUT(("")); |
|
874 } |
|
875 |
|
876 |
|
877 // --------------------------------------------------------------------------- |
|
878 // Checks if the engine supports the given capability or not |
|
879 // --------------------------------------------------------------------------- |
|
880 // |
|
881 TBool CNcdProtocol::IsCapabilitySupported( const TDesC& aCapability ) const |
|
882 { |
|
883 /** |
|
884 * @ Update engine/provider's capabilities here |
|
885 */ |
|
886 DLTRACEIN(("")); |
|
887 /** |
|
888 * Check that engine supports the capability |
|
889 */ |
|
890 if ( NcdCapabilities::KSearch().Compare( aCapability ) == 0 ) |
|
891 { |
|
892 return ETrue; |
|
893 } |
|
894 else if ( NcdCapabilities::KSubscriptions().Compare( aCapability ) == 0 ) |
|
895 { |
|
896 return ETrue; |
|
897 } |
|
898 /* |
|
899 else if ( NcdCapabilities::KEmbeddedSessions().Compare( aCapability ) == 0 ) |
|
900 { |
|
901 return ETrue; |
|
902 } |
|
903 */ |
|
904 /* |
|
905 else if ( NcdCapabilities::KActivities().Compare( aCapability ) == 0 ) |
|
906 { |
|
907 return ETrue; |
|
908 } |
|
909 */ |
|
910 /* |
|
911 else if ( NcdCapabilities::KLegacySubscriptions().Compare( aCapability ) == 0 ) |
|
912 { |
|
913 return ETrue; |
|
914 } |
|
915 */ |
|
916 /* |
|
917 else if ( NcdCapabilities::KUpload().Compare( aCapability ) == 0 ) |
|
918 { |
|
919 return ETrue; |
|
920 } |
|
921 */ |
|
922 /* |
|
923 else if ( NcdCapabilities::KReDownload().Compare( aCapability ) == 0 ) |
|
924 { |
|
925 return ETrue; |
|
926 } |
|
927 */ |
|
928 /* |
|
929 else if ( NcdCapabilities::KGpsLocation().Compare( aCapability ) == 0 ) |
|
930 { |
|
931 return ETrue; |
|
932 } |
|
933 */ |
|
934 /* |
|
935 else if ( NcdCapabilities::KDelayedTransfer().Compare( aCapability ) == 0 ) |
|
936 { |
|
937 return ETrue; |
|
938 } |
|
939 */ |
|
940 /* |
|
941 else if ( NcdCapabilities::KAutoDownload().Compare( aCapability ) == 0 ) |
|
942 { |
|
943 return ETrue; |
|
944 } |
|
945 */ |
|
946 /* |
|
947 else if ( NcdCapabilities::KXmlResponseFiltering().Compare( aCapability ) == 0 ) |
|
948 { |
|
949 return ETrue; |
|
950 } |
|
951 */ |
|
952 else if ( NcdCapabilities::KInstallationReport().Compare( aCapability ) == 0 ) |
|
953 { |
|
954 return ETrue; |
|
955 } |
|
956 /* |
|
957 else if ( NcdCapabilities::KBrowseFiltering().Compare( aCapability ) == 0 ) |
|
958 { |
|
959 return ETrue; |
|
960 } |
|
961 |
|
962 else if ( NcdCapabilities::KClientReview().Compare( aCapability ) == 0 ) |
|
963 { |
|
964 return ETrue; |
|
965 } |
|
966 |
|
967 else if ( NcdCapabilities::KPromotionalEntities().Compare( aCapability ) == 0 ) |
|
968 { |
|
969 return ETrue; |
|
970 } |
|
971 */ |
|
972 else if ( NcdCapabilities::KDirectSchemeLinks().Compare( aCapability ) == 0 ) |
|
973 { |
|
974 return ETrue; |
|
975 } |
|
976 else if ( NcdCapabilities::KIndirectSchemeLinks().Compare( aCapability ) == 0 ) |
|
977 { |
|
978 return ETrue; |
|
979 } |
|
980 /* |
|
981 else if ( NcdCapabilities::KEntityRequest().Compare( aCapability ) == 0 ) |
|
982 { |
|
983 return ETrue; |
|
984 } |
|
985 |
|
986 else if ( NcdCapabilities::KDiffQuery().Compare( aCapability ) == 0 ) |
|
987 { |
|
988 return ETrue; |
|
989 } |
|
990 else if ( NcdCapabilities::KUpLevel().Compare( aCapability ) == 0 ) |
|
991 { |
|
992 return ETrue; |
|
993 } |
|
994 else if ( NcdCapabilities::KRemoteContent().Compare( aCapability ) == 0 ) |
|
995 { |
|
996 return ETrue; |
|
997 } |
|
998 else if ( NcdCapabilities::KPredefinedSearch().Compare( aCapability ) == 0 ) |
|
999 { |
|
1000 return ETrue; |
|
1001 } |
|
1002 else if ( NcdCapabilities::KPredefinedPurchase().Compare( aCapability ) == 0 ) |
|
1003 { |
|
1004 return ETrue; |
|
1005 } |
|
1006 */ |
|
1007 else if ( NcdCapabilities::KCacheExpiration().Compare( aCapability ) == 0 ) |
|
1008 { |
|
1009 return ETrue; |
|
1010 } |
|
1011 /* |
|
1012 else if ( NcdCapabilities::KMultiPurchase().Compare( aCapability ) == 0 ) |
|
1013 { |
|
1014 return ETrue; |
|
1015 } |
|
1016 */ |
|
1017 else if ( NcdCapabilities::KMultiDownload().Compare( aCapability ) == 0 ) |
|
1018 { |
|
1019 return ETrue; |
|
1020 } |
|
1021 else if ( NcdCapabilities::KBasicQueries().Compare( aCapability ) == 0 ) |
|
1022 { |
|
1023 return ETrue; |
|
1024 } |
|
1025 else if ( NcdCapabilities::KSourceScopeCookies().Compare( aCapability ) == 0 ) |
|
1026 { |
|
1027 return ETrue; |
|
1028 } |
|
1029 else if ( NcdCapabilities::KSimScopeCookies().Compare( aCapability ) == 0 ) |
|
1030 { |
|
1031 return ETrue; |
|
1032 } |
|
1033 /* |
|
1034 else if ( NcdCapabilities::KCancelPurchase().Compare( aCapability ) == 0 ) |
|
1035 { |
|
1036 return ETrue; |
|
1037 } |
|
1038 |
|
1039 else if ( NcdCapabilities::KSmsAction().Compare( aCapability ) == 0 ) |
|
1040 { |
|
1041 return ETrue; |
|
1042 } |
|
1043 */ |
|
1044 else if ( NcdCapabilities::KDrmClientDownload().Compare( aCapability ) == 0 ) |
|
1045 { |
|
1046 return ETrue; |
|
1047 } |
|
1048 /* |
|
1049 else if ( NcdCapabilities::KGiftPurchase().Compare( aCapability ) == 0 ) |
|
1050 { |
|
1051 return ETrue; |
|
1052 } |
|
1053 */ |
|
1054 else if ( NcdCapabilities::KUniversalSubscriptions().Compare( aCapability ) == 0 ) |
|
1055 { |
|
1056 return ETrue; |
|
1057 } |
|
1058 else if ( NcdCapabilities::KDownloadReport().Compare( aCapability ) == 0 ) |
|
1059 { |
|
1060 return ETrue; |
|
1061 } |
|
1062 |
|
1063 DLTRACEOUT(("")); |
|
1064 return EFalse; |
|
1065 } |
|
1066 |
|
1067 // --------------------------------------------------------------------------- |
|
1068 // AddCookiesL |
|
1069 // --------------------------------------------------------------------------- |
|
1070 // |
|
1071 TBool CNcdProtocol::AddCookiesL( const MCatalogsContext& aContext, |
|
1072 RPointerArray<MNcdConfigurationProtocolCookie>& aCookies, |
|
1073 const TDesC& aServerUri, |
|
1074 const TDesC& aNamespace ) |
|
1075 { |
|
1076 DLTRACEIN(("")); |
|
1077 |
|
1078 TBool removedCookies = EFalse; |
|
1079 |
|
1080 TInt index = FindContextData( aContext ); |
|
1081 if ( index != KErrNotFound ) |
|
1082 { |
|
1083 |
|
1084 // Get SSID |
|
1085 const TDesC8& ssid( iConfigurationManager.SsidL( aContext ) ); |
|
1086 |
|
1087 |
|
1088 // Get server details |
|
1089 MNcdServerDetails& details( |
|
1090 iConfigurationManager.ServerDetailsL( aContext, |
|
1091 aServerUri, |
|
1092 aNamespace )); |
|
1093 |
|
1094 // Remove expired cookies |
|
1095 removedCookies = details.RemoveExpiredCookies(); |
|
1096 |
|
1097 // If the cookie's scope is "sim" it has to match the given SSID |
|
1098 RPointerArray<const MNcdConfigurationProtocolCookie> cookies( |
|
1099 details.CookiesL( ssid ) ); |
|
1100 |
|
1101 CleanupClosePushL( cookies ); |
|
1102 |
|
1103 TIdentityRelation<MNcdConfigurationProtocolCookie> identity( |
|
1104 CNcdConfigurationProtocolCookie::Identity ); |
|
1105 |
|
1106 DLTRACE(( "Adding %i cookies to the request", cookies.Count() )); |
|
1107 for ( TInt i = 0; i < cookies.Count(); ++i ) |
|
1108 { |
|
1109 |
|
1110 // Only add "saveAndSend" cookies |
|
1111 if ( cookies[i]->Type().Compare( |
|
1112 NcdConfigurationProtocolCookieTypes::KSaveAndSend ) == 0 ) |
|
1113 { |
|
1114 DLTRACE(( _L("Adding cookie with key: %S"), &cookies[i]->Key() )); |
|
1115 CNcdConfigurationProtocolCookie* copy = |
|
1116 CNcdConfigurationProtocolCookie::NewLC( *cookies[i] ); |
|
1117 |
|
1118 |
|
1119 // Ensure that a matching cookie doesn't already exist |
|
1120 TInt oldCookie = aCookies.Find( copy, identity ); |
|
1121 if ( oldCookie != KErrNotFound ) |
|
1122 { |
|
1123 delete aCookies[oldCookie]; |
|
1124 aCookies[oldCookie] = copy; |
|
1125 } |
|
1126 else |
|
1127 { |
|
1128 // Add cookie to request, ownership is transferred |
|
1129 aCookies.AppendL( copy ); |
|
1130 } |
|
1131 |
|
1132 CleanupStack::Pop( copy ); |
|
1133 } |
|
1134 } |
|
1135 DLTRACE(( "Cookies added" )); |
|
1136 CleanupStack::PopAndDestroy( &cookies ); |
|
1137 |
|
1138 } |
|
1139 DLTRACEOUT(("")); |
|
1140 return removedCookies; |
|
1141 } |
|
1142 |
|
1143 |
|
1144 // --------------------------------------------------------------------------- |
|
1145 // Add cookies to the request |
|
1146 // --------------------------------------------------------------------------- |
|
1147 // |
|
1148 void CNcdProtocol::AddCookiesToRequestL( |
|
1149 CNcdRequestBase& aRequest, |
|
1150 RPointerArray<MNcdConfigurationProtocolCookie>& aCookies ) |
|
1151 { |
|
1152 for ( TInt i = 0; i < aCookies.Count(); ++i ) |
|
1153 { |
|
1154 aRequest.AddCookieL( aCookies[i] ); |
|
1155 aCookies[i] = NULL; |
|
1156 } |
|
1157 aCookies.Reset(); |
|
1158 } |
|
1159 |
|
1160 |
|
1161 // --------------------------------------------------------------------------- |
|
1162 // Add cookies to the config request |
|
1163 // --------------------------------------------------------------------------- |
|
1164 // |
|
1165 void CNcdProtocol::AddCookiesToConfigRequestL( |
|
1166 CNcdRequestConfigurationData& aConfig, |
|
1167 RPointerArray<MNcdConfigurationProtocolCookie>& aCookies ) |
|
1168 { |
|
1169 for ( TInt i = 0; i < aCookies.Count(); ++i ) |
|
1170 { |
|
1171 aConfig.AddCookieL( aCookies[i] ); |
|
1172 aCookies[i] = NULL; |
|
1173 } |
|
1174 aCookies.Reset(); |
|
1175 } |
|
1176 |
|
1177 |
|
1178 // --------------------------------------------------------------------------- |
|
1179 // Searches for the given key in the array |
|
1180 // --------------------------------------------------------------------------- |
|
1181 // |
|
1182 TInt CNcdProtocol::FindKey( const TDesC& aKey, |
|
1183 const RPointerArray<CNcdKeyValuePair>& aArray ) const |
|
1184 { |
|
1185 for ( TInt i = 0; i < aArray.Count(); ++i ) |
|
1186 { |
|
1187 if ( aArray[i]->Key().Compare( aKey ) == 0 ) |
|
1188 { |
|
1189 return i; |
|
1190 } |
|
1191 } |
|
1192 return KErrNotFound; |
|
1193 } |
|
1194 |
|
1195 |
|
1196 // --------------------------------------------------------------------------- |
|
1197 // Reads the value of the given key as TInt and removes the key |
|
1198 // --------------------------------------------------------------------------- |
|
1199 // |
|
1200 TInt CNcdProtocol::AddDisplayDetailsL( |
|
1201 CNcdRequestConfigurationHardware& aConfig, |
|
1202 RPointerArray<CNcdKeyValuePair>& aConfigPairs ) |
|
1203 { |
|
1204 DLTRACEIN(("")); |
|
1205 TInt index = FindKey( NcdConfigurationKeys::KDisplay, aConfigPairs ); |
|
1206 if ( index != KErrNotFound ) |
|
1207 { |
|
1208 DLTRACE(("Found the key")); |
|
1209 TInt disp = 0; |
|
1210 TInt width = 0; |
|
1211 TInt height = 0; |
|
1212 TInt colors = 0; |
|
1213 |
|
1214 // Interpret the value as TInts |
|
1215 TInt err = InterpretDisplayValue( aConfigPairs[index]->Value(), |
|
1216 disp, width, height, colors ); |
|
1217 |
|
1218 // Remove the pair (doesn't matter whether the conversion was |
|
1219 // successful or not |
|
1220 aConfigPairs.Remove( index ); |
|
1221 if ( err == KErrNone ) |
|
1222 { |
|
1223 DLTRACE(("Adding display details to the config")); |
|
1224 aConfig.AddHardwareDisplayL( colors, height, width ); |
|
1225 } |
|
1226 return err; |
|
1227 } |
|
1228 return KErrNotFound; |
|
1229 } |
|
1230 |
|
1231 |
|
1232 // --------------------------------------------------------------------------- |
|
1233 // Interprets a display value |
|
1234 // --------------------------------------------------------------------------- |
|
1235 // |
|
1236 TInt CNcdProtocol::InterpretDisplayValue( |
|
1237 const TDesC& aValue, TInt& aDispNumber, TInt& aWidth, |
|
1238 TInt& aHeight, TInt& aColors ) const |
|
1239 { |
|
1240 DLTRACEIN(("")); |
|
1241 TLex lex( aValue ); |
|
1242 |
|
1243 TInt err = lex.Val( aDispNumber ); |
|
1244 if ( err == KErrNone ) |
|
1245 { |
|
1246 lex.SkipSpaceAndMark(); |
|
1247 err = lex.Val( aWidth ); |
|
1248 if ( err == KErrNone ) |
|
1249 { |
|
1250 lex.SkipSpaceAndMark(); |
|
1251 err = lex.Val( aHeight ); |
|
1252 if ( err == KErrNone ) |
|
1253 { |
|
1254 lex.SkipSpaceAndMark(); |
|
1255 lex.Val( aColors ); |
|
1256 } |
|
1257 } |
|
1258 } |
|
1259 |
|
1260 DLTRACEOUT(("disp: %d, width: %d, height: %d, colors: %d", |
|
1261 aDispNumber, aWidth, aHeight, aColors )); |
|
1262 return err; |
|
1263 } |
|
1264 |
|
1265 |
|
1266 // --------------------------------------------------------------------------- |
|
1267 // Reads the value of the given key and and removes the config pair |
|
1268 // --------------------------------------------------------------------------- |
|
1269 // |
|
1270 void CNcdProtocol::AddProductCodeToHardwareDetailsL( |
|
1271 CNcdRequestConfigurationHardware& aConfig, |
|
1272 RPointerArray<CNcdKeyValuePair>& aConfigPairs ) |
|
1273 { |
|
1274 DLTRACEIN(("")); |
|
1275 |
|
1276 // First try to get the product code from the device service. |
|
1277 // If device service gives the product code, then always use it. |
|
1278 // If device service does not give the product code, then check |
|
1279 // if product code is given through the NCD API and use it if |
|
1280 // available. |
|
1281 |
|
1282 // Get possible product code from the device service. |
|
1283 HBufC* productCode( iDeviceService->ProductCodeLC() ); |
|
1284 |
|
1285 // Get the index value for the possible product code in |
|
1286 // config pair array. |
|
1287 TInt index( |
|
1288 FindKey( NcdConfigurationKeys::KDeviceProductCode, |
|
1289 aConfigPairs ) ); |
|
1290 |
|
1291 // Check if the config pair array contains the product code. |
|
1292 if ( index != KErrNotFound ) |
|
1293 { |
|
1294 DLINFO(("Product code given in config pair.")); |
|
1295 if ( !productCode ) |
|
1296 { |
|
1297 DLINFO(("Use config pair product code")); |
|
1298 |
|
1299 // Product code was not gotten from device service. |
|
1300 // So, use the config pair value. |
|
1301 productCode = aConfigPairs[ index ]->Value().AllocLC(); |
|
1302 } |
|
1303 |
|
1304 // Remove the pair is required. This way the config pair will not |
|
1305 // be included into the software details element in the server requests. |
|
1306 aConfigPairs.Remove( index ); |
|
1307 } |
|
1308 |
|
1309 // Check if product code was gotten from device service or from |
|
1310 // the config pair. |
|
1311 if ( productCode ) |
|
1312 { |
|
1313 DLINFO(( _L("Adding productCode: %S"), productCode )); |
|
1314 |
|
1315 // Add the hardware detail because value exists. |
|
1316 CNcdConfigurationProtocolDetailImpl* productCodeDetail( |
|
1317 CreateDetailLC( NcdConfigurationKeys::KDeviceProductCode(), |
|
1318 *productCode ) ); |
|
1319 aConfig.AddHardwareDetailsL( productCodeDetail ); |
|
1320 CleanupStack::Pop( productCodeDetail ); |
|
1321 |
|
1322 CleanupStack::PopAndDestroy( productCode ); |
|
1323 } |
|
1324 } |
|
1325 |
|
1326 |
|
1327 // --------------------------------------------------------------------------- |
|
1328 // Creates a new context data object or returns an existing one |
|
1329 // --------------------------------------------------------------------------- |
|
1330 // |
|
1331 CNcdProtocol::CContextData& CNcdProtocol::CreateContextDataL( |
|
1332 const MCatalogsContext& aContext ) |
|
1333 { |
|
1334 DLTRACEIN(("")); |
|
1335 TInt index = FindContextData( aContext ); |
|
1336 if ( index == KErrNotFound ) |
|
1337 { |
|
1338 // Create a new session handler |
|
1339 CNcdSessionHandler* sessionHandler = CNcdSessionHandler::NewL(); |
|
1340 |
|
1341 CleanupStack::PushL( sessionHandler ); |
|
1342 |
|
1343 |
|
1344 // Create a new context data |
|
1345 // owns session and cookie handlers |
|
1346 CContextData* newData = new( ELeave ) CContextData( aContext, |
|
1347 sessionHandler ); |
|
1348 |
|
1349 CleanupStack::Pop( sessionHandler ); |
|
1350 CleanupStack::PushL( newData ); |
|
1351 |
|
1352 iContexts.AppendL( newData ); |
|
1353 CleanupStack::Pop( newData ); |
|
1354 index = iContexts.Count() - 1; |
|
1355 } |
|
1356 DLTRACEOUT(( "index: %d", index )); |
|
1357 return *iContexts[index]; |
|
1358 } |
|
1359 |
|
1360 |
|
1361 // --------------------------------------------------------------------------- |
|
1362 // Searches for the given context in contexts |
|
1363 // --------------------------------------------------------------------------- |
|
1364 // |
|
1365 TInt CNcdProtocol::FindContextData( const MCatalogsContext& aContext ) const |
|
1366 { |
|
1367 TIdentityRelation<CContextData> match( CNcdProtocol::MatchContextDatas ); |
|
1368 CContextData data( aContext, NULL ); |
|
1369 |
|
1370 return iContexts.Find( &data, match ); |
|
1371 } |
|
1372 |
|
1373 |
|
1374 // --------------------------------------------------------------------------- |
|
1375 // Compares two contexts |
|
1376 // --------------------------------------------------------------------------- |
|
1377 // |
|
1378 TBool CNcdProtocol::MatchContextDatas( const CContextData& aFirst, |
|
1379 const CContextData& aSecond ) |
|
1380 { |
|
1381 return aFirst.FamilyId() == aSecond.FamilyId(); |
|
1382 } |
|
1383 |
|
1384 |
|
1385 // --------------------------------------------------------------------------- |
|
1386 // Gets flash player data |
|
1387 // --------------------------------------------------------------------------- |
|
1388 // |
|
1389 TBool CNcdProtocol::FlashPlayerDataL( TUid& aUid, TCatalogsVersion& aVersion ) |
|
1390 { |
|
1391 DLTRACEIN(("")); |
|
1392 |
|
1393 TUid flashUid = iDeviceService->FlashPlayerUidL(); |
|
1394 |
|
1395 if( flashUid.iUid == NULL ) |
|
1396 { |
|
1397 return EFalse; |
|
1398 } |
|
1399 |
|
1400 TCatalogsVersion flashVersion; |
|
1401 MNcdInstallationService& installationService = |
|
1402 CNcdProviderUtils::InstallationServiceL(); |
|
1403 TInt err = installationService.ApplicationVersion( flashUid, flashVersion ); |
|
1404 |
|
1405 if ( err != KErrNone ) |
|
1406 { |
|
1407 DLTRACEOUT(("Error occured while retrieving flash player version")) |
|
1408 return EFalse; |
|
1409 } |
|
1410 |
|
1411 aUid = flashUid; |
|
1412 aVersion = flashVersion; |
|
1413 |
|
1414 DLTRACEOUT(("Flash player uid: %d, version: %d.%d.%d", |
|
1415 aUid.iUid, |
|
1416 aVersion.iMajor, |
|
1417 aVersion.iMinor, |
|
1418 aVersion.iBuild)); |
|
1419 return ETrue; |
|
1420 } |
|
1421 |
|
1422 // --------------------------------------------------------------------------- |
|
1423 // Add additional firmware information |
|
1424 // --------------------------------------------------------------------------- |
|
1425 // |
|
1426 void CNcdProtocol::AddFirmwareDetailsToHardwareDetailsL( |
|
1427 CNcdRequestConfigurationHardware& aConfig ) |
|
1428 { |
|
1429 DLTRACEIN(("")); |
|
1430 RBuf buf; |
|
1431 buf.CreateL( MNcdDeviceService::KFirmwareDetailMaxLength ); |
|
1432 CleanupClosePushL( buf ); |
|
1433 |
|
1434 RFs& fs = CNcdProviderUtils::FileSession(); |
|
1435 |
|
1436 iDeviceService->GetProductType( buf, fs ); |
|
1437 AddHardwareDetailL( aConfig, KProductType, buf ); |
|
1438 buf.Zero(); |
|
1439 |
|
1440 iDeviceService->GetFirmwareId( buf, fs ); |
|
1441 AddHardwareDetailL( aConfig, KFirmwareId, buf ); |
|
1442 buf.Zero(); |
|
1443 |
|
1444 iDeviceService->GetFirmwareVersion1( buf ); |
|
1445 AddHardwareDetailL( aConfig, KFirmwareVersion1, buf ); |
|
1446 buf.Zero(); |
|
1447 |
|
1448 iDeviceService->GetFirmwareVersion2( buf ); |
|
1449 AddHardwareDetailL( aConfig, KFirmwareVersion2, buf ); |
|
1450 buf.Zero(); |
|
1451 |
|
1452 iDeviceService->GetFirmwareVersion3( buf, fs ); |
|
1453 AddHardwareDetailL( aConfig, KFirmwareVersion3, buf ); |
|
1454 buf.Zero(); |
|
1455 |
|
1456 AddHardwareDetailL( aConfig, KSimLockStatus, KFalseAsZero ); |
|
1457 |
|
1458 CleanupStack::PopAndDestroy( &buf ); |
|
1459 } |
|
1460 |
|
1461 |
|
1462 // --------------------------------------------------------------------------- |
|
1463 // Helper method for adding a detail to hardware details |
|
1464 // --------------------------------------------------------------------------- |
|
1465 // |
|
1466 void CNcdProtocol::AddHardwareDetailL( |
|
1467 CNcdRequestConfigurationHardware& aConfig, |
|
1468 const TDesC& aKey, |
|
1469 const TDesC& aValue ) |
|
1470 { |
|
1471 if ( aValue.Length() ) |
|
1472 { |
|
1473 CNcdConfigurationProtocolDetailImpl* detail( |
|
1474 CreateDetailLC( aKey, |
|
1475 aValue ) ); |
|
1476 aConfig.AddHardwareDetailsL( detail ); |
|
1477 CleanupStack::Pop( detail ); |
|
1478 } |
|
1479 } |