idlehomescreen/xmluirendering/uiengine/src/xneditor.cpp
branchRCL_3
changeset 28 d721605b30d0
parent 25 137ebc85284b
child 31 89165693e770
equal deleted inserted replaced
26:1b758917cafc 28:d721605b30d0
    91     {
    91     {
    92     ECanBeAdded = 0x01,
    92     ECanBeAdded = 0x01,
    93     ECanBeRemoved
    93     ECanBeRemoved
    94     };
    94     };
    95 
    95 
    96 const TInt KNotifyWidgetUpdateDelay( 1000000 ); //1sec
    96 const TInt KNotifyWidgetListChangedDelay( 1000000 ); //1sec
       
    97 const TInt KNotifyViewListChangedDelay( 1000000 );   //1sec
    97 
    98 
    98 // ====================== LOCAL FUNTION PROTOTYPES ============================
    99 // ====================== LOCAL FUNTION PROTOTYPES ============================
    99 static void DeletePluginInfos( TAny* aObject );
   100 static void DeletePluginInfos( TAny* aObject );
   100 static void DeleteItemMaps( TAny* aObject );
   101 static void DeleteItemMaps( TAny* aObject );
   101 static void DeleteContentInfo( TAny* aObject );
   102 static void DeleteContentInfo( TAny* aObject );
   310     {
   311     {
   311     iCpsWrapper = CCpsWrapper::NewL( *this );
   312     iCpsWrapper = CCpsWrapper::NewL( *this );
   312     iHspsWrapper = CHspsWrapper::NewL( aUid, this );
   313     iHspsWrapper = CHspsWrapper::NewL( aUid, this );
   313     iRepository= CRepository::NewL( TUid::Uid( KCRUidActiveIdleLV ) );
   314     iRepository= CRepository::NewL( TUid::Uid( KCRUidActiveIdleLV ) );
   314     iOomSysHandler = CXnOomSysHandler::NewL();
   315     iOomSysHandler = CXnOomSysHandler::NewL();
   315     iNotifyWidgetUpdate = CPeriodic::New( CActive::EPriorityIdle );
   316     iNotifyWidgetListChanged = CPeriodic::New( CActive::EPriorityIdle );
       
   317     iNotifyViewListChanged = CPeriodic::New( CActive::EPriorityIdle );
   316     }
   318     }
   317 
   319 
   318 // ---------------------------------------------------------------------------
   320 // ---------------------------------------------------------------------------
   319 // CXnEditor::~CXnEditor
   321 // CXnEditor::~CXnEditor
   320 // ---------------------------------------------------------------------------
   322 // ---------------------------------------------------------------------------
   321 // 
   323 // 
   322 CXnEditor::~CXnEditor()
   324 CXnEditor::~CXnEditor()
   323     {
   325     {
   324     if ( iNotifyWidgetUpdate->IsActive() )
   326     if ( iNotifyWidgetListChanged->IsActive() )
   325         {
   327         {
   326         iNotifyWidgetUpdate->Cancel();
   328         iNotifyWidgetListChanged->Cancel();
   327         }
   329         }
   328     delete iNotifyWidgetUpdate;
   330     delete iNotifyWidgetListChanged;
   329     
   331 
       
   332     if ( iNotifyViewListChanged->IsActive() )
       
   333         {
       
   334         iNotifyViewListChanged->Cancel();
       
   335         }
       
   336     delete iNotifyViewListChanged;
       
   337 
   330     iViewManager.RemoveObserver( *this );
   338     iViewManager.RemoveObserver( *this );
   331     if( iPluginConfigurations.Count() )
   339     if( iPluginConfigurations.Count() )
   332         {
   340         {
   333         iPluginConfigurations.ResetAndDestroy();
   341         iPluginConfigurations.ResetAndDestroy();
   334         }    
   342         }    
   608         {
   616         {
   609     	OomSysHandler().HandlePotentialOomL();
   617     	OomSysHandler().HandlePotentialOomL();
   610     	return;
   618     	return;
   611         }
   619         }
   612     
   620     
   613     TBuf8<KOpaQDataLen> oPaqDataStr;
   621     TBuf8<KOpaQDataLen> oPaqDataStr = KNullDesC8();
   614            
   622            
   615     MHsContentControlUi* ui( NULL );
   623     MHsContentControlUi* ui( NULL );
   616     if ( IdFromCrep ( oPaqDataStr ) == KErrNone )
   624     if ( IdFromCrep ( oPaqDataStr ) == KErrNone )
   617         {
   625         {
   618         ui = iViewManager.AppUiAdapter().HsContentController( oPaqDataStr ); 
   626         ui = iViewManager.AppUiAdapter().HsContentController( oPaqDataStr ); 
  1238         XnPropertyNames::style::common::KDisplay,
  1246         XnPropertyNames::style::common::KDisplay,
  1239         XnPropertyNames::style::common::display::KBlock );
  1247         XnPropertyNames::style::common::display::KBlock );
  1240     
  1248     
  1241     node->SetDirtyL( XnDirtyLevel::ELayoutAndRenderSiblings );
  1249     node->SetDirtyL( XnDirtyLevel::ELayoutAndRenderSiblings );
  1242     
  1250     
  1243     WidgetListChanged();
  1251     NotifyWidgetListChanged();
  1244     }
  1252     }
  1245 
  1253 
  1246 // ---------------------------------------------------------------------------
  1254 // ---------------------------------------------------------------------------
  1247 // CXnEditor::NotifyWidgetRemovalL
  1255 // CXnEditor::NotifyWidgetRemovalL
  1248 // ---------------------------------------------------------------------------
  1256 // ---------------------------------------------------------------------------
  1320             // No more widgets in the active view
  1328             // No more widgets in the active view
  1321             iWidgetsVisibilityState = EFalse;
  1329             iWidgetsVisibilityState = EFalse;
  1322             }               
  1330             }               
  1323         }
  1331         }
  1324     
  1332     
  1325     WidgetListChanged();
  1333     NotifyWidgetListChanged();
  1326     }
  1334     }
  1327 
  1335 
  1328 // ---------------------------------------------------------------------------
  1336 // ---------------------------------------------------------------------------
  1329 // CXnEditor::NotifyViewAdditionL
  1337 // CXnEditor::NotifyViewAdditionL
  1330 // ---------------------------------------------------------------------------
  1338 // ---------------------------------------------------------------------------
  1331 //
  1339 //
  1332 void CXnEditor::NotifyViewAdditionL( const CXnPluginData& /*aPluginData*/ )
  1340 void CXnEditor::NotifyViewAdditionL( const CXnPluginData& /*aPluginData*/ )
  1333     {
  1341     {
  1334     ViewListChanged();
  1342     NotifyViewListChanged();
  1335     }
  1343     }
  1336 
  1344 
  1337 // ---------------------------------------------------------------------------
  1345 // ---------------------------------------------------------------------------
  1338 // CXnEditor::NotifyViewRemovalL
  1346 // CXnEditor::NotifyViewRemovalL
  1339 // ---------------------------------------------------------------------------
  1347 // ---------------------------------------------------------------------------
  1340 //
  1348 //
  1341 void CXnEditor::NotifyViewRemovalL( const CXnPluginData& /*aPluginData*/ )
  1349 void CXnEditor::NotifyViewRemovalL( const CXnPluginData& /*aPluginData*/ )
  1342     {
  1350     {
  1343     ViewListChanged();
  1351     NotifyViewListChanged();
  1344     }
  1352     }
  1345 
  1353 
  1346 // ---------------------------------------------------------------------------
  1354 // ---------------------------------------------------------------------------
  1347 // CXnEditor::NotifyWidgetUnregisteredL
  1355 // CXnEditor::NotifyWidgetUnregisteredL
  1348 // ---------------------------------------------------------------------------
  1356 // ---------------------------------------------------------------------------
  1349 //
  1357 //
  1350 void CXnEditor::NotifyWidgetUnregisteredL( const TDesC& aPublisher )
  1358 void CXnEditor::NotifyWidgetUnregisteredL( const TDesC& aPublisher )
  1351     {
  1359     {
  1352     ResetPluginsAndPublishers();
  1360     ResetPluginsAndPublishers();
  1353     RemoveUnRegisteredWidgetL( aPublisher );
  1361     RemoveUnRegisteredWidgetL( aPublisher );
  1354     WidgetListChanged();    
  1362     NotifyWidgetListChanged();    
  1355     }
  1363     }
  1356 
  1364 
  1357 // ---------------------------------------------------------------------------
  1365 // ---------------------------------------------------------------------------
  1358 // CXnEditor::NotifyWidgetRegisteredL
  1366 // CXnEditor::NotifyWidgetRegisteredL
  1359 // ---------------------------------------------------------------------------
  1367 // ---------------------------------------------------------------------------
  1360 //
  1368 //
  1361 void CXnEditor::NotifyWidgetRegisteredL()
  1369 void CXnEditor::NotifyWidgetRegisteredL()
  1362     {
  1370     {
  1363     ResetPluginsAndPublishers();        
  1371     ResetPluginsAndPublishers();        
  1364     WidgetListChanged();
  1372     NotifyWidgetListChanged();
  1365     }
  1373     }
  1366 
  1374 
  1367 // ---------------------------------------------------------------------------
  1375 // ---------------------------------------------------------------------------
  1368 // CXnEditor::NotifyWidgetUpdatedL
  1376 // CXnEditor::NotifyWidgetUpdatedL
  1369 // ---------------------------------------------------------------------------
  1377 // ---------------------------------------------------------------------------
  1370 //
  1378 //
  1371 void CXnEditor::NotifyWidgetUpdatedL()
  1379 void CXnEditor::NotifyWidgetUpdatedL()
  1372     {
  1380     {
  1373     if ( iNotifyWidgetUpdate->IsActive() )
  1381     NotifyWidgetListChanged();
  1374         {
  1382     }
  1375         iNotifyWidgetUpdate->Cancel();
  1383 
  1376         }
  1384 // ---------------------------------------------------------------------------
  1377     // start waiting for widget updates (wait time is 1sec).
  1385 // CXnEditor::NotifyAllViewsLoadedL
  1378 	// if no new updates, notify views about changes. otherwise
  1386 // ---------------------------------------------------------------------------
  1379 	// start waiting for new updates again. 
  1387 //
  1380     iNotifyWidgetUpdate->Start(
  1388 void CXnEditor::NotifyAllViewsLoadedL()
  1381         KNotifyWidgetUpdateDelay,
  1389     {
  1382         KNotifyWidgetUpdateDelay,
  1390     NotifyViewListChanged();
       
  1391     NotifyWidgetListChanged();
       
  1392     }
       
  1393 
       
  1394 // -----------------------------------------------------------------------------
       
  1395 // CXnEditor::NotifyContainerActivatedL
       
  1396 // -----------------------------------------------------------------------------
       
  1397 //
       
  1398 void CXnEditor::NotifyContainerActivatedL( const CXnViewData& /* aViewData */ )
       
  1399     {
       
  1400     if ( iViewManager.ActiveAppData().AllViewsLoaded() )
       
  1401         {
       
  1402         NotifyWidgetListChanged();
       
  1403         }
       
  1404     }
       
  1405 
       
  1406 // ---------------------------------------------------------------------------
       
  1407 // CXnEditor::NotifyWidgetListChanged
       
  1408 // ---------------------------------------------------------------------------
       
  1409 //
       
  1410 void CXnEditor::NotifyWidgetListChanged()
       
  1411     {
       
  1412     if ( iNotifyWidgetListChanged->IsActive() )
       
  1413         {
       
  1414         iNotifyWidgetListChanged->Cancel();
       
  1415         }
       
  1416     // start waiting for widget list changes (wait time is 1sec).
       
  1417     // if no new changes, notify observers about changes. otherwise
       
  1418     // start waiting for new updates again. 
       
  1419     iNotifyWidgetListChanged->Start(
       
  1420         KNotifyWidgetListChangedDelay,
       
  1421         KNotifyWidgetListChangedDelay,
  1383         TCallBack( WidgetListChangedCallBack, this ) );
  1422         TCallBack( WidgetListChangedCallBack, this ) );
       
  1423 
  1384     }
  1424     }
  1385 
  1425 
  1386 // ---------------------------------------------------------------------------
  1426 // ---------------------------------------------------------------------------
  1387 // CXnEditor::WidgetListChangedCallBack
  1427 // CXnEditor::WidgetListChangedCallBack
  1388 // ---------------------------------------------------------------------------
  1428 // ---------------------------------------------------------------------------
  1389 //
  1429 //
  1390 TInt CXnEditor::WidgetListChangedCallBack( TAny* aSelf )
  1430 TInt CXnEditor::WidgetListChangedCallBack( TAny* aSelf )
  1391     {
  1431     {
  1392     CXnEditor* editor = static_cast<CXnEditor*>( aSelf );
  1432     CXnEditor* editor = static_cast<CXnEditor*>( aSelf );
  1393     if ( editor && editor->iNotifyWidgetUpdate->IsActive() )
  1433     if ( editor && editor->iNotifyWidgetListChanged->IsActive() )
  1394         {
  1434         {
  1395         // prevent multiple events
  1435         // prevent multiple events
  1396         editor->iNotifyWidgetUpdate->Cancel();
  1436         editor->iNotifyWidgetListChanged->Cancel();
  1397         editor->WidgetListChanged();
  1437         editor->WidgetListChanged();
       
  1438         }
       
  1439     return KErrNone;
       
  1440     }
       
  1441 
       
  1442 // ---------------------------------------------------------------------------
       
  1443 // CXnEditor::NotifyViewListChanged
       
  1444 // ---------------------------------------------------------------------------
       
  1445 //
       
  1446 void CXnEditor::NotifyViewListChanged()
       
  1447     {
       
  1448     if ( iNotifyViewListChanged->IsActive() )
       
  1449         {
       
  1450         iNotifyViewListChanged->Cancel();
       
  1451         }
       
  1452     // start waiting for widget list changes (wait time is 1sec).
       
  1453     // if no new changes, notify observer about changes. otherwise
       
  1454     // start waiting for new changes again. 
       
  1455     iNotifyViewListChanged->Start(
       
  1456         KNotifyViewListChangedDelay,
       
  1457         KNotifyViewListChangedDelay,
       
  1458         TCallBack( ViewListChangedCallBack, this ) );
       
  1459 
       
  1460     }
       
  1461 
       
  1462 // ---------------------------------------------------------------------------
       
  1463 // CXnEditor::ViewListChangedCallBack
       
  1464 // ---------------------------------------------------------------------------
       
  1465 //
       
  1466 TInt CXnEditor::ViewListChangedCallBack( TAny* aSelf )
       
  1467     {
       
  1468     CXnEditor* editor = static_cast<CXnEditor*>( aSelf );
       
  1469     if ( editor && editor->iNotifyViewListChanged->IsActive() )
       
  1470         {
       
  1471         // prevent multiple events
       
  1472         editor->iNotifyViewListChanged->Cancel();
       
  1473         editor->ViewListChanged();
  1398         }
  1474         }
  1399     return KErrNone;
  1475     return KErrNone;
  1400     }
  1476     }
  1401 
  1477 
  1402 // ---------------------------------------------------------------------------
  1478 // ---------------------------------------------------------------------------
  1466         info->SetNameL( aPluginName );
  1542         info->SetNameL( aPluginName );
  1467         info->SetUidL( aPluginUid );
  1543         info->SetUidL( aPluginUid );
  1468         info->SetPluginIdL( aPluginId );
  1544         info->SetPluginIdL( aPluginId );
  1469 
  1545 
  1470         RemoveUnInstalledWidgetL( *info );
  1546         RemoveUnInstalledWidgetL( *info );
  1471         WidgetListChanged();
  1547         NotifyWidgetListChanged();
  1472 
  1548 
  1473         CleanupStack::PopAndDestroy( info );
  1549         CleanupStack::PopAndDestroy( info );
  1474         }
  1550         }
  1475     else if ( aEvent == KEventRootConfActivated )
  1551     else if ( aEvent == KEventRootConfActivated )
  1476         {
  1552         {
  1478         }
  1554         }
  1479     else if ( aEvent == KEventPluginInstalled )
  1555     else if ( aEvent == KEventPluginInstalled )
  1480         {        
  1556         {        
  1481         ResetPluginsAndPublishers();
  1557         ResetPluginsAndPublishers();
  1482         
  1558         
  1483         WidgetListChanged();        
  1559         NotifyWidgetListChanged();        
  1484         }
  1560         }
  1485     else if ( aEvent == KEventPluginUpdated )
  1561     else if ( aEvent == KEventPluginUpdated )
  1486         {
  1562         {
  1487         ResetPluginsAndPublishers();
  1563         ResetPluginsAndPublishers();
  1488         
  1564         
  1494             info->SetUidL( aPluginUid );
  1570             info->SetUidL( aPluginUid );
  1495             info->SetPluginIdL( aPluginId );    
  1571             info->SetPluginIdL( aPluginId );    
  1496             ReplaceWidgetL( *info );                
  1572             ReplaceWidgetL( *info );                
  1497             CleanupStack::PopAndDestroy( info );
  1573             CleanupStack::PopAndDestroy( info );
  1498             }
  1574             }
  1499         WidgetListChanged();
  1575         NotifyWidgetListChanged();
  1500         }
  1576         }
  1501  
  1577  
  1502     return KErrNone;
  1578     return KErrNone;
  1503     }
  1579     }
  1504 
  1580 
  1506 // CXnEditor::WidgetListChanged
  1582 // CXnEditor::WidgetListChanged
  1507 // -----------------------------------------------------------------------------
  1583 // -----------------------------------------------------------------------------
  1508 //
  1584 //
  1509 void CXnEditor::WidgetListChanged()
  1585 void CXnEditor::WidgetListChanged()
  1510     {
  1586     {
  1511     TBuf8<KOpaQDataLen> oPaqDataStr;
  1587     TBuf8<KOpaQDataLen> oPaqDataStr = KNullDesC8();
  1512               
  1588               
  1513    MHsContentControlUi* ui( NULL );
  1589    MHsContentControlUi* ui( NULL );
  1514    if ( IdFromCrep ( oPaqDataStr ) == KErrNone )
  1590    if ( IdFromCrep ( oPaqDataStr ) == KErrNone )
  1515        {
  1591        {
  1516        ui = iViewManager.AppUiAdapter().HsContentController( oPaqDataStr ); 
  1592        ui = iViewManager.AppUiAdapter().HsContentController( oPaqDataStr ); 
  1530 // CXnEditor::ViewListChanged
  1606 // CXnEditor::ViewListChanged
  1531 // -----------------------------------------------------------------------------
  1607 // -----------------------------------------------------------------------------
  1532 //
  1608 //
  1533 void CXnEditor::ViewListChanged()
  1609 void CXnEditor::ViewListChanged()
  1534     {
  1610     {
  1535     TBuf8<KOpaQDataLen> oPaqDataStr;
  1611     TBuf8<KOpaQDataLen> oPaqDataStr = KNullDesC8();
  1536               
  1612               
  1537    MHsContentControlUi* ui( NULL );
  1613    MHsContentControlUi* ui( NULL );
  1538    if ( IdFromCrep ( oPaqDataStr ) == KErrNone )
  1614    if ( IdFromCrep ( oPaqDataStr ) == KErrNone )
  1539        {
  1615        {
  1540        ui = iViewManager.AppUiAdapter().HsContentController( oPaqDataStr ); 
  1616        ui = iViewManager.AppUiAdapter().HsContentController( oPaqDataStr ); 
  1848     TInt ret( KErrNone );    
  1924     TInt ret( KErrNone );    
  1849 
  1925 
  1850     const TDesC8& type( aInfo.Type() );
  1926     const TDesC8& type( aInfo.Type() );
  1851     
  1927     
  1852     if ( ( type != KKeyWidget && type != KKeyTemplate ) ||
  1928     if ( ( type != KKeyWidget && type != KKeyTemplate ) ||
  1853          aInfo.Uid() == KNullDesC8 )
  1929          aInfo.Uid() == KNullDesC8  || !aInfo.CanBeAdded() )
  1854         {
  1930         {
  1855         // malformed content info
  1931         // malformed content info
  1856         return KErrArgument;
  1932         return KErrArgument;
  1857         }
  1933         }
  1858 
  1934 
       
  1935     CXnPluginData* plugin( NULL );
       
  1936     
       
  1937     if( iTargetPlugin )
       
  1938         {
       
  1939         plugin = DeterminePlugin( iViewManager, iTargetPlugin );
       
  1940         }
       
  1941     else
       
  1942         {
       
  1943         plugin = DeterminePlugin( iViewManager );
       
  1944         }
       
  1945     
       
  1946     iTargetPlugin = NULL;
       
  1947     
  1859     // the widget can not be added. Return proper error code
  1948     // the widget can not be added. Return proper error code
  1860     if ( IsCurrentViewFull() )
  1949     if ( IsCurrentViewFull() || !plugin )
  1861         {
  1950         {
  1862         return KHsErrorViewFull;
  1951         return KHsErrorViewFull;
  1863         }
  1952         }
  1864     else if ( !aInfo.CanBeAdded() )
       
  1865         {
       
  1866         return KHsErrorMaxInstanceCountExceeded;
       
  1867         }
       
  1868 
       
  1869 
       
  1870     CXnPluginData* plugin( NULL );
       
  1871     
       
  1872     if( iTargetPlugin )
       
  1873         {
       
  1874         plugin = DeterminePlugin( iViewManager, iTargetPlugin );
       
  1875         }
       
  1876     else
  1953     else
  1877         {
  1954         {
  1878         plugin = DeterminePlugin( iViewManager );
  1955         TInt result;
  1879         }
  1956         if ( aInfo.Type() != KKeyTemplate() )
  1880     
  1957             { 
  1881     iTargetPlugin = NULL;
  1958             result = NonTemplateWidgetCanBeAddedRemovedL( aInfo ); 
  1882     
  1959             }
  1883     if ( !plugin )
  1960         else
  1884         {
  1961             {
  1885         return KErrGeneral;
  1962             result = TemplateWidgetCanBeAddedRemovedL( aInfo );
       
  1963             } 
       
  1964         
       
  1965         if ( !( result & ECanBeAdded ) )
       
  1966             {
       
  1967             return KHsErrorMaxInstanceCountExceeded;
       
  1968             } 
  1886         }
  1969         }
  1887     
  1970     
  1888     ret = iViewManager.LoadWidgetToPluginL( aInfo, *plugin );
  1971     ret = iViewManager.LoadWidgetToPluginL( aInfo, *plugin );
  1889     
  1972     
  1890     if( ret == KErrNone )
  1973     if( ret == KErrNone )