|
1 /* |
|
2 * Copyright (c) 2002-2007 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 CPBK2IMAGEDATA_H |
|
21 #define CPBK2IMAGEDATA_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 #include <f32file.h> |
|
26 |
|
27 // FORWARD DECLARATIONS |
|
28 class CPbk2AttachmentFile; |
|
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 MPbk2ImageData |
|
37 { |
|
38 public: |
|
39 /** |
|
40 * Virtual destructor. |
|
41 */ |
|
42 virtual ~MPbk2ImageData() |
|
43 { |
|
44 } |
|
45 |
|
46 /** |
|
47 * Returns the image data in a buffer. |
|
48 * @return The image data in a buffer. |
|
49 */ |
|
50 virtual const TDesC8& GetBufferL() const =0; |
|
51 |
|
52 /** |
|
53 * Returns the image data in a file. |
|
54 * @return The image data in a file. |
|
55 */ |
|
56 virtual const TDesC& GetFileNameL() const =0; |
|
57 }; |
|
58 |
|
59 |
|
60 /** |
|
61 * Image file implementation of MPbk2ImageData. |
|
62 */ |
|
63 NONSHARABLE_CLASS(CPbk2ImageFileData) : |
|
64 public CBase, |
|
65 public MPbk2ImageData |
|
66 { |
|
67 public: // Interface |
|
68 /** |
|
69 * Creates a new instance of this class. |
|
70 * |
|
71 * @param aFileName name of the image file to encapsulate. |
|
72 * @return a new instance of this class. |
|
73 */ |
|
74 static CPbk2ImageFileData* NewL(const TDesC& aFileName); |
|
75 |
|
76 /** |
|
77 * Destructor. |
|
78 */ |
|
79 ~CPbk2ImageFileData(); |
|
80 |
|
81 public: // from MPbk2ImageData |
|
82 const TDesC8& GetBufferL() const; |
|
83 const TDesC& GetFileNameL() const; |
|
84 |
|
85 private: // Implementation |
|
86 CPbk2ImageFileData(const TDesC& aFileName); |
|
87 |
|
88 private: // Data |
|
89 /// Own: file name |
|
90 TFileName iFileName; |
|
91 /// Own: buffer |
|
92 mutable HBufC8* iBuffer; |
|
93 }; |
|
94 |
|
95 |
|
96 /** |
|
97 * Image buffer implementation of MPbk2ImageData. |
|
98 */ |
|
99 NONSHARABLE_CLASS(CPbk2ImageBufferData) : |
|
100 public CBase, |
|
101 public MPbk2ImageData |
|
102 { |
|
103 public: // Interface |
|
104 /** |
|
105 * Creates a new instance of this class. |
|
106 * |
|
107 * @param aBuffer reference to the image buffer to encapsulate. |
|
108 * The buffer must exist as long as the returned |
|
109 * object exists. |
|
110 * @param aBaseName base name to use for any image file created |
|
111 * from the buffer. |
|
112 * @return a new instance of this class. |
|
113 */ |
|
114 static CPbk2ImageBufferData* NewL |
|
115 (const TDesC8& aBuffer, const TDesC& aBaseName=KNullDesC); |
|
116 |
|
117 /** |
|
118 * Destructor. |
|
119 * Deletes any file created in GetFileNameL(). |
|
120 */ |
|
121 ~CPbk2ImageBufferData(); |
|
122 |
|
123 public: // from MPbk2ImageData |
|
124 const TDesC8& GetBufferL() const; |
|
125 const TDesC& GetFileNameL() const; |
|
126 |
|
127 private: // Implementation |
|
128 CPbk2ImageBufferData(const TDesC8& aBuffer, const TDesC& aBaseName); |
|
129 |
|
130 private: // Data |
|
131 /// Ref: buffer |
|
132 const TDesC8& iBuffer; |
|
133 /// Own: file name |
|
134 TFileName iBaseName; |
|
135 /// Own: file server session |
|
136 mutable RFs iFsSession; |
|
137 /// Own: attachment file |
|
138 mutable CPbk2AttachmentFile* iFile; |
|
139 }; |
|
140 |
|
141 |
|
142 #endif // CPBK2IMAGEDATA_H |
|
143 |
|
144 // End of File |