harvester/harvesterplugins/AudioPlugin/inc/harvesteraudioplugin.h
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 25 May 2010 13:10:05 +0300
branchRCL_3
changeset 27 4a4892eec172
parent 19 82c0024438c8
child 47 b73252188534
permissions -rw-r--r--
Revision: 201019 Kit: 2010121

/*
* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). 
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:
*
*/


#ifndef HARVESTERAUDIOPLUGIN_H
#define HARVESTERAUDIOPLUGIN_H

#include <harvesterplugin.h>
#include <thumbnailmanager.h>
#include <thumbnailmanagerobserver.h>

#include "harvesteraudiopluginutils.h"
#include "mdeobjectwrapper.h"

// FORWARD DECLARATION
class CMdEObjectDef;
class CHarvestData;
class MThumbnailData;

/**
 * Helper class to hold all property definitions 
 * (pointers are not owned) used in harvester audio plug-in.
 */
class CHarvesterAudioPluginPropertyDefs : public CBase
	{
	public:
		// Common property definitions
		CMdEPropertyDef* iCreationDatePropertyDef;
		CMdEPropertyDef* iLastModifiedDatePropertyDef;
		CMdEPropertyDef* iSizePropertyDef;
		CMdEPropertyDef* iItemTypePropertyDef;
		CMdEPropertyDef* iTitlePropertyDef;
		CMdEPropertyDef* iTimeOffsetPropertyDef;

		// Media property definitions	
		CMdEPropertyDef* iRatingPropertyDef;
		CMdEPropertyDef* iGenrePropertyDef;
		CMdEPropertyDef* iArtistPropertyDef;
		CMdEPropertyDef* iDurationPropertyDef;
		CMdEPropertyDef* iCopyrightPropertyDef;
		CMdEPropertyDef* iThumbnailPropertyDef;
		CMdEPropertyDef* iDatePropertyDef;
		CMdEPropertyDef* iDrmPropertyDef;
		CMdEPropertyDef* iDefaultFolderPropertyDef;

		// Audio property definitions
		CMdEPropertyDef* iAlbumPropertyDef;
		CMdEPropertyDef* iComposerPropertyDef;		
		CMdEPropertyDef* iOriginalArtistPropertyDef;
		CMdEPropertyDef* iTrackPropertyDef;

	private:
		CHarvesterAudioPluginPropertyDefs();
	
		void ConstructL(CMdEObjectDef& aObjectDef);

	public:	
		static CHarvesterAudioPluginPropertyDefs* NewL(CMdEObjectDef& aObjectDef);
	};

class CHarvesterAudioPlugin : public CHarvesterPlugin,
                                            public MThumbnailManagerObserver
	{
	public:
		/**
		* Construction
		* @return Harvester audio plugin
		*/
		static CHarvesterAudioPlugin* NewL();

		/**
		* Destruction
		*/
		virtual ~CHarvesterAudioPlugin();

    private:
		// Default constructor
		CHarvesterAudioPlugin();
		
		// 2nd phase constructor
		void ConstructL();
    
    
    
    public: // from CHarvesterPlugin
    
		/**
		* Harvesting multiple files
		* @param aHarvesterData  CHarvesterData datatype containing needed harvest data
 		* @return None
		*/
		void HarvestL( CHarvesterData* aHD );

    public: // from Thumbnail Observer
		
	    void ThumbnailPreviewReady( MThumbnailData& aThumbnail,
	        TThumbnailRequestId aId );
	    
	    void ThumbnailReady( TInt aError, MThumbnailData& aThumbnail,
	        TThumbnailRequestId aId );

    protected: // from CHarvesterPlugin
	    
	    void GetMimeType( const TDesC& aUri, TDes& aMimeType );
	    
	private:
	     
		/**
		* Harvesting multiple files
		* @param aHarvesterData  CHarvesterData datatype containing needed harvest data
 		* 
		*/
		void DoHarvestL( CHarvesterData* aHD );

		/**
		 * Handles creation of new mde objects.
		 */
		void GetPropertiesL( CHarvesterData* aHarvesterData, TBool aIsAdd );
		 		
		/**
		 * Get placeholder properties (creation time, modify time and file size).
		 */
        void GetPlaceHolderPropertiesL( CHarvesterData* aHD, TBool aIsAdd );
		
		/**
		 * Get media file mime type (eg. "audio/mp3").
		 */
        const TMimeTypeMapping<TAudioMetadataHandling>* GetMimeTypePropertyL( 
        		CHarvesterData* aHD, TBool aIsAdd );

		/**
		 * Get song name, artist, album, genre and composer from normal music
         * file (eg. mp3).
		 */
        void GetMusicPropertiesL( CHarvesterData* aHD, TBool aIsAdd, TPtrC aMimeType );

	private:
		CAudioMDParser* iAudioParser;
		
		CHarvesterAudioPluginPropertyDefs* iPropDefs;
		
		CThumbnailManager* iTNM;
		TBool iHarvestAlbumArt;
		
		TInt iMaxTextLength;
		
		HBufC* iPhoneSoundsPath;
		HBufC* iMmcSoundsPath;
	};


#endif  // HARVESTERAUDIOPLUGIN_H