idlehomescreen/xmluicontroller/src/contentrenderer.cpp
branchRCL_3
changeset 9 f966699dea19
parent 4 4d54b72983ae
child 30 b8fae6b8a148
equal deleted inserted replaced
5:c743ef5928ba 9:f966699dea19
    14 * Description:  Content renderer implementation
    14 * Description:  Content renderer implementation
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 // System includes
    18 // System includes
    19 #include    <e32hashtab.h>
    19 #include <e32hashtab.h>
    20 #include    <utf.h>
    20 #include <utf.h>
    21 #include    <gulicon.h>
    21 #include <gulicon.h>
    22 
    22 
    23 // User includes
    23 // User includes
    24 
    24 #include <hscontentpublisher.h>
    25 #include    "contentrenderer.h"
    25 #include <hspublisherinfo.h>
    26 #include    "appui.h"
    26 #include "contentrenderer.h"
    27 #include    "activetransactionstack.h"
    27 #include "appui.h"
    28 #include    "transactionfactoryimpl.h"
    28 #include "activetransactionstack.h"
    29 #include    "mtransaction.h"
    29 #include "transactionfactoryimpl.h"
    30 #include    "mtransactionelement.h"
    30 #include "mtransaction.h"
    31 #include    "aixmluiutils.h"
    31 #include "mtransactionelement.h"
    32 #include    "xmluicontroller.h"
    32 #include "aixmluiutils.h"
    33 #include    "xmlnodeidgenerator.h"
    33 #include "xmluicontroller.h"
    34 #include    "aixmluiconstants.h"
    34 #include "xmlnodeidgenerator.h"
    35 #include    "aifweventhandler.h"
    35 #include "aixmluiconstants.h"
    36 #include    "databuffertransactionelement.h"
    36 #include "aifweventhandler.h"
    37 #include    "newstickercallbackhandler.h"
    37 #include "databuffertransactionelement.h"
    38 #include    "newstickertransactionelement.h"
    38 #include "newstickercallbackhandler.h"
    39 #include    "csspropertymap.h"
    39 #include "newstickertransactionelement.h"
    40 #include    "policyevaluator.h"
    40 #include "csspropertymap.h"
    41 #include    "debug.h"
    41 #include "policyevaluator.h"
    42 #include    "xnuiengineappif.h"
    42 #include "debug.h"
    43 #include    "xnnodeappif.h"
    43 #include "xnuiengineappif.h"
    44 #include    "xnproperty.h"
    44 #include "xnnodeappif.h"
    45 #include    "mxncomponentinterface.h"
    45 #include "xncomponentnodeimpl.h"
    46 #include    "xntext.h"
    46 #include "xnproperty.h"
    47 #include    "xnbitmap.h"
    47 #include "mxncomponentinterface.h"
    48 #include    "xntype.h"
    48 #include "xntext.h"
    49 #include    "xnmenuadapter.h"
    49 #include "xnbitmap.h"
    50 #include    "xnlistquerydialogadapter.h"
    50 #include "xntype.h"
    51 #include    "mxncomponentinterface.h"
    51 #include "xnmenuadapter.h"
    52 #include    "aistrcnv.h"
    52 #include "xnlistquerydialogadapter.h"
    53 #include    "contentprioritymap.h"
    53 #include "mxncomponentinterface.h"
    54 #include    "ainativeuiplugins.h"
    54 #include "aistrcnv.h"
       
    55 #include "contentprioritymap.h"
       
    56 #include "ainativeuiplugins.h"
    55 
    57 
    56 using namespace AiXmlUiController;
    58 using namespace AiXmlUiController;
    57 using namespace AiUiDef::xml;
    59 using namespace AiUiDef::xml;
    58 using namespace XnTextInterface;
    60 using namespace XnTextInterface;
    59 using namespace XnImageInterface;
    61 using namespace XnImageInterface;
    60 
    62 
    61 namespace
    63 /**
    62     {
    64  * Cleanup item for cleanup of TPtrHashMapIter
    63     typedef RPointerArray<CXnNodeAppIf> RXnNodeArray;
    65  */            
    64 
    66 class TMapCleanupItem
       
    67     {
       
    68 public:
    65     /**
    69     /**
    66      * Gets content item iterator.
    70      * C++ consturctor
    67      *
    71      */
    68      * @param aPlugin plugin to fetch the iterator
    72     TMapCleanupItem( TPtrHashMapIter< TDesC, TInt >& aIterator );
    69      * @param aContentType type of iterator (content/resource/event)
    73     
    70      * @return the iterator
    74     /**
    71      * @leave KErrNotSupported if plugin does not provide iterator
    75      * Removes the pointers in the map and deletes the objects
       
    76      * referenced by the pointers.
    72      */ 
    77      */ 
    73     static MAiContentItemIterator& ContentItemIteratorL( MAiPropertyExtension& aPlugin,
    78     void Release();
    74                                                          TInt aContentType )
    79             
    75         {
    80 private:        
    76         MAiContentItemIterator* iter =
    81     TPtrHashMapIter< TDesC, TInt > iIterator;    
    77             static_cast< MAiContentItemIterator* >( aPlugin.GetPropertyL( aContentType ) );
    82     };
    78 
    83 
    79         if ( !iter )
    84 // ----------------------------------------------------------------------------
    80             {
    85 // TMapCleanupItem::TMapCleanupItem
    81             User::Leave( KErrNotSupported );
    86 //  
    82             }
    87 // ----------------------------------------------------------------------------
    83 
    88 //
    84         return *iter;
    89 TMapCleanupItem::TMapCleanupItem( TPtrHashMapIter< TDesC, TInt >& aIterator )
    85         }
    90     : iIterator( aIterator )
    86 
    91     {
    87     /**
    92     }
    88      * Gets the content priority associated in the property element.
    93 
    89      *
    94 // ----------------------------------------------------------------------------
    90      * @param aPropertyElement the property element
    95 // TMapCleanupItem::Release
    91      * @return priority value or KErrNotFound for non-prioritized element
    96 //  
    92      */
    97 // ----------------------------------------------------------------------------
    93     TInt GetContentPriority( CXnNodeAppIf& aPropertyElement )
    98 //
    94         {
    99 void TMapCleanupItem::Release()
    95         TInt32 priority( KErrNotFound );
   100     {
    96         
   101     // Delete current key and value
    97         const TDesC8* name = PropertyValue( aPropertyElement,
   102     const TDesC* key( iIterator.CurrentKey() );
    98                                             property::KName );
   103     const TInt* value( iIterator.CurrentValue() );
    99                                             
   104     
   100         
   105     delete key;
   101         if ( name && *name == name::KPriority )
   106     delete value;
   102             {
   107     
   103             const TDesC8* value = PropertyValue( aPropertyElement,
   108     // Remove mapping from the map.
   104                                                  property::KValue );
   109     iIterator.RemoveCurrent();
   105             if ( value )
   110     }
       
   111 
       
   112 // ============================ LOCAL FUNCTIONS ===============================
       
   113 
       
   114 // ----------------------------------------------------------------------------
       
   115 // ContentItemIterator
       
   116 // Gets content item iterator
       
   117 // ----------------------------------------------------------------------------
       
   118 //
       
   119 static MAiContentItemIterator* ContentItemIterator( CHsContentPublisher& aPlugin,
       
   120     CHsContentPublisher::TProperty aType )
       
   121     {       
       
   122     return static_cast< 
       
   123         MAiContentItemIterator* >( aPlugin.GetProperty( aType ) );                                     
       
   124     }
       
   125 
       
   126 // ----------------------------------------------------------------------------
       
   127 // ContentPriority
       
   128 // Gets the content priority associated in the property element
       
   129 // ----------------------------------------------------------------------------
       
   130 //
       
   131 static TInt ContentPriority( CXnNodeAppIf& aPropertyElement )
       
   132     {
       
   133     TInt32 priority( KErrNotFound );
       
   134     
       
   135     const TDesC8* name( 
       
   136         PropertyValue( aPropertyElement, property::KName ) );
       
   137                                                                                    
       
   138     if ( name && *name == name::KPriority )
       
   139         {
       
   140         const TDesC8* value( 
       
   141             PropertyValue( aPropertyElement, property::KValue ) );
       
   142                                              
       
   143         if ( value )
       
   144             {
       
   145             AiUtility::ParseInt( priority, *value );
       
   146             }
       
   147         }
       
   148         
       
   149     return priority;
       
   150     }
       
   151     
       
   152 // ----------------------------------------------------------------------------
       
   153 // RemoveNonPriorityElements
       
   154 // Remove elements from array which do not contain priority or priority is 
       
   155 // not lower than the given value.
       
   156 // ----------------------------------------------------------------------------
       
   157 //
       
   158 static void RemoveNonPriorityElements( RPointerArray< CXnNodeAppIf>& aElements,
       
   159     TInt aLastPriority )
       
   160     {
       
   161     //  Remove non priority elements and higher priority elements
       
   162     TInt elementCount( aElements.Count() );    
       
   163     
       
   164     for ( TInt i = 0; i < elementCount; )
       
   165         {
       
   166         CXnNodeAppIf* current( aElements[i] );
       
   167         
       
   168         // Check name attribute
       
   169         const TDesC8* name( PropertyValue( *current, property::KName ) );
       
   170         
       
   171         if ( !name || *name != name::KPriority )
       
   172             {
       
   173             // Remove current
       
   174             aElements.Remove( i );
       
   175             --elementCount;
       
   176             }
       
   177         else
       
   178             {
       
   179             // Check current priority
       
   180             const TDesC8* value( 
       
   181                 PropertyValue( *current, property::KValue ) );
       
   182             
       
   183             if ( !value ) // value not present
   106                 {
   184                 {
   107                 AiUtility::ParseInt( priority, *value );
   185                 aElements.Remove( i );
       
   186                 --elementCount;
       
   187                 continue;
   108                 }
   188                 }
   109             }
       
   110             
   189             
   111         return priority;
   190             TInt32 currentPriority( KErrNotFound );
   112         }
       
   113     
       
   114     /**
       
   115      * Remove elements from array which do not contain priority or priority is not lower than
       
   116      * the given value.
       
   117      * 
       
   118      * @param aElements array of elements
       
   119      * @param aLastPriority upper bound of priority value (excluded from the array)
       
   120      */
       
   121     void RemoveNonPriorityElements( RPointerArray< CXnNodeAppIf>& aElements,
       
   122                                     TInt aLastPriority )
       
   123         {
       
   124         //  Remove non priority elements and higher priority elements
       
   125 
       
   126         TInt elementCount = aElements.Count();    
       
   127         for ( TInt i = 0; i < elementCount; )
       
   128             {
       
   129             CXnNodeAppIf* current = aElements[i];
       
   130             
   191             
   131             // Check name attribute
   192             if ( AiUtility::ParseInt( currentPriority, *value ) != KErrNone )
   132             const TDesC8* name = PropertyValue( *current, property::KName );
       
   133             
       
   134             if ( !name || *name != name::KPriority )
       
   135                 {
   193                 {
   136                 // Remove current
   194                 // value is not integer
       
   195                 aElements.Remove( i );
       
   196                 --elementCount;
       
   197                 continue;
       
   198                 }
       
   199                 
       
   200             if ( currentPriority < aLastPriority )
       
   201                 {
       
   202                 // Keep element and iterate further
       
   203                 ++i;
       
   204                 }
       
   205             else
       
   206                 {
       
   207                 // priority is too high
   137                 aElements.Remove( i );
   208                 aElements.Remove( i );
   138                 --elementCount;
   209                 --elementCount;
   139                 }
   210                 }
   140             else
   211             }
       
   212         }
       
   213     }
       
   214     
       
   215 // ----------------------------------------------------------------------------
       
   216 // DescendingPriorityOrder
       
   217 // Descending priority order for prioritized content selectors. 
       
   218 // ----------------------------------------------------------------------------
       
   219 //
       
   220 static TInt DescendingPriorityOrder( const CXnNodeAppIf& aNode1,
       
   221     const CXnNodeAppIf& aNode2 )
       
   222     {
       
   223     /*
       
   224     * @param aNode1 First node to compare
       
   225     * @param aNode2 Second node to compare
       
   226     * @return 0 nodes have equal priority
       
   227     * @return >0 aNode1 has lower priority
       
   228     * @return <0 aNode2 has lower priority
       
   229     */
       
   230     // Array content has been validated, so no checks are needed
       
   231     const TDesC8* value1( 
       
   232         PropertyValue( aNode1, property::KValue ) );
       
   233                                               
       
   234     const TDesC8* value2( 
       
   235         PropertyValue( aNode2, property::KValue ) );
       
   236                                               
       
   237     TInt32 priority1( KErrNotFound );
       
   238     AiUtility::ParseInt( priority1, *value1 );
       
   239     
       
   240     TInt32 priority2( KErrNotFound );
       
   241     AiUtility::ParseInt( priority2, *value2 );
       
   242     
       
   243     if ( priority1 == priority2 )
       
   244         {
       
   245         return 0;
       
   246         }
       
   247         
       
   248     return ( priority1 < priority2 ) ? 1 : -1;
       
   249     }
       
   250 
       
   251 // ----------------------------------------------------------------------------
       
   252 // RemoveDuplicateContentChangesL
       
   253 // Removes duplicate entries in content change array 
       
   254 // ----------------------------------------------------------------------------
       
   255 //
       
   256 static void RemoveDuplicateContentChangesL( RAiPolicyElementArray& aArray )
       
   257     {
       
   258     for ( TInt i = 0; i < aArray.Count(); ++i )
       
   259         {
       
   260         HBufC* id( PropertyValueL( aArray[i].Target(),  
       
   261             AiUiDef::xml::property::KId ) ); 
       
   262                                         
       
   263         if ( id )
       
   264             {
       
   265             CleanupStack::PushL( id );
       
   266             
       
   267             for ( TInt j = i; j < aArray.Count(); ++j )
   141                 {
   268                 {
   142                 // Check current priority
   269                 HBufC* id2( PropertyValueL( aArray[j].Target(), 
   143                 const TDesC8* value = PropertyValue( *current, property::KValue );
   270                    AiUiDef::xml::property::KId ) );
   144                 
   271                 
   145                 if ( !value ) // value not present
   272                 if ( id2 )
   146                     {
   273                     {
   147                     aElements.Remove( i );
   274                     CleanupStack::PushL( id2 );
   148                     --elementCount;
   275                 
   149                     continue;
   276                     // Same id and same policy
       
   277                     if ( i != j && id->Compare( *id2 ) == 0 &&                          
       
   278                      ( aArray[i].Policy().Compare( aArray[j].Policy()) == 0 ) ) 
       
   279                             
       
   280                         {
       
   281                         aArray.Remove( j );
       
   282                         --j;
       
   283                         }
   150                     }
   284                     }
   151                 
   285                 
   152                 TInt32 currentPriority( KErrNotFound );
   286                 CleanupStack::PopAndDestroy( id2 );                
   153                 if ( AiUtility::ParseInt( currentPriority, *value ) != KErrNone )
       
   154                     {
       
   155                     // value is not integer
       
   156                     aElements.Remove( i );
       
   157                     --elementCount;
       
   158                     continue;
       
   159                     }
       
   160                     
       
   161                 if ( currentPriority < aLastPriority )
       
   162                     {
       
   163                     // Keep element and iterate further
       
   164                     ++i;
       
   165                     }
       
   166                 else
       
   167                     {
       
   168                     // priority is too high
       
   169                     aElements.Remove( i );
       
   170                     --elementCount;
       
   171                     }
       
   172                 }
   287                 }
   173             }
       
   174         }
       
   175     
       
   176     /**
       
   177      * Descending priority order for prioritized content selectors.
       
   178      *
       
   179      * @param aNode1 First node to compare
       
   180      * @param aNode2 Second node to compare
       
   181      * @return 0 nodes have equal priority
       
   182      * @return >0 aNode1 has lower priority
       
   183      * @return <0 aNode2 has lower priority
       
   184      */
       
   185     TInt DescendingPriorityOrder( const CXnNodeAppIf& aNode1,
       
   186                                   const CXnNodeAppIf& aNode2 )
       
   187         {
       
   188         // Array content has been validated, so no checks are needed
       
   189         const TDesC8* value1 = PropertyValue( aNode1,
       
   190                                               property::KValue );
       
   191         
       
   192         const TDesC8* value2 = PropertyValue( aNode2,
       
   193                                               property::KValue );
       
   194         
       
   195         TInt32 priority1( KErrNotFound );
       
   196         AiUtility::ParseInt( priority1, *value1 );
       
   197         
       
   198         TInt32 priority2( KErrNotFound );
       
   199         AiUtility::ParseInt( priority2, *value2 );
       
   200         
       
   201         if ( priority1 == priority2 )
       
   202             {
       
   203             return 0;
       
   204             }
       
   205             
   288             
   206         return ( priority1 < priority2 ) ? 1 : -1;
   289             CleanupStack::PopAndDestroy( id );
   207         }
   290             }
   208     
   291         }
   209     /**
   292     }
   210      * Removes duplicate entries in content change array
   293 
   211      */
   294 // ----------------------------------------------------------------------------
   212     void RemoveDuplicateContentChangesL( RAiPolicyElementArray& aArray )
   295 // CleanupReleaseMapItem
   213         {
   296 // Helper to handle cleanup of map iterator 
   214         for ( TInt i = 0; i < aArray.Count(); ++i )
   297 // ----------------------------------------------------------------------------
   215             {
   298 //
   216             HBufC* id = PropertyValueL( aArray[i].Target(), 
   299 static void CleanupReleaseMapItem( TAny* aMapCleanupItem )
   217                                             AiUiDef::xml::property::KId );
   300     {
   218             if ( id )
   301     if ( aMapCleanupItem )
   219                 {
   302         {
   220                 CleanupStack::PushL( id );
   303         static_cast< TMapCleanupItem* >( aMapCleanupItem )->Release();
   221                 for ( TInt j = i; j < aArray.Count(); ++j )
   304         }
   222                     {
   305     }
   223                     HBufC* id2 = PropertyValueL( aArray[j].Target(), 
   306 
   224                                                            AiUiDef::xml::property::KId );
   307 // ----------------------------------------------------------------------------
   225                     if ( id2)
   308 // CleanupReleasePushL
   226                         {
   309 // Helper to push map iterator into cleanup stack. 
   227                         CleanupStack::PushL( id2 );
   310 // ----------------------------------------------------------------------------
   228                         // Same id and same policy
   311 //
   229                         if ( i != j &&
   312 static void CleanupReleasePushL( TMapCleanupItem& aCleanupItem )
   230                              id->Compare( *id2 ) == 0 && 
   313     {
   231                              ( aArray[i].Policy().Compare( aArray[j].Policy()) == 0) 
   314     CleanupStack::PushL( TCleanupItem( CleanupReleaseMapItem, &aCleanupItem ) );
   232                                 )
   315     }
   233                             {
       
   234                             aArray.Remove( j );
       
   235                             --j;
       
   236                             }
       
   237                         }
       
   238                     CleanupStack::PopAndDestroy( id2 );
       
   239                     
       
   240                     }
       
   241                 CleanupStack::PopAndDestroy( id );
       
   242                 }
       
   243             }
       
   244         }
       
   245     /**
       
   246      * Cleanup item for cleanup of TPtrHashMapIter
       
   247      */            
       
   248     class TMapCleanupItem
       
   249         {
       
   250     public:
       
   251         
       
   252         TMapCleanupItem( TPtrHashMapIter< TDesC, TInt >& aIterator );
       
   253         
       
   254         /**
       
   255          * Removes the pointers in the map and deletes the objects
       
   256          * referenced by the pointers.
       
   257          */ 
       
   258         void Release();
       
   259                 
       
   260     private:
       
   261             
       
   262         TPtrHashMapIter< TDesC, TInt > iIterator;
       
   263         
       
   264         };
       
   265 
       
   266     /**
       
   267      * Helper to handle cleanup of map iterator
       
   268      * @param aMapCleanupItem 
       
   269      */
       
   270     void CleanupRelease( TAny* aMapCleanupItem )
       
   271         {
       
   272         if ( aMapCleanupItem )
       
   273             {
       
   274             static_cast< TMapCleanupItem* >( aMapCleanupItem )->Release();
       
   275             }
       
   276         }
       
   277 
       
   278     /**
       
   279      * Helper to push map iterator into cleanup stack.
       
   280      *
       
   281      * @param aCleanupItem item to push into cleanup stack
       
   282      **/
       
   283     void CleanupReleasePushL( TMapCleanupItem& aCleanupItem )
       
   284         {
       
   285         CleanupStack::PushL( TCleanupItem( CleanupRelease,
       
   286                                            &aCleanupItem ) );
       
   287         }
       
   288 
       
   289     
       
   290     }
       
   291 
       
   292 TMapCleanupItem::TMapCleanupItem( TPtrHashMapIter< TDesC, TInt >& aIterator )
       
   293     : iIterator( aIterator )
       
   294     {
       
   295     }
       
   296 
       
   297 void TMapCleanupItem::Release()
       
   298     {
       
   299     // Delete current key and value
       
   300     const TDesC* key = iIterator.CurrentKey();
       
   301     const TInt* value = iIterator.CurrentValue();
       
   302     
       
   303     delete key;
       
   304     delete value;
       
   305     
       
   306     // Remove mapping from the map.
       
   307     iIterator.RemoveCurrent();
       
   308     }
       
   309 
       
   310 
       
   311 
   316 
   312 // ============================ MEMBER FUNCTIONS ===============================
   317 // ============================ MEMBER FUNCTIONS ===============================
   313 
   318 
       
   319 // ----------------------------------------------------------------------------
       
   320 // CContentRenderer::CContentRenderer
       
   321 // 
       
   322 // ----------------------------------------------------------------------------
       
   323 //
   314 CContentRenderer::CContentRenderer( CAppUi& aAppUi )
   324 CContentRenderer::CContentRenderer( CAppUi& aAppUi )
   315     : iAppUi( aAppUi )
   325     : iAppUi( aAppUi )
   316     {
   326     {
   317     }
   327     }
   318 
   328 
       
   329 // ----------------------------------------------------------------------------
       
   330 // CContentRenderer::ConstructL
       
   331 // 
       
   332 // ----------------------------------------------------------------------------
       
   333 //
   319 void CContentRenderer::ConstructL()
   334 void CContentRenderer::ConstructL()
   320     {
   335     {
   321     iContentPriorityMap = AiUtility::CContentPriorityMap::NewL();
   336     iContentPriorityMap = AiUtility::CContentPriorityMap::NewL();
   322     iPropertyMap = CCssPropertyMap::NewL();
   337     iPropertyMap = CCssPropertyMap::NewL();
   323     iFactory = CTransactionFactoryImpl::NewL(*iContentPriorityMap,
   338     iFactory = CTransactionFactoryImpl::NewL(*iContentPriorityMap,
   326     iNodeIdGenerator = CXmlNodeIdGenerator::NewL();
   341     iNodeIdGenerator = CXmlNodeIdGenerator::NewL();
   327     iTimer = CPeriodic::NewL( CActive::EPriorityStandard );
   342     iTimer = CPeriodic::NewL( CActive::EPriorityStandard );
   328     iPolicyEvaluator = CPolicyEvaluator::NewL();
   343     iPolicyEvaluator = CPolicyEvaluator::NewL();
   329     }
   344     }
   330 
   345 
       
   346 // ----------------------------------------------------------------------------
       
   347 // CContentRenderer::NewL
       
   348 // 
       
   349 // ----------------------------------------------------------------------------
       
   350 //
   331 CContentRenderer* CContentRenderer::NewL( CAppUi& aAppUi )
   351 CContentRenderer* CContentRenderer::NewL( CAppUi& aAppUi )
   332     {
   352     {
   333     CContentRenderer* self = new( ELeave ) CContentRenderer( aAppUi );
   353     CContentRenderer* self = new( ELeave ) CContentRenderer( aAppUi );
   334 
   354 
   335     CleanupStack::PushL( self );
   355     CleanupStack::PushL( self );
   336     self->ConstructL();
   356     self->ConstructL();
   337     CleanupStack::Pop();
   357     CleanupStack::Pop( self );
   338 
   358 
   339     return self;
   359     return self;
   340     }
   360     }
   341 
   361 
       
   362 // ----------------------------------------------------------------------------
       
   363 // CContentRenderer::~CContentRenderer
       
   364 // 
       
   365 // ----------------------------------------------------------------------------
       
   366 //
   342 CContentRenderer::~CContentRenderer()
   367 CContentRenderer::~CContentRenderer()
   343     {
   368     {
   344     delete iPolicyEvaluator;
   369     delete iPolicyEvaluator;
   345     
   370     
   346     if ( iTimer )
   371     if ( iTimer )
   372     
   397     
   373     delete iContentPriorityMap;
   398     delete iContentPriorityMap;
   374     delete iCallbackHandler;
   399     delete iCallbackHandler;
   375     }
   400     }
   376 
   401 
       
   402 // ----------------------------------------------------------------------------
       
   403 // CContentRenderer::SetEventHandler
       
   404 // 
       
   405 // ----------------------------------------------------------------------------
       
   406 //
   377 void CContentRenderer::SetEventHandler( MAiFwEventHandler& aFwEventHandler )
   407 void CContentRenderer::SetEventHandler( MAiFwEventHandler& aFwEventHandler )
   378     {
   408     {
   379     iFwEventHandler = &aFwEventHandler;
   409     iFwEventHandler = &aFwEventHandler;
   380     }
   410     }
   381 
   411 
   382 void CContentRenderer::Reset()
   412 // ----------------------------------------------------------------------------
   383     {
   413 // CContentRenderer::StartTransaction
   384     iContentPriorityMap->Reset();
   414 // 
   385     iPropertyMap->Reset();
   415 // ----------------------------------------------------------------------------
   386     }
   416 //
   387 
       
   388 void CContentRenderer::CleanPluginFromUi( MAiPropertyExtension& aPlugin )
       
   389     {
       
   390     // Create transaction to clean UI
       
   391     TInt txId = reinterpret_cast< TInt >( &aPlugin );
       
   392     
       
   393     TBool txCreated = ( StartTransaction( txId ) == KErrNone );
       
   394     
       
   395     // Clean plugin
       
   396     TRAPD( cleanError, CleanPluginFromUiL( aPlugin ) );
       
   397     
       
   398     // Commit transaction
       
   399     if ( txCreated )
       
   400         {
       
   401         if (cleanError )
       
   402             {
       
   403             CancelTransaction( txId );
       
   404             }
       
   405         else
       
   406             {
       
   407             Commit( txId );
       
   408             }
       
   409         }
       
   410     }
       
   411 
       
   412 TInt CContentRenderer::StartTransaction( TInt aTxId )
   417 TInt CContentRenderer::StartTransaction( TInt aTxId )
   413     {
   418     {
   414     __PRINT(__DBG_FORMAT("\t[I]\tXML UI: Start transaction id=%d"), aTxId);
   419     __PRINT(__DBG_FORMAT("\t[I]\tXML UI: Start transaction id=%d"), aTxId);
   415     __HEAP("XML UI: Start transaction");
   420     __HEAP("XML UI: Start transaction");
   416     __TICK("XML UI: Start transaction");
   421     __TICK("XML UI: Start transaction");
       
   422     
   417     TRAPD( error, DoStartTransactionL( aTxId ) );
   423     TRAPD( error, DoStartTransactionL( aTxId ) );
   418 
   424 
   419     if ( error )
   425     if ( error )
   420         {
   426         {
   421         SetImmediateMode( ETrue );
   427         SetImmediateMode( ETrue );
   422         }
   428         }
   423 
   429 
   424     return error;
   430     return error;
   425     }
   431     }
   426 
   432 
       
   433 // ----------------------------------------------------------------------------
       
   434 // CContentRenderer::Commit
       
   435 // 
       
   436 // ----------------------------------------------------------------------------
       
   437 //
   427 TInt CContentRenderer::Commit( TInt aTxId )
   438 TInt CContentRenderer::Commit( TInt aTxId )
   428     {
   439     {
   429     // Remove transaction with aTxId from stack
   440     // Remove transaction with aTxId from stack
   430     MTransaction* tr = iStack->Remove( aTxId );
   441     MTransaction* tr( iStack->Remove( aTxId ) );
   431 
   442 
   432     if ( tr )
   443     if ( tr )
   433         {
   444         {
   434         // Commit transaction        
   445         // Commit transaction        
   435         RPropertyHashMap propertyHashMap;
   446         RPropertyHashMap propertyHashMap;
   436         
   447         
   437         TBool layoutChanged( EFalse );
   448         TBool layoutChanged( EFalse );
   438         
   449         
   439         TRAPD( error, tr->CommitL( layoutChanged, propertyHashMap ) );
   450         TRAPD( error, tr->CommitL( layoutChanged, propertyHashMap ) );
       
   451 
   440         if( error == KErrNone )
   452         if( error == KErrNone )
   441             {
   453             {
   442             TRAP_IGNORE( SetPropertyArraysL( propertyHashMap ) );
   454             TRAP_IGNORE( SetPropertyArraysL( propertyHashMap ) );
   443             }
   455             }
       
   456         
   444         propertyHashMap.Close();
   457         propertyHashMap.Close();
   445 
   458 
   446         __TICK("XML UI: Commit transaction");
   459         __TICK("XML UI: Commit transaction");
   447         __HEAP("XML UI: Commit transaction");
   460         __HEAP("XML UI: Commit transaction");
   448         __PRINT(__DBG_FORMAT("\t[I]\tXML UI: Commit transaction id=%d"), aTxId);
   461         __PRINT(__DBG_FORMAT("\t[I]\tXML UI: Commit transaction id=%d"), aTxId);
   462         }
   475         }
   463         
   476         
   464     return KErrNotSupported;
   477     return KErrNotSupported;
   465     }
   478     }
   466 
   479 
       
   480 // ----------------------------------------------------------------------------
       
   481 // CContentRenderer::ProcessContentChangesL
       
   482 // 
       
   483 // ----------------------------------------------------------------------------
       
   484 //
   467 void CContentRenderer::ProcessContentChangesL( MTransaction& aTr )
   485 void CContentRenderer::ProcessContentChangesL( MTransaction& aTr )
   468     {
   486     {
   469     TDblQueIter<CTransactionElement> iter = aTr.ElementIter();
   487     TDblQueIter<CTransactionElement> iter( aTr.ElementIter() );
   470     RAiPolicyElementArray contentChangedArray;
   488     RAiPolicyElementArray contentChangedArray;
   471     CleanupClosePushL( contentChangedArray );
   489     CleanupClosePushL( contentChangedArray );
   472 
   490 
   473     while ( iter )
   491     while ( iter )
   474           {
   492           {
   477           
   495           
   478           // Find own and parents policy/ContentChanged nodes 
   496           // Find own and parents policy/ContentChanged nodes 
   479           iPolicyEvaluator->EvaluateContentChangedPolicyL( target, 
   497           iPolicyEvaluator->EvaluateContentChangedPolicyL( target, 
   480                   contentChangedArray);
   498                   contentChangedArray);
   481 
   499 
   482           iPolicyEvaluator->EvaluateContentChangedPolicyL( *(target.ParentL()), 
   500           iPolicyEvaluator->EvaluateContentChangedPolicyL( *(target.ParentL() ), 
   483                   contentChangedArray);
   501                   contentChangedArray);
   484           }
   502           }
   485        
   503        
   486     ::RemoveDuplicateContentChangesL( contentChangedArray );
   504     ::RemoveDuplicateContentChangesL( contentChangedArray );
   487         
   505         
   488     for ( TInt i = 0; i < contentChangedArray.Count(); ++i )
   506     for ( TInt i = 0; i < contentChangedArray.Count(); ++i )
   489         {
   507         {
   490         ProcessContentChangeL( contentChangedArray[i] );
   508         ProcessContentChangeL( contentChangedArray[i] );
   491         }
   509         }
       
   510     
   492     CleanupStack::PopAndDestroy();
   511     CleanupStack::PopAndDestroy();
   493     }
   512     }
   494 
   513 
       
   514 // ----------------------------------------------------------------------------
       
   515 // CContentRenderer::ProcessContentChangeL
       
   516 // 
       
   517 // ----------------------------------------------------------------------------
       
   518 //
   495 void CContentRenderer::ProcessContentChangeL( TAiPolicyElement& aElement )
   519 void CContentRenderer::ProcessContentChangeL( TAiPolicyElement& aElement )
   496     {
   520     {
   497     const TDesC8* id = PropertyValue( aElement.Target(), 
   521     const TDesC8* id( PropertyValue( 
   498                                 AiUiDef::xml::property::KId );
   522         aElement.Target(), AiUiDef::xml::property::KId ) ); 
       
   523                                 
   499     if ( id )
   524     if ( id )
   500         {
   525         {
   501         CXnNodeAppIf* targetNode = FindNodeByIdL( *id, aElement.Target().Namespace() );
   526         CXnNodeAppIf* targetNode( 
       
   527             FindNodeByIdL( *id, aElement.Target().Namespace() ) );
       
   528         
   502         if ( targetNode )
   529         if ( targetNode )
   503             {                     
   530             {                     
   504             if ( aElement.Policy() == AiUiDef::xml::value::KShowTooltips )
   531             if ( aElement.Policy() == AiUiDef::xml::value::KShowTooltips )
   505                 {
   532                 {
   506                 targetNode->ShowTooltipsL();
   533                 targetNode->ShowTooltipsL();
   507                 }                   
   534                 }                   
   508             }        
   535             }        
   509         }
   536         }
   510     }
   537     }
   511 
   538 
       
   539 // ----------------------------------------------------------------------------
       
   540 // CContentRenderer::CancelTransaction
       
   541 // 
       
   542 // ----------------------------------------------------------------------------
       
   543 //
   512 TInt CContentRenderer::CancelTransaction( TInt aTxId )
   544 TInt CContentRenderer::CancelTransaction( TInt aTxId )
   513     {
   545     {
   514     // Remove transaction with aTxId from stack
   546     // Remove transaction with aTxId from stack
   515     MTransaction* tr = iStack->Remove( aTxId );
   547     MTransaction* tr( iStack->Remove( aTxId ) );
   516 
   548 
   517     if ( tr )
   549     if ( tr )
   518         {
   550         {
   519         // Release transaction to factory
   551         // Release transaction to factory
   520         __TICK("XML UI: Cancel transaction");
   552         __TICK("XML UI: Cancel transaction");
   527         }
   559         }
   528 
   560 
   529     return KErrNotSupported;
   561     return KErrNotSupported;
   530     }
   562     }
   531 
   563 
   532 TBool CContentRenderer::CanPublish( MAiPropertyExtension& aPlugin,
   564 // ----------------------------------------------------------------------------
   533                                     TInt aContent,
   565 // CContentRenderer::CanPublish
   534                                     TInt aIndex )
   566 // 
       
   567 // ----------------------------------------------------------------------------
       
   568 //
       
   569 TBool CContentRenderer::CanPublish( CHsContentPublisher& aPlugin,
       
   570     TInt aContent, TInt aIndex )                                   
   535     {
   571     {
   536     TInt error( KErrNone );
   572     TInt error( KErrNone );
   537     TInt retval( KErrNone );
   573     TInt retval( KErrNone );
       
   574     
   538     __PRINTS("*** UC: Init - Content Validation ***");
   575     __PRINTS("*** UC: Init - Content Validation ***");
   539 	__TIME("UC: Content Validation",
   576 	__TIME("UC: Content Validation",
   540         TRAP( error, retval = CanPublishL( aPlugin, aContent, aIndex ) );
   577         TRAP( error, retval = CanPublishL( aPlugin, aContent, aIndex ) );
   541         );
   578         );
   542     __HEAP("UC: Content Validation");
   579     __HEAP("UC: Content Validation");
   543     __PRINTS("*** UC: Done - Content Validation ***");
   580     __PRINTS("*** UC: Done - Content Validation ***");
   544 
   581 
   545     return ( error == KErrNone && retval == KErrNone );
   582     return ( error == KErrNone && retval == KErrNone );
   546     }
   583     }
   547 
   584 
   548 TInt CContentRenderer::Publish( MAiPropertyExtension& aPlugin,
   585 // ----------------------------------------------------------------------------
   549                                 TInt aContent,
   586 // CContentRenderer::Publish
   550                                 TInt aResource,
   587 // 
   551                                 TInt aIndex )
   588 // ----------------------------------------------------------------------------
       
   589 //
       
   590 TInt CContentRenderer::Publish( CHsContentPublisher& aPlugin, TInt aContent, 
       
   591     TInt aResource, TInt aIndex )
   552     {
   592     {
   553 	TInt error( KErrNone );
   593 	TInt error( KErrNone );
   554 	TInt retval( KErrNone );
   594 	TInt retval( KErrNone );
       
   595 	
   555 	__PRINTS("*** UC: Init - Content Publishing (Resource) ***");
   596 	__PRINTS("*** UC: Init - Content Publishing (Resource) ***");
   556 	__TIME("UC: Content Publishing (Resource)",
   597 	__TIME("UC: Content Publishing (Resource)",
   557     	TRAP( error, retval = DoPublishL( aPlugin, aContent, aResource, aIndex ) );
   598     	TRAP( error, retval = DoPublishL( aPlugin, aContent, aResource, aIndex ) );
   558     );
   599     );
   559     __HEAP("UC: Content Publishing (Resource)");
   600     __HEAP("UC: Content Publishing (Resource)");
   565         }
   606         }
   566     
   607     
   567     return error;
   608     return error;
   568     }
   609     }
   569 
   610 
   570 TInt CContentRenderer::Publish( MAiPropertyExtension& aPlugin,
   611 // ----------------------------------------------------------------------------
   571                                 TInt aContent,
   612 // CContentRenderer::Publish
   572                                 const TDesC16& aText,
   613 // 
   573                                 TInt aIndex )
   614 // ----------------------------------------------------------------------------
       
   615 //
       
   616 TInt CContentRenderer::Publish( CHsContentPublisher& aPlugin, TInt aContent, 
       
   617     const TDesC16& aText, TInt aIndex )
   574     {
   618     {
   575     TInt error( KErrNone );
   619     TInt error( KErrNone );
   576     TInt retval( KErrNone );
   620     TInt retval( KErrNone );
   577     
   621     
   578     __PRINTS("*** UC: Init - Content Publishing (Value-Text) ***");
   622     __PRINTS("*** UC: Init - Content Publishing (Value-Text) ***");
   588         }
   632         }
   589 
   633 
   590     return error;
   634     return error;
   591     }
   635     }
   592 
   636 
   593 TInt CContentRenderer::Publish( MAiPropertyExtension& aPlugin,
   637 // ----------------------------------------------------------------------------
   594                                 TInt aContent,
   638 // CContentRenderer::Publish
   595                                 const TDesC8& aBuf,
   639 // 
   596                                 TInt aIndex )
   640 // ----------------------------------------------------------------------------
       
   641 //
       
   642 TInt CContentRenderer::Publish( CHsContentPublisher& aPlugin, TInt aContent, 
       
   643     const TDesC8& aBuf, TInt aIndex )
   597     {
   644     {
   598     TInt error( KErrNone );
   645     TInt error( KErrNone );
   599     TInt retval( KErrNone );
   646     TInt retval( KErrNone );
   600     
   647     
   601     __PRINTS("*** UC: Init - Content Publishing (Value-Buf) ***");
   648     __PRINTS("*** UC: Init - Content Publishing (Value-Buf) ***");
   611         }
   658         }
   612     
   659     
   613     return error;
   660     return error;
   614     }
   661     }
   615 
   662 
   616 TInt CContentRenderer::Publish( MAiPropertyExtension& aPlugin,
   663 // ----------------------------------------------------------------------------
   617                                 TInt aContent,
   664 // CContentRenderer::Publish
   618                                 RFile& aFile,
   665 // 
   619                                 TInt aIndex )
   666 // ----------------------------------------------------------------------------
       
   667 //
       
   668 TInt CContentRenderer::Publish( CHsContentPublisher& aPlugin, TInt aContent,                                
       
   669     RFile& aFile, TInt aIndex )                                
   620     {
   670     {
   621     TInt error( KErrNone );
   671     TInt error( KErrNone );
   622     TInt retval( KErrNone );
   672     TInt retval( KErrNone );
   623     	
   673     	
   624 	__PRINTS("*** UC: Init - Content Publishing (Value-RFile) ***");
   674 	__PRINTS("*** UC: Init - Content Publishing (Value-RFile) ***");
   634         }
   684         }
   635     
   685     
   636     return error;
   686     return error;
   637     }
   687     }
   638 
   688 
   639 TInt CContentRenderer::Clean( MAiPropertyExtension& aPlugin, TInt aContent, TInt aIndex )
   689 // ----------------------------------------------------------------------------
       
   690 // CContentRenderer::Clean
       
   691 // 
       
   692 // ----------------------------------------------------------------------------
       
   693 //
       
   694 TInt CContentRenderer::Clean( CHsContentPublisher& aPlugin, TInt aContent, 
       
   695     TInt aIndex )
   640     {
   696     {
   641     TInt error( KErrNone );
   697     TInt error( KErrNone );
   642     TInt retval( KErrNone );
   698     TInt retval( KErrNone );
   643             
   699             
   644     __PRINTS("*** UC: Init - Content Publishing (Clean) ***");
   700     __PRINTS("*** UC: Init - Content Publishing (Clean) ***");
   654         }
   710         }
   655     
   711     
   656     return error;
   712     return error;
   657     }
   713     }
   658 
   714 
       
   715 // ----------------------------------------------------------------------------
       
   716 // CContentRenderer::CContentRenderer
       
   717 // 
       
   718 // ----------------------------------------------------------------------------
       
   719 //
   659 TAny* CContentRenderer::Extension( TUid /*aUid*/ )
   720 TAny* CContentRenderer::Extension( TUid /*aUid*/ )
   660     {
   721     {
   661     // No extensions supported
   722     // No extensions supported
   662     return NULL;
   723     return NULL;
   663     }
   724     }
   664 
   725 
       
   726 // ----------------------------------------------------------------------------
       
   727 // CContentRenderer::RequiresSubscription
       
   728 // 
       
   729 // ----------------------------------------------------------------------------
       
   730 //
   665 TBool CContentRenderer::RequiresSubscription( 
   731 TBool CContentRenderer::RequiresSubscription( 
   666     const TAiPublisherInfo& aPublisherInfo ) const
   732     const THsPublisherInfo& aPublisherInfo ) const
   667     {
   733     {
   668     if ( aPublisherInfo.iNamespace == KNativeUiNamespace )
   734     if ( aPublisherInfo.Namespace() == KNativeUiNamespace )
   669         {
   735         {
   670         // Not targeted to this content renderer
   736         // Not targeted to this content renderer
   671         return EFalse;
   737         return EFalse;
   672         }
   738         }
   673         
   739         
   674     return ETrue;
   740     return ETrue;
   675     }
   741     }
   676 
   742 
   677 TInt CContentRenderer::SetProperty( MAiPropertyExtension& aPlugin,
   743 // ----------------------------------------------------------------------------
   678         const TDesC8& aElementId,
   744 // CContentRenderer::DoStartTransactionL
   679         const TDesC8& aPropertyName,
   745 // 
   680         const TDesC8& aPropertyValue ) 
   746 // ----------------------------------------------------------------------------
   681     {
   747 //
   682    return ( SetProperty( aPlugin, aElementId, 
       
   683                aPropertyName, aPropertyValue,
       
   684                MAiContentObserver::EValueString ) );
       
   685     }
       
   686 
       
   687 TInt CContentRenderer::SetProperty( MAiPropertyExtension& aPlugin,
       
   688         const TDesC8& aElementId,
       
   689         const TDesC8& aPropertyName,
       
   690         const TDesC8& aPropertyValue,
       
   691         MAiContentObserver::TValueType aValueType) 
       
   692     {
       
   693     TInt error( KErrNone );
       
   694     TInt retval( KErrNone );
       
   695 
       
   696     TRAP( error, retval = SetPropertyL( aPlugin, aElementId, aPropertyName,
       
   697             aPropertyValue, aValueType ) );
       
   698     
       
   699     if( !error && retval )
       
   700      {
       
   701      error = retval;
       
   702      }
       
   703     
       
   704     return error;
       
   705     }
       
   706 
       
   707 TInt CContentRenderer::SetPropertyL( MAiPropertyExtension& aPlugin,
       
   708         const TDesC8& aElementId,
       
   709         const TDesC8& aPropertyName,
       
   710         const TDesC8& aPropertyValue,
       
   711         MAiContentObserver::TValueType aValueType) 
       
   712     {
       
   713     TInt err = KErrNone;
       
   714     // Find node
       
   715     CXnNodeAppIf* targetNode = FindNodeByIdL( aElementId, aPlugin.PublisherInfoL()->iNamespace );
       
   716     if ( targetNode )
       
   717        {
       
   718        CXnDomStringPool& sp( targetNode->UiEngineL()->StringPool() );
       
   719               
       
   720        CXnProperty* prop = CXnProperty::NewL( 
       
   721                aPropertyName,
       
   722                aPropertyValue,
       
   723                DomPropertyValueType(aValueType), sp );
       
   724                       
       
   725        CleanupStack::PushL( prop );
       
   726     
       
   727        targetNode->SetPropertyL( prop );
       
   728       
       
   729        CleanupStack::Pop( prop );
       
   730        }
       
   731     else
       
   732        {
       
   733        err = KErrNotFound;
       
   734        }
       
   735     return err;
       
   736     }
       
   737 
       
   738 
       
   739 CXnDomPropertyValue::TPrimitiveValueType 
       
   740     CContentRenderer::DomPropertyValueType(
       
   741             MAiContentObserver::TValueType aValueType)
       
   742     {
       
   743     CXnDomPropertyValue::TPrimitiveValueType type = 
       
   744             CXnDomPropertyValue::EUnknown;
       
   745     switch ( aValueType )
       
   746         {
       
   747         case MAiContentObserver::EValueNumber :
       
   748             {
       
   749             type = CXnDomPropertyValue::ENumber;
       
   750             }
       
   751             break;
       
   752         case MAiContentObserver::EValuePercentage :
       
   753             {
       
   754             type = CXnDomPropertyValue::EPercentage;
       
   755             }
       
   756             break;
       
   757         case MAiContentObserver::EValuePx :
       
   758             {
       
   759             type = CXnDomPropertyValue::EPx;
       
   760             }
       
   761             break;
       
   762         case MAiContentObserver::EValueString :
       
   763             {
       
   764             type = CXnDomPropertyValue::EString;
       
   765             }
       
   766             break;
       
   767         case MAiContentObserver::EValueRgbColor :
       
   768             {
       
   769             type = CXnDomPropertyValue::ERgbColor;
       
   770             }
       
   771             break;
       
   772         case MAiContentObserver::EValueUnitValue :
       
   773             {
       
   774             type = CXnDomPropertyValue::EUnitValue;
       
   775             }
       
   776             break;
       
   777         default:
       
   778             {
       
   779             type = CXnDomPropertyValue::EUnknown;
       
   780             }
       
   781         }
       
   782     return type;
       
   783     }
       
   784 
       
   785 void CContentRenderer::DoStartTransactionL( TInt aTxId )
   748 void CContentRenderer::DoStartTransactionL( TInt aTxId )
   786     {
   749     {
   787     MTransaction* tr = iFactory->CreateTransactionL( aTxId );
   750     MTransaction* tr( iFactory->CreateTransactionL( aTxId ) );
   788     iStack->Push(tr);
   751     iStack->Push( tr );
   789     SetImmediateMode(EFalse);
   752     
   790     }
   753     SetImmediateMode( EFalse );
   791 
   754     }
   792 TInt CContentRenderer::CanPublishL( MAiPropertyExtension& aPlugin,
   755 
   793                                     TInt aContent,
   756 // ----------------------------------------------------------------------------
   794                                     TInt aIndex )
   757 // CContentRenderer::CanPublishL
       
   758 // 
       
   759 // ----------------------------------------------------------------------------
       
   760 //
       
   761 TInt CContentRenderer::CanPublishL( CHsContentPublisher& aPlugin,
       
   762     TInt aContent, TInt aIndex )                                    
   795     {
   763     {
   796     // Get content item for aContent
   764     // Get content item for aContent
   797     MAiContentItemIterator& iter( 
   765     MAiContentItemIterator* iter( ContentItemIterator(  
   798             ContentItemIteratorL( aPlugin, EAiPublisherContent ) );
   766         aPlugin, CHsContentPublisher::EPublisherContent ) );
   799     
   767     
   800     const TAiContentItem& item( iter.ItemL( aContent ) );
   768     if ( !iter )
       
   769         {
       
   770         return KErrNotSupported;
       
   771         }
       
   772 
       
   773     const TAiContentItem& item( iter->ItemL( aContent ) );
   801 
   774 
   802     // Lookup ui element
   775     // Lookup ui element
   803     const TDesC& nodeId( iNodeIdGenerator->ContentNodeIdL( aPlugin, item ) );
   776     const TDesC& nodeId( iNodeIdGenerator->ContentNodeIdL( aPlugin, item ) );
   804 
   777 
   805     CXnNodeAppIf* property( FindNodeByClassL( nodeId, aIndex, 
   778     CXnNodeAppIf* property( FindNodeByClassL( nodeId, aIndex, 
   806                             aPlugin.PublisherInfoL()->iNamespace ) ); 
   779         aPlugin.PublisherInfo().Namespace() ) ); 
   807  
   780  
   808     if( !property )
   781     if( !property )
   809         {
   782         {
   810         return KErrNotFound;
   783         return KErrNotFound;
   811         }
   784         }
   812     
   785     
   813     // Check content priority
   786     // Check content priority
   814     TInt priority( GetContentPriority( *property ) );
   787     TInt priority( ContentPriority( *property ) );
   815 
   788 
   816     CXnNodeAppIf* target( property->ParentL() );
   789     CXnNodeAppIf* target( property->ParentL() );
   817     
   790     
   818     if( !target )
   791     if( !target )
   819         {
   792         {
   827 
   800 
   828     // Check if content type is supported by target
   801     // Check if content type is supported by target
   829     const TDesC8& contentType( ContentType( item ) );
   802     const TDesC8& contentType( ContentType( item ) );
   830 
   803 
   831     if ( !iFactory->IsSupported( *target, contentType ) &&
   804     if ( !iFactory->IsSupported( *target, contentType ) &&
   832           target->Type()->Type() != XnPropertyNames::listquerydialog::KListQueryDialog )
   805         target->Type()->Type() != XnPropertyNames::listquerydialog::KListQueryDialog )
   833         {
   806         {
   834         return KErrNotSupported;
   807         return KErrNotSupported;
   835         }
   808         }
   836     
   809     
   837     return KErrNone;
   810     return KErrNone;
   838     }
   811     }
   839 
   812 
   840 TInt CContentRenderer::DoPublishL( MAiPropertyExtension& aPlugin,
   813 // ----------------------------------------------------------------------------
   841                                    TInt aContent,
   814 // CContentRenderer::DoPublishL
   842                                    TInt aResource,
   815 // 
   843                                    TInt aIndex )
   816 // ----------------------------------------------------------------------------
   844     {
   817 //
   845     TAiPublisherInfo *info = static_cast<TAiPublisherInfo*>(aPlugin.GetPropertyL( EAiPublisherInfo ));
   818 TInt CContentRenderer::DoPublishL( CHsContentPublisher& aPlugin, TInt aContent,
   846     if (!info)
   819     TInt aResource, TInt aIndex )                                  
   847         {
   820     {
   848         return KErrNotFound;
   821     TInt retval( KErrNotSupported );
   849         }
   822     
       
   823     const THsPublisherInfo& info( aPlugin.PublisherInfo() );
       
   824 
   850     // Read ref value.
   825     // Read ref value.
   851     MAiContentItemIterator& refIter( ContentItemIteratorL( aPlugin, EAiPublisherResources ) );
   826     MAiContentItemIterator* resIter( ContentItemIterator( 
   852     const TAiContentItem& ref( refIter.ItemL( aResource ) );
   827         aPlugin, CHsContentPublisher::EPublisherResources ) );
       
   828     
       
   829     if ( !resIter )
       
   830         {
       
   831         return retval;
       
   832         }
       
   833     
       
   834     const TAiContentItem& ref( resIter->ItemL( aResource ) );
   853 
   835 
   854     const TDesC8& refType( ContentType( ref ) );
   836     const TDesC8& refType( ContentType( ref ) );
   855 
   837 
   856     // Resolve source node
   838     // Resolve source node
   857     const TDesC& nodeId = iNodeIdGenerator->ResourceNodeIdL(aPlugin, ref);
   839     const TDesC& nodeId( iNodeIdGenerator->ResourceNodeIdL( aPlugin, ref ) );
   858     HBufC8* nodeId8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L(nodeId);
   840     
   859     CleanupStack::PushL(nodeId8);
   841     HBufC8* nodeId8( CnvUtfConverter::ConvertFromUnicodeToUtf8L( nodeId ) );
   860     CXnNodeAppIf* source = NULL;
   842     CleanupStack::PushL( nodeId8 );
   861     __TIME_MARK(xmlOverhead);
   843     
   862     source = FindNodeByIdL( *nodeId8, info->iNamespace );
   844     CXnNodeAppIf* source( NULL );
       
   845     
       
   846     __TIME_MARK( xmlOverhead );
       
   847     
       
   848     source = FindNodeByIdL( *nodeId8, info.Namespace() );
       
   849     
   863     __TIME_ENDMARK("XML UI: Lookup node by id", xmlOverhead);
   850     __TIME_ENDMARK("XML UI: Lookup node by id", xmlOverhead);
   864     __PRINT(__DBG_FORMAT("\t[I]\tXML UI: Lookup node by id=%S"), &nodeId);
   851     __PRINT(__DBG_FORMAT("\t[I]\tXML UI: Lookup node by id=%S"), &nodeId);
   865     
   852     
   866     CleanupStack::PopAndDestroy(nodeId8);
   853     CleanupStack::PopAndDestroy( nodeId8 );
   867     
   854     
   868     // Fetch content id
   855     // Fetch content id
   869     MAiContentItemIterator& iter = ContentItemIteratorL( aPlugin, EAiPublisherContent );
   856     MAiContentItemIterator* iter( ContentItemIterator( 
   870     const TAiContentItem& item = iter.ItemL( aContent );
   857        aPlugin, CHsContentPublisher::EPublisherContent ) );
   871 
   858     
   872     const TDesC& targetId = iNodeIdGenerator->ContentNodeIdL(aPlugin, item);
   859     if ( !iter )
   873 
   860         {
   874     TInt retval( KErrNotSupported );
   861         return retval;
   875 
   862         }
       
   863     
       
   864     const TAiContentItem& item( iter->ItemL( aContent ) );
       
   865 
       
   866     const TDesC& targetId( iNodeIdGenerator->ContentNodeIdL( aPlugin, item ) );
       
   867     
   876     // Check types
   868     // Check types
   877     if ( refType == KContentTypeText )
   869     if ( refType == KContentTypeText )
   878         {
   870         {
   879         // Fetch text
   871         // Fetch text
   880         const TDesC8& text = source->GetPCData();
   872         const TDesC8& text( source->GetPCData() );
   881         
   873         
   882         // Delegate to data publishing function
   874         // Delegate to data publishing function
   883         retval = PublishDataL( aPlugin,
   875         retval = PublishDataL( aPlugin,
   884                                targetId,
   876                                targetId,
   885                                text,
   877                                text,
   888                                source );
   880                                source );
   889         }
   881         }
   890     else if ( refType.Find( KContentTypeImage ) != KErrNotFound )
   882     else if ( refType.Find( KContentTypeImage ) != KErrNotFound )
   891         {
   883         {
   892         // Fetch icon
   884         // Fetch icon
   893         CGulIcon* icon = LoadIconLC( *source ); 
   885         CGulIcon* icon( LoadIconLC( *source ) ); 
   894         
   886         
   895        // Delegate to icon publishing function
   887        // Delegate to icon publishing function
   896         retval = PublishIconL( aPlugin,
   888         retval = PublishIconL( aPlugin,
   897                                targetId,
   889                                targetId,
   898                                icon,
   890                                icon,
   903         }
   895         }
   904     
   896     
   905     return retval;
   897     return retval;
   906     }
   898     }
   907 
   899 
   908 TInt CContentRenderer::DoPublishL( MAiPropertyExtension& aPlugin,
   900 // ----------------------------------------------------------------------------
   909                                    TInt aContent,
   901 // CContentRenderer::DoPublishL
   910                                    const TDesC16& aText,
   902 // 
   911                                    TInt aIndex )
   903 // ----------------------------------------------------------------------------
   912     {
   904 //
       
   905 TInt CContentRenderer::DoPublishL( CHsContentPublisher& aPlugin, TInt aContent,                                  
       
   906     const TDesC16& aText, TInt aIndex )                                   
       
   907     {
       
   908     const THsPublisherInfo& info( aPlugin.PublisherInfo() );
       
   909 
   913     // Resolve content item
   910     // Resolve content item
   914     MAiContentItemIterator& iter( 
   911     MAiContentItemIterator* iter( ContentItemIterator( 
   915             ContentItemIteratorL( aPlugin, EAiPublisherContent ) );
   912         aPlugin, CHsContentPublisher::EPublisherContent ) ); 
   916     
   913             
   917     const TAiContentItem& item( iter.ItemL( aContent ) );
   914     if ( !iter )
       
   915         {
       
   916         return KErrNotSupported;
       
   917         }
       
   918     
       
   919     const TAiContentItem& item( iter->ItemL( aContent ) );
   918 
   920 
   919     const TDesC8& type( ContentType( item ) );
   921     const TDesC8& type( ContentType( item ) );
   920 
   922 
   921     if ( type == KContentTypeText )
   923     if ( type == KContentTypeText )
   922         {
   924         {
   923         // Find ui element
   925         // Find ui element
   924         const TDesC& nodeId = iNodeIdGenerator->ContentNodeIdL( aPlugin, item );
   926         const TDesC& nodeId( 
   925 
   927             iNodeIdGenerator->ContentNodeIdL( aPlugin, item ) ); 
   926         __TIME_MARK(xmlOverhead);
   928             
   927 
   929         __TIME_MARK( xmlOverhead );
   928         CXnNodeAppIf* property( FindNodeByClassL( nodeId, aIndex, 
   930 
   929                                                   aPlugin.PublisherInfoL()->iNamespace ) );
   931         CXnNodeAppIf* property( FindNodeByClassL(  
       
   932             nodeId, aIndex, info.Namespace() ) );
   930 
   933 
   931         if( !property )
   934         if( !property )
   932             {
   935             {
   933             return KErrNotFound;
   936             return KErrNotFound;
   934             }
   937             }
   935         
   938         
   936         TInt priority( GetContentPriority( *property ) );
   939         TInt priority( ContentPriority( *property ) );
   937         
   940         
   938         __TIME_ENDMARK("XML UI: Lookup node by class", xmlOverhead);
   941         __TIME_ENDMARK("XML UI: Lookup node by class", xmlOverhead);
   939     	__PRINT(__DBG_FORMAT("\t[I]\tXML UI: Lookup node by class=%S"), &nodeId);
   942     	__PRINT(__DBG_FORMAT("\t[I]\tXML UI: Lookup node by class=%S"), &nodeId);
   940 
   943 
   941         //Navigate to parent
   944         //Navigate to parent
   961                     {
   964                     {
   962                     return KErrNotFound;
   965                     return KErrNotFound;
   963                     }
   966                     }
   964                                 
   967                                 
   965                 RegisterNewstickerCallbackInterfaceL( *parent );
   968                 RegisterNewstickerCallbackInterfaceL( *parent );
       
   969                                                
       
   970                 iNTPublisher.Set( info.Name() );
       
   971                 iNTClass = AiUtility::CopyToBufferL( iNTClass, nodeId );
   966                 
   972                 
   967                 const TAiPublisherInfo* info( aPlugin.PublisherInfoL() );
   973                 element = iFactory->CreateNewsTickerTransactionElementL( 
   968                 
   974                         *target, aText, priority, aIndex );
   969                 if ( info )
       
   970                     {
       
   971                     iNTPublisher.Set( info->iName );
       
   972                     iNTClass = AiUtility::CopyToBufferL( iNTClass, nodeId );
       
   973                     }
       
   974                 
       
   975                 element = iFactory->CreateNewsTickerTransactionElementL( *target,
       
   976                                                                     aText,
       
   977                                                                     priority, 
       
   978                                                                     aIndex );
       
   979                 }
   975                 }
   980             else if( target->Type()->Type() == 
   976             else if( target->Type()->Type() == 
   981                      XnListQueryDialogInterface::MXnListQueryDialogInterface::Type())
   977                      XnListQueryDialogInterface::MXnListQueryDialogInterface::Type())
   982                 {
   978                 {
   983                 // Get the data interface for dialog and publish data
   979                 // Get the data interface for dialog and publish data
   994                 element = iFactory->CreateTextTransactionElementL( *target,
   990                 element = iFactory->CreateTextTransactionElementL( *target,
   995                                                                     aText,
   991                                                                     aText,
   996                                                                     priority );
   992                                                                     priority );
   997                 }
   993                 }
   998             
   994             
   999             iPolicyEvaluator->EvaluateContentPolicyL( *target,
   995             iPolicyEvaluator->EvaluateContentPolicyL( 
  1000                                                       element->PolicyArray() );
   996                     *target, element->PolicyArray() );
  1001             iPolicyEvaluator->EvaluateVisibilityPolicyL( *target,
   997                                                      
  1002                                                          element->PolicyArray() );
   998             iPolicyEvaluator->EvaluateVisibilityPolicyL( 
  1003 
   999                     *target, element->PolicyArray() );
       
  1000                                                          
  1004             ProcessTransactionElementL( element );
  1001             ProcessTransactionElementL( element );
  1005             }
  1002             }
  1006         else
  1003         else
  1007             {
  1004             {
  1008             return KErrAccessDenied;            
  1005             return KErrAccessDenied;            
  1014         }
  1011         }
  1015     
  1012     
  1016     return KErrNone;
  1013     return KErrNone;
  1017     }
  1014     }
  1018 
  1015 
  1019 TInt CContentRenderer::DoPublishL( MAiPropertyExtension& aPlugin,
  1016 // ----------------------------------------------------------------------------
  1020                                    TInt aContent,
  1017 // CContentRenderer::DoPublishL
  1021                                    const TDesC8& aBuf,
  1018 // 
  1022                                    TInt aIndex )
  1019 // ----------------------------------------------------------------------------
  1023     {
  1020 //
       
  1021 TInt CContentRenderer::DoPublishL( CHsContentPublisher& aPlugin, TInt aContent,
       
  1022     const TDesC8& aBuf, TInt aIndex )                                   
       
  1023     {
       
  1024     TInt retval( KErrNotSupported );
       
  1025     
  1024     // resolve content item
  1026     // resolve content item
  1025     MAiContentItemIterator& iter( 
  1027     MAiContentItemIterator* iter( ContentItemIterator( 
  1026             ContentItemIteratorL( aPlugin, EAiPublisherContent ) );
  1028         aPlugin, CHsContentPublisher::EPublisherContent ) ); 
  1027     
  1029             
  1028     const TAiContentItem& item( iter.ItemL( aContent ) );
  1030     if ( !iter )
       
  1031         {
       
  1032         return retval;
       
  1033         }
       
  1034     
       
  1035     const TAiContentItem& item( iter->ItemL( aContent ) );
  1029 
  1036 
  1030     const TDesC8& type( ContentType( item ) );
  1037     const TDesC8& type( ContentType( item ) );
  1031 
  1038     
  1032     TInt retval( KErrNotSupported );
  1039     const TDesC& nodeId( iNodeIdGenerator->ContentNodeIdL( aPlugin, item ) );
  1033     
  1040 
  1034     if( type == KContentTypeBitmap )
  1041     if( type == KContentTypeBitmap )
  1035         {
  1042         {
  1036         // Unpack icon from pointer
  1043         // Unpack icon from pointer
  1037         CGulIcon* icon( LeaveIfNull( UnpackPtr<CGulIcon>( aBuf ), KErrArgument ) );
  1044         CGulIcon* icon( LeaveIfNull( UnpackPtr<CGulIcon>( aBuf ), KErrArgument ) );
  1038 
  1045                 
  1039         const TDesC& nodeId( iNodeIdGenerator->ContentNodeIdL( aPlugin, item ) );
       
  1040         
       
  1041         // Publish icon
  1046         // Publish icon
  1042         retval = PublishIconL( aPlugin, nodeId, icon, aIndex );
  1047         retval = PublishIconL( aPlugin, nodeId, icon, aIndex );
  1043         }
  1048         }
  1044     else if ( type == KContentTypeImageSvg )
  1049     else if ( type == KContentTypeImageSvg ||
  1045         {
  1050         type == KContentTypeData )
  1046         // Get node id
  1051         {
  1047         const TDesC& nodeId( iNodeIdGenerator->ContentNodeIdL( aPlugin, item ) );
  1052         // Publish data
  1048         
  1053         retval = PublishDataL( aPlugin, nodeId, aBuf, type, aIndex );
  1049         // Publish SVG data
       
  1050         retval = PublishDataL( aPlugin, nodeId, aBuf, KContentTypeImageSvg, aIndex );
       
  1051         }
  1054         }
  1052 
  1055 
  1053     return retval;
  1056     return retval;
  1054     }
  1057     }
  1055 
  1058 
  1056 TInt CContentRenderer::DoPublishL( MAiPropertyExtension& aPlugin,
  1059 // ----------------------------------------------------------------------------
  1057                                    TInt aContent,
  1060 // CContentRenderer::DoPublishL
  1058                                    RFile& aFile,
  1061 // 
  1059                                    TInt aIndex)
  1062 // ----------------------------------------------------------------------------
  1060     {
  1063 //
       
  1064 TInt CContentRenderer::DoPublishL( CHsContentPublisher& aPlugin, TInt aContent,
       
  1065     RFile& aFile, TInt aIndex )                                   
       
  1066     {
       
  1067     const THsPublisherInfo& info( aPlugin.PublisherInfo() );
       
  1068     
  1061     //Resolve content item
  1069     //Resolve content item
  1062     MAiContentItemIterator& iter( 
  1070     MAiContentItemIterator* iter( ContentItemIterator( 
  1063             ContentItemIteratorL( aPlugin, EAiPublisherContent ) );
  1071         aPlugin, CHsContentPublisher::EPublisherContent ) ); 
  1064     
  1072 
  1065     const TAiContentItem& item( iter.ItemL( aContent ) );
  1073     if ( !iter )
       
  1074         {
       
  1075         return KErrNotSupported;
       
  1076         }
       
  1077     
       
  1078     const TAiContentItem& item( iter->ItemL( aContent ) );
  1066 
  1079 
  1067     const TDesC8& type( ContentType( item ) );
  1080     const TDesC8& type( ContentType( item ) );
  1068 
  1081 
  1069     // Image support
  1082     // Image support
  1070     if ( type.Find( KContentTypeImage ) != KErrNotFound )
  1083     if ( type.Find( KContentTypeImage ) != KErrNotFound )
  1071         {
  1084         {
  1072         // Find ui element
  1085         // Find ui element
  1073         const TDesC& nodeId( iNodeIdGenerator->ContentNodeIdL( aPlugin, item ) );
  1086         const TDesC& nodeId( iNodeIdGenerator->ContentNodeIdL( aPlugin, item ) );
  1074 
  1087 
  1075         CXnNodeAppIf* property( FindNodeByClassL( nodeId, aIndex, 
  1088         CXnNodeAppIf* property( FindNodeByClassL( 
  1076                                 aPlugin.PublisherInfoL()->iNamespace ) );
  1089             nodeId, aIndex, info.Namespace() ) );
  1077         
  1090                                         
  1078         if( !property )
  1091         if( !property )
  1079             {
  1092             {
  1080             return KErrNotFound;
  1093             return KErrNotFound;
  1081             }
  1094             }
  1082         
  1095         
  1083         // Check priority
  1096         // Check priority
  1084         TInt priority( GetContentPriority( *property ) );
  1097         TInt priority( ContentPriority( *property ) );
  1085         
  1098         
  1086         CXnNodeAppIf* target( property->ParentL() );
  1099         CXnNodeAppIf* target( property->ParentL() );
  1087         
  1100         
  1088         if( !target )
  1101         if( !target )
  1089             {
  1102             {
  1103                     return KErrNotFound;
  1116                     return KErrNotFound;
  1104                     }
  1117                     }
  1105                                 
  1118                                 
  1106                 RegisterNewstickerCallbackInterfaceL( *parent );
  1119                 RegisterNewstickerCallbackInterfaceL( *parent );
  1107                 
  1120                 
  1108                 const TAiPublisherInfo* info( aPlugin.PublisherInfoL() );
  1121                 iNTPublisher.Set( info.Name() );
  1109                 
  1122                 iNTClass = AiUtility::CopyToBufferL( iNTClass, nodeId );           
  1110                 if( info )
       
  1111                     {
       
  1112                     iNTPublisher.Set( info->iName );
       
  1113                     iNTClass = AiUtility::CopyToBufferL( iNTClass, nodeId );
       
  1114                     }
       
  1115                 }
  1123                 }
  1116             
  1124             
  1117             // Create transaction element for file
  1125             // Create transaction element for file
  1118             MTransactionElement* element =
  1126             MTransactionElement* element =
  1119                 iFactory->CreateImageTransactionElementL( *target,
  1127                 iFactory->CreateImageTransactionElementL( 
  1120                                                           aFile,
  1128                         *target, aFile, priority );
  1121                                                           priority );
  1129                                                           
       
  1130             iPolicyEvaluator->EvaluateContentPolicyL( 
       
  1131                     *target, element->PolicyArray() );
       
  1132                                                       
       
  1133             iPolicyEvaluator->EvaluateVisibilityPolicyL( 
       
  1134                     *target, element->PolicyArray() );
       
  1135                                                                      
       
  1136             ProcessTransactionElementL( element );
       
  1137             }
       
  1138         else
       
  1139             {
       
  1140             return KErrAccessDenied;
       
  1141             }
       
  1142         }
       
  1143     else 
       
  1144         {
       
  1145         return KErrNotSupported;        
       
  1146         }
       
  1147     
       
  1148     return KErrNone;
       
  1149     }
       
  1150 
       
  1151 // ----------------------------------------------------------------------------
       
  1152 // CContentRenderer::DoCleanL
       
  1153 // 
       
  1154 // ----------------------------------------------------------------------------
       
  1155 //
       
  1156 TInt CContentRenderer::DoCleanL( CHsContentPublisher& aPlugin, TInt aContent,
       
  1157     TInt aIndex )                                                
       
  1158     {
       
  1159     const THsPublisherInfo& info( aPlugin.PublisherInfo() );
       
  1160     
       
  1161     // Resolve content item
       
  1162     MAiContentItemIterator* iter( ContentItemIterator( 
       
  1163         aPlugin, CHsContentPublisher::EPublisherContent ) ); 
  1122             
  1164             
  1123             iPolicyEvaluator->EvaluateContentPolicyL( *target,
  1165     if ( !iter )
  1124                                                       element->PolicyArray() );
  1166         {
  1125             iPolicyEvaluator->EvaluateVisibilityPolicyL( *target,
  1167         return KErrNotSupported;
  1126                                                          element->PolicyArray() );
  1168         }
       
  1169     
       
  1170     const TAiContentItem& item( iter->ItemL( aContent ) );
       
  1171 
       
  1172     const TDesC& nodeId( iNodeIdGenerator->ContentNodeIdL( aPlugin, item ) );
       
  1173 
       
  1174     CXnNodeAppIf* property( FindNodeByClassL( 
       
  1175         nodeId, aIndex, info.Namespace() ) ); 
  1127             
  1176             
  1128             ProcessTransactionElementL( element );
       
  1129             }
       
  1130         else
       
  1131             {
       
  1132             return KErrAccessDenied;
       
  1133             }
       
  1134         }
       
  1135     else 
       
  1136         {
       
  1137         return KErrNotSupported;        
       
  1138         }
       
  1139     
       
  1140     return KErrNone;
       
  1141     }
       
  1142 
       
  1143 TInt CContentRenderer::DoCleanL( MAiPropertyExtension& aPlugin,
       
  1144                                  TInt aContent,
       
  1145                                  TInt aIndex )
       
  1146     {
       
  1147     // Resolve content item
       
  1148     MAiContentItemIterator& iter( 
       
  1149             ContentItemIteratorL( aPlugin, EAiPublisherContent ) );
       
  1150     
       
  1151     const TAiContentItem& item( iter.ItemL( aContent ) );
       
  1152 
       
  1153     const TDesC& nodeId( iNodeIdGenerator->ContentNodeIdL( aPlugin, item ) );
       
  1154 
       
  1155     CXnNodeAppIf* property( FindNodeByClassL( nodeId, aIndex, 
       
  1156                             aPlugin.PublisherInfoL()->iNamespace ) );
       
  1157 
       
  1158     if( !property )
  1177     if( !property )
  1159         {
  1178         {
  1160         return KErrNotFound;
  1179         return KErrNotFound;
  1161         }
  1180         }
  1162     
  1181     
  1163     TInt priority( GetContentPriority( *property ) );
  1182     TInt priority( ContentPriority( *property ) );
  1164 
  1183 
  1165     // Navigate to parent
  1184     // Navigate to parent
  1166     CXnNodeAppIf* target( property->ParentL() );
  1185     CXnNodeAppIf* target( property->ParentL() );
  1167 
  1186 
  1168     if( !target )
  1187     if( !target )
  1184             return KErrNotFound;
  1203             return KErrNotFound;
  1185             }
  1204             }
  1186                
  1205                
  1187         RegisterNewstickerCallbackInterfaceL( *parent );
  1206         RegisterNewstickerCallbackInterfaceL( *parent );
  1188         
  1207         
  1189         const TAiPublisherInfo* info( aPlugin.PublisherInfoL() );
  1208         iNTPublisher.Set( info.Name() );
  1190         
  1209         iNTClass = AiUtility::CopyToBufferL( iNTClass, nodeId );
  1191         if( info )
  1210         }
  1192             {
  1211     
  1193             iNTPublisher.Set( info->iName );
       
  1194             iNTClass = AiUtility::CopyToBufferL( iNTClass, nodeId );
       
  1195             }
       
  1196         }
       
  1197     if( target->Type()->Type() ==
  1212     if( target->Type()->Type() ==
  1198         XnListQueryDialogInterface::MXnListQueryDialogInterface::Type())
  1213         XnListQueryDialogInterface::MXnListQueryDialogInterface::Type())
  1199         {
  1214         {
  1200         // Get the data interface for dialog and delete data
  1215         // Get the data interface for dialog and delete data
  1201         XnListQueryDialogInterface::MXnListQueryDialogInterface* listQuery( NULL );
  1216         XnListQueryDialogInterface::MXnListQueryDialogInterface* listQuery( NULL );
  1205         return KErrNone;
  1220         return KErrNone;
  1206         }
  1221         }
  1207     
  1222     
  1208     // Create transaction element for empty content
  1223     // Create transaction element for empty content
  1209     MTransactionElement* element =
  1224     MTransactionElement* element =
  1210         iFactory->CreateEmptyContentTransactionElementL( *target, aIndex );
  1225         iFactory->CreateEmptyContentTransactionElementL( 
  1211 
  1226                 *target, aIndex );
  1212     iPolicyEvaluator->EvaluateEmptyContentPolicyL( *target,
  1227 
  1213                                                    element->PolicyArray() );
  1228     iPolicyEvaluator->EvaluateEmptyContentPolicyL( 
  1214     iPolicyEvaluator->EvaluateVisibilityPolicyL( *target,
  1229             *target, element->PolicyArray() );
  1215                                                    element->PolicyArray() );
  1230                                                    
  1216 
  1231     iPolicyEvaluator->EvaluateVisibilityPolicyL( 
       
  1232             *target, element->PolicyArray() );
       
  1233                                                    
  1217     ProcessTransactionElementL( element );
  1234     ProcessTransactionElementL( element );
  1218       
  1235       
  1219     if ( priority > KErrNotFound ) // Only for prioritized elements
  1236     if ( priority > KErrNotFound ) // Only for prioritized elements
  1220         {
  1237         {
  1221         // Add current ui element into content refresh map
  1238         // Add current ui element into content refresh map
  1222         HBufC* uiElementId = PropertyValueL( *target,
  1239         HBufC* uiElementId( PropertyValueL( 
  1223                                          XnPropertyNames::common::KId );
  1240             *target, XnPropertyNames::common::KId ) );
       
  1241                                          
  1224         return RefreshContentL( uiElementId, priority );
  1242         return RefreshContentL( uiElementId, priority );
  1225         }
  1243         }
  1226     
  1244     
  1227     return KErrNone;
  1245     return KErrNone;
  1228     }
  1246     }
  1229 
  1247 
       
  1248 // ----------------------------------------------------------------------------
       
  1249 // CContentRenderer::SetImmediateMode
       
  1250 // 
       
  1251 // ----------------------------------------------------------------------------
       
  1252 //
  1230 void CContentRenderer::SetImmediateMode( TBool aImmediateMode )
  1253 void CContentRenderer::SetImmediateMode( TBool aImmediateMode )
  1231     {
  1254     {
  1232     iImmediateMode = aImmediateMode;
  1255     iImmediateMode = aImmediateMode;
  1233     }
  1256     }
  1234 
  1257 
       
  1258 // ----------------------------------------------------------------------------
       
  1259 // CContentRenderer::IsImmediateMode
       
  1260 // 
       
  1261 // ----------------------------------------------------------------------------
       
  1262 //
  1235 TBool CContentRenderer::IsImmediateMode() const
  1263 TBool CContentRenderer::IsImmediateMode() const
  1236     {
  1264     {
  1237     return iImmediateMode;
  1265     return iImmediateMode;
  1238     }
  1266     }
  1239 
  1267 
  1240 void CContentRenderer::ProcessTransactionElementL( MTransactionElement* aElement )
  1268 // ----------------------------------------------------------------------------
       
  1269 // CContentRenderer::ProcessTransactionElementL
       
  1270 // 
       
  1271 // ----------------------------------------------------------------------------
       
  1272 //
       
  1273 void CContentRenderer::ProcessTransactionElementL( 
       
  1274     MTransactionElement* aElement )
  1241     {
  1275     {
  1242     LeaveIfNull( aElement, KErrArgument );
  1276     LeaveIfNull( aElement, KErrArgument );
  1243     
  1277     
  1244     if ( IsImmediateMode() || iStack->IsEmpty() )
  1278     if ( IsImmediateMode() || iStack->IsEmpty() )
  1245         {
  1279         {
  1246         // No transaction. Commit element immediately
  1280         // No transaction. Commit element immediately
  1247         TBool layoutChanged = EFalse;
  1281         TBool layoutChanged( EFalse );
  1248         
  1282         
  1249         RPropertyHashMap propertyHashMap;
  1283         RPropertyHashMap propertyHashMap;
  1250         aElement->CommitL(layoutChanged, propertyHashMap);
  1284         CleanupClosePushL( propertyHashMap );
       
  1285         
       
  1286         aElement->CommitL( layoutChanged, propertyHashMap );
  1251         SetPropertyArraysL( propertyHashMap );
  1287         SetPropertyArraysL( propertyHashMap );
  1252         propertyHashMap.Close();
  1288         
       
  1289         CleanupStack::PopAndDestroy( &propertyHashMap );
  1253         
  1290         
  1254         iFactory->ReleaseTransactionElement( aElement );
  1291         iFactory->ReleaseTransactionElement( aElement );
  1255         StartContentRefresh();
  1292         StartContentRefresh();
  1256         
  1293         
  1257         // Re-layout
  1294         // Re-layout
  1258         iAppUi.UiEngineL()->RenderUIL();
  1295         iAppUi.UiEngineL()->RenderUIL();
  1259         }
  1296         }
  1260     else
  1297     else
  1261         {
  1298         {
  1262         // Append transaction element to transaction
  1299         // Append transaction element to transaction
  1263         MTransaction* tr = iStack->Top();
  1300         MTransaction* tr( iStack->Top() );
  1264         tr->Append( *aElement );
  1301         tr->Append( *aElement );
  1265         }
  1302         }
  1266     }
  1303     }
  1267 
  1304 
       
  1305 // ----------------------------------------------------------------------------
       
  1306 // CContentRenderer::FindNodeByClassL
       
  1307 // 
       
  1308 // ----------------------------------------------------------------------------
       
  1309 //
  1268 CXnNodeAppIf* CContentRenderer::FindNodeByClassL( const TDesC& aCid,
  1310 CXnNodeAppIf* CContentRenderer::FindNodeByClassL( const TDesC& aCid,
  1269                                                   TInt aIndex,
  1311     TInt aIndex, const TDesC8& aNs )                                                  
  1270                                                   const TDesC8& aNs )
       
  1271     {
  1312     {
  1272     // Find node
  1313     // Find node
  1273     HBufC8* classId = CnvUtfConverter::ConvertFromUnicodeToUtf8L(aCid);
  1314     HBufC8* classId( CnvUtfConverter::ConvertFromUnicodeToUtf8L( aCid ) );
  1274     CleanupStack::PushL(classId);
  1315     CleanupStack::PushL( classId );
  1275     
  1316     
  1276     RPointerArray<CXnNodeAppIf> nodes = iAppUi.UiEngineL()->FindNodeByClassL( *classId, aNs );
  1317     RPointerArray<CXnNodeAppIf> nodes( 
  1277 
  1318         iAppUi.UiEngineL()->FindNodeByClassL( *classId, aNs ) );
  1278     CleanupStack::PopAndDestroy(classId);
  1319 
       
  1320     CleanupStack::PopAndDestroy( classId );
  1279 
  1321 
  1280     CleanupClosePushL( nodes );
  1322     CleanupClosePushL( nodes );
  1281 
  1323 
  1282     for ( TInt i = 0; i < nodes.Count(); ++i )
  1324     for ( TInt i = 0; i < nodes.Count(); ++i )
  1283         {
  1325         {
  1284         CXnNodeAppIf* node = nodes[i];
  1326         CXnNodeAppIf* node = nodes[i];
  1285 
  1327 
  1286         const TDesC8* name =
  1328         const TDesC8* name(
  1287             PropertyValue( *node, AiUiDef::xml::property::KName );
  1329             PropertyValue( *node, AiUiDef::xml::property::KName ) );
  1288 
  1330 
  1289         if ( name && ( *name == AiUiDef::xml::name::KOrdinal ) )
  1331         if ( name && ( *name == AiUiDef::xml::name::KOrdinal ) )
  1290             {
  1332             {
  1291             const TDesC8* value =
  1333             const TDesC8* value(
  1292                 PropertyValue( *node, AiUiDef::xml::property::KValue );
  1334                 PropertyValue( *node, AiUiDef::xml::property::KValue ) );
  1293 
  1335 
  1294             if ( value )
  1336             if ( value )
  1295                 {
  1337                 {
  1296                 // Try to parse index from string either
  1338                 // Try to parse index from string either
  1297 
       
  1298                 TInt32 index( 0 );
  1339                 TInt32 index( 0 );
       
  1340 
  1299                 User::LeaveIfError( AiUtility::ParseInt( index, *value ) );
  1341                 User::LeaveIfError( AiUtility::ParseInt( index, *value ) );
  1300 
  1342 
  1301                 if ( index == aIndex )
  1343                 if ( index == aIndex )
  1302                     {
  1344                     {
  1303                     CleanupStack::PopAndDestroy(&nodes);
  1345                     CleanupStack::PopAndDestroy( &nodes );
       
  1346                     
  1304                     return node;
  1347                     return node;
  1305                     }
  1348                     }
  1306                 }
  1349                 }
  1307             }
  1350             }
  1308         else if ( name && ( *name == AiUiDef::xml::name::KTarget ) )
  1351         else if ( name && ( *name == AiUiDef::xml::name::KTarget ) )
  1309             {            
  1352             {            
  1310             const TDesC8* target =
  1353             const TDesC8* target(
  1311                            PropertyValue( *node, AiUiDef::xml::property::KValue );
  1354                PropertyValue( *node, AiUiDef::xml::property::KValue ) );
  1312             
  1355             
  1313             CXnNodeAppIf* targetNode = FindNodeByIdL( *target, node->Namespace() );
  1356             CXnNodeAppIf* targetNode( 
       
  1357                 FindNodeByIdL( *target, node->Namespace() ) );
       
  1358             
  1314             if ( targetNode )
  1359             if ( targetNode )
  1315                 {
  1360                 {
  1316                 CleanupStack::PopAndDestroy( &nodes );
  1361                 CleanupStack::PopAndDestroy( &nodes );
       
  1362                 
  1317                 return targetNode;
  1363                 return targetNode;
  1318                 }
  1364                 }
  1319             }
  1365             }
  1320         else if ( nodes.Count() == 1 ) // Only one node in class
  1366         else if ( nodes.Count() == 1 ) // Only one node in class
  1321             {
  1367             {
  1322             // No ordinal specified
  1368             node = nodes[ 0 ];
  1323 			node = nodes[ 0 ];
  1369             
  1324 			CleanupStack::PopAndDestroy(&nodes);
  1370             // No ordinal specified			
       
  1371 			CleanupStack::PopAndDestroy( &nodes );
       
  1372 			
  1325             return node;
  1373             return node;
  1326             }
  1374             }
  1327         }
  1375         }
  1328     
  1376     
  1329     CleanupStack::PopAndDestroy( &nodes );
  1377     CleanupStack::PopAndDestroy( &nodes );
  1330     
  1378     
  1331     return NULL; // Never reached. Needed to omit compiler warning
  1379     return NULL; // Never reached. Needed to omit compiler warning
  1332     }
  1380     }
  1333 
  1381 
  1334 CXnNodeAppIf* CContentRenderer::FindNodeByIdL( const TDesC& aCid, const TDesC& aNs )
  1382 // ----------------------------------------------------------------------------
       
  1383 // CContentRenderer::FindNodeByIdL
       
  1384 // 
       
  1385 // ----------------------------------------------------------------------------
       
  1386 //
       
  1387 CXnNodeAppIf* CContentRenderer::FindNodeByIdL( const TDesC& aCid, 
       
  1388     const TDesC& aNs )
  1335     {
  1389     {
  1336     // Find node
  1390     // Find node
  1337     return LeaveIfNull( iAppUi.UiEngineL()->FindNodeByIdL( aCid, aNs ),
  1391     return LeaveIfNull( 
  1338                         KErrNotFound );
  1392         iAppUi.UiEngineL()->FindNodeByIdL( aCid, aNs ), KErrNotFound );                        
  1339     }
  1393     }
  1340 
  1394 
  1341 CXnNodeAppIf* CContentRenderer::FindNodeByIdL( const TDesC8& aCid, const TDesC8& aNs )
  1395 // ----------------------------------------------------------------------------
       
  1396 // CContentRenderer::FindNodeByIdL
       
  1397 // 
       
  1398 // ----------------------------------------------------------------------------
       
  1399 //
       
  1400 CXnNodeAppIf* CContentRenderer::FindNodeByIdL( const TDesC8& aCid, 
       
  1401     const TDesC8& aNs )
  1342     {
  1402     {
  1343     // Find node
  1403     // Find node
  1344     return LeaveIfNull( iAppUi.UiEngineL()->FindNodeByIdL( aCid, aNs ),
  1404     return LeaveIfNull( 
  1345                         KErrNotFound );
  1405         iAppUi.UiEngineL()->FindNodeByIdL( aCid, aNs ), KErrNotFound );                        
  1346     }
  1406     }
  1347 
  1407 
  1348 TInt CContentRenderer::PublishIconL( MAiPropertyExtension& aPlugin,
  1408 // ----------------------------------------------------------------------------
  1349                                      const TDesC& aCid,
  1409 // CContentRenderer::PublishIconL
  1350                                      CGulIcon* aIcon,
  1410 // 
  1351                                      TInt aIndex,
  1411 // ----------------------------------------------------------------------------
  1352                                      CXnNodeAppIf* aResource )
  1412 //
  1353     {
  1413 TInt CContentRenderer::PublishIconL( CHsContentPublisher& aPlugin,
       
  1414     const TDesC& aCid, CGulIcon* aIcon, TInt aIndex, CXnNodeAppIf* aResource )
       
  1415     {
       
  1416     const THsPublisherInfo& info( aPlugin.PublisherInfo() );
       
  1417     
  1354     // Find proiperty element by class
  1418     // Find proiperty element by class
  1355     CXnNodeAppIf* property( FindNodeByClassL( aCid, aIndex, 
  1419     CXnNodeAppIf* property( 
  1356                             aPlugin.PublisherInfoL()->iNamespace ) );
  1420         FindNodeByClassL( aCid, aIndex, info.Namespace() ) );                             
  1357     
  1421     
  1358     if( !property )
  1422     if( !property )
  1359         {
  1423         {
  1360         return KErrNotFound;
  1424         return KErrNotFound;
  1361         }
  1425         }
  1362     
  1426     
  1363     // Get priority information
  1427     // Get priority information
  1364     TInt priority( GetContentPriority( *property ) );
  1428     TInt priority( ContentPriority( *property ) );
  1365     
  1429     
  1366     // Navigate to parent
  1430     // Navigate to parent
  1367     CXnNodeAppIf* target( property->ParentL() );
  1431     CXnNodeAppIf* target( property->ParentL() );
  1368     
  1432     
  1369     if( !target )
  1433     if( !target )
  1388             return KErrNotFound;
  1452             return KErrNotFound;
  1389             }
  1453             }
  1390                 
  1454                 
  1391         RegisterNewstickerCallbackInterfaceL( *parent );
  1455         RegisterNewstickerCallbackInterfaceL( *parent );
  1392         
  1456         
  1393         const TAiPublisherInfo* info( aPlugin.PublisherInfoL() );
  1457         iNTPublisher.Set( info.Name() );
  1394         
  1458         iNTClass = AiUtility::CopyToBufferL( iNTClass, aCid );
  1395         if( info )
       
  1396             {
       
  1397             iNTPublisher.Set( info->iName );
       
  1398             iNTClass = AiUtility::CopyToBufferL( iNTClass, aCid );
       
  1399             }
       
  1400         }
  1459         }
  1401 
  1460 
  1402     MTransactionElement* element =
  1461     MTransactionElement* element =
  1403         iFactory->CreateImageTransactionElementL( *target,
  1462         iFactory->CreateImageTransactionElementL( 
  1404                                                   aIcon,
  1463             *target, aIcon, priority );
  1405                                                   priority );
       
  1406 
  1464 
  1407     if ( aResource )
  1465     if ( aResource )
  1408         {
  1466         {
  1409         iPolicyEvaluator->EvaluateResourcePolicyL( *target,
  1467         iPolicyEvaluator->EvaluateResourcePolicyL( 
  1410                                                    *aResource,
  1468             *target, *aResource, element->PolicyArray() );
  1411                                                    element->PolicyArray() );
  1469 
  1412         iPolicyEvaluator->EvaluateContentPolicyL( *target,
  1470         iPolicyEvaluator->EvaluateContentPolicyL( 
  1413                                                   element->PolicyArray() );
  1471             *target, element->PolicyArray() );
  1414         iPolicyEvaluator->EvaluateVisibilityPolicyL( *target,
  1472                                                   
  1415                                                      element->PolicyArray() );
  1473         iPolicyEvaluator->EvaluateVisibilityPolicyL( 
       
  1474             *target, element->PolicyArray() );                                                     
  1416         }
  1475         }
  1417 
  1476 
  1418     else
  1477     else
  1419         {
  1478         {
  1420         iPolicyEvaluator->EvaluateContentPolicyL( *target,
  1479         iPolicyEvaluator->EvaluateContentPolicyL( 
  1421                                                   element->PolicyArray() );
  1480             *target, element->PolicyArray() );
  1422         iPolicyEvaluator->EvaluateVisibilityPolicyL( *target,
  1481                                                   
  1423                                                      element->PolicyArray() );
  1482         iPolicyEvaluator->EvaluateVisibilityPolicyL( 
       
  1483             *target, element->PolicyArray() );                                                    
  1424         }
  1484         }
  1425 
  1485 
  1426     ProcessTransactionElementL( element );
  1486     ProcessTransactionElementL( element );
  1427     
  1487     
  1428     return KErrNone;
  1488     return KErrNone;
  1429     }
  1489     }
  1430 
  1490 
  1431 TInt CContentRenderer::PublishDataL( MAiPropertyExtension& aPlugin,
  1491 // ----------------------------------------------------------------------------
  1432                                      const TDesC& aCid,
  1492 // CContentRenderer::PublishDataL
  1433                                      const TDesC8& aData,
  1493 // 
  1434                                      const TDesC8& aContentType,
  1494 // ----------------------------------------------------------------------------
  1435                                      TInt aIndex,
  1495 //
  1436                                      CXnNodeAppIf* aResource )
  1496 TInt CContentRenderer::PublishDataL( CHsContentPublisher& aPlugin,
  1437     {
  1497     const TDesC& aCid, const TDesC8& aData, const TDesC8& aContentType,
  1438     CXnNodeAppIf* property( FindNodeByClassL( aCid, aIndex, 
  1498     TInt aIndex, CXnNodeAppIf* aResource )                                     
  1439                             aPlugin.PublisherInfoL()->iNamespace ) );
  1499     {
       
  1500     const THsPublisherInfo& info( aPlugin.PublisherInfo() );
       
  1501     
       
  1502     CXnNodeAppIf* property( 
       
  1503         FindNodeByClassL( aCid, aIndex, info.Namespace() ) );                             
  1440 
  1504 
  1441     if( !property )
  1505     if( !property )
  1442         {
  1506         {
  1443         return KErrNotFound;
  1507         return KErrNotFound;
  1444         }
  1508         }
  1445     
  1509     
  1446     TInt priority( GetContentPriority( *property ) );
  1510     TInt priority( ContentPriority( *property ) );
  1447     
  1511     
  1448     // Navigate to parent
  1512     // Navigate to parent
  1449     CXnNodeAppIf* target( property->ParentL() );
  1513     CXnNodeAppIf* target( property->ParentL() );
  1450     
  1514     
  1451     if( !target )
  1515     if( !target )
  1456     if ( !AllowPublishByPriority( *target, priority ) )
  1520     if ( !AllowPublishByPriority( *target, priority ) )
  1457         {
  1521         {
  1458         return KErrAccessDenied;        
  1522         return KErrAccessDenied;        
  1459         }
  1523         }
  1460 
  1524 
       
  1525     if( aContentType == KContentTypeData )
       
  1526         {
       
  1527         CXnComponent& component( target->ParentL()->Component() );
       
  1528         component.SetDataL( aData, aCid, aIndex );
       
  1529         return KErrNone;
       
  1530         }
       
  1531 
  1461     if ( !CDataBufferTransactionElement::IsSupported( *target, aContentType ) )
  1532     if ( !CDataBufferTransactionElement::IsSupported( *target, aContentType ) )
  1462         {
  1533         {
  1463         return KErrNotSupported;        
  1534         return KErrNotSupported;        
  1464         }
  1535         }
  1465         
  1536         
  1473             return KErrNotFound;
  1544             return KErrNotFound;
  1474             }
  1545             }
  1475                 
  1546                 
  1476         RegisterNewstickerCallbackInterfaceL( *parent );
  1547         RegisterNewstickerCallbackInterfaceL( *parent );
  1477         
  1548         
  1478         const TAiPublisherInfo* info( aPlugin.PublisherInfoL() );
  1549         iNTPublisher.Set( info.Name() );
  1479         
  1550         iNTClass = AiUtility::CopyToBufferL( iNTClass, aCid );
  1480         if( info )
       
  1481             {
       
  1482             iNTPublisher.Set( info->iName );
       
  1483             iNTClass = AiUtility::CopyToBufferL( iNTClass, aCid );
       
  1484             }
       
  1485         }
  1551         }
  1486         
  1552         
  1487     MTransactionElement* element =
  1553     MTransactionElement* element =
  1488         iFactory->CreateDataBufferTransactionElementL( *target,
  1554         iFactory->CreateDataBufferTransactionElementL( 
  1489                                                        aData,
  1555             *target, aData, priority );
  1490                                                        priority );
  1556                                                        
  1491     
       
  1492     if ( aResource )
  1557     if ( aResource )
  1493         {
  1558         {
  1494         iPolicyEvaluator->EvaluateResourcePolicyL( *target,
  1559         iPolicyEvaluator->EvaluateResourcePolicyL( 
  1495                                                    *aResource,
  1560             *target, *aResource, element->PolicyArray() );
  1496                                                    element->PolicyArray() );
  1561                                                    
  1497         iPolicyEvaluator->EvaluateContentPolicyL( *target,
  1562         iPolicyEvaluator->EvaluateContentPolicyL( 
  1498                                                   element->PolicyArray() );
  1563             *target, element->PolicyArray() );
  1499         iPolicyEvaluator->EvaluateVisibilityPolicyL( *target,
  1564                                                   
  1500                                                      element->PolicyArray() );
  1565         iPolicyEvaluator->EvaluateVisibilityPolicyL( 
       
  1566             *target, element->PolicyArray() );                                                     
  1501         }
  1567         }
  1502     else
  1568     else
  1503         {
  1569         {
  1504         iPolicyEvaluator->EvaluateContentPolicyL( *target,
  1570         iPolicyEvaluator->EvaluateContentPolicyL( 
  1505                                                   element->PolicyArray() );
  1571             *target, element->PolicyArray() );
  1506         iPolicyEvaluator->EvaluateVisibilityPolicyL( *target,
  1572                                                   
  1507                                                      element->PolicyArray() );
  1573         iPolicyEvaluator->EvaluateVisibilityPolicyL( 
       
  1574             *target, element->PolicyArray() );                                                     
  1508         }
  1575         }
  1509 
  1576 
  1510     ProcessTransactionElementL( element );
  1577     ProcessTransactionElementL( element );
  1511     
  1578     
  1512     return KErrNone;
  1579     return KErrNone;
  1513     }
  1580     }
  1514 
  1581 
       
  1582 // ----------------------------------------------------------------------------
       
  1583 // CContentRenderer::SetProperty
       
  1584 // 
       
  1585 // ----------------------------------------------------------------------------
       
  1586 //
       
  1587 TInt CContentRenderer::SetProperty( CHsContentPublisher& aPlugin,
       
  1588     const TDesC8& aElementId, const TDesC8& aPropertyName, 
       
  1589     const TDesC8& aPropertyValue )
       
  1590     {
       
  1591    return ( SetProperty( aPlugin, aElementId, 
       
  1592                aPropertyName, aPropertyValue,
       
  1593                MAiContentObserver::EValueString ) );
       
  1594     }
       
  1595 
       
  1596 // ----------------------------------------------------------------------------
       
  1597 // CContentRenderer::SetProperty
       
  1598 // 
       
  1599 // ----------------------------------------------------------------------------
       
  1600 //
       
  1601 TInt CContentRenderer::SetProperty( CHsContentPublisher& aPlugin,
       
  1602     const TDesC8& aElementId, const TDesC8& aPropertyName,        
       
  1603     const TDesC8& aPropertyValue, MAiContentObserver::TValueType aValueType )     
       
  1604     {
       
  1605     TInt error( KErrNone );
       
  1606     TInt retval( KErrNone );
       
  1607 
       
  1608     TRAP( error, retval = SetPropertyL( aPlugin, aElementId, aPropertyName,
       
  1609             aPropertyValue, aValueType ) );
       
  1610     
       
  1611     if( !error && retval )
       
  1612      {
       
  1613      error = retval;
       
  1614      }
       
  1615     
       
  1616     return error;
       
  1617     }
       
  1618 
       
  1619 // ----------------------------------------------------------------------------
       
  1620 // CContentRenderer::SetPropertyL
       
  1621 // 
       
  1622 // ----------------------------------------------------------------------------
       
  1623 //
       
  1624 TInt CContentRenderer::SetPropertyL( CHsContentPublisher& aPlugin,
       
  1625     const TDesC8& aElementId, const TDesC8& aPropertyName,    
       
  1626     const TDesC8& aPropertyValue, MAiContentObserver::TValueType aValueType )         
       
  1627     {
       
  1628     TInt err( KErrNone ); 
       
  1629     // Find node
       
  1630     
       
  1631     CXnNodeAppIf* targetNode( 
       
  1632         FindNodeByIdL( aElementId, aPlugin.PublisherInfo().Namespace() ) );
       
  1633     
       
  1634     if ( targetNode )
       
  1635        {
       
  1636        CXnDomStringPool& sp( targetNode->UiEngineL()->StringPool() );
       
  1637               
       
  1638        CXnProperty* prop = CXnProperty::NewL( 
       
  1639                aPropertyName,
       
  1640                aPropertyValue,
       
  1641                DomPropertyValueType(aValueType), sp );
       
  1642                       
       
  1643        CleanupStack::PushL( prop );
       
  1644     
       
  1645        targetNode->SetPropertyL( prop );
       
  1646       
       
  1647        CleanupStack::Pop( prop );
       
  1648        }
       
  1649     else
       
  1650        {
       
  1651        err = KErrNotFound;
       
  1652        }
       
  1653     
       
  1654     return err;
       
  1655     }
       
  1656 
       
  1657 // ----------------------------------------------------------------------------
       
  1658 // CContentRenderer::DomPropertyValueType
       
  1659 // 
       
  1660 // ----------------------------------------------------------------------------
       
  1661 //
       
  1662 CXnDomPropertyValue::TPrimitiveValueType CContentRenderer::DomPropertyValueType(     
       
  1663     MAiContentObserver::TValueType aValueType )
       
  1664     {
       
  1665     CXnDomPropertyValue::TPrimitiveValueType type(
       
  1666             CXnDomPropertyValue::EUnknown );
       
  1667     
       
  1668     switch ( aValueType )
       
  1669         {
       
  1670         case MAiContentObserver::EValueNumber :
       
  1671             {
       
  1672             type = CXnDomPropertyValue::ENumber;
       
  1673             }
       
  1674             break;
       
  1675         case MAiContentObserver::EValuePercentage :
       
  1676             {
       
  1677             type = CXnDomPropertyValue::EPercentage;
       
  1678             }
       
  1679             break;
       
  1680         case MAiContentObserver::EValuePx :
       
  1681             {
       
  1682             type = CXnDomPropertyValue::EPx;
       
  1683             }
       
  1684             break;
       
  1685         case MAiContentObserver::EValueString :
       
  1686             {
       
  1687             type = CXnDomPropertyValue::EString;
       
  1688             }
       
  1689             break;
       
  1690         case MAiContentObserver::EValueRgbColor :
       
  1691             {
       
  1692             type = CXnDomPropertyValue::ERgbColor;
       
  1693             }
       
  1694             break;
       
  1695         case MAiContentObserver::EValueUnitValue :
       
  1696             {
       
  1697             type = CXnDomPropertyValue::EUnitValue;
       
  1698             }
       
  1699             break;
       
  1700         default:
       
  1701             {
       
  1702             type = CXnDomPropertyValue::EUnknown;
       
  1703             }
       
  1704         }
       
  1705     
       
  1706     return type;
       
  1707     }
       
  1708 
       
  1709 // ----------------------------------------------------------------------------
       
  1710 // CContentRenderer::AllowPublishByPriority
       
  1711 // 
       
  1712 // ----------------------------------------------------------------------------
       
  1713 //
  1515 TBool CContentRenderer::AllowPublishByPriority( CXnNodeAppIf& aUiElement,
  1714 TBool CContentRenderer::AllowPublishByPriority( CXnNodeAppIf& aUiElement,
  1516                                                 TInt aPriority ) const
  1715     TInt aPriority ) const
  1517     {
  1716     {
  1518     // Get ui element id
  1717     // Get ui element id
  1519     const TDesC8* uiElementId = PropertyValue( aUiElement,
  1718     const TDesC8* uiElementId( 
  1520                                                XnPropertyNames::common::KId );
  1719         PropertyValue( aUiElement, XnPropertyNames::common::KId ) );
  1521                                          
  1720                                                                                         
  1522     if ( uiElementId )
  1721     if ( uiElementId )
  1523         {
  1722         {
  1524         // compare given priority with the current value of ui element
  1723         // compare given priority with the current value of ui element
  1525         return iContentPriorityMap->OverrideContent( *uiElementId, aPriority );
  1724         return iContentPriorityMap->OverrideContent( *uiElementId, aPriority );
  1526         }
  1725         }
  1527     
  1726     
  1528     return EFalse; // priority cannot be used, because ui element does not have id
  1727     // priority cannot be used, because ui element does not have id
  1529     }
  1728     return EFalse; 
  1530 
  1729     }
       
  1730 
       
  1731 // ----------------------------------------------------------------------------
       
  1732 // CContentRenderer::StartContentRefresh
       
  1733 // 
       
  1734 // ----------------------------------------------------------------------------
       
  1735 //
  1531 void CContentRenderer::StartContentRefresh()
  1736 void CContentRenderer::StartContentRefresh()
  1532     {
  1737     {
  1533     // Cancel ongoing refresh
  1738     // Cancel ongoing refresh
  1534     iTimer->Cancel();
  1739     iTimer->Cancel();
  1535     
  1740     
  1540                        TTimeIntervalMicroSeconds32( 0 ),
  1745                        TTimeIntervalMicroSeconds32( 0 ),
  1541                        TCallBack( RefreshContentCallback, this ) );
  1746                        TCallBack( RefreshContentCallback, this ) );
  1542         }
  1747         }
  1543     }
  1748     }
  1544 
  1749 
  1545 /**
  1750 // ----------------------------------------------------------------------------
  1546  * Adds ui element to list of refreshable elements
  1751 // CContentRenderer::RefreshContentL
  1547  *
  1752 // 
  1548  * @param aUiElementId ui element id
  1753 // ----------------------------------------------------------------------------
  1549  * @param aOldPriority old priority value
  1754 //
  1550  */                         
       
  1551 TInt CContentRenderer::RefreshContentL( HBufC* aUiElementId,
  1755 TInt CContentRenderer::RefreshContentL( HBufC* aUiElementId,
  1552                                         TInt aOldPriority )
  1756     TInt aOldPriority )
  1553     {
  1757     {
  1554     if( !aUiElementId )
  1758     if( !aUiElementId )
  1555         {
  1759         {
  1556         return KErrArgument;
  1760         return KErrArgument;
  1557         }
  1761         }
  1561     
  1765     
  1562     if ( !iFwEventHandler )
  1766     if ( !iFwEventHandler )
  1563         {
  1767         {
  1564         // Content refresh event cannot be sent
  1768         // Content refresh event cannot be sent
  1565         CleanupStack::PopAndDestroy( aUiElementId );
  1769         CleanupStack::PopAndDestroy( aUiElementId );
       
  1770     
  1566         return KErrNotReady;
  1771         return KErrNotReady;
  1567         }
  1772         }
  1568     
  1773     
  1569     // Find current mapping
  1774     // Find current mapping
  1570     TInt* oldPriority = iRefreshableUiElements.Find( *aUiElementId );
  1775     TInt* oldPriority( iRefreshableUiElements.Find( *aUiElementId ) );
  1571     
  1776     
  1572     if ( oldPriority )
  1777     if ( oldPriority )
  1573         {
  1778         {
  1574         // Update mapping
  1779         // Update mapping
  1575         *oldPriority = aOldPriority;
  1780         *oldPriority = aOldPriority;
  1588         }
  1793         }
  1589     
  1794     
  1590     return KErrNone;
  1795     return KErrNone;
  1591     }
  1796     }
  1592 
  1797 
  1593 /**
  1798 // ----------------------------------------------------------------------------
  1594  * Callback function to make content refreshing asynchronous
  1799 // CContentRenderer::RefreshContentCallback
  1595  */    
  1800 // 
       
  1801 // ----------------------------------------------------------------------------
       
  1802 //
  1596 TInt CContentRenderer::RefreshContentCallback( TAny* aContentRenderer )
  1803 TInt CContentRenderer::RefreshContentCallback( TAny* aContentRenderer )
  1597     {
  1804     {
  1598     if ( !aContentRenderer )
  1805     if ( !aContentRenderer )
  1599         {
  1806         {
  1600         return KErrArgument;
  1807         return KErrArgument;
  1601         }
  1808         }
  1602         
  1809         
  1603     CContentRenderer* renderer = static_cast< CContentRenderer* >( aContentRenderer );
  1810     CContentRenderer* self = 
  1604     TRAP_IGNORE( renderer->SendRefreshContentEventL() );
  1811         static_cast< CContentRenderer* >( aContentRenderer );
       
  1812     
       
  1813     TRAP_IGNORE( self->SendRefreshContentEventL() );
       
  1814     
  1605     return KErrNone;
  1815     return KErrNone;
  1606     }
  1816     }
  1607 
  1817 
  1608 /**
  1818 // ----------------------------------------------------------------------------
  1609  * Sends Refresh content event to framework.
  1819 // CContentRenderer::SendRefreshContentEventL
  1610  * Event is sent for content selectors with lower priority than the
  1820 // 
  1611  * last content which has been cleaned from ui element.
  1821 // ----------------------------------------------------------------------------
  1612  */ 
  1822 //
  1613 void CContentRenderer::SendRefreshContentEventL()
  1823 void CContentRenderer::SendRefreshContentEventL()
  1614     {
  1824     {
       
  1825     /**
       
  1826      * Sends Refresh content event to framework.
       
  1827      * Event is sent for content selectors with lower priority than the
       
  1828      * last content which has been cleaned from ui element.
       
  1829      */ 
       
  1830 
  1615     // Cancel periodic timer.
  1831     // Cancel periodic timer.
  1616     iTimer->Cancel();
  1832     iTimer->Cancel();
  1617     
  1833     
  1618     // Get ui element id and old content priority
  1834     // Get ui element id and old content priority
  1619     TPtrHashMapIter< TDesC, TInt> iter( iRefreshableUiElements );
  1835     TPtrHashMapIter< TDesC, TInt> iter( iRefreshableUiElements );
  1620     iter.Reset();
  1836     iter.Reset();
  1621     
  1837     
  1622     const TDesC* uiElementId = iter.NextKey(); // Never NULL
  1838     const TDesC* uiElementId( iter.NextKey() ); // Never NULL
  1623     TInt priority = *( iter.CurrentValue() );
  1839     TInt priority( *( iter.CurrentValue() ) );
  1624     
  1840     
  1625     //  Cleanup item for iterator 
  1841     //  Cleanup item for iterator 
  1626     TMapCleanupItem cleanup( iter );
  1842     TMapCleanupItem cleanup( iter );
  1627     CleanupReleasePushL( cleanup );
  1843     CleanupReleasePushL( cleanup );
  1628     
  1844     
  1629     // Lookup ui element
  1845     // Lookup ui element
  1630     CXnNodeAppIf* uiElement = FindNodeByIdL( *uiElementId );
  1846     CXnNodeAppIf* uiElement( FindNodeByIdL( *uiElementId ) );
  1631     
  1847     
  1632     // Remove current ui element from the map
  1848     // Remove current ui element from the map
  1633     CleanupStack::PopAndDestroy( &cleanup );
  1849     CleanupStack::PopAndDestroy( &cleanup );
  1634     
  1850     
  1635     // Find lower priority content elements associated to this ui element
  1851     // Find lower priority content elements associated to this ui element
  1636     RPointerArray< CXnNodeAppIf > children = uiElement->ChildrenL();
  1852     RPointerArray< CXnNodeAppIf > children( uiElement->ChildrenL() );
  1637     
  1853     
  1638     // Remove higher priority content elements
  1854     // Remove higher priority content elements
  1639     RemoveNonPriorityElements( children, priority );
  1855     RemoveNonPriorityElements( children, priority );
  1640         
  1856         
  1641     // Sort array to descending order
  1857     // Sort array to descending order
  1643     
  1859     
  1644     // Send event for content selectors in descending priority order.
  1860     // Send event for content selectors in descending priority order.
  1645     // Continue until first content gets published or array exhausts.
  1861     // Continue until first content gets published or array exhausts.
  1646     for ( TInt i = 0; i < children.Count(); ++i )
  1862     for ( TInt i = 0; i < children.Count(); ++i )
  1647         {
  1863         {
  1648         CXnNodeAppIf* current = children[ i ];
  1864         CXnNodeAppIf* current( children[ i ] );
  1649         
  1865         
  1650         // Get content selector
  1866         // Get content selector
  1651         const HBufC* contentSelector = PropertyValueL( *current,
  1867         const HBufC* contentSelector( 
  1652                                                        XnPropertyNames::common::KClass );
  1868             PropertyValueL( *current, XnPropertyNames::common::KClass ) );
  1653         
  1869                                                                
  1654         if ( contentSelector && iFwEventHandler->RefreshContent( *contentSelector ))
  1870         if ( contentSelector && 
       
  1871             iFwEventHandler->RefreshContent( *contentSelector ) )
  1655             {
  1872             {
  1656             break;
  1873             break;
  1657             }
  1874             }
  1658         }
  1875         }
  1659     
  1876     
  1662     
  1879     
  1663     // Continue content refresh for next ui element.
  1880     // Continue content refresh for next ui element.
  1664     StartContentRefresh();    
  1881     StartContentRefresh();    
  1665     }
  1882     }
  1666 
  1883 
       
  1884 // ----------------------------------------------------------------------------
       
  1885 // CContentRenderer::TitleScrolled
       
  1886 // 
       
  1887 // ----------------------------------------------------------------------------
       
  1888 //
  1667 void CContentRenderer::TitleScrolled( TInt aTitleIndex )
  1889 void CContentRenderer::TitleScrolled( TInt aTitleIndex )
  1668     {
  1890     {
  1669     if ( iCallbackHandler )
  1891     if ( iCallbackHandler )
  1670         {
  1892         {
  1671         TRAP_IGNORE( iCallbackHandler->TitleScrolledL( iNTPublisher,
  1893         TRAP_IGNORE( iCallbackHandler->TitleScrolledL( 
  1672                                                        *iNTClass,
  1894             iNTPublisher, *iNTClass, aTitleIndex ) );
  1673                                                        aTitleIndex ) );
  1895         }
  1674         }
  1896     }
  1675     }
  1897 
  1676     
  1898 // ----------------------------------------------------------------------------
       
  1899 // CContentRenderer::TitleToScroll
       
  1900 // 
       
  1901 // ----------------------------------------------------------------------------
       
  1902 //
  1677 void CContentRenderer::TitleToScroll( TInt aTitleIndex )
  1903 void CContentRenderer::TitleToScroll( TInt aTitleIndex )
  1678     {
  1904     {
  1679     if ( iCallbackHandler )
  1905     if ( iCallbackHandler )
  1680         {
  1906         {
  1681         TRAP_IGNORE( iCallbackHandler->TitleToScrollL( iNTPublisher,
  1907         TRAP_IGNORE( iCallbackHandler->TitleToScrollL( 
  1682                                                        *iNTClass,
  1908             iNTPublisher, *iNTClass, aTitleIndex ) );
  1683                                                        aTitleIndex ) );        
  1909         }
  1684         }
  1910     }
  1685     }
  1911 
  1686 
  1912 // ----------------------------------------------------------------------------
       
  1913 // CContentRenderer::IsParentNewsticker
       
  1914 // 
       
  1915 // ----------------------------------------------------------------------------
       
  1916 //
  1687 TBool CContentRenderer::IsParentNewsticker( CXnNodeAppIf& aTarget )
  1917 TBool CContentRenderer::IsParentNewsticker( CXnNodeAppIf& aTarget )
  1688     {
  1918     {
  1689     CXnNodeAppIf* parent = NULL;
  1919     CXnNodeAppIf* parent( NULL );
       
  1920     
  1690     TRAP_IGNORE( parent = aTarget.ParentL() );
  1921     TRAP_IGNORE( parent = aTarget.ParentL() );
       
  1922     
  1691     if ( !parent )
  1923     if ( !parent )
  1692         {
  1924         {
  1693         return EFalse;
  1925         return EFalse;
  1694         }
  1926         }
  1695     CXnType* typeInfo = parent->Type();
  1927     
  1696     
  1928     const TDesC8& type( parent->Type()->Type() ) ;
  1697     if ( !typeInfo )
  1929             
  1698         {
  1930     return ( type == XnNewstickerInterface::MXnNewstickerInterface::Type() );
  1699         return EFalse;
  1931     }
  1700         }
  1932     
  1701         
  1933 // ----------------------------------------------------------------------------
  1702     return ( typeInfo->Type() == XnNewstickerInterface::MXnNewstickerInterface::Type());
  1934 // CContentRenderer::RegisterNewstickerCallbackInterfaceL
  1703     }
  1935 // 
  1704     
  1936 // ----------------------------------------------------------------------------
  1705 void CContentRenderer::RegisterNewstickerCallbackInterfaceL( CXnNodeAppIf& aTarget )
  1937 //
       
  1938 void CContentRenderer::RegisterNewstickerCallbackInterfaceL( 
       
  1939     CXnNodeAppIf& aTarget )
  1706     {
  1940     {
  1707     if ( !iCallbackHandler )
  1941     if ( !iCallbackHandler )
  1708         {
  1942         {
  1709         // Instantiate callback handler
  1943         // Instantiate callback handler
  1710         CNewstickerCallbackHandler* handler = CNewstickerCallbackHandler::NewLC( *iFwEventHandler );
  1944         CNewstickerCallbackHandler* handler = 
       
  1945             CNewstickerCallbackHandler::NewLC( *iFwEventHandler );
  1711 
  1946 
  1712         // Set callback handler
  1947         // Set callback handler
  1713         iCallbackHandler = handler;
  1948         iCallbackHandler = handler;
  1714         CleanupStack::Pop( handler );
  1949         CleanupStack::Pop( handler );
  1715         }
  1950         }
  1716         // Obtain newsticker component interface
  1951 
  1717         XnNewstickerInterface::MXnNewstickerInterface* newsticker = NULL;
  1952     // Obtain newsticker component interface
  1718         XnComponentInterface::MakeInterfaceL( newsticker, aTarget );
  1953     XnNewstickerInterface::MXnNewstickerInterface* newsticker( NULL );
  1719         
  1954     XnComponentInterface::MakeInterfaceL( newsticker, aTarget );
  1720         LeaveIfNull( newsticker, KErrGeneral );
  1955     
  1721         
  1956     LeaveIfNull( newsticker, KErrGeneral );
  1722         // Set callback interface
  1957     
  1723         newsticker->SetCallbackInterfaceL( this );
  1958     // Set callback interface
  1724     }
  1959     newsticker->SetCallbackInterfaceL( this );
  1725 
       
  1726 void CContentRenderer::CleanPluginFromUiL( MAiPropertyExtension& aPlugin )
       
  1727     {
       
  1728     TInt itemCount = 0;
       
  1729     
       
  1730     // Resolve content items
       
  1731     MAiContentItemIterator& iter = ContentItemIteratorL( aPlugin, EAiPublisherContent );
       
  1732     iter.Reset();
       
  1733     
       
  1734     // Clean all content items
       
  1735     while ( iter.HasNext() )
       
  1736         {
       
  1737         const TAiContentItem& item = iter.NextL();
       
  1738 
       
  1739         const TDesC& nodeId = iNodeIdGenerator->ContentNodeIdL( aPlugin, item );
       
  1740         
       
  1741         // Find nodes
       
  1742         HBufC8* nodeId8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L(nodeId);
       
  1743         CleanupStack::PushL(nodeId8);
       
  1744 
       
  1745         RPointerArray<CXnNodeAppIf> nodes = iAppUi.UiEngineL()->FindNodeByClassL( 
       
  1746             *nodeId8, aPlugin.PublisherInfoL()->iNamespace );
       
  1747 
       
  1748         CleanupStack::PopAndDestroy(nodeId8);
       
  1749 
       
  1750         itemCount += nodes.Count(); 
       
  1751         
       
  1752         CleanupClosePushL( nodes );
       
  1753 
       
  1754         for ( TInt i = 0; i < nodes.Count(); ++i )
       
  1755             {
       
  1756             CXnNodeAppIf* property = nodes[i];
       
  1757             
       
  1758             TInt priority = GetContentPriority( *property );
       
  1759 
       
  1760             // Navigate to parent
       
  1761             CXnNodeAppIf* target = LeaveIfNull( property->ParentL(), KErrNotFound );
       
  1762 
       
  1763             if ( AllowPublishByPriority( *target, priority ) )
       
  1764                 {
       
  1765                 // Create transaction element for empty content
       
  1766                 MTransactionElement* element =
       
  1767                     iFactory->CreateEmptyContentTransactionElementL( *target, 0 );
       
  1768 
       
  1769                 iPolicyEvaluator->EvaluateEmptyContentPolicyL( *target,
       
  1770                                                                element->PolicyArray() );
       
  1771                 iPolicyEvaluator->EvaluateVisibilityPolicyL( *target,
       
  1772                                                                element->PolicyArray() );
       
  1773                                                       
       
  1774                 ProcessTransactionElementL( element );
       
  1775                   
       
  1776                 if ( priority > KErrNotFound ) // Only for prioritized elements
       
  1777                     {
       
  1778                     // Add current ui element into content refresh map
       
  1779                     HBufC* uiElementId = PropertyValueL( *target,
       
  1780                                                          XnPropertyNames::common::KId );
       
  1781                     RefreshContentL( uiElementId, priority );
       
  1782                     }
       
  1783                 }
       
  1784             }
       
  1785             
       
  1786         CleanupStack::PopAndDestroy(&nodes);
       
  1787         }
       
  1788         
       
  1789     if ( itemCount == 0 )
       
  1790         {
       
  1791         //Nothing to clean from UI. Cancel transaction outside current trap harness
       
  1792         User::Leave( KErrNotFound );
       
  1793         }
       
  1794     }
  1960     }
  1795 
  1961 
  1796 //  End of File
  1962 //  End of File