125
|
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 |
*/
|
127
|
17 |
#include "tsutils.h"
|
|
18 |
#include "tsentrykey.h"
|
125
|
19 |
#include "tsrunningappstorageimp.h"
|
127
|
20 |
|
125
|
21 |
//------------------------------------------------------------------------------
|
|
22 |
CTsRunningAppStorage* CTsRunningAppStorage::NewLC()
|
|
23 |
{
|
|
24 |
CTsRunningAppStorage* self = new(ELeave) CTsRunningAppStorage();
|
|
25 |
CleanupStack::PushL( self );
|
127
|
26 |
self->iRunningApps = new (ELeave)CArrayPtrFlat<CTsRunningApp>(1);
|
125
|
27 |
return self;
|
|
28 |
}
|
|
29 |
|
|
30 |
//------------------------------------------------------------------------------
|
127
|
31 |
CTsRunningAppStorage* CTsRunningAppStorage::NewL()
|
|
32 |
{
|
|
33 |
CTsRunningAppStorage* self( CTsRunningAppStorage::NewLC() );
|
|
34 |
CleanupStack::Pop( self );
|
|
35 |
return self;
|
|
36 |
}
|
|
37 |
//------------------------------------------------------------------------------
|
125
|
38 |
CTsRunningAppStorage::CTsRunningAppStorage()
|
|
39 |
{
|
|
40 |
//No implementation required
|
|
41 |
}
|
|
42 |
|
|
43 |
//------------------------------------------------------------------------------
|
|
44 |
CTsRunningAppStorage::~CTsRunningAppStorage()
|
127
|
45 |
{
|
|
46 |
if( 0 != iRunningApps )
|
|
47 |
{
|
|
48 |
iRunningApps->ResetAndDestroy();
|
|
49 |
}
|
|
50 |
delete iRunningApps;
|
|
51 |
iBlockedWindowGroups.Close();
|
|
52 |
}
|
125
|
53 |
|
|
54 |
//------------------------------------------------------------------------------
|
|
55 |
void CTsRunningAppStorage::HandleWindowGroupChanged(
|
|
56 |
MTsResourceManager &aResources,
|
|
57 |
const TArray<RWsSession::TWindowGroupChainInfo> & aWindowGroups )
|
|
58 |
{
|
|
59 |
CTsRunningApp* app(0);
|
|
60 |
iBlockedWindowGroups.Reset();
|
|
61 |
TRAP_IGNORE(
|
127
|
62 |
CArrayPtr<CTsRunningApp> *runningApps(new (ELeave)CArrayPtrFlat<CTsRunningApp>(aWindowGroups.Count()));
|
|
63 |
TaskSwitcher::CleanupResetAndDestroyPushL(runningApps);
|
|
64 |
for(TInt current(0); current < aWindowGroups.Count(); ++current)
|
125
|
65 |
{
|
127
|
66 |
app = 0;
|
|
67 |
for(TInt old(0); 0 == app && old < iRunningApps->Count(); ++old)
|
|
68 |
{
|
|
69 |
if(iRunningApps->At(old)->WindowGroupId() == aWindowGroups[current].iId)
|
|
70 |
{
|
|
71 |
app = iRunningApps->At(old);
|
|
72 |
iRunningApps->Delete(old);
|
|
73 |
CleanupStack::PushL(app);
|
|
74 |
app->RefreshDataL();
|
|
75 |
}
|
|
76 |
}
|
|
77 |
if(0 == app)
|
|
78 |
{
|
|
79 |
app = CTsRunningApp::NewLC(aResources, aWindowGroups[current]);
|
|
80 |
}
|
|
81 |
runningApps->InsertL(current, app);
|
125
|
82 |
CleanupStack::Pop(app);
|
|
83 |
}
|
127
|
84 |
iRunningApps->ResetAndDestroy();
|
|
85 |
delete iRunningApps;
|
|
86 |
iRunningApps = runningApps;
|
|
87 |
CleanupStack::Pop(runningApps);
|
125
|
88 |
)//TRAP_IGNORE
|
|
89 |
}
|
|
90 |
|
|
91 |
//------------------------------------------------------------------------------
|
|
92 |
void CTsRunningAppStorage::HandleWindowGroupChanged(
|
|
93 |
MTsResourceManager &aResources,
|
|
94 |
const TArray<RWsSession::TWindowGroupChainInfo>& aFull,
|
|
95 |
const TArray<RWsSession::TWindowGroupChainInfo>& aFiltered)
|
|
96 |
{
|
|
97 |
TInt filtered(0);
|
|
98 |
HandleWindowGroupChanged(aResources, aFiltered);
|
|
99 |
for(TInt full(0); full < aFull.Count(); ++full)
|
|
100 |
{
|
|
101 |
for(filtered = 0; filtered < aFiltered.Count(); ++filtered)
|
|
102 |
{
|
127
|
103 |
if(aFull[full].iId == aFiltered[filtered].iId)
|
125
|
104 |
{
|
|
105 |
break;
|
|
106 |
}
|
|
107 |
}
|
|
108 |
if(aFiltered.Count() == filtered)
|
|
109 |
{
|
|
110 |
iBlockedWindowGroups.Append(aFull[full].iId);
|
|
111 |
}
|
|
112 |
}
|
|
113 |
}
|
|
114 |
//------------------------------------------------------------------------------
|
127
|
115 |
MTsRunningApplication& CTsRunningAppStorage::operator[] (TInt aOffset) const
|
125
|
116 |
{
|
127
|
117 |
return *(*iRunningApps)[aOffset];
|
125
|
118 |
}
|
|
119 |
|
|
120 |
//------------------------------------------------------------------------------
|
|
121 |
TInt CTsRunningAppStorage::Count() const
|
|
122 |
{
|
127
|
123 |
return iRunningApps->Count();
|
125
|
124 |
}
|
|
125 |
|
|
126 |
//------------------------------------------------------------------------------
|
|
127 |
TInt CTsRunningAppStorage::ParentIndex( const MTsRunningApplication& aRunningApp ) const
|
|
128 |
{
|
|
129 |
const TInt applicationIndex(Find(aRunningApp.WindowGroupId()));
|
|
130 |
return KErrNotFound == applicationIndex ?
|
|
131 |
applicationIndex : ParentIndex(applicationIndex);
|
|
132 |
}
|
|
133 |
|
|
134 |
//------------------------------------------------------------------------------
|
|
135 |
TArray<TInt> CTsRunningAppStorage::BlockedWindowGroups() const
|
|
136 |
{
|
|
137 |
return iBlockedWindowGroups.Array();
|
|
138 |
}
|
|
139 |
|
|
140 |
//------------------------------------------------------------------------------
|
127
|
141 |
TInt CTsRunningAppStorage::GenerateKey( TTsEntryKey& aReturnKey,
|
|
142 |
TInt aWindowGroupId) const
|
|
143 |
{
|
|
144 |
return GenerateKey(aReturnKey, aWindowGroupId, 0);
|
|
145 |
}
|
|
146 |
|
|
147 |
//------------------------------------------------------------------------------
|
|
148 |
TInt CTsRunningAppStorage::GenerateKey( TTsEntryKey& aReturnKey,
|
|
149 |
TInt aWindowGroupId,
|
|
150 |
TInt aOffset) const
|
|
151 |
{
|
|
152 |
TInt retVal(Find(aWindowGroupId, aOffset));
|
|
153 |
if( KErrNotFound != retVal )
|
|
154 |
{
|
|
155 |
CTsRunningApp &app(*iRunningApps->At(retVal));
|
|
156 |
if(app.WindowGroupId() == app.ParentWindowGroupId())
|
|
157 |
{
|
|
158 |
retVal = KErrBadHandle;
|
|
159 |
}
|
|
160 |
else if( app.IsEmbeded() )
|
|
161 |
{
|
|
162 |
retVal = GenerateKey(aReturnKey, app.ParentWindowGroupId(), retVal);
|
|
163 |
}
|
|
164 |
else
|
|
165 |
{
|
|
166 |
aReturnKey = app.Key();
|
|
167 |
retVal = KErrNone;
|
|
168 |
}
|
|
169 |
}
|
|
170 |
return retVal;
|
|
171 |
}
|
|
172 |
|
|
173 |
//------------------------------------------------------------------------------
|
125
|
174 |
TInt CTsRunningAppStorage::ParentIndex( TInt aOffset ) const
|
|
175 |
{
|
|
176 |
TInt retval(aOffset);
|
127
|
177 |
|
|
178 |
if((*iRunningApps)[aOffset]->IsEmbeded())
|
125
|
179 |
{
|
127
|
180 |
const TInt parentIndex( Find((*iRunningApps)[aOffset]->ParentWindowGroupId(),
|
125
|
181 |
aOffset + 1) );
|
|
182 |
if( KErrNotFound != parentIndex )
|
|
183 |
{
|
|
184 |
retval = ParentIndex( parentIndex );
|
|
185 |
}
|
|
186 |
}
|
|
187 |
return retval;
|
|
188 |
}
|
|
189 |
|
|
190 |
//------------------------------------------------------------------------------
|
|
191 |
TInt CTsRunningAppStorage::Find(TInt aWindowGroupId, TInt aOffset) const
|
|
192 |
{
|
|
193 |
TInt retVal(KErrNotFound);
|
|
194 |
for( TInt iter(aOffset);
|
127
|
195 |
KErrNotFound == retVal && iter < iRunningApps->Count();
|
125
|
196 |
++iter )
|
|
197 |
{
|
127
|
198 |
if( (*iRunningApps)[iter]->WindowGroupId() == aWindowGroupId )
|
125
|
199 |
{
|
|
200 |
retVal = iter;
|
|
201 |
}
|
|
202 |
}
|
|
203 |
return retVal;
|
|
204 |
}
|
|
205 |
|
|
206 |
|