54 #include "pmodtiterator.h" |
55 #include "pmodtiterator.h" |
55 #include "contentpublisher.h" |
56 #include "contentpublisher.h" |
56 #include "xnplugindefs.h" |
57 #include "xnplugindefs.h" |
57 #include "ainativeuiplugins.h" |
58 #include "ainativeuiplugins.h" |
58 |
59 |
|
60 // Constants |
|
61 const TInt KOneSecondInMicroS = 1000*1000; |
|
62 _LIT8( KData, "data" ); |
59 |
63 |
60 using namespace AiXmlUiController; |
64 using namespace AiXmlUiController; |
61 |
|
62 const TInt KOneSecondInMicroS = 1000*1000; |
|
63 const TInt KAI2CrKeyIncrementBy2 = 2; |
|
64 |
|
65 typedef TBuf<32> TNamespace; |
|
66 |
|
67 _LIT( KSettingsDummyData, "" ); |
|
68 |
65 |
69 // ======== LOCAL FUNCTIONS ======== |
66 // ======== LOCAL FUNCTIONS ======== |
70 // ---------------------------------------------------------------------------- |
67 // ---------------------------------------------------------------------------- |
71 // ResolveEventParameters() |
68 // ResolveEventParameters() |
72 // ---------------------------------------------------------------------------- |
69 // ---------------------------------------------------------------------------- |
283 // ---------------------------------------------------------------------------- |
280 // ---------------------------------------------------------------------------- |
284 // CXmlUiController::LoadUIDefinition() |
281 // CXmlUiController::LoadUIDefinition() |
285 // ---------------------------------------------------------------------------- |
282 // ---------------------------------------------------------------------------- |
286 // |
283 // |
287 void CXmlUiController::LoadUIDefinitionL() |
284 void CXmlUiController::LoadUIDefinitionL() |
288 { |
285 { |
289 // No implementation required |
|
290 } |
|
291 |
|
292 // ---------------------------------------------------------------------------- |
|
293 // CXmlUiController::GetPluginsL() |
|
294 // ---------------------------------------------------------------------------- |
|
295 // |
|
296 void CXmlUiController::GetPluginsL( RAiPublisherInfoArray& /*aPlugins*/ ) |
|
297 { |
|
298 // No implementation required |
|
299 } |
|
300 |
|
301 // ---------------------------------------------------------------------------- |
|
302 // CXmlUiController::PublisherInfo() |
|
303 // ---------------------------------------------------------------------------- |
|
304 // |
|
305 void CXmlUiController::PublisherInfoL( RAiPublisherInfoArray& aPlugins ) |
|
306 { |
|
307 // This method returns plugins with namespace KNativeUiNamespace |
|
308 if ( iRunningAsMain ) |
|
309 { |
|
310 // This plugin is used to publish data on secondary ui controller side |
|
311 TAiPublisherInfo deviceStatus; |
|
312 deviceStatus.iUid = KDeviceStatusPluginUid; |
|
313 deviceStatus.iName.Copy( KDeviceStatusPluginName ); |
|
314 deviceStatus.iNamespace.Copy( KNativeUiNamespace ); |
|
315 |
|
316 aPlugins.AppendL( deviceStatus ); |
|
317 } |
|
318 } |
286 } |
319 |
287 |
320 // ---------------------------------------------------------------------------- |
288 // ---------------------------------------------------------------------------- |
321 // CXmlUiController::PublisherInfoL() |
289 // CXmlUiController::PublisherInfoL() |
322 // ---------------------------------------------------------------------------- |
290 // ---------------------------------------------------------------------------- |
323 // |
291 // |
324 void CXmlUiController::PublisherInfoL( CXnNodeAppIf& aSource, |
292 void CXmlUiController::PublisherInfoL( CXnNodeAppIf& aSource, |
325 TAiPublisherInfo& aInfo ) |
293 THsPublisherInfo& aInfo ) |
326 { |
294 { |
327 // Fetch uid from XML and convert it to TUid |
295 // Fetch uid from XML and convert it to TUid |
328 const TDesC8* uid( PropertyValue( aSource, |
296 const TDesC8* uid( PropertyValue( aSource, |
329 AiUiDef::xml::property::KValue ) ); |
297 AiUiDef::xml::property::KValue ) ); |
330 |
298 |
331 if ( !uid ) |
299 if ( !uid ) |
332 { |
300 { |
333 return; |
301 return; |
334 } |
302 } |
335 |
303 |
336 _LIT8( KPrefix, "0x" ); |
304 _LIT8( KPrefix, "0x" ); |
337 |
305 |
338 const TInt pos( uid->FindF( KPrefix ) ); |
306 const TInt pos( uid->FindF( KPrefix ) ); |
339 |
307 |
|
308 TInt32 uidValue( 0 ); |
|
309 |
340 if( pos != KErrNotFound ) |
310 if( pos != KErrNotFound ) |
341 { |
311 { |
342 TLex8 lex( uid->Mid( pos + KPrefix().Length() ) ); |
312 TLex8 lex( uid->Mid( pos + KPrefix().Length() ) ); |
343 |
313 |
344 // Hex parsing needs unsigned int |
314 // Hex parsing needs unsigned int |
345 TUint32 value = 0; |
315 TUint32 value( 0 ); |
346 const TInt parseResult = lex.Val( value, EHex ); |
316 TInt err( lex.Val( value, EHex ) ); |
347 |
317 |
348 if ( parseResult == KErrNone ) |
318 if ( err == KErrNone ) |
349 { |
319 { |
350 TInt32 value32( value ); |
320 uidValue = value; |
351 |
|
352 aInfo.iUid = TUid::Uid( value32 ); |
|
353 } |
321 } |
354 } |
322 } |
355 |
323 |
356 // Fetch plug-in name from XML |
324 // Fetch plug-in name from XML |
357 HBufC* pluginName( PropertyValueL( aSource, |
325 HBufC* name( PropertyValueL( aSource, AiUiDef::xml::property::KName ) ); |
358 AiUiDef::xml::property::KName ) ); |
326 |
359 |
327 TUid pluginuid( TUid::Uid( uidValue ) ); |
360 CleanupStack::PushL( pluginName ); |
328 |
361 |
329 aInfo = THsPublisherInfo( pluginuid, *name, aSource.Namespace() ); |
362 if ( pluginName ) |
330 |
363 { |
331 delete name; |
364 aInfo.iName.Copy( *pluginName ); |
332 name = NULL; |
365 } |
|
366 |
|
367 CleanupStack::PopAndDestroy( pluginName ); |
|
368 |
|
369 aInfo.iNamespace.Copy( aSource.Namespace() ); |
|
370 } |
333 } |
371 |
334 |
372 // ---------------------------------------------------------------------------- |
335 // ---------------------------------------------------------------------------- |
373 // CXmlUiController::GetSettingsL() |
336 // CXmlUiController::GetSettingsL() |
374 // ---------------------------------------------------------------------------- |
337 // |
375 // |
338 // ---------------------------------------------------------------------------- |
376 void CXmlUiController::GetSettingsL( const TAiPublisherInfo& aPubInfo, |
339 // |
|
340 void CXmlUiController::GetSettingsL( const THsPublisherInfo& aPublisherInfo, |
377 RAiSettingsItemArray& aSettings ) |
341 RAiSettingsItemArray& aSettings ) |
378 { |
342 { |
379 if ( aPubInfo.iNamespace == KNativeUiNamespace ) |
343 if ( aPublisherInfo.Namespace() == KNativeUiNamespace ) |
380 { |
344 { |
381 // This controller doesn't provide settings for native ui namespace |
345 // This controller doesn't provide settings for native ui namespace |
382 return; |
346 return; |
383 } |
347 } |
384 |
348 |
385 const TDesC& classId( iNodeIdGenerator->SettingsNodeIdL( aPubInfo ) ); |
349 const TDesC& classId( |
386 |
350 iNodeIdGenerator->SettingsNodeIdL( aPublisherInfo ) ); |
387 TNamespace ns; |
351 |
388 |
352 TBuf< KHsPublisherNamespaceMaxLength > ns; |
389 ns.Copy( aPubInfo.iNamespace ); |
353 |
390 |
354 ns.Copy( aPublisherInfo.Namespace() ); |
|
355 |
391 // Find settings nodes |
356 // Find settings nodes |
392 RPointerArray< CXnNodeAppIf > nodes( |
357 RPointerArray< CXnNodeAppIf > nodes( |
393 UiEngineL()->FindNodeByClassL( classId, ns ) ); |
358 UiEngineL()->FindNodeByClassL( classId, ns ) ); |
394 |
359 |
395 CleanupClosePushL( nodes ); |
360 CleanupClosePushL( nodes ); |
436 CleanupStack::PopAndDestroy( value ); |
401 CleanupStack::PopAndDestroy( value ); |
437 } |
402 } |
438 |
403 |
439 CleanupStack::PopAndDestroy( &nodes ); |
404 CleanupStack::PopAndDestroy( &nodes ); |
440 |
405 |
441 GetSettingsFromCRL( aPubInfo, aSettings ); |
406 GetContentModelL( aPublisherInfo, aSettings ); |
442 GetContentModelL( aPubInfo, aSettings ); |
|
443 } |
|
444 |
|
445 // ---------------------------------------------------------------------------- |
|
446 // CXmlUiController::GetSettingsFromCRL() |
|
447 // ---------------------------------------------------------------------------- |
|
448 // |
|
449 void CXmlUiController::GetSettingsFromCRL( const TAiPublisherInfo& aPubInfo, |
|
450 RAiSettingsItemArray &aPluginSettings ) |
|
451 { |
|
452 if ( aPubInfo.iNamespace == KNativeUiNamespace ) |
|
453 { |
|
454 // This controller doesn't provide settings for native ui namespace |
|
455 return; |
|
456 } |
|
457 |
|
458 /* |
|
459 * The settings are stored in the cenrep starting from 0x1000. |
|
460 * 0x1000 is the name of the plugin which this setting belongs to (for example Settings/Shortcut) |
|
461 * 0x1001 is the id of the setting (for example 1) |
|
462 * 0x1002 is the value of the setting (for example localapp:0x012345678) |
|
463 * |
|
464 * So three keys per setting. |
|
465 * |
|
466 * Settings from cenrep override those from XML |
|
467 */ |
|
468 |
|
469 TUint32 crKey( KAIPluginSettingsKeyRangeStart ); |
|
470 |
|
471 TBool moreSettings( ETrue ); |
|
472 |
|
473 HBufC* pluginId = HBufC::NewLC( |
|
474 NCentralRepositoryConstants::KMaxUnicodeStringLength ); |
|
475 |
|
476 HBufC* settingValue = HBufC::NewLC( |
|
477 NCentralRepositoryConstants::KMaxUnicodeStringLength ); |
|
478 |
|
479 HBufC* settingKey = HBufC::NewLC( |
|
480 NCentralRepositoryConstants::KMaxUnicodeStringLength ); |
|
481 |
|
482 TPtr pluginIdPtr( pluginId->Des() ); |
|
483 TPtr settingValuePtr( settingValue->Des() ); |
|
484 TPtr settingKeyPtr( settingKey->Des() ); |
|
485 |
|
486 TInt32 settingId( 0 ); |
|
487 |
|
488 TInt err( KErrNone ); |
|
489 TBool settingFound( EFalse ); |
|
490 |
|
491 while( moreSettings ) |
|
492 { |
|
493 settingFound = EFalse; |
|
494 |
|
495 pluginIdPtr.Zero(); |
|
496 settingValuePtr.Zero(); |
|
497 settingKeyPtr.Zero(); |
|
498 |
|
499 //Get the name of plugin with the Settings/ prefix |
|
500 err = iAISettingsRepository->Get( crKey++, pluginIdPtr ); |
|
501 |
|
502 // remove the Settings/ prefix if it is located at the start of the string |
|
503 if( pluginIdPtr.FindC( AiUiDef::xml::propertyClass::KSettings ) == 0 ) |
|
504 { |
|
505 pluginIdPtr.Delete( 0, |
|
506 AiUiDef::xml::id::KSettingsIdSeparator().Length() + |
|
507 AiUiDef::xml::propertyClass::KSettings().Length() ); |
|
508 } |
|
509 |
|
510 // does the setting belong to this plugin |
|
511 if( err == KErrNone && pluginIdPtr == aPubInfo.iName ) |
|
512 { |
|
513 // Get the settings id |
|
514 err = iAISettingsRepository->Get( crKey++, settingKeyPtr ); |
|
515 |
|
516 if( err == KErrNone ) |
|
517 { |
|
518 err = AiUtility::ParseInt( settingId,settingKeyPtr ); |
|
519 } |
|
520 |
|
521 if( err == KErrNone ) |
|
522 { |
|
523 // Get the actual value of the setting |
|
524 err = iAISettingsRepository->Get( crKey++, settingValuePtr ); |
|
525 |
|
526 // Ignore possible placeholder data in cenrep |
|
527 if( err == KErrNone && settingValuePtr.Compare( KSettingsDummyData ) != 0 ) |
|
528 { |
|
529 // Try to find an existing setting for this |
|
530 for( TInt j = 0; j < aPluginSettings.Count(); j++ ) |
|
531 { |
|
532 MAiPluginSettings* setting( aPluginSettings[j] ); |
|
533 MAiPluginSettingsItem& item( setting->AiPluginSettingsItem() ); |
|
534 |
|
535 // Existing setting found => replace it |
|
536 if( item.Key() == settingId && item.PublisherId() == aPubInfo.iUid ) |
|
537 { |
|
538 item.SetValueL( settingValuePtr, EFalse ); |
|
539 settingFound = ETrue; |
|
540 break; |
|
541 } |
|
542 } |
|
543 |
|
544 // Existing setting not found => append new one ONLY if we |
|
545 // are dealing with the icon overrides or toolbar shortcuts |
|
546 if( !settingFound && |
|
547 ( ( settingId & KScutFlagBitToolbarShortcut ) || |
|
548 ( settingId & KScutFlagBitIconOverride ) ) ) |
|
549 { |
|
550 MAiPluginSettings* settings( AiUtility::CreatePluginSettingsL() ); |
|
551 CleanupDeletePushL( settings ); |
|
552 |
|
553 MAiPluginSettingsItem& item( settings->AiPluginSettingsItem() ); |
|
554 |
|
555 item.SetPublisherId( aPubInfo.iUid ); |
|
556 item.SetKey( settingId ); |
|
557 item.SetValueL( settingValuePtr, EFalse ); |
|
558 |
|
559 aPluginSettings.Append( settings ); |
|
560 CleanupStack::Pop( settings ); |
|
561 } |
|
562 } |
|
563 } |
|
564 else |
|
565 { |
|
566 // no settings id found => invalid settings in cenrep |
|
567 __PRINT8( __DBG_FORMAT8("CXmlUiController::GetSettingsFromCRL: ERROR: invalid settings. key: %d pluginname: %S id: %d value: %S"), crKey, pluginId, settingId, settingValue ); |
|
568 } |
|
569 } |
|
570 else if( err != KErrNone ) |
|
571 { |
|
572 // name of the plugin not found => no more settings |
|
573 moreSettings = EFalse; |
|
574 } |
|
575 else |
|
576 { |
|
577 // not the correct setting for this plugin |
|
578 crKey += KAI2CrKeyIncrementBy2; |
|
579 } |
|
580 } |
|
581 |
|
582 CleanupStack::PopAndDestroy( 3, pluginId ); // settingValue, settingKey |
|
583 } |
407 } |
584 |
408 |
585 // ---------------------------------------------------------------------------- |
409 // ---------------------------------------------------------------------------- |
586 // CXmlUiController::GetContentModelL() |
410 // CXmlUiController::GetContentModelL() |
587 // ---------------------------------------------------------------------------- |
411 // ---------------------------------------------------------------------------- |
588 // |
412 // |
589 // ContentModelL() |
413 // ContentModelL() |
590 void CXmlUiController::GetContentModelL( const TAiPublisherInfo& aPubInfo, |
414 void CXmlUiController::GetContentModelL( const THsPublisherInfo& aPublisherInfo, |
591 RAiSettingsItemArray& aSettings ) |
415 RAiSettingsItemArray& aSettings ) |
592 { |
416 { |
593 if ( aPubInfo.iNamespace == KNativeUiNamespace ) |
417 if ( aPublisherInfo.Namespace() == KNativeUiNamespace ) |
594 { |
418 { |
595 // This controller doesn't provide content model for native ui namespace |
419 // This controller doesn't provide content model for native ui namespace |
596 return; |
420 return; |
597 } |
421 } |
598 |
422 |
599 // Find the node for the publisher |
423 // Find the node for the publisher |
600 // TODO Does not work if widget is in view |
424 // TODO Does not work if widget is in view |
601 RPointerArray<CXnNodeAppIf> list( |
425 RPointerArray<CXnNodeAppIf> list( |
602 UiEngineL()->FindContentSourceNodesL( aPubInfo.iNamespace ) ); |
426 UiEngineL()->FindContentSourceNodesL( aPublisherInfo.Namespace() ) ); |
|
427 |
603 CleanupClosePushL( list ); |
428 CleanupClosePushL( list ); |
604 |
429 |
605 CXnNodeAppIf* publisherNode( NULL ); |
430 CXnNodeAppIf* publisherNode( NULL ); |
606 |
431 |
607 if ( list.Count() > 0 ) |
432 if ( list.Count() > 0 ) |
791 { |
618 { |
792 iFwEventHandler = &aFwEventHandler; |
619 iFwEventHandler = &aFwEventHandler; |
793 } |
620 } |
794 |
621 |
795 // ---------------------------------------------------------------------------- |
622 // ---------------------------------------------------------------------------- |
796 // CXmlUiController::RemovePluginFromUI() |
623 // CXmlUiController::SetStateHandler() |
797 // ---------------------------------------------------------------------------- |
624 // ---------------------------------------------------------------------------- |
798 // |
625 // |
799 void CXmlUiController::RemovePluginFromUI( MAiPropertyExtension& aPlugin ) |
626 void CXmlUiController::SetStateHandler( MAiFwStateHandler& aFwStateHandler ) |
800 { |
627 { |
801 CContentRenderer* contentRenderer = |
628 iFwStateHandler = &aFwStateHandler; |
802 static_cast< CContentRenderer* >( iObserver ); |
|
803 |
|
804 if ( contentRenderer ) |
|
805 { |
|
806 contentRenderer->CleanPluginFromUi( aPlugin ); |
|
807 } |
|
808 } |
629 } |
809 |
630 |
810 // ---------------------------------------------------------------------------- |
631 // ---------------------------------------------------------------------------- |
811 // CXmlUiController::FwEventHandler() |
632 // CXmlUiController::FwEventHandler() |
812 // ---------------------------------------------------------------------------- |
633 // ---------------------------------------------------------------------------- |
813 // |
634 // |
814 MAiFwEventHandler* CXmlUiController::FwEventHandler() const |
635 MAiFwEventHandler* CXmlUiController::FwEventHandler() const |
815 { |
636 { |
816 return iFwEventHandler; |
637 return iFwEventHandler; |
|
638 } |
|
639 |
|
640 // ---------------------------------------------------------------------------- |
|
641 // CXmlUiController::FwStateHandler() |
|
642 // ---------------------------------------------------------------------------- |
|
643 // |
|
644 MAiFwStateHandler* CXmlUiController::FwStateHandler() const |
|
645 { |
|
646 return iFwStateHandler; |
817 } |
647 } |
818 |
648 |
819 // ---------------------------------------------------------------------------- |
649 // ---------------------------------------------------------------------------- |
820 // CXmlUiController::MainInterface() |
650 // CXmlUiController::MainInterface() |
821 // ---------------------------------------------------------------------------- |
651 // ---------------------------------------------------------------------------- |
855 __ASSERT_ALWAYS( iAppUi, Panic(ECriticalPointerNull) ); |
685 __ASSERT_ALWAYS( iAppUi, Panic(ECriticalPointerNull) ); |
856 return *iAppUi->CoeEnv(); |
686 return *iAppUi->CoeEnv(); |
857 } |
687 } |
858 |
688 |
859 // ---------------------------------------------------------------------------- |
689 // ---------------------------------------------------------------------------- |
860 // CXmlUiController::SetUiFrameworkObserver() |
|
861 // ---------------------------------------------------------------------------- |
|
862 // |
|
863 void CXmlUiController::SetUiFrameworkObserver( |
|
864 MAiUiFrameworkObserver& aObserver ) |
|
865 { |
|
866 iUiFrameworkObserver = &aObserver; |
|
867 } |
|
868 |
|
869 // ---------------------------------------------------------------------------- |
|
870 // CXmlUiController::IsMenuOpen() |
690 // CXmlUiController::IsMenuOpen() |
871 // ---------------------------------------------------------------------------- |
691 // ---------------------------------------------------------------------------- |
872 // |
692 // |
873 TBool CXmlUiController::IsMenuOpen() |
693 TBool CXmlUiController::IsMenuOpen() |
874 { |
694 { |
875 TBool menuOpen( EFalse ); |
695 return iAppUi->IsDisplayingMenuOrDialog(); |
876 TRAP_IGNORE( menuOpen = UiEngineL()->IsMenuDisplaying() ); |
|
877 return menuOpen; |
|
878 } |
|
879 |
|
880 // ---------------------------------------------------------------------------- |
|
881 // CXmlUiController::UiFrameworkObserver() |
|
882 // ---------------------------------------------------------------------------- |
|
883 // |
|
884 MAiUiFrameworkObserver* CXmlUiController::UiFrameworkObserver() const |
|
885 { |
|
886 return iUiFrameworkObserver; |
|
887 } |
696 } |
888 |
697 |
889 // ---------------------------------------------------------------------------- |
698 // ---------------------------------------------------------------------------- |
890 // CXmlUiController::HandleUiEvent() |
699 // CXmlUiController::HandleUiEvent() |
891 // ---------------------------------------------------------------------------- |
700 // ---------------------------------------------------------------------------- |