commonuis/CommonUi/inc/DocDCFHandler.h
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2002-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:  Definition of DCF handler class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef DOCDCFHANDLER_H
       
    20 #define DOCDCFHANDLER_H
       
    21 
       
    22 #include <apmstd.h>          
       
    23 #include <apacln.h>             // MapaEmbeddedDocObserver
       
    24 #include "DocumentHandler.h"
       
    25 #include "DocDefaultHandler.h"
       
    26 
       
    27 // CONSTANTS
       
    28 
       
    29 // FORWARD DECLARATIONS
       
    30 class DRMCommon;
       
    31 class CBufStore;
       
    32 class CStreamDictionary;
       
    33 
       
    34 NONSHARABLE_CLASS(CDocDCFHandler) : public CDocDefaultHandler
       
    35     {
       
    36     public:
       
    37 
       
    38         /**
       
    39         * Two-phased constructor. 
       
    40         *
       
    41         * @param aDataType      Data type
       
    42         * @param aOperation     Operation
       
    43         * @param aUid           UID of the handler app
       
    44         * @param aDocDispatcher Pointer to DocumentHandler instance
       
    45         *
       
    46         * @return Constructed CDocDcfHandler
       
    47         */
       
    48          static CDocDCFHandler* NewL(
       
    49             const TDataType& aDataType,
       
    50             TDocOperation aOperation,
       
    51             const TUid& aUid, 
       
    52             CDocumentHandler* aDocDispatcher);
       
    53                  
       
    54         /**
       
    55         * EPOC constructor. (Base construction for subclasses.)
       
    56         */     
       
    57         void ConstructL();
       
    58         
       
    59         /**
       
    60         * Destructor.
       
    61         */
       
    62         ~CDocDCFHandler();
       
    63  
       
    64         /**
       
    65         * Open an application standalone. 
       
    66         *
       
    67         * @param aFileHandle File to open 
       
    68         * @return           KErrNone if success. If fail, a fail reason 
       
    69         *                   constant declared in CDocumentHandler.h
       
    70         * @since Series60 3.0
       
    71         */
       
    72         TInt OpenFileL(RFile& aFileHandle);
       
    73         
       
    74         /**
       
    75         * Open an application embedded. 
       
    76         *
       
    77         * @param aFileHandle File to open 
       
    78         * @return           KErrNone if success. If fail, a fail reason 
       
    79         *                   constant declared in CDocumentHandler.h
       
    80         * @since Series60 3.0
       
    81         */
       
    82         TInt OpenFileEmbeddedL(RFile& aFileHandle);
       
    83 
       
    84         /**
       
    85         * Copy/Move a file to the correct directory. Correct operation
       
    86         * is decided based on DocOperation(). Possible operations are
       
    87         * EDocCopy, EDocMove and EDocSilentMove.
       
    88         *
       
    89         * @param        aAttr File attributes.
       
    90         *
       
    91         * @return       KErrNone if success. If fail, a fail reason
       
    92         *               constant declared in CDocumentHandler.h
       
    93         */
       
    94         TInt CopyOrMoveL( const TUint aAttr );
       
    95 
       
    96         /**
       
    97         * Copy a file to the correct directory. 
       
    98         *
       
    99         * @param        aAttr File attributes.
       
   100         * @param        aSourceFile File handle to copied
       
   101         *
       
   102         * @return       KErrNone if success. If fail, a fail reason
       
   103         *               constant declared in CDocumentHandler.h
       
   104         */
       
   105         TInt CopyHandleL( const RFile& aSourceFile, const TUint aAttr );
       
   106 
       
   107         /**
       
   108         * Get the path where the content were saved. If the storage
       
   109         * is not a file based the path can be also any other
       
   110         * textual presentation of an object.
       
   111         *
       
   112         * This function is called e.g. when opening a buffer. The buffer
       
   113         * is saved first. After saving we have to know where we saved it
       
   114         * in order to be able to open it.
       
   115         *
       
   116         * @param aPath Path to the object
       
   117         *
       
   118         */
       
   119         void GetPath( TDes& aPath ) const;
       
   120 
       
   121         /**
       
   122         * Get the Uid of handler application. 
       
   123         *
       
   124         * @param aUid Uid of the handler application. In case of Media files
       
   125         * this is MediaGallery's Uid.
       
   126         */
       
   127         void HandlerAppUid( TUid& aUid ) const;
       
   128 
       
   129         /**
       
   130         * Is the handler capable of opening the content
       
   131         * @param aDataType  Data type for content to be launched
       
   132         *
       
   133         * @return           ETrue if yes, else EFalse 
       
   134         */
       
   135         TBool CanOpen() const;
       
   136 
       
   137         /**
       
   138         * Is the handler capable of saving the content
       
   139         * @param aDataType  Data type for content to be saved
       
   140         *
       
   141         * @return           ETrue if yes, else EFalse 
       
   142         */
       
   143         TBool CanSave() const;
       
   144 
       
   145     private:
       
   146     
       
   147         /**
       
   148         * C++ constructor.
       
   149         *
       
   150         * @param aDataType      A mime type for the content
       
   151         * @param aOperation     Operation
       
   152         * @param aUid           UID of the handler app
       
   153         * @param aDocDispatcher Pointer to DocumentHandler instance
       
   154         */
       
   155         CDocDCFHandler(  
       
   156             const TDataType& aDataType,
       
   157             TDocOperation aOperation,
       
   158             const TUid& aUid,
       
   159             CDocumentHandler* aDocDispatcher);
       
   160         
       
   161         /**
       
   162         * Handles DCF file opening.
       
   163         *
       
   164         * @param aFileHandle File which needs opening.
       
   165         * @return           KErrNone if success. If fail, a fail reason 
       
   166         *                   constant declared in CDocumentHandler.h
       
   167         * @since Series60 3.0
       
   168         */
       
   169         TInt OpenDCFFileL( RFile& aFileHandle );
       
   170         
       
   171         /**
       
   172         * Handles DCF file copying.
       
   173         *
       
   174         * @param aUseHandle Do we operate with filehandle
       
   175         * @param aFileHandle File which needs copying/moving
       
   176         * @param aAttr      Attributes of file 
       
   177         * @return           KErrNone if success. If fail, a fail reason 
       
   178         *                   constant declared in CDocumentHandler.h
       
   179         * @since Series60 3.0
       
   180         */
       
   181         TInt CopyDCFFileL( TBool aUseHandle, 
       
   182                            RFile& aFileHandle, 
       
   183                            const TUint aAttr);
       
   184         
       
   185         /**
       
   186         * Set the data type of the content. 
       
   187         *
       
   188         * @param aMIMEType  A data type in descriptor.
       
   189         */  
       
   190         void SetDataTypeL( HBufC8* MIMEType );
       
   191 
       
   192         /**
       
   193         * Convert DRM error code to DocumentHandler error code.
       
   194         *
       
   195         * @param aDrmError  DRM error
       
   196         * @return           General error code 
       
   197         */ 
       
   198         TInt ConvertErrorCode(TInt aDrmError);
       
   199 
       
   200     private:
       
   201         DRMCommon* iDRMCommon;
       
   202         TDocOperation iEntryFunc;
       
   203         CDocumentHandler* iDocHandler;
       
   204     };
       
   205 
       
   206 #endif      // DOCDCFHANDLER_H
       
   207             
       
   208 // End of File