|
1 /* |
|
2 * Copyright (c) 2002 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: |
|
15 * Image data abstraction hierarchy. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef __PbkImageData_H__ |
|
21 #define __PbkImageData_H__ |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 #include <f32file.h> |
|
26 |
|
27 // FORWARD DECLARATIONS |
|
28 class CPbkAttachmentFile; |
|
29 |
|
30 // CLASS DECLARATIONS |
|
31 |
|
32 /** |
|
33 * Abstract thumbnail image data interface. Provides polymorphism between |
|
34 * images stored in a file or buffer. |
|
35 */ |
|
36 class MPbkImageData |
|
37 { |
|
38 public: |
|
39 /** |
|
40 * Virtual destructor. |
|
41 */ |
|
42 virtual ~MPbkImageData() |
|
43 { |
|
44 } |
|
45 |
|
46 /** |
|
47 * Returns the image data in a buffer. |
|
48 */ |
|
49 virtual const TDesC8& GetBufferL() const =0; |
|
50 |
|
51 /** |
|
52 * Returns the image data in a file. |
|
53 */ |
|
54 virtual const TDesC& GetFileNameL() const =0; |
|
55 }; |
|
56 |
|
57 |
|
58 /** |
|
59 * Image file implementation of MPbkImageData. |
|
60 */ |
|
61 class CPbkImageFileData : |
|
62 public CBase, public MPbkImageData |
|
63 { |
|
64 public: // Interface |
|
65 /** |
|
66 * Creates a new instance of this class. |
|
67 * |
|
68 * @param aFileName name of the image file to encapsulate. |
|
69 * @return a new instance of this class. |
|
70 */ |
|
71 static CPbkImageFileData* NewL(const TDesC& aFileName); |
|
72 |
|
73 /** |
|
74 * Destructor. |
|
75 */ |
|
76 ~CPbkImageFileData(); |
|
77 |
|
78 public: // from MPbkImageData |
|
79 const TDesC8& GetBufferL() const; |
|
80 const TDesC& GetFileNameL() const; |
|
81 |
|
82 private: // Implementation |
|
83 CPbkImageFileData(const TDesC& aFileName); |
|
84 |
|
85 private: // Data |
|
86 /// Own: file name |
|
87 TFileName iFileName; |
|
88 /// Own: buffer |
|
89 mutable HBufC8* iBuffer; |
|
90 }; |
|
91 |
|
92 |
|
93 /** |
|
94 * Image buffer implementation of MPbkImageData. |
|
95 */ |
|
96 class CPbkImageBufferData : |
|
97 public CBase, public MPbkImageData |
|
98 { |
|
99 public: // Interface |
|
100 /** |
|
101 * Creates a new instance of this class. |
|
102 * |
|
103 * @param aBuffer reference to the image buffer to encapsulate. |
|
104 * The buffer must exist as long as the returned |
|
105 * object exists. |
|
106 * @param aBaseName base name to use for any image file created |
|
107 * from the buffer. |
|
108 * @return a new instance of this class. |
|
109 */ |
|
110 static CPbkImageBufferData* NewL |
|
111 (const TDesC8& aBuffer, const TDesC& aBaseName=KNullDesC); |
|
112 |
|
113 /** |
|
114 * Destructor. |
|
115 * Deletes any file created in GetFileNameL(). |
|
116 */ |
|
117 ~CPbkImageBufferData(); |
|
118 |
|
119 public: // from MPbkImageData |
|
120 const TDesC8& GetBufferL() const; |
|
121 const TDesC& GetFileNameL() const; |
|
122 |
|
123 private: // Implementation |
|
124 CPbkImageBufferData(const TDesC8& aBuffer, const TDesC& aBaseName); |
|
125 |
|
126 private: // Data |
|
127 /// Ref: buffer |
|
128 const TDesC8& iBuffer; |
|
129 /// Own: file name |
|
130 TFileName iBaseName; |
|
131 /// Own: file server session |
|
132 mutable RFs iFsSession; |
|
133 /// Own: attachment file |
|
134 mutable CPbkAttachmentFile* iFile; |
|
135 }; |
|
136 |
|
137 |
|
138 /** |
|
139 * Image data with image info. |
|
140 */ |
|
141 class CPbkImageDataWithInfo : |
|
142 public CBase |
|
143 { |
|
144 public: // Interface |
|
145 /** |
|
146 * Construction parameters for CPbkImageDataWithInfo. |
|
147 */ |
|
148 struct TParams |
|
149 { |
|
150 /** |
|
151 * Default constructor. Initializes all fields to default values. |
|
152 */ |
|
153 IMPORT_C TParams(); |
|
154 |
|
155 /** |
|
156 * Image data. CPbkImageDataWithInfo takes ownership of this field |
|
157 * when this struct is passed to CPbkImageDataWithInfo::NewL(). |
|
158 */ |
|
159 MPbkImageData* iImageData; |
|
160 |
|
161 /** |
|
162 * Image size in pixels. |
|
163 */ |
|
164 TSize iSizeInPixels; |
|
165 |
|
166 /** |
|
167 * Image format's MIME type. |
|
168 */ |
|
169 const TDesC8* iMimeType; |
|
170 }; |
|
171 |
|
172 /** |
|
173 * Creates a new instance of this class. |
|
174 * |
|
175 * @param aParams construction parameters. This object takes |
|
176 * ownership of aParams.iImageData if this function |
|
177 * does not leave. |
|
178 * @return a new instance of this class. |
|
179 */ |
|
180 IMPORT_C static CPbkImageDataWithInfo* NewL(const TParams& aParams); |
|
181 |
|
182 /** |
|
183 * Destructor. |
|
184 */ |
|
185 ~CPbkImageDataWithInfo(); |
|
186 |
|
187 /** |
|
188 * Returns the image data. |
|
189 */ |
|
190 IMPORT_C const MPbkImageData& ImageData() const; |
|
191 |
|
192 /** |
|
193 * Returns the image size in pixels. |
|
194 */ |
|
195 IMPORT_C TSize ImageSizeInPixels() const; |
|
196 |
|
197 /** |
|
198 * Returns the image format's MIME type. |
|
199 */ |
|
200 IMPORT_C const TDesC8& MimeType() const; |
|
201 |
|
202 private: // Implementation |
|
203 CPbkImageDataWithInfo(); |
|
204 void ConstructL(const TParams& aParams); |
|
205 |
|
206 private: // Data |
|
207 /// Own: parameters |
|
208 TParams iParams; |
|
209 }; |
|
210 |
|
211 #endif // __PbkImageData_H__ |
|
212 |
|
213 // End of File |