msg_plat/messaging_media_resolver_api/inc/MsgMediaInfo.h
changeset 31 ebfee66fde93
child 36 844a5921f85b
equal deleted inserted replaced
30:6a20128ce557 31:ebfee66fde93
       
     1 /*
       
     2 * Copyright (c) 2005 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:  
       
    15 *           Messaging Media Info class.
       
    16 *           Containing detailed information about (media) files.
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 
       
    22 #ifndef __MSGMEDIAINFO_H
       
    23 #define __MSGMEDIAINFO_H
       
    24 
       
    25 // INCLUDES
       
    26 
       
    27 #include <e32std.h>
       
    28 #include <e32base.h> // CBase
       
    29 #include <f32file.h>
       
    30 #include <apmstd.h>
       
    31 
       
    32 #include <MsgMedia.hrh>
       
    33 
       
    34 // CONSTANTS
       
    35 
       
    36 // MACROS
       
    37 
       
    38 // FORWARD DECLARATIONS
       
    39 
       
    40 class TDataType;
       
    41 class CDRMHelper;
       
    42 
       
    43 // DATA TYPES
       
    44 
       
    45 // FUNCTION PROTOTYPES
       
    46 
       
    47 // CLASS DECLARATION
       
    48 
       
    49 /**
       
    50 *
       
    51 */
       
    52 class MMediaInfoObserver
       
    53     {
       
    54     public:
       
    55         
       
    56         /**
       
    57         *
       
    58         */
       
    59         virtual void MediaInfoParsed() = 0;
       
    60     };
       
    61 
       
    62 /**
       
    63 * Base class for different media type info classes.
       
    64 *
       
    65 * @lib MsgMedia.lib
       
    66 * @since 3.1
       
    67 */
       
    68 NONSHARABLE_CLASS( CMsgMediaInfo ) : public CActive
       
    69     {
       
    70     public:  // New methods
       
    71 
       
    72         /**
       
    73         * Factory method that creates this object.
       
    74         *
       
    75         * @param    aFile       IN File handle to create info class from.
       
    76         * @param    aMimeType   IN Mime type of the file.
       
    77         * @param    aMediaType  IN Media type of the file.
       
    78         * @return   pointer to instance
       
    79         */
       
    80         IMPORT_C static CMsgMediaInfo* NewL(
       
    81             RFile& aFile, 
       
    82             TDataType& aMimeType,
       
    83             TMsgMediaType aMediaType );
       
    84 
       
    85         /**
       
    86         * Destructor
       
    87         */
       
    88         virtual ~CMsgMediaInfo();
       
    89 
       
    90         /**
       
    91         * Fills data structure with basic file information & media information.
       
    92         *
       
    93         * @param    aFile       IN File handle to create info class from.
       
    94         * @leave    Leaves with "KErrAbort" if object is deleted while
       
    95         *           ParseFileInformationL is not yet ready. (Might happen e.g. with
       
    96         *           video and audio files.)
       
    97         * @leave    Leaves if opening file fails. See RFile::Open().
       
    98         */
       
    99         IMPORT_C void ParseInfoDetails( RFile& aFile, CDRMHelper& aDRMHelper, MMediaInfoObserver& aObserver );
       
   100 
       
   101         /**
       
   102         * Deprecated.
       
   103         *
       
   104         * Use non-leaving ParseInfoDetails(...) instead.
       
   105         */
       
   106         IMPORT_C void ParseInfoDetailsL( RFile& aFile, CDRMHelper& aDRMHelper, MMediaInfoObserver& aObserver );
       
   107 
       
   108         /**
       
   109         * Updates file info for existing media info.
       
   110         *
       
   111         * Does not resolve the media information again! Only updates
       
   112         * basic file information (name, size, etc).
       
   113         *
       
   114         * @param    aFile       IN New file handle for existing media info.
       
   115         */
       
   116         IMPORT_C void SetFileL( RFile& aFile );
       
   117 
       
   118         /**
       
   119         * A convenience function for checking whether the media content was 
       
   120         * corrupt. This method should be called only after ParseInfoDetailsL.
       
   121         * Just maps certain error codes (iParseError) to corrupt.
       
   122         *
       
   123         * @return ETrue, if media content is corrupt,
       
   124         *         EFalse, if media content is not corrupt,
       
   125         *                 or media content is not parsed.
       
   126         */
       
   127         IMPORT_C TBool Corrupt() const;
       
   128         
       
   129         /**
       
   130         * Get full file path.
       
   131         *
       
   132         * @return   Full path with file name. Can be "null descriptor"!
       
   133         */    
       
   134         inline TPtrC FullFilePath() const;
       
   135         
       
   136         /**
       
   137         * Get file size.
       
   138         *
       
   139         * @return   Size of the file this ínformation was created from.
       
   140         */
       
   141         inline TInt FileSize() const;
       
   142 
       
   143         /**
       
   144         * Get access time of file.
       
   145         *
       
   146         * @param    aTime   OUT Modification time of the file this ínformation was created from.
       
   147         */
       
   148         inline void ModificationTime( TTime& aTime ) const;
       
   149 
       
   150         /**
       
   151         * Get mime type
       
   152         *
       
   153         * @return   Mime type of the file this ínformation was created of.
       
   154         */
       
   155         inline TPtrC8 MimeType() const;
       
   156 
       
   157         /**
       
   158         * Get media type
       
   159         *
       
   160         * @return   media type of the file this ínformation was created of.
       
   161         */
       
   162         inline TMsgMediaType MediaType() const;
       
   163 
       
   164         /**
       
   165         * Get protection flags.
       
   166         *
       
   167         * @return   Protection flags as defined in MmsMedia.h
       
   168         */
       
   169         inline TUint32 Protection() const;
       
   170 
       
   171         /**
       
   172         * Set protection flags.
       
   173         * Normally set by CMsgMediaResolver.
       
   174         *
       
   175         * @param    aProtection Protection flags as defined in FileProtectionResolver.h
       
   176         */
       
   177         inline void SetProtection( TUint32 aProtection );
       
   178 
       
   179         /**
       
   180         * Get DRM Content URI.
       
   181         *
       
   182         * @return   Pointer to DRM Content URI,
       
   183         *           NULL if not defined.
       
   184         */
       
   185         inline HBufC8* DRMContentURI() const;
       
   186 
       
   187         /**
       
   188         * Set DRM Content URI.
       
   189         * Normally set by CMmsMediaResolver.
       
   190         *
       
   191         * @param    aContentURI Pointer to DRM Content URI.
       
   192         *           Takes ownership.
       
   193         */
       
   194         inline void SetDRMContentURI( HBufC8* aContentURI );
       
   195 
       
   196         /**
       
   197         * Get duration.
       
   198         *
       
   199         * @return   Duration of an object in milliseconds.
       
   200         */
       
   201         inline TInt Duration() const;
       
   202     
       
   203         /**
       
   204         * Get handler application UID.
       
   205         *
       
   206         * @return   UID of the handler application,
       
   207         *           KNullUid if no handler found.
       
   208         */
       
   209         inline TUid HandlerApplicationUid() const;
       
   210     
       
   211         /**
       
   212         * Set handler application UID.
       
   213         * Normally set by CMmsMediaResolver.
       
   214         *
       
   215         * @param    aHandlerAppUid  UID of the handler application,
       
   216         *                           KNullUid if no handler found.
       
   217         */
       
   218         inline void SetHandlerApplicationUid( TUid aHandlerAppUid );
       
   219 
       
   220         /**
       
   221         * Get "Parsed" flag.
       
   222         *
       
   223         * @return   ETrue,  if all media info is successfully resolved,
       
   224         *           EFalse, otherwise (e.g. ParseFileInformationL is not
       
   225         *                   called or an error happened during 
       
   226         *                   ParseFileInformationL).
       
   227         */
       
   228         inline TBool Parsed() const;
       
   229         
       
   230         /**
       
   231         * Get parsing error code.
       
   232         *
       
   233         * @return   ETrue,  if all media info is successfully resolved,
       
   234         *           EFalse, otherwise (e.g. ParseFileInformationL is not
       
   235         *                   called or an error happened during 
       
   236         *                   ParseFileInformationL).
       
   237         */
       
   238         inline TInt ParseError() const;
       
   239         
       
   240     protected: // From base classes
       
   241 
       
   242         /**
       
   243         * From CActive
       
   244         */
       
   245     	void DoCancel();
       
   246         
       
   247         /**
       
   248         * From CActive
       
   249         */
       
   250     	void RunL();
       
   251 	
       
   252         /**
       
   253         * From CActive
       
   254         */
       
   255     	TInt RunError( TInt aError );
       
   256 	
       
   257     protected:
       
   258         
       
   259         /**
       
   260         * Constructor.
       
   261         *
       
   262         * @param    aMimeType   IN Mime type of the file.
       
   263         * @param    aMediaType  IN Media type of the file.
       
   264         */
       
   265         CMsgMediaInfo( TDataType& aMimeType, TMsgMediaType aMediaType );
       
   266 
       
   267         /**
       
   268         * 2nd phase constructor.
       
   269         *
       
   270         * @param    aFileName   IN File name to create info class from.
       
   271         */
       
   272         void ConstructL( RFile& aFile );
       
   273 
       
   274         /**
       
   275         * Complete self.
       
   276         */
       
   277         void CompleteSelf( TInt aError );
       
   278 
       
   279         /**
       
   280         * Complete observer.
       
   281         */
       
   282         void CompleteObserver();
       
   283 
       
   284         /**
       
   285         * Freezes DRM rights (with "Consume API") if needed.
       
   286         */
       
   287         void FreezeRights();
       
   288         
       
   289         /**
       
   290         * Releases DRM rights (with "Consume API") if frozen earlier.
       
   291         */
       
   292         void ReleaseRights();
       
   293 
       
   294 
       
   295     protected: // data
       
   296         // Required information for class
       
   297         MMediaInfoObserver* iObserver;
       
   298         CDRMHelper* iDRMHelper;
       
   299         RFile iFile;
       
   300         
       
   301         TDataType       iMimeType;
       
   302         HBufC*          iFullFilePath;
       
   303         TInt            iFileSize;
       
   304         TTime           iModificationTime;
       
   305         TMsgMediaType   iMediaType;
       
   306         TInt            iDuration;
       
   307         TUint32         iProtection;
       
   308         HBufC8*         iContentURI;
       
   309         
       
   310         TBool           iParsed;
       
   311         TBool           iConsumed;
       
   312         TInt            iParseError;
       
   313         TUid            iHandlerAppUid;
       
   314         };
       
   315 
       
   316 #include <MsgMediaInfo.inl>
       
   317 
       
   318 #endif // __MSGMEDIAINFO_H