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 } |
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 // --------------------------------------------------------------------------- |
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 ) |