|
1 /* |
|
2 * Copyright (c) 2008-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: AppUi class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #include "glxappui.h" |
|
22 |
|
23 #include <avkon.hrh> |
|
24 #include <StringLoader.h> |
|
25 #include <aknnotewrappers.h> |
|
26 #include <AknUtils.h> |
|
27 #include <mpxviewutility.h> |
|
28 #include <mpxcollectionutility.h> |
|
29 #include <mpxcollectionmessage.h> |
|
30 #include <mpxmessagegeneraldefs.h> |
|
31 #include <mpxcollectionpath.h> |
|
32 #include <centralrepository.h> |
|
33 #include <alf/alfenv.h> |
|
34 #include <akntoolbar.h> |
|
35 #include <glxgallery.hrh> |
|
36 #include <glxcollectionplugincamera.hrh> |
|
37 #include <glxcollectionpluginall.hrh> |
|
38 #include <glxcollectionpluginalbums.hrh> |
|
39 #include <glxcollectionpluginmonths.hrh> |
|
40 #include <glxcollectionplugintags.hrh> |
|
41 #include <glxcollectionpluginimageviewer.hrh> |
|
42 #include <glxcollectionplugintype.hrh> |
|
43 #include <glxfiltergeneraldefs.h> |
|
44 #include <glxpanic.h> |
|
45 #include <glxuistd.h> |
|
46 #include <glxviewpluginuids.hrh> |
|
47 #include <glxlog.h> |
|
48 #include <glxuiutility.h> |
|
49 #include <glxsettingsmodel.h> |
|
50 #include <glxupnprenderer.h> |
|
51 #include <glxcommandhandlers.hrh> |
|
52 #include <glxzoomstatepublisher.h> |
|
53 #include <glxnavigationalstate.h> |
|
54 #include <glxnavigationalstatedefs.h> |
|
55 #include <glxfullscreenviewplugin.hrh> |
|
56 #include <glx.rsg> |
|
57 #include <AknGlobalNote.h> |
|
58 #include <hal.h> |
|
59 #include <hal_data.h> |
|
60 #include <oommonitorsession.h> |
|
61 #include <glxtracer.h> |
|
62 #include "glxcachemanager.h"//OOM |
|
63 //OOM |
|
64 |
|
65 #include <oommonitorplugin.h> |
|
66 #include <oommonitorsession.h> |
|
67 |
|
68 //OOM |
|
69 |
|
70 |
|
71 #include <glxbackservicewrapper.h> |
|
72 |
|
73 |
|
74 #include <glxuistd.h> |
|
75 #include <apgcli.h> |
|
76 #include "glxiadupdate.h" |
|
77 |
|
78 //constants |
|
79 const TInt KGlxGridThumbnailPages = 9 ; // 4 page Down + 4 page Up + 1 Visible page = 9 page |
|
80 const TInt KGlxFullThumbnailCount = 11 ; // 5 Thumnail Front + 5 Thumbnail Rear + 1 Visible = 11 page |
|
81 const TInt KGlxMaxMegaPixelsSupportedByCamera = 5242880 ; // 5 MB |
|
82 const TInt KGlxMaxMemoryToDecodeCapturedPicture = 2 * KGlxMaxMegaPixelsSupportedByCamera ; |
|
83 const TInt KGlxMemoryForOOMFwk = 1048576 ; // 1 MB |
|
84 const TInt KGlxThumbNailRepresentation = 2; // Thumbnail Representation; Could be 3 also |
|
85 |
|
86 _LIT8( KPhotosSuiteNavigation, "SuiteNavigation" ); |
|
87 _LIT8( KPhotosCaptured, "Captured" ); |
|
88 _LIT8( KPhotosMonths, "Months" ); |
|
89 _LIT8( KPhotosTags, "Tags" ); |
|
90 _LIT8( KPhotosAlbums, "Albums" ); |
|
91 _LIT8( KPhotosAllValue,"Allcs"); |
|
92 |
|
93 _LIT8( KPhotosSuiteExitMessage, "mm://photossuite?action=exit" ); |
|
94 |
|
95 // Matrix uid, needed for activating the suite view. |
|
96 const TInt KMatrixUid = 0x101F4CD2; |
|
97 const TInt KCapturedAlbumId = 2 ; |
|
98 |
|
99 // ----------------------------------------------------------------------------- |
|
100 // Constructor |
|
101 // ----------------------------------------------------------------------------- |
|
102 // |
|
103 CGlxAppUi::CGlxAppUi() |
|
104 { |
|
105 } |
|
106 |
|
107 // ----------------------------------------------------------------------------- |
|
108 // ConstructL is called by the application framework |
|
109 // ----------------------------------------------------------------------------- |
|
110 // |
|
111 void CGlxAppUi::ConstructL() |
|
112 { |
|
113 TRACER("void CGlxAppUi::ConstructL()"); |
|
114 |
|
115 // Enable Avkon skins. |
|
116 BaseConstructL( EAknEnableSkin | EAknEnableMSK | EAknSingleClickCompatible ); |
|
117 // Create navigational state |
|
118 iNavigationalState = CGlxNavigationalState::InstanceL(); |
|
119 |
|
120 iNavigationalState->AddObserverL( *this ); |
|
121 |
|
122 // Create Back Stepping Service wrapper |
|
123 iBSWrapper = CGlxBackServiceWrapper::NewL( TUid::Uid( KGlxGalleryApplicationUid ) ); |
|
124 iNavigationalState->SetBackExitStatus(EFalse); |
|
125 |
|
126 iFocusLostLowMemory = EFalse; |
|
127 |
|
128 // Get an instance of view utility |
|
129 iViewUtility = MMPXViewUtility::UtilityL(); |
|
130 |
|
131 iUiUtility = CGlxUiUtility::UtilityL(); |
|
132 // Always start in default orientation |
|
133 iUiUtility->SetAppOrientationL(EGlxOrientationDefault); |
|
134 ReserveMemoryL(EEntryTypeStartUp); |
|
135 // publish zoom context, no zoom keys for now |
|
136 NGlxZoomStatePublisher::PublishStateL( EFalse ); |
|
137 iEndKeyPressed = EFalse; |
|
138 } |
|
139 |
|
140 // ----------------------------------------------------------------------------- |
|
141 // Destructor |
|
142 // ----------------------------------------------------------------------------- |
|
143 // |
|
144 CGlxAppUi::~CGlxAppUi() |
|
145 { |
|
146 TRACER("CGlxAppUi::~CGlxAppUi()"); |
|
147 iEndKeyPressed = EFalse; |
|
148 if ( iNavigationalState ) |
|
149 { |
|
150 iNavigationalState->RemoveObserver(*this); |
|
151 iNavigationalState->Close(); |
|
152 } |
|
153 |
|
154 if ( iViewUtility ) |
|
155 { |
|
156 iViewUtility->Close(); |
|
157 } |
|
158 |
|
159 delete iActivationParam; |
|
160 |
|
161 if ( iUiUtility ) |
|
162 { |
|
163 iUiUtility->Close(); |
|
164 } |
|
165 |
|
166 if( iBSWrapper ) |
|
167 { |
|
168 delete iBSWrapper; |
|
169 } |
|
170 |
|
171 if( iIadUpdate ) |
|
172 { |
|
173 delete iIadUpdate; |
|
174 } |
|
175 } |
|
176 |
|
177 // ----------------------------------------------------------------------------- |
|
178 // HandleCommandL |
|
179 // ----------------------------------------------------------------------------- |
|
180 // |
|
181 void CGlxAppUi::HandleCommandL(TInt aCommand) |
|
182 { |
|
183 TRACER("void CGlxAppUi::HandleCommandL(TInt aCommand)"); |
|
184 GLX_LOG_INFO1("PHOTOS LOGS: void CGlxAppUi::HandleCommandL(TInt aCommand = %d)",aCommand ); |
|
185 switch(aCommand) |
|
186 { |
|
187 case EEikCmdExit: |
|
188 { |
|
189 // Send message to Menu and exit. |
|
190 /** |
|
191 * In case of exit is pressed from options menu of photos grid, this flag will be |
|
192 * false. so it will launch matrix menu. If we don't call LaunchMmViewL, in the above |
|
193 * scenario, photos will exit,but photosuite will come. This is misleading to user. |
|
194 */ |
|
195 if(!iEndKeyPressed) |
|
196 { |
|
197 LaunchMmViewL( KPhotosSuiteExitMessage ); |
|
198 } |
|
199 Exit(); |
|
200 } |
|
201 break; |
|
202 case EAknSoftkeyExit: |
|
203 { |
|
204 ClosePhotosL(); |
|
205 GLX_LOG_INFO("CGlxAppUi::HandleCommandL: Exit() being Called"); |
|
206 Exit(); |
|
207 } |
|
208 break; |
|
209 |
|
210 case EAknSoftkeyBack: |
|
211 iNavigationalState->ActivatePreviousViewL(); |
|
212 break; |
|
213 |
|
214 default: |
|
215 break; |
|
216 } |
|
217 } |
|
218 |
|
219 // --------------------------------------------------------------------------- |
|
220 // HandleMessageL |
|
221 // --------------------------------------------------------------------------- |
|
222 // |
|
223 MCoeMessageObserver::TMessageResponse CGlxAppUi::HandleMessageL( |
|
224 TUint32 /*aClientHandleOfTargetWindowGroup*/, |
|
225 TUid aMessageUid, const TDesC8& aMessageParameters) |
|
226 { |
|
227 TRACER("MCoeMessageObserver::TMessageResponse CGlxAppUi::HandleMessageL(TUint32 aClientHandleOfTargetWindowGroup,TUid aMessageUid, const TDesC8& aMessageParameters)"); |
|
228 |
|
229 // TO DO: Check if gallery is in background |
|
230 MCoeMessageObserver::TMessageResponse |
|
231 response = MCoeMessageObserver::EMessageHandled; |
|
232 |
|
233 |
|
234 switch ( aMessageUid.iUid ) |
|
235 { |
|
236 case KGlxActivationCmdShowLastModified: |
|
237 case KGlxActivationCameraAlbum: |
|
238 HandleActivationMessageL(aMessageParameters); |
|
239 break; |
|
240 |
|
241 case KGlxActivationPhotosMenu: |
|
242 case KGlxActivationCameraView: |
|
243 case KGlxActivationMonthsView: |
|
244 case KGlxActivationAlbumsView: |
|
245 case KGlxActivationTagsView: |
|
246 case KGlxActivationAllView: |
|
247 { |
|
248 TApaTaskList taskList( iCoeEnv->WsSession() ); |
|
249 TApaTask task = taskList.FindApp( TUid::Uid( KGlxGalleryApplicationUid ) ); |
|
250 TApaTask taskForeGround = taskList.FindByPos(0); // get fopreground app |
|
251 if ( task.Exists() && task.ThreadId() != taskForeGround.ThreadId() ) |
|
252 { |
|
253 // No matter which collection is selected, |
|
254 // Photos is running in background, bring to foreground |
|
255 iEikonEnv->RootWin().SetOrdinalPosition(0); |
|
256 } |
|
257 } |
|
258 break; |
|
259 default: |
|
260 //To prevent Continues Activation of the Same View; Same is Triggered in ProcessCommandParametersL |
|
261 HandleActivationMessageL(aMessageParameters); |
|
262 break; |
|
263 } |
|
264 return response; |
|
265 } |
|
266 |
|
267 // --------------------------------------------------------------------------- |
|
268 // ProcessCommandParametersL |
|
269 // --------------------------------------------------------------------------- |
|
270 // |
|
271 TBool CGlxAppUi::ProcessCommandParametersL(TApaCommand aCommand, |
|
272 TFileName& aDocumentName, const TDesC8& aTail) |
|
273 { |
|
274 TRACER("TBool CGlxAppUi::ProcessCommandParametersL(TApaCommand aCommand, TFileName& aDocumentName, const TDesC8& aTail)"); |
|
275 |
|
276 TRAPD(err, HandleActivationMessageL(aCommand, aDocumentName, aTail)); |
|
277 if ( KErrNone != err ) |
|
278 { |
|
279 // Open collection for main view |
|
280 iStartupViewUid = TUid::Null(); |
|
281 // Open navigational state at root level |
|
282 CMPXCollectionPath* newState = CMPXCollectionPath::NewL(); |
|
283 CleanupStack::PushL( newState ); |
|
284 iNavigationalState->NavigateToL( *newState ); |
|
285 CleanupStack::PopAndDestroy( newState ); |
|
286 } |
|
287 |
|
288 return (EApaCommandOpen == aCommand) && (0 != aDocumentName.Size()); |
|
289 } |
|
290 |
|
291 // --------------------------------------------------------------------------- |
|
292 // Handle navigational state change |
|
293 // --------------------------------------------------------------------------- |
|
294 // |
|
295 void CGlxAppUi::HandleNavigationalStateChangedL() |
|
296 { |
|
297 TRACER("void CGlxAppUi::HandleNavigationalStateChangedL()"); |
|
298 |
|
299 /* |
|
300 * This thread chk is added for EDDG-7UUC53. In this scenario we get EPathChanged from MPX. |
|
301 * That initiates a viewnavigational change from CGlxNavigationalStateImp HandleCollectionMessageL() |
|
302 * In these types of scenarios we don't want a view switch. So ignoring the event. |
|
303 */ |
|
304 TApaTaskList taskList( iCoeEnv->WsSession() ); |
|
305 TApaTask task = taskList.FindApp( TUid::Uid( KGlxGalleryApplicationUid ) ); |
|
306 TApaTask taskForeGround = taskList.FindByPos(0); // get fopreground app |
|
307 if ( task.Exists() && task.ThreadId() != taskForeGround.ThreadId() ) |
|
308 { |
|
309 GLX_LOG_INFO("CGlxAppUi::HandleNavigationalStateChanged: Return "); |
|
310 return; |
|
311 } |
|
312 HBufC* activationParam = iActivationParam; |
|
313 iActivationParam = NULL; // release ownership |
|
314 CleanupStack::PushL( activationParam ); |
|
315 |
|
316 if ( TUid::Null() != iStartupViewUid ) |
|
317 { |
|
318 GLX_LOG_INFO("CGlxAppUi::HandleNavigationalStateChanged: Activating startup view"); |
|
319 // Activate startup view |
|
320 iViewUtility->ActivateViewL( iStartupViewUid, activationParam ); |
|
321 iStartupViewUid = TUid::Null(); |
|
322 } |
|
323 else |
|
324 { |
|
325 GLX_LOG_INFO("CGlxAppUi::HandleNavigationalStateChanged: Activating view"); |
|
326 |
|
327 // get ids for scoring a view |
|
328 RArray< TUid > scoringIds; |
|
329 CleanupClosePushL( scoringIds ); |
|
330 GetViewScoringIdsL( scoringIds ); |
|
331 |
|
332 GLX_LOG_INFO1( "CGlxAppUi::HandleNavigationalStateChanged: Uid count %d", scoringIds.Count()); |
|
333 // let view utility to select the best view based on scoring ids |
|
334 iViewUtility->ActivateViewL( scoringIds, activationParam ); |
|
335 |
|
336 CleanupStack::PopAndDestroy( &scoringIds ); |
|
337 } |
|
338 |
|
339 CleanupStack::PopAndDestroy( activationParam ); |
|
340 } |
|
341 |
|
342 // --------------------------------------------------------------------------- |
|
343 // Populate array with view scoring ids |
|
344 // --------------------------------------------------------------------------- |
|
345 // |
|
346 void CGlxAppUi::GetViewScoringIdsL( RArray<TUid>& aIds ) const |
|
347 { |
|
348 TRACER("void CGlxAppUi::GetViewScoringIdsL( RArray<TUid>& aIds ) const"); |
|
349 |
|
350 aIds.Reset(); // For maintenance safety |
|
351 |
|
352 // get current navigational state |
|
353 CMPXCollectionPath* naviState = iNavigationalState->StateLC(); |
|
354 |
|
355 // no if check in needed here ,it makes the aapui aware of the list view depth |
|
356 // to be removed.added by gopa |
|
357 if ( naviState->Levels() >= 1) |
|
358 { |
|
359 if (iNavigationalState->ViewingMode() == NGlxNavigationalState::EBrowse) |
|
360 { |
|
361 // For image viewer collection, goto view mode |
|
362 if (naviState->Id() == TMPXItemId(KGlxCollectionPluginImageViewerImplementationUid)) |
|
363 { |
|
364 aIds.AppendL( TUid::Uid( KGlxViewingModeView ) ); |
|
365 } |
|
366 else |
|
367 { |
|
368 aIds.AppendL( TUid::Uid( KGlxViewingModeBrowse ) ); |
|
369 } |
|
370 } |
|
371 else |
|
372 { |
|
373 aIds.AppendL( TUid::Uid( KGlxViewingModeView ) ); |
|
374 } |
|
375 } |
|
376 |
|
377 if( TUid::Null() != GetViewScoringIdForCollectionPlugin( *naviState ) ) |
|
378 { |
|
379 // add scoring id for collection plugin |
|
380 aIds.AppendL( GetViewScoringIdForCollectionPlugin( *naviState ) ); |
|
381 } |
|
382 |
|
383 if( TUid::Null() != ViewScoringIdForNaviStateDepth( *naviState ) ) |
|
384 { |
|
385 // add scoring id for depth in the ui hierarchy |
|
386 aIds.AppendL( ViewScoringIdForNaviStateDepth( *naviState ) ); |
|
387 } |
|
388 |
|
389 CleanupStack::PopAndDestroy( naviState ); |
|
390 } |
|
391 // --------------------------------------------------------------------------- |
|
392 // Handles the foreground events |
|
393 // --------------------------------------------------------------------------- |
|
394 // |
|
395 void CGlxAppUi::HandleForegroundEventL( TBool aForeground ) |
|
396 { |
|
397 TRACER("void CGlxAppUi::HandleForegroundEventL( TBool aForeground )"); |
|
398 |
|
399 // first let base class handle it so that we dont break anything |
|
400 CAknViewAppUi::HandleForegroundEventL( aForeground ); |
|
401 |
|
402 } |
|
403 // --------------------------------------------------------------------------- |
|
404 // Return scoring id for collection plugin |
|
405 // --------------------------------------------------------------------------- |
|
406 // |
|
407 TUid CGlxAppUi::GetViewScoringIdForCollectionPlugin( const CMPXCollectionPath& aNaviState ) const |
|
408 { |
|
409 TRACER("TUid CGlxAppUi::GetViewScoringIdForCollectionPluginL( const CMPXCollectionPath& aNaviState ) const"); |
|
410 |
|
411 GLX_LOG_INFO1( "CGlxAppUi::GetViewScoringIdForCollectionPluginL: Depth %d", aNaviState.Levels() ); |
|
412 // score view based on collection plugin if not on root level |
|
413 if ( aNaviState.Levels() ) |
|
414 { |
|
415 return TUid::Uid( aNaviState.Id( 0 ) ); |
|
416 } |
|
417 // return null as id to be ignored in scoring |
|
418 return TUid::Null(); |
|
419 } |
|
420 |
|
421 |
|
422 // --------------------------------------------------------------------------- |
|
423 // Return scoring id for depth |
|
424 // --------------------------------------------------------------------------- |
|
425 // |
|
426 TUid CGlxAppUi::ViewScoringIdForNaviStateDepth( const CMPXCollectionPath& aNaviState ) const |
|
427 { |
|
428 TRACER("TUid CGlxAppUi::ViewScoringIdForNaviStateDepthL( const CMPXCollectionPath& aNaviState ) const"); |
|
429 GLX_LOG_INFO1( "CGlxAppUi::ViewScoringIdForNaviStateDepthL: Level %d", aNaviState.Levels() ); |
|
430 |
|
431 switch ( aNaviState.Levels() ) |
|
432 { |
|
433 case 0: |
|
434 |
|
435 GLX_LOG_INFO1( "CGlxAppUi::ViewScoringIdForNaviStateDepthL: \ |
|
436 Depth case 0 %x", TUid::Uid( KGlxDepthOne ) ); |
|
437 return TUid::Uid( KGlxDepthOne ); |
|
438 |
|
439 case 1: |
|
440 |
|
441 GLX_LOG_INFO1( "CGlxAppUi::ViewScoringIdForNaviStateDepthL: \ |
|
442 Depth case 1 %x", TUid::Uid( KGlxDepthTwo ) ); |
|
443 return TUid::Uid( KGlxDepthTwo ); |
|
444 |
|
445 |
|
446 case 2: |
|
447 |
|
448 GLX_LOG_INFO1( "CGlxAppUi::GetViewScoringIdForUiHieararchyDepthL: \ |
|
449 Depth case 2 %x", TUid::Uid( KGlxDepthThree ) ); |
|
450 return TUid::Uid( KGlxDepthThree ); |
|
451 |
|
452 default: |
|
453 GLX_LOG_WARNING( "CGlxAppUi::GetViewScoringIdsL: Navigational state deeper than supported" ); |
|
454 // return null as an id to be ignored in scoring |
|
455 return TUid::Null(); |
|
456 } |
|
457 } |
|
458 |
|
459 // --------------------------------------------------------------------------- |
|
460 // HandleActivationMessageL |
|
461 // --------------------------------------------------------------------------- |
|
462 // |
|
463 void CGlxAppUi::HandleActivationMessageL(const TApaCommand& aCommand, |
|
464 const TFileName& aDocumentName, const TDesC8& aData) |
|
465 { |
|
466 TRACER("void CGlxAppUi::HandleActivationMessageL(const TApaCommand& aCommand, const TFileName& aDocumentName, const TDesC8& aData)"); |
|
467 |
|
468 delete iActivationParam; |
|
469 iActivationParam = NULL; |
|
470 |
|
471 //Check for the IADUpdate |
|
472 //TBD: Need to check the location this has to be called. |
|
473 //This might not be proper place. |
|
474 DoCheckForIADUpdatesL(); |
|
475 |
|
476 if ( aDocumentName.Length() > 0 && EApaCommandOpen == aCommand ) |
|
477 { |
|
478 CMPXCollectionPath* path = CMPXCollectionPath::NewL(); |
|
479 CleanupStack::PushL(path); |
|
480 iNavigationalState->SetBackExitStatus( EFalse ); |
|
481 path->AppendL( KGlxCollectionPluginImageViewerImplementationUid ); |
|
482 iNavigationalState->NavigateToL( *path ); |
|
483 CleanupStack::PopAndDestroy( path ); |
|
484 } |
|
485 else |
|
486 { |
|
487 HandleActivationMessageL( aData ); |
|
488 } |
|
489 |
|
490 // Introduced to fix bug EMJN-78GH6N. Rowland Cook 10/12/2007 |
|
491 if (0 != iEikonEnv->RootWin().OrdinalPosition()) |
|
492 { |
|
493 iEikonEnv->RootWin().SetOrdinalPosition(0); |
|
494 } |
|
495 } |
|
496 |
|
497 // --------------------------------------------------------------------------- |
|
498 // HandleActivationMessageL |
|
499 // --------------------------------------------------------------------------- |
|
500 // |
|
501 void CGlxAppUi::HandleActivationMessageL(const TDesC8& aData) |
|
502 { |
|
503 TRACER("void CGlxAppUi::HandleActivationMessageL(const TDesC8& aData)"); |
|
504 |
|
505 CMPXCollectionPath* path = CMPXCollectionPath::NewL(); |
|
506 CleanupStack::PushL(path); |
|
507 |
|
508 delete iActivationParam; |
|
509 iActivationParam = NULL; |
|
510 |
|
511 TUid msgUid; |
|
512 RDesReadStream stream(aData); |
|
513 CleanupClosePushL(stream); |
|
514 stream >> msgUid; |
|
515 |
|
516 //Check for the IADUpdate |
|
517 //TBD: Need to check the location this has to be called. |
|
518 //This might not be proper place. |
|
519 DoCheckForIADUpdatesL(); |
|
520 |
|
521 switch ( msgUid.iUid ) |
|
522 { |
|
523 case KGlxActivationCmdShowLastModified: |
|
524 // Go to camera album full screen view |
|
525 GLX_LOG_INFO("CGlxAppUi::HandleActivationMessageL: show last modified"); |
|
526 // Send the command to reset the view |
|
527 ProcessCommandL(EGlxCmdResetView); |
|
528 // Not using KGlxCollectionPluginCameraImplementationUid |
|
529 path->AppendL(KGlxCollectionPluginAlbumsImplementationUid); |
|
530 path->AppendL(KCapturedAlbumId); |
|
531 SetActivationParamL(KGlxActivationFullScreen); |
|
532 break; |
|
533 |
|
534 case KGlxActivationCameraAlbum: |
|
535 // Go to camera album tile view |
|
536 GLX_LOG_INFO("CGlxAppUi::HandleActivationMessageL: camera album"); |
|
537 path->AppendL(KGlxCollectionPluginAlbumsImplementationUid); |
|
538 path->AppendL(KCapturedAlbumId); |
|
539 break; |
|
540 |
|
541 case KGlxActivationPhotosMenu: |
|
542 // Open the main view |
|
543 GLX_LOG_INFO("CGlxAppUi::HandleActivationMessageL: photos menu"); |
|
544 break; |
|
545 |
|
546 default: |
|
547 GLX_LOG_INFO("CGlxAppUi::HandleActivationMessageL: unknown command"); |
|
548 |
|
549 |
|
550 if(0 == aData.CompareC(KPhotosCaptured)) |
|
551 { |
|
552 iNavigationalState->SetBackExitStatus(ETrue); |
|
553 path->AppendL(KGlxCollectionPluginAlbumsImplementationUid); |
|
554 path->AppendL(KCapturedAlbumId); |
|
555 } |
|
556 else if(0 == aData.CompareC(KPhotosAllValue)) |
|
557 { |
|
558 iNavigationalState->SetBackExitStatus(ETrue); |
|
559 path->AppendL(KGlxCollectionPluginAllImplementationUid); |
|
560 } |
|
561 else if(0 == aData.CompareC(KPhotosMonths)) |
|
562 { |
|
563 iNavigationalState->SetBackExitStatus(ETrue); |
|
564 path->AppendL(KGlxCollectionPluginMonthsImplementationUid); |
|
565 } |
|
566 else if(0 == aData.CompareC(KPhotosAlbums)) |
|
567 { |
|
568 iNavigationalState->SetBackExitStatus(ETrue); |
|
569 path->AppendL(KGlxCollectionPluginAlbumsImplementationUid); |
|
570 } |
|
571 else if(0 == aData.CompareC(KPhotosTags)) |
|
572 { |
|
573 iNavigationalState->SetBackExitStatus(ETrue); |
|
574 path->AppendL(KGlxTagCollectionPluginImplementationUid); |
|
575 } |
|
576 else |
|
577 { |
|
578 User::Leave(KErrNotSupported); |
|
579 } |
|
580 TBuf8<15> buf; |
|
581 buf.Append( KPhotosSuiteNavigation ); |
|
582 TRAP_IGNORE(iBSWrapper->ForwardActivationEventL( buf, ETrue )) |
|
583 |
|
584 break; |
|
585 } |
|
586 CleanupStack::PopAndDestroy(&stream); |
|
587 iNavigationalState->NavigateToL( *path ); |
|
588 CleanupStack::PopAndDestroy(path); |
|
589 |
|
590 // Introduced to fix bug EMJN-78GH6N. Rowland Cook 10/12/2007 |
|
591 if (0 != iEikonEnv->RootWin().OrdinalPosition()) |
|
592 { |
|
593 iEikonEnv->RootWin().SetOrdinalPosition(0); |
|
594 } |
|
595 } |
|
596 |
|
597 // --------------------------------------------------------------------------- |
|
598 // SetActivationParamL |
|
599 // --------------------------------------------------------------------------- |
|
600 // |
|
601 void CGlxAppUi::SetActivationParamL(const TDesC8& aParam) |
|
602 { |
|
603 TRACER("void CGlxAppUi::SetActivationParamL(const TDesC8& aParam)"); |
|
604 iActivationParam = HBufC::NewL(aParam.Length()); |
|
605 iActivationParam->Des().Copy(aParam); |
|
606 } |
|
607 |
|
608 // --------------------------------------------------------------------------- |
|
609 // RequestFreeMemory |
|
610 // --------------------------------------------------------------------------- |
|
611 // |
|
612 TInt CGlxAppUi::OOMRequestFreeMemoryL( TInt aBytesRequested) |
|
613 { |
|
614 TRACER("TInt CGlxAppUi::OOMRequestFreeMemoryL( TInt aBytesRequested)"); |
|
615 GLX_LOG_INFO1("CGlxAppUi::OOMRequestFreeMemoryL() aBytesRequested=%d", |
|
616 aBytesRequested); |
|
617 |
|
618 ROomMonitorSession oomMonitor; |
|
619 User::LeaveIfError( oomMonitor.Connect() ); |
|
620 // No leaving code after this point, so no need to use cleanup stack |
|
621 // for oomMonitor |
|
622 TInt errorCode = oomMonitor.RequestFreeMemory( aBytesRequested ); |
|
623 GLX_LOG_INFO1("CGlxAppUi::OOMRequestFreeMemoryL(1) errorCode=%d",errorCode); |
|
624 if ( errorCode != KErrNone ) |
|
625 { |
|
626 // try one more time |
|
627 errorCode = oomMonitor.RequestFreeMemory( aBytesRequested ); |
|
628 GLX_LOG_INFO1("CGlxAppUi::OOMRequestFreeMemoryL(2) errorCode=%d",errorCode); |
|
629 } |
|
630 oomMonitor.Close(); |
|
631 return errorCode; |
|
632 } |
|
633 |
|
634 |
|
635 // --------------------------------------------------------------------------- |
|
636 // ReserveMemory |
|
637 // --------------------------------------------------------------------------- |
|
638 // |
|
639 TInt CGlxAppUi::ReserveMemoryL(TInt aCriticalMemoryRequired) |
|
640 { |
|
641 TRACER("void CGlxAppUi::ReserveMemory(TInt aCriticalMemoryRequired)"); |
|
642 |
|
643 TInt memoryLeft = 0; |
|
644 TInt error = KErrNone ; |
|
645 HAL::Get( HALData::EMemoryRAMFree, memoryLeft ); |
|
646 GLX_LOG_INFO2("CGlxAppUi::ReserveMemoryL() - aCriticalMemoryRequired=%d, memoryLeft=%d", |
|
647 aCriticalMemoryRequired, memoryLeft); |
|
648 if ( aCriticalMemoryRequired > memoryLeft ) |
|
649 { |
|
650 // Request for critical memory required |
|
651 error = OOMRequestFreeMemoryL( aCriticalMemoryRequired); |
|
652 GLX_LOG_INFO1("CGlxAppUi::ReserveMemoryL() - OOMRequestFreeMemoryL() error=%d", error); |
|
653 } |
|
654 return error; |
|
655 } |
|
656 |
|
657 // --------------------------------------------------------------------------- |
|
658 // CriticalRamMemory |
|
659 // --------------------------------------------------------------------------- |
|
660 // |
|
661 TInt CGlxAppUi::RamRequiredInBytesL(TEntryType aType) |
|
662 { |
|
663 TRACER("TInt CGlxAppUi::RamRequiredInBytesL(TEntryType aType)"); |
|
664 TSize gridIconSize = iUiUtility->GetGridIconSize(); |
|
665 TInt criticalRamMemory = 0 ; |
|
666 TSize displaySize = iUiUtility->DisplaySize(); |
|
667 TInt itemsInPage = iUiUtility->VisibleItemsInPageGranularityL(); |
|
668 if(EEntryTypeStartUp == aType) |
|
669 { |
|
670 // This is Bare Minimum Required Memory for Photos to start |
|
671 // For Framework to work and to do the on-the-fly decoding |
|
672 // for the just captured picture = KGlxMemoryForOOMFwk + KGlxMaxMemoryToDecodeCapturedPicture |
|
673 // For Grid Number of pages * Thumbnail width * Thumbnail Height * KGlxThumbNailRepresentation * |
|
674 // Number of images in a page + |
|
675 // For FullScreen to Work Number of Thumbnails * Width * Height * Representation |
|
676 criticalRamMemory = KGlxMemoryForOOMFwk + KGlxMaxMemoryToDecodeCapturedPicture + |
|
677 (KGlxFullThumbnailCount * |
|
678 displaySize.iWidth * displaySize.iHeight * |
|
679 KGlxThumbNailRepresentation ) + |
|
680 (KGlxGridThumbnailPages * |
|
681 itemsInPage * gridIconSize.iWidth * |
|
682 gridIconSize.iHeight * |
|
683 KGlxThumbNailRepresentation); |
|
684 |
|
685 GLX_LOG_INFO1("CGlxAppUi::RamRequiredInBytesL(EEntryTypeStartUp): criticalRamMemory=%d", |
|
686 criticalRamMemory); |
|
687 } |
|
688 else |
|
689 { |
|
690 GLX_LOG_INFO("CGlxAppUi::RamRequiredInBytesL(): Photos Already Running"); |
|
691 } |
|
692 |
|
693 return criticalRamMemory; |
|
694 } |
|
695 |
|
696 // --------------------------------------------------------------------------- |
|
697 // ReserveMemoryL |
|
698 // --------------------------------------------------------------------------- |
|
699 // |
|
700 void CGlxAppUi::ReserveMemoryL(TEntryType aType) |
|
701 { |
|
702 TRACER("TInt CGlxAppUi::ReserveMemoryL(TEntryType aType)"); |
|
703 |
|
704 TInt error = ReserveMemoryL(RamRequiredInBytesL(aType)); |
|
705 GLX_LOG_INFO1("CGlxAppUi::ReserveMemoryL() error=%d", error); |
|
706 |
|
707 if (KErrNoMemory == error) |
|
708 { |
|
709 GLX_LOG_INFO("CGlxAppUi::ReserveMemoryL(): LEAVE with KErrNoMemory "); |
|
710 User::Leave(KErrNoMemory); |
|
711 } |
|
712 } |
|
713 |
|
714 //OOM |
|
715 |
|
716 // --------------------------------------------------------------------------- |
|
717 // HandleApplicationSpecificEventL |
|
718 // Handle OOM events. |
|
719 // --------------------------------------------------------------------------- |
|
720 // |
|
721 |
|
722 void CGlxAppUi::HandleApplicationSpecificEventL(TInt aEventType, const TWsEvent& aWsEvent) |
|
723 { |
|
724 TRACER("CGlxAppUi::HandleApplicationSpecificEventL"); |
|
725 CAknViewAppUi::HandleApplicationSpecificEventL(aEventType,aWsEvent); |
|
726 if(aWsEvent.Type() == KAknUidValueEndKeyCloseEvent) |
|
727 { |
|
728 /** |
|
729 * Making the flag etrue ensures that it will not call LaunchMmViewL in handlecommandl while |
|
730 * red key is pressed. Otherwise it will launch matrix menu, not idle screen. |
|
731 */ |
|
732 iEndKeyPressed = ETrue; |
|
733 ClosePhotosL(); |
|
734 } |
|
735 switch(aEventType) |
|
736 { |
|
737 case KAppOomMonitor_FreeRam: |
|
738 { |
|
739 StartCleanupL(); |
|
740 } |
|
741 break; |
|
742 case KAppOomMonitor_MemoryGood: |
|
743 { |
|
744 StopCleanupL(); |
|
745 } |
|
746 break; |
|
747 default: |
|
748 break; |
|
749 } |
|
750 } |
|
751 |
|
752 // --------------------------------------------------------------------------- |
|
753 // StartCleanup |
|
754 // Initiate cleanup from cache manager on low memory event |
|
755 // --------------------------------------------------------------------------- |
|
756 // |
|
757 void CGlxAppUi::StartCleanupL() |
|
758 { |
|
759 MGlxCache* cacheManager = MGlxCache::InstanceL(); |
|
760 cacheManager->ReleaseRAML(); |
|
761 cacheManager->Close(); |
|
762 } |
|
763 |
|
764 // --------------------------------------------------------------------------- |
|
765 // StopCleanup |
|
766 // Cancel cache cleanup on memory good event |
|
767 // --------------------------------------------------------------------------- |
|
768 // |
|
769 void CGlxAppUi::StopCleanupL() |
|
770 { |
|
771 MGlxCache* cacheManager = MGlxCache::InstanceL(); |
|
772 cacheManager->StopRAMReleaseL(); |
|
773 cacheManager->Close(); |
|
774 } |
|
775 |
|
776 // --------------------------------------------------------------------------- |
|
777 // CCGlxNsAppUi::DoCheckForIADUpdatesL() |
|
778 // Check for updates via IAD |
|
779 // --------------------------------------------------------------------------- |
|
780 // |
|
781 void CGlxAppUi::DoCheckForIADUpdatesL() |
|
782 { |
|
783 TRACER("CGlxNsAppUi::CheckForUpdatesL()"); |
|
784 |
|
785 if ( !iIadUpdate ) |
|
786 { |
|
787 iIadUpdate = CGlxIadUpdate::NewL(); |
|
788 } |
|
789 iIadUpdate->StartL(); |
|
790 } |
|
791 |
|
792 // --------------------------------------------------------------------------- |
|
793 // LaunchMmViewL |
|
794 // |
|
795 // --------------------------------------------------------------------------- |
|
796 // |
|
797 void CGlxAppUi::LaunchMmViewL( const TDesC8& aMessage ) |
|
798 { |
|
799 TRACER("CGlxNsAppUi::LaunchMmViewL()"); |
|
800 TApaTaskList taskList( iCoeEnv->WsSession() ); |
|
801 TApaTask task = taskList.FindApp( TUid::Uid( KMatrixUid ) ); |
|
802 |
|
803 if ( task.Exists() ) |
|
804 { |
|
805 task.SendMessage( TUid::Uid( KUidApaMessageSwitchOpenFileValue ),aMessage ); |
|
806 } |
|
807 else |
|
808 { // app not yet running |
|
809 RApaLsSession appArcSession; |
|
810 CleanupClosePushL( appArcSession ); |
|
811 User::LeaveIfError( appArcSession.Connect() ); |
|
812 TApaAppInfo appInfo; |
|
813 TInt err = appArcSession.GetAppInfo( appInfo, |
|
814 TUid::Uid( KMatrixUid ) ); |
|
815 if( err == KErrNone ) |
|
816 { |
|
817 CApaCommandLine* cmdLine = CApaCommandLine::NewLC(); |
|
818 cmdLine->SetExecutableNameL( appInfo.iFullName ); |
|
819 cmdLine->SetCommandL( EApaCommandRun ); |
|
820 cmdLine->SetTailEndL( aMessage ); |
|
821 appArcSession.StartApp( *cmdLine ); |
|
822 CleanupStack::PopAndDestroy( cmdLine ); |
|
823 } |
|
824 CleanupStack::PopAndDestroy( &appArcSession ); |
|
825 } |
|
826 } |
|
827 |
|
828 // ----------------------------------------------------------------------------- |
|
829 // ClosePhotosL |
|
830 // ----------------------------------------------------------------------------- |
|
831 // |
|
832 void CGlxAppUi::ClosePhotosL() |
|
833 { |
|
834 TRACER("CGlxNsAppUi::ClosePhotosL()"); |
|
835 iUiUtility->SetViewNavigationDirection(EGlxNavigationBackwards); |
|
836 //Temparory fix provided for Kern Exec 3 bug |
|
837 //UPnP Stop Showin is explicitly called when exiting the gallery |
|
838 GlxUpnpRenderer:: StopShowingL(); |
|
839 |
|
840 iUiUtility->SetExitingState(ETrue); |
|
841 GLX_LOG_INFO("CGlxAppUi::HandleWsEventL: Exit() for C key being Called"); |
|
842 |
|
843 } |
|
844 //OOM |