|
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 "glxivwrappui.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 |
|
33 #include <alf/alfenv.h> |
|
34 #include <akntoolbar.h> |
|
35 #include <glxgallery.hrh> |
|
36 |
|
37 #include <glxcollectionpluginimageviewer.hrh> |
|
38 #include <glxfiltergeneraldefs.h> |
|
39 #include <glxpanic.h> |
|
40 #include <glxuistd.h> |
|
41 #include <glxviewpluginuids.hrh> |
|
42 #include <glxlog.h> |
|
43 #include <glxuiutility.h> |
|
44 #include <glxsettingsmodel.h> |
|
45 #include <glxcommandhandlers.hrh> |
|
46 #include <glxzoomstatepublisher.h> |
|
47 #include <glxnavigationalstate.h> |
|
48 #include <glxnavigationalstatedefs.h> |
|
49 #include <glxfullscreenviewplugin.hrh> |
|
50 #include <glxivwr.rsg> |
|
51 #include <AknGlobalNote.h> |
|
52 #include <glxtracer.h> |
|
53 |
|
54 |
|
55 #include <glxbackservicewrapper.h> |
|
56 |
|
57 #include <glxuistd.h> |
|
58 #include <apgcli.h> |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // Constructor |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 CGlxIVwrAppUi::CGlxIVwrAppUi() |
|
65 { |
|
66 } |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // ConstructL is called by the application framework |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 void CGlxIVwrAppUi::ConstructL() |
|
73 { |
|
74 TRACER("void CGlxIVwrAppUi::ConstructL()"); |
|
75 |
|
76 // Enable Avkon skins. |
|
77 BaseConstructL( EAknEnableSkin | EAknEnableMSK | EAknSingleClickCompatible ); |
|
78 // Create navigational state |
|
79 iNavigationalState = CGlxNavigationalState::InstanceL(); |
|
80 |
|
81 iNavigationalState->AddObserverL( *this ); |
|
82 |
|
83 // Create Back Stepping Service wrapper |
|
84 iBSWrapper = CGlxBackServiceWrapper::NewL( TUid::Uid( KGlxGalleryApplicationUid ) ); |
|
85 iNavigationalState->SetBackExitStatus(EFalse); |
|
86 |
|
87 // Get an instance of view utility |
|
88 iViewUtility = MMPXViewUtility::UtilityL(); |
|
89 |
|
90 iUiUtility = CGlxUiUtility::UtilityL(); |
|
91 // Always start in default orientation |
|
92 iUiUtility->SetAppOrientationL(EGlxOrientationDefault); |
|
93 // publish zoom context, no zoom keys for now |
|
94 NGlxZoomStatePublisher::PublishStateL( EFalse ); |
|
95 } |
|
96 |
|
97 // ----------------------------------------------------------------------------- |
|
98 // Destructor |
|
99 // ----------------------------------------------------------------------------- |
|
100 // |
|
101 CGlxIVwrAppUi::~CGlxIVwrAppUi() |
|
102 { |
|
103 TRACER("CGlxIVwrAppUi::~CGlxIVwrAppUi()"); |
|
104 if ( iNavigationalState ) |
|
105 { |
|
106 iNavigationalState->RemoveObserver(*this); |
|
107 iNavigationalState->Close(); |
|
108 } |
|
109 |
|
110 if ( iViewUtility ) |
|
111 { |
|
112 iViewUtility->Close(); |
|
113 } |
|
114 |
|
115 delete iActivationParam; |
|
116 |
|
117 if ( iUiUtility ) |
|
118 { |
|
119 iUiUtility->Close(); |
|
120 } |
|
121 |
|
122 if( iBSWrapper ) |
|
123 { |
|
124 delete iBSWrapper; |
|
125 } |
|
126 } |
|
127 |
|
128 // ----------------------------------------------------------------------------- |
|
129 // HandleCommandL |
|
130 // ----------------------------------------------------------------------------- |
|
131 // |
|
132 void CGlxIVwrAppUi::HandleCommandL(TInt aCommand) |
|
133 { |
|
134 TRACER("void CGlxIVwrAppUi::HandleCommandL(TInt aCommand)"); |
|
135 GLX_LOG_INFO1("PHOTOS LOGS: void CGlxIVwrAppUi::HandleCommandL(TInt aCommand = %d)",aCommand ); |
|
136 switch(aCommand) |
|
137 { |
|
138 case EEikCmdExit: |
|
139 { |
|
140 Exit(); |
|
141 } |
|
142 break; |
|
143 case EAknSoftkeyExit: |
|
144 { |
|
145 CloseImgVwr(); |
|
146 GLX_LOG_INFO("CGlxIVwrAppUi::HandleCommandL: Exit() being Called"); |
|
147 Exit(); |
|
148 } |
|
149 break; |
|
150 |
|
151 case EAknSoftkeyBack: |
|
152 iNavigationalState->ActivatePreviousViewL(); |
|
153 break; |
|
154 |
|
155 default: |
|
156 break; |
|
157 } |
|
158 } |
|
159 |
|
160 // --------------------------------------------------------------------------- |
|
161 // ProcessCommandParametersL |
|
162 // --------------------------------------------------------------------------- |
|
163 // |
|
164 TBool CGlxIVwrAppUi::ProcessCommandParametersL(TApaCommand aCommand, |
|
165 TFileName& aDocumentName, const TDesC8& aTail) |
|
166 { |
|
167 TRACER("TBool CGlxIVwrAppUi::ProcessCommandParametersL(TApaCommand /*aCommand*/,TFileName& /*aDocumentName*/, const TDesC8& aTail)"); |
|
168 |
|
169 TRAPD(err, HandleActivationMessageL(aCommand, aDocumentName, aTail)); |
|
170 if ( KErrNone != err ) |
|
171 { |
|
172 // Open collection for main view |
|
173 iStartupViewUid = TUid::Null(); |
|
174 // Open navigational state at root level |
|
175 CMPXCollectionPath* newState = CMPXCollectionPath::NewL(); |
|
176 CleanupStack::PushL( newState ); |
|
177 iNavigationalState->NavigateToL( *newState ); |
|
178 CleanupStack::PopAndDestroy( newState ); |
|
179 } |
|
180 if(0 == aTail.CompareC(KNullDesC8)) |
|
181 { |
|
182 return ETrue; |
|
183 } |
|
184 else |
|
185 { |
|
186 return EFalse; |
|
187 } |
|
188 |
|
189 } |
|
190 |
|
191 // --------------------------------------------------------------------------- |
|
192 // Handle navigational state change |
|
193 // --------------------------------------------------------------------------- |
|
194 // |
|
195 void CGlxIVwrAppUi::HandleNavigationalStateChangedL() |
|
196 { |
|
197 TRACER("void CGlxIVwrAppUi::HandleNavigationalStateChangedL()"); |
|
198 // get current navigational state |
|
199 CMPXCollectionPath* naviState = iNavigationalState->StateLC(); |
|
200 |
|
201 // Case: Open photos in grid, go to filemanager via menu and open any image |
|
202 if (naviState->Id() != TMPXItemId(KGlxCollectionPluginImageViewerImplementationUid)) |
|
203 { |
|
204 /* |
|
205 * This thread chk is added for EDDG-7UUC53. In this scenario we get EPathChanged from MPX. |
|
206 * That initiates a viewnavigational change from CGlxNavigationalStateImp HandleCollectionMessageL() |
|
207 * In these types of scenarios we don't want a view switch. So ignoring the event. |
|
208 */ |
|
209 TApaTaskList taskList( iCoeEnv->WsSession() ); |
|
210 TApaTask task = taskList.FindApp( TUid::Uid( KGlxGalleryApplicationUid ) ); |
|
211 TApaTask taskForeGround = taskList.FindByPos(0); // get fopreground app |
|
212 if ( task.Exists() && task.ThreadId() != taskForeGround.ThreadId() ) |
|
213 { |
|
214 GLX_LOG_INFO("CGlxIVwrAppUi ::HandleNavigationalStateChanged: Return "); |
|
215 return; |
|
216 } |
|
217 } |
|
218 |
|
219 CleanupStack::PopAndDestroy( naviState ); |
|
220 |
|
221 HBufC* activationParam = iActivationParam; |
|
222 iActivationParam = NULL; // release ownership |
|
223 CleanupStack::PushL( activationParam ); |
|
224 |
|
225 if ( TUid::Null() != iStartupViewUid ) |
|
226 { |
|
227 GLX_LOG_INFO("CGlxAppUi::HandleNavigationalStateChanged: Activating startup view"); |
|
228 // Activate startup view |
|
229 iViewUtility->ActivateViewL( iStartupViewUid, activationParam ); |
|
230 iStartupViewUid = TUid::Null(); |
|
231 } |
|
232 else |
|
233 { |
|
234 GLX_LOG_INFO("CGlxAppUi::HandleNavigationalStateChanged: Activating view"); |
|
235 |
|
236 // get ids for scoring a view |
|
237 RArray< TUid > scoringIds; |
|
238 CleanupClosePushL( scoringIds ); |
|
239 GetViewScoringIdsL( scoringIds ); |
|
240 |
|
241 GLX_LOG_INFO1( "CGlxIVwrAppUi::HandleNavigationalStateChanged: Uid count %d", scoringIds.Count()); |
|
242 // let view utility to select the best view based on scoring ids |
|
243 iViewUtility->ActivateViewL( scoringIds, activationParam ); |
|
244 |
|
245 CleanupStack::PopAndDestroy( &scoringIds ); |
|
246 } |
|
247 |
|
248 CleanupStack::PopAndDestroy( activationParam ); |
|
249 } |
|
250 |
|
251 // --------------------------------------------------------------------------- |
|
252 // Populate array with view scoring ids |
|
253 // --------------------------------------------------------------------------- |
|
254 // |
|
255 void CGlxIVwrAppUi::GetViewScoringIdsL( RArray<TUid>& aIds ) const |
|
256 { |
|
257 TRACER("void CGlxIVwrAppUi::GetViewScoringIdsL( RArray<TUid>& aIds ) const"); |
|
258 |
|
259 aIds.Reset(); // For maintenance safety |
|
260 |
|
261 // get current navigational state |
|
262 CMPXCollectionPath* naviState = iNavigationalState->StateLC(); |
|
263 |
|
264 // no if check in needed here ,it makes the aapui aware of the list view depth |
|
265 // to be removed.added by gopa |
|
266 if ( naviState->Levels() >= 1) |
|
267 { |
|
268 if (iNavigationalState->ViewingMode() == NGlxNavigationalState::EBrowse) |
|
269 { |
|
270 // For image viewer collection, goto view mode |
|
271 if (naviState->Id() == TMPXItemId(KGlxCollectionPluginImageViewerImplementationUid)) |
|
272 { |
|
273 aIds.AppendL( TUid::Uid( KGlxViewingModeView ) ); |
|
274 } |
|
275 else |
|
276 { |
|
277 aIds.AppendL( TUid::Uid( KGlxViewingModeBrowse ) ); |
|
278 } |
|
279 } |
|
280 else |
|
281 { |
|
282 aIds.AppendL( TUid::Uid( KGlxViewingModeView ) ); |
|
283 } |
|
284 } |
|
285 |
|
286 if( TUid::Null() != GetViewScoringIdForCollectionPlugin( *naviState ) ) |
|
287 { |
|
288 // add scoring id for collection plugin |
|
289 aIds.AppendL( GetViewScoringIdForCollectionPlugin( *naviState ) ); |
|
290 } |
|
291 |
|
292 if( TUid::Null() != ViewScoringIdForNaviStateDepth( *naviState ) ) |
|
293 { |
|
294 // add scoring id for depth in the ui hierarchy |
|
295 aIds.AppendL( ViewScoringIdForNaviStateDepth( *naviState ) ); |
|
296 } |
|
297 |
|
298 CleanupStack::PopAndDestroy( naviState ); |
|
299 } |
|
300 // --------------------------------------------------------------------------- |
|
301 // Handles the foreground events |
|
302 // --------------------------------------------------------------------------- |
|
303 // |
|
304 void CGlxIVwrAppUi::HandleForegroundEventL( TBool aForeground ) |
|
305 { |
|
306 TRACER("void CGlxIVwrAppUi::HandleForegroundEventL( TBool aForeground )"); |
|
307 |
|
308 // first let base class handle it so that we dont break anything |
|
309 CAknViewAppUi::HandleForegroundEventL( aForeground ); |
|
310 |
|
311 } |
|
312 // --------------------------------------------------------------------------- |
|
313 // Return scoring id for collection plugin |
|
314 // --------------------------------------------------------------------------- |
|
315 // |
|
316 TUid CGlxIVwrAppUi::GetViewScoringIdForCollectionPlugin( const CMPXCollectionPath& aNaviState ) const |
|
317 { |
|
318 TRACER("TUid CGlxIVwrAppUi::GetViewScoringIdForCollectionPluginL( const CMPXCollectionPath& aNaviState ) const"); |
|
319 |
|
320 GLX_LOG_INFO1( "CGlxIVwrAppUi::GetViewScoringIdForCollectionPluginL: Depth %d", aNaviState.Levels() ); |
|
321 // score view based on collection plugin if not on root level |
|
322 if ( aNaviState.Levels() ) |
|
323 { |
|
324 return TUid::Uid( aNaviState.Id( 0 ) ); |
|
325 } |
|
326 // return null as id to be ignored in scoring |
|
327 return TUid::Null(); |
|
328 } |
|
329 |
|
330 // --------------------------------------------------------------------------- |
|
331 // Return scoring id for depth |
|
332 // --------------------------------------------------------------------------- |
|
333 // |
|
334 TUid CGlxIVwrAppUi::ViewScoringIdForNaviStateDepth( const CMPXCollectionPath& aNaviState ) const |
|
335 { |
|
336 TRACER("TUid CGlxIVwrAppUi::ViewScoringIdForNaviStateDepthL( const CMPXCollectionPath& aNaviState ) const"); |
|
337 GLX_LOG_INFO1( "CGlxIVwrAppUi::ViewScoringIdForNaviStateDepthL: Level %d", aNaviState.Levels() ); |
|
338 |
|
339 switch ( aNaviState.Levels() ) |
|
340 { |
|
341 case 0: |
|
342 |
|
343 GLX_LOG_INFO1( "CGlxIVwrAppUi::ViewScoringIdForNaviStateDepthL: \ |
|
344 Depth case 0 %x", TUid::Uid( KGlxDepthOne ) ); |
|
345 return TUid::Uid( KGlxDepthOne ); |
|
346 |
|
347 case 1: |
|
348 |
|
349 GLX_LOG_INFO1( "CGlxIVwrAppUi::ViewScoringIdForNaviStateDepthL: \ |
|
350 Depth case 1 %x", TUid::Uid( KGlxDepthTwo ) ); |
|
351 return TUid::Uid( KGlxDepthTwo ); |
|
352 |
|
353 |
|
354 case 2: |
|
355 |
|
356 GLX_LOG_INFO1( "CGlxIVwrAppUi::GetViewScoringIdForUiHieararchyDepthL: \ |
|
357 Depth case 2 %x", TUid::Uid( KGlxDepthThree ) ); |
|
358 return TUid::Uid( KGlxDepthThree ); |
|
359 |
|
360 default: |
|
361 GLX_LOG_WARNING( "CGlxIVwrAppUi::GetViewScoringIdsL: Navigational state deeper than supported" ); |
|
362 // return null as an id to be ignored in scoring |
|
363 return TUid::Null(); |
|
364 } |
|
365 } |
|
366 |
|
367 // --------------------------------------------------------------------------- |
|
368 // HandleActivationMessageL |
|
369 // --------------------------------------------------------------------------- |
|
370 // |
|
371 void CGlxIVwrAppUi::HandleActivationMessageL(const TApaCommand& aCommand, |
|
372 const TFileName& aDocumentName, const TDesC8& aData) |
|
373 { |
|
374 TRACER("void CGlxIVwrAppUi::HandleActivationMessageL(const TApaCommand& aCommand, const TFileName& aDocumentName, const TDesC8& aData)"); |
|
375 |
|
376 delete iActivationParam; |
|
377 iActivationParam = NULL; |
|
378 |
|
379 if ( 0 == aData.CompareC(KNullDesC8) ) |
|
380 { |
|
381 CMPXCollectionPath* path = CMPXCollectionPath::NewL(); |
|
382 CleanupStack::PushL(path); |
|
383 path->AppendL( KGlxCollectionPluginImageViewerImplementationUid ); |
|
384 iNavigationalState->NavigateToL( *path ); |
|
385 CleanupStack::PopAndDestroy( path ); |
|
386 } |
|
387 |
|
388 // Introduced to fix bug EMJN-78GH6N. Rowland Cook 10/12/2007 |
|
389 if (0 != iEikonEnv->RootWin().OrdinalPosition()) |
|
390 { |
|
391 iEikonEnv->RootWin().SetOrdinalPosition(0); |
|
392 } |
|
393 } |
|
394 |
|
395 // --------------------------------------------------------------------------- |
|
396 // SetActivationParamL |
|
397 // --------------------------------------------------------------------------- |
|
398 // |
|
399 void CGlxIVwrAppUi::SetActivationParamL(const TDesC8& aParam) |
|
400 { |
|
401 TRACER("void CGlxIVwrAppUi::SetActivationParamL(const TDesC8& aParam)"); |
|
402 iActivationParam = HBufC::NewL(aParam.Length()); |
|
403 iActivationParam->Des().Copy(aParam); |
|
404 } |
|
405 |
|
406 // --------------------------------------------------------------------------- |
|
407 // HandleApplicationSpecificEventL |
|
408 // |
|
409 // --------------------------------------------------------------------------- |
|
410 // |
|
411 |
|
412 void CGlxIVwrAppUi::HandleApplicationSpecificEventL(TInt aEventType, const TWsEvent& aWsEvent) |
|
413 { |
|
414 TRACER("CGlxIVwrAppUi::HandleApplicationSpecificEventL"); |
|
415 CAknViewAppUi::HandleApplicationSpecificEventL(aEventType,aWsEvent); |
|
416 if(aWsEvent.Type() == KAknUidValueEndKeyCloseEvent) |
|
417 { |
|
418 CloseImgVwr(); |
|
419 } |
|
420 } |
|
421 |
|
422 // ----------------------------------------------------------------------------- |
|
423 // CloseImgVwr |
|
424 // ----------------------------------------------------------------------------- |
|
425 // |
|
426 void CGlxIVwrAppUi::CloseImgVwr() |
|
427 { |
|
428 TRACER("CGlxNsAppUi::CloseImgVwr()"); |
|
429 iUiUtility->SetViewNavigationDirection(EGlxNavigationBackwards); |
|
430 iUiUtility->SetExitingState(ETrue); |
|
431 } |
|
432 |