50 #include "aifweventhandler.h" |
50 #include "aifweventhandler.h" |
51 #include "debug.h" |
51 #include "debug.h" |
52 #include "aiconsts.h" |
52 #include "aiconsts.h" |
53 #include "contentrenderer.h" |
53 #include "contentrenderer.h" |
54 #include "xmluicontrollerpanic.h" |
54 #include "xmluicontrollerpanic.h" |
55 #include "pmodtiterator.h" |
|
56 #include "contentpublisher.h" |
55 #include "contentpublisher.h" |
57 #include "xnplugindefs.h" |
56 #include "xnplugindefs.h" |
58 #include "ainativeuiplugins.h" |
57 #include "ainativeuiplugins.h" |
59 |
58 |
60 // Constants |
59 // Constants |
61 const TInt KOneSecondInMicroS = 1000*1000; |
60 const TInt KOneSecondInMicroS = 1000*1000; |
62 _LIT8( KData, "data" ); |
61 |
63 |
62 // Macros |
|
63 #define IS_KNOWN_CONTENT_MODEL_ELEMENT( e ) \ |
|
64 ( e == AiUiDef::xml::element::KImage || \ |
|
65 e == AiUiDef::xml::element::KText || \ |
|
66 e == AiUiDef::xml::element::KAnimation || \ |
|
67 e == AiUiDef::xml::element::KTextEditor || \ |
|
68 e == AiUiDef::xml::element::KTitle || \ |
|
69 e == AiUiDef::xml::element::KData ) |
|
70 |
64 using namespace AiXmlUiController; |
71 using namespace AiXmlUiController; |
65 |
72 |
66 // ======== LOCAL FUNCTIONS ======== |
73 // ======== LOCAL FUNCTIONS ======== |
|
74 // ---------------------------------------------------------------------------- |
|
75 // BuildModelL() |
|
76 // ---------------------------------------------------------------------------- |
|
77 // |
|
78 static void BuildModelL( CXnNodeAppIf* aParent, const TDesC8& aKey, |
|
79 const TDesC8& aNs, RPointerArray< CXnNodeAppIf >& aModel ) |
|
80 { |
|
81 if ( !aParent || aParent->Namespace() != aNs ) |
|
82 { |
|
83 // No parent or traversed out from the namespace |
|
84 return; |
|
85 } |
|
86 |
|
87 if ( aParent->Type()->Type() == XnPropertyNames::action::KProperty ) |
|
88 { |
|
89 CXnProperty* prop( |
|
90 aParent->GetPropertyL( XnPropertyNames::common::KClass ) ); |
|
91 |
|
92 if ( prop ) |
|
93 { |
|
94 const TDesC8& value( prop->StringValue() ); |
|
95 |
|
96 if ( value.Find( aKey ) != KErrNotFound ) |
|
97 { |
|
98 aModel.AppendL( aParent ); |
|
99 } |
|
100 } |
|
101 } |
|
102 |
|
103 RPointerArray< CXnNodeAppIf > children( aParent->ChildrenL() ); |
|
104 CleanupClosePushL( children ); |
|
105 |
|
106 for ( TInt i = 0; i < children.Count(); i++ ) |
|
107 { |
|
108 // Recurse children |
|
109 BuildModelL( children[i], aKey, aNs, aModel ); |
|
110 } |
|
111 |
|
112 CleanupStack::PopAndDestroy( &children ); |
|
113 } |
|
114 |
67 // ---------------------------------------------------------------------------- |
115 // ---------------------------------------------------------------------------- |
68 // ResolveEventParameters() |
116 // ResolveEventParameters() |
69 // ---------------------------------------------------------------------------- |
117 // ---------------------------------------------------------------------------- |
70 // |
118 // |
71 static void ResolveEventParameters( const TDesC8& aEventString, |
119 static void ResolveEventParameters( const TDesC8& aEventString, |
401 |
449 |
402 // ---------------------------------------------------------------------------- |
450 // ---------------------------------------------------------------------------- |
403 // CXmlUiController::GetContentModelL() |
451 // CXmlUiController::GetContentModelL() |
404 // ---------------------------------------------------------------------------- |
452 // ---------------------------------------------------------------------------- |
405 // |
453 // |
406 // ContentModelL() |
|
407 void CXmlUiController::GetContentModelL( const THsPublisherInfo& aPublisherInfo, |
454 void CXmlUiController::GetContentModelL( const THsPublisherInfo& aPublisherInfo, |
408 RAiSettingsItemArray& aSettings ) |
455 RAiSettingsItemArray& aSettings ) |
409 { |
456 { |
410 if ( aPublisherInfo.Namespace() == KNativeUiNamespace ) |
457 if ( aPublisherInfo.Namespace() == KNativeUiNamespace ) |
411 { |
458 { |
412 // This controller doesn't provide content model for native ui namespace |
459 // This controller doesn't provide content model for native ui namespace |
413 return; |
460 return; |
414 } |
461 } |
415 |
462 |
416 // Find the node for the publisher |
463 // Find the node for the publisher |
417 // TODO Does not work if widget is in view |
|
418 RPointerArray<CXnNodeAppIf> list( |
464 RPointerArray<CXnNodeAppIf> list( |
419 UiEngineL()->FindContentSourceNodesL( aPublisherInfo.Namespace() ) ); |
465 UiEngineL()->FindContentSourceNodesL( aPublisherInfo.Namespace() ) ); |
420 |
466 |
421 CleanupClosePushL( list ); |
467 CleanupClosePushL( list ); |
422 |
468 |
423 CXnNodeAppIf* publisherNode( NULL ); |
469 CXnNodeAppIf* publisher( NULL ); |
424 |
470 |
425 if ( list.Count() > 0 ) |
471 if ( list.Count() > 0 ) |
426 { |
472 { |
427 publisherNode = list[0]; |
473 publisher = list[0]; |
428 } |
474 } |
429 |
475 |
430 CleanupStack::PopAndDestroy( &list ); |
476 CleanupStack::PopAndDestroy( &list ); |
431 |
477 |
432 if( !publisherNode ) |
478 if( !publisher ) |
433 { |
479 { |
434 return; |
480 return; |
435 } |
481 } |
436 |
482 |
437 // Find ui plugin node for the data plugin |
483 // Find plugin node for the <contentsource> element |
438 CXnNodeAppIf* parentNode( publisherNode->ParentL() ); |
484 CXnNodeAppIf* parent( publisher->ParentL() ); |
439 |
485 |
440 // parent must be correct type |
486 if ( parent && parent->InternalDomNodeType() == XnPropertyNames::KWidget ) |
441 if( parentNode->InternalDomNodeType() == _L8("widget") ) |
487 { |
442 { |
488 // Get <contentsource> element configurations |
443 // Get plugin configurations |
489 GetConfigurationsL( |
444 GetConfigurationsL( *parentNode, aSettings, AiUiDef::xml::element::K16Plugin()); |
490 *parent, aSettings, AiUiDef::xml::element::K16Plugin() ); |
445 CPmODTIterator* iter = CPmODTIterator::NewL( *parentNode ); |
491 |
446 CleanupStack::PushL( iter ); |
492 RPointerArray< CXnNodeAppIf > model; |
447 CXnNodeAppIf* node = iter->First(); |
493 CleanupClosePushL( model ); |
448 while( node ) |
494 |
449 { |
495 HBufC8* key = HBufC8::NewLC( aPublisherInfo.Name().Length() + 1 ); |
450 const TDesC8& nodeType = node->Type()->Type(); |
496 |
451 if( nodeType == XnPropertyNames::action::KActions) |
497 _LIT( KSlash, "/" ); |
|
498 |
|
499 key->Des().Copy( aPublisherInfo.Name() ); |
|
500 key->Des().Append( KSlash ); |
|
501 |
|
502 BuildModelL( parent, *key, parent->Namespace(), model ); |
|
503 |
|
504 for ( TInt i = 0; i < model.Count(); i++ ) |
|
505 { |
|
506 CXnNodeAppIf* parent( model[i]->ParentL() ); |
|
507 |
|
508 if ( parent ) |
452 { |
509 { |
453 node = iter->SkipBranchL(); |
510 const TDesC8& type( parent->Type()->Type() ); |
454 } |
511 |
455 // Get the content model and configuration for the supported elements |
512 if ( IS_KNOWN_CONTENT_MODEL_ELEMENT( type ) ) |
456 else if( nodeType == AiUiDef::xml::element::KImage || |
513 { |
457 nodeType == AiUiDef::xml::element::KText || |
514 // Content model found for the element, create content item |
458 nodeType == AiUiDef::xml::element::KNewsTicker || |
515 MAiPluginSettings* settings( |
459 nodeType == AiUiDef::xml::element::KAnimation || |
516 AiUtility::CreatePluginSettingsL() ); |
460 nodeType == AiUiDef::xml::element::KTextEditor || |
517 |
461 nodeType == KData ) |
518 CleanupDeletePushL( settings ); |
462 { |
519 |
463 // Is created in GetContenItem and used in GetConfigurationsL |
520 MAiPluginContentItem& item( |
464 HBufC* confOwner( NULL ); |
521 settings->AiPluginContentItem() ); |
465 // get content item for the element, confOwner is filled |
522 |
466 GetContentItemL( *node, aSettings, confOwner ); |
523 // Type of the element is needed in content model |
467 if( confOwner ) |
524 HBufC* type16( NULL ); |
468 { |
525 |
469 CleanupStack::PushL( confOwner ); |
526 type16 = AiUtility::CopyToBufferL( type16, type ); |
470 // get configurations for the element |
527 |
471 GetConfigurationsL( *node, aSettings, *confOwner ); |
528 CleanupStack::PushL( type16 ); |
472 CleanupStack::PopAndDestroy( confOwner ); |
529 |
|
530 item.SetTypeL( *type16 ); |
|
531 |
|
532 HBufC* name( PropertyValueL( |
|
533 *model[i], AiUiDef::xml::property::KClass ) ); |
|
534 CleanupStack::PushL( name ); |
|
535 |
|
536 item.SetNameL( *name ); |
|
537 |
|
538 // Get content model configurations, |
|
539 // i.e. <property> element's <configuration> siblings |
|
540 GetConfigurationsL( *parent, aSettings, *name ); |
|
541 |
|
542 CleanupStack::PopAndDestroy( 2, type16 ); // name |
|
543 |
|
544 aSettings.AppendL( settings ); |
|
545 CleanupStack::Pop( settings ); |
473 } |
546 } |
474 node = iter->SkipBranchL(); |
547 } |
475 } |
|
476 else |
|
477 { |
|
478 node = iter->NextL(); |
|
479 } |
|
480 } |
548 } |
481 CleanupStack::PopAndDestroy( iter ); |
549 |
482 } |
550 CleanupStack::PopAndDestroy( 2, &model ); // key |
483 } |
551 } |
484 |
|
485 // ---------------------------------------------------------------------------- |
|
486 // CXmlUiController::GetContentItemL() |
|
487 // ---------------------------------------------------------------------------- |
|
488 // |
|
489 // ContentItemL() |
|
490 void CXmlUiController::GetContentItemL( CXnNodeAppIf& aNode, |
|
491 RAiSettingsItemArray& aSettings, HBufC*& aItemName ) |
|
492 { |
|
493 // Find property node |
|
494 RPointerArray<CXnNodeAppIf> childNodes( aNode.ChildrenL() ); |
|
495 CleanupClosePushL( childNodes ); |
|
496 |
|
497 TInt count( childNodes.Count() ); |
|
498 |
|
499 for ( TInt i = 0; i < count; i++ ) |
|
500 { |
|
501 CXnNodeAppIf* node( childNodes[i] ); |
|
502 |
|
503 if( node->Type()->Type() == XnPropertyNames::action::KProperty ) |
|
504 { |
|
505 HBufC* name = PropertyValueL( *node, AiUiDef::xml::property::KClass ); |
|
506 CleanupStack::PushL( name ); |
|
507 |
|
508 if( name ) |
|
509 { |
|
510 // Content model found for the element, create content item |
|
511 MAiPluginSettings* settings = AiUtility::CreatePluginSettingsL(); |
|
512 CleanupDeletePushL( settings ); |
|
513 |
|
514 MAiPluginContentItem& item = settings->AiPluginContentItem(); |
|
515 |
|
516 // Type of the element is needed in content model |
|
517 HBufC* type( NULL ); |
|
518 type = AiUtility::CopyToBufferL( type, aNode.Type()->Type()); |
|
519 CleanupStack::PushL( type ); |
|
520 item.SetTypeL( *type ); |
|
521 CleanupStack::PopAndDestroy( type ); |
|
522 |
|
523 item.SetNameL( *name ); |
|
524 |
|
525 aItemName = name; |
|
526 aSettings.AppendL( settings ); |
|
527 CleanupStack::Pop( settings ); |
|
528 } |
|
529 |
|
530 // Ownership is given to aItemName |
|
531 CleanupStack::Pop( name ); |
|
532 |
|
533 // First property element, which has class attribute is selected |
|
534 break; |
|
535 } |
|
536 } |
|
537 |
|
538 CleanupStack::PopAndDestroy( &childNodes ); |
|
539 } |
552 } |
540 |
553 |
541 // ---------------------------------------------------------------------------- |
554 // ---------------------------------------------------------------------------- |
542 // CXmlUiController::GetConfigurationsL() |
555 // CXmlUiController::GetConfigurationsL() |
543 // ---------------------------------------------------------------------------- |
556 // ---------------------------------------------------------------------------- |
544 // |
557 // |
545 // ConfigurationItemsL() |
|
546 void CXmlUiController::GetConfigurationsL( CXnNodeAppIf& aNode, |
558 void CXmlUiController::GetConfigurationsL( CXnNodeAppIf& aNode, |
547 RAiSettingsItemArray& aSettings, const TDesC& aConfOwner ) |
559 RAiSettingsItemArray& aSettings, const TDesC& aConfOwner ) |
548 { |
560 { |
549 // Find configuration nodes |
561 // Find configuration nodes |
550 RPointerArray< CXnNodeAppIf > nodes( aNode.ChildrenL() ); |
562 RPointerArray< CXnNodeAppIf > nodes( aNode.ChildrenL() ); |
551 CleanupClosePushL( nodes ); |
563 CleanupClosePushL( nodes ); |
552 |
564 |
553 // Collect settings |
565 // Collect settings |
554 TInt count( nodes.Count() ); |
566 TInt count( nodes.Count() ); |
555 |
567 |
556 for( TInt j = 0; j < count; j++ ) |
568 for( TInt i = 0; i < count; i++ ) |
557 { |
569 { |
558 CXnNodeAppIf* node( nodes[j] ); |
570 CXnNodeAppIf* node( nodes[i] ); |
559 |
571 |
560 if( node->Type()->Type() == AiUiDef::xml::element::KConfiguration ) |
572 if( node->Type()->Type() == AiUiDef::xml::element::KConfiguration ) |
561 { |
573 { |
562 HBufC* name( PropertyValueL( *node, AiUiDef::xml::property::KName ) ); |
574 HBufC* name( PropertyValueL( *node, AiUiDef::xml::property::KName ) ); |
563 CleanupStack::PushL( name ); |
575 CleanupStack::PushL( name ); |