epoc32/include/mw/documenthandler.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     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 CDocumentHandler class.
    15 *                The purpose of the Documenthandler is to offer to applications
    16 *                - wrapper for application embedding
    17 *                - temporary file utility to support data caging for platform security 
    18 *             
    19 *
    20 */
    21 
    22 
    23 #ifndef DOCUMENTHANDLER_H
    24 #define DOCUMENTHANDLER_H
    25 
    26 //  INCLUDES
    27 #include <e32base.h>
    28 #include <f32file.h>
    29 
    30 // CONSTANTS
    31 
    32 // App UIDs for handlers. Handlers are identified by the handler application's
    33 // UID. E.g. The handler for WMLC (binary format of Wireless Markup Language)
    34 // is responsible for launching the WMLBrowser. The data type
    35 // application/wap.vnd.wmlc is therefore mapped to the browser's UID,
    36 // 0x10008D39.
    37 
    38 const TInt KTextHandler         = 0x1000599d;   // Notepad viever
    39 const TInt KWmlcHandler         = 0x10008D39;   // WML Browser
    40 const TInt KJamHandler          = 0x100009C1;   // JAM
    41 const TInt KAppInstHandler      = 0x101F875A;   // Installer 
    42 const TInt KBioViewerAppHandler = 0x0FC99F01;   // BVA
    43 const TInt KImageViewerHandler  = 0x101f4d90;   // Image viever
    44 const TInt KCertSaveAppHandler  = 0x100059D2;   // Cert response handler app
    45 const TInt KCODHandler          = 0x10008d4a;   // COD handler
    46 const TInt KDDhandler           = 0x10008d3f;   // DD Handler
    47 
    48 // A global external mime type for all nokia games.
    49 _LIT8(KGameMimeType, "application/x-NokiaGameData");
    50 _LIT8(KDataTypeODM,"application/vnd.oma.drm.message"); // Not supported by DocumentHandler
    51 _LIT8(KDataTypeDCF,"application/vnd.oma.drm.content"); // Deprecated, do not use from here
    52                                                      
    53 // Fail reasons
    54 const TInt KBadMimeType         = -12002;        // Mime type conflict etc.
    55 const TInt KMimeNotSupported    = -12003;        // No handler found
    56 const TInt KNullContent         = -12005;        // Empty content
    57 const TInt KDataDirNotFound     = -12006;        // Deprecated - not used
    58 const TInt KExecNotAllowed      = -12007;        // Executables not allowed
    59 const TInt KNoHostProcess       = -12008;        // Deprecated - not used
    60 const TInt KNotInitialized      = -12009;        // Not initialized
    61 const TInt KUserCancel          = -12010;        // User cancelled operation
    62 const TInt KDRMErrSession           = -12011;   // DRM session error.
    63 const TInt KDRMErrNoRights          = -12012;   // Invalid DRM rights.
    64 const TInt KDRMErrRightsDBCorrupted = -12013;   // DRM rights db corrupted.
    65 const TInt KDRMErrInvalidVersion    = -12014;   // Invalid DRM version.
    66 const TInt KDRMErrPreviewRights     = -12015;   // Preview DRM rights.
    67 
    68 
    69 // DATA TYPES
    70 
    71 // API operations to inform special handlers of the entry function.
    72 enum TDocOperation
    73     {
    74     EDocCopy,               // CopyL( aFileNameOld, aNameNew, aDataType, aAttr)
    75     EDocSave,               // SaveL( aContent, aDataType, aAttr )
    76     EDocSaveAs,             // SaveL( aContent, aDataType,aFileName, aAttr )
    77     EDocOpenFile,           // OpenFileL( aFileName, aDataType )
    78     EDocOpenFileEmb,        // OpenFileEmbeddedL( aFileName, aDataType) 
    79     EDocMove,               // MoveL( aFileNameOld, aNameNew, aDataType, aAttr)
    80     EDocSilentMove,         // SilentMoveL( aFileNameOld, aNameNew, aRootPaht, aDataType, aAttr)
    81     EDocSaveTemp,           // SaveTempFileL( aContent, aDataType, aFileName, aSharableFile)
    82     };
    83 
    84 // FORWARD DECLARATIONS
    85 class CDocHandlerBase;                       // Base class for handlers
    86 class CEikProcess;                           // The host process
    87 class MAknServerAppExitObserver;             // Viewer app exit observer 
    88 class TDataType;                             // Mime type handling
    89 class RApaLsSession;                         // App list server session
    90 class CAiwGenericParamList;                  // Generic parameter list 
    91 
    92 // CLASS DECLARATION
    93 
    94 /**
    95 * Utility class for opening and saving any supported content.
    96 * This class declares an interface for the DocumentHandler, a
    97 * common component in Series60.
    98 *
    99 * The CDocumentHandler class will not itself implement any content
   100 * handling routines. It's responsible for finding out which application
   101 * can handle given data type and constructing a correct handler implementation
   102 * for that application. If the given data type is supported by the system
   103 * but no specific handler is found, the CDocDefaltHandler is then constructed.
   104 * The default handler is an implementation of the CDoCDocHandlerBase class with
   105 * standard "Epoc-style" content handling.
   106 *
   107 * The handler application can be lauched standalone or embedded. The
   108 * Embedded launching is preferred way in Series60.
   109 * Standalone launching means that the application will run in
   110 * it's own process. Embedded launching means that the UI of an
   111 * application, which is responsible for handling given data type,
   112 * is embedded into the parent application. There will be only
   113 * parent applications icon shown in the fast swap window when an
   114 * application is embedded.
   115 *
   116 * Link your application against CommonUI.lib.
   117 *
   118 * <b>An example: </b> 
   119 *<pre> 
   120 * #include <DocumentHandler.h>
   121 *
   122 * <i>// Define DocHandler</i>
   123 * CDocumentHandler* iDocHandler;
   124 * 
   125 * <i>// Construct DocHandler</i>
   126 * void ConstructL()
   127 *    {
   128 *    iDocHandler = CDocumentHandler::NewL();
   129 *
   130 *    <i>// I want to be notified when exit happends. Because I
   131 *    // pass "this" pointer, I have to derive from
   132 *    // MAknServerAppExitObserver class.</i>
   133 *    iDocHandler->SetExitObserver(this)     
   134 *    }
   135 *
   136 * <i>// delete DocHandler</i>
   137 * void ~Myapp()
   138 *    {
   139 *    delete iDocHandler;
   140 *    }
   141 *
   142 *
   143 * <i>// and use like this</i>
   144 *
   145 * void OpenAttachmentL( RFile& aFile,           <i>// A file to be open</i>
   146 *                       TDataType& aDataType )  <i>// DataType can be empty</i>
   147 *   {
   148 *   TInt error = KErrNone;
   149 *   TFileName path;
   150 *
   151 *   <i>
   152 *   // Leaves on system wide errors like disk full, out of memory etc.</i>
   153 *   error = iDocHandler->OpenFileEmbeddedL( aFile, aDataType );
   154 *   // The status code can be either KErrNone or KUserCancel
   155 *
   156 *    }
   157 * </pre>
   158 *
   159 */
   160 NONSHARABLE_CLASS(CDocumentHandler) : public CBase
   161     {
   162     public:        // Constructors and destructor
   163 
   164         /**
   165         * Two-phased constructor. Leaves on failure.
   166         *
   167         * @param aProcess   The host process, which will be
   168         *                   used for embedded launching.
   169         *
   170         * @return           The constructed CDocumentHandler
   171         * @deprecated in Series60 3.0, instead use NewL without CEikProcess parameter
   172         */
   173         IMPORT_C static CDocumentHandler* NewL( CEikProcess* aProcess );
   174 
   175         /**
   176         * Two-phased constructor. Leaves on failure.
   177         *
   178         * @param aProcess   The host process, which will be
   179         *                   used for embedded launching.
   180         *
   181         * @return           The constructed CDocumentHandler
   182         * @deprecated in Series60 3.0, instead use NewL without CEikProcess parameter
   183         */
   184         IMPORT_C static CDocumentHandler* NewLC( CEikProcess* aProcess );
   185 
   186         /**
   187         * Two-phased constructor. Leaves on failure.
   188         *
   189         *
   190         * @return           The constructed CDocumentHandler
   191         * @since Series 60 3.0
   192         */
   193         IMPORT_C static CDocumentHandler* NewL( );
   194 
   195         /**
   196         * Two-phased constructor. Leaves on failure.
   197         *
   198         *
   199         * @return           The constructed CDocumentHandler
   200         * @since Series 60 3.0
   201         */
   202         IMPORT_C static CDocumentHandler* NewLC( );
   203 
   204         /**
   205         * Destructor.
   206         */
   207         IMPORT_C virtual ~CDocumentHandler();
   208 
   209     private:        // Constructors and destructor
   210 
   211         /**
   212         * C++ default constructor.
   213         */
   214         CDocumentHandler( );
   215 
   216         /**
   217         * C++ copy constructor
   218         */
   219         CDocumentHandler( const CDocumentHandler& );
   220 
   221         /**
   222         * By default EPOC constructor is private.
   223         */
   224         void ConstructL();
   225 
   226     public:       // New functions, data caging
   227         
   228       /**
   229        * Utility method for opening filehandle from existing file for OpenFileL 
   230        * calls. The created file handle is meant to be shared across process 
   231        * boundaries.
   232        * 
   233        * This function can leave in some system wide error situation.
   234        * E.g. out of memory, not enough space in filesystem etc. These
   235        * errors are usually trapped by the application framework.
   236        *
   237        * NOTE! Caller is responsible of closing opened file handle. 
   238        *
   239        * @param aFileName  Name (including directory information) for file. 
   240        *                   This file should exist allready, otherwise this 
   241        *                   function leaves with KErrNotFound. 
   242        * @param aSharableFile Returned file handle that can be shared.
   243        * @since Series 60 3.0
   244        */
   245       IMPORT_C void OpenTempFileL(
   246           const TDesC& aFileName,
   247           RFile &aSharableFile);
   248 
   249       /**
   250        * Utility method for save aContent with aDataType temporarily
   251        * for OpenFileL calls. The created file handle is meant to be shared 
   252        * across process boundaries.
   253        *
   254        * This temporary file will be saved to process private temp directory.
   255        * Temporary directory will be created if not existing yet. 
   256        *
   257        * This function can leave in some system wide error situation.
   258        * E.g. out of memory, not enough space in filesystem etc. These
   259        * errors are usually trapped by the application framework.
   260        *
   261        * NOTE! Caller is responsible of closing opened file handle!
   262        * Created temporary file will be deleted in destructor of 
   263        * DocumentHandler, but caller can delete it self as well.
   264        *
   265        * @param aContent   A content data buffer. Narrow descriptor that
   266        *                   can contain any kind of data.
   267        * @param aDataType  A data type for the content of the file. If empty
   268        *                   the DocumentHandler tries to recognize the content.
   269        * @param aFileName  Use this name for saving. The name must not 
   270        *                   contain any directory information.
   271        * @param aSharableFile Returned file handle that can be shared.
   272        * @since Series 60 3.0
   273        */
   274       IMPORT_C void SaveTempFileL(
   275           const TDesC8& aContent,
   276           TDataType& aDataType,
   277           const TDesC& aFileName,
   278           RFile &aSharableFile);
   279 
   280     public:       // New functions, parameter handling
   281       
   282       /**
   283        * Returns an empty instance of CAiwGenericParamList class. It can be
   284        * used for example as an input parameter list for API methods.
   285        * This is just a convinience method and doesn't have
   286        * to be used. If consumer wants to create input list by itself
   287        * it is ok. If this method is used, service handler takes care
   288        * of deleting returned generic parameter list.
   289        *
   290        * @return  An empty instance of CAiwGenericParameter list.
   291        * @since Series 60 3.0
   292        */
   293       IMPORT_C CAiwGenericParamList& InParamListL();
   294 
   295       /**
   296        * Returns a list of possible output parameters handler application
   297        * may have set after executing the service. The caller is responsible 
   298        * for deleting the parameter instance if not null.
   299        *
   300        * @return   List of output parameters, NULL if nothing set.
   301        * @deprecated
   302        */          
   303       IMPORT_C const CAiwGenericParamList* OutParamList();
   304 
   305     public:       // New functions, open file with filehandle
   306       
   307        /**
   308         * Launches an application in standalone capable of handling
   309         * data in aSharableFile (using aDatatype if available). 
   310         * Doesn't save data from the file. In case of DRM protected 
   311         * files with restricted rights, there will be query asking
   312         * if user want open file. 
   313         *
   314         * This function can leave in some system wide error situation.
   315         * E.g. out of memory, not enough space in filesystem etc. See 
   316         * also possible error codes from documenthandler.h header file.
   317         * 
   318         * @param aSharableFile  A sharable file handle to be passed to
   319         *                       the launched application
   320         * @param aDataType  A data type for the content of the file. If empty
   321         *                   the DocumentHandler tries to recognize the content.
   322         * @return           KErrNone if success. KUserCancel if the user 
   323         *                   cancelled the operation. 
   324         * @since Series 60 3.0
   325         */
   326       IMPORT_C TInt OpenFileL(
   327           RFile& aSharableFile,
   328           TDataType& aDataType);      
   329          
   330        /**
   331         * Launches an application in embedded (if possible) capable of 
   332         * handling data in aSharableFile (using aDatatype if available). 
   333         * Doesn't save data from the file. In case of DRM protected
   334         * files with restricted rights, there will be query asking
   335         * if user want open file. 
   336         *
   337         * This function can leave in some system wide error situation.
   338         * E.g. out of memory, not enough space in filesystem etc. See 
   339         * also possible error codes from documenthandler.h header file.
   340         *
   341         * @param aSharableFile  A sharable file handle to be passed to
   342         *                       the launched application. 
   343         * @param aDataType  A data type for the content of the file. If empty
   344         *                   the DocumentHandler tries to recognize the content.
   345         * @param aParamList Parameter list to be passed to handler application.
   346         * @return           KErrNone if success. KUserCancel if the user 
   347         *                   cancelled the operation. 
   348         * @since Series 60 3.0
   349         */
   350       IMPORT_C TInt OpenFileEmbeddedL(
   351           RFile& aSharableFile,
   352           TDataType& aDataType,
   353           const CAiwGenericParamList& aParamList);
   354           
   355         /**
   356         * Launches an application in embedded (if possible) capable of 
   357         * handling data in aSharableFile (using aDatatype if available). 
   358         * Doesn't save data from the file. In case of DRM protected
   359         * files with restricted rights, there will be query asking
   360         * if user want open file. 
   361         *
   362         * This function can leave in some system wide error situation.
   363         * E.g. out of memory, not enough space in filesystem etc. See 
   364         * also possible error codes from documenthandler.h header file.
   365         *
   366         * @param aSharableFile  A sharable file handle to be passed to
   367         *                       the launched application. 
   368         * @param aDataType  A data type for the content of the file. If empty
   369         *                   the DocumentHandler tries to recognize the content.
   370         * @return           KErrNone if success. KUserCancel if the user 
   371         *                   cancelled the operation. 
   372         * @since Series 60 3.0
   373         */
   374       IMPORT_C TInt OpenFileEmbeddedL(
   375           RFile& aSharableFile,
   376           TDataType& aDataType);
   377      
   378     public:       // open file with filename
   379 
   380         /**
   381         * Launches an application standalone capable of handling
   382         * data in aFilename, with aDataType. Doesn't copy data
   383         * from the file.
   384         *
   385         * This function can leave in some system wide error situation.
   386         * E.g. out of memory, not enough space in filesystem etc. See 
   387         * also possible error codes from documenthandler.h header file.
   388         *
   389         * @param aFileName  Name of the file. Directory path included.
   390         * @param aDataType  A data type for the content of the file. If empty
   391         *                   the DocumentHandler tries to recognize the content.
   392         * @return           KErrNone if success. KUserCancel if the user 
   393         *                   cancelled the operation.
   394         */
   395         IMPORT_C TInt OpenFileL(
   396             const TDesC& aFileName,
   397             TDataType& aDataType );
   398 
   399         /**
   400         * Launches an application embedded capable of handling data in
   401         * aFilename with aDataType. Doesn't copy data from the file.
   402         *
   403         * This function can leave in some system wide error situation.
   404         * E.g. out of memory, not enough space in filesystem etc. See 
   405         * also possible error codes from documenthandler.h header file.
   406         *
   407         * @param aFileName  Name of the file. Directory path included.
   408         * @param aDataType  A data type for the content of the file. If empty
   409         *                   the DocumentHandler tries to recognize the content.
   410         * @return           KErrNone if success. KUserCancel if the user 
   411         *                   cancelled the operation.
   412         */
   413         IMPORT_C TInt OpenFileEmbeddedL(
   414             const TDesC& aFileName,
   415             TDataType& aDataType );
   416 
   417     public:       // data saving
   418 
   419         /**
   420         * Save aContent with aDataType using aAttr to a correct directory.
   421         * Generates a new name for saving. The storage is usually a filesystem, 
   422         * but can be anything from application spesific data structures to 
   423         * a database.
   424         *
   425         * This function can leave in some system wide error situation.
   426         * E.g. out of memory, not enough space in filesystem etc. See 
   427         * also possible error codes from documenthandler.h header file.
   428         *
   429         * @param aContent   A content data buffer. Narrow descriptor that
   430         *                   can contain any kind of data.
   431         * @param aDataType  A data type for the content of the file. If empty
   432         *                   the DocumentHandler tries to recognize the content.
   433         * @param aAttr      Use these file attributes for saving. Your can 
   434         *                   find these attributes from 
   435         *                   \epoc32\include\f32file.h header file. 
   436         *                   If the storage is not a filesystem these 
   437         *                   attributes are ignored.
   438         * @return           KErrNone if success. KUserCancel if the user 
   439         *                   cancelled the operation.
   440         */
   441         IMPORT_C TInt SaveL(
   442             const TDesC8& aContent,
   443             TDataType& aDataType,
   444             const TUint aAttr );
   445 
   446         /**
   447         * Save aBuffer with aDataType using aAttr to a correct storage with a
   448         * supplied name. The storage is usually a filesystem, but can be 
   449         * anything from application spesific data structures to a database.
   450         *
   451         * This function can leave in some system wide error situation.
   452         * E.g. out of memory, not enough space in filesystem etc. See 
   453         * also possible error codes from documenthandler.h header file.
   454         *
   455         * @param aContent   A content data buffer. Narrow descriptor that
   456         *                   can contain any kind of data.
   457         * @param aDataType  A data type for the content of the file. If empty
   458         *                   the DocumentHandler tries to recognize the content.
   459         * @param aName      Use this name for saving. The name must not 
   460         *                   contain any directory information.
   461         * @param aAttr      Use these file attributes for saving. Your can 
   462         *                   find these attributes from 
   463         *                   \epoc32\include\f32file.h header file. 
   464         *                   If the storage is not a filesystem these 
   465         *                   attributes are ignored.
   466         * @return           KErrNone if success. KUserCancel if the user 
   467         *                   cancelled the operation.
   468         */
   469         IMPORT_C TInt SaveL(
   470             const TDesC8& aContent,
   471             TDataType& aDataType,
   472             const TDesC& aName,
   473             const TUint aAttr );
   474 
   475         /**
   476         * Copy a file named aFileNameOld to the correct storage using
   477         * name aNameNew and aFileAttr. If aNameNew is empty, use
   478         * the old name.
   479         *
   480         * This function can leave in some system wide error situation.
   481         * E.g. out of memory, not enough space in filesystem etc. See 
   482         * also possible error codes from documenthandler.h header file.
   483         *
   484         * @param aFileNameOld   Name of the file being copied.
   485         * @param aNameNew       Name of the new file. If null, use the 
   486         *                       old name.
   487         * @param aDataType      A data type for the file. If empty the 
   488         *                       DocumentHandler tries to recognize type.
   489         * @param aAttr          Use these file attributes for saving. 
   490         *                       ReadOnly, ReadWrite.
   491         * @return               KErrNone if success. KUserCancel if the user 
   492         *                       cancelled the operation.
   493         */
   494         IMPORT_C TInt CopyL(
   495             const TDesC& aFileNameOld,
   496             const TDesC& aNameNew,
   497             TDataType& aDataType,
   498             const TUint aAttr );
   499             
   500         /**
   501         * Copy a file with handle aFileOld to the correct storage using
   502         * name aNameNew and aFileAttr. If aNameNew is empty, use
   503         * the old name.
   504         *
   505         * This function can leave in some system wide error situation.
   506         * E.g. out of memory, not enough space in filesystem etc. See 
   507         * also possible error codes from documenthandler.h header file.
   508         *
   509         * @param aFileOld       Handle of the file being copied.
   510         * @param aNameNew       Name of the new file. If null, use the 
   511         *                       old name.
   512         * @param aDataType      A data type for the file. If empty the 
   513         *                       DocumentHandler tries to recognize type.
   514         * @param aAttr          Use these file attributes for saving. 
   515         *                       ReadOnly, ReadWrite.
   516         * @return               KErrNone if success. KUserCancel if the user 
   517         *                       cancelled the operation.
   518         */
   519         IMPORT_C TInt CopyL(
   520             const RFile& aFileOld,
   521             const TDesC& aNameNew,
   522             TDataType& aDataType,
   523             const TUint aAttr );
   524 
   525         /**
   526         * Move a file named aFileNameOld to the correct storage using
   527         * name aNameNew and aFileAttr. Note that file in the old location 
   528         * (aFileNameOld) will be removed during this operation.
   529         *
   530         * This function can leave in some system wide error situation.
   531         * E.g. out of memory, not enough space in filesystem etc. See 
   532         * also possible error codes from documenthandler.h header file.
   533         *
   534         * @param aFileNameOld   Name of the file being copied.
   535         * @param aNameNew       Name of the new file. If null, use the 
   536         *                       default name for this mime-type. 
   537         * @param aDataType      A data type for the file. If empty the 
   538         *                       DocumentHandler tries to recognize type.
   539         * @param aAttr          Use these file attributes for saving. 
   540         *                       ReadOnly, ReadWrite.
   541         * @return               KErrNone if success. KUserCancel if the user 
   542         *                       cancelled the operation.
   543         * @since Series60 2.8
   544         */
   545         IMPORT_C TInt MoveL(
   546             const TDesC& aFileNameOld,
   547             const TDesC& aNameNew,
   548             TDataType& aDataType,
   549             const TUint aAttr );
   550 
   551         /**
   552         * Move a file named aFileNameOld to the correct storage using
   553         * name aNameNew and aFileAttr. This method operates silently, so 
   554         * nothing will be asked from user. Caller should give root path of 
   555         * the selected memory. Unique file name will be created automatically 
   556         * without user interaction. Note that file in the old location 
   557         * (aFileNameOld) will be removed during this operation. 
   558         *
   559         * This function can leave in some system wide error situation.
   560         * E.g. out of memory, not enough space in filesystem etc. See 
   561         * also possible error codes from documenthandler.h header file.
   562         * 
   563         * @param aFileNameOld   Name of the file being copied.
   564         * @param aNameNew       Name of the new file. If null, use the 
   565         *                       default name for this mime-type. 
   566         * @param aRootPath      Root path of the selected memory where file 
   567         *                       should be moved.
   568         * @param aDataType      A data type for the file. If empty the 
   569         *                       DocumentHandler tries to recognize type.
   570         * @param aAttr          Use these file attributes for saving. 
   571         *                       ReadOnly, ReadWrite.
   572         * @return               KErrNone if success. 
   573         * @since Series60 3.0
   574         */
   575         IMPORT_C TInt SilentMoveL(
   576             const TDesC& aFileNameOld,
   577             const TDesC& aNameNew,
   578             const TDesC& aRootPath,
   579             TDataType& aDataType,
   580             const TUint aAttr );
   581 
   582 
   583     public:       // query functions
   584 
   585         /**
   586         * Is the aDataType supported by the system.
   587         *
   588         * @param    aDataType Data type for content.
   589         *
   590         * @return   True if there is an application capable of handling
   591         *           aDataType. False if no application can handle
   592         *           this mime type.
   593         */
   594         IMPORT_C TBool CanHandleL( const TDataType& aDataType );
   595 
   596         /**
   597         * Is opening of aDataType supported by the system.
   598         *
   599         * @param    aDataType Data type for content.
   600         *
   601         * @return   True if there is an application capable of handling
   602         *           aDataType. False if no application can handle
   603         *           this mime type.
   604         */
   605         IMPORT_C TBool CanOpenL( const TDataType& aDataType );
   606 
   607         /**
   608         * Is saving aDataType supported by the system.
   609         *
   610         * @param    aDataType Data type for content.
   611         *
   612         * @return   True if there is an application capable of handling
   613         *           aDataType. False if no application can handle
   614         *           this mime type.
   615         */
   616         IMPORT_C TBool CanSaveL( const TDataType& aDataType );
   617 
   618         /**
   619         * Get the whole path including filename where the content was saved.
   620         * If the content was not saved to a file, this function returns
   621         * a name that represents the saved object.  
   622         * 
   623         * It may not be possible to open the object with the returned 
   624         * value, if it's not a real file in the filesystem. This situation
   625         * may happen when e.g. the handler application stores it's contents in
   626         * some weird data structure.
   627         *
   628         * @param    aPath The path of the saved content.
   629         *
   630         * @return   KErrNone if the path was found. KNotInitialised if the  
   631         *           handler is not initialised.        
   632         */
   633         IMPORT_C TInt GetPath( TDes& aPath );   
   634         
   635         /**
   636         * Get the uid of handler application. In case of media files uid is 
   637         * Media Gallery's uid. This method should be called only succesfully 
   638         * completed DocumentHandler operations. 
   639         *
   640         * @param    aUid Uid of the handler application for the content. 
   641         *
   642         * @return   KErrNone if the uid was found. KNotInitialised if the 
   643         *           handler is not initialised.        
   644         * @since Series 60 2.8
   645         */
   646         IMPORT_C TInt HandlerAppUid( TUid& aUid );   
   647         
   648         /**
   649         * Set an observer for embedded application exit events. 
   650         * DocumentHandler will delegate embedding applications exit 
   651         * events to aObserver if it's not NULL:
   652         * 
   653         * @param    aObserver Exit observer
   654         * @since Series 60 3.0
   655         */
   656         IMPORT_C void SetExitObserver( MAknServerAppExitObserver* aObserver );
   657         
   658         /**
   659         * Utility method for appending a correct file name extension for some 
   660         * content. This method should be called if wanted quarantee that file 
   661         * extension of aFileName is correct with aDataType. 
   662         *
   663         * This method uses internal mapping table to find correct file 
   664         * extension to aFileName. Mapping table contains mainly extensions
   665         * and datatypes, which cannot be recognized based on the data it self 
   666         * (No header information etc.). 
   667         *
   668         * This method replaces existing extension with correct one at aFileName 
   669         * if needed. If aDatatype is not found from mapping table or aDatatype
   670         * is not supported by any application, aFileName will remain unchanged.
   671         *
   672         * @param aFileName  Append extension to this filename. 
   673         * @param aDataType  The content type of the file.
   674         * @since Series 60 3.0
   675         */
   676         IMPORT_C void CheckFileNameExtension(
   677             TDes& aFileName,
   678             const TDataType& aDatatype );
   679         
   680         /**
   681         * Get the RApaLsSession.
   682         *
   683         * @return Pointer to RApaLsSession
   684         */
   685         RApaLsSession* ApaLs();
   686 
   687         /**
   688         * Get the exit observer.    
   689         *
   690         * @return Pointer to exit observer
   691         * @since Series 60 3.0
   692         */
   693         MAknServerAppExitObserver* ServerAppExitObserver() const;
   694 
   695         /**
   696         * Get the operation code of the api entry function.
   697         */
   698         TDocOperation DocOperation() const;
   699         
   700         /** 
   701         * Close sharable FileSession. 
   702         */
   703         void CloseSharableFS();
   704         
   705         /**
   706         * Set temporary file, which will be deleted in destructor.
   707         */
   708         void SetTempFile( const TDesC& aTempFile);
   709         
   710         /**
   711         * Utility method to find out if there are any applications that 
   712         * support progressive downloading for a given data type. 
   713         *        
   714         * The decision is based on configuration made in central repository.
   715         *
   716         * @param aDataType  The content type of the file.
   717         * @param aUid  An Uid of the applications for the given data type.
   718         * @return ETrue if progressive download was supported for the given
   719         *   data type. Otherwise EFalse.
   720         * @since Series 60 3.1
   721         */
   722         IMPORT_C TBool CanHandleProgressivelyL( 
   723             const TDataType& aDataType, 
   724             TUid& aUid );
   725         
   726         /**
   727         * Utility method to provide a list of applications that support 
   728         * progressive downloading. 
   729         *
   730         * The list of applications uids is configured central repository.
   731         *
   732         * @param aUidList A list of app Uids
   733         * @since Series 60 3.2
   734         */            
   735         IMPORT_C void GetProgressiveDownloadAppUidsL( RArray<TInt32>& aUidList );            
   736             
   737     private:        // New functions
   738 
   739         /**
   740         * Construct a handler for a given data type. A previous handler will 
   741         * be destroyed and the new one is constructed.
   742         *
   743         * The desicion of which handler implementation to use is
   744         * based on Apparc's AppForDataType query. If the app uid is
   745         * found for aDataType and there is a hardcoded handler for it,
   746         * the right handler will be constucted. If the app uid is not found
   747         * try to match a data type for some handler. The default handler is
   748         * constructed if no handler entry is found.
   749         *
   750         * @param    aUid UID of the handler application.
   751         * @return   Error code
   752         */
   753         TInt FindHandlerL(
   754             const TDataType& aDataType,
   755             const TUid& aUid);
   756 
   757         /**
   758         * Try to find a handler for aUid. Constructs iHandler if found.
   759         *
   760         * @param aDataType A data type to pass to a handler
   761         * @param aUid An uid to search a handler for
   762         */
   763         void FindHandlerByUidL( 
   764             const TUid& aUid, 
   765             const TDataType& aDataType);
   766 
   767         /**
   768         * Try to find a handler for aDataType. Constructs iHandler if found.
   769         *
   770         * @param aUid      An Uid for handler application.
   771         * @param aDataType A data type to search a handler for.
   772         */
   773         void FindHandlerByMimeTypeL( 
   774             const TUid& aUid, 
   775             const TDataType& aDataType);
   776                                 
   777         /**
   778         * Makes all the nesessary security checks and maps aDataType to 
   779         * an UID of the handler application. If system is not able to handle 
   780         * the content type, or file is DRM protectedfile, aDataType and aUid  
   781         * will left empty.
   782         *
   783         * @param aFileName  Filename
   784         * @param aDataType  Data type for the file
   785         * @param aUid       An application UID will be returned if a handler 
   786         *                   was found.
   787         * @return           KErrNone if success, error code if failure.
   788         */
   789         TInt RecognizeAndCheckFileL(
   790             const TDesC& aFileName,
   791             TDataType& aDataType,
   792             TUid& aUid );     
   793             
   794         /**
   795         * Makes all the nesessary security checks and maps aDataType to 
   796         * an UID of the handler application. If system is not able to handle 
   797         * the content type, or file is DRM protectedfile, aDataType and aUid  
   798         * will left empty.
   799         *
   800         * @param aFileHandle Filehandle
   801         * @param aDataType  Data type for the file
   802         * @param aUid       An application UID will be returned if a handler 
   803         *                   was found.
   804         * @return           KErrNone if success, error code if failure.
   805         */
   806         TInt RecognizeAndCheckFileL(
   807             RFile& aFileHandle,
   808             TDataType& aDataType,
   809             TUid& aUid );     
   810 
   811         /**
   812         * This method lists all supported mime-types of system using 
   813         * RDebug::Print. On UREL mode this method do nothing.
   814         */
   815         void ListSupportedMimeTypesL();
   816 		
   817         /**
   818         * Prohibit the assignment operation
   819         */
   820         CDocumentHandler operator=( const CDocumentHandler& )  const;
   821         
   822         /**
   823         * Convert a hex string to 32-bit integer.
   824         */        
   825         TInt ConvertHexStringToInt32( 
   826             const TDesC& aHexString, 
   827             TInt32& aInt );               
   828 
   829     private:          // Data
   830 
   831         /**
   832         * The entry operation. Handlers can query about the entry function
   833         * when they need to implement some special behaviour.
   834         */
   835         TDocOperation iOperation;
   836 
   837         /**
   838         * A handler providing operations. 
   839         */
   840         CDocHandlerBase* iHandler;
   841 
   842         /**
   843         * A ApaLs session client.
   844         */
   845         RApaLsSession* iApaLs;
   846         
   847         /**
   848         * Notify embedded app's exit event to this observer.
   849         */
   850         MAknServerAppExitObserver* iServerAppExitObserver;
   851         
   852         /**
   853         * Holds sharable Fileserver session
   854         */
   855         RFs iSharableFS;
   856 
   857         /**
   858         * Parameter list created using InParamListL function
   859         */
   860         CAiwGenericParamList* iInParams;
   861         
   862         /**
   863         * Filename of temporary saved file. This file will be deleted 
   864         * in destructor of documenthandler
   865         */
   866         TFileName iTempFileName;     
   867         
   868     };
   869 
   870 #endif              // DOCUMENTHANDLER_H
   871 
   872 // End of File