diff -r 1b207dd38b72 -r ace62b58f4b2 idlefw/plugins/sapidataplugin/src/sapidataplugin.cpp --- a/idlefw/plugins/sapidataplugin/src/sapidataplugin.cpp Tue May 25 13:01:39 2010 +0300 +++ b/idlefw/plugins/sapidataplugin/src/sapidataplugin.cpp Wed Jun 09 10:01:25 2010 +0300 @@ -149,7 +149,7 @@ } // --------------------------------------------------------------------------- -// Publish a specific text of the widget +// Publish a specific text to the widget // --------------------------------------------------------------------------- // void CSapiDataPlugin::PublishTextL(MAiContentObserver* aObserver, @@ -174,7 +174,7 @@ } // --------------------------------------------------------------------------- -// Publish a specific image of the widget +// Publish a specific image to the widget // --------------------------------------------------------------------------- // void CSapiDataPlugin::PublishImageL(MAiContentObserver* aObserver, @@ -270,11 +270,11 @@ } // --------------------------------------------------------------------------- -// Publish a image of the widget +// Publish a image to the widget // --------------------------------------------------------------------------- // void CSapiDataPlugin::PublishImageL(MAiContentObserver* aObserver, - TInt& aContentId, TInt aHandle, TInt aMaskHandle ) + TInt& aContentId, TInt aHandle, TInt aMaskHandle ) { if ( aObserver->CanPublish( *this, aContentId , aContentId ) ) { @@ -303,7 +303,20 @@ aObserver->Clean( *this, aContentId, aContentId ); } } - } + } + } + +// --------------------------------------------------------------------------- +// Publish a data to the widget +// --------------------------------------------------------------------------- +// +void CSapiDataPlugin::PublishData( MAiContentObserver* aObserver, + TInt& aContentId, const TDesC8& aData ) + { + if ( aObserver->CanPublish( *this, aContentId, aContentId ) ) + { + aObserver->Publish( *this, aContentId, aData, aContentId ); + } } // --------------------------------------------------------------------------- @@ -342,6 +355,10 @@ { return KImage(); } + else if ( iContentModel[i].type == KAiContentTypeData ) + { + return KData(); + } } } @@ -570,15 +587,11 @@ // void CSapiDataPlugin::ConfigureL( RAiSettingsItemArray& aSettings ) { - if ( iDataCount > 0 ) - { - // We own the array so destroy it - aSettings.ResetAndDestroy(); - return; - } + RAiSettingsItemArray contentItemsArr; + CleanupClosePushL( contentItemsArr ); - RAiSettingsItemArray contentItemsArr; RAiSettingsItemArray configurationItemsArr; + CleanupClosePushL( configurationItemsArr ); TInt count( aSettings.Count() ); @@ -598,68 +611,67 @@ iDataCount = contentItemsArr.Count(); - if ( iDataCount > 0 ) + // Create the content Model + HBufC* contentId = HBufC::NewLC( + KAiContentIdMaxLength + KAiPluginNameMaxLength ); + + iContentModel = new TAiContentItem[iDataCount]; + + for ( TInt i = 0; i < iDataCount; i++ ) { - // Create the content Model - HBufC* contentId = HBufC::NewLC( - KAiContentIdMaxLength + KAiPluginNameMaxLength ); + MAiPluginContentItem& contentItem( + contentItemsArr[i]->AiPluginContentItem() ); + + iContentModel[i].id = i; - iContentModel = new TAiContentItem[iDataCount]; + const TDesC& type( contentItem.Type() ); - for ( TInt i = 0; i < iDataCount; i++ ) + if ( type == KText() || type == KNewsTicker() || + type == KTextEditor() ) { - MAiPluginContentItem& contentItem( - contentItemsArr[i]->AiPluginContentItem() ); - - iContentModel[i].id = i; - - if( contentItem.Type() == KText() || - contentItem.Type() == KNewsTicker() || - contentItem.Type() == KTextEditor() ) - { - // text - iContentModel[i].type = KAiContentTypeText; - } - if( contentItem.Type() == KImage() ) - { - // image - iContentModel[i].type = KAiContentTypeBitmap; - } + // text + iContentModel[i].type = KAiContentTypeText; + } + else if ( type == KImage() ) + { + // image + iContentModel[i].type = KAiContentTypeBitmap; + } + else if ( type == KData() ) + { + // data stream + iContentModel[i].type = KAiContentTypeData; + } + + contentId->Des().Copy( contentItem.Name() ); + contentId->Des().Delete( 0, + contentId->Des().LocateReverse( KPluginNameSeprator ) + 1 ); + + TInt sizeOfContentId( contentId->Des().Size() + sizeof( wchar_t ) ); + + iContentModel[i].cid = + static_cast< const wchar_t* >( User::Alloc( sizeOfContentId ) ); - contentId->Des().Copy( contentItem.Name() ); - contentId->Des().Delete( 0, - contentId->Des().LocateReverse( KPluginNameSeprator ) + 1 ); - - TInt sizeOfContentId( contentId->Des().Size() + sizeof( wchar_t ) ); - - iContentModel[i].cid = - static_cast< const wchar_t* >( User::Alloc( sizeOfContentId ) ); - - Mem::Copy( ( TAny* )iContentModel[i].cid, - contentId->Des().PtrZ(), sizeOfContentId ); - - contentId->Des().Delete( 0, contentId->Des().Length() ); - } + Mem::Copy( ( TAny* )iContentModel[i].cid, + contentId->Des().PtrZ(), sizeOfContentId ); - CleanupStack::PopAndDestroy( contentId ); + contentId->Des().Delete( 0, contentId->Des().Length() ); + } + + CleanupStack::PopAndDestroy( contentId ); - iContent = AiUtility::CreateContentItemArrayIteratorL( - iContentModel, iDataCount ); - - iData->SetContentIdL( PublisherInfo().Namespace() ); - - // Configurations - iData->ConfigureL( configurationItemsArr ); + iContent = AiUtility::CreateContentItemArrayIteratorL( + iContentModel, iDataCount ); - // Listen the publisher content update - iData->RegisterContentObserverL(); - } + iData->SetContentIdL( PublisherInfo().Namespace() ); - contentItemsArr.Reset(); - configurationItemsArr.Reset(); - - // We own the array so destroy it - aSettings.ResetAndDestroy(); + // Configurations + iData->ConfigureL( configurationItemsArr ); + + // Listen the publisher content update + iData->RegisterContentObserverL(); + + CleanupStack::PopAndDestroy( 2, &contentItemsArr ); // configurationItemsArr } // ---------------------------------------------------------------------------- @@ -720,6 +732,16 @@ } // ---------------------------------------------------------------------------- +// CSapiDataPlugin::IsStopped +// +// ---------------------------------------------------------------------------- +// +TBool CSapiDataPlugin::IsStopped() const + { + return iPluginState == EStopped; + } + +// ---------------------------------------------------------------------------- // CSapiDataPlugin::Data // // ---------------------------------------------------------------------------- @@ -740,3 +762,4 @@ } // End of file +