153 // |
153 // |
154 // ---------------------------------------------------------------------------- |
154 // ---------------------------------------------------------------------------- |
155 // |
155 // |
156 void CWrtDataPlugin::Stop( TStopReason aReason ) |
156 void CWrtDataPlugin::Stop( TStopReason aReason ) |
157 { |
157 { |
|
158 iPluginState = EStopped; |
|
159 |
158 if( aReason == EPluginShutdown || |
160 if( aReason == EPluginShutdown || |
159 aReason == ESystemShutdown ) |
161 aReason == ESystemShutdown ) |
160 { |
162 { |
161 TRAP_IGNORE(iData->NotifyPublisherL( KDeActive )); |
163 TRAP_IGNORE(iData->NotifyPublisherL( KDeActive )); |
162 } |
164 } |
163 |
|
164 iStopped = ETrue; |
|
165 } |
165 } |
166 |
166 |
167 // ---------------------------------------------------------------------------- |
167 // ---------------------------------------------------------------------------- |
168 // CWrtDataPlugin::Resume |
168 // CWrtDataPlugin::Resume |
169 // |
169 // |
170 // ---------------------------------------------------------------------------- |
170 // ---------------------------------------------------------------------------- |
171 // |
171 // |
172 void CWrtDataPlugin::Resume( TResumeReason aReason ) |
172 void CWrtDataPlugin::Resume( TResumeReason aReason ) |
173 { |
173 { |
174 if ( aReason == EForeground && !iStopped ) |
174 if ( aReason == EForeground && iPluginState != EStopped ) |
175 { |
175 { |
176 iPluginState = EResume; |
176 iPluginState = EResume; |
177 |
177 |
178 TRAP_IGNORE( iData->NotifyPublisherL( KResume )); |
178 TRAP_IGNORE( iData->NotifyPublisherL( KResume )); |
179 } |
179 } |
263 configurationItemsArr.Append( setting ); |
256 configurationItemsArr.Append( setting ); |
264 } |
257 } |
265 } |
258 } |
266 |
259 |
267 iDataCount = contentItemsArr.Count(); |
260 iDataCount = contentItemsArr.Count(); |
268 |
261 |
269 if ( iDataCount > 0 ) |
262 // Create the content Model |
270 { |
263 HBufC16* contentId = HBufC16::NewLC( |
271 // Create the content Model |
264 KAiContentIdMaxLength + KAiPluginNameMaxLength ); |
272 HBufC16* contentId = HBufC16::NewLC( |
265 |
273 KAiContentIdMaxLength + KAiPluginNameMaxLength ); |
266 iContentModel = new TAiContentItem[iDataCount]; |
|
267 |
|
268 for( TInt i = 0; i < iDataCount; i++ ) |
|
269 { |
|
270 MAiPluginContentItem& contentItem( |
|
271 contentItemsArr[i]->AiPluginContentItem() ); |
274 |
272 |
275 iContentModel = new TAiContentItem[iDataCount]; |
273 iContentModel[i].id = i; |
|
274 if( contentItem.Type() == KText() ) |
|
275 { |
|
276 // text |
|
277 iContentModel[i].type = KAiContentTypeText; |
|
278 } |
|
279 if( contentItem.Type() == KImage() || |
|
280 contentItem.Type() == KAnimation() ) |
|
281 { |
|
282 // image |
|
283 iContentModel[i].type = KAiContentTypeBitmap; |
|
284 } |
276 |
285 |
277 for( TInt i = 0; i < iDataCount; i++ ) |
286 contentId->Des().Copy( contentItem.Name() ); |
278 { |
287 contentId->Des().Delete( 0, |
279 MAiPluginContentItem& contentItem( |
288 contentId->Des().LocateReverse( KPluginNameSeprator ) + 1 ); |
280 contentItemsArr[i]->AiPluginContentItem() ); |
289 |
|
290 TInt sizeOfContentId( contentId->Des().Size()+sizeof( wchar_t ) ); |
|
291 |
|
292 iContentModel[i].cid = |
|
293 static_cast< const wchar_t* >( User::Alloc( sizeOfContentId ) ); |
281 |
294 |
282 iContentModel[i].id = i; |
295 Mem::Copy( ( TAny* )iContentModel[i].cid, |
283 if( contentItem.Type() == KText() ) |
296 contentId->Des().PtrZ(), sizeOfContentId ); |
284 { |
|
285 // text |
|
286 iContentModel[i].type = KAiContentTypeText; |
|
287 } |
|
288 if( contentItem.Type() == KImage() || |
|
289 contentItem.Type() == KAnimation() ) |
|
290 { |
|
291 // image |
|
292 iContentModel[i].type = KAiContentTypeBitmap; |
|
293 } |
|
294 |
|
295 contentId->Des().Copy( contentItem.Name() ); |
|
296 contentId->Des().Delete( 0, |
|
297 contentId->Des().LocateReverse( KPluginNameSeprator ) + 1 ); |
|
298 |
|
299 TInt sizeOfContentId( contentId->Des().Size()+sizeof( wchar_t ) ); |
|
300 |
|
301 iContentModel[i].cid = |
|
302 static_cast< const wchar_t* >( User::Alloc( sizeOfContentId ) ); |
|
303 |
|
304 Mem::Copy( ( TAny* )iContentModel[i].cid, |
|
305 contentId->Des().PtrZ(), sizeOfContentId ); |
|
306 |
|
307 contentId->Des().Delete( 0, contentId->Des().Length() ); |
|
308 } |
|
309 |
297 |
310 CleanupStack::PopAndDestroy( contentId ); |
298 contentId->Des().Delete( 0, contentId->Des().Length() ); |
311 iContent = AiUtility::CreateContentItemArrayIteratorL( |
299 } |
312 iContentModel, iDataCount ); |
300 |
313 |
301 CleanupStack::PopAndDestroy( contentId ); |
314 // Configurations |
302 iContent = AiUtility::CreateContentItemArrayIteratorL( |
315 iData->ConfigureL( configurationItemsArr ); |
303 iContentModel, iDataCount ); |
316 |
304 |
317 iPluginState = ESuspend; |
305 // Configurations |
318 |
306 iData->ConfigureL( configurationItemsArr ); |
319 // Register for notifications |
307 |
320 iData->RegisterL(); |
308 // Register for notifications |
321 |
309 iData->RegisterL(); |
322 // Activate the publisher |
310 |
323 iData->NotifyPublisherL( KActive ); |
311 // Activate the publisher |
324 } |
312 iData->NotifyPublisherL( KActive ); |
325 |
313 |
326 contentItemsArr.Reset(); |
314 contentItemsArr.Reset(); |
327 configurationItemsArr.Reset(); |
315 configurationItemsArr.Reset(); |
328 // We own the array so destroy it |
316 // We own the array so destroy it |
329 aSettings.ResetAndDestroy(); |
317 aSettings.ResetAndDestroy(); |
373 // |
361 // |
374 // ---------------------------------------------------------------------------- |
362 // ---------------------------------------------------------------------------- |
375 // |
363 // |
376 TBool CWrtDataPlugin::IsActive() const |
364 TBool CWrtDataPlugin::IsActive() const |
377 { |
365 { |
378 return iPluginState == EResume && !iStopped; |
366 return iPluginState == EResume; |
|
367 } |
|
368 |
|
369 // ---------------------------------------------------------------------------- |
|
370 // CWrtDataPlugin::IsStopped |
|
371 // |
|
372 // ---------------------------------------------------------------------------- |
|
373 // |
|
374 TBool CWrtDataPlugin::IsStopped() const |
|
375 { |
|
376 return iPluginState == EStopped; |
379 } |
377 } |
380 |
378 |
381 // ---------------------------------------------------------------------------- |
379 // ---------------------------------------------------------------------------- |
382 // CWrtDataPlugin::Data |
380 // CWrtDataPlugin::Data |
383 // |
381 // |