159 iAppUi.AddToStackL( *this, iContainer ); |
169 iAppUi.AddToStackL( *this, iContainer ); |
160 iContainer->ActivateL(); |
170 iContainer->ActivateL(); |
161 iContainer->DrawNow(); |
171 iContainer->DrawNow(); |
162 } |
172 } |
163 |
173 |
164 iData.iAppUid = aPrevViewId.iAppUid; |
174 iPreviousViewUid = aPrevViewId; |
165 iData.iViewUid = aPrevViewId.iViewUid; |
175 iMultiple = ( (aCustomMessage == KMulti) ? ETrue : EFalse ); |
166 iData.iMultiple = EFalse; |
176 |
167 |
177 iAppUi.EffectManager()->UiRendered(); |
168 if ( aCustomMessage == KMulti ) |
178 |
169 { |
179 iWaitDialog = NULL; |
170 iData.iMultiple = ETrue; |
180 iViewState = EImageSelection; |
171 } |
|
172 |
181 |
173 // Run image selection dialog asynchronously |
182 // Run image selection dialog asynchronously |
174 iTimer->Cancel(); |
183 iTimer->Cancel(); |
175 iTimer->Start( 0, 1000, TCallBack( TimerCallbackL, this ) ); |
184 iTimer->Start( KShortDelay, KLongDelay, TCallBack( TimerCallback, this ) ); |
176 |
|
177 iAppUi.EffectManager()->UiRendered(); |
|
178 } |
185 } |
179 |
186 |
180 // ----------------------------------------------------------------------------- |
187 // ----------------------------------------------------------------------------- |
181 // CXnWallpaperView::DoActivateL |
188 // CXnWallpaperView::DoActivateL |
182 // ----------------------------------------------------------------------------- |
189 // ----------------------------------------------------------------------------- |
183 // |
190 // |
184 void CXnWallpaperView::DoDeactivate() |
191 void CXnWallpaperView::DoDeactivate() |
185 { |
192 { |
|
193 iTimer->Cancel(); // cancel timer |
|
194 |
|
195 if ( iWaitDialog ) |
|
196 { |
|
197 TRAP_IGNORE( iWaitDialog->ProcessFinishedL(); ); |
|
198 } |
|
199 |
186 if ( iContainer ) |
200 if ( iContainer ) |
187 { |
201 { |
188 iAppUi.RemoveFromStack( iContainer ); |
202 iAppUi.RemoveFromStack( iContainer ); |
189 delete iContainer; |
203 delete iContainer; |
190 iContainer = NULL; |
204 iContainer = NULL; |
194 { |
208 { |
195 AppUi()->RemoveFromStack( iXnSpBgCleaner ); |
209 AppUi()->RemoveFromStack( iXnSpBgCleaner ); |
196 delete iXnSpBgCleaner; |
210 delete iXnSpBgCleaner; |
197 iXnSpBgCleaner = NULL; |
211 iXnSpBgCleaner = NULL; |
198 } |
212 } |
199 |
213 |
|
214 iViewState = EIdle; |
200 iAppUi.EffectManager()->UiRendered(); |
215 iAppUi.EffectManager()->UiRendered(); |
201 } |
216 } |
202 |
217 |
203 // ----------------------------------------------------------------------------- |
218 // ----------------------------------------------------------------------------- |
204 // CXnWallpaperView::TimerCallback |
219 // CXnWallpaperView::TimerCallback |
205 // ----------------------------------------------------------------------------- |
220 // ----------------------------------------------------------------------------- |
206 // |
221 // |
207 TInt CXnWallpaperView::TimerCallbackL( TAny *aPtr ) |
222 TInt CXnWallpaperView::TimerCallback( TAny *aPtr ) |
208 { |
223 { |
209 CXnWallpaperView* self = reinterpret_cast< CXnWallpaperView* >( aPtr ); |
224 CXnWallpaperView* self = reinterpret_cast< CXnWallpaperView* >( aPtr ); |
210 self->iTimer->Cancel(); |
225 TRAPD( err, self->DoHandleCallBackL(); ); |
211 |
226 if ( KErrNone != err ) |
212 CDesCArrayFlat* files = |
227 { |
213 new (ELeave) CDesCArrayFlat( KFileArrayGranularity ); |
228 // activate default view in case of any error |
214 CleanupStack::PushL( files ); |
229 TVwsViewId defaultView; |
215 |
230 if ( self->iAppUi.GetDefaultViewId( defaultView ) != KErrNone ) |
216 TInt err( KErrNone ); |
231 { |
217 TBool selected( EFalse ); |
232 // use default if we got wrong viewid as previous view |
218 |
233 defaultView.iAppUid = self->iAppUi.Application()->AppDllUid(); |
219 TXnWallpaperViewData& data( self->iData ); |
234 defaultView.iViewUid = TUid::Uid( 1 ); |
220 |
235 } |
221 CXnBackgroundManager& bg( self->iAppUi.ViewAdapter().BgManager() ); |
236 // try activating default view |
222 |
237 TRAP_IGNORE( self->iAppUi.ActivateViewL( defaultView ); ); |
223 TRAPD( fetch, selected = MGFetch::RunL( *files, EImageFile, data.iMultiple ) ); |
238 } |
224 |
239 return KErrNone; |
225 if ( fetch == KErrNone && selected && files->MdcaCount() > 0 ) |
240 } |
226 { |
241 |
227 // set wallpaper |
242 // ----------------------------------------------------------------------------- |
228 if( files->MdcaCount() == 1 ) |
243 // CXnWallpaperView::DoHandleCallBackL |
229 { |
244 // ----------------------------------------------------------------------------- |
230 err = bg.AddWallpaperL( files->MdcaPoint( 0 ) ); |
245 // |
|
246 void CXnWallpaperView::DoHandleCallBackL() |
|
247 { |
|
248 iTimer->Cancel(); |
|
249 |
|
250 if ( iViewState == EImageSelection ) |
|
251 { |
|
252 CDesCArrayFlat* files = |
|
253 new (ELeave) CDesCArrayFlat( KFileArrayGranularity ); |
|
254 CleanupStack::PushL( files ); |
|
255 |
|
256 TInt err( KErrNone ); |
|
257 TBool selected( EFalse ); |
|
258 |
|
259 CXnBackgroundManager& bg( iAppUi.ViewAdapter().BgManager() ); |
|
260 |
|
261 selected = MGFetch::RunL( *files, EImageFile, iMultiple ); |
|
262 |
|
263 if ( selected && files->MdcaCount() > 0 ) |
|
264 { |
|
265 // set wallpaper |
|
266 if( files->MdcaCount() == 1 ) |
|
267 { |
|
268 TFileName fileName( files->MdcaPoint( 0 ) ); |
|
269 RFs& fs = CEikonEnv::Static()->FsSession(); |
|
270 if ( BaflUtils::FileExists( fs, fileName ) ) |
|
271 { |
|
272 // if wallpaper adding will take more than 1,5 sec waitdlg will appear |
|
273 iWaitDialog = new( ELeave ) CAknWaitDialog( |
|
274 reinterpret_cast<CEikDialog**>( &iWaitDialog ), EFalse ); |
|
275 iWaitDialog->ExecuteLD( R_CHANGE_WALLPAPER_WAIT_DIALOG ); |
|
276 |
|
277 // add wallpaper |
|
278 err = bg.AddWallpaperL( fileName ); |
|
279 |
|
280 // notify waitdlg we're done. |
|
281 iWaitDialog->ProcessFinishedL(); |
|
282 // ProcessFinishedL() will NULL iWaitDialog |
|
283 } |
|
284 } |
231 } |
285 } |
232 } |
286 |
233 |
287 CleanupStack::PopAndDestroy( files ); |
234 CleanupStack::PopAndDestroy( files ); |
288 |
235 |
289 if( err == KErrTooBig || err == KErrNoMemory ) |
236 if ( err == KErrCACorruptContent ) |
290 { |
237 { |
291 ShowErrorDialogL( R_QTN_HS_TOO_BIG_IMAGE_NOTE ); |
238 //load message text |
292 } |
239 HBufC* msg = StringLoader::LoadLC( R_QTN_HS_CORRUPTED_IMAGE_NOTE ); |
293 else if( err == KErrCancel || err == KErrCouldNotConnect ) |
240 //ensure that dialog will not disappear immediatelly - by const. param |
294 { |
241 CAknErrorNote* dialog = new (ELeave) CAknErrorNote( true ); |
295 // Ignore these. |
242 CleanupStack::PushL( dialog ); |
296 } |
243 //show dialog to user and destroy it |
297 else if( err != KErrNone ) |
244 dialog->ExecuteLD( *msg ); |
298 { |
245 CleanupStack::Pop( dialog ); |
299 ShowErrorDialogL( R_QTN_HS_CORRUPTED_IMAGE_NOTE ); |
246 CleanupStack::PopAndDestroy( msg ); |
300 } |
247 } |
301 |
248 |
302 // restart timer to deactivate view. View activation fails if |
249 self->iAppUi.EffectManager()->BeginFullscreenEffectL( |
303 // any dialog was shown just before calling iAppUi.ActivateViewL |
250 KGfxContextCloseWallpaperView, self->iAppUi.ViewManager().ActiveViewData() ); |
304 // specially when theme effects are on. |
251 |
305 iViewState = EViewDeactivation; |
252 self->iAppUi.ActivateViewL( TVwsViewId( data.iAppUid, data.iViewUid ) ); |
306 iTimer->Start( KLongDelay, KLongDelay, TCallBack( TimerCallback, this ) ); |
253 |
307 } |
254 return KErrNone; |
308 else if ( iViewState == EViewDeactivation ) |
255 } |
309 { |
|
310 iAppUi.EffectManager()->BeginFullscreenEffectL( |
|
311 KGfxContextCloseWallpaperView, |
|
312 iAppUi.ViewManager().ActiveViewData() ); |
|
313 iAppUi.ActivateViewL( iPreviousViewUid ); |
|
314 } |
|
315 else |
|
316 { |
|
317 iViewState = EIdle; |
|
318 User::Leave( KErrUnknown ); |
|
319 } |
|
320 } |
|
321 |
|
322 // ----------------------------------------------------------------------------- |
|
323 // CXnWallpaperView::ShowErrorDialogL |
|
324 // ----------------------------------------------------------------------------- |
|
325 // |
|
326 void CXnWallpaperView::ShowErrorDialogL( const TInt aResourceId ) |
|
327 { |
|
328 //load message text |
|
329 HBufC* msg = StringLoader::LoadLC( aResourceId ); |
|
330 //ensure that dialog will not disappear immediatelly - by const. param |
|
331 CAknErrorNote* dialog = new (ELeave) CAknErrorNote( true ); |
|
332 CleanupStack::PushL( dialog ); |
|
333 //show dialog to user and destroy it |
|
334 dialog->ExecuteLD( *msg ); |
|
335 CleanupStack::Pop( dialog ); |
|
336 CleanupStack::PopAndDestroy( msg ); |
|
337 } |
|
338 |
256 |
339 |
257 // End of File |
340 // End of File |