mmserv/metadatautility/Src/MetaDataSourceFile.h
changeset 0 71ca22bcf22a
equal deleted inserted replaced
-1:000000000000 0:71ca22bcf22a
       
     1 /*
       
     2 * Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  This class implements the interface specified in CMetaDataSource
       
    15 *				 when audio source is from a file.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 #ifndef CMETADATASOURCEFILE_H
       
    22 #define CMETADATASOURCEFILE_H
       
    23 
       
    24 // INCLUDES
       
    25 #include <caf/content.h>
       
    26 #include <caf/data.h>
       
    27 #include "MetaDataSource.h"
       
    28 
       
    29 using namespace ContentAccess;
       
    30 // CLASS DECLARATION
       
    31 
       
    32 /**
       
    33 *  This class implements the interface specified in CMetaDataSource
       
    34 *  when audio source is from a file.
       
    35 *
       
    36 *  @lib MetaDataUtility.lib
       
    37 *  @since 3.0
       
    38 */
       
    39 class CMetaDataSourceFile : public CMetaDataSource
       
    40 	{
       
    41     public:  // Constructors and destructor
       
    42 
       
    43         /**
       
    44         * Two-phased constructor.
       
    45 		* @param aFileName The name of the file
       
    46 		* @return A pointer to a new instance of this class
       
    47         */
       
    48         static CMetaDataSourceFile* NewL( const TDesC& aFileName );
       
    49         
       
    50         /**
       
    51         * Two-phased constructor.
       
    52 		* @param aFile File handle
       
    53 		* @return A pointer to a new instance of this class
       
    54         */
       
    55         static CMetaDataSourceFile* NewL( RFile& aFile );
       
    56 
       
    57         /**
       
    58         * Destructor.
       
    59         */
       
    60         virtual ~CMetaDataSourceFile();
       
    61 
       
    62     public: // Functions from base classes
       
    63 
       
    64         /**
       
    65         * Reads sufficient data from the source to fill the specified 8-bit descriptor
       
    66         * up to its maximum length.
       
    67         * @since 3.0
       
    68         * @param aDes Contains the data that was read
       
    69 		* @param aLength How many bytes will be read
       
    70         * @return KErrNone, or one of the systemwide error codes.
       
    71 		*/
       
    72 		void ReadL( TDes8& aDes );
       
    73 
       
    74         /**
       
    75         * Reads data of specified length from the source into the specified 8-bit descriptor.
       
    76         * @since 3.0
       
    77         * @param aDes Contains the data that was read. Note that the descriptor
       
    78 		*        length must be at least aLength!
       
    79 		* @param aLength How many bytes will be read
       
    80         * @return KErrNone, or one of the systemwide error codes.
       
    81 		*/
       
    82 		void ReadL( TDes8& aDes, TInt aLength );
       
    83 
       
    84         /**
       
    85         * Reads data from specified position in the source into the specified 8-bit descriptor
       
    86         * up to its maximum length.
       
    87         * @since 3.0
       
    88         * @param aPos Offset from current position
       
    89 		* @param aDes Contains the data that was read
       
    90         * @return KErrNone, or one of the systemwide error codes.
       
    91 		*/
       
    92 		void ReadL( TInt aPos, TDes8& aDes );
       
    93 
       
    94         /**
       
    95         * Reads data from specified position in the source into the specified 8-bit descriptor
       
    96         * up to its maximum length.
       
    97         * @since 3.0
       
    98         * @param aPos Offset from current position
       
    99 		* @param aDes Contains the data that was read
       
   100 		* @param aLength How many bytes will be read
       
   101         * @return KErrNone, or one of the systemwide error codes.
       
   102 		*/
       
   103 		void ReadL( TInt aPos, TDes8& aDes, TInt aLength );
       
   104 
       
   105         /**
       
   106         * Size of the source in bytes.
       
   107         * @since 3.0
       
   108         * @param aSize On return, the size is stored here.
       
   109         * @return KErrNone, or one of the systemwide error codes.
       
   110 		*/
       
   111 		TInt Size( TInt& aSize ) const;
       
   112 
       
   113 		/**
       
   114         * Positions the file pointer to aPos.
       
   115         * @since 3.0
       
   116         * @param aMode seek modes from TSeek
       
   117         * @param aPos position to seek
       
   118         * @return KErrNone, or one of the systemwide error codes.
       
   119 		*/
       
   120 		TInt Seek(TSeek aMode,TInt& aPos) const;
       
   121 		
       
   122 		/**
       
   123         * Is the file DRM protected
       
   124         * @since 3.0
       
   125         * @return ETrue if DRM protected, EFalse otherwise
       
   126 		*/
       
   127 		TBool FileProtected() const;
       
   128 		
       
   129 		/**
       
   130         * Does the file have play rights?
       
   131         * @since 3.0
       
   132         * @return ETrue if file has play rights, EFalse otherwise
       
   133 		*/
       
   134 		TBool CanPlay() const;
       
   135 	
       
   136 		/**
       
   137         * Whats the DRM Type?
       
   138         * @since 3.0
       
   139         * @return ETrue if file has play rights, EFalse otherwise
       
   140 		*/
       
   141 		TInt DrmType() const;
       
   142 		
       
   143 		/**
       
   144         * Does the file have play rights?
       
   145         * @since 3.0
       
   146         * @param aAttribute the attribute to get
       
   147         * @param aValue the value on return
       
   148         * @return KErrNone, or one of the systemwide error codes.
       
   149 		*/
       
   150 		TInt GetStringAttribute(TInt aAttribute, TDes& aValue) const;
       
   151   
       
   152 		TInt GetAttributeL(TInt aAttribute, HBufC8** aValue);
       
   153 
       
   154 		
       
   155 		/**
       
   156         * Return a pointer to the CAF data 
       
   157         * @since 3.0
       
   158         * @return CData pointer
       
   159 		*/
       
   160 		ContentAccess::CData* DataPtr();
       
   161 		
       
   162 		/**
       
   163         * Returns iFileName to caller 
       
   164         * @since 3.2
       
   165         * @return TDesC&
       
   166 		*/
       
   167 		TDesC8& FileName();	
       
   168 		
       
   169 		/**
       
   170         * Returns iFileHandler to caller 
       
   171         * @since 3.2
       
   172         * @return RFile
       
   173 		*/
       
   174 		RFile FileHandler();	
       
   175 		
       
   176 		/**
       
   177         * Allows caller to set iRFile
       
   178         * @since 3.2
       
   179         * @return void
       
   180 		*/
       
   181 		void SetFileHandler(RFile aRFile);		
       
   182 		
       
   183 		/**
       
   184         * Returns boolean value for iIsFileHandle
       
   185         * @since 3.2
       
   186         * @return TBool
       
   187 		*/
       
   188 		TBool IsFileHandler();	
       
   189 		
       
   190 		/**
       
   191         * Allows caller to set boolean iIsFileHandler
       
   192         * @since 3.2
       
   193         * @return void
       
   194 		*/
       
   195 		void SetIsFileHandler(TBool aIsFileHandler);
       
   196 		
       
   197 		/**
       
   198         * Does the file have any rights?
       
   199         * @since 3.2
       
   200         * @return ETrue if file has any rights, EFalse otherwise
       
   201 		*/
       
   202 		TBool KeyExist() const;
       
   203 						
       
   204 				
       
   205 	private:
       
   206 
       
   207         /**
       
   208         * C++ default constructor.
       
   209         */
       
   210 		CMetaDataSourceFile();
       
   211 
       
   212         /**
       
   213         * By default Symbian 2nd phase constructor is private.
       
   214         */
       
   215 		void ConstructL( const TDesC& aFileName );
       
   216 		
       
   217 		/**
       
   218         * By default Symbian 2nd phase constructor is private.
       
   219         */
       
   220 		void ConstructL( RFile& aFile );
       
   221 		
       
   222 		/**
       
   223         * Gets Source Attributes, used by ConstructL
       
   224         */
       
   225 		void GetSourceAttributesL();
       
   226 
       
   227  	private:	// Data
       
   228 
       
   229 		// full path name of the file
       
   230 		TBuf8<256> iFileName;
       
   231 		// RFile file handler
       
   232 		RFile iFileHandler;	
       
   233 		// Is File Handler
       
   234 		TBool iIsFileHandler;	
       
   235 		// pointer to CAF content 
       
   236 		CContent *iContent;
       
   237 		// pointer to CAF Data
       
   238 		CData *iData;
       
   239 		// DRM protected or not
       
   240 		TBool iProtected;
       
   241 		// Play rights or not
       
   242 		TBool iCanPlay;
       
   243 		// DRM Type
       
   244 		TInt iDRMType;
       
   245 		// Key exist or not
       
   246 		TBool iKeyExist;
       
   247 	};
       
   248 
       
   249 #endif      // CMETADATASOURCE_H
       
   250 
       
   251 // End of File