00001 /* 00002 * ============================================================================== 00003 * Name : DocumentHandler.h 00004 * Part of : Document handler (CommonUI) 00005 * Description : Definition of CDocumentHandler class. 00006 * The purpose of the Documenthandler is to offer to applications 00007 * - wrapper for application embedding 00008 * - temporary file utility to support data caging for platform security 00009 * 00010 * Version : ?Version 00011 * 00012 * Copyright © 2002-2005 Nokia. All rights reserved. 00013 * This material, including documentation and any related 00014 * computer programs, is protected by copyright controlled by 00015 * Nokia. All rights are reserved. Copying, including 00016 * reproducing, storing, adapting or translating, any 00017 * or all of this material requires the prior written consent of 00018 * Nokia. This material also contains confidential 00019 * information which may not be disclosed to others without the 00020 * prior written consent of Nokia. 00021 * ============================================================================== 00022 */ 00023 00024 #ifndef DOCUMENTHANDLER_H 00025 #define DOCUMENTHANDLER_H 00026 00027 // INCLUDES 00028 #include <e32base.h> 00029 #include <f32file.h> 00030 00031 // CONSTANTS 00032 00033 // App UIDs for handlers. Handlers are identified by the handler application's 00034 // UID. E.g. The handler for WMLC (binary format of Wireless Markup Language) 00035 // is responsible for launching the WMLBrowser. The data type 00036 // application/wap.vnd.wmlc is therefore mapped to the browser's UID, 00037 // 0x10008D39. 00038 00039 const TInt KTextHandler = 0x1000599d; // Notepad viever 00040 const TInt KWmlcHandler = 0x10008D39; // WML Browser 00041 const TInt KJamHandler = 0x100009C1; // JAM 00042 const TInt KAppInstHandler = 0x101F875A; // Installer 00043 const TInt KBioViewerAppHandler = 0x0FC99F01; // BVA 00044 const TInt KImageViewerHandler = 0x101f4d90; // Image viever 00045 const TInt KCertSaveAppHandler = 0x100059D2; // Cert response handler app 00046 const TInt KCODHandler = 0x10008d4a; // COD handler 00047 const TInt KDDhandler = 0x10008d3f; // DD Handler 00048 00049 // A global external mime type for all nokia games. 00050 _LIT8(KGameMimeType, "application/x-NokiaGameData"); 00051 _LIT8(KDataTypeODM,"application/vnd.oma.drm.message"); // Not supported by DocumentHandler 00052 _LIT8(KDataTypeDCF,"application/vnd.oma.drm.content"); // Deprecated, do not use from here 00053 00054 // Fail reasons 00055 const TInt KBadMimeType = -12002; // Mime type conflict etc. 00056 const TInt KMimeNotSupported = -12003; // No handler found 00057 const TInt KNullContent = -12005; // Empty content 00058 const TInt KDataDirNotFound = -12006; // Deprecated - not used 00059 const TInt KExecNotAllowed = -12007; // Executables not allowed 00060 const TInt KNoHostProcess = -12008; // Deprecated - not used 00061 const TInt KNotInitialized = -12009; // Not initialized 00062 const TInt KUserCancel = -12010; // User cancelled operation 00063 const TInt KDRMErrSession = -12011; // DRM session error. 00064 const TInt KDRMErrNoRights = -12012; // Invalid DRM rights. 00065 const TInt KDRMErrRightsDBCorrupted = -12013; // DRM rights db corrupted. 00066 const TInt KDRMErrInvalidVersion = -12014; // Invalid DRM version. 00067 const TInt KDRMErrPreviewRights = -12015; // Preview DRM rights. 00068 00069 00070 // DATA TYPES 00071 00072 // API operations to inform special handlers of the entry function. 00073 enum TDocOperation 00074 { 00075 EDocCopy, // CopyL( aFileNameOld, aNameNew, aDataType, aAttr) 00076 EDocSave, // SaveL( aContent, aDataType, aAttr ) 00077 EDocSaveAs, // SaveL( aContent, aDataType,aFileName, aAttr ) 00078 EDocOpenFile, // OpenFileL( aFileName, aDataType ) 00079 EDocOpenFileEmb, // OpenFileEmbeddedL( aFileName, aDataType) 00080 EDocMove, // MoveL( aFileNameOld, aNameNew, aDataType, aAttr) 00081 EDocSilentMove, // SilentMoveL( aFileNameOld, aNameNew, aRootPaht, aDataType, aAttr) 00082 EDocSaveTemp, // SaveTempFileL( aContent, aDataType, aFileName, aSharableFile) 00083 }; 00084 00085 // FORWARD DECLARATIONS 00086 class CDocHandlerBase; // Base class for handlers 00087 class CEikProcess; // The host process 00088 class MAknServerAppExitObserver; // Viewer app exit observer 00089 class TDataType; // Mime type handling 00090 class RApaLsSession; // App list server session 00091 class CAiwGenericParamList; // Generic parameter list 00092 00093 // CLASS DECLARATION 00094 00161 NONSHARABLE_CLASS(CDocumentHandler) : public CBase 00162 { 00163 public: // Constructors and destructor 00164 00174 IMPORT_C static CDocumentHandler* NewL( CEikProcess* aProcess ); 00175 00185 IMPORT_C static CDocumentHandler* NewLC( CEikProcess* aProcess ); 00186 00194 IMPORT_C static CDocumentHandler* NewL( ); 00195 00203 IMPORT_C static CDocumentHandler* NewLC( ); 00204 00208 IMPORT_C virtual ~CDocumentHandler(); 00209 00210 private: // Constructors and destructor 00211 00215 CDocumentHandler( ); 00216 00220 CDocumentHandler( const CDocumentHandler& ); 00221 00225 void ConstructL(); 00226 00227 public: // New functions, data caging 00228 00246 IMPORT_C void OpenTempFileL( 00247 const TDesC& aFileName, 00248 RFile &aSharableFile); 00249 00275 IMPORT_C void SaveTempFileL( 00276 const TDesC8& aContent, 00277 TDataType& aDataType, 00278 const TDesC& aFileName, 00279 RFile &aSharableFile); 00280 00281 public: // New functions, parameter handling 00282 00294 IMPORT_C CAiwGenericParamList& InParamListL(); 00295 00304 IMPORT_C const CAiwGenericParamList* OutParamList(); 00305 00306 public: // New functions, open file with filehandle 00307 00327 IMPORT_C TInt OpenFileL( 00328 RFile& aSharableFile, 00329 TDataType& aDataType); 00330 00351 IMPORT_C TInt OpenFileEmbeddedL( 00352 RFile& aSharableFile, 00353 TDataType& aDataType, 00354 const CAiwGenericParamList& aParamList); 00355 00375 IMPORT_C TInt OpenFileEmbeddedL( 00376 RFile& aSharableFile, 00377 TDataType& aDataType); 00378 00379 public: // open file with filename 00380 00396 IMPORT_C TInt OpenFileL( 00397 const TDesC& aFileName, 00398 TDataType& aDataType ); 00399 00414 IMPORT_C TInt OpenFileEmbeddedL( 00415 const TDesC& aFileName, 00416 TDataType& aDataType ); 00417 00418 public: // data saving 00419 00442 IMPORT_C TInt SaveL( 00443 const TDesC8& aContent, 00444 TDataType& aDataType, 00445 const TUint aAttr ); 00446 00470 IMPORT_C TInt SaveL( 00471 const TDesC8& aContent, 00472 TDataType& aDataType, 00473 const TDesC& aName, 00474 const TUint aAttr ); 00475 00495 IMPORT_C TInt CopyL( 00496 const TDesC& aFileNameOld, 00497 const TDesC& aNameNew, 00498 TDataType& aDataType, 00499 const TUint aAttr ); 00500 00520 IMPORT_C TInt CopyL( 00521 const RFile& aFileOld, 00522 const TDesC& aNameNew, 00523 TDataType& aDataType, 00524 const TUint aAttr ); 00525 00546 IMPORT_C TInt MoveL( 00547 const TDesC& aFileNameOld, 00548 const TDesC& aNameNew, 00549 TDataType& aDataType, 00550 const TUint aAttr ); 00551 00576 IMPORT_C TInt SilentMoveL( 00577 const TDesC& aFileNameOld, 00578 const TDesC& aNameNew, 00579 const TDesC& aRootPath, 00580 TDataType& aDataType, 00581 const TUint aAttr ); 00582 00583 00584 public: // query functions 00585 00595 IMPORT_C TBool CanHandleL( const TDataType& aDataType ); 00596 00606 IMPORT_C TBool CanOpenL( const TDataType& aDataType ); 00607 00617 IMPORT_C TBool CanSaveL( const TDataType& aDataType ); 00618 00634 IMPORT_C TInt GetPath( TDes& aPath ); 00635 00647 IMPORT_C TInt HandlerAppUid( TUid& aUid ); 00648 00657 IMPORT_C void SetExitObserver( MAknServerAppExitObserver* aObserver ); 00658 00677 IMPORT_C void CheckFileNameExtension( 00678 TDes& aFileName, 00679 const TDataType& aDatatype ); 00680 00686 RApaLsSession* ApaLs(); 00687 00694 MAknServerAppExitObserver* ServerAppExitObserver() const; 00695 00699 TDocOperation DocOperation() const; 00700 00704 void CloseSharableFS(); 00705 00709 void SetTempFile( const TDesC& aTempFile); 00710 00711 #start_since SINCE_3_1_SDK 00712 00725 IMPORT_C TBool CanHandleProgressivelyL( 00726 const TDataType& aDataType, 00727 TUid& aUid ); 00728 #end_since SINCE_3_1_SDK 00729 00730 00731 private: // New functions 00732 00747 TInt FindHandlerL( 00748 const TDataType& aDataType, 00749 const TUid& aUid); 00750 00757 void FindHandlerByUidL( 00758 const TUid& aUid, 00759 const TDataType& aDataType); 00760 00767 void FindHandlerByMimeTypeL( 00768 const TUid& aUid, 00769 const TDataType& aDataType); 00770 00783 TInt RecognizeAndCheckFileL( 00784 const TDesC& aFileName, 00785 TDataType& aDataType, 00786 TUid& aUid ); 00787 00800 TInt RecognizeAndCheckFileL( 00801 RFile& aFileHandle, 00802 TDataType& aDataType, 00803 TUid& aUid ); 00804 00809 void ListSupportedMimeTypesL(); 00810 00814 CDocumentHandler operator=( const CDocumentHandler& ) const; 00815 00819 TInt ConvertHexStringToInt32( 00820 const TDesC& aHexString, 00821 TInt32& aInt ); 00822 00823 private: // Data 00824 00829 TDocOperation iOperation; 00830 00834 CDocHandlerBase* iHandler; 00835 00839 RApaLsSession* iApaLs; 00840 00844 MAknServerAppExitObserver* iServerAppExitObserver; 00845 00849 RFs iSharableFS; 00850 00854 CAiwGenericParamList* iInParams; 00855 00860 TFileName iTempFileName; 00861 00862 }; 00863 00864 // DOCUMENTHANDLER_H 00865 #endif 00866 00867 // End of File