diff -r 0b3699f6c654 -r e36b2f4799c0 taskswitcher/server/src/tsrunningappstorage.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/taskswitcher/server/src/tsrunningappstorage.cpp Mon Oct 04 00:38:31 2010 +0300 @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description : + * + */ +#include "tsrunningappstorage.h" +#include "tsrunningapp.h" +//------------------------------------------------------------------------------ +CTsRunningAppStorage* CTsRunningAppStorage::NewLC() + { + CTsRunningAppStorage* self = new(ELeave) CTsRunningAppStorage(); + CleanupStack::PushL( self ); + return self; + } + +//------------------------------------------------------------------------------ +CTsRunningAppStorage::CTsRunningAppStorage() + { + //No implementation required + } + +//------------------------------------------------------------------------------ +CTsRunningAppStorage::~CTsRunningAppStorage() +{ + iRunningApps.ResetAndDestroy(); +} + +//------------------------------------------------------------------------------ +void CTsRunningAppStorage::HandleWindowGroupChanged( + MTsResourceManager &aResources, + const TArray & aWindowGroups ) + { + CTsRunningApp* app(0); + iRunningApps.ResetAndDestroy(); + iBlockedWindowGroups.Reset(); + TRAP_IGNORE( + for( TInt iter(0); iter < aWindowGroups.Count(); ++iter ) + { + app = CTsRunningApp::NewLC(aResources, aWindowGroups[iter]); + iRunningApps.AppendL(app); + CleanupStack::Pop(app); + } + )//TRAP_IGNORE + } + +//------------------------------------------------------------------------------ +void CTsRunningAppStorage::HandleWindowGroupChanged( + MTsResourceManager &aResources, + const TArray& aFull, + const TArray& aFiltered) + { + TInt filtered(0); + HandleWindowGroupChanged(aResources, aFiltered); + for(TInt full(0); full < aFull.Count(); ++full) + { + for(filtered = 0; filtered < aFiltered.Count(); ++filtered) + { + if(aFull[full].iId == aFiltered[ filtered].iId) + { + break; + } + } + if(aFiltered.Count() == filtered) + { + iBlockedWindowGroups.Append(aFull[full].iId); + } + } + } +//------------------------------------------------------------------------------ +const MTsRunningApplication& CTsRunningAppStorage::operator[] (TInt aOffset) const + { + return *iRunningApps[aOffset]; + } + +//------------------------------------------------------------------------------ +TInt CTsRunningAppStorage::Count() const + { + return iRunningApps.Count(); + } + +//------------------------------------------------------------------------------ +TInt CTsRunningAppStorage::ParentIndex( const MTsRunningApplication& aRunningApp ) const + { + const TInt applicationIndex(Find(aRunningApp.WindowGroupId())); + return KErrNotFound == applicationIndex ? + applicationIndex : ParentIndex(applicationIndex); + } + +//------------------------------------------------------------------------------ +TArray CTsRunningAppStorage::BlockedWindowGroups() const + { + return iBlockedWindowGroups.Array(); + } + +//------------------------------------------------------------------------------ +TInt CTsRunningAppStorage::ParentIndex( TInt aOffset ) const + { + TInt retval(aOffset); + if(iRunningApps[aOffset]->IsEmbeded()) + { + const TInt parentIndex( Find(iRunningApps[aOffset]->ParentWindowGroupId(), + aOffset + 1) ); + if( KErrNotFound != parentIndex ) + { + retval = ParentIndex( parentIndex ); + } + } + return retval; + } + +//------------------------------------------------------------------------------ +TInt CTsRunningAppStorage::Find(TInt aWindowGroupId, TInt aOffset) const + { + TInt retVal(KErrNotFound); + for( TInt iter(aOffset); + KErrNotFound == retVal && iter < iRunningApps.Count(); + ++iter ) + { + if( iRunningApps[iter]->WindowGroupId() == aWindowGroupId ) + { + retVal = iter; + } + } + return retVal; + } + +