idlehomescreen/xmluirendering/uiengine/src/xneditor.cpp
branchRCL_3
changeset 19 79311d856354
parent 18 d05a55b217df
child 25 137ebc85284b
equal deleted inserted replaced
18:d05a55b217df 19:79311d856354
    93     };
    93     };
    94 
    94 
    95 // ====================== LOCAL FUNTION PROTOTYPES ============================
    95 // ====================== LOCAL FUNTION PROTOTYPES ============================
    96 static void DeletePluginInfos( TAny* aObject );
    96 static void DeletePluginInfos( TAny* aObject );
    97 static void DeleteItemMaps( TAny* aObject );
    97 static void DeleteItemMaps( TAny* aObject );
       
    98 static void DeleteContentInfo( TAny* aObject );
    98 
    99 
    99 static TPtrC ParseWidgetName( const CHsContentInfo& aContentInfo );
   100 static TPtrC ParseWidgetName( const CHsContentInfo& aContentInfo );
   100 static void SetPropertyL( CXnNode& aNode, const TDesC8& aAttribute, 
   101 static void SetPropertyL( CXnNode& aNode, const TDesC8& aAttribute, 
   101                           const TDesC8& aValue );    
   102                           const TDesC8& aValue );    
   102 static void ShowErrorNoteL( const TDesC& aMsg );      
   103 static void ShowErrorNoteL( const TDesC& aMsg );      
   129         RPointerArray< hspswrapper::CItemMap >* >(
   130         RPointerArray< hspswrapper::CItemMap >* >(
   130             aObject )->ResetAndDestroy();
   131             aObject )->ResetAndDestroy();
   131     }
   132     }
   132 
   133 
   133 // ---------------------------------------------------------------------------
   134 // ---------------------------------------------------------------------------
       
   135 // DeleteContentInfo
       
   136 // ---------------------------------------------------------------------------
       
   137 // 
       
   138 static void DeleteContentInfo( TAny* aObject )    
       
   139     {
       
   140     reinterpret_cast<RPointerArray< CHsContentInfo >* >( 
       
   141         aObject )->ResetAndDestroy();
       
   142     }
       
   143 
       
   144 // ---------------------------------------------------------------------------
   134 // ParseWidgetName
   145 // ParseWidgetName
   135 // ---------------------------------------------------------------------------
   146 // ---------------------------------------------------------------------------
   136 // 
   147 // 
   137 static TPtrC ParseWidgetName( const CHsContentInfo& aContentInfo )
   148 static TPtrC ParseWidgetName( const CHsContentInfo& aContentInfo )
   138     {
   149     {
   322 // CXnEditor::IsCurrentViewFull
   333 // CXnEditor::IsCurrentViewFull
   323 // -----------------------------------------------------------------------------
   334 // -----------------------------------------------------------------------------
   324 //
   335 //
   325 TBool CXnEditor::IsCurrentViewFull()
   336 TBool CXnEditor::IsCurrentViewFull()
   326     {
   337     {
   327     TBool viewFull = ETrue;
   338     return IsViewFull( iViewManager.ActiveViewData() );
   328     
       
   329     RPointerArray< CXnPluginData >& plugins( 
       
   330         iViewManager.ActiveViewData().PluginData() );
       
   331                 
       
   332     for ( TInt i = 0; i < plugins.Count(); i++ )
       
   333         {
       
   334         if ( !plugins[i]->Occupied() )
       
   335             {
       
   336             viewFull = EFalse;
       
   337             break;
       
   338             }
       
   339         }
       
   340     
       
   341     return viewFull;
       
   342     }
   339     }
   343 
   340 
   344 // -----------------------------------------------------------------------------
   341 // -----------------------------------------------------------------------------
   345 // CXnEditor::FilterPluginsL
   342 // CXnEditor::FilterPluginsL
   346 // -----------------------------------------------------------------------------
   343 // -----------------------------------------------------------------------------
   417 		    continue;
   414 		    continue;
   418 		    }
   415 		    }
   419 		
   416 		
   420 		if ( plugin->PublisherName() == aInfo.PublisherId() )
   417 		if ( plugin->PublisherName() == aInfo.PublisherId() )
   421 			{
   418 			{
   422 			if ( plugin->Removable() )
       
   423 			    {
       
   424 			    // To enable widget remove
       
   425 			    aInfo.SetPluginIdL( plugin->PluginId() );
       
   426 			    
       
   427 			    retval |= ECanBeRemoved;
       
   428 			    }
       
   429 			
       
   430 			widgetCount++;
   419 			widgetCount++;
   431 			}
   420 			}
   432 		}
   421 		}
   433 
   422 
   434 	if ( widgetCount < aInfo.MaxWidgets() )
   423 	if ( widgetCount < aInfo.MaxWidgets() )
   466             continue;
   455             continue;
   467             }        
   456             }        
   468         
   457         
   469         if ( plugin->PluginUid().CompareF( aInfo.Uid() ) == 0 )
   458         if ( plugin->PluginUid().CompareF( aInfo.Uid() ) == 0 )
   470             {
   459             {
   471             if ( plugin->Removable() )
       
   472                 {
       
   473                 // To enable widget remove
       
   474                 aInfo.SetPluginIdL( plugin->PluginId() );
       
   475                 
       
   476                 retval |= ECanBeRemoved;
       
   477                 }
       
   478             
       
   479             widgetCount++;
   460             widgetCount++;
   480             }
   461             }
   481         }
   462         }
   482     
   463     
   483     if ( widgetCount < aInfo.MaxWidgets() ||
   464     if ( widgetCount < aInfo.MaxWidgets() ||
   496 //
   477 //
   497 void CXnEditor::FilterViewListL( CHsContentInfoArray& aContentInfoArray )
   478 void CXnEditor::FilterViewListL( CHsContentInfoArray& aContentInfoArray )
   498     {
   479     {
   499     RPointerArray< CHsContentInfo >& list( aContentInfoArray.Array() );
   480     RPointerArray< CHsContentInfo >& list( aContentInfoArray.Array() );
   500     
   481     
   501     RPointerArray< CXnPluginData >& views( 
   482     TBool canBeAdded( EFalse );
   502         iViewManager.ActiveAppData().PluginData() );
   483     CXnRootData& appData( iViewManager.ActiveAppData() );
   503 
   484     if ( appData.PluginData().Count() < appData.MaxPages() )
   504     TInt viewAmount( iViewManager.ViewAmount() );
   485         {
   505     
   486         canBeAdded = ETrue;
   506     const TInt KMaxViewAmount( 6 );
   487         }    
   507     
   488     
   508     for ( TInt i = 0; i < list.Count(); i++ )
   489     for ( TInt i = 0; i < list.Count(); i++ )
   509         {
   490         {
   510         CHsContentInfo* info( list[i] );
   491         CHsContentInfo* info( list[i] );        
   511         
   492         info->SetCanBeAdded( canBeAdded );
   512         info->SetCanBeAdded( EFalse );
       
   513         info->SetCanBeRemoved( EFalse );
       
   514 
       
   515         for ( TInt j = 0 ; j < views.Count(); j++ )
       
   516             {
       
   517             CXnPluginData* view( views[j] );
       
   518             
       
   519             if ( view->PluginUid().CompareF( info->Uid() ) == 0 )
       
   520                 {
       
   521                 // To enable view remove
       
   522                 info->SetPluginIdL( view->PluginId() );
       
   523                 // Last view cannot be removed
       
   524                 if ( views.Count() > 1 )
       
   525                     {
       
   526                     info->SetCanBeRemoved( ETrue );
       
   527                     }
       
   528                 }
       
   529             }
       
   530         
       
   531         if ( viewAmount < KMaxViewAmount )
       
   532             {
       
   533             info->SetCanBeAdded( ETrue );
       
   534             }
       
   535         }
   493         }
   536     }
   494     }
   537 
   495 
   538 // ---------------------------------------------------------------------------
   496 // ---------------------------------------------------------------------------
   539 // CXnEditor::RemoveUnRegisteredWidgetL
   497 // CXnEditor::RemoveUnRegisteredWidgetL
  1716     
  1674     
  1717     if ( !err )
  1675     if ( !err )
  1718         {
  1676         {
  1719         // Get installed widget content infos
  1677         // Get installed widget content infos
  1720         RPointerArray< CHsContentInfo > array;
  1678         RPointerArray< CHsContentInfo > array;
  1721         CleanupClosePushL( array );        
  1679         CleanupStack::PushL( TCleanupItem( DeleteContentInfo, &array ) );
  1722         
  1680         
  1723         // get installed widgets and template configurations from HSPS
  1681         // get installed widgets and template configurations from HSPS
  1724         HspsWidgetPluginsL( array );
  1682         HspsWidgetPluginsL( array );
  1725                 
  1683                 
  1726         // get published widgets
  1684         // get published widgets
  1763 
  1721 
  1764 // -----------------------------------------------------------------------------
  1722 // -----------------------------------------------------------------------------
  1765 // from MHsContentController
  1723 // from MHsContentController
  1766 // -----------------------------------------------------------------------------
  1724 // -----------------------------------------------------------------------------
  1767 //
  1725 //
       
  1726 TInt CXnEditor::ViewListL( CHsContentInfo& aInfo, CHsContentInfoArray& aArray )
       
  1727     {
       
  1728     TInt err( KErrNone );
       
  1729 
       
  1730     if ( aInfo.Type() == KApplication )
       
  1731         {
       
  1732         if ( aInfo.Uid().CompareF( iViewManager.ActiveAppData().PluginUid() ) == 0 )
       
  1733             {
       
  1734             // Get list of views in active application configuration
       
  1735             CXnRootData& appData( iViewManager.ActiveAppData() );
       
  1736             RPointerArray< CXnPluginData >& views( appData.PluginData() );
       
  1737             
       
  1738             // Get installed view content infos
       
  1739             RPointerArray< CHsContentInfo > array;
       
  1740             CleanupStack::PushL( TCleanupItem( DeleteContentInfo, &array ) );
       
  1741             HspsViewPluginsL( array );
       
  1742                     
       
  1743             // Create content info for each found view
       
  1744             for ( TInt i = 0; i < views.Count(); i++ )
       
  1745                 {
       
  1746                 CHsContentInfo* info = CreateContentInfoLC( *views[i], array );
       
  1747                 if ( info )
       
  1748                     {
       
  1749                     CXnViewData* view = static_cast < CXnViewData* >( views[ i ] );
       
  1750                     info->SetIsFull( IsViewFull( *view ) );
       
  1751                     aArray.Array().AppendL( info );
       
  1752                     CleanupStack::Pop( info );
       
  1753                     }
       
  1754                 }
       
  1755             CleanupStack::PopAndDestroy(); // array
       
  1756             }
       
  1757         else
       
  1758             {
       
  1759             // Invalid application configuration
       
  1760             err = KErrArgument;
       
  1761             }
       
  1762         }
       
  1763     else
       
  1764         {
       
  1765         // Invalid argument
       
  1766         err = KErrArgument;
       
  1767         }
       
  1768     
       
  1769     return err;
       
  1770     }
       
  1771 
       
  1772 // -----------------------------------------------------------------------------
       
  1773 // from MHsContentController
       
  1774 // -----------------------------------------------------------------------------
       
  1775 //
  1768 TInt CXnEditor::AppListL( CHsContentInfoArray& aArray )
  1776 TInt CXnEditor::AppListL( CHsContentInfoArray& aArray )
  1769     {
  1777     {
  1770     RPointerArray< CHsContentInfo >& array( aArray.Array() );
  1778     RPointerArray< CHsContentInfo >& array( aArray.Array() );
  1771     
  1779     
  1772     // get installed application configurations from HSPS
  1780     // get installed application configurations from HSPS
  1948         aInfo.SetPluginIdL( viewData.PluginId() );
  1956         aInfo.SetPluginIdL( viewData.PluginId() );
  1949         aInfo.SetUidL( view->PluginInfo().Uid() );
  1957         aInfo.SetUidL( view->PluginInfo().Uid() );
  1950         aInfo.SetTypeL( view->PluginInfo().Type() );
  1958         aInfo.SetTypeL( view->PluginInfo().Type() );
  1951         aInfo.SetDescriptionL( view->PluginInfo().Description() );
  1959         aInfo.SetDescriptionL( view->PluginInfo().Description() );
  1952         aInfo.SetIconPathL( view->PluginInfo().LogoIcon() );
  1960         aInfo.SetIconPathL( view->PluginInfo().LogoIcon() );
  1953 
  1961         aInfo.SetIsFull( IsViewFull( viewData ) );        
  1954         // Check if there is empty space
       
  1955         RPointerArray< CXnNode > nodes;
       
  1956         viewData.PluginNodesL( nodes );
       
  1957         TBool isFull( ETrue );
       
  1958         for ( TInt i = 0; i < nodes.Count(); i++ )
       
  1959             {
       
  1960             CXnNode* node( nodes[i] );
       
  1961             CXnPluginData* plugin = viewData.Plugin( node );
       
  1962 
       
  1963             if ( plugin && !plugin->Occupied() )
       
  1964                 {
       
  1965                 isFull = EFalse;
       
  1966                 break;
       
  1967                 }
       
  1968             }
       
  1969         aInfo.SetIsFull( isFull );
       
  1970         }
  1962         }
  1971     else
  1963     else
  1972         {
  1964         {
  1973         err = KErrNotFound;
  1965         err = KErrNotFound;
  1974         }
  1966         }
  2034                    ( aPlugin.PublisherName().CompareF( info->PublisherId() ) == 0 ) ) )
  2026                    ( aPlugin.PublisherName().CompareF( info->PublisherId() ) == 0 ) ) )
  2035                 {
  2027                 {
  2036                 contentInfo = info->CloneL();
  2028                 contentInfo = info->CloneL();
  2037                 CleanupStack::PushL( contentInfo );
  2029                 CleanupStack::PushL( contentInfo );
  2038                 contentInfo->SetPluginIdL( aPlugin.PluginId() );
  2030                 contentInfo->SetPluginIdL( aPlugin.PluginId() );
       
  2031                 contentInfo->SetCanBeRemoved( aPlugin.Removable() );
  2039                 }
  2032                 }
  2040             }
  2033             }
  2041         }
  2034         }
  2042     return contentInfo;
  2035     return contentInfo;
  2043     }
  2036     }
  2044 
  2037 
  2045 // -----------------------------------------------------------------------------
  2038 // -----------------------------------------------------------------------------
       
  2039 // CXnEditor::IsViewFull
       
  2040 // -----------------------------------------------------------------------------
       
  2041 //
       
  2042 TBool CXnEditor::IsViewFull( CXnViewData& aViewData )
       
  2043     {
       
  2044     TBool isFull( ETrue );
       
  2045 
       
  2046     RPointerArray< CXnPluginData >& plugins( 
       
  2047             aViewData.PluginData() );
       
  2048 
       
  2049     for ( TInt i = 0; i < plugins.Count(); i++ )
       
  2050         {
       
  2051         CXnPluginData* plugin = plugins[ i ];
       
  2052 
       
  2053         if ( !plugin->Occupied() )
       
  2054             {
       
  2055             isFull = EFalse;
       
  2056             break;
       
  2057             }
       
  2058         }
       
  2059     
       
  2060     return isFull;
       
  2061     }
       
  2062 
       
  2063 // -----------------------------------------------------------------------------
  2046 // CXnBackgroundManager::OOMSysHandler
  2064 // CXnBackgroundManager::OOMSysHandler
  2047 // -----------------------------------------------------------------------------
  2065 // -----------------------------------------------------------------------------
  2048 //
  2066 //
  2049 CXnOomSysHandler& CXnEditor::OomSysHandler() const
  2067 CXnOomSysHandler& CXnEditor::OomSysHandler() const
  2050     {
  2068     {