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