|
1 /* |
|
2 * Copyright (c) 2006 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: Header of FileAccess Classes. |
|
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 virtual TInt SetAgentProperty(ContentAccess::TAgentProperty aProperty, TInt aValue) = 0; |
|
49 |
|
50 }; |
|
51 |
|
52 // Provide RFile based file access |
|
53 class CF32File : public CBase, public MGenericFile |
|
54 { |
|
55 public: |
|
56 static CF32File* NewL(RFs& aSession, TDesC& aPath, TUint aMode); |
|
57 static CF32File* NewL(RFile& aFile); |
|
58 void ConstructL(RFile& aFile); |
|
59 void ConstructL(RFs& aSession, TDesC& aPath, TUint aMode); |
|
60 |
|
61 virtual ~CF32File(); |
|
62 |
|
63 // from MGenericFile |
|
64 virtual TInt Seek(TSeek aSeekMode, TInt aPosition); |
|
65 virtual TInt Read(TDes8& aDes,TInt aLength); |
|
66 virtual void Read(TDes8& aDes, TInt aLength, TRequestStatus& aStatus); |
|
67 virtual TInt Write(const TDesC8& aDes,TInt aLength); |
|
68 virtual void Write(const TDesC8& aDes, TInt aLength, TRequestStatus& aStatus); |
|
69 virtual TInt Size(TInt& aSize); |
|
70 virtual TInt SetSize(TInt aSize); |
|
71 virtual TInt EvaluateIntent(const ContentAccess::TIntent aIntent) const; |
|
72 virtual TInt ExecuteIntent(const ContentAccess::TIntent aIntent); |
|
73 virtual TBool IsProtected() const; |
|
74 virtual RFile& FileL(); |
|
75 |
|
76 virtual TInt SetAgentProperty(ContentAccess::TAgentProperty, TInt aValue); |
|
77 |
|
78 private: |
|
79 CF32File(); |
|
80 |
|
81 private: |
|
82 RFs* iSession; // not owned |
|
83 HBufC* iFilePath; |
|
84 RFile iFile; |
|
85 |
|
86 TBool iFileHandle; |
|
87 TInt iFileSize; |
|
88 }; |
|
89 |
|
90 // Provides content access framework based file access |
|
91 class CContentFile : public CBase, public MGenericFile |
|
92 { |
|
93 public: |
|
94 static CContentFile* NewL(RFs& aSession, const TDesC& aPath, const TDesC& aUniqueId, TUint aMode, TBool aEnableUI); |
|
95 void ConstructL(RFs& aSession, const TDesC& aPath, const TDesC& aUniqueId, TUint aMode, TBool aEnableUI); |
|
96 |
|
97 static CContentFile* NewL(RFile& aFile, const TDesC& aUniqueId, TBool aEnableUI); |
|
98 void ConstructL(RFile& aFile, const TDesC& aUniqueId, TBool aEnableUI); |
|
99 |
|
100 virtual ~CContentFile(); |
|
101 |
|
102 // from MGenericFile |
|
103 virtual TInt Seek(TSeek aSeekMode, TInt aPosition); |
|
104 virtual TInt Read(TDes8& aDes,TInt aLength); |
|
105 virtual void Read(TDes8& aDes, TInt aLength, TRequestStatus& aStatus); |
|
106 virtual TInt Write(const TDesC8& aDes,TInt aLength); |
|
107 virtual void Write(const TDesC8& aDes, TInt aLength, TRequestStatus& aStatus); |
|
108 virtual TInt Size(TInt& aSize); |
|
109 virtual TInt SetSize(TInt aSize); |
|
110 virtual TInt EvaluateIntent(const ContentAccess::TIntent aIntent) const; |
|
111 virtual TInt ExecuteIntent(const ContentAccess::TIntent aIntent); |
|
112 virtual TBool IsProtected() const; |
|
113 virtual RFile& FileL(); |
|
114 |
|
115 virtual TInt SetAgentProperty(ContentAccess::TAgentProperty, TInt aValue); |
|
116 |
|
117 private: |
|
118 CContentFile(); |
|
119 |
|
120 |
|
121 private: |
|
122 RFs* iSession; // not owned |
|
123 HBufC* iFilePath; |
|
124 ContentAccess::CData* iData; |
|
125 |
|
126 RFile iLegacyFile; |
|
127 TBool iLegacyFileOpen; |
|
128 }; |
|
129 |
|
130 |
|
131 inline CF32File::CF32File() |
|
132 { |
|
133 } |
|
134 |
|
135 inline CContentFile::CContentFile() |
|
136 { |
|
137 } |
|
138 |
|
139 inline MGenericFile::~MGenericFile() |
|
140 { |
|
141 } |
|
142 |
|
143 #endif //__FILE_ACCESS_H__ |