118 { |
114 { |
119 iLoader = CPeriodic::NewL( CActive::EPriorityStandard ); |
115 iLoader = CPeriodic::NewL( CActive::EPriorityStandard ); |
120 } |
116 } |
121 |
117 |
122 // ----------------------------------------------------------------------------- |
118 // ----------------------------------------------------------------------------- |
123 // CXnPluginData::LoadL() |
119 // CXnPluginData::Load() |
124 // ----------------------------------------------------------------------------- |
120 // ----------------------------------------------------------------------------- |
125 // |
121 // |
126 void CXnPluginData::LoadL() |
122 TInt CXnPluginData::Load() |
127 { |
123 { |
128 if ( Occupied() || PluginState().CompareF( KStateError ) == 0 ) |
124 if ( Occupied() ) |
129 { |
125 { |
130 return; |
126 return KErrInUse; |
131 } |
127 } |
132 |
128 |
133 if ( !CXnOomSysHandler::HeapAvailable( WIDGET_MIN_MEM ) ) |
129 if ( !CXnOomSysHandler::HeapAvailable( WIDGET_MIN_MEM ) ) |
134 { |
130 { |
135 ViewManager().OomSysHandler().HandlePotentialOomL(); |
131 return KErrNoMemory; |
136 return; |
|
137 } |
132 } |
138 |
133 |
139 iFlags.Clear( EIsEmpty ); |
134 iFlags.Clear( EIsEmpty ); |
140 iFlags.Set( EIsRemovable ); |
135 iFlags.Set( EIsRemovable ); |
141 |
136 |
142 TRAPD( error, |
137 TInt err( KErrNone ); |
143 |
138 |
144 if ( iManager.Composer().ComposeWidgetL( *this ) == KErrNone ) |
139 TRAP( err, err = iManager.Composer().ComposeWidgetL( *this ) ); |
145 { |
140 |
146 iManager.Parser().LoadWidgetL( *this ); |
141 if ( err == KErrNone ) |
147 } |
142 { |
148 ); |
143 TRAP( err, iManager.Parser().LoadWidgetL( *this ) ); |
149 |
144 } |
150 if ( Empty() ) |
145 |
151 { |
146 if ( err == KErrNone ) |
152 // All done |
147 { |
153 return; |
148 // Mark publishers as virgin |
154 } |
149 iVirginPublishers = ETrue; |
155 |
150 |
156 if ( error || !Occupied() ) |
151 // Succesfully composed, try schedule publishers' loading |
157 { |
152 LoadPublishers(); |
158 if( error == KErrNoMemory ) |
|
159 { |
|
160 ViewManager().OomSysHandler().HandlePotentialOomL(); |
|
161 } |
|
162 |
|
163 // Mark this plugin ready, View Manager will remove it |
|
164 DataPluginsLoadCompletedL( KErrGeneral ); |
|
165 } |
153 } |
166 else |
154 else if ( err == KXnErrPluginFailure ) |
167 { |
155 { |
168 if ( Active() ) |
156 // Widget's configuration is broken, remove it |
169 { |
157 TRAP_IGNORE( iManager.UnloadWidgetFromPluginL( *this, ETrue ) ); |
170 // Load data plugins will set confirmation state to "wait" |
158 } |
171 LoadDataPluginsL(); |
159 |
172 } |
160 return err; |
173 else |
|
174 { |
|
175 // Composed succesfully to inactive page. Set confirmed |
|
176 SetPluginStateL( KStateConfirmed ); |
|
177 } |
|
178 } |
|
179 } |
161 } |
180 |
162 |
181 // ----------------------------------------------------------------------------- |
163 // ----------------------------------------------------------------------------- |
182 // CXnPluginData::Destroy() |
164 // CXnPluginData::Destroy() |
183 // ----------------------------------------------------------------------------- |
165 // ----------------------------------------------------------------------------- |
184 // |
166 // |
185 void CXnPluginData::Destroy() |
167 void CXnPluginData::Destroy() |
186 { |
168 { |
187 if ( Occupied() ) |
169 if ( Occupied() ) |
188 { |
170 { |
189 TRAP_IGNORE( |
171 DestroyPublishers(); |
190 DestroyDataPluginsL(); |
172 |
191 iManager.Parser().DestroyWidgetL( *this ); |
173 TRAP_IGNORE( iManager.Parser().DestroyWidgetL( *this ) ); |
192 ); |
|
193 } |
174 } |
194 |
175 |
195 Flush(); |
176 Flush(); |
196 } |
177 } |
197 |
178 |
198 // ----------------------------------------------------------------------------- |
179 // ----------------------------------------------------------------------------- |
199 // CXnPluginData::LoadDataPluginsL |
180 // CXnPluginData::LoadPublishers |
200 // Loads data plugins associated to the plugin |
181 // Loads data plugins associated to the plugin |
201 // ----------------------------------------------------------------------------- |
182 // ----------------------------------------------------------------------------- |
202 // |
183 // |
203 void CXnPluginData::LoadDataPluginsL() |
184 void CXnPluginData::LoadPublishers() |
204 { |
185 { |
205 if ( !Active() || !Occupied() ) |
186 if ( !Active() || !Occupied() || iContentSourceNodes.Count() == 0 ) |
206 { |
187 { |
207 iFlags.Set( EIsDataPluginsReady ); |
|
208 |
|
209 return; |
188 return; |
210 } |
189 } |
211 |
190 |
212 if ( iContentSourceNodes.Count() == 0 ) |
191 iLoader->Cancel(); |
213 { |
192 |
214 DataPluginsLoadCompletedL( KErrNone ); |
193 iLoader->Start( TTimeIntervalMicroSeconds32( 50 ), |
215 } |
194 TTimeIntervalMicroSeconds32( 50 ), |
216 else |
195 TCallBack( PeriodicEventL, this ) ); |
217 { |
196 } |
218 iLoader->Cancel(); |
197 |
219 |
198 // ----------------------------------------------------------------------------- |
220 iFlags.Clear( EIsDataPluginsReady ); |
199 // CXnPluginData::PeriodicEventL() |
221 |
200 // |
222 iLoadIndex = 0; |
201 // ----------------------------------------------------------------------------- |
223 |
202 // |
224 iLoader->Start( TTimeIntervalMicroSeconds32( 0 ), |
203 /* static */ TInt CXnPluginData::PeriodicEventL( TAny* aAny ) |
225 TTimeIntervalMicroSeconds32( 0 ), |
204 { |
226 TCallBack( RunL, this ) ); |
205 CXnPluginData* self = static_cast< CXnPluginData* >( aAny ); |
227 } |
206 |
228 } |
207 self->iLoader->Cancel(); |
229 |
208 |
230 // ----------------------------------------------------------------------------- |
209 TInt reason( EAiFwPluginStartup ); |
231 // CXnPluginData::DataPluginsLoadCompletedL |
210 |
232 // Indicates that all data plugins are loaded |
211 if ( self->LoadPublishers( reason ) != KErrNone ) |
233 // ----------------------------------------------------------------------------- |
212 { |
234 // |
213 self->iManager.UnloadWidgetFromPluginL( *self, ETrue ); |
235 void CXnPluginData::DataPluginsLoadCompletedL( TInt aStatus ) |
214 |
236 { |
215 self->ShowContentRemovedError(); |
237 iFlags.Set( EIsDataPluginsReady ); |
216 } |
238 |
217 |
239 const TDesC8& state( aStatus == KErrNone |
218 return KErrNone; |
240 ? KStateConfirmed() : KStateError() ); |
219 } |
241 |
220 |
242 SetPluginStateL( state ); |
221 // ----------------------------------------------------------------------------- |
243 |
222 // CXnPluginData::LoadPublishers() |
244 iManager.SetDataPluginLoadCompleteL( *this ); |
223 // |
245 } |
224 // ----------------------------------------------------------------------------- |
246 |
225 // |
247 // ----------------------------------------------------------------------------- |
226 TInt CXnPluginData::LoadPublishers( TInt aReason ) |
248 // CXnPluginData::DataPluginsLoaded |
227 { |
249 // Queries whether all data plugins are loaded |
228 TInt err( KErrNone ); |
250 // ----------------------------------------------------------------------------- |
229 |
251 // |
230 TRAP( err, |
252 TBool CXnPluginData::DataPluginsLoaded() const |
231 for ( TInt i = 0; i < iContentSourceNodes.Count(); i++ ) |
253 { |
232 { |
254 return ( iFlags.IsSet( EIsDataPluginsReady ) ? ETrue : EFalse ); |
233 CXnNodeAppIf& plugin( iContentSourceNodes[i]->AppIfL() ); |
255 } |
234 |
256 |
235 TInt retval( |
257 // ----------------------------------------------------------------------------- |
236 iManager.AppUiAdapter().LoadPublisher( plugin, aReason ) ); |
258 // CXnPluginData::DestroyDataPluginsL |
237 |
|
238 if ( !err ) |
|
239 { |
|
240 err = retval; |
|
241 } |
|
242 } |
|
243 ); |
|
244 |
|
245 iVirginPublishers = EFalse; |
|
246 |
|
247 if ( !Removable() ) |
|
248 { |
|
249 // Not allowed to remove even it fails |
|
250 return KErrNone; |
|
251 } |
|
252 |
|
253 return err; |
|
254 } |
|
255 |
|
256 // ----------------------------------------------------------------------------- |
|
257 // CXnPluginData::DestroyPublishers |
259 // Remove data plugins associated to the plugin |
258 // Remove data plugins associated to the plugin |
260 // ----------------------------------------------------------------------------- |
259 // ----------------------------------------------------------------------------- |
261 // |
260 // |
262 void CXnPluginData::DestroyDataPluginsL() |
261 void CXnPluginData::DestroyPublishers() |
263 { |
262 { |
264 if ( Occupied() ) |
263 if ( Occupied() ) |
265 { |
264 { |
266 iFlags.Set( EIsDataPluginsReady ); |
265 // If not all plugins loaded yet |
267 |
266 iLoader->Cancel(); |
268 if ( iLoader->IsActive() ) |
267 |
269 { |
268 TRAP_IGNORE( DoDestroyPublishersL() ); |
270 // Not all plugins loaded yet |
|
271 iLoader->Cancel(); |
|
272 |
|
273 RevertPluginState(); |
|
274 } |
|
275 |
|
276 // Create list of data plugins to be removed |
|
277 RPointerArray< CXnNodeAppIf > list; |
|
278 CleanupClosePushL( list ); |
|
279 |
|
280 for ( TInt i = 0; i < iContentSourceNodes.Count(); i++ ) |
|
281 { |
|
282 list.AppendL( &iContentSourceNodes[i]->AppIfL() ); |
|
283 } |
|
284 |
|
285 // Destruction is synchronous |
|
286 iManager.AppUiAdapter().DestroyDataPluginsL( list ); |
|
287 |
|
288 CleanupStack::PopAndDestroy( &list ); |
|
289 |
269 |
290 User::Heap().Compress(); |
270 User::Heap().Compress(); |
291 } |
271 } |
292 } |
272 } |
293 |
273 |
294 // ----------------------------------------------------------------------------- |
274 // ----------------------------------------------------------------------------- |
|
275 // CXnPluginData::VirginPublishers |
|
276 // |
|
277 // ----------------------------------------------------------------------------- |
|
278 // |
|
279 TBool CXnPluginData::VirginPublishers() const |
|
280 { |
|
281 return iVirginPublishers; |
|
282 } |
|
283 |
|
284 // ----------------------------------------------------------------------------- |
|
285 // CXnPluginData::DoDestroyPublishersL |
|
286 // Remove data plugins associated to the plugin |
|
287 // ----------------------------------------------------------------------------- |
|
288 // |
|
289 void CXnPluginData::DoDestroyPublishersL() |
|
290 { |
|
291 for ( TInt i = 0; i < iContentSourceNodes.Count(); i++ ) |
|
292 { |
|
293 CXnNodeAppIf& plugin( iContentSourceNodes[i]->AppIfL() ); |
|
294 |
|
295 // Destruction is synchronous |
|
296 iManager.AppUiAdapter().DestroyPublisher( |
|
297 plugin, EAiFwPluginShutdown ); |
|
298 } |
|
299 } |
|
300 |
|
301 // ----------------------------------------------------------------------------- |
295 // CXnPluginData::SetConfigurationIdL() |
302 // CXnPluginData::SetConfigurationIdL() |
296 // ----------------------------------------------------------------------------- |
303 // ----------------------------------------------------------------------------- |
297 // |
304 // |
298 void CXnPluginData::SetConfigurationIdL( const TDesC8& aConfigurationId ) |
305 void CXnPluginData::SetConfigurationIdL( const TDesC8& aConfigurationId ) |
299 { |
306 { |
622 // CXnPluginData::SetIsDisplayingPopup() |
591 // CXnPluginData::SetIsDisplayingPopup() |
623 // |
592 // |
624 // ----------------------------------------------------------------------------- |
593 // ----------------------------------------------------------------------------- |
625 // |
594 // |
626 void CXnPluginData::SetIsDisplayingPopup ( TBool aVisible, CXnNode* aNode ) |
595 void CXnPluginData::SetIsDisplayingPopup ( TBool aVisible, CXnNode* aNode ) |
627 { |
596 { |
628 |
|
629 if ( aVisible ) |
597 if ( aVisible ) |
630 { |
598 { |
631 iPopupNodes.InsertInAddressOrder( aNode ); |
599 iPopupNodes.InsertInAddressOrder( aNode ); |
632 } |
600 } |
633 else |
601 else |
634 { |
602 { |
635 TInt index( iPopupNodes.Find( aNode ) ); |
603 TInt index( iPopupNodes.Find( aNode ) ); |
|
604 |
636 if ( index != KErrNotFound ) |
605 if ( index != KErrNotFound ) |
637 { |
606 { |
638 iPopupNodes.Remove( index ); |
607 iPopupNodes.Remove( index ); |
639 } |
608 } |
640 } |
609 } |
641 } |
610 } |
642 |
611 |
643 |
|
644 //------------------------------------------------------------------------------ |
612 //------------------------------------------------------------------------------ |
645 // CXnPluginData::IsDisplayingPopup() |
613 // CXnPluginData::IsDisplayingPopup() |
646 // |
614 // |
647 //------------------------------------------------------------------------------ |
615 //------------------------------------------------------------------------------ |
648 // |
616 // |
649 TBool CXnPluginData::IsDisplayingPopup() const |
617 TBool CXnPluginData::IsDisplayingPopup() const |
650 { |
618 { |
651 return ( iPopupNodes.Count() > 0 ); |
619 return ( iPopupNodes.Count() > 0 ); |
652 } |
620 } |
653 |
621 |
654 // ----------------------------------------------------------------------------- |
622 //------------------------------------------------------------------------------ |
655 // CXnPluginData::RunL() |
623 // CXnPluginData::ShowContentRemovedError() |
656 // |
624 // |
657 // ----------------------------------------------------------------------------- |
625 //------------------------------------------------------------------------------ |
658 // |
626 // |
659 /* static */ TInt CXnPluginData::RunL( TAny* aAny ) |
627 void CXnPluginData::ShowContentRemovedError() |
660 { |
628 { |
661 CXnPluginData* self = static_cast< CXnPluginData* >( aAny ); |
629 TRAP_IGNORE( DoShowContentRemovedErrorL() ); |
662 |
630 } |
663 self->iLoader->Cancel(); |
631 |
664 |
632 //------------------------------------------------------------------------------ |
665 RPointerArray< CXnNodeAppIf >list; |
633 // CXnPluginData::DoShowContentRemovedErrorL() |
666 CleanupClosePushL( list ); |
634 // |
667 |
635 //------------------------------------------------------------------------------ |
668 for ( TInt i = 0; i < self->iContentSourceNodes.Count(); i++ ) |
636 // |
669 { |
637 void CXnPluginData::DoShowContentRemovedErrorL() |
670 list.AppendL( &self->iContentSourceNodes[i]->AppIfL() ); |
638 { |
671 } |
639 HBufC* msg( StringLoader::LoadLC( R_QTN_HS_ERROR_WIDGETS_REMOVED ) ); |
672 |
640 |
673 // State is "wait" until data plugins are loaded |
641 CAknErrorNote* note = new ( ELeave ) CAknErrorNote; |
674 self->SetPluginStateL( KStateWaitConfirmation ); |
642 CleanupStack::PushL( note ); |
675 |
643 |
676 TRAPD( err, self->iManager.AppUiAdapter().LoadDataPluginsL( list ) ); |
644 note->ExecuteLD( *msg ); |
677 |
645 |
678 if ( err && self->Removable() ) |
646 CleanupStack::Pop( note ); |
679 { |
647 CleanupStack::PopAndDestroy( msg ); |
680 self->DataPluginsLoadCompletedL( err ); |
648 } |
681 } |
649 |
682 else |
650 //------------------------------------------------------------------------------ |
683 { |
651 // CXnPluginData::ShowOutOfMemErrorL() |
684 self->DataPluginsLoadCompletedL( KErrNone ); |
652 // |
685 } |
653 //------------------------------------------------------------------------------ |
686 |
654 // |
687 CleanupStack::PopAndDestroy( &list ); |
655 void CXnPluginData::ShowOutOfMemError() |
688 |
656 { |
689 return KErrNone; |
657 TRAP_IGNORE( ViewManager().OomSysHandler().HandlePotentialOomL() ); |
690 } |
658 } |
691 |
659 |
692 // End of file |
660 // End of file |