12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description : |
14 * Description : |
15 * |
15 * |
16 */ |
16 */ |
|
17 #include "tsutils.h" |
|
18 #include "tsentrykey.h" |
17 #include "tsrunningappstorageimp.h" |
19 #include "tsrunningappstorageimp.h" |
|
20 |
18 //------------------------------------------------------------------------------ |
21 //------------------------------------------------------------------------------ |
19 CTsRunningAppStorage* CTsRunningAppStorage::NewLC() |
22 CTsRunningAppStorage* CTsRunningAppStorage::NewLC() |
20 { |
23 { |
21 CTsRunningAppStorage* self = new(ELeave) CTsRunningAppStorage(); |
24 CTsRunningAppStorage* self = new(ELeave) CTsRunningAppStorage(); |
22 CleanupStack::PushL( self ); |
25 CleanupStack::PushL( self ); |
|
26 self->iRunningApps = new (ELeave)CArrayPtrFlat<CTsRunningApp>(1); |
23 return self; |
27 return self; |
24 } |
28 } |
25 |
29 |
26 //------------------------------------------------------------------------------ |
30 //------------------------------------------------------------------------------ |
|
31 CTsRunningAppStorage* CTsRunningAppStorage::NewL() |
|
32 { |
|
33 CTsRunningAppStorage* self( CTsRunningAppStorage::NewLC() ); |
|
34 CleanupStack::Pop( self ); |
|
35 return self; |
|
36 } |
|
37 //------------------------------------------------------------------------------ |
27 CTsRunningAppStorage::CTsRunningAppStorage() |
38 CTsRunningAppStorage::CTsRunningAppStorage() |
28 { |
39 { |
29 //No implementation required |
40 //No implementation required |
30 } |
41 } |
31 |
42 |
32 //------------------------------------------------------------------------------ |
43 //------------------------------------------------------------------------------ |
33 CTsRunningAppStorage::~CTsRunningAppStorage() |
44 CTsRunningAppStorage::~CTsRunningAppStorage() |
34 { |
45 { |
35 iRunningApps.ResetAndDestroy(); |
46 if( 0 != iRunningApps ) |
36 } |
47 { |
|
48 iRunningApps->ResetAndDestroy(); |
|
49 } |
|
50 delete iRunningApps; |
|
51 iBlockedWindowGroups.Close(); |
|
52 } |
37 |
53 |
38 //------------------------------------------------------------------------------ |
54 //------------------------------------------------------------------------------ |
39 void CTsRunningAppStorage::HandleWindowGroupChanged( |
55 void CTsRunningAppStorage::HandleWindowGroupChanged( |
40 MTsResourceManager &aResources, |
56 MTsResourceManager &aResources, |
41 const TArray<RWsSession::TWindowGroupChainInfo> & aWindowGroups ) |
57 const TArray<RWsSession::TWindowGroupChainInfo> & aWindowGroups ) |
42 { |
58 { |
43 CTsRunningApp* app(0); |
59 CTsRunningApp* app(0); |
44 iRunningApps.ResetAndDestroy(); |
|
45 iBlockedWindowGroups.Reset(); |
60 iBlockedWindowGroups.Reset(); |
46 TRAP_IGNORE( |
61 TRAP_IGNORE( |
47 for( TInt iter(0); iter < aWindowGroups.Count(); ++iter ) |
62 CArrayPtr<CTsRunningApp> *runningApps(new (ELeave)CArrayPtrFlat<CTsRunningApp>(aWindowGroups.Count())); |
48 { |
63 TaskSwitcher::CleanupResetAndDestroyPushL(runningApps); |
49 app = CTsRunningApp::NewLC(aResources, aWindowGroups[iter]); |
64 for(TInt current(0); current < aWindowGroups.Count(); ++current) |
50 iRunningApps.AppendL(app); |
65 { |
|
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); |
51 CleanupStack::Pop(app); |
82 CleanupStack::Pop(app); |
52 } |
83 } |
|
84 iRunningApps->ResetAndDestroy(); |
|
85 delete iRunningApps; |
|
86 iRunningApps = runningApps; |
|
87 CleanupStack::Pop(runningApps); |
53 )//TRAP_IGNORE |
88 )//TRAP_IGNORE |
54 } |
89 } |
55 |
90 |
56 //------------------------------------------------------------------------------ |
91 //------------------------------------------------------------------------------ |
57 void CTsRunningAppStorage::HandleWindowGroupChanged( |
92 void CTsRunningAppStorage::HandleWindowGroupChanged( |
75 iBlockedWindowGroups.Append(aFull[full].iId); |
110 iBlockedWindowGroups.Append(aFull[full].iId); |
76 } |
111 } |
77 } |
112 } |
78 } |
113 } |
79 //------------------------------------------------------------------------------ |
114 //------------------------------------------------------------------------------ |
80 const MTsRunningApplication& CTsRunningAppStorage::operator[] (TInt aOffset) const |
115 MTsRunningApplication& CTsRunningAppStorage::operator[] (TInt aOffset) const |
81 { |
116 { |
82 return *iRunningApps[aOffset]; |
117 return *(*iRunningApps)[aOffset]; |
83 } |
118 } |
84 |
119 |
85 //------------------------------------------------------------------------------ |
120 //------------------------------------------------------------------------------ |
86 TInt CTsRunningAppStorage::Count() const |
121 TInt CTsRunningAppStorage::Count() const |
87 { |
122 { |
88 return iRunningApps.Count(); |
123 return iRunningApps->Count(); |
89 } |
124 } |
90 |
125 |
91 //------------------------------------------------------------------------------ |
126 //------------------------------------------------------------------------------ |
92 TInt CTsRunningAppStorage::ParentIndex( const MTsRunningApplication& aRunningApp ) const |
127 TInt CTsRunningAppStorage::ParentIndex( const MTsRunningApplication& aRunningApp ) const |
93 { |
128 { |
101 { |
136 { |
102 return iBlockedWindowGroups.Array(); |
137 return iBlockedWindowGroups.Array(); |
103 } |
138 } |
104 |
139 |
105 //------------------------------------------------------------------------------ |
140 //------------------------------------------------------------------------------ |
|
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 //------------------------------------------------------------------------------ |
106 TInt CTsRunningAppStorage::ParentIndex( TInt aOffset ) const |
174 TInt CTsRunningAppStorage::ParentIndex( TInt aOffset ) const |
107 { |
175 { |
108 TInt retval(aOffset); |
176 TInt retval(aOffset); |
109 if(iRunningApps[aOffset]->IsEmbeded()) |
177 |
110 { |
178 if((*iRunningApps)[aOffset]->IsEmbeded()) |
111 const TInt parentIndex( Find(iRunningApps[aOffset]->ParentWindowGroupId(), |
179 { |
|
180 const TInt parentIndex( Find((*iRunningApps)[aOffset]->ParentWindowGroupId(), |
112 aOffset + 1) ); |
181 aOffset + 1) ); |
113 if( KErrNotFound != parentIndex ) |
182 if( KErrNotFound != parentIndex ) |
114 { |
183 { |
115 retval = ParentIndex( parentIndex ); |
184 retval = ParentIndex( parentIndex ); |
116 } |
185 } |