profilesservices/MediaFileList/Inc/mediafileprotection.h
branchRCL_3
changeset 25 7e0eff37aedb
equal deleted inserted replaced
24:8ee96d21d9bf 25:7e0eff37aedb
       
     1 /*
       
     2 * Copyright (c) 2007 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:   Class used to check the protection of the 
       
    15 *                media files.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 #ifndef MEDIAFILEPROTECTION_H
       
    22 #define MEDIAFILEPROTECTION_H
       
    23 
       
    24 #include "mediafiledialogutils.h"
       
    25 #include "mediafilevariation.h"
       
    26 
       
    27 //  INCLUDES
       
    28 
       
    29 #include <e32base.h>
       
    30 #include <DRMHelper.h>
       
    31 #include <apgcli.h>   // RApaLsSession
       
    32 
       
    33 
       
    34 // CONSTANTS
       
    35 
       
    36 
       
    37 //	FORWARD DECLARATIONS
       
    38 
       
    39 
       
    40 
       
    41 /**
       
    42 * CMFProtectionHandler
       
    43 * 
       
    44 * For gettting media file protection information (eg drm protection).
       
    45 * If media is protected and does not have necessary rights it cannot
       
    46 * be used eg as ringing tone. 
       
    47 *
       
    48 */
       
    49 NONSHARABLE_CLASS (CMFProtectionHandler) : public CBase
       
    50     {
       
    51     public:
       
    52     // enumeration which tells what is the file used for.
       
    53     enum TIntention
       
    54         {
       
    55         EPlay,
       
    56         ESelect
       
    57         };
       
    58     
       
    59     public:// Constructors and destructor
       
    60 
       
    61         /**
       
    62         * Two-phased constructor.
       
    63         */
       
    64 		static CMFProtectionHandler* NewL();
       
    65         
       
    66         /**
       
    67         * Destructor.
       
    68         */
       
    69         virtual ~CMFProtectionHandler();
       
    70     
       
    71     private:
       
    72 
       
    73         /**
       
    74         * C++ default constructor.
       
    75         */
       
    76         CMFProtectionHandler();
       
    77 	
       
    78         /**
       
    79         * By default Symbian OS constructor is private.
       
    80         */
       
    81         void ConstructL();
       
    82 
       
    83     public: // Functions from base classes
       
    84 
       
    85         /**
       
    86         * Checks if an unprotected file is valid.
       
    87         * @param aFileName Full path and filename.
       
    88         * @param aIntention Describes what the file is used for.
       
    89         * @return ETrue if the file is valid for intended use.
       
    90         */
       
    91         TBool IsFileValidL( const TDesC& aFileName, TIntention aIntention );
       
    92         TBool IsFileValid( const TDesC& aFileName, TIntention aIntention );
       
    93         TBool IsVideoValidL( const TDesC& aFileName, TIntention aIntention );
       
    94         TBool IsVideoValid( const TDesC& aFileName, TIntention aIntention );
       
    95         
       
    96         /**
       
    97         * Check if the DRM protect file is expired or have no rights to use.
       
    98         * @param aFileName Full path and filename.
       
    99         * @return ETrue if the file is DRM expired or have rights to use.
       
   100         */
       
   101         TBool IsFlieDRMExpired( const TDesC& aFileName );
       
   102 
       
   103         void SetAttrL( TInt aAttr, TInt aValue );
       
   104         void SetAttrL( TInt aAttr, const TDesC& aValue );
       
   105         
       
   106 
       
   107     private:
       
   108         /**
       
   109         * Return media file type
       
   110         */
       
   111         //TInt32 MediaFileType( const TDesC& aFileName );
       
   112 
       
   113         /**
       
   114         * Set the automated content type
       
   115         * @param  aAutomatedType: type of automated content
       
   116         */
       
   117         void SetAutomatedType(
       
   118              CDRMHelper::TDRMHelperAutomatedType aAutomatedType );
       
   119 
       
   120     private:
       
   121 
       
   122         /**
       
   123         * Displays an error note.
       
   124         * @param @aResourceId Resource ID
       
   125         */
       
   126         void ShowErrorNoteL( TInt aResourceId );
       
   127 
       
   128         /**
       
   129         * Checks if an unprotected file is valid.
       
   130         * @param aFileName Full path and filename.
       
   131         * @param aIntention Describes what the file is used for.
       
   132         * @return ETrue if the file is valid for intended use.
       
   133         */
       
   134         TBool IsFileValidUnprotectedL(
       
   135               const TDesC& aFileName, TIntention aIntention );
       
   136 
       
   137         /**
       
   138         * Returns info whether demoplay is allowed for given filetype
       
   139         * @param aDataType Tone MIME type
       
   140         * @return ETrue if tone allowed to be played
       
   141         */
       
   142         //TBool AllowDemoPlay( const TDesC& aDataType );
       
   143 
       
   144         /**
       
   145         * Returns info whether given filetype is allowed as ringingtone
       
   146         * @param aDataType Tone MIME type
       
   147         * @return ETrue if tone is allowed to be selected
       
   148         */
       
   149         //TBool AllowSelect( const TDesC& aDataType ) const;
       
   150 
       
   151         /**
       
   152         * Finds out the MIME type of a given file
       
   153         * @param aFileName File to be checked
       
   154         * @return Returns datatype of a file
       
   155         */
       
   156         TDataType DataTypeL( const TDesC& aFileName );
       
   157         
       
   158         /**
       
   159         * Finds out DRM restrictions for a given file
       
   160         * @param aFileName File to be checked
       
   161         * @param aInfoBits(out) Determines CFM protection
       
   162         * @return Returns EFalse if file is corrupted or has no rights
       
   163         */
       
   164         TBool GetFileInfoL( const TDesC& aFileName, TInt32& aInfoBits );
       
   165 
       
   166         /**
       
   167         * Checks if file is WMDRM protected.
       
   168         * @param aFileName Name of the file to be checked.
       
   169         * @return ETrue if file is WMDRM protected, EFalse otherwise.
       
   170         */
       
   171         TBool   IsFileWMDRMProtectedL( const TDesC& aFileName );
       
   172         
       
   173         TBool CheckFileSize( const TDesC& aFile, const TDesC& aMimeType );
       
   174 
       
   175 
       
   176     private:
       
   177         // DRM common functions
       
   178         DRMCommon* iDRMCommon;
       
   179 
       
   180         // DRM helper
       
   181         CDRMHelper* iDRMHelper;
       
   182         
       
   183         // for finding out drive type (eg memory card)
       
   184         CDriveUtil* iDriveUtil;
       
   185         
       
   186         // for media file list variation
       
   187         CMediaFileDialogVariation* iVariation;
       
   188           
       
   189         // Automated content type
       
   190         CDRMHelper::TDRMHelperAutomatedType iAutomatedType;
       
   191         
       
   192         // max file size
       
   193         TInt iMaxFileSize;
       
   194         
       
   195         // excluded mime types 
       
   196         CMimeTypeList* iExcludedMimeTypes;
       
   197         
       
   198         RApaLsSession iApaLsSession;
       
   199         RFs iFsSession;
       
   200 
       
   201     };
       
   202     
       
   203 
       
   204     
       
   205 
       
   206 
       
   207 #endif  // MEDIAFILEPROTECTION_H
       
   208 
       
   209 // End of File