9 * Initial Contributors: |
9 * Initial Contributors: |
10 * Nokia Corporation - initial contribution. |
10 * Nokia Corporation - initial contribution. |
11 * |
11 * |
12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description: AppUi class |
14 * Description: Image Viewer AppUi class |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 |
18 |
19 |
19 |
20 |
20 |
21 #include "glxivwrappui.h" |
21 #include "glxivwrappui.h" |
22 |
22 #include "glxivwrdocument.h" |
23 #include <avkon.hrh> |
23 |
24 #include <StringLoader.h> |
24 #include <apgcli.h> |
25 #include <aknnotewrappers.h> |
25 #include <hal.h> |
26 #include <AknUtils.h> |
26 #include <oommonitorsession.h> |
27 #include <mpxviewutility.h> |
27 #include <mpxviewutility.h> |
28 #include <mpxcollectionutility.h> |
|
29 #include <mpxcollectionmessage.h> |
|
30 #include <mpxmessagegeneraldefs.h> |
|
31 #include <mpxcollectionpath.h> |
28 #include <mpxcollectionpath.h> |
32 |
29 |
33 #include <alf/alfenv.h> |
30 #include <glxmedialist.h> |
34 #include <akntoolbar.h> |
|
35 #include <glxgallery.hrh> |
|
36 |
|
37 #include <glxcollectionpluginimageviewer.hrh> |
31 #include <glxcollectionpluginimageviewer.hrh> |
38 #include <glxfiltergeneraldefs.h> |
|
39 #include <glxpanic.h> |
|
40 #include <glxuistd.h> |
|
41 #include <glxviewpluginuids.hrh> |
32 #include <glxviewpluginuids.hrh> |
42 #include <glxlog.h> |
|
43 #include <glxuiutility.h> |
33 #include <glxuiutility.h> |
44 #include <glxsettingsmodel.h> |
|
45 #include <glxcommandhandlers.hrh> |
|
46 #include <glxzoomstatepublisher.h> |
34 #include <glxzoomstatepublisher.h> |
47 #include <glxnavigationalstate.h> |
35 #include <glxnavigationalstate.h> |
48 #include <glxnavigationalstatedefs.h> |
36 #include <glxnavigationalstatedefs.h> |
49 #include <glxfullscreenviewplugin.hrh> |
37 #include <glxtracer.h> |
|
38 #include <glxlog.h> |
50 #include <glxivwr.rsg> |
39 #include <glxivwr.rsg> |
51 #include <AknGlobalNote.h> |
40 |
52 #include <hal.h> |
41 |
53 #include <hal_data.h> |
|
54 #include <oommonitorsession.h> |
|
55 #include <glxtracer.h> |
|
56 #include <glxuistd.h> |
|
57 #include <apgcli.h> |
|
58 |
42 |
59 //constants |
43 //constants |
60 const TInt KGlxFullThumbnailCount = 1 ; // 1 visible thumnail |
44 const TInt KGlxFullThumbnailCount = 1 ; // 1 visible thumnail |
61 #ifdef __MARM |
45 #ifdef __MARM |
62 const TInt KGlxMaxMegaPixelsSupportedByCamera = 5242880 ; // 5 MB |
46 const TInt KGlxMaxMegaPixelsSupportedByCamera = 5242880 ; // 5 MB |
187 TRACER("void CGlxIVwrAppUi::HandleNavigationalStateChangedL()"); |
178 TRACER("void CGlxIVwrAppUi::HandleNavigationalStateChangedL()"); |
188 // get current navigational state |
179 // get current navigational state |
189 CMPXCollectionPath* naviState = iNavigationalState->StateLC(); |
180 CMPXCollectionPath* naviState = iNavigationalState->StateLC(); |
190 |
181 |
191 // Case: Open photos in grid, go to filemanager via menu and open any image |
182 // Case: Open photos in grid, go to filemanager via menu and open any image |
192 if (naviState->Id() != TMPXItemId(KGlxCollectionPluginImageViewerImplementationUid)) |
183 if (naviState->Id() != TMPXItemId( |
|
184 KGlxCollectionPluginImageViewerImplementationUid)) |
193 { |
185 { |
194 /* |
186 /* |
195 * This thread chk is added for EDDG-7UUC53. In this scenario we get EPathChanged from MPX. |
187 * This thread chk is added for EDDG-7UUC53. In this scenario we get EPathChanged from MPX. |
196 * That initiates a viewnavigational change from CGlxNavigationalStateImp HandleCollectionMessageL() |
188 * That initiates a viewnavigational change from CGlxNavigationalStateImp HandleCollectionMessageL() |
197 * In these types of scenarios we don't want a view switch. So ignoring the event. |
189 * In these types of scenarios we don't want a view switch. So ignoring the event. |
198 */ |
190 */ |
199 TApaTaskList taskList( iCoeEnv->WsSession() ); |
191 TApaTaskList taskList(iCoeEnv->WsSession()); |
200 TApaTask task = taskList.FindApp( TUid::Uid( KGlxGalleryApplicationUid ) ); |
192 TApaTask task = taskList.FindApp(KUidGlxIvwrApp); |
201 TApaTask taskForeGround = taskList.FindByPos(0); // get fopreground app |
193 TApaTask taskForeGround = taskList.FindByPos(0); // get fopreground app |
202 if ( task.Exists() && task.ThreadId() != taskForeGround.ThreadId() ) |
194 if (task.Exists() && task.ThreadId() != taskForeGround.ThreadId()) |
203 { |
195 { |
204 GLX_LOG_INFO("CGlxIVwrAppUi ::HandleNavigationalStateChanged: Return "); |
196 GLX_LOG_INFO("CGlxIVwrAppUi ::HandleNavigationalStateChanged: Return "); |
205 return; |
197 return; |
206 } |
198 } |
207 } |
199 } |
208 |
200 |
209 CleanupStack::PopAndDestroy( naviState ); |
201 CleanupStack::PopAndDestroy(naviState); |
210 |
202 |
211 if ( TUid::Null() != iStartupViewUid ) |
203 if (TUid::Null() != iStartupViewUid) |
212 { |
204 { |
213 GLX_LOG_INFO("CGlxAppUi::HandleNavigationalStateChanged: Activating startup view"); |
205 GLX_LOG_INFO("CGlxIVwrAppUi::HandleNavigationalStateChanged:Activating startup view"); |
214 // Activate startup view |
206 // Activate startup view |
215 iViewUtility->ActivateViewL( iStartupViewUid, NULL ); |
207 iViewUtility->ActivateViewL(iStartupViewUid, NULL); |
216 iStartupViewUid = TUid::Null(); |
208 iStartupViewUid = TUid::Null(); |
217 } |
209 } |
218 else |
210 else |
219 { |
211 { |
220 GLX_LOG_INFO("CGlxAppUi::HandleNavigationalStateChanged: Activating view"); |
212 GLX_LOG_INFO("CGlxIVwrAppUi::HandleNavigationalStateChanged:Activating view"); |
221 |
213 |
222 // get ids for scoring a view |
214 // get ids for scoring a view |
223 RArray< TUid > scoringIds; |
215 RArray<TUid> scoringIds; |
224 CleanupClosePushL( scoringIds ); |
216 CleanupClosePushL(scoringIds); |
225 GetViewScoringIdsL( scoringIds ); |
217 GetViewScoringIdsL(scoringIds); |
226 |
218 |
227 GLX_LOG_INFO1( "CGlxIVwrAppUi::HandleNavigationalStateChanged: Uid count %d", scoringIds.Count()); |
219 GLX_LOG_INFO1("CGlxIVwrAppUi::HandleNavigationalStateChanged:Uid count %d", scoringIds.Count()); |
228 // let view utility to select the best view based on scoring ids |
220 // let view utility to select the best view based on scoring ids |
229 iViewUtility->ActivateViewL( scoringIds, NULL ); |
221 iViewUtility->ActivateViewL(scoringIds, NULL); |
230 |
222 |
231 CleanupStack::PopAndDestroy( &scoringIds ); |
223 CleanupStack::PopAndDestroy(&scoringIds); |
232 } |
224 } |
233 } |
225 } |
234 |
226 |
235 // --------------------------------------------------------------------------- |
227 // --------------------------------------------------------------------------- |
236 // Populate array with view scoring ids |
228 // Populate array with view scoring ids |
237 // --------------------------------------------------------------------------- |
229 // --------------------------------------------------------------------------- |
238 // |
230 // |
239 void CGlxIVwrAppUi::GetViewScoringIdsL( RArray<TUid>& aIds ) const |
231 void CGlxIVwrAppUi::GetViewScoringIdsL( RArray<TUid>& aIds ) const |
240 { |
232 { |
241 TRACER("void CGlxIVwrAppUi::GetViewScoringIdsL( RArray<TUid>& aIds ) const"); |
233 TRACER("void CGlxIVwrAppUi::GetViewScoringIdsL()"); |
242 CleanupClosePushL(aIds); |
234 CleanupClosePushL(aIds); |
243 aIds.Reset(); // For maintenance safety |
235 aIds.Reset(); // For maintenance safety |
244 |
236 |
245 // get current navigational state |
237 // get current navigational state |
246 CMPXCollectionPath* naviState = iNavigationalState->StateLC(); |
238 CMPXCollectionPath* naviState = iNavigationalState->StateLC(); |
247 |
239 |
248 // no if check in needed here ,it makes the aapui aware of the list view depth |
240 // no if check in needed here ,it makes the aapui aware of the list view depth |
249 // to be removed.added by gopa |
241 // to be removed.added by gopa |
250 if ( naviState->Levels() >= 1) |
242 if (naviState->Levels() >= 1) |
251 { |
243 { |
252 if (iNavigationalState->ViewingMode() |
244 if (iNavigationalState->ViewingMode() |
253 == NGlxNavigationalState::EBrowse) |
245 == NGlxNavigationalState::EBrowse) |
254 { |
246 { |
255 // For image viewer collection, goto view mode |
247 // For image viewer collection, goto view mode |
256 if (naviState->Id() == TMPXItemId( |
248 if (naviState->Id() == TMPXItemId( |
257 KGlxCollectionPluginImageViewerImplementationUid)) |
249 KGlxCollectionPluginImageViewerImplementationUid)) |
258 { |
250 { |
259 aIds.AppendL( TUid::Uid( KGlxViewingModeView ) ); |
251 aIds.AppendL(TUid::Uid(KGlxViewingModeView)); |
|
252 } |
|
253 else |
|
254 { |
|
255 aIds.AppendL(TUid::Uid(KGlxViewingModeBrowse)); |
|
256 } |
260 } |
257 } |
261 else |
258 else |
262 { |
259 { |
263 aIds.AppendL( TUid::Uid( KGlxViewingModeBrowse ) ); |
260 aIds.AppendL(TUid::Uid(KGlxViewingModeView)); |
264 } |
261 } |
265 } |
262 } |
266 else |
263 |
267 { |
264 if (TUid::Null() != GetViewScoringIdForCollectionPlugin(*naviState)) |
268 aIds.AppendL( TUid::Uid( KGlxViewingModeView ) ); |
265 { |
269 } |
266 // add scoring id for collection plugin |
270 } |
267 aIds.AppendL(GetViewScoringIdForCollectionPlugin(*naviState)); |
271 |
268 } |
272 if( TUid::Null() != GetViewScoringIdForCollectionPlugin( *naviState ) ) |
269 |
273 { |
270 if (TUid::Null() != ViewScoringIdForNaviStateDepth(*naviState)) |
274 // add scoring id for collection plugin |
271 { |
275 aIds.AppendL( GetViewScoringIdForCollectionPlugin( *naviState ) ); |
272 // add scoring id for depth in the ui hierarchy |
276 } |
273 aIds.AppendL(ViewScoringIdForNaviStateDepth(*naviState)); |
277 |
274 } |
278 if( TUid::Null() != ViewScoringIdForNaviStateDepth( *naviState ) ) |
275 |
279 { |
276 CleanupStack::PopAndDestroy(naviState); |
280 // add scoring id for depth in the ui hierarchy |
|
281 aIds.AppendL( ViewScoringIdForNaviStateDepth( *naviState ) ); |
|
282 } |
|
283 |
|
284 CleanupStack::PopAndDestroy( naviState ); |
|
285 CleanupStack::Pop(&aIds); |
277 CleanupStack::Pop(&aIds); |
286 } |
278 } |
287 // --------------------------------------------------------------------------- |
279 |
288 // Handles the foreground events |
|
289 // --------------------------------------------------------------------------- |
|
290 // |
|
291 void CGlxIVwrAppUi::HandleForegroundEventL( TBool aForeground ) |
|
292 { |
|
293 TRACER("void CGlxIVwrAppUi::HandleForegroundEventL( TBool aForeground )"); |
|
294 |
|
295 // first let base class handle it so that we dont break anything |
|
296 CAknViewAppUi::HandleForegroundEventL( aForeground ); |
|
297 |
|
298 } |
|
299 // --------------------------------------------------------------------------- |
280 // --------------------------------------------------------------------------- |
300 // Return scoring id for collection plugin |
281 // Return scoring id for collection plugin |
301 // --------------------------------------------------------------------------- |
282 // --------------------------------------------------------------------------- |
302 // |
283 // |
303 TUid CGlxIVwrAppUi::GetViewScoringIdForCollectionPlugin( const CMPXCollectionPath& aNaviState ) const |
284 TUid CGlxIVwrAppUi::GetViewScoringIdForCollectionPlugin( |
304 { |
285 const CMPXCollectionPath& aNaviState) const |
305 TRACER("TUid CGlxIVwrAppUi::GetViewScoringIdForCollectionPluginL( const CMPXCollectionPath& aNaviState ) const"); |
286 { |
306 |
287 TRACER("TUid CGlxIVwrAppUi::GetViewScoringIdForCollectionPluginL()"); |
307 GLX_LOG_INFO1( "CGlxIVwrAppUi::GetViewScoringIdForCollectionPluginL: Depth %d", aNaviState.Levels() ); |
288 |
308 // score view based on collection plugin if not on root level |
289 GLX_LOG_INFO1( "CGlxIVwrAppUi::GetViewScoringIdForCollectionPluginL:Depth %d", aNaviState.Levels() ); |
309 if ( aNaviState.Levels() ) |
290 // score view based on collection plugin if not on root level |
310 { |
291 if (aNaviState.Levels()) |
311 return TUid::Uid( aNaviState.Id( 0 ) ); |
292 { |
312 } |
293 return TUid::Uid(aNaviState.Id(0)); |
313 // return null as id to be ignored in scoring |
294 } |
314 return TUid::Null(); |
295 // return null as id to be ignored in scoring |
315 } |
296 return TUid::Null(); |
|
297 } |
316 |
298 |
317 // --------------------------------------------------------------------------- |
299 // --------------------------------------------------------------------------- |
318 // Return scoring id for depth |
300 // Return scoring id for depth |
319 // --------------------------------------------------------------------------- |
301 // --------------------------------------------------------------------------- |
320 // |
302 // |
321 TUid CGlxIVwrAppUi::ViewScoringIdForNaviStateDepth( const CMPXCollectionPath& aNaviState ) const |
303 TUid CGlxIVwrAppUi::ViewScoringIdForNaviStateDepth( |
322 { |
304 const CMPXCollectionPath& aNaviState) const |
323 TRACER("TUid CGlxIVwrAppUi::ViewScoringIdForNaviStateDepthL( const CMPXCollectionPath& aNaviState ) const"); |
305 { |
324 GLX_LOG_INFO1( "CGlxIVwrAppUi::ViewScoringIdForNaviStateDepthL: Level %d", aNaviState.Levels() ); |
306 TRACER("TUid CGlxIVwrAppUi::ViewScoringIdForNaviStateDepthL()"); |
325 |
307 GLX_LOG_INFO1( "CGlxIVwrAppUi::ViewScoringIdForNaviStateDepthL: Level %d",aNaviState.Levels() ); |
326 switch ( aNaviState.Levels() ) |
308 |
327 { |
309 switch (aNaviState.Levels()) |
328 case 0: |
310 { |
329 |
311 case 0: |
330 GLX_LOG_INFO1( "CGlxIVwrAppUi::ViewScoringIdForNaviStateDepthL: \ |
312 |
331 Depth case 0 %x", TUid::Uid( KGlxDepthOne ) ); |
313 GLX_LOG_INFO1( "CGlxIVwrAppUi::ViewScoringIdForNaviStateDepthL:Depth case 0 %x", TUid::Uid( KGlxDepthOne ) ); |
332 return TUid::Uid( KGlxDepthOne ); |
314 return TUid::Uid(KGlxDepthOne); |
333 |
315 |
334 case 1: |
316 case 1: |
335 |
317 |
336 GLX_LOG_INFO1( "CGlxIVwrAppUi::ViewScoringIdForNaviStateDepthL: \ |
318 GLX_LOG_INFO1( "CGlxIVwrAppUi::ViewScoringIdForNaviStateDepthL:Depth case 1 %x", TUid::Uid( KGlxDepthTwo ) ); |
337 Depth case 1 %x", TUid::Uid( KGlxDepthTwo ) ); |
319 return TUid::Uid(KGlxDepthTwo); |
338 return TUid::Uid( KGlxDepthTwo ); |
320 |
339 |
321 case 2: |
340 |
322 |
341 case 2: |
323 GLX_LOG_INFO1( "CGlxIVwrAppUi::GetViewScoringIdForUiHieararchyDepthL:Depth case 2 %x", TUid::Uid( KGlxDepthThree ) ); |
342 |
324 return TUid::Uid(KGlxDepthThree); |
343 GLX_LOG_INFO1( "CGlxIVwrAppUi::GetViewScoringIdForUiHieararchyDepthL: \ |
325 |
344 Depth case 2 %x", TUid::Uid( KGlxDepthThree ) ); |
326 default: |
345 return TUid::Uid( KGlxDepthThree ); |
327 GLX_LOG_WARNING( "CGlxIVwrAppUi::GetViewScoringIdsL:Navigational state deeper than supported" ); |
346 |
328 // return null as an id to be ignored in scoring |
347 default: |
329 return TUid::Null(); |
348 GLX_LOG_WARNING( "CGlxIVwrAppUi::GetViewScoringIdsL: Navigational state deeper than supported" ); |
330 } |
349 // return null as an id to be ignored in scoring |
331 } |
350 return TUid::Null(); |
|
351 } |
|
352 } |
|
353 |
332 |
354 // --------------------------------------------------------------------------- |
333 // --------------------------------------------------------------------------- |
355 // HandleOpenFileL |
334 // HandleOpenFileL |
356 // --------------------------------------------------------------------------- |
335 // --------------------------------------------------------------------------- |
357 // |
336 // |
482 // CloseImgVwr |
458 // CloseImgVwr |
483 // ----------------------------------------------------------------------------- |
459 // ----------------------------------------------------------------------------- |
484 // |
460 // |
485 void CGlxIVwrAppUi::CloseImgVwr() |
461 void CGlxIVwrAppUi::CloseImgVwr() |
486 { |
462 { |
487 TRACER("CGlxNsAppUi::CloseImgVwr()"); |
463 TRACER("CGlxIVwrAppUi::CloseImgVwr()"); |
488 iUiUtility->SetViewNavigationDirection(EGlxNavigationBackwards); |
464 iUiUtility->SetViewNavigationDirection(EGlxNavigationBackwards); |
489 iUiUtility->SetExitingState(ETrue); |
465 iUiUtility->SetExitingState(ETrue); |
490 } |
466 } |
491 |
467 |
|
468 // ---------------------------------------------------------------------------- |
|
469 // CGlxIVwrAppUi::OpenFileL |
|
470 // This is called by framework when application is already open in background |
|
471 // and user open other file in eg. File Browse. |
|
472 // New file to been shown is passed via aFileName. |
|
473 // ---------------------------------------------------------------------------- |
|
474 // |
|
475 void CGlxIVwrAppUi::OpenFileL(const TDesC& aFileName) |
|
476 { |
|
477 TRACER("CGlxIVwrAppUi::OpenFileL()"); |
|
478 GLX_LOG_URI("CGlxIVwrAppUi::OpenFileL(%S)", &aFileName); |
|
479 |
|
480 // File changed. Open new file with documents OpenFileL method. |
|
481 Document()->OpenFileL(EFalse, aFileName, iEikonEnv->FsSession()); |
|
482 |
|
483 GLX_DEBUG1("CGlxIVwrAppUi::OpenFileL() *** File Changed *** "); |
|
484 MGlxCache* cacheManager = MGlxCache::InstanceL(); |
|
485 CleanupClosePushL(*cacheManager); |
|
486 |
|
487 CMPXCollectionPath* path = CMPXCollectionPath::NewL(); |
|
488 CleanupStack::PushL(path); |
|
489 path->AppendL(KGlxCollectionPluginImageViewerImplementationUid); |
|
490 |
|
491 MGlxMediaList* mediaList = MGlxMediaList::InstanceL(*path); |
|
492 CleanupClosePushL(*mediaList); |
|
493 |
|
494 if (mediaList->Count() > 0) |
|
495 { |
|
496 GLX_DEBUG1("CGlxIVwrAppUi::OpenFileL() - Cleanup & Refresh Media!"); |
|
497 cacheManager->ForceCleanupMedia(mediaList->IdSpaceId(0), |
|
498 mediaList->Item(0).Id()); |
|
499 cacheManager->RefreshL(); |
|
500 } |
|
501 |
|
502 CleanupStack::PopAndDestroy(mediaList); |
|
503 CleanupStack::PopAndDestroy(path); |
|
504 CleanupStack::PopAndDestroy(cacheManager); |
|
505 } |