// ---------------------------------------------------------------------------
// CThumbnailAudioProvider::GetThumbnailL()
// Provides the thumbnail image
// ---------------------------------------------------------------------------
//
void CThumbnailAudioProvider::GetThumbnailL( RFs& aFs, RFile64& aFile, const
    TDataType& aMimeType  , const CThumbnailManager::TThumbnailFlags aFlags,
    const TDisplayMode /*aDisplayMode*/, const CThumbnailManager::TThumbnailQualityPreference /*aQualityPreference*/  )
    {   
    TN_DEBUG1( "CThumbnailAudioProvider::GetThumbnailL() - rfile " );
    OstTrace0( TRACE_NORMAL, CTHUMBNAILAUDIOPROVIDER_GETTHUMBNAILL, "CThumbnailAudioProvider::GetThumbnailL - rfile" );
    CMetaDataUtility* metaDataUtil = CMetaDataUtility::NewL();
    CleanupStack::PushL( metaDataUtil );
    
    RArray<TMetaDataFieldId> wantedFields;
    CleanupClosePushL(wantedFields);
    wantedFields.AppendL(EMetaDataJpeg);
    
    metaDataUtil->OpenFileL(aFile, wantedFields, aMimeType.Des8());
    const CMetaDataFieldContainer& metaCont = metaDataUtil->MetaDataFieldsL();
    TPtrC8 ptr = metaCont.Field8( EMetaDataJpeg );
    HBufC8* data = ptr.AllocL();
    
    CleanupStack::PopAndDestroy(&wantedFields);
    CleanupStack::PopAndDestroy(metaDataUtil);
    CleanupStack::PushL( data );
    
    if(data->Length() == 0)
      {
      User::Leave( KErrNotFound );            
      }
    
    if ( !iImageDecoderv3 )
        {
        iImageDecoderv3 = new( ELeave )CThumbnailImageDecoderv3( aFs );
        }
    
    iMimeType = TDataType(KJpegMime);
    iFlags = aFlags;
	//set default mode displaymode from global constants
    iDisplayMode = KStoreDisplayMode;
    TRAPD( err, iImageDecoderv3->CreateL( data, *iObserver, iFlags, iMimeType, iTargetSize ) );
    if (err == KErrNone)
        {
        CleanupStack::Pop( data );
        }
    else
        {
        // this is because data buffer is already released in CreateDecoderL
        // and we must prevent automatic PopAndDestroy
        CleanupStack::Pop( data );
        User::Leave(err);
        } 
    
    iOriginalSize = iImageDecoderv3->OriginalSize();
    iImageDecoderv3->DecodeL( iDisplayMode );
    }
TInt Cdmatest::UpdateLeafL( CStifItemParser& aItem )	
	{

    TInt ret( KErrNone );
    // Print to UI
    TestModuleIf().Printf( 0, _L("Cdmatest"), _L("UpdateLeafL") );

    TPtrC8 nodename( GetNextStringLC ( aItem, _L("Node name") )->Des() ) ;
    TPtrC8 data (GetNextStringLC( aItem, _L("datafile"))->Des() );
    
	HBufC8 *mime = GetNextStringLC( aItem, _L("mime") ) ;
    SetURIL( nodename );
    
    TPtrC8 parentURI(RemoveLastSeg(nodename));
    HBufC8 *luid = GetLuidAllocLC( parentURI );
    
    TDataType type; 

	TPtrC8 mimePtr( *mime == KNullDesC8 ? type.Des8() : mime->Des() );

    /**
    virtual void UpdateLeafObjectL( const TDesC8& aURI, const TDesC8& aLUID,
									const TDesC8& aObject, const TDesC8& aType,
									TInt aStatusRef ) = 0;
    */
    
	Adapter()->UpdateLeafObjectL( *iURI , *luid, data, mimePtr, 3);

	if ( iStatus == MSmlDmAdapter::EOk )
	{
		iLog->Log( _L("UpdateLeafL: UpdateLeafObjectL Successful! %d" ), iStatus );	
	}
	else
	{
		iLog->Log( _L("UpdateLeafL UpdateLeafObjectL Error ! %d" ), iStatus );	
		ret = KErrGeneral ;
	}

	CleanupStack::PopAndDestroy(); // loadfile
	CleanupStack::PopAndDestroy(); // luid
	CleanupStack::PopAndDestroy(); // mime
	CleanupStack::PopAndDestroy(); // nodename

	iLog->Log( _L("UpdateLeafL Test Complete with status %d" ), ret );	

    return ret;
	}	
/**
   @SYMTestCaseID T-RApaLsSessionTestStep-TestServiceDiscovery26
  
   @SYMPREQ 538
   
   @SYMTestPriority  High
  
   @SYMTestStatus Implemented
  
   @SYMTestCaseDesc Test the functionality ofAppForDocumentAndService given a file, service uid,file server and undefined file name 
   
   @SYMTestActions  Call AppForDocumentAndService with two parameters: a filename, a service uid, an
   app uid and the datatype requested
   on z: drive.\n
   API Calls:\n	
   RApaLsSession::AppForDocumentAndService(const TDesC& aFileName, TUid aServiceUid, TUid& aAppUid, TDataType& aDataType) const
   
   @SYMTestExpectedResults Returns KErrBadHandle. The app uid is set to null, the uid of datatype is set to null
    
 */	
void CT_ServicesTestStep::TestServiceDiscovery26()
	{
	INFO_PRINTF1(_L("TestServiceDiscovery26 about to start..."));
	const TUid KUidService = {0x01020304};
	TInt ret(0);
	TUid appUid=KNullUid;
	TDataType dataType;
	RFile file;
	_LIT(KOneByteFileName, "z:\\system\\data\\imaginary_byte.txt");
	RFs fs;
	ret = fs.Connect();
	ret = fs.ShareProtected();
	ret = file.Open(fs, KOneByteFileName, EFileRead|EFileShareAny);
	TEST(ret==KErrNotFound);
	ret = iApaLsSession.AppForDocumentAndService(file, KUidService, appUid, dataType);
	TEST(appUid==KNullUid);
	TEST(dataType.Des8().Length()==0);
	TEST(ret==KErrBadHandle);	
	fs.Close();

	}