|
1 /******************************************************************************* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. This program and the accompanying materials |
|
4 * are made available under the terms of the Eclipse Public License v1.0 |
|
5 * which accompanies this distribution, and is available at |
|
6 * http://www.eclipse.org/legal/epl-v10.html |
|
7 * |
|
8 * Contributors: |
|
9 * Nokia Corporation - S60 implementation |
|
10 *******************************************************************************/ |
|
11 |
|
12 |
|
13 #ifndef MIFCONVERTER_H |
|
14 #define MIFCONVERTER_H |
|
15 |
|
16 #include <e32base.h> |
|
17 #include <f32file.h> |
|
18 #include <s32file.h> |
|
19 |
|
20 |
|
21 /** |
|
22 * The structure for MIF file header |
|
23 * @since S60 v3.2 |
|
24 */ |
|
25 NONSHARABLE_CLASS(TMifFileHeader) |
|
26 { |
|
27 public: |
|
28 /** |
|
29 * The UID of the MIF file format. It is used for validating the MIF file format. |
|
30 */ |
|
31 TInt32 iUid; |
|
32 /** |
|
33 * Determines the valid fields in the MIF file header. |
|
34 * Must be greater than or equal to 2. |
|
35 */ |
|
36 TInt32 iVersion; |
|
37 /** |
|
38 * The pointer to the beginning of the array of icon offset elements. |
|
39 */ |
|
40 TInt32 iOffset; |
|
41 /** |
|
42 * The array length in the items of icon offset elements. |
|
43 */ |
|
44 TInt32 iLength; |
|
45 }; |
|
46 |
|
47 /** |
|
48 * The structure for MIF icon offset |
|
49 * @since S60 v3.2 |
|
50 */ |
|
51 NONSHARABLE_CLASS(TMifIconOffset) |
|
52 { |
|
53 public: |
|
54 /** |
|
55 * The offset to the icon from the beginning of the MIF file. |
|
56 * Icon = icon header + icon data. |
|
57 */ |
|
58 TInt32 iIconOffset; |
|
59 /** |
|
60 * The combined length of the icon header and the icon data. |
|
61 */ |
|
62 TInt32 iIconLength; |
|
63 }; |
|
64 |
|
65 /** |
|
66 * The structure for MIF icon header |
|
67 * @since S60 v3.2 |
|
68 */ |
|
69 NONSHARABLE_CLASS(TMifIconHeader) |
|
70 { |
|
71 public: |
|
72 /** |
|
73 * The UID of the MIF icon header format. |
|
74 * It is used for validating the MIF file format. |
|
75 */ |
|
76 TInt32 iUid; |
|
77 /** |
|
78 * The version of the MIF icon header format. |
|
79 * Determines the valid fields in the MIF icon header. |
|
80 */ |
|
81 TInt32 iVersion; |
|
82 /** |
|
83 * The offset to icon data (from the beginning of the icon). |
|
84 */ |
|
85 TInt32 iOffset; |
|
86 /** |
|
87 * The length of icon data in bytes. |
|
88 */ |
|
89 TInt32 iLength; |
|
90 /** |
|
91 * The type of the MIF icon. |
|
92 */ |
|
93 TInt32 iType; |
|
94 /** |
|
95 * The depth of the bitmap the content will be rendered to. |
|
96 * Corresponds to the Symbian OS enumeration TDisplayMode. |
|
97 */ |
|
98 TInt32 iDepth; |
|
99 /** |
|
100 * Whether the icon is animated. |
|
101 */ |
|
102 TInt32 iAnimated; |
|
103 /** |
|
104 * The depth of the mask. |
|
105 * Corresponds to the Symbian OS enumeration TDisplayMode. |
|
106 */ |
|
107 TInt32 iMaskDepth; |
|
108 }; |
|
109 |
|
110 /** |
|
111 * Class to handle the conversion of icons from SVG to MIF file |
|
112 * @since S60 v3.2 |
|
113 */ |
|
114 NONSHARABLE_CLASS(CMifConverter) : public CBase |
|
115 { |
|
116 public: |
|
117 /** |
|
118 * CMifConverter::NewL constructor |
|
119 * Construct a CMifConverter object, using two phase construction |
|
120 * and return a pointer to the created object. |
|
121 * |
|
122 * @since S60 v3.2 |
|
123 * @param aFs file session |
|
124 * @param aMifFile the name of the MIF file to be created |
|
125 * @return a pointer to the created instance of CMifConverter |
|
126 */ |
|
127 static CMifConverter* NewL(RFs& aFs, const TDesC& aMifFile); |
|
128 |
|
129 /** |
|
130 * CMifConverter::~CMifConverter destructor |
|
131 * Destroy the object and release all memory objects |
|
132 * |
|
133 * @since S60 v3.2 |
|
134 */ |
|
135 virtual ~CMifConverter(); |
|
136 |
|
137 public: |
|
138 /** |
|
139 * CMifConverter::WriteMifFileHeaderL method |
|
140 * Writes file header to the MIF file |
|
141 * |
|
142 * @since S60 v3.2 |
|
143 * @param aMifFileHeader TMifFileHeader structure |
|
144 */ |
|
145 void WriteMifFileHeaderL(const TMifFileHeader& aMifFileHeader); |
|
146 |
|
147 /** |
|
148 * CMifConverter::WriteMifIconOffsetL method |
|
149 * Writes icon offset to the MIF file |
|
150 * |
|
151 * @since S60 v3.2 |
|
152 * @param aMifIconOffset TMifIconOffset structure |
|
153 */ |
|
154 void WriteMifIconOffsetL(const TMifIconOffset& aMifIconOffset); |
|
155 |
|
156 /** |
|
157 * CMifConverter::WriteMifIconHeaderL method |
|
158 * Writes icon header to the MIF file |
|
159 * |
|
160 * @since S60 v3.2 |
|
161 * @param aMifIconHeader TMifIconHeader structure |
|
162 */ |
|
163 void WriteMifIconHeaderL(const TMifIconHeader& aMifIconHeader); |
|
164 |
|
165 /** |
|
166 * CMifConverter::WriteMifBodyL method |
|
167 * Writes file body to the MIF file |
|
168 * |
|
169 * @since S60 v3.2 |
|
170 * @param apIconBuf buffer containing the contents of the svg file |
|
171 */ |
|
172 void WriteMifBodyL(const TDesC8& apIconBuf); |
|
173 |
|
174 private: |
|
175 /** |
|
176 * CMifConverter::CMifConverter constructor |
|
177 * Perform the first phase of two phase construction |
|
178 * |
|
179 * @since S60 v3.2 |
|
180 * @param aFs file session |
|
181 */ |
|
182 CMifConverter(RFs& aFs); |
|
183 |
|
184 /** |
|
185 * CMifConverter::ConstructL constructor |
|
186 * Perform the second phase of two phase construction |
|
187 * |
|
188 * @since S60 v3.2 |
|
189 * @param aMifFile the name of the MIF file to be created |
|
190 */ |
|
191 void ConstructL(const TDesC& aMifFile); |
|
192 |
|
193 |
|
194 private: |
|
195 /** |
|
196 * File session reference. |
|
197 */ |
|
198 RFs& iFs; |
|
199 |
|
200 /** |
|
201 * Stream for the MIF file |
|
202 * Own. |
|
203 */ |
|
204 RFileWriteStream iMifWriteStream; |
|
205 }; |
|
206 |
|
207 #endif // MIFCONVERTER_H |
|
208 |