taskswitcher/server/src/tsrunningappstorage.cpp
changeset 125 26079c1bb561
parent 123 d1dadafc5584
child 126 efda7c0771b9
equal deleted inserted replaced
123:d1dadafc5584 125:26079c1bb561
     1 /*
       
     2  * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3  * All rights reserved.
       
     4  * This component and the accompanying materials are made available
       
     5  * under the terms of "Eclipse Public License v1.0"
       
     6  * which accompanies this distribution, and is available
       
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8  *
       
     9  * Initial Contributors:
       
    10  * Nokia Corporation - initial contribution.
       
    11  *
       
    12  * Contributors:
       
    13  *
       
    14  * Description :
       
    15  *
       
    16  */
       
    17 #include "tsrunningappstorage.h"
       
    18 #include "tsrunningapp.h"
       
    19 //------------------------------------------------------------------------------
       
    20 CTsRunningAppStorage* CTsRunningAppStorage::NewLC()
       
    21     {
       
    22     CTsRunningAppStorage* self = new(ELeave) CTsRunningAppStorage();
       
    23     CleanupStack::PushL( self );
       
    24     return self;
       
    25     }
       
    26 
       
    27 //------------------------------------------------------------------------------
       
    28 CTsRunningAppStorage::CTsRunningAppStorage()
       
    29     {
       
    30     //No implementation required
       
    31     }
       
    32 
       
    33 //------------------------------------------------------------------------------
       
    34 CTsRunningAppStorage::~CTsRunningAppStorage()
       
    35 {
       
    36     iRunningApps.ResetAndDestroy();
       
    37 }
       
    38 
       
    39 //------------------------------------------------------------------------------
       
    40 void CTsRunningAppStorage::HandleWindowGroupChanged( 
       
    41                MTsResourceManager &aResources, 
       
    42                const TArray<RWsSession::TWindowGroupChainInfo> & aWindowGroups )
       
    43     {
       
    44     CTsRunningApp* app(0);
       
    45     iRunningApps.ResetAndDestroy();
       
    46     iBlockedWindowGroups.Reset();
       
    47     TRAP_IGNORE(
       
    48     for( TInt iter(0); iter < aWindowGroups.Count(); ++iter )
       
    49         {
       
    50         app = CTsRunningApp::NewLC(aResources, aWindowGroups[iter]);
       
    51         iRunningApps.AppendL(app);
       
    52         CleanupStack::Pop(app);
       
    53         }
       
    54     )//TRAP_IGNORE
       
    55     }
       
    56 
       
    57 //------------------------------------------------------------------------------
       
    58 void CTsRunningAppStorage::HandleWindowGroupChanged( 
       
    59            MTsResourceManager &aResources, 
       
    60            const TArray<RWsSession::TWindowGroupChainInfo>& aFull,
       
    61            const TArray<RWsSession::TWindowGroupChainInfo>& aFiltered)
       
    62     {
       
    63     TInt filtered(0);
       
    64     HandleWindowGroupChanged(aResources, aFiltered);
       
    65     for(TInt full(0); full < aFull.Count(); ++full)
       
    66         {
       
    67         for(filtered = 0; filtered < aFiltered.Count(); ++filtered)
       
    68             {
       
    69             if(aFull[full].iId == aFiltered[ filtered].iId)
       
    70                 {
       
    71                 break;
       
    72                 }
       
    73             }
       
    74         if(aFiltered.Count() == filtered)
       
    75             {
       
    76             iBlockedWindowGroups.Append(aFull[full].iId);
       
    77             }
       
    78         }
       
    79     }
       
    80 //------------------------------------------------------------------------------
       
    81 const MTsRunningApplication& CTsRunningAppStorage::operator[] (TInt aOffset) const
       
    82     {
       
    83     return *iRunningApps[aOffset];
       
    84     }
       
    85 
       
    86 //------------------------------------------------------------------------------
       
    87 TInt CTsRunningAppStorage::Count() const
       
    88     {
       
    89     return iRunningApps.Count();
       
    90     }
       
    91 
       
    92 //------------------------------------------------------------------------------
       
    93 TInt CTsRunningAppStorage::ParentIndex( const MTsRunningApplication& aRunningApp ) const
       
    94     {
       
    95     const TInt applicationIndex(Find(aRunningApp.WindowGroupId()));
       
    96     return KErrNotFound == applicationIndex ? 
       
    97            applicationIndex : ParentIndex(applicationIndex);
       
    98     }
       
    99 
       
   100 //------------------------------------------------------------------------------
       
   101 TArray<TInt> CTsRunningAppStorage::BlockedWindowGroups() const
       
   102     {
       
   103     return iBlockedWindowGroups.Array();
       
   104     }
       
   105 
       
   106 //------------------------------------------------------------------------------
       
   107 TInt CTsRunningAppStorage::ParentIndex( TInt aOffset ) const
       
   108     {
       
   109     TInt retval(aOffset);
       
   110     if(iRunningApps[aOffset]->IsEmbeded())
       
   111         {
       
   112         const TInt parentIndex( Find(iRunningApps[aOffset]->ParentWindowGroupId(), 
       
   113                                 aOffset + 1) );
       
   114         if( KErrNotFound != parentIndex )
       
   115             {
       
   116             retval = ParentIndex( parentIndex );
       
   117             }
       
   118         }
       
   119     return retval;
       
   120     }
       
   121 
       
   122 //------------------------------------------------------------------------------
       
   123 TInt CTsRunningAppStorage::Find(TInt aWindowGroupId, TInt aOffset) const
       
   124     {
       
   125     TInt retVal(KErrNotFound);
       
   126     for( TInt iter(aOffset); 
       
   127          KErrNotFound == retVal && iter < iRunningApps.Count(); 
       
   128          ++iter )
       
   129         {
       
   130         if( iRunningApps[iter]->WindowGroupId() == aWindowGroupId )
       
   131             {
       
   132             retVal = iter;
       
   133             }
       
   134         }
       
   135     return retVal;
       
   136     }
       
   137 
       
   138