mmfenh/progressivedownload/ProgressiveDownloadSource/src/FileAccess.h
changeset 16 43d09473c595
parent 14 80975da52420
child 22 128eb6a32b84
equal deleted inserted replaced
14:80975da52420 16:43d09473c595
     1 /*
       
     2 * Copyright (c) 2004 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:  Progressive Download Utility
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef __FILE_ACCESS_H__
       
    19 #define __FILE_ACCESS_H__
       
    20 
       
    21 #include <caf/content.h>
       
    22 #include <caf/data.h>
       
    23 #include <mmf/common/mmcaf.h>
       
    24 
       
    25 // Abstract class providing generic file access
       
    26 class MGenericFile
       
    27 	{
       
    28 public:
       
    29 	virtual ~MGenericFile();
       
    30 
       
    31 	virtual TInt Seek(TSeek aSeekMode, TInt aPosition)=0;
       
    32 	virtual TInt Read(TDes8& aDes,TInt aLength)=0;
       
    33 	virtual void Read(TDes8& aDes, TInt aLength, TRequestStatus& aStatus)=0;
       
    34 
       
    35 	virtual TInt Write(const TDesC8& aDes,TInt aLength)=0;
       
    36 	virtual void Write(const TDesC8& aDes, TInt aLength, TRequestStatus& aStatus)=0;
       
    37 
       
    38 	virtual TInt Size(TInt& aSize)=0;
       
    39 	virtual TInt SetSize(TInt aSize)=0;
       
    40 
       
    41 	virtual TInt EvaluateIntent(const ContentAccess::TIntent aIntent) const = 0;
       
    42 	virtual TInt ExecuteIntent(const ContentAccess::TIntent aIntent) = 0;
       
    43 	virtual TBool IsProtected()const = 0;
       
    44 
       
    45 	// legacy file support
       
    46 	virtual RFile& FileL()=0;
       
    47 
       
    48 
       
    49 	virtual TInt SetAgentProperty(ContentAccess::TAgentProperty aProperty, TInt aValue) = 0;
       
    50 
       
    51 
       
    52 	};
       
    53 
       
    54 // Provide RFile based file access
       
    55 class CF32File : public CBase, public MGenericFile
       
    56 	{
       
    57 public:
       
    58 	static CF32File* NewL(RFs& aSession, TDesC& aPath, TUint aMode);
       
    59 
       
    60 	static CF32File* NewL(RFile& aFile);
       
    61 	void ConstructL(RFile& aFile);
       
    62 
       
    63 	void ConstructL(RFs& aSession, TDesC& aPath, TUint aMode);
       
    64 
       
    65 	virtual ~CF32File();
       
    66 
       
    67 	// from MGenericFile
       
    68 	virtual TInt Seek(TSeek aSeekMode, TInt aPosition);
       
    69 	virtual TInt Read(TDes8& aDes,TInt aLength);
       
    70 	virtual void Read(TDes8& aDes, TInt aLength, TRequestStatus& aStatus);
       
    71 	virtual TInt Write(const TDesC8& aDes,TInt aLength);
       
    72 	virtual void Write(const TDesC8& aDes, TInt aLength, TRequestStatus& aStatus);
       
    73 	virtual TInt Size(TInt& aSize);
       
    74 	virtual TInt SetSize(TInt aSize);
       
    75 	virtual TInt EvaluateIntent(const ContentAccess::TIntent aIntent) const;
       
    76 	virtual TInt ExecuteIntent(const ContentAccess::TIntent aIntent);
       
    77 	virtual TBool IsProtected() const;
       
    78 	virtual RFile& FileL();
       
    79 
       
    80 
       
    81 	virtual TInt SetAgentProperty(ContentAccess::TAgentProperty, TInt aValue);
       
    82 
       
    83 
       
    84 private:
       
    85 	CF32File();
       
    86 
       
    87 private:
       
    88 	RFs* iSession;	// not owned
       
    89 	HBufC* iFilePath;
       
    90 	RFile iFile;
       
    91 
       
    92 	TBool iFileHandle;
       
    93 	TInt iFileSize;
       
    94 	};
       
    95 
       
    96 // Provides content access framework based file access
       
    97 class CContentFile : public CBase, public MGenericFile
       
    98 	{
       
    99 public:
       
   100 
       
   101 	static CContentFile* NewL(RFs& aSession, const TDesC& aPath, const TDesC& aUniqueId, TUint aMode);
       
   102 	void ConstructL(RFs& aSession, const TDesC& aPath, const TDesC& aUniqueId, TUint aMode);
       
   103 
       
   104 	static CContentFile* NewL(RFs& aSession, const TDesC& aPath, TUint aMode);
       
   105 	void ConstructL(RFs& aSession, const TDesC& aPath, TUint aMode);
       
   106 
       
   107 
       
   108 
       
   109 	static CContentFile* NewL(RFile& aFile, const TDesC& aUniqueId);
       
   110 	void ConstructL(RFile& aFile, const TDesC& aUniqueId);
       
   111 
       
   112 
       
   113 	virtual ~CContentFile();
       
   114 
       
   115 	// from MGenericFile
       
   116 	virtual TInt Seek(TSeek aSeekMode, TInt aPosition);
       
   117 	virtual TInt Read(TDes8& aDes,TInt aLength);
       
   118 	virtual void Read(TDes8& aDes, TInt aLength, TRequestStatus& aStatus);
       
   119 	virtual TInt Write(const TDesC8& aDes,TInt aLength);
       
   120 	virtual void Write(const TDesC8& aDes, TInt aLength, TRequestStatus& aStatus);
       
   121 	virtual TInt Size(TInt& aSize);
       
   122 	virtual TInt SetSize(TInt aSize);
       
   123 	virtual TInt EvaluateIntent(const ContentAccess::TIntent aIntent) const;
       
   124 	virtual TInt ExecuteIntent(const ContentAccess::TIntent aIntent);
       
   125 	virtual TBool IsProtected() const;
       
   126 	virtual RFile& FileL();
       
   127 
       
   128 
       
   129 	virtual TInt SetAgentProperty(ContentAccess::TAgentProperty, TInt aValue);
       
   130 
       
   131 
       
   132 private:
       
   133 	CContentFile();
       
   134 
       
   135 
       
   136 private:
       
   137 	RFs* iSession; // not owned
       
   138 	HBufC* iFilePath;
       
   139 	ContentAccess::CContent* iContent;
       
   140 	ContentAccess::CData* iData;
       
   141 
       
   142 	RFile iLegacyFile;
       
   143 	TBool iLegacyFileOpen;
       
   144 	};
       
   145 
       
   146 
       
   147 inline CF32File::CF32File()
       
   148 	{
       
   149 	}
       
   150 
       
   151 inline CContentFile::CContentFile()
       
   152 	{
       
   153 	}
       
   154 
       
   155 inline MGenericFile::~MGenericFile()
       
   156 	{
       
   157 	}
       
   158 
       
   159 #endif //__FILE_ACCESS_H__