williamr@2: /* williamr@2: * Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies). williamr@2: * All rights reserved. williamr@2: * This component and the accompanying materials are made available williamr@4: * under the terms of "Eclipse Public License v1.0" williamr@2: * which accompanies this distribution, and is available williamr@4: * at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@2: * williamr@2: * Initial Contributors: williamr@2: * Nokia Corporation - initial contribution. williamr@2: * williamr@2: * Contributors: williamr@2: * williamr@2: * Description: Definition of CDocumentHandler class. williamr@2: * The purpose of the Documenthandler is to offer to applications williamr@2: * - wrapper for application embedding williamr@2: * - temporary file utility to support data caging for platform security williamr@2: * williamr@2: * williamr@2: */ williamr@2: williamr@2: williamr@2: #ifndef DOCUMENTHANDLER_H williamr@2: #define DOCUMENTHANDLER_H williamr@2: williamr@2: // INCLUDES williamr@2: #include williamr@2: #include williamr@2: williamr@2: // CONSTANTS williamr@2: williamr@2: // App UIDs for handlers. Handlers are identified by the handler application's williamr@2: // UID. E.g. The handler for WMLC (binary format of Wireless Markup Language) williamr@2: // is responsible for launching the WMLBrowser. The data type williamr@2: // application/wap.vnd.wmlc is therefore mapped to the browser's UID, williamr@2: // 0x10008D39. williamr@2: williamr@2: const TInt KTextHandler = 0x1000599d; // Notepad viever williamr@2: const TInt KWmlcHandler = 0x10008D39; // WML Browser williamr@2: const TInt KJamHandler = 0x100009C1; // JAM williamr@2: const TInt KAppInstHandler = 0x101F875A; // Installer williamr@2: const TInt KBioViewerAppHandler = 0x0FC99F01; // BVA williamr@2: const TInt KImageViewerHandler = 0x101f4d90; // Image viever williamr@2: const TInt KCertSaveAppHandler = 0x100059D2; // Cert response handler app williamr@2: const TInt KCODHandler = 0x10008d4a; // COD handler williamr@2: const TInt KDDhandler = 0x10008d3f; // DD Handler williamr@2: williamr@2: // A global external mime type for all nokia games. williamr@2: _LIT8(KGameMimeType, "application/x-NokiaGameData"); williamr@2: _LIT8(KDataTypeODM,"application/vnd.oma.drm.message"); // Not supported by DocumentHandler williamr@2: _LIT8(KDataTypeDCF,"application/vnd.oma.drm.content"); // Deprecated, do not use from here williamr@2: williamr@2: // Fail reasons williamr@2: const TInt KBadMimeType = -12002; // Mime type conflict etc. williamr@2: const TInt KMimeNotSupported = -12003; // No handler found williamr@2: const TInt KNullContent = -12005; // Empty content williamr@2: const TInt KDataDirNotFound = -12006; // Deprecated - not used williamr@2: const TInt KExecNotAllowed = -12007; // Executables not allowed williamr@2: const TInt KNoHostProcess = -12008; // Deprecated - not used williamr@2: const TInt KNotInitialized = -12009; // Not initialized williamr@2: const TInt KUserCancel = -12010; // User cancelled operation williamr@2: const TInt KDRMErrSession = -12011; // DRM session error. williamr@2: const TInt KDRMErrNoRights = -12012; // Invalid DRM rights. williamr@2: const TInt KDRMErrRightsDBCorrupted = -12013; // DRM rights db corrupted. williamr@2: const TInt KDRMErrInvalidVersion = -12014; // Invalid DRM version. williamr@2: const TInt KDRMErrPreviewRights = -12015; // Preview DRM rights. williamr@2: williamr@2: williamr@2: // DATA TYPES williamr@2: williamr@2: // API operations to inform special handlers of the entry function. williamr@2: enum TDocOperation williamr@2: { williamr@2: EDocCopy, // CopyL( aFileNameOld, aNameNew, aDataType, aAttr) williamr@2: EDocSave, // SaveL( aContent, aDataType, aAttr ) williamr@2: EDocSaveAs, // SaveL( aContent, aDataType,aFileName, aAttr ) williamr@2: EDocOpenFile, // OpenFileL( aFileName, aDataType ) williamr@2: EDocOpenFileEmb, // OpenFileEmbeddedL( aFileName, aDataType) williamr@2: EDocMove, // MoveL( aFileNameOld, aNameNew, aDataType, aAttr) williamr@2: EDocSilentMove, // SilentMoveL( aFileNameOld, aNameNew, aRootPaht, aDataType, aAttr) williamr@2: EDocSaveTemp, // SaveTempFileL( aContent, aDataType, aFileName, aSharableFile) williamr@2: }; williamr@2: williamr@2: // FORWARD DECLARATIONS williamr@2: class CDocHandlerBase; // Base class for handlers williamr@2: class CEikProcess; // The host process williamr@2: class MAknServerAppExitObserver; // Viewer app exit observer williamr@2: class TDataType; // Mime type handling williamr@2: class RApaLsSession; // App list server session williamr@2: class CAiwGenericParamList; // Generic parameter list williamr@2: williamr@2: // CLASS DECLARATION williamr@2: williamr@2: /** williamr@2: * Utility class for opening and saving any supported content. williamr@2: * This class declares an interface for the DocumentHandler, a williamr@2: * common component in Series60. williamr@2: * williamr@2: * The CDocumentHandler class will not itself implement any content williamr@2: * handling routines. It's responsible for finding out which application williamr@2: * can handle given data type and constructing a correct handler implementation williamr@2: * for that application. If the given data type is supported by the system williamr@2: * but no specific handler is found, the CDocDefaltHandler is then constructed. williamr@2: * The default handler is an implementation of the CDoCDocHandlerBase class with williamr@2: * standard "Epoc-style" content handling. williamr@2: * williamr@2: * The handler application can be lauched standalone or embedded. The williamr@2: * Embedded launching is preferred way in Series60. williamr@2: * Standalone launching means that the application will run in williamr@2: * it's own process. Embedded launching means that the UI of an williamr@2: * application, which is responsible for handling given data type, williamr@2: * is embedded into the parent application. There will be only williamr@2: * parent applications icon shown in the fast swap window when an williamr@2: * application is embedded. williamr@2: * williamr@2: * Link your application against CommonUI.lib. williamr@2: * williamr@2: * An example: williamr@2: *
 
williamr@2: * #include 
williamr@2: *
williamr@2: * // Define DocHandler
williamr@2: * CDocumentHandler* iDocHandler;
williamr@2: * 
williamr@2: * // Construct DocHandler
williamr@2: * void ConstructL()
williamr@2: *    {
williamr@2: *    iDocHandler = CDocumentHandler::NewL();
williamr@2: *
williamr@2: *    // I want to be notified when exit happends. Because I
williamr@2: *    // pass "this" pointer, I have to derive from
williamr@2: *    // MAknServerAppExitObserver class.
williamr@2: *    iDocHandler->SetExitObserver(this)     
williamr@2: *    }
williamr@2: *
williamr@2: * // delete DocHandler
williamr@2: * void ~Myapp()
williamr@2: *    {
williamr@2: *    delete iDocHandler;
williamr@2: *    }
williamr@2: *
williamr@2: *
williamr@2: * // and use like this
williamr@2: *
williamr@2: * void OpenAttachmentL( RFile& aFile,           // A file to be open
williamr@2: *                       TDataType& aDataType )  // DataType can be empty
williamr@2: *   {
williamr@2: *   TInt error = KErrNone;
williamr@2: *   TFileName path;
williamr@2: *
williamr@2: *   
williamr@2: *   // Leaves on system wide errors like disk full, out of memory etc.
williamr@2: *   error = iDocHandler->OpenFileEmbeddedL( aFile, aDataType );
williamr@2: *   // The status code can be either KErrNone or KUserCancel
williamr@2: *
williamr@2: *    }
williamr@2: * 
williamr@2: * williamr@2: */ williamr@2: NONSHARABLE_CLASS(CDocumentHandler) : public CBase williamr@2: { williamr@2: public: // Constructors and destructor williamr@2: williamr@2: /** williamr@2: * Two-phased constructor. Leaves on failure. williamr@2: * williamr@2: * @param aProcess The host process, which will be williamr@2: * used for embedded launching. williamr@2: * williamr@2: * @return The constructed CDocumentHandler williamr@2: * @deprecated in Series60 3.0, instead use NewL without CEikProcess parameter williamr@2: */ williamr@2: IMPORT_C static CDocumentHandler* NewL( CEikProcess* aProcess ); williamr@2: williamr@2: /** williamr@2: * Two-phased constructor. Leaves on failure. williamr@2: * williamr@2: * @param aProcess The host process, which will be williamr@2: * used for embedded launching. williamr@2: * williamr@2: * @return The constructed CDocumentHandler williamr@2: * @deprecated in Series60 3.0, instead use NewL without CEikProcess parameter williamr@2: */ williamr@2: IMPORT_C static CDocumentHandler* NewLC( CEikProcess* aProcess ); williamr@2: williamr@2: /** williamr@2: * Two-phased constructor. Leaves on failure. williamr@2: * williamr@2: * williamr@2: * @return The constructed CDocumentHandler williamr@2: * @since Series 60 3.0 williamr@2: */ williamr@2: IMPORT_C static CDocumentHandler* NewL( ); williamr@2: williamr@2: /** williamr@2: * Two-phased constructor. Leaves on failure. williamr@2: * williamr@2: * williamr@2: * @return The constructed CDocumentHandler williamr@2: * @since Series 60 3.0 williamr@2: */ williamr@2: IMPORT_C static CDocumentHandler* NewLC( ); williamr@2: williamr@2: /** williamr@2: * Destructor. williamr@2: */ williamr@2: IMPORT_C virtual ~CDocumentHandler(); williamr@2: williamr@2: private: // Constructors and destructor williamr@2: williamr@2: /** williamr@2: * C++ default constructor. williamr@2: */ williamr@2: CDocumentHandler( ); williamr@2: williamr@2: /** williamr@2: * C++ copy constructor williamr@2: */ williamr@2: CDocumentHandler( const CDocumentHandler& ); williamr@2: williamr@2: /** williamr@2: * By default EPOC constructor is private. williamr@2: */ williamr@2: void ConstructL(); williamr@2: williamr@2: public: // New functions, data caging williamr@2: williamr@2: /** williamr@2: * Utility method for opening filehandle from existing file for OpenFileL williamr@2: * calls. The created file handle is meant to be shared across process williamr@2: * boundaries. williamr@2: * williamr@2: * This function can leave in some system wide error situation. williamr@2: * E.g. out of memory, not enough space in filesystem etc. These williamr@2: * errors are usually trapped by the application framework. williamr@2: * williamr@2: * NOTE! Caller is responsible of closing opened file handle. williamr@2: * williamr@2: * @param aFileName Name (including directory information) for file. williamr@2: * This file should exist allready, otherwise this williamr@2: * function leaves with KErrNotFound. williamr@2: * @param aSharableFile Returned file handle that can be shared. williamr@2: * @since Series 60 3.0 williamr@2: */ williamr@2: IMPORT_C void OpenTempFileL( williamr@2: const TDesC& aFileName, williamr@2: RFile &aSharableFile); williamr@2: williamr@2: /** williamr@2: * Utility method for save aContent with aDataType temporarily williamr@2: * for OpenFileL calls. The created file handle is meant to be shared williamr@2: * across process boundaries. williamr@2: * williamr@2: * This temporary file will be saved to process private temp directory. williamr@2: * Temporary directory will be created if not existing yet. williamr@2: * williamr@2: * This function can leave in some system wide error situation. williamr@2: * E.g. out of memory, not enough space in filesystem etc. These williamr@2: * errors are usually trapped by the application framework. williamr@2: * williamr@2: * NOTE! Caller is responsible of closing opened file handle! williamr@2: * Created temporary file will be deleted in destructor of williamr@2: * DocumentHandler, but caller can delete it self as well. williamr@2: * williamr@2: * @param aContent A content data buffer. Narrow descriptor that williamr@2: * can contain any kind of data. williamr@2: * @param aDataType A data type for the content of the file. If empty williamr@2: * the DocumentHandler tries to recognize the content. williamr@2: * @param aFileName Use this name for saving. The name must not williamr@2: * contain any directory information. williamr@2: * @param aSharableFile Returned file handle that can be shared. williamr@2: * @since Series 60 3.0 williamr@2: */ williamr@2: IMPORT_C void SaveTempFileL( williamr@2: const TDesC8& aContent, williamr@2: TDataType& aDataType, williamr@2: const TDesC& aFileName, williamr@2: RFile &aSharableFile); williamr@2: williamr@2: public: // New functions, parameter handling williamr@2: williamr@2: /** williamr@2: * Returns an empty instance of CAiwGenericParamList class. It can be williamr@2: * used for example as an input parameter list for API methods. williamr@2: * This is just a convinience method and doesn't have williamr@2: * to be used. If consumer wants to create input list by itself williamr@2: * it is ok. If this method is used, service handler takes care williamr@2: * of deleting returned generic parameter list. williamr@2: * williamr@2: * @return An empty instance of CAiwGenericParameter list. williamr@2: * @since Series 60 3.0 williamr@2: */ williamr@2: IMPORT_C CAiwGenericParamList& InParamListL(); williamr@2: williamr@2: /** williamr@2: * Returns a list of possible output parameters handler application williamr@2: * may have set after executing the service. The caller is responsible williamr@2: * for deleting the parameter instance if not null. williamr@2: * williamr@2: * @return List of output parameters, NULL if nothing set. williamr@2: * @deprecated williamr@2: */ williamr@2: IMPORT_C const CAiwGenericParamList* OutParamList(); williamr@2: williamr@2: public: // New functions, open file with filehandle williamr@2: williamr@2: /** williamr@2: * Launches an application in standalone capable of handling williamr@2: * data in aSharableFile (using aDatatype if available). williamr@2: * Doesn't save data from the file. In case of DRM protected williamr@2: * files with restricted rights, there will be query asking williamr@2: * if user want open file. williamr@2: * williamr@2: * This function can leave in some system wide error situation. williamr@2: * E.g. out of memory, not enough space in filesystem etc. See williamr@2: * also possible error codes from documenthandler.h header file. williamr@2: * williamr@2: * @param aSharableFile A sharable file handle to be passed to williamr@2: * the launched application williamr@2: * @param aDataType A data type for the content of the file. If empty williamr@2: * the DocumentHandler tries to recognize the content. williamr@2: * @return KErrNone if success. KUserCancel if the user williamr@2: * cancelled the operation. williamr@2: * @since Series 60 3.0 williamr@2: */ williamr@2: IMPORT_C TInt OpenFileL( williamr@2: RFile& aSharableFile, williamr@2: TDataType& aDataType); williamr@2: williamr@2: /** williamr@2: * Launches an application in embedded (if possible) capable of williamr@2: * handling data in aSharableFile (using aDatatype if available). williamr@2: * Doesn't save data from the file. In case of DRM protected williamr@2: * files with restricted rights, there will be query asking williamr@2: * if user want open file. williamr@2: * williamr@2: * This function can leave in some system wide error situation. williamr@2: * E.g. out of memory, not enough space in filesystem etc. See williamr@2: * also possible error codes from documenthandler.h header file. williamr@2: * williamr@2: * @param aSharableFile A sharable file handle to be passed to williamr@2: * the launched application. williamr@2: * @param aDataType A data type for the content of the file. If empty williamr@2: * the DocumentHandler tries to recognize the content. williamr@2: * @param aParamList Parameter list to be passed to handler application. williamr@2: * @return KErrNone if success. KUserCancel if the user williamr@2: * cancelled the operation. williamr@2: * @since Series 60 3.0 williamr@2: */ williamr@2: IMPORT_C TInt OpenFileEmbeddedL( williamr@2: RFile& aSharableFile, williamr@2: TDataType& aDataType, williamr@2: const CAiwGenericParamList& aParamList); williamr@2: williamr@2: /** williamr@2: * Launches an application in embedded (if possible) capable of williamr@2: * handling data in aSharableFile (using aDatatype if available). williamr@2: * Doesn't save data from the file. In case of DRM protected williamr@2: * files with restricted rights, there will be query asking williamr@2: * if user want open file. williamr@2: * williamr@2: * This function can leave in some system wide error situation. williamr@2: * E.g. out of memory, not enough space in filesystem etc. See williamr@2: * also possible error codes from documenthandler.h header file. williamr@2: * williamr@2: * @param aSharableFile A sharable file handle to be passed to williamr@2: * the launched application. williamr@2: * @param aDataType A data type for the content of the file. If empty williamr@2: * the DocumentHandler tries to recognize the content. williamr@2: * @return KErrNone if success. KUserCancel if the user williamr@2: * cancelled the operation. williamr@2: * @since Series 60 3.0 williamr@2: */ williamr@2: IMPORT_C TInt OpenFileEmbeddedL( williamr@2: RFile& aSharableFile, williamr@2: TDataType& aDataType); williamr@2: williamr@2: public: // open file with filename williamr@2: williamr@2: /** williamr@2: * Launches an application standalone capable of handling williamr@2: * data in aFilename, with aDataType. Doesn't copy data williamr@2: * from the file. williamr@2: * williamr@2: * This function can leave in some system wide error situation. williamr@2: * E.g. out of memory, not enough space in filesystem etc. See williamr@2: * also possible error codes from documenthandler.h header file. williamr@2: * williamr@2: * @param aFileName Name of the file. Directory path included. williamr@2: * @param aDataType A data type for the content of the file. If empty williamr@2: * the DocumentHandler tries to recognize the content. williamr@2: * @return KErrNone if success. KUserCancel if the user williamr@2: * cancelled the operation. williamr@2: */ williamr@2: IMPORT_C TInt OpenFileL( williamr@2: const TDesC& aFileName, williamr@2: TDataType& aDataType ); williamr@2: williamr@2: /** williamr@2: * Launches an application embedded capable of handling data in williamr@2: * aFilename with aDataType. Doesn't copy data from the file. williamr@2: * williamr@2: * This function can leave in some system wide error situation. williamr@2: * E.g. out of memory, not enough space in filesystem etc. See williamr@2: * also possible error codes from documenthandler.h header file. williamr@2: * williamr@2: * @param aFileName Name of the file. Directory path included. williamr@2: * @param aDataType A data type for the content of the file. If empty williamr@2: * the DocumentHandler tries to recognize the content. williamr@2: * @return KErrNone if success. KUserCancel if the user williamr@2: * cancelled the operation. williamr@2: */ williamr@2: IMPORT_C TInt OpenFileEmbeddedL( williamr@2: const TDesC& aFileName, williamr@2: TDataType& aDataType ); williamr@2: williamr@2: public: // data saving williamr@2: williamr@2: /** williamr@2: * Save aContent with aDataType using aAttr to a correct directory. williamr@2: * Generates a new name for saving. The storage is usually a filesystem, williamr@2: * but can be anything from application spesific data structures to williamr@2: * a database. williamr@2: * williamr@2: * This function can leave in some system wide error situation. williamr@2: * E.g. out of memory, not enough space in filesystem etc. See williamr@2: * also possible error codes from documenthandler.h header file. williamr@2: * williamr@2: * @param aContent A content data buffer. Narrow descriptor that williamr@2: * can contain any kind of data. williamr@2: * @param aDataType A data type for the content of the file. If empty williamr@2: * the DocumentHandler tries to recognize the content. williamr@2: * @param aAttr Use these file attributes for saving. Your can williamr@2: * find these attributes from williamr@2: * \epoc32\include\f32file.h header file. williamr@2: * If the storage is not a filesystem these williamr@2: * attributes are ignored. williamr@2: * @return KErrNone if success. KUserCancel if the user williamr@2: * cancelled the operation. williamr@2: */ williamr@2: IMPORT_C TInt SaveL( williamr@2: const TDesC8& aContent, williamr@2: TDataType& aDataType, williamr@2: const TUint aAttr ); williamr@2: williamr@2: /** williamr@2: * Save aBuffer with aDataType using aAttr to a correct storage with a williamr@2: * supplied name. The storage is usually a filesystem, but can be williamr@2: * anything from application spesific data structures to a database. williamr@2: * williamr@2: * This function can leave in some system wide error situation. williamr@2: * E.g. out of memory, not enough space in filesystem etc. See williamr@2: * also possible error codes from documenthandler.h header file. williamr@2: * williamr@2: * @param aContent A content data buffer. Narrow descriptor that williamr@2: * can contain any kind of data. williamr@2: * @param aDataType A data type for the content of the file. If empty williamr@2: * the DocumentHandler tries to recognize the content. williamr@2: * @param aName Use this name for saving. The name must not williamr@2: * contain any directory information. williamr@2: * @param aAttr Use these file attributes for saving. Your can williamr@2: * find these attributes from williamr@2: * \epoc32\include\f32file.h header file. williamr@2: * If the storage is not a filesystem these williamr@2: * attributes are ignored. williamr@2: * @return KErrNone if success. KUserCancel if the user williamr@2: * cancelled the operation. williamr@2: */ williamr@2: IMPORT_C TInt SaveL( williamr@2: const TDesC8& aContent, williamr@2: TDataType& aDataType, williamr@2: const TDesC& aName, williamr@2: const TUint aAttr ); williamr@2: williamr@2: /** williamr@2: * Copy a file named aFileNameOld to the correct storage using williamr@2: * name aNameNew and aFileAttr. If aNameNew is empty, use williamr@2: * the old name. williamr@2: * williamr@2: * This function can leave in some system wide error situation. williamr@2: * E.g. out of memory, not enough space in filesystem etc. See williamr@2: * also possible error codes from documenthandler.h header file. williamr@2: * williamr@2: * @param aFileNameOld Name of the file being copied. williamr@2: * @param aNameNew Name of the new file. If null, use the williamr@2: * old name. williamr@2: * @param aDataType A data type for the file. If empty the williamr@2: * DocumentHandler tries to recognize type. williamr@2: * @param aAttr Use these file attributes for saving. williamr@2: * ReadOnly, ReadWrite. williamr@2: * @return KErrNone if success. KUserCancel if the user williamr@2: * cancelled the operation. williamr@2: */ williamr@2: IMPORT_C TInt CopyL( williamr@2: const TDesC& aFileNameOld, williamr@2: const TDesC& aNameNew, williamr@2: TDataType& aDataType, williamr@2: const TUint aAttr ); williamr@2: williamr@2: /** williamr@2: * Copy a file with handle aFileOld to the correct storage using williamr@2: * name aNameNew and aFileAttr. If aNameNew is empty, use williamr@2: * the old name. williamr@2: * williamr@2: * This function can leave in some system wide error situation. williamr@2: * E.g. out of memory, not enough space in filesystem etc. See williamr@2: * also possible error codes from documenthandler.h header file. williamr@2: * williamr@2: * @param aFileOld Handle of the file being copied. williamr@2: * @param aNameNew Name of the new file. If null, use the williamr@2: * old name. williamr@2: * @param aDataType A data type for the file. If empty the williamr@2: * DocumentHandler tries to recognize type. williamr@2: * @param aAttr Use these file attributes for saving. williamr@2: * ReadOnly, ReadWrite. williamr@2: * @return KErrNone if success. KUserCancel if the user williamr@2: * cancelled the operation. williamr@2: */ williamr@2: IMPORT_C TInt CopyL( williamr@2: const RFile& aFileOld, williamr@2: const TDesC& aNameNew, williamr@2: TDataType& aDataType, williamr@2: const TUint aAttr ); williamr@2: williamr@2: /** williamr@2: * Move a file named aFileNameOld to the correct storage using williamr@2: * name aNameNew and aFileAttr. Note that file in the old location williamr@2: * (aFileNameOld) will be removed during this operation. williamr@2: * williamr@2: * This function can leave in some system wide error situation. williamr@2: * E.g. out of memory, not enough space in filesystem etc. See williamr@2: * also possible error codes from documenthandler.h header file. williamr@2: * williamr@2: * @param aFileNameOld Name of the file being copied. williamr@2: * @param aNameNew Name of the new file. If null, use the williamr@2: * default name for this mime-type. williamr@2: * @param aDataType A data type for the file. If empty the williamr@2: * DocumentHandler tries to recognize type. williamr@2: * @param aAttr Use these file attributes for saving. williamr@2: * ReadOnly, ReadWrite. williamr@2: * @return KErrNone if success. KUserCancel if the user williamr@2: * cancelled the operation. williamr@2: * @since Series60 2.8 williamr@2: */ williamr@2: IMPORT_C TInt MoveL( williamr@2: const TDesC& aFileNameOld, williamr@2: const TDesC& aNameNew, williamr@2: TDataType& aDataType, williamr@2: const TUint aAttr ); williamr@2: williamr@2: /** williamr@2: * Move a file named aFileNameOld to the correct storage using williamr@2: * name aNameNew and aFileAttr. This method operates silently, so williamr@2: * nothing will be asked from user. Caller should give root path of williamr@2: * the selected memory. Unique file name will be created automatically williamr@2: * without user interaction. Note that file in the old location williamr@2: * (aFileNameOld) will be removed during this operation. williamr@2: * williamr@2: * This function can leave in some system wide error situation. williamr@2: * E.g. out of memory, not enough space in filesystem etc. See williamr@2: * also possible error codes from documenthandler.h header file. williamr@2: * williamr@2: * @param aFileNameOld Name of the file being copied. williamr@2: * @param aNameNew Name of the new file. If null, use the williamr@2: * default name for this mime-type. williamr@2: * @param aRootPath Root path of the selected memory where file williamr@2: * should be moved. williamr@2: * @param aDataType A data type for the file. If empty the williamr@2: * DocumentHandler tries to recognize type. williamr@2: * @param aAttr Use these file attributes for saving. williamr@2: * ReadOnly, ReadWrite. williamr@2: * @return KErrNone if success. williamr@2: * @since Series60 3.0 williamr@2: */ williamr@2: IMPORT_C TInt SilentMoveL( williamr@2: const TDesC& aFileNameOld, williamr@2: const TDesC& aNameNew, williamr@2: const TDesC& aRootPath, williamr@2: TDataType& aDataType, williamr@2: const TUint aAttr ); williamr@2: williamr@2: williamr@2: public: // query functions williamr@2: williamr@2: /** williamr@2: * Is the aDataType supported by the system. williamr@2: * williamr@2: * @param aDataType Data type for content. williamr@2: * williamr@2: * @return True if there is an application capable of handling williamr@2: * aDataType. False if no application can handle williamr@2: * this mime type. williamr@2: */ williamr@2: IMPORT_C TBool CanHandleL( const TDataType& aDataType ); williamr@2: williamr@2: /** williamr@2: * Is opening of aDataType supported by the system. williamr@2: * williamr@2: * @param aDataType Data type for content. williamr@2: * williamr@2: * @return True if there is an application capable of handling williamr@2: * aDataType. False if no application can handle williamr@2: * this mime type. williamr@2: */ williamr@2: IMPORT_C TBool CanOpenL( const TDataType& aDataType ); williamr@2: williamr@2: /** williamr@2: * Is saving aDataType supported by the system. williamr@2: * williamr@2: * @param aDataType Data type for content. williamr@2: * williamr@2: * @return True if there is an application capable of handling williamr@2: * aDataType. False if no application can handle williamr@2: * this mime type. williamr@2: */ williamr@2: IMPORT_C TBool CanSaveL( const TDataType& aDataType ); williamr@2: williamr@2: /** williamr@2: * Get the whole path including filename where the content was saved. williamr@2: * If the content was not saved to a file, this function returns williamr@2: * a name that represents the saved object. williamr@2: * williamr@2: * It may not be possible to open the object with the returned williamr@2: * value, if it's not a real file in the filesystem. This situation williamr@2: * may happen when e.g. the handler application stores it's contents in williamr@2: * some weird data structure. williamr@2: * williamr@2: * @param aPath The path of the saved content. williamr@2: * williamr@2: * @return KErrNone if the path was found. KNotInitialised if the williamr@2: * handler is not initialised. williamr@2: */ williamr@2: IMPORT_C TInt GetPath( TDes& aPath ); williamr@2: williamr@2: /** williamr@2: * Get the uid of handler application. In case of media files uid is williamr@2: * Media Gallery's uid. This method should be called only succesfully williamr@2: * completed DocumentHandler operations. williamr@2: * williamr@2: * @param aUid Uid of the handler application for the content. williamr@2: * williamr@2: * @return KErrNone if the uid was found. KNotInitialised if the williamr@2: * handler is not initialised. williamr@2: * @since Series 60 2.8 williamr@2: */ williamr@2: IMPORT_C TInt HandlerAppUid( TUid& aUid ); williamr@2: williamr@2: /** williamr@2: * Set an observer for embedded application exit events. williamr@2: * DocumentHandler will delegate embedding applications exit williamr@2: * events to aObserver if it's not NULL: williamr@2: * williamr@2: * @param aObserver Exit observer williamr@2: * @since Series 60 3.0 williamr@2: */ williamr@2: IMPORT_C void SetExitObserver( MAknServerAppExitObserver* aObserver ); williamr@2: williamr@2: /** williamr@2: * Utility method for appending a correct file name extension for some williamr@2: * content. This method should be called if wanted quarantee that file williamr@2: * extension of aFileName is correct with aDataType. williamr@2: * williamr@2: * This method uses internal mapping table to find correct file williamr@2: * extension to aFileName. Mapping table contains mainly extensions williamr@2: * and datatypes, which cannot be recognized based on the data it self williamr@2: * (No header information etc.). williamr@2: * williamr@2: * This method replaces existing extension with correct one at aFileName williamr@2: * if needed. If aDatatype is not found from mapping table or aDatatype williamr@2: * is not supported by any application, aFileName will remain unchanged. williamr@2: * williamr@2: * @param aFileName Append extension to this filename. williamr@2: * @param aDataType The content type of the file. williamr@2: * @since Series 60 3.0 williamr@2: */ williamr@2: IMPORT_C void CheckFileNameExtension( williamr@2: TDes& aFileName, williamr@2: const TDataType& aDatatype ); williamr@2: williamr@2: /** williamr@2: * Get the RApaLsSession. williamr@2: * williamr@2: * @return Pointer to RApaLsSession williamr@2: */ williamr@2: RApaLsSession* ApaLs(); williamr@2: williamr@2: /** williamr@2: * Get the exit observer. williamr@2: * williamr@2: * @return Pointer to exit observer williamr@2: * @since Series 60 3.0 williamr@2: */ williamr@2: MAknServerAppExitObserver* ServerAppExitObserver() const; williamr@2: williamr@2: /** williamr@2: * Get the operation code of the api entry function. williamr@2: */ williamr@2: TDocOperation DocOperation() const; williamr@2: williamr@2: /** williamr@2: * Close sharable FileSession. williamr@2: */ williamr@2: void CloseSharableFS(); williamr@2: williamr@2: /** williamr@2: * Set temporary file, which will be deleted in destructor. williamr@2: */ williamr@2: void SetTempFile( const TDesC& aTempFile); williamr@2: williamr@2: /** williamr@2: * Utility method to find out if there are any applications that williamr@2: * support progressive downloading for a given data type. williamr@2: * williamr@2: * The decision is based on configuration made in central repository. williamr@2: * williamr@2: * @param aDataType The content type of the file. williamr@2: * @param aUid An Uid of the applications for the given data type. williamr@2: * @return ETrue if progressive download was supported for the given williamr@2: * data type. Otherwise EFalse. williamr@2: * @since Series 60 3.1 williamr@2: */ williamr@2: IMPORT_C TBool CanHandleProgressivelyL( williamr@2: const TDataType& aDataType, williamr@2: TUid& aUid ); williamr@2: williamr@2: /** williamr@2: * Utility method to provide a list of applications that support williamr@2: * progressive downloading. williamr@2: * williamr@2: * The list of applications uids is configured central repository. williamr@2: * williamr@2: * @param aUidList A list of app Uids williamr@2: * @since Series 60 3.2 williamr@2: */ williamr@2: IMPORT_C void GetProgressiveDownloadAppUidsL( RArray& aUidList ); williamr@2: williamr@2: private: // New functions williamr@2: williamr@2: /** williamr@2: * Construct a handler for a given data type. A previous handler will williamr@2: * be destroyed and the new one is constructed. williamr@2: * williamr@2: * The desicion of which handler implementation to use is williamr@2: * based on Apparc's AppForDataType query. If the app uid is williamr@2: * found for aDataType and there is a hardcoded handler for it, williamr@2: * the right handler will be constucted. If the app uid is not found williamr@2: * try to match a data type for some handler. The default handler is williamr@2: * constructed if no handler entry is found. williamr@2: * williamr@2: * @param aUid UID of the handler application. williamr@2: * @return Error code williamr@2: */ williamr@2: TInt FindHandlerL( williamr@2: const TDataType& aDataType, williamr@2: const TUid& aUid); williamr@2: williamr@2: /** williamr@2: * Try to find a handler for aUid. Constructs iHandler if found. williamr@2: * williamr@2: * @param aDataType A data type to pass to a handler williamr@2: * @param aUid An uid to search a handler for williamr@2: */ williamr@2: void FindHandlerByUidL( williamr@2: const TUid& aUid, williamr@2: const TDataType& aDataType); williamr@2: williamr@2: /** williamr@2: * Try to find a handler for aDataType. Constructs iHandler if found. williamr@2: * williamr@2: * @param aUid An Uid for handler application. williamr@2: * @param aDataType A data type to search a handler for. williamr@2: */ williamr@2: void FindHandlerByMimeTypeL( williamr@2: const TUid& aUid, williamr@2: const TDataType& aDataType); williamr@2: williamr@2: /** williamr@2: * Makes all the nesessary security checks and maps aDataType to williamr@2: * an UID of the handler application. If system is not able to handle williamr@2: * the content type, or file is DRM protectedfile, aDataType and aUid williamr@2: * will left empty. williamr@2: * williamr@2: * @param aFileName Filename williamr@2: * @param aDataType Data type for the file williamr@2: * @param aUid An application UID will be returned if a handler williamr@2: * was found. williamr@2: * @return KErrNone if success, error code if failure. williamr@2: */ williamr@2: TInt RecognizeAndCheckFileL( williamr@2: const TDesC& aFileName, williamr@2: TDataType& aDataType, williamr@2: TUid& aUid ); williamr@2: williamr@2: /** williamr@2: * Makes all the nesessary security checks and maps aDataType to williamr@2: * an UID of the handler application. If system is not able to handle williamr@2: * the content type, or file is DRM protectedfile, aDataType and aUid williamr@2: * will left empty. williamr@2: * williamr@2: * @param aFileHandle Filehandle williamr@2: * @param aDataType Data type for the file williamr@2: * @param aUid An application UID will be returned if a handler williamr@2: * was found. williamr@2: * @return KErrNone if success, error code if failure. williamr@2: */ williamr@2: TInt RecognizeAndCheckFileL( williamr@2: RFile& aFileHandle, williamr@2: TDataType& aDataType, williamr@2: TUid& aUid ); williamr@2: williamr@2: /** williamr@2: * This method lists all supported mime-types of system using williamr@2: * RDebug::Print. On UREL mode this method do nothing. williamr@2: */ williamr@2: void ListSupportedMimeTypesL(); williamr@2: williamr@2: /** williamr@2: * Prohibit the assignment operation williamr@2: */ williamr@2: CDocumentHandler operator=( const CDocumentHandler& ) const; williamr@2: williamr@2: /** williamr@2: * Convert a hex string to 32-bit integer. williamr@2: */ williamr@2: TInt ConvertHexStringToInt32( williamr@2: const TDesC& aHexString, williamr@2: TInt32& aInt ); williamr@2: williamr@2: private: // Data williamr@2: williamr@2: /** williamr@2: * The entry operation. Handlers can query about the entry function williamr@2: * when they need to implement some special behaviour. williamr@2: */ williamr@2: TDocOperation iOperation; williamr@2: williamr@2: /** williamr@2: * A handler providing operations. williamr@2: */ williamr@2: CDocHandlerBase* iHandler; williamr@2: williamr@2: /** williamr@2: * A ApaLs session client. williamr@2: */ williamr@2: RApaLsSession* iApaLs; williamr@2: williamr@2: /** williamr@2: * Notify embedded app's exit event to this observer. williamr@2: */ williamr@2: MAknServerAppExitObserver* iServerAppExitObserver; williamr@2: williamr@2: /** williamr@2: * Holds sharable Fileserver session williamr@2: */ williamr@2: RFs iSharableFS; williamr@2: williamr@2: /** williamr@2: * Parameter list created using InParamListL function williamr@2: */ williamr@2: CAiwGenericParamList* iInParams; williamr@2: williamr@2: /** williamr@2: * Filename of temporary saved file. This file will be deleted williamr@2: * in destructor of documenthandler williamr@2: */ williamr@2: TFileName iTempFileName; williamr@2: williamr@2: }; williamr@2: williamr@2: #endif // DOCUMENTHANDLER_H williamr@2: williamr@2: // End of File