author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 14 Sep 2010 20:58:58 +0300 | |
branch | RCL_3 |
changeset 35 | 3321d3e205b6 |
parent 34 | 5456b4e8b3a8 |
permissions | -rw-r--r-- |
34 | 1 |
/* |
2 |
* Copyright (c) 2008 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: Task monitor engine |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
#include "tsfswengine.h" |
|
20 |
#include "tscpsnotifier.h" |
|
21 |
#include "tsfswdatalist.h" |
|
22 |
#include "tsfsalwaysshownapplist.h" |
|
23 |
#include "tsfshiddenapplist.h" |
|
24 |
#include "tsfswidgetlist.h" |
|
25 |
#include "tspreviewprovider.h" |
|
26 |
#include "tsfswclient.h" |
|
27 |
#include <apgtask.h> |
|
28 |
#include <AknDef.h> |
|
29 |
#include <apgwgnam.h> |
|
30 |
#include <mmf/common/mmfcontrollerpluginresolver.h> // for CleanupResetAndDestroyPushL |
|
31 |
#include <featmgr.h> |
|
32 |
#include <swi/swispubsubdefs.h> |
|
33 |
#include <s32mem.h> |
|
34 |
#include <bitmaptransforms.h> |
|
35 |
#include "enginelogging.h" |
|
36 |
||
37 |
// time to wait before refreshing content |
|
38 |
const TInt KContentRefreshDelay = 50000; // 0.05 sec |
|
39 |
||
40 |
// for screenshots, they are scaled down to (screensize/this_factor). |
|
41 |
const TInt KScreenSizeFactor = 2; |
|
42 |
||
43 |
const TUid KTsCameraUid = { 0x101F857a }; |
|
44 |
||
45 |
//close command for widget |
|
46 |
const TInt KCloseWidgetCmd(9); |
|
47 |
//handle close cmd for s60 widgets |
|
48 |
_LIT(KWidgetAppName, "widgetlauncher.exe"); |
|
49 |
//handle close cmd for CWRT widgets |
|
50 |
_LIT(KWidgetAppNameWgt,"wgtwidgetlauncher.exe"); |
|
51 |
||
52 |
// -------------------------------------------------------------------------- |
|
53 |
// CTsFswEngine::NewL |
|
54 |
// -------------------------------------------------------------------------- |
|
55 |
// |
|
56 |
EXPORT_C CTsFswEngine* CTsFswEngine::NewL( MTsFswEngineObserver& aObserver ) |
|
57 |
{ |
|
58 |
CTsFswEngine* self = NewLC( aObserver ); |
|
59 |
CleanupStack::Pop( self ); |
|
60 |
return self; |
|
61 |
} |
|
62 |
||
63 |
// -------------------------------------------------------------------------- |
|
64 |
// CTsFswEngine::NewLC |
|
65 |
// -------------------------------------------------------------------------- |
|
66 |
// |
|
67 |
EXPORT_C CTsFswEngine* CTsFswEngine::NewLC( MTsFswEngineObserver& aObserver ) |
|
68 |
{ |
|
69 |
CTsFswEngine* self = new ( ELeave ) CTsFswEngine( aObserver ); |
|
70 |
CleanupStack::PushL( self ); |
|
71 |
self->ConstructL(); |
|
72 |
return self; |
|
73 |
} |
|
74 |
||
75 |
// -------------------------------------------------------------------------- |
|
76 |
// CTsFswEngine::CTsFswEngine |
|
77 |
// -------------------------------------------------------------------------- |
|
78 |
// |
|
79 |
CTsFswEngine::CTsFswEngine( MTsFswEngineObserver& aObserver ) |
|
80 |
: CActive( EPriorityStandard ), iObserver( aObserver ) |
|
81 |
{ |
|
82 |
CActiveScheduler::Add( this ); |
|
83 |
} |
|
84 |
||
85 |
// -------------------------------------------------------------------------- |
|
86 |
// CTsFswEngine::ConstructL |
|
87 |
// -------------------------------------------------------------------------- |
|
88 |
// |
|
89 |
void CTsFswEngine::ConstructL() |
|
90 |
{ |
|
91 |
iEnv = CEikonEnv::Static(); |
|
92 |
||
93 |
User::LeaveIfError( iWsSession.Connect() ); |
|
94 |
User::LeaveIfError( iAppArcSession.Connect() ); |
|
95 |
||
96 |
iDataList = CTsFswDataList::NewL(*this); |
|
97 |
iWidgetsSupported = FeatureManager::FeatureSupported( KFeatureIdWebWidgets ); |
|
98 |
||
99 |
// get an initial list of tasks |
|
100 |
iDataList->SetAppDataRefreshNeeded(); |
|
101 |
CollectTasksL(); |
|
102 |
||
103 |
// listen for app screenshots |
|
104 |
iPreviewProvider = CTsFastSwapPreviewProvider::NewL( *this ); |
|
105 |
SetPreviewParams(); |
|
106 |
UpdatePreviewContent(); |
|
107 |
||
108 |
iUpdateStarter = CPeriodic::NewL( CActive::EPriorityStandard ); |
|
109 |
||
110 |
// start listening for swi ps property |
|
111 |
if ( iSwiProp.Attach( KUidSystemCategory, |
|
112 |
Swi::KUidSoftwareInstallKey ) == KErrNone ) |
|
113 |
{ |
|
114 |
iSwiProp.Subscribe( iStatus ); |
|
115 |
SetActive(); |
|
116 |
} |
|
117 |
iCpsWidgetPublisher = CTSCpsNotifier::NewL(*this); |
|
118 |
} |
|
119 |
||
120 |
// -------------------------------------------------------------------------- |
|
121 |
// CTsFswEngine::~CTsFswEngine |
|
122 |
// -------------------------------------------------------------------------- |
|
123 |
// |
|
124 |
CTsFswEngine::~CTsFswEngine() |
|
125 |
{ |
|
126 |
Cancel(); |
|
127 |
iSwiProp.Close(); |
|
128 |
||
129 |
delete iUpdateStarter; |
|
130 |
delete iPreviewProvider; |
|
131 |
||
132 |
iWgIds.Close(); |
|
133 |
||
134 |
iAppArcSession.Close(); |
|
135 |
iWsSession.Close(); |
|
136 |
||
137 |
for ( TInt i = 0; i < iRotaTasks.Count(); i++ ) |
|
138 |
{ |
|
139 |
iRotaTasks[i]->Cancel(); |
|
140 |
delete iRotaTasks[i]; |
|
141 |
} |
|
142 |
iRotaTasks.Close(); |
|
143 |
delete iDataList; |
|
144 |
delete iCpsWidgetPublisher; |
|
145 |
} |
|
146 |
||
147 |
// -------------------------------------------------------------------------- |
|
148 |
// CTsFswEngine::FswDataL |
|
149 |
// -------------------------------------------------------------------------- |
|
150 |
// |
|
151 |
EXPORT_C const RTsFswArray& CTsFswEngine::FswDataL() |
|
152 |
{ |
|
153 |
TSLOG_CONTEXT( FswDataL, TSLOG_LOCAL ); |
|
154 |
TSLOG_OUT(); |
|
155 |
return iDataList->FswDataL(); |
|
156 |
} |
|
157 |
||
158 |
// -------------------------------------------------------------------------- |
|
159 |
// CTsFswEngine::CloseAppL |
|
160 |
// -------------------------------------------------------------------------- |
|
161 |
// |
|
162 |
EXPORT_C void CTsFswEngine::CloseAppL( TInt aWgId ) |
|
163 |
{ |
|
164 |
TSLOG_CONTEXT( CloseAppL, TSLOG_LOCAL ); |
|
165 |
TSLOG1_IN( "aWgId = %d", aWgId ); |
|
166 |
||
167 |
if( iWidgetsSupported && 0 > aWgId ) |
|
168 |
{ |
|
169 |
// convert aWgId to an index in the list of running widgets and close widget |
|
170 |
CloseWidgetL( -aWgId -1 ); |
|
171 |
} |
|
172 |
else if( !iDataList->IsAlwaysShownAppL( aWgId ) ) |
|
173 |
{ |
|
174 |
// send window group event to kill the app |
|
175 |
TWsEvent event; |
|
176 |
event.SetTimeNow(); |
|
177 |
event.SetType( KAknShutOrHideApp ); |
|
178 |
iEnv->WsSession().SendEventToWindowGroup( aWgId, event ); |
|
179 |
TSLOG0( TSLOG_INFO, "event sent to wg" ); |
|
180 |
} |
|
181 |
TSLOG_OUT(); |
|
182 |
} |
|
183 |
||
184 |
// -------------------------------------------------------------------------- |
|
185 |
// CTsFswEngine::SwitchToAppL |
|
186 |
// -------------------------------------------------------------------------- |
|
187 |
// |
|
188 |
EXPORT_C void CTsFswEngine::SwitchToAppL( TInt aWgId ) |
|
189 |
{ |
|
190 |
TSLOG_CONTEXT( SwitchToAppL, TSLOG_LOCAL ); |
|
191 |
TSLOG1_IN( "aWgId = %d", aWgId ); |
|
192 |
||
193 |
if ( iWidgetsSupported && aWgId < 0 ) |
|
194 |
{ |
|
195 |
// for widgets clients see a wgid that is -1*(index+1) |
|
196 |
const RWidgetInfoArray& arr( iDataList->Widgets()->RunningWidgets() ); |
|
197 |
// convert aWgId to an index in the list of running widgets |
|
198 |
TInt idx = -aWgId - 1; |
|
199 |
// if index is valid then handle the widget specially |
|
200 |
if ( idx >= 0 && idx < arr.Count() ) |
|
201 |
{ |
|
202 |
SwitchToWidgetL( idx ); |
|
203 |
TSLOG1_OUT( "switched to widget %d", idx ); |
|
204 |
return; |
|
205 |
} |
|
206 |
} |
|
207 |
||
208 |
TApaTask task( iEnv->WsSession() ); |
|
209 |
task.SetWgId( aWgId ); |
|
210 |
task.BringToForeground(); |
|
211 |
||
212 |
TSLOG_OUT(); |
|
213 |
} |
|
214 |
||
215 |
// -------------------------------------------------------------------------- |
|
216 |
// CTsFswEngine::SwitchToWidgetL |
|
217 |
// -------------------------------------------------------------------------- |
|
218 |
// |
|
219 |
void CTsFswEngine::SwitchToWidgetL( TInt aWidgetIndex ) |
|
220 |
{ |
|
221 |
const RWidgetInfoArray& arr( iDataList->Widgets()->RunningWidgets() ); |
|
222 |
CApaCommandLine* cmdLine = CApaCommandLine::NewLC(); |
|
223 |
cmdLine->SetCommandL( EApaCommandRun ); |
|
224 |
TApaAppInfo info; |
|
225 |
iAppArcSession.GetAppInfo( info, arr[aWidgetIndex]->iUid ); // codescanner::accessArrayElementWithoutCheck2 (aWidgetIndex checked in SwitchToAppL()) |
|
226 |
cmdLine->SetExecutableNameL( info.iFullName ); |
|
227 |
iAppArcSession.StartApp( *cmdLine ); |
|
228 |
CleanupStack::PopAndDestroy(cmdLine); |
|
229 |
} |
|
230 |
||
231 |
// -------------------------------------------------------------------------- |
|
232 |
// CTsFswEngine::UpdateTaskList |
|
233 |
// Callback from appui |
|
234 |
// -------------------------------------------------------------------------- |
|
235 |
// |
|
236 |
void CTsFswEngine::UpdateTaskList() |
|
237 |
{ |
|
238 |
TSLOG_CONTEXT( UpdateTaskList, TSLOG_LOCAL ); |
|
239 |
TSLOG_IN(); |
|
240 |
||
241 |
// screenshot taking support - call Register and Unregister when needed |
|
242 |
UpdatePreviewContent(); |
|
243 |
||
244 |
// get the foreground app uid and publish it to CFW if different than before |
|
245 |
TRAP_IGNORE( PublishFgAppUidL() ); |
|
246 |
||
247 |
// There can be many calls in a row, use a timer to prevent degrading |
|
248 |
// device performance. |
|
249 |
if ( !iUpdateStarter->IsActive() ) |
|
250 |
{ |
|
251 |
iUpdateStarter->Start( KContentRefreshDelay, 0, |
|
252 |
TCallBack( UpdateStarterCallback, this ) ); |
|
253 |
} |
|
254 |
||
255 |
TSLOG_OUT(); |
|
256 |
} |
|
257 |
||
258 |
// -------------------------------------------------------------------------- |
|
259 |
// CTsFswEngine::ForegroundAppUidL |
|
260 |
// -------------------------------------------------------------------------- |
|
261 |
// |
|
262 |
EXPORT_C TUid CTsFswEngine::ForegroundAppUidL( TInt aType ) |
|
263 |
{ |
|
264 |
// Do not use GetFocusWindowGroup or others. |
|
265 |
// We want to see only "real" application uids in FgApp, |
|
266 |
// i.e. stuff that would also be shown in the task swapper |
|
267 |
// area of Taskswitcher. |
|
268 |
||
269 |
TUid result = KNullUid; |
|
270 |
RArray<RWsSession::TWindowGroupChainInfo> allWgIds; |
|
271 |
CleanupClosePushL( allWgIds ); |
|
272 |
User::LeaveIfError( iWsSession.WindowGroupList( 0, &allWgIds ) ); |
|
273 |
TInt count = allWgIds.Count(); |
|
274 |
for ( TInt i = 0; i < count; ++i ) |
|
275 |
{ |
|
276 |
// Depending on aType we may not need to bother with iParentId here. |
|
277 |
// If aType == EUseEmbeddedUid => embedded apps are treated as others. |
|
278 |
// If aType == EUseStandaloneUid => embedded apps must be ignored. |
|
279 |
if ( allWgIds[i].iParentId > 0 |
|
280 |
&& aType == CTsFswClient::EUseStandaloneUid ) |
|
281 |
{ |
|
282 |
continue; |
|
283 |
} |
|
284 |
||
285 |
CApaWindowGroupName* wgn = CApaWindowGroupName::NewLC( |
|
286 |
iWsSession, allWgIds[i].iId ); |
|
287 |
TUid newUid = wgn->AppUid(); |
|
288 |
TBool hidden = wgn->Hidden() || iDataList->HiddenApps()->IsHiddenL( |
|
289 |
newUid, iWsSession, allWgIds[i].iId ); |
|
290 |
CleanupStack::PopAndDestroy( wgn ); |
|
291 |
||
292 |
if ( !hidden && newUid.iUid ) |
|
293 |
{ |
|
294 |
result = newUid; |
|
295 |
break; |
|
296 |
} |
|
297 |
} |
|
298 |
CleanupStack::PopAndDestroy( &allWgIds ); |
|
299 |
||
300 |
return result; |
|
301 |
} |
|
302 |
||
303 |
// -------------------------------------------------------------------------- |
|
304 |
// CTsFswEngine::PublishFgAppUidL |
|
305 |
// -------------------------------------------------------------------------- |
|
306 |
// |
|
307 |
void CTsFswEngine::PublishFgAppUidL() |
|
308 |
{ |
|
309 |
TSLOG_CONTEXT( PublishFgAppUidL, TSLOG_LOCAL ); |
|
310 |
TSLOG_IN(); |
|
311 |
||
312 |
TUid newUid = ForegroundAppUidL( CTsFswClient::EUseEmbeddedUid ); |
|
313 |
TSLOG2( TSLOG_INFO, "ws says: %x we have: %x", newUid.iUid, iFgAppUid.iUid ); |
|
314 |
if ( iFgAppUid != newUid && newUid.iUid ) |
|
315 |
{ |
|
316 |
iFgAppUid = newUid; |
|
317 |
iDataList->MoveEntryAtStart(newUid.iUid, EFalse); |
|
318 |
TBool change( iDataList->MoveEntryAtStart(newUid.iUid, EFalse) ); |
|
319 |
if( change ) |
|
320 |
{ |
|
321 |
iObserver.FswDataChanged(); |
|
322 |
} |
|
323 |
} |
|
324 |
||
325 |
TSLOG_OUT(); |
|
326 |
} |
|
327 |
||
328 |
// -------------------------------------------------------------------------- |
|
329 |
// CTsFswEngine::UpdateStarterCallback |
|
330 |
// Callback for the timer |
|
331 |
// -------------------------------------------------------------------------- |
|
332 |
// |
|
333 |
TInt CTsFswEngine::UpdateStarterCallback( TAny* aParam ) |
|
334 |
{ |
|
335 |
CTsFswEngine* self = static_cast<CTsFswEngine*>( aParam ); |
|
336 |
self->iUpdateStarter->Cancel(); |
|
337 |
// get list of tasks and notify observer if there is a change in the list |
|
338 |
TBool changed = EFalse; |
|
339 |
TRAPD( err, changed = self->CollectTasksL() ); |
|
340 |
if ( err == KErrNone && changed ) |
|
341 |
{ |
|
342 |
self->iObserver.FswDataChanged(); |
|
343 |
} |
|
344 |
return 0; |
|
345 |
} |
|
346 |
||
347 |
// -------------------------------------------------------------------------- |
|
348 |
// CTsFswEngine::CollectTasksL |
|
349 |
// -------------------------------------------------------------------------- |
|
350 |
// |
|
351 |
TBool CTsFswEngine::CollectTasksL() |
|
352 |
{ |
|
353 |
TSLOG_CONTEXT( CollectTasksL, TSLOG_LOCAL ); |
|
354 |
TBool changed = iDataList->CollectTasksL(); |
|
355 |
TSLOG1_OUT( "change flag = %d", changed ); |
|
356 |
return changed; |
|
357 |
} |
|
358 |
||
359 |
||
360 |
// CTsFswEngine::HiddenAppListUpdated |
|
361 |
// Callback from the hidden app list watcher |
|
362 |
// -------------------------------------------------------------------------- |
|
363 |
// |
|
364 |
void CTsFswEngine::HiddenAppListUpdated() |
|
365 |
{ |
|
366 |
UpdateTaskList(); |
|
35
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
367 |
TRAP_IGNORE( iDataList->RemoveHiddenAppsScrenshotsL(); ) |
34 | 368 |
} |
369 |
||
370 |
// -------------------------------------------------------------------------- |
|
371 |
// CTsFswEngine::CopyBitmapL |
|
372 |
// -------------------------------------------------------------------------- |
|
373 |
// |
|
374 |
CFbsBitmap* CTsFswEngine::CopyBitmapL( TInt aFbsHandle, TBool aKeepAspectRatio ) |
|
375 |
{ |
|
376 |
TSLOG_CONTEXT( CopyBitmapL, TSLOG_LOCAL ); |
|
377 |
||
378 |
CFbsBitmap* ret = new (ELeave) CFbsBitmap; |
|
379 |
CleanupStack::PushL( ret ); |
|
380 |
CFbsBitmap* bmp = new (ELeave) CFbsBitmap; |
|
381 |
CleanupStack::PushL( bmp ); |
|
382 |
User::LeaveIfError( bmp->Duplicate( aFbsHandle ) ); |
|
383 |
||
384 |
//Make bitmap width and height equal so that it will look better in FSW control. |
|
385 |
TSize size = bmp->SizeInPixels(); |
|
386 |
||
387 |
if ( !aKeepAspectRatio ) |
|
388 |
{ |
|
389 |
if ( size.iHeight > size.iWidth ) |
|
390 |
{ |
|
391 |
size.iHeight = size.iWidth; |
|
392 |
} |
|
393 |
else |
|
394 |
{ |
|
395 |
size.iWidth = size.iHeight; |
|
396 |
} |
|
397 |
} |
|
398 |
||
399 |
// preserve size and mode |
|
400 |
User::LeaveIfError( ret->Create( size, EColor64K ) ); |
|
401 |
||
402 |
CFbsBitmapDevice* doubleBufferDev = CFbsBitmapDevice::NewL( ret ); |
|
403 |
CleanupStack::PushL( doubleBufferDev ); |
|
404 |
||
405 |
CFbsBitGc* doubleBufferGc = 0; |
|
406 |
User::LeaveIfError( doubleBufferDev->CreateContext( doubleBufferGc ) ); |
|
407 |
CleanupStack::PushL( doubleBufferGc ); |
|
408 |
||
409 |
// preserve size |
|
410 |
doubleBufferGc->BitBlt( TPoint( 0, 0 ), bmp, TRect(size) ); |
|
411 |
||
412 |
CleanupStack::PopAndDestroy( doubleBufferGc ); |
|
413 |
CleanupStack::PopAndDestroy( doubleBufferDev ); |
|
414 |
CleanupStack::PopAndDestroy( bmp ); |
|
415 |
CleanupStack::Pop( ret ); |
|
416 |
||
417 |
TSLOG_OUT(); |
|
418 |
return ret; |
|
419 |
} |
|
420 |
||
421 |
// -------------------------------------------------------------------------- |
|
422 |
// CTsFswEngine::UpdatePreviewContent |
|
423 |
// -------------------------------------------------------------------------- |
|
424 |
// |
|
425 |
void CTsFswEngine::UpdatePreviewContent() |
|
426 |
{ |
|
427 |
TSLOG_CONTEXT( UpdatePreviewContent, TSLOG_LOCAL ); |
|
428 |
TSLOG_IN(); |
|
429 |
||
430 |
RArray<RWsSession::TWindowGroupChainInfo> allWgIds; |
|
431 |
if ( iWsSession.WindowGroupList( 0, &allWgIds ) == KErrNone ) |
|
432 |
{ |
|
433 |
// check window groups that do not exist anymore |
|
434 |
for ( TInt i = 0, ie = iWgIds.Count(); i != ie; ++i ) |
|
435 |
{ |
|
436 |
TInt wgid = iWgIds[i]; |
|
437 |
TBool present = EFalse; |
|
438 |
for ( TInt j = 0, je = allWgIds.Count(); j != je; ++j ) |
|
439 |
{ |
|
440 |
if ( allWgIds[j].iId == wgid ) |
|
441 |
{ |
|
442 |
present = ETrue; |
|
443 |
break; |
|
444 |
} |
|
445 |
} |
|
446 |
if ( !present ) |
|
447 |
{ |
|
448 |
TSLOG1( TSLOG_INFO, "unregister: %d", wgid ); |
|
449 |
iPreviewProvider->Unregister( wgid ); |
|
450 |
} |
|
451 |
} |
|
452 |
// check topmost window group |
|
453 |
if ( allWgIds.Count() ) |
|
454 |
{ |
|
455 |
if ( !iWgIds.Count() || allWgIds[0].iId != iWgIds[0] ) |
|
456 |
{ |
|
457 |
TInt wgid = allWgIds[0].iId; |
|
458 |
TSLOG1( TSLOG_INFO, "registering %d", wgid ); |
|
459 |
iPreviewProvider->Register( wgid ); |
|
460 |
} |
|
461 |
} |
|
462 |
// store the new list |
|
463 |
iWgIds.Reset(); |
|
464 |
for ( TInt i = 0, ie = allWgIds.Count(); i != ie; ++i ) |
|
465 |
{ |
|
466 |
iWgIds.Append( allWgIds[i].iId ); |
|
467 |
} |
|
468 |
} |
|
469 |
allWgIds.Close(); |
|
470 |
||
471 |
TSLOG_OUT(); |
|
472 |
} |
|
473 |
||
474 |
// -------------------------------------------------------------------------- |
|
475 |
// CTsFswEngine::HandleFswPpApplicationChange |
|
476 |
// Callback from CTsFastSwapPreviewProvider |
|
477 |
// Note: aWgId is for the window group for which the screenshot is taken, |
|
478 |
// it may not be the same as the application's wgid (in case of embedded apps) |
|
479 |
// -------------------------------------------------------------------------- |
|
480 |
// |
|
481 |
void CTsFswEngine::HandleFswPpApplicationChange( TInt aWgId, TInt aFbsHandle ) |
|
482 |
{ |
|
483 |
TSLOG_CONTEXT( HandleFswPpApplicationChange, TSLOG_LOCAL ); |
|
484 |
TSLOG2_IN( "aWgId = %d aFbsHandle = %d", aWgId, aFbsHandle ); |
|
485 |
||
486 |
TUid appUid; |
|
487 |
TInt wgId = iDataList->FindMostTopParentWgId(aWgId); |
|
488 |
if ( wgId == KErrNotFound ) |
|
489 |
{ |
|
490 |
wgId = aWgId; |
|
491 |
} |
|
492 |
TInt err = iDataList->AppUidForWgId( wgId, appUid ); |
|
35
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
493 |
TBool hidden = EFalse; |
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
494 |
TRAP_IGNORE( |
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
495 |
hidden = iDataList->HiddenApps()->IsHiddenL( appUid, iWsSession, aWgId) ); |
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
496 |
if ( err || |
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
497 |
KTsCameraUid == appUid || |
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
498 |
hidden ) |
34 | 499 |
{ |
35
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
500 |
// Dont't assign screenshot to camera app or hidden app |
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
501 |
TSLOG0( TSLOG_LOCAL, "Screenshot for camera or hidden app - ignore" ); |
34 | 502 |
iPreviewProvider->AckPreview(aFbsHandle); |
503 |
TSLOG_OUT(); |
|
504 |
return; |
|
505 |
} |
|
506 |
||
507 |
CFbsBitmap* bmp = 0; |
|
508 |
TRAP( err, bmp = CopyBitmapL( aFbsHandle, EFalse ) ); |
|
509 |
iPreviewProvider->AckPreview(aFbsHandle); |
|
510 |
if ( err == KErrNone ) |
|
511 |
{ |
|
512 |
StoreScreenshot(aWgId, bmp); |
|
513 |
} |
|
514 |
||
515 |
TSLOG_OUT(); |
|
516 |
} |
|
517 |
||
518 |
// -------------------------------------------------------------------------- |
|
519 |
// CTsFswEngine::HandleFswPpApplicationUnregistered |
|
520 |
// Callback from CTsFastSwapPreviewProvider |
|
521 |
// -------------------------------------------------------------------------- |
|
522 |
// |
|
523 |
void CTsFswEngine::HandleFswPpApplicationUnregistered( TInt aWgId ) |
|
524 |
{ |
|
525 |
TSLOG_CONTEXT( HandleFswPpApplicationUnregistered, TSLOG_LOCAL ); |
|
526 |
TSLOG1_IN( "aWgId = %d", aWgId ); |
|
527 |
||
528 |
RemoveScreenshot(aWgId); |
|
529 |
||
530 |
TSLOG_OUT(); |
|
531 |
} |
|
532 |
||
533 |
// -------------------------------------------------------------------------- |
|
534 |
// CTsFswEngine::HandleFswPpApplicationBitmapRotation |
|
535 |
// Callback from CTsFastSwapPreviewProvider |
|
536 |
// -------------------------------------------------------------------------- |
|
537 |
// |
|
35
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
538 |
void CTsFswEngine::HandleFswPpApplicationBitmapRotation( TInt aWgId, |
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
539 |
TInt aFbsHandle, TBool aClockwise ) |
34 | 540 |
{ |
541 |
TSLOG_CONTEXT( HandleFswPpApplicationBitmapRotation, TSLOG_LOCAL ); |
|
542 |
TSLOG1_IN( "aWgId = %d", aWgId ); |
|
543 |
||
35
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
544 |
HandleFswPpApplicationChange( aWgId, aFbsHandle ); |
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
545 |
|
34 | 546 |
CFbsBitmap** bmp = iDataList->FindScreenshot(aWgId); |
547 |
||
548 |
if ( bmp ) |
|
549 |
{ |
|
550 |
// Rotate bitmap |
|
551 |
TRAP_IGNORE( RotateL( **bmp, aWgId, aClockwise ) ); |
|
552 |
// Bitmap in a array is invalid, remove it |
|
553 |
RemoveScreenshot(aWgId); |
|
554 |
} |
|
555 |
||
556 |
TSLOG_OUT(); |
|
557 |
} |
|
558 |
||
559 |
||
560 |
// -------------------------------------------------------------------------- |
|
561 |
// CTsFswEngine::RotateL |
|
562 |
// Callback from CTsFastSwapPreviewProvider |
|
563 |
// -------------------------------------------------------------------------- |
|
564 |
// |
|
565 |
void CTsFswEngine::RotateL( CFbsBitmap& aBitmap, TInt aWgId, TBool aClockwise ) |
|
566 |
{ |
|
567 |
CFbsBitmap* rotaBitmap = new (ELeave) CFbsBitmap; |
|
568 |
CleanupStack::PushL( rotaBitmap ); |
|
569 |
User::LeaveIfError( rotaBitmap->Duplicate( aBitmap.Handle() ) ); |
|
570 |
CTsRotationTask* rotaTask = new (ELeave) CTsRotationTask( *this ); |
|
571 |
CleanupStack::PushL( rotaTask ); |
|
572 |
User::LeaveIfError( iRotaTasks.Append( rotaTask ) ); |
|
573 |
rotaTask->StartLD( aWgId, rotaBitmap, aClockwise ); // ownership transferred |
|
574 |
CleanupStack::Pop( rotaTask ); |
|
575 |
CleanupStack::Pop( rotaBitmap ); |
|
576 |
} |
|
577 |
||
578 |
||
579 |
// -------------------------------------------------------------------------- |
|
580 |
// CTsFswEngine::RotationComplete |
|
581 |
// Callback from CTsFastSwapPreviewProvider |
|
582 |
// -------------------------------------------------------------------------- |
|
583 |
// |
|
584 |
void CTsFswEngine::RotationComplete( TInt aWgId, |
|
585 |
CFbsBitmap* aBitmap, |
|
586 |
CTsRotationTask* aCompletedTask, |
|
587 |
TInt aError ) |
|
588 |
{ |
|
589 |
TSLOG_CONTEXT( RotationComplete, TSLOG_LOCAL ); |
|
590 |
TSLOG_IN(); |
|
591 |
||
592 |
TSLOG1( TSLOG_INFO, "---> rotation completed with status: %d", aError ); |
|
593 |
TInt idx = iRotaTasks.Find( aCompletedTask ); |
|
594 |
if ( idx != KErrNotFound ) |
|
595 |
{ |
|
596 |
// Update task list |
|
597 |
iRotaTasks.Remove(idx); |
|
598 |
} |
|
599 |
||
600 |
if ( aError == KErrNone ) |
|
601 |
{ |
|
602 |
StoreScreenshot(aWgId, aBitmap); |
|
603 |
} |
|
604 |
else |
|
605 |
{ |
|
606 |
// Rotation failed, cleanup bitmap |
|
607 |
delete aBitmap; |
|
608 |
} |
|
609 |
||
610 |
TSLOG_OUT(); |
|
611 |
} |
|
612 |
||
613 |
// -------------------------------------------------------------------------- |
|
614 |
// CTsFswEngine::RunL |
|
615 |
// -------------------------------------------------------------------------- |
|
616 |
// |
|
617 |
void CTsFswEngine::RunL() |
|
618 |
{ |
|
619 |
if ( iStatus != KErrCancel ) // when cancelling the subscribe it completes with KErrCancel |
|
620 |
{ |
|
621 |
TInt value = 0; |
|
622 |
if ( iSwiProp.Get( value ) == KErrNone ) |
|
623 |
{ |
|
624 |
TInt operationStatus( value & Swi::KSwisOperationStatusMask ); |
|
625 |
// When an (un)installation has finished change the flag to |
|
626 |
// refresh the app list during the next task list update. |
|
627 |
if ( operationStatus == Swi::ESwisStatusSuccess ) |
|
628 |
{ |
|
629 |
iDataList->SetAppDataRefreshNeeded(); |
|
630 |
} |
|
631 |
} |
|
632 |
iSwiProp.Subscribe( iStatus ); |
|
633 |
SetActive(); |
|
634 |
} |
|
635 |
} |
|
636 |
||
637 |
// -------------------------------------------------------------------------- |
|
638 |
// CTsFswEngine::DoCancel |
|
639 |
// -------------------------------------------------------------------------- |
|
640 |
// |
|
641 |
void CTsFswEngine::DoCancel() |
|
642 |
{ |
|
643 |
iSwiProp.Cancel(); |
|
644 |
} |
|
645 |
||
646 |
// -------------------------------------------------------------------------- |
|
647 |
// CTsFswEngine::RunError |
|
648 |
// -------------------------------------------------------------------------- |
|
649 |
// |
|
650 |
TInt CTsFswEngine::RunError( TInt /*aError*/ ) |
|
651 |
{ |
|
652 |
return KErrNone; |
|
653 |
} |
|
654 |
||
655 |
// -------------------------------------------------------------------------- |
|
656 |
// CTsFswEngine::HandleResourceChange |
|
657 |
// callback from appui's HandleResourceChangeL |
|
658 |
// -------------------------------------------------------------------------- |
|
659 |
// |
|
660 |
void CTsFswEngine::HandleResourceChange( TInt aType ) |
|
661 |
{ |
|
662 |
TSLOG_CONTEXT( HandleResourceChange, TSLOG_LOCAL ); |
|
663 |
TSLOG_IN(); |
|
664 |
||
665 |
if ( iPreviewProvider && aType == KEikDynamicLayoutVariantSwitch ) |
|
666 |
{ |
|
667 |
SetPreviewParams(); |
|
668 |
} |
|
669 |
||
670 |
TSLOG_OUT(); |
|
671 |
} |
|
672 |
||
673 |
// -------------------------------------------------------------------------- |
|
674 |
// CTsFswEngine::SetPreviewParams |
|
675 |
// -------------------------------------------------------------------------- |
|
676 |
// |
|
677 |
void CTsFswEngine::SetPreviewParams() |
|
678 |
{ |
|
679 |
TSize screenSize = iEnv->ScreenDevice()->SizeInPixels(); |
|
680 |
iPreviewProvider->SetPreviewParam( |
|
681 |
TSize( screenSize.iWidth / KScreenSizeFactor, |
|
682 |
screenSize.iHeight / KScreenSizeFactor ), |
|
683 |
EColor64K ); // displaymode is ignored |
|
684 |
} |
|
685 |
||
686 |
// -------------------------------------------------------------------------- |
|
687 |
// CTsFswEngine::CloseWidgetL |
|
688 |
// -------------------------------------------------------------------------- |
|
689 |
// |
|
690 |
void CTsFswEngine::CloseWidgetL(TInt aOffset ) |
|
691 |
{ |
|
692 |
TSLOG_CONTEXT( CloseWidgetL, TSLOG_LOCAL ); |
|
693 |
TSLOG1_IN( "aOffset = %d", aOffset ); |
|
694 |
if( iDataList->Widgets()->RunningWidgets().Count() <= aOffset ) |
|
695 |
{ |
|
696 |
User::Leave(KErrArgument); |
|
697 |
} |
|
698 |
const CWidgetInfo* widgetInfo(iDataList->Widgets()->RunningWidgets()[aOffset]); |
|
699 |
const TPtrC bundleName(*widgetInfo->iBundleName); |
|
700 |
CApaCommandLine* const cmdLine = CApaCommandLine::NewLC(); |
|
701 |
||
702 |
HBufC8* const |
|
703 |
opaque( HBufC8::NewLC( bundleName.Size() + 3 * sizeof( TUint32 ) ) ); |
|
704 |
TPtr8 des ( opaque->Des() ); |
|
705 |
RDesWriteStream stream; |
|
706 |
stream.Open( des ); |
|
707 |
CleanupClosePushL( stream ); |
|
708 |
stream.WriteUint32L ( widgetInfo->iUid.iUid ); |
|
709 |
stream.WriteUint32L ( bundleName.Length() ); |
|
710 |
stream.WriteL ( reinterpret_cast< const TUint8* >( bundleName.Ptr() ), bundleName.Size()); |
|
711 |
stream.WriteInt32L ( KCloseWidgetCmd ); |
|
712 |
CleanupStack::PopAndDestroy( &stream ); |
|
713 |
cmdLine->SetCommandL( EApaCommandBackgroundAndWithoutViews ); |
|
714 |
cmdLine->SetOpaqueDataL( *opaque ); |
|
715 |
CleanupStack::PopAndDestroy( opaque ); |
|
716 |
||
717 |
if (iDataList->Widgets()->IsCWRTWidget(widgetInfo->iUid)) |
|
718 |
{ |
|
719 |
cmdLine->SetExecutableNameL( KWidgetAppNameWgt); |
|
720 |
} |
|
721 |
else |
|
722 |
{ |
|
723 |
cmdLine->SetExecutableNameL( KWidgetAppName ); |
|
724 |
} |
|
725 |
||
726 |
iAppArcSession.StartApp( *cmdLine ); |
|
727 |
CleanupStack::PopAndDestroy( cmdLine ); |
|
728 |
TSLOG_OUT(); |
|
729 |
} |
|
730 |
||
731 |
// -------------------------------------------------------------------------- |
|
732 |
// CTsFswEngine::StoreScreenshot |
|
733 |
// -------------------------------------------------------------------------- |
|
734 |
// |
|
735 |
TBool CTsFswEngine::StoreScreenshot(TInt aWgId, CFbsBitmap* aBmp) |
|
736 |
{ |
|
737 |
TSLOG_CONTEXT( StoreScreenshot, TSLOG_LOCAL ); |
|
738 |
//iDataList would take ownership |
|
739 |
TBool change = EFalse; |
|
740 |
change = iDataList->StoreScreenshot(aWgId, aBmp); |
|
741 |
if(change) |
|
742 |
{ |
|
743 |
iObserver.FswDataChanged(); |
|
744 |
} |
|
745 |
TSLOG1_OUT( "Screenshot for = %d", aWgId ); |
|
746 |
return change; |
|
747 |
} |
|
748 |
||
749 |
// -------------------------------------------------------------------------- |
|
750 |
// CTsFswEngine::RemoveScreenshot() |
|
751 |
// -------------------------------------------------------------------------- |
|
752 |
// |
|
753 |
void CTsFswEngine::RemoveScreenshot(TInt aWgId) |
|
754 |
{ |
|
755 |
TBool change = EFalse; |
|
756 |
change = iDataList->RemoveScreenshot(aWgId); |
|
757 |
if( change ) |
|
758 |
{ |
|
759 |
iObserver.FswDataChanged(); |
|
760 |
} |
|
761 |
} |
|
762 |
||
763 |
// -------------------------------------------------------------------------- |
|
764 |
// CTsFswEngine::HandleWidgetUpdateL() |
|
765 |
// -------------------------------------------------------------------------- |
|
766 |
// |
|
767 |
void CTsFswEngine::HandleWidgetUpdateL(TInt aWidgetId, TInt aBitmapHandle) |
|
768 |
{ |
|
769 |
TSLOG_CONTEXT( HandleWidgetUpdateL, TSLOG_LOCAL ); |
|
770 |
||
771 |
TBool contentChanged( iDataList->MoveEntryAtStart(aWidgetId, ETrue) ); |
|
772 |
||
773 |
CFbsBitmap* bmp = 0; |
|
774 |
if( aBitmapHandle ) |
|
775 |
{ |
|
776 |
TRAPD( err, bmp = CopyBitmapL( aBitmapHandle, EFalse ) ); |
|
777 |
if ( err == KErrNone ) |
|
778 |
{ |
|
779 |
contentChanged = StoreScreenshot(aWidgetId, bmp); |
|
780 |
} |
|
781 |
} |
|
782 |
if(!contentChanged) |
|
783 |
{ |
|
784 |
iObserver.FswDataChanged(); |
|
785 |
} |
|
786 |
||
787 |
TSLOG_OUT(); |
|
788 |
} |
|
789 |
||
790 |
// -------------------------------------------------------------------------- |
|
791 |
// CTsRotationListener::CTsRotationListener |
|
792 |
// -------------------------------------------------------------------------- |
|
793 |
// |
|
794 |
CTsRotationTask::CTsRotationTask(CTsFswEngine& aEngine ) |
|
795 |
: CActive(EPriorityStandard), |
|
796 |
iEngine(aEngine) |
|
797 |
{ |
|
798 |
CActiveScheduler::Add( this ); |
|
799 |
} |
|
800 |
||
801 |
||
802 |
// -------------------------------------------------------------------------- |
|
803 |
// CTsRotationListener::~CTsRotationListener |
|
804 |
// -------------------------------------------------------------------------- |
|
805 |
// |
|
806 |
CTsRotationTask::~CTsRotationTask() |
|
807 |
{ |
|
808 |
Cancel(); |
|
809 |
delete iRotator; |
|
810 |
delete iBitmap; |
|
811 |
} |
|
812 |
||
813 |
||
814 |
// -------------------------------------------------------------------------- |
|
815 |
// CTsRotationListener::Start |
|
816 |
// -------------------------------------------------------------------------- |
|
817 |
// |
|
818 |
void CTsRotationTask::StartLD( TInt aWgId, |
|
819 |
CFbsBitmap* aBitmap, |
|
820 |
TBool aClockwise ) |
|
821 |
{ |
|
822 |
TSLOG_CONTEXT( StartLD, TSLOG_LOCAL ); |
|
823 |
TSLOG_IN(); |
|
824 |
||
825 |
iWgId = aWgId; |
|
826 |
iBitmap = aBitmap; |
|
827 |
iRotator = CBitmapRotator::NewL(); |
|
828 |
if ( aClockwise ) |
|
829 |
{ |
|
830 |
iRotator->Rotate(&iStatus, *iBitmap, CBitmapRotator::ERotation90DegreesClockwise); |
|
831 |
} |
|
832 |
else |
|
833 |
{ |
|
834 |
iRotator->Rotate(&iStatus, *iBitmap, CBitmapRotator::ERotation270DegreesClockwise); |
|
835 |
} |
|
836 |
SetActive(); |
|
837 |
||
838 |
TSLOG_OUT(); |
|
839 |
} |
|
840 |
||
841 |
||
842 |
// -------------------------------------------------------------------------- |
|
843 |
// CTsRotationListener::RunL |
|
844 |
// -------------------------------------------------------------------------- |
|
845 |
// |
|
846 |
void CTsRotationTask::RunL() |
|
847 |
{ |
|
848 |
iEngine.RotationComplete( iWgId, iBitmap, this, iStatus.Int() ); // bitmap ownership transferred |
|
849 |
iBitmap = NULL; |
|
850 |
delete this; |
|
851 |
} |
|
852 |
||
853 |
||
854 |
// -------------------------------------------------------------------------- |
|
855 |
// CTsRotationListener::DoCancel |
|
856 |
// -------------------------------------------------------------------------- |
|
857 |
// |
|
858 |
void CTsRotationTask::DoCancel() |
|
859 |
{ |
|
860 |
iRotator->Cancel(); |
|
861 |
} |
|
862 |
||
863 |
// end of file |