55 #include "xnplugindata.h" |
55 #include "xnplugindata.h" |
56 #include "xnrootdata.h" |
56 #include "xnrootdata.h" |
57 #include "xnviewdata.h" |
57 #include "xnviewdata.h" |
58 #include "xnwallpaperview.h" |
58 #include "xnwallpaperview.h" |
59 #include "xnbackgroundmanager.h" |
59 #include "xnbackgroundmanager.h" |
|
60 #include "xnpopupcontroladapter.h" |
60 |
61 |
61 #include "xneditor.h" |
62 #include "xneditor.h" |
62 #include "xnpanic.h" |
63 #include "xnpanic.h" |
63 |
64 |
64 #include "xnoomsyshandler.h" |
65 #include "xnoomsyshandler.h" |
307 { |
310 { |
308 iCpsWrapper = CCpsWrapper::NewL( *this ); |
311 iCpsWrapper = CCpsWrapper::NewL( *this ); |
309 iHspsWrapper = CHspsWrapper::NewL( aUid, this ); |
312 iHspsWrapper = CHspsWrapper::NewL( aUid, this ); |
310 iRepository= CRepository::NewL( TUid::Uid( KCRUidActiveIdleLV ) ); |
313 iRepository= CRepository::NewL( TUid::Uid( KCRUidActiveIdleLV ) ); |
311 iOomSysHandler = CXnOomSysHandler::NewL(); |
314 iOomSysHandler = CXnOomSysHandler::NewL(); |
|
315 iNotifyWidgetUpdate = CPeriodic::New( CActive::EPriorityIdle ); |
312 } |
316 } |
313 |
317 |
314 // --------------------------------------------------------------------------- |
318 // --------------------------------------------------------------------------- |
315 // CXnEditor::~CXnEditor |
319 // CXnEditor::~CXnEditor |
316 // --------------------------------------------------------------------------- |
320 // --------------------------------------------------------------------------- |
317 // |
321 // |
318 CXnEditor::~CXnEditor() |
322 CXnEditor::~CXnEditor() |
319 { |
323 { |
|
324 if ( iNotifyWidgetUpdate->IsActive() ) |
|
325 { |
|
326 iNotifyWidgetUpdate->Cancel(); |
|
327 } |
|
328 delete iNotifyWidgetUpdate; |
|
329 |
320 iViewManager.RemoveObserver( *this ); |
330 iViewManager.RemoveObserver( *this ); |
321 if( iPluginsCache.Count() ) |
331 if( iPluginConfigurations.Count() ) |
322 { |
332 { |
323 iPluginsCache.ResetAndDestroy(); |
333 iPluginConfigurations.ResetAndDestroy(); |
324 } |
334 } |
325 delete iCpsWrapper; |
335 delete iCpsWrapper; |
326 delete iHspsWrapper; |
336 delete iHspsWrapper; |
327 delete iPublisherMap; |
337 delete iPublisherMap; |
328 delete iRepository; |
338 delete iRepository; |
870 // --------------------------------------------------------------------------- |
892 // --------------------------------------------------------------------------- |
871 // |
893 // |
872 void CXnEditor::CpsWidgetPluginsL( RPointerArray< CHsContentInfo >& aWidgets ) |
894 void CXnEditor::CpsWidgetPluginsL( RPointerArray< CHsContentInfo >& aWidgets ) |
873 { |
895 { |
874 // Get publishers from CPS |
896 // Get publishers from CPS |
875 |
897 delete iPublisherMap; |
876 if( !iPublisherMap ) |
898 iPublisherMap = NULL; |
877 { |
899 |
878 iPublisherMap = iCpsWrapper->GetTemplatedPublishersL(); |
900 iPublisherMap = iCpsWrapper->GetTemplatedPublishersL(); |
879 } |
|
880 |
901 |
881 RPointerArray< CPublisherInfo >& publisherInfo( iPublisherMap->PublisherInfo() ); |
902 RPointerArray< CPublisherInfo >& publisherInfo( iPublisherMap->PublisherInfo() ); |
882 |
903 |
883 // Find templates for the published data |
904 // Find templates for the published data |
884 for ( TInt i = 0; i < publisherInfo.Count(); i++ ) |
905 for ( TInt i = 0; i < publisherInfo.Count(); i++ ) |
885 { |
906 { |
886 CPublisherInfo* info( publisherInfo[i] ); |
907 CPublisherInfo* info( publisherInfo[i] ); |
887 |
908 |
888 for ( TInt j = 0; j < iPluginsCache.Count(); j++ ) |
909 for ( TInt j = 0; j < iPluginConfigurations.Count(); j++ ) |
889 { |
910 { |
890 if( iPluginsCache[j]->Name().Length() > 0 ) |
911 if( iPluginConfigurations[j]->Name().Length() > 0 ) |
891 { |
912 { |
892 // 8 to 16bit conv |
913 // 8 to 16bit conv |
893 HBufC* nameBuf = HBufC::NewLC( iPluginsCache[j]->Name().Length() ); |
914 HBufC* nameBuf = HBufC::NewLC( iPluginConfigurations[j]->Name().Length() ); |
894 nameBuf->Des().Copy( iPluginsCache[j]->Name() ); |
915 nameBuf->Des().Copy( iPluginConfigurations[j]->Name() ); |
895 TBool matchingNames = ( nameBuf->Des() == info->TemplateType() ); |
916 TBool matchingNames = ( nameBuf->Des() == info->TemplateType() ); |
896 CleanupStack::PopAndDestroy(); |
917 CleanupStack::PopAndDestroy(); |
897 if ( matchingNames ) |
918 if ( matchingNames ) |
898 { |
919 { |
899 |
920 |
901 CHsContentInfo* contentInfo = CHsContentInfo::NewLC(); |
922 CHsContentInfo* contentInfo = CHsContentInfo::NewLC(); |
902 |
923 |
903 contentInfo->SetNameL( info->WidgetName() ); |
924 contentInfo->SetNameL( info->WidgetName() ); |
904 contentInfo->SetPublisherIdL( info->PublisherId() ); |
925 contentInfo->SetPublisherIdL( info->PublisherId() ); |
905 contentInfo->SetMaxWidgets( info->MaxWidgets() ); |
926 contentInfo->SetMaxWidgets( info->MaxWidgets() ); |
906 contentInfo->SetUidL( iPluginsCache[j]->Uid() ); |
927 contentInfo->SetUidL( iPluginConfigurations[j]->Uid() ); |
907 contentInfo->SetTypeL( iPluginsCache[j]->Type() ); |
928 contentInfo->SetTypeL( iPluginConfigurations[j]->Type() ); |
908 contentInfo->SetDescriptionL( info->Description() ); |
929 contentInfo->SetDescriptionL( info->Description() ); |
909 contentInfo->SetIconPathL( info->LogoIcon() ); |
930 contentInfo->SetIconPathL( info->LogoIcon() ); |
910 contentInfo->SetIsWrt( info->ContentType() == KWRTTemplate() ); |
931 contentInfo->SetIsWrt( info->ContentType() == KWRTTemplate() ); |
911 |
932 |
912 aWidgets.AppendL( contentInfo ); |
933 aWidgets.AppendL( contentInfo ); |
1326 // CXnEditor::NotifyWidgetUnregisteredL |
1347 // CXnEditor::NotifyWidgetUnregisteredL |
1327 // --------------------------------------------------------------------------- |
1348 // --------------------------------------------------------------------------- |
1328 // |
1349 // |
1329 void CXnEditor::NotifyWidgetUnregisteredL( const TDesC& aPublisher ) |
1350 void CXnEditor::NotifyWidgetUnregisteredL( const TDesC& aPublisher ) |
1330 { |
1351 { |
1331 ResetCache(); |
1352 ResetPluginsAndPublishers(); |
1332 RemoveUnRegisteredWidgetL( aPublisher ); |
1353 RemoveUnRegisteredWidgetL( aPublisher ); |
1333 WidgetListChanged(); |
1354 WidgetListChanged(); |
1334 } |
1355 } |
1335 |
1356 |
1336 // --------------------------------------------------------------------------- |
1357 // --------------------------------------------------------------------------- |
1337 // CXnEditor::NotifyWidgetRegisteredL |
1358 // CXnEditor::NotifyWidgetRegisteredL |
1338 // --------------------------------------------------------------------------- |
1359 // --------------------------------------------------------------------------- |
1339 // |
1360 // |
1340 void CXnEditor::NotifyWidgetRegisteredL() |
1361 void CXnEditor::NotifyWidgetRegisteredL() |
1341 { |
1362 { |
1342 ResetCache(); |
1363 ResetPluginsAndPublishers(); |
1343 WidgetListChanged(); |
1364 WidgetListChanged(); |
|
1365 } |
|
1366 |
|
1367 // --------------------------------------------------------------------------- |
|
1368 // CXnEditor::NotifyWidgetUpdatedL |
|
1369 // --------------------------------------------------------------------------- |
|
1370 // |
|
1371 void CXnEditor::NotifyWidgetUpdatedL() |
|
1372 { |
|
1373 if ( iNotifyWidgetUpdate->IsActive() ) |
|
1374 { |
|
1375 iNotifyWidgetUpdate->Cancel(); |
|
1376 } |
|
1377 // start waiting for widget updates (wait time is 1sec). |
|
1378 // if no new updates, notify views about changes. otherwise |
|
1379 // start waiting for new updates again. |
|
1380 iNotifyWidgetUpdate->Start( |
|
1381 KNotifyWidgetUpdateDelay, |
|
1382 KNotifyWidgetUpdateDelay, |
|
1383 TCallBack( WidgetListChangedCallBack, this ) ); |
|
1384 } |
|
1385 |
|
1386 // --------------------------------------------------------------------------- |
|
1387 // CXnEditor::WidgetListChangedCallBack |
|
1388 // --------------------------------------------------------------------------- |
|
1389 // |
|
1390 TInt CXnEditor::WidgetListChangedCallBack( TAny* aSelf ) |
|
1391 { |
|
1392 CXnEditor* editor = static_cast<CXnEditor*>( aSelf ); |
|
1393 if ( editor && editor->iNotifyWidgetUpdate->IsActive() ) |
|
1394 { |
|
1395 // prevent multiple events |
|
1396 editor->iNotifyWidgetUpdate->Cancel(); |
|
1397 editor->WidgetListChanged(); |
|
1398 } |
|
1399 return KErrNone; |
1344 } |
1400 } |
1345 |
1401 |
1346 // --------------------------------------------------------------------------- |
1402 // --------------------------------------------------------------------------- |
1347 // CXnEditor::NotifyViewDeactivatedL |
1403 // CXnEditor::NotifyViewDeactivatedL |
1348 // --------------------------------------------------------------------------- |
1404 // --------------------------------------------------------------------------- |
1401 const TDesC8& aPluginUid, |
1457 const TDesC8& aPluginUid, |
1402 const TDesC8& aPluginId ) |
1458 const TDesC8& aPluginId ) |
1403 { |
1459 { |
1404 if ( aEvent == KEventPluginUnInstalled ) |
1460 if ( aEvent == KEventPluginUnInstalled ) |
1405 { |
1461 { |
1406 ResetCache(); |
1462 ResetPluginsAndPublishers(); |
1407 |
1463 |
1408 CHsContentInfo* info = CHsContentInfo::NewLC(); |
1464 CHsContentInfo* info = CHsContentInfo::NewLC(); |
1409 |
1465 |
1410 info->SetNameL( aPluginName ); |
1466 info->SetNameL( aPluginName ); |
1411 info->SetUidL( aPluginUid ); |
1467 info->SetUidL( aPluginUid ); |
1420 { |
1476 { |
1421 iViewManager.AppUiAdapter().ReloadUiL(); |
1477 iViewManager.AppUiAdapter().ReloadUiL(); |
1422 } |
1478 } |
1423 else if ( aEvent == KEventPluginInstalled ) |
1479 else if ( aEvent == KEventPluginInstalled ) |
1424 { |
1480 { |
1425 ResetCache(); |
1481 ResetPluginsAndPublishers(); |
1426 |
1482 |
1427 WidgetListChanged(); |
1483 WidgetListChanged(); |
1428 } |
1484 } |
1429 else if ( aEvent == KEventPluginUpdated ) |
1485 else if ( aEvent == KEventPluginUpdated ) |
1430 { |
1486 { |
1431 ResetCache(); |
1487 ResetPluginsAndPublishers(); |
1432 |
1488 |
1433 // If the plugin is in use then reload the widget |
1489 // If the plugin is in use then reload the widget |
1434 if ( aPluginId.Length() > 0 ) |
1490 if ( aPluginId.Length() > 0 ) |
1435 { |
1491 { |
1436 CHsContentInfo* info = CHsContentInfo::NewLC(); |
1492 CHsContentInfo* info = CHsContentInfo::NewLC(); |
1538 CleanupStack::Pop( contentInfo ); |
1594 CleanupStack::Pop( contentInfo ); |
1539 } |
1595 } |
1540 } |
1596 } |
1541 |
1597 |
1542 // ----------------------------------------------------------------------------- |
1598 // ----------------------------------------------------------------------------- |
1543 // CXnEditor::ResetCache |
1599 // CXnEditor::ResetPluginsAndPublishers |
1544 // ----------------------------------------------------------------------------- |
1600 // ----------------------------------------------------------------------------- |
1545 // |
1601 // |
1546 void CXnEditor::ResetCache() |
1602 void CXnEditor::ResetPluginsAndPublishers() |
1547 { |
1603 { |
1548 // Force loading of widget/template plugin configurations |
1604 // Force loading of widget/template plugin configurations |
1549 iPluginsCache.ResetAndDestroy(); |
1605 iPluginConfigurations.ResetAndDestroy(); |
1550 |
1606 |
1551 // Forece reloading of CPS publishers |
1607 // Forece reloading of CPS publishers |
1552 delete iPublisherMap; |
1608 delete iPublisherMap; |
1553 iPublisherMap = NULL; |
1609 iPublisherMap = NULL; |
1554 } |
1610 } |
1594 void CXnEditor::HspsWidgetPluginsL( RPointerArray< CHsContentInfo >& aWidgets ) |
1650 void CXnEditor::HspsWidgetPluginsL( RPointerArray< CHsContentInfo >& aWidgets ) |
1595 { |
1651 { |
1596 __ASSERT_DEBUG( aWidgets.Count() == 0, User::Leave( KErrGeneral ) ); |
1652 __ASSERT_DEBUG( aWidgets.Count() == 0, User::Leave( KErrGeneral ) ); |
1597 |
1653 |
1598 // If widget/template plugins haven't been fetched yet |
1654 // If widget/template plugins haven't been fetched yet |
1599 if( iPluginsCache.Count() == 0 ) |
1655 if( iPluginConfigurations.Count() == 0 ) |
1600 { |
1656 { |
1601 // Fetch the plugins into the runtime cache |
1657 // Fetch the plugins into the runtime cache |
1602 TRAPD( err, DoHspsWidgetPluginsL() ); |
1658 TRAPD( err, DoHspsWidgetPluginsL() ); |
1603 if( err ) |
1659 if( err ) |
1604 { |
1660 { |
1605 ResetCache(); |
1661 ResetPluginsAndPublishers(); |
1606 User::LeaveIfError( err ); |
1662 User::LeaveIfError( err ); |
1607 } |
1663 } |
1608 } |
1664 } |
1609 |
1665 |
1610 // Append plugins to the content info array |
1666 // Append plugins to the content info array |
1611 AppendPluginsL( iPluginsCache, aWidgets ); |
1667 AppendPluginsL( iPluginConfigurations, aWidgets ); |
1612 } |
1668 } |
1613 |
1669 |
1614 // ----------------------------------------------------------------------------- |
1670 // ----------------------------------------------------------------------------- |
1615 // CXnEditor::DoHspsWidgetPluginsL |
1671 // CXnEditor::DoHspsWidgetPluginsL |
1616 // ----------------------------------------------------------------------------- |
1672 // ----------------------------------------------------------------------------- |
1617 // |
1673 // |
1618 void CXnEditor::DoHspsWidgetPluginsL() |
1674 void CXnEditor::DoHspsWidgetPluginsL() |
1619 { |
1675 { |
1620 iHspsWrapper->GetPluginsL( iPluginsCache, KPluginInterface, KKeyWidget ); |
1676 iHspsWrapper->GetPluginsL( iPluginConfigurations, KPluginInterface, KKeyWidget ); |
1621 iHspsWrapper->GetPluginsL( iPluginsCache, KPluginInterface, KKeyTemplate ); |
1677 iHspsWrapper->GetPluginsL( iPluginConfigurations, KPluginInterface, KKeyTemplate ); |
1622 } |
1678 } |
1623 |
1679 |
1624 // ----------------------------------------------------------------------------- |
1680 // ----------------------------------------------------------------------------- |
1625 // from MHsContentController |
1681 // from MHsContentController |
1626 // ----------------------------------------------------------------------------- |
1682 // ----------------------------------------------------------------------------- |