55 // CWmPlugin::~CWmPlugin |
55 // CWmPlugin::~CWmPlugin |
56 // --------------------------------------------------------- |
56 // --------------------------------------------------------- |
57 // |
57 // |
58 CWmPlugin::~CWmPlugin() |
58 CWmPlugin::~CWmPlugin() |
59 { |
59 { |
60 iPostponedCommand = ENone; |
60 // delete members |
61 |
|
62 // delete WM UI resources |
|
63 if ( iViewAppUi ) |
|
64 { |
|
65 if ( iWmMainContainer && IsActive() ) |
|
66 { |
|
67 // WM is showing. Hide first! |
|
68 iWmMainContainer->SetClosingDown( ETrue ); |
|
69 TRAPD( err, iViewAppUi->ActivateLocalViewL( |
|
70 iPreviousViewUid.iViewUid ); ); |
|
71 if ( KErrNone == err ) |
|
72 { |
|
73 // wait until previous view is switched on top |
|
74 // then continue destruction. |
|
75 iWait->Start(); |
|
76 } |
|
77 else |
|
78 { |
|
79 // try to activate default view |
|
80 TVwsViewId viewId; |
|
81 if ( iViewAppUi->GetDefaultViewId( viewId ) != KErrNone ) |
|
82 { |
|
83 viewId.iAppUid = iViewAppUi->Application()->AppDllUid(); |
|
84 viewId.iViewUid = TUid::Uid( 1 ); |
|
85 } |
|
86 |
|
87 TRAPD( err, iViewAppUi->ActivateLocalViewL( viewId.iViewUid ); ); |
|
88 if ( KErrNone == err ) |
|
89 { |
|
90 // wait until previous view is switched on top |
|
91 // then continue destruction. |
|
92 iWait->Start(); |
|
93 } |
|
94 } |
|
95 } |
|
96 // remove view from appui (also deletes it) |
|
97 iViewAppUi->RemoveView( |
|
98 TUid::Uid( EWmMainContainerViewId ) ); |
|
99 } |
|
100 |
|
101 // delete other members |
|
102 delete iResourceLoader; |
61 delete iResourceLoader; |
103 delete iEffectManager; |
62 delete iEffectManager; |
104 delete iPostponedContent; |
63 delete iPostponedContent; |
105 delete iWait; |
|
106 delete iWmInstaller; |
64 delete iWmInstaller; |
107 } |
65 } |
108 |
66 |
109 // --------------------------------------------------------- |
67 // --------------------------------------------------------- |
110 // CWmPlugin::CWmPlugin |
68 // CWmPlugin::CWmPlugin |
131 |
89 |
132 // create resource loader |
90 // create resource loader |
133 iFs = &eikonEnv->FsSession(); |
91 iFs = &eikonEnv->FsSession(); |
134 iResourceLoader = CWmResourceLoader::NewL( *eikonEnv ); |
92 iResourceLoader = CWmResourceLoader::NewL( *eikonEnv ); |
135 iEffectManager = CWmEffectManager::NewL( *eikonEnv ); |
93 iEffectManager = CWmEffectManager::NewL( *eikonEnv ); |
136 |
94 iWmInstaller = CWmInstaller::NewL(); |
137 // wait object |
95 |
138 iWait = new (ELeave) CActiveSchedulerWait(); |
|
139 |
|
140 // main view |
96 // main view |
141 CWmMainContainerView* mainView = |
97 CWmMainContainerView* mainView = |
142 CWmMainContainerView::NewL( *this ); |
98 CWmMainContainerView::NewL( *this ); |
143 CleanupStack::PushL( mainView ); |
99 CleanupStack::PushL( mainView ); |
144 iViewAppUi->AddViewL( mainView ); |
100 iViewAppUi->AddViewL( mainView ); |
145 CleanupStack::Pop( mainView ); |
101 CleanupStack::Pop( mainView ); |
146 |
|
147 iWmInstaller = CWmInstaller::NewL(); |
|
148 } |
102 } |
149 |
103 |
150 // --------------------------------------------------------- |
104 // --------------------------------------------------------- |
151 // CWmPlugin::Activate |
105 // CWmPlugin::Activate |
152 // --------------------------------------------------------- |
106 // --------------------------------------------------------- |
153 // |
107 // |
154 void CWmPlugin::Activate() |
108 void CWmPlugin::Activate() |
155 { |
109 { |
156 if ( !IsActive() && iHsContentController ) |
110 CWmMainContainerView* view = static_cast<CWmMainContainerView*>( |
|
111 iViewAppUi->View( TUid::Uid(EWmMainContainerViewId) ) ); |
|
112 if ( !IsActive() && view && iHsContentController ) |
157 { |
113 { |
158 TRAP_IGNORE( |
114 TRAP_IGNORE( |
159 iEffectManager->BeginFullscreenEffectL( |
115 iEffectManager->BeginFullscreenEffectL( |
160 KAppStartCommonDefaultStyle ); |
116 KAppStartCommonDefaultStyle ); |
161 iViewAppUi->ActivateLocalViewL( |
117 iViewAppUi->ActivateLocalViewL( |
162 TUid::Uid( EWmMainContainerViewId ) ); |
118 TUid::Uid( EWmMainContainerViewId ) ); |
163 ); |
119 ); |
164 } |
120 } |
165 } |
121 } |
166 |
122 |
167 // --------------------------------------------------------- |
123 // --------------------------------------------------------- |
|
124 // CWmPlugin::DeActivate |
|
125 // --------------------------------------------------------- |
|
126 // |
|
127 void CWmPlugin::DeActivate() |
|
128 { |
|
129 iPostponedCommand = ENone; |
|
130 iPreviousViewUid.iViewUid = KNullUid; |
|
131 CWmMainContainerView* view = static_cast<CWmMainContainerView*>( |
|
132 iViewAppUi->View( TUid::Uid(EWmMainContainerViewId) ) ); |
|
133 if ( view ) { view->DoDeactivate(); } |
|
134 } |
|
135 |
|
136 // --------------------------------------------------------- |
|
137 // CWmPlugin::Views |
|
138 // --------------------------------------------------------- |
|
139 // |
|
140 void CWmPlugin::Views( RPointerArray<CAknView>& aViews ) |
|
141 { |
|
142 // return view to be destroyed. |
|
143 CAknView* view = iViewAppUi->View( |
|
144 TUid::Uid(EWmMainContainerViewId) ); |
|
145 if ( view ) |
|
146 { |
|
147 aViews.Append( view ); |
|
148 } |
|
149 } |
|
150 |
|
151 // --------------------------------------------------------- |
168 // CWmPlugin::IsActive |
152 // CWmPlugin::IsActive |
169 // --------------------------------------------------------- |
153 // --------------------------------------------------------- |
170 // |
154 // |
171 TBool CWmPlugin::IsActive() |
155 TBool CWmPlugin::IsActive() |
172 { |
156 { |
173 return ( iPreviousViewUid.iViewUid != KNullUid ); |
157 TVwsViewId activeViewId(KNullUid,KNullUid); |
174 } |
158 if ( iViewAppUi->GetActiveViewId( activeViewId ) == KErrNone && |
175 |
159 activeViewId.iViewUid == TUid::Uid( EWmMainContainerViewId ) ) |
176 // --------------------------------------------------------- |
160 { |
177 // CWmPlugin::Deactivate |
161 if ( iPreviousViewUid.iViewUid == KNullUid ) |
178 // --------------------------------------------------------- |
162 { |
179 // |
163 iPreviousViewUid.iAppUid = iViewAppUi->Application()->AppDllUid(); |
180 void CWmPlugin::Deactivate() |
164 iPreviousViewUid.iViewUid = TUid::Uid( 1 ); |
|
165 } |
|
166 return ETrue; |
|
167 } |
|
168 |
|
169 return( iPreviousViewUid.iViewUid != KNullUid ); |
|
170 } |
|
171 |
|
172 // --------------------------------------------------------- |
|
173 // CWmPlugin::CloseView |
|
174 // --------------------------------------------------------- |
|
175 // |
|
176 void CWmPlugin::CloseView() |
181 { |
177 { |
182 if ( IsActive() ) |
178 if ( IsActive() ) |
183 { |
179 { |
184 iWmMainContainer->SetClosingDown( ETrue ); |
180 iWmMainContainer->SetClosingDown( ETrue ); |
185 TRAP_IGNORE( |
181 TRAP_IGNORE( |
198 void CWmPlugin::MainViewActivated( |
194 void CWmPlugin::MainViewActivated( |
199 const TVwsViewId& aViewId, |
195 const TVwsViewId& aViewId, |
200 CWmMainContainer* aWmMainContainer ) |
196 CWmMainContainer* aWmMainContainer ) |
201 { |
197 { |
202 iPreviousViewUid = aViewId; |
198 iPreviousViewUid = aViewId; |
|
199 // verify if we have correct viewid to activate. |
|
200 if ( iPreviousViewUid.iViewUid == KNullUid ) |
|
201 { |
|
202 // use default if we got wrong viewid as previous view |
|
203 iPreviousViewUid.iAppUid = iViewAppUi->Application()->AppDllUid(); |
|
204 iPreviousViewUid.iViewUid = TUid::Uid( 1 ); |
|
205 } |
|
206 |
203 iWmMainContainer = aWmMainContainer; |
207 iWmMainContainer = aWmMainContainer; |
204 iEffectManager->UiRendered(); |
208 iEffectManager->UiRendered(); |
205 iWmMainContainer->SetClosingDown( EFalse ); |
209 iWmMainContainer->SetClosingDown( EFalse ); |
206 |
210 |
207 // Don't forward numeric keys to phone |
211 // Don't forward numeric keys to phone |
208 ForwardNumericKeysToPhone( EFalse ); |
212 ForwardNumericKeysToPhone( EFalse ); |
209 } |
213 } |
210 |
214 |
211 // --------------------------------------------------------- |
215 // --------------------------------------------------------- |
212 // CWmPlugin::MainViewDeactivated |
216 // CWmPlugin::MainViewDeactivated |
213 // --------------------------------------------------------- |
217 // --------------------------------------------------------- |
214 // |
218 // |
217 // Forward numeric keys to phone |
221 // Forward numeric keys to phone |
218 ForwardNumericKeysToPhone( ETrue ); |
222 ForwardNumericKeysToPhone( ETrue ); |
219 |
223 |
220 iPreviousViewUid.iViewUid = KNullUid; |
224 iPreviousViewUid.iViewUid = KNullUid; |
221 iWmMainContainer = NULL; |
225 iWmMainContainer = NULL; |
222 if ( iEffectManager && !iWait->IsStarted() ) |
226 if ( iEffectManager ) |
223 { |
227 { |
224 iEffectManager->UiRendered(); |
228 iEffectManager->UiRendered(); |
225 } |
229 } |
226 |
230 |
227 TRAP_IGNORE( ExecuteCommandL(); ); |
231 TRAP_IGNORE( ExecuteCommandL(); ); |
228 |
|
229 if ( iWait->IsStarted() ) { iWait->AsyncStop(); } |
|
230 } |
232 } |
231 |
233 |
232 // --------------------------------------------------------- |
234 // --------------------------------------------------------- |
233 // CWmPlugin::ForwardNumericKeysToPhone |
235 // CWmPlugin::ForwardNumericKeysToPhone |
234 // --------------------------------------------------------- |
236 // --------------------------------------------------------- |
265 void CWmPlugin::ExecuteCommandL() |
267 void CWmPlugin::ExecuteCommandL() |
266 { |
268 { |
267 if ( iPostponedCommand == EAddToHomescreen ) |
269 if ( iPostponedCommand == EAddToHomescreen ) |
268 { |
270 { |
269 TInt err = ContentController().AddWidgetL( *iPostponedContent ); |
271 TInt err = ContentController().AddWidgetL( *iPostponedContent ); |
270 if ( err == KHsErrorViewFull || |
272 if ( err != KErrNone ) |
271 err == KHsErrorDoesNotFit ) |
273 ShowErrorNoteL( err ); |
272 { |
|
273 ResourceLoader().InfoPopupL( |
|
274 R_QTN_HS_ADD_WIDGET_NO_SPACE_NOTE, KNullDesC ); |
|
275 } |
|
276 else if ( err == KHsErrorMaxInstanceCountExceeded ) |
|
277 { |
|
278 ResourceLoader().InfoPopupL( |
|
279 R_QTN_HS_ADD_WIDGET_MAX_COUNT_NOTE, KNullDesC ); |
|
280 } |
|
281 else if ( err == KErrNoMemory ) |
|
282 { |
|
283 ResourceLoader().InfoPopupL( |
|
284 R_QTN_HS_HS_MEMORY_FULL, KNullDesC ); |
|
285 } |
|
286 else if ( ( err != KErrNone ) && ( err != KErrDiskFull ) ) |
|
287 { |
|
288 ResourceLoader().ErrorPopup( err ); |
|
289 } |
|
290 } |
274 } |
291 iPostponedCommand = ENone; |
275 iPostponedCommand = ENone; |
292 delete iPostponedContent; |
276 delete iPostponedContent; |
293 iPostponedContent = NULL; |
277 iPostponedContent = NULL; |
294 } |
278 } |
295 |
279 |
296 // --------------------------------------------------------- |
280 // --------------------------------------------------------- |
297 // CWmPlugin::MainViewDeactivated |
281 // CWmPlugin::ShowErrorNoteL |
|
282 // --------------------------------------------------------- |
|
283 // |
|
284 void CWmPlugin::ShowErrorNoteL( TInt aError ) |
|
285 { |
|
286 switch ( aError ) |
|
287 { |
|
288 case KHsErrorViewFull: |
|
289 case KHsErrorDoesNotFit: |
|
290 ResourceLoader().InfoPopupL( |
|
291 R_QTN_HS_ADD_WIDGET_NO_SPACE_NOTE, KNullDesC ); |
|
292 break; |
|
293 |
|
294 case KHsErrorMaxInstanceCountExceeded: |
|
295 { |
|
296 TInt resource = ( iPostponedContent->Type() == KContentTemplate ) ? |
|
297 resource = R_QTN_HS_ADD_WIDGET_MAX_REACHED : // wrt |
|
298 resource = R_QTN_HS_ADD_WIDGET_MAX_COUNT_NOTE; // native |
|
299 |
|
300 ResourceLoader().InfoPopupL( resource, KNullDesC ); |
|
301 break; |
|
302 } |
|
303 |
|
304 case KErrNoMemory: |
|
305 ResourceLoader().InfoPopupL( R_QTN_HS_HS_MEMORY_FULL, KNullDesC ); |
|
306 break; |
|
307 |
|
308 default: |
|
309 ResourceLoader().ErrorPopup( aError ); |
|
310 break; |
|
311 } |
|
312 } |
|
313 |
|
314 // --------------------------------------------------------- |
|
315 // CWmPlugin::ViewAppUi |
298 // --------------------------------------------------------- |
316 // --------------------------------------------------------- |
299 // |
317 // |
300 CAknViewAppUi& CWmPlugin::ViewAppUi() |
318 CAknViewAppUi& CWmPlugin::ViewAppUi() |
301 { |
319 { |
302 return *iViewAppUi; |
320 return *iViewAppUi; |
303 } |
321 } |
304 |
322 |
305 // --------------------------------------------------------- |
323 // --------------------------------------------------------- |
306 // CWmPlugin::MainViewDeactivated |
324 // CWmPlugin::ResourceLoader |
307 // --------------------------------------------------------- |
325 // --------------------------------------------------------- |
308 // |
326 // |
309 CWmResourceLoader& CWmPlugin::ResourceLoader() |
327 CWmResourceLoader& CWmPlugin::ResourceLoader() |
310 { |
328 { |
311 return *iResourceLoader; |
329 return *iResourceLoader; |
312 } |
330 } |
313 |
331 |
314 // --------------------------------------------------------- |
332 // --------------------------------------------------------- |
315 // CWmPlugin::MainViewDeactivated |
333 // CWmPlugin::ContentController |
316 // --------------------------------------------------------- |
334 // --------------------------------------------------------- |
317 // |
335 // |
318 MHsContentController& CWmPlugin::ContentController() |
336 MHsContentController& CWmPlugin::ContentController() |
319 { |
337 { |
320 return *iHsContentController; |
338 return *iHsContentController; |
321 } |
339 } |
322 |
340 |
323 // --------------------------------------------------------- |
341 // --------------------------------------------------------- |
324 // CWmPlugin::MainViewDeactivated |
342 // CWmPlugin::FileServer |
325 // --------------------------------------------------------- |
343 // --------------------------------------------------------- |
326 // |
344 // |
327 RFs& CWmPlugin::FileServer() |
345 RFs& CWmPlugin::FileServer() |
328 { |
346 { |
329 return *iFs; |
347 return *iFs; |