118 /** |
122 /** |
119 * Interface implementation |
123 * Interface implementation |
120 * @see MTsWindowGroupsObserver HandleWindowGroupChanged |
124 * @see MTsWindowGroupsObserver HandleWindowGroupChanged |
121 */ |
125 */ |
122 void CTsDataList::HandleWindowGroupChanged( |
126 void CTsDataList::HandleWindowGroupChanged( |
123 MTsResourceManager &, |
127 MTsResourceManager &/*aResources*/, |
124 const TArray<RWsSession::TWindowGroupChainInfo>& aWgList) |
128 const MTsRunningApplicationStorage& aStorage) |
125 { |
129 { |
126 TRAP_IGNORE(RDebug::Print(_L("[TaskSwitcher] processing started")); |
130 TRAP_IGNORE(RDebug::Print(_L("[TaskSwitcher] processing started")); |
127 RTsFswArray newAppsList; |
131 RTsFswArray newAppsList; |
128 CleanupResetAndDestroyPushL(newAppsList); |
132 CleanupResetAndDestroyPushL(newAppsList); |
129 CollectAppsL(newAppsList, aWgList); |
133 CollectAppsL(newAppsList, aStorage); |
130 RDebug::Print(_L("[TaskSwitcher] gathered app info")); |
134 RDebug::Print(_L("[TaskSwitcher] gathered app info")); |
131 FitDataToListL(newAppsList); |
135 FitDataToListL(newAppsList); |
132 CleanupStack::PopAndDestroy(&newAppsList); |
136 CleanupStack::PopAndDestroy(&newAppsList); |
133 RDebug::Print(_L("[TaskSwitcher] processing finished")); |
137 RDebug::Print(_L("[TaskSwitcher] processing finished")); |
134 ); |
138 ); |
138 /** |
142 /** |
139 * Adds running apps to the list. |
143 * Adds running apps to the list. |
140 * @param aAppsList array to add to |
144 * @param aAppsList array to add to |
141 */ |
145 */ |
142 void CTsDataList::CollectAppsL(RTsFswArray& aAppsList, |
146 void CTsDataList::CollectAppsL(RTsFswArray& aAppsList, |
143 const TArray<RWsSession::TWindowGroupChainInfo> &aWgList) |
147 const MTsRunningApplicationStorage& aStorage) |
144 { |
148 { |
145 for( TInt i(0); i < aWgList.Count(); ++i ) |
149 for( TInt i(0); i < aStorage.Count(); ++i ) |
146 { |
150 { |
147 TTsEntryKey key; |
151 TTsEntryKey key; |
148 TInt err = TsEntryKeyGeneraror::Generate(key, aWgList[i].iId, aWgList); |
152 TInt err = TsEntryKeyGeneraror::Generate( key, |
|
153 aStorage[i].WindowGroupId(), |
|
154 aStorage ); |
149 //skip this entry if it is already on list or generate key failed |
155 //skip this entry if it is already on list or generate key failed |
150 if( err!=KErrNone || FindEntry( aAppsList, key ) >= 0 ) |
156 if( err!=KErrNone || FindEntry( aAppsList, key ) >= 0 ) |
151 { |
157 { |
152 continue; |
158 continue; |
153 } |
159 } |
154 |
160 |
155 // get window group name |
161 // get screen number (-1=console, 0=main screen, 1=cover ui) |
156 CApaWindowGroupName* windowName = |
|
157 CApaWindowGroupName::NewLC( iResources.WsSession(), |
|
158 key.WindowGroupId() ); |
|
159 TUid appUid = windowName->AppUid(); |
|
160 |
|
161 // get screen number (-1=console, 0=main screen, 1=cover ui) |
|
162 TInt appScreen = 0; |
162 TInt appScreen = 0; |
163 TInt scrNumErr = |
163 TInt scrNumErr = |
164 iResources.ApaSession().GetDefaultScreenNumber( appScreen, |
164 iResources.ApaSession().GetDefaultScreenNumber( appScreen, |
165 appUid ); |
165 aStorage[i].UidL() ); |
166 |
166 |
167 if( appUid.iUid && |
167 if( aStorage[i].UidL().iUid && |
168 !windowName->Hidden() && |
168 !aStorage[i].IsHiddenL() && |
169 (appScreen == 0 || appScreen == -1) && |
169 (appScreen == 0 || appScreen == -1) && |
170 scrNumErr == KErrNone ) |
170 scrNumErr == KErrNone ) |
171 { |
171 { |
172 AddEntryL( key, appUid, windowName, aAppsList ); |
172 AddEntryL( key, aStorage[i], aAppsList ); |
173 } |
173 } |
174 |
|
175 CleanupStack::PopAndDestroy( windowName ); |
|
176 } |
174 } |
177 } |
175 } |
178 |
176 |
179 // -------------------------------------------------------------------------- |
177 // -------------------------------------------------------------------------- |
180 /** |
178 /** |
181 * Called from CollectTasksL for each entry in the task list. |
179 * Called from CollectTasksL for each entry in the task list. |
182 * @param aKey entry key |
180 * @param aKey entry key |
183 * @param aAppUid application uid |
181 * @param aRunningApp running application entry |
184 * @param aWgName window group name or NULL |
|
185 * @param aNewList list to add to |
182 * @param aNewList list to add to |
186 */ |
183 */ |
187 void CTsDataList::AddEntryL( const TTsEntryKey& aKey, |
184 void CTsDataList::AddEntryL( const TTsEntryKey& aKey, |
188 const TUid& aAppUid, |
185 const MTsRunningApplication& aRunningApp, |
189 CApaWindowGroupName* aWgName, |
|
190 RTsFswArray& aNewList ) |
186 RTsFswArray& aNewList ) |
191 { |
187 { |
192 CTsEntry* entry = CTsEntry::NewLC( aKey, iObserver ); |
188 CTsEntry* entry = CTsEntry::NewLC( aKey, iObserver, &iEnv ); |
193 // check if present in old list and if yes then take some of the old data |
189 // check if present in old list and if yes then take some of the old data |
194 TBool found = ConsiderOldDataL( aKey ); |
190 TBool found = ConsiderOldDataL( aKey ); |
195 // if not present previously then find out app name |
191 // if not present previously then find out app name |
196 // and check if screenshot is already available |
192 // and check if screenshot is already available |
197 if( !found ) |
193 if( !found ) |
198 { |
194 { |
199 entry->SetAppUid(aAppUid); |
195 entry->SetAppUid(aRunningApp.UidL()); |
200 HBufC* name = FindAppNameLC( aWgName, aAppUid, aKey.WindowGroupId() ); |
196 HBufC* name = FindAppNameLC( aRunningApp ); |
201 entry->SetAppNameL(*name); |
197 entry->SetAppNameL(*name); |
202 CleanupStack::PopAndDestroy( name ); |
198 CleanupStack::PopAndDestroy( name ); |
203 //transfer ownership to entry |
199 //transfer ownership to entry |
204 entry->SetAppIcon( GetAppIconL( aAppUid ) ); |
200 entry->SetAppIcon( GetAppIconL( aRunningApp.UidL() ) ); |
205 } |
201 } |
206 if(aWgName) |
202 entry->SetCloseableApp( !aRunningApp.IsSystemL()); |
207 { |
|
208 entry->SetCloseableApp( !aWgName->IsSystem() ); |
|
209 } |
|
210 // add to new list, ownership is transferred |
203 // add to new list, ownership is transferred |
211 aNewList.AppendL( entry ); |
204 aNewList.AppendL( entry ); |
212 CleanupStack::Pop( entry ); |
205 CleanupStack::Pop( entry ); |
213 } |
206 } |
214 |
207 |
238 * @param aWindowName window group name or NULL |
231 * @param aWindowName window group name or NULL |
239 * @param aAppUId application uid |
232 * @param aAppUId application uid |
240 * @param aWgId window group id |
233 * @param aWgId window group id |
241 * @return application name, ownership transferred to caller |
234 * @return application name, ownership transferred to caller |
242 */ |
235 */ |
243 HBufC* CTsDataList::FindAppNameLC( CApaWindowGroupName* aWindowName, |
236 HBufC* CTsDataList::FindAppNameLC( const MTsRunningApplication& aRunningApp ) |
244 const TUid& aAppUid, |
|
245 TInt aWgId ) |
|
246 { |
237 { |
247 //Retrieve the app name |
238 //Retrieve the app name |
248 TApaAppInfo info; |
239 TApaAppInfo info; |
249 iResources.ApaSession().GetAppInfo( info, aAppUid ); |
240 iResources.ApaSession().GetAppInfo( info, aRunningApp.UidL() ); |
250 TPtrC caption = info.iShortCaption; |
241 TPtrC caption = info.iShortCaption; |
251 |
242 |
252 HBufC* tempName( 0 ); |
243 HBufC* tempName( 0 ); |
253 if (!caption.Length() && aWindowName) // if not set - use thread name instead |
244 if (!caption.Length() ) // if not set - use thread name instead |
254 { |
245 { |
255 if (aWindowName->Caption().Length()) |
246 if( aRunningApp.CaptionL().Length() ) |
256 { |
247 { |
257 tempName = aWindowName->Caption().AllocLC(); |
248 tempName = aRunningApp.CaptionL().AllocLC(); |
258 } |
249 } |
259 else |
250 else |
260 { |
251 { |
261 TThreadId threadId; |
252 TThreadId threadId; |
262 if(KErrNone == iResources.WsSession().GetWindowGroupClientThreadId( aWgId, threadId ) ) |
253 if(KErrNone == iResources.WsSession().GetWindowGroupClientThreadId( aRunningApp.WindowGroupId(), threadId ) ) |
263 { |
254 { |
264 RThread thread; |
255 RThread thread; |
265 CleanupClosePushL( thread ); |
256 CleanupClosePushL( thread ); |
266 if( KErrNone == thread.Open( threadId ) ) |
257 if( KErrNone == thread.Open( threadId ) ) |
267 { |
258 { |