--- a/taskswitcher/server/src/tsdatalist.cpp Wed Oct 13 12:59:22 2010 +0300
+++ b/taskswitcher/server/src/tsdatalist.cpp Mon Oct 18 10:44:15 2010 +0300
@@ -16,34 +16,18 @@
*/
//INCLUDES:
-#include <mmf/common/mmfcontrollerpluginresolver.h> // for CleanupResetAndDestroyPushL
-#include <e32debug.h>
-#include <apgwgnam.h>
-#include <bitstd.h>
-#include <AknIconUtils.h> // avkon
-#include <apgicnfl.h> // fbsbitmap
-#include <AknIconSrvClient.h>
#include <fbs.h>
-#include <apgwgnam.h>
-#include <QSizeF>
-#include <camenuiconutility.h>
#include <apgcli.h>
+#include "tsutils.h"
#include "tsdatalist.h"
-#include "tsentrykeygenerator.h"
#include "tsscreenshotmsg.h"
#include "tsunregscreenshotmsg.h"
-#include "tsvisibilitymsg.h"
#include "tsresourcemanager.h"
#include "tsrunningapp.h"
#include "tsrunningappstorage.h"
-
-// size for the created app icons
-const TInt KAppIconWidth = 128;
-const TInt KAppIconHeight = 128;
-
-//uids to be hidden
-const TUid KHsApplicationUid = { 0x20022F35 };
+#include "tsiconprovider.h"
+#include "tsidlist.h"
// ================= MEMBER FUNCTIONS =======================
@@ -87,10 +71,6 @@
{
iData.ResetAndDestroy();
iVisibleData.Close();
- iHiddenUids.Close();
- RFbsSession::Disconnect();
- RAknIconSrvClient::Disconnect();
- delete iDefaultIcon;
}
// --------------------------------------------------------------------------
@@ -100,11 +80,6 @@
void CTsDataList::ConstructL()
{
BaseConstructL();
- iHiddenUids.AppendL( KHsApplicationUid );
- User::LeaveIfError(RFbsSession::Connect());
- RAknIconSrvClient::Connect();
- QT_TRYCATCH_LEAVING(
- iDefaultIcon = HbIcon2CFbsBitmap( HbIcon("qtg_large_application") );)
}
// --------------------------------------------------------------------------
@@ -130,7 +105,7 @@
{
TRAP_IGNORE(RDebug::Print(_L("[TaskSwitcher] processing started"));
RTsFswArray newAppsList;
- CleanupResetAndDestroyPushL(newAppsList);
+ TaskSwitcher::CleanupResetAndDestroyPushL(newAppsList);
CollectAppsL(newAppsList, aStorage);
RDebug::Print(_L("[TaskSwitcher] gathered app info"));
FitDataToListL(newAppsList);
@@ -150,9 +125,7 @@
for( TInt i(0); i < aStorage.Count(); ++i )
{
TTsEntryKey key;
- TInt err = TsEntryKeyGeneraror::Generate( key,
- aStorage[i].WindowGroupId(),
- aStorage );
+ TInt err = aStorage.GenerateKey(key, aStorage[i].WindowGroupId());
//skip this entry if it is already on list or generate key failed
if( err!=KErrNone || FindEntry( aAppsList, key ) >= 0 )
{
@@ -163,14 +136,14 @@
TInt appScreen = 0;
TInt scrNumErr =
iResources.ApaSession().GetDefaultScreenNumber( appScreen,
- aStorage[i].UidL() );
+ aStorage[i].Uid() );
- if( aStorage[i].UidL().iUid &&
- !aStorage[i].IsHiddenL() &&
+ if( aStorage[i].Uid().iUid &&
+ MTsRunningApplication::None == aStorage[i].HideMode()&&
(appScreen == 0 || appScreen == -1) &&
scrNumErr == KErrNone )
{
- AddEntryL( key, aStorage[i], aAppsList );
+ AddEntryL(key, aStorage[i], aAppsList );
}
}
}
@@ -178,29 +151,18 @@
// --------------------------------------------------------------------------
/**
* Called from CollectTasksL for each entry in the task list.
- * @param aKey entry key
* @param aRunningApp running application entry
* @param aNewList list to add to
*/
-void CTsDataList::AddEntryL( const TTsEntryKey& aKey,
+void CTsDataList::AddEntryL( const TTsEntryKey aKey,
const MTsRunningApplication& aRunningApp,
RTsFswArray& aNewList )
{
- CTsEntry* entry = CTsEntry::NewLC( aKey, iObserver, &iEnv );
- // check if present in old list and if yes then take some of the old data
- TBool found = ConsiderOldDataL( aKey );
- // if not present previously then find out app name
- // and check if screenshot is already available
- if( !found )
- {
- entry->SetAppUid(aRunningApp.UidL());
- HBufC* name = FindAppNameLC( aRunningApp );
- entry->SetAppNameL(*name);
- CleanupStack::PopAndDestroy( name );
- //transfer ownership to entry
- entry->SetAppIcon( GetAppIconL( aRunningApp.UidL() ) );
- }
- entry->SetCloseableApp( !aRunningApp.IsSystemL());
+ CTsRunningAppEntry* entry = CTsRunningAppEntry::NewLC(aKey,
+ aRunningApp,
+ iResources,
+ iObserver,
+ &iEnv );
// add to new list, ownership is transferred
aNewList.AppendL( entry );
CleanupStack::Pop( entry );
@@ -214,11 +176,11 @@
* @param aKey new key in content list
* @return ETrue if app was found
*/
-TBool CTsDataList::ConsiderOldDataL( const TTsEntryKey& aKey )
+TBool CTsDataList::ConsiderOldData( const TTsEntryKey& aKey )
{
for(TInt entryIdx = 0, oldCount = iData.Count(); entryIdx < oldCount; ++entryIdx)
{
- if (iData[entryIdx]->Key() == aKey)
+ if (iData[entryIdx]->Key().Key() == aKey.Key())
{
return ETrue;
}
@@ -228,59 +190,6 @@
// --------------------------------------------------------------------------
/**
- * Finds out the application name.
- * @param aWindowName window group name or NULL
- * @param aAppUId application uid
- * @param aWgId window group id
- * @return application name, ownership transferred to caller
- */
-HBufC* CTsDataList::FindAppNameLC( const MTsRunningApplication& aRunningApp )
- {
- //Retrieve the app name
- TApaAppInfo info;
- iResources.ApaSession().GetAppInfo( info, aRunningApp.UidL() );
- TPtrC caption = info.iShortCaption;
-
- HBufC* tempName( 0 );
- if (!caption.Length() ) // if not set - use thread name instead
- {
- if( aRunningApp.CaptionL().Length() )
- {
- tempName = aRunningApp.CaptionL().AllocLC();
- }
- else
- {
- TThreadId threadId;
- if(KErrNone == iResources.WsSession().GetWindowGroupClientThreadId( aRunningApp.WindowGroupId(), threadId ) )
- {
- RThread thread;
- CleanupClosePushL( thread );
- if( KErrNone == thread.Open( threadId ) )
- {
- tempName = thread.Name().AllocL(); // codescanner::forgottoputptroncleanupstack
- }
- // tempName put on cleanupstack after the if
- CleanupStack::PopAndDestroy( &thread );
- if(tempName)
- {
- CleanupStack::PushL(tempName);
- }
- }
- }
- }
- else
- {
- tempName = caption.AllocLC();
- }
- if( 0 == tempName )
- {
- tempName = KNullDesC16().AllocLC();
- }
- return tempName;
- }
-
-// --------------------------------------------------------------------------
-/**
* Fit existing class contained data list into give one.
* Data is being changed with application type consideration that is based
* on aConsiderWidgets param.
@@ -295,7 +204,7 @@
//remove items that dont't exists in newly collected list
for (TInt i = dataCount - 1; i >= 0; --i)
{
- if( !CheckIfExists( *iData[i], aListToFit ) )
+ if( !CheckIfExistsL( *iData[i], aListToFit ) )
{
delete iData[i];
iData.Remove( i );
@@ -308,19 +217,17 @@
for(TInt i = aListToFit.Count() - 1; i >= 0; --i)
{
User::LeaveIfError( allKeys.Insert(aListToFit[i]->Key(), 0) );
- if( !CheckIfExists( *aListToFit[i], iData ) )
+ if( !CheckIfExistsL( *aListToFit[i], iData ) )
{
HideEntryIfNotAllowed( aListToFit[i] );
User::LeaveIfError( iData.Insert( aListToFit[i], 0 ) );
- TTime currentTimestamp;
- currentTimestamp.UniversalTime();
- iData[0]->SetTimestamp( currentTimestamp );
+ iData[0]->RefreshTimestamp();
aListToFit[i] = 0;
changed = ETrue;
}
}
//establish order
- TBool orderChanged = EstablishOrder( allKeys );
+ TBool orderChanged = EstablishOrderL( allKeys );
//update entries data
TBool dataChanged = UpdateEntryData( aListToFit );
RebuildVisibleDataListL();
@@ -339,61 +246,17 @@
* @return ETrue if app was found
*/
-TBool CTsDataList::CheckIfExists( const CTsEntry& aEntry,
+TBool CTsDataList::CheckIfExistsL( const MTsEntry& aEntry,
const RTsFswArray& aList ) const
{
return 0 <= FindEntry( aList, aEntry.Key() );
}
// --------------------------------------------------------------------------
-/**
- * Retrieves the bitmap for the icon of the given app.
- * @param aAppUid application uid
- * @return app CFbsBitmap
- */
-CFbsBitmap* CTsDataList::GetAppIconL( const TUid& aAppUid )
- {
-
- CFbsBitmap* iconBitmap(0);
- TRAPD(errNo,
- QT_TRYCATCH_LEAVING(
- const QSize size(KAppIconWidth, KAppIconHeight);
- HbIcon icon = CaMenuIconUtility::getApplicationIcon( aAppUid.iUid, size);
- iconBitmap = HbIcon2CFbsBitmap( icon );)
- User::LeaveIfNull(iconBitmap); )
- if( KErrNone != errNo )
- {
- iconBitmap = new(ELeave) CFbsBitmap;
- CleanupStack::PushL(iconBitmap);
- User::LeaveIfError( iconBitmap->Duplicate( iDefaultIcon->Handle() ) );
- CleanupStack::Pop(iconBitmap);
- }
- return iconBitmap;
- }
-
-// --------------------------------------------------------------------------
-/**
- * Converts HbIcon to CFbsBitmap
- * @param aIcon icon to be coverted
- * @return CFbsBitmap
- */
-CFbsBitmap* CTsDataList::HbIcon2CFbsBitmap( const HbIcon& aIcon )
- {
- CFbsBitmap* retValue(0);
- QIcon qicon = aIcon.qicon();
- QPixmap pixmap = qicon.pixmap(QSize(KAppIconWidth, KAppIconHeight));
- if( !pixmap.isNull() )
- {
- retValue = pixmap.toSymbianCFbsBitmap();
- }
- return retValue;
- }
-// --------------------------------------------------------------------------
TBool CTsDataList::IsSupported( TInt aFunction ) const
{
return ( RegisterScreenshotMessage == aFunction ||
UnregisterScreenshotMessage == aFunction ||
- VisibilityChange == aFunction ||
WindowGroupToBackgroundMessage == aFunction );
}
@@ -408,9 +271,6 @@
case UnregisterScreenshotMessage:
UnregisterScreenshotL( aDataStream );
break;
- case VisibilityChange:
- ChangeVisibilityL( aDataStream );
- break;
case WindowGroupToBackgroundMessage:
UpdateTaskTimestampL( aDataStream );
break;
@@ -418,10 +278,25 @@
}
// --------------------------------------------------------------------------
+MTsEntry& CTsDataList::FindL(TTsEntryKey& aKey)
+ {
+ MTsEntry* entry(0);
+ for(TInt offset(0); 0 == entry && offset < iData.Count(); ++offset)
+ {
+ if(iData[offset]->Key().Key() == aKey.Key())
+ {
+ entry = iData[offset];
+ }
+ }
+ User::LeaveIfNull(entry);
+ return *entry;
+ }
+
+// --------------------------------------------------------------------------
void CTsDataList::RegisterScreenshotL( RReadStream& aDataStream )
{
CTsScreenshotMsg* msg = CTsScreenshotMsg::NewLC( aDataStream );
- const TInt pos = FindEntry( iData, GenerateKeyL(msg->WindowGroupId() ) );
+ const TInt pos = FindEntry(iData, GenerateKeyL(msg->WindowGroupId() ) );
User::LeaveIfError(pos);
iData[pos]->SetScreenshotL( msg->Screenshot(), msg->Priority(), msg->Rotation() );
CleanupStack::PopAndDestroy(msg);
@@ -436,21 +311,7 @@
iData[pos]->RemoveScreenshotL();
CleanupStack::PopAndDestroy(msg);
}
-// --------------------------------------------------------------------------
-void CTsDataList::ChangeVisibilityL( RReadStream& aDataStream )
- {
- CTsVisibilitMsg* msg = CTsVisibilitMsg::NewLC(aDataStream);
- const TInt pos = FindEntry( iData, GenerateKeyL( msg->windowGroupId() ) );
- User::LeaveIfError(pos);
-
- msg->visibility() == iData[pos]->GetVisibility() ?
- User::Leave( KErrInUse ) :
- iData[pos]->SetVisibility( msg->visibility() );
-
- CleanupStack::PopAndDestroy(msg);
- RebuildVisibleDataListL();
- iObserver.DataChanged();
- }
+
// --------------------------------------------------------------------------
void CTsDataList::UpdateTaskTimestampL( RReadStream& aDataStream )
{
@@ -458,26 +319,13 @@
const TInt pos = FindEntry( iData, GenerateKeyL( wgId ) );
User::LeaveIfError( pos );
- TTime currentTimestamp;
- currentTimestamp.UniversalTime();
- iData[pos]->SetTimestamp( currentTimestamp );
+ iData[pos]->RefreshTimestamp();
iObserver.DataChanged();
}
// --------------------------------------------------------------------------
/**
- * Checks if given uid is on hidden list
- * @param aUid uid to be checked
- * @return ETrue if uid is on hidden list
- */
-TBool CTsDataList::IsHiddenUid( TUid aUid )
- {
- return 0 < iHiddenUids.Find( aUid );
- }
-
-// --------------------------------------------------------------------------
-/**
* Finds entry in array
* @param aList list to find
* @param aKey finding key
@@ -491,7 +339,7 @@
entryIdx < aList.Count() && KErrNotFound == pos;
++entryIdx)
{
- if (aList[entryIdx]->Key() == aKey)
+ if (aList[entryIdx]->Key().Key() == aKey.Key())
{
pos = entryIdx;
}
@@ -505,7 +353,7 @@
* @param aKeyList reference key list
* @return ETrue if changes occured
*/
-TBool CTsDataList::EstablishOrder( const RArray<TTsEntryKey>& aKeyList )
+TBool CTsDataList::EstablishOrderL( const RArray<TTsEntryKey>& aKeyList )
{
TBool changed( EFalse );
TInt lastChangedItem( KErrNotFound );
@@ -518,18 +366,16 @@
{
TInt foundPos = FindEntry( iData, referenceKey );
__ASSERT_ALWAYS(foundPos>=0, User::Panic(_L("EstablishOrder 2"), KErrBadHandle));
- CTsEntry* entry = iData[foundPos];
+ CTsRunningAppEntry* entry = iData[foundPos];
iData.Remove( foundPos );
iData.Insert( entry, i );
changed = ETrue;
lastChangedItem = i;
}
}
- TTime currentTimestamp;
- currentTimestamp.UniversalTime();
for (TInt i = lastChangedItem; i >= 0; --i)
{
- iData[i]->SetTimestamp(currentTimestamp);
+ iData[i]->RefreshTimestamp();
}
return changed;
}
@@ -551,9 +397,9 @@
{
__ASSERT_ALWAYS(iData[i]->Key() == aList[i]->Key(),
User::Panic(_L("UpdateEntryData 2"), KErrBadHandle));
- if( iData[i]->CloseableApp() != aList[i]->CloseableApp() )
+ if( iData[i]->IsClosable() != aList[i]->IsClosable() )
{
- iData[i]->SetCloseableApp(aList[i]->CloseableApp());
+ iData[i]->SetCloseableApp(aList[i]->IsClosable());
changed = ETrue;
}
}
@@ -569,13 +415,16 @@
*/
TTsEntryKey CTsDataList::GenerateKeyL( TInt aWgId )
{
- RArray<RWsSession::TWindowGroupChainInfo> allWgIds;
+ TTsEntryKey retVal;
+ iResources.WsMonitor().Storage().GenerateKey(retVal, aWgId);
+ return retVal;
+ /*RArray<RWsSession::TWindowGroupChainInfo> allWgIds;
CleanupClosePushL( allWgIds );
User::LeaveIfError( iResources.WsSession().WindowGroupList( 0, &allWgIds ) );
TTsEntryKey key;
User::LeaveIfError(TsEntryKeyGeneraror::Generate(key, aWgId, allWgIds.Array()));
CleanupStack::PopAndDestroy( &allWgIds );
- return key;
+ return key;*/
}
// --------------------------------------------------------------------------
@@ -583,14 +432,15 @@
* Hides entrie if exist on mHiddenUids
* @param entry
*/
-void CTsDataList::HideEntryIfNotAllowed( CTsEntry* aEntry )
+void CTsDataList::HideEntryIfNotAllowed( CTsRunningAppEntry* aEntry )
{
- if( iHiddenUids.Find( aEntry->AppUid() ) >= 0 )
+ if( iResources.ApplicationsBlackList().IsPresent(aEntry->Uid().iUid) )
{
- aEntry->SetVisibility(Invisible);
+ aEntry->SetHidden(ETrue);
}
}
+// --------------------------------------------------------------------------
void CTsDataList::RebuildVisibleDataListL()
{
iVisibleData.Reset();
@@ -598,7 +448,7 @@
CleanupClosePushL(visibleItems);
for( TInt iter = 0; iter < iData.Count(); ++iter )
{
- if( Visible == iData[iter]->GetVisibility() )
+ if( MTsRunningApplication::None == iData[iter]->HideMode() )
{
visibleItems.AppendL(iter);
}