|
1 /* |
|
2 * Copyright (c) 2003-2008 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: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "SDCGlobals.h" |
|
19 #include "SDCInlOutput.h" |
|
20 #include "SDCException.h" |
|
21 |
|
22 ////////////////////////////////////////////////////////////////////// |
|
23 // Construction/Destruction |
|
24 ////////////////////////////////////////////////////////////////////// |
|
25 |
|
26 CSDCInlOutput::CSDCInlOutput() |
|
27 { |
|
28 |
|
29 } |
|
30 |
|
31 CSDCInlOutput::~CSDCInlOutput() |
|
32 { |
|
33 |
|
34 } |
|
35 |
|
36 ////////////////////////////////////////////////////////////////////// |
|
37 // Other methods |
|
38 ////////////////////////////////////////////////////////////////////// |
|
39 |
|
40 void CSDCInlOutput::Output( CSDCData* aData, const char* aSkinName, const char* aCppFilename, const char* aMmpFilename ) |
|
41 { |
|
42 iData = aData; |
|
43 |
|
44 if( iData->iPid.iPID2 != 0 ) |
|
45 { |
|
46 throw CSDCException( ESDCContentError, "System skin must have a UID, no PID is allowed"); |
|
47 } |
|
48 |
|
49 if( iData->iParentPid.iPID2 != 0 ) |
|
50 { |
|
51 throw CSDCException( ESDCContentError, "System override skin must have a parent UID, no PID is allowed"); |
|
52 } |
|
53 |
|
54 if( iData->iAHOverridePid.iPID2 != 0 ) |
|
55 { |
|
56 throw CSDCException( ESDCContentError, "System override skin must have a UID, no PID is allowed"); |
|
57 } |
|
58 |
|
59 int storageUid = iData->iParentPid.iPID1; |
|
60 if( storageUid == 0 ) storageUid = iData->iPid.iPID1; |
|
61 |
|
62 FILE* file = fopen( aCppFilename, "wt" ); |
|
63 if( !file ) throw CSDCException( ESDCFileOpenError, "Text output file for CPP generation can not be opened" ); |
|
64 |
|
65 fprintf( file, "// Generated skin content DLL source file for %s\n", aSkinName ); |
|
66 fprintf( file, "// Copyright (c) 2003,2004 Nokia. All rights reserved. Confidential.\n"); |
|
67 |
|
68 fprintf( file, "\n#include <e32std.h>\n" ); |
|
69 fprintf( file, "#include \"AknsSrvItemDef.h\"\n" ); |
|
70 |
|
71 fprintf( file, "\n#define AKNS_DTPP(a) {EAknsSrvMPPtrAbsoluteROM,static_cast<const TAny*>(&(a))}\n" ); |
|
72 |
|
73 fprintf( file, "\n// Skin MBM file\n"); |
|
74 fprintf( file, "#if defined(AKNS_SDC_NO_CONST_SUPPORT)\n"); |
|
75 fprintf( file, "#define K%s_Mbm _S(\"z:\\\\system\\\\skins\\\\%08x\\\\%s.mbm\")\n", aSkinName, storageUid, aSkinName ); |
|
76 fprintf( file, "#else\n"); |
|
77 fprintf( file, "static const TText* const K%s_Mbm = _S(\"z:\\\\system\\\\skins\\\\%08x\\\\%s.mbm\");\n", aSkinName, storageUid, aSkinName ); |
|
78 fprintf( file, "#endif\n"); |
|
79 |
|
80 int i, a; |
|
81 |
|
82 fprintf( file, "\n// Bitmap definitions\n"); |
|
83 for( i=0; i<iData->iBitmapDefVector.size(); i++ ) |
|
84 { |
|
85 TSDCBitmapDef* entry = iData->iBitmapDefVector[i]; |
|
86 |
|
87 if( entry->iMaskMBMIndex!=-1 ) |
|
88 { |
|
89 fprintf( file, "static const TAknsSrvMaskedBitmapDef K%s_BitmapDef_%i =\n", aSkinName, i ); |
|
90 fprintf( file, " { {EAknsSrvMPPtrAbsoluteROM,K%s_Mbm}, %i, %i, ", |
|
91 aSkinName, entry->iMBMIndex, entry->iMaskMBMIndex ); |
|
92 OutputAttributes( file, entry->iAttributes ); |
|
93 fprintf( file, " };\n" ); |
|
94 } |
|
95 else |
|
96 { |
|
97 fprintf( file, "static const TAknsSrvBitmapDef K%s_BitmapDef_%i =\n", aSkinName, i ); |
|
98 fprintf( file, " { {EAknsSrvMPPtrAbsoluteROM,K%s_Mbm}, %i, ", |
|
99 aSkinName, entry->iMBMIndex ); |
|
100 OutputAttributes( file, entry->iAttributes ); |
|
101 fprintf( file, " };\n" ); |
|
102 } |
|
103 } |
|
104 |
|
105 fprintf( file, "\n// Color table definitions\n"); |
|
106 for( i=0; i<iData->iColorTableDefVector.size(); i++ ) |
|
107 { |
|
108 TSDCColorTableDef* entry = iData->iColorTableDefVector[i]; |
|
109 |
|
110 fprintf( file, "static const TAknsColorTableEntry K%s_ColorTableDef_%i_All[] =\n", aSkinName, i ); |
|
111 fprintf( file, " { " ); |
|
112 for( a=0; a<entry->iColors.size(); a++ ) |
|
113 { |
|
114 if( a!= 0 ) fprintf( file, ", " ); |
|
115 fprintf( file, "{%i,0x%06x}", entry->iColors[a].iIndex, entry->iColors[a].iRgb ); |
|
116 } |
|
117 fprintf( file, " };\n" ); |
|
118 |
|
119 fprintf( file, "static const TAknsSrvColorTableDef K%s_ColorTableDef_%i =\n", aSkinName, i ); |
|
120 fprintf( file, " { %i, {EAknsSrvMPPtrAbsoluteROM,&K%s_ColorTableDef_%i_All[0]}, ", |
|
121 entry->iColors.size(), aSkinName, i ); |
|
122 TSDCImageAttributes attributes; |
|
123 attributes.iAttributeFlags = ESDCImageAttributeNone; |
|
124 attributes.iAlignmentFlags = ESDCImageAlignNone; |
|
125 attributes.iCoordX = 0; |
|
126 attributes.iCoordY = 0; |
|
127 attributes.iSizeW = 0; |
|
128 attributes.iSizeH = 0; |
|
129 OutputAttributes( file, attributes ); |
|
130 fprintf( file, " };\n" ); |
|
131 } |
|
132 |
|
133 fprintf( file, "\n// Frame definitions\n"); |
|
134 for( i=0; i<iData->iFrameDefVector.size(); i++ ) |
|
135 { |
|
136 TSDCFrameDef* entry = iData->iFrameDefVector[i]; |
|
137 |
|
138 fprintf( file, "static const TAknsItemID K%s_FrameDef_%i_All[] = \n", aSkinName, i ); |
|
139 fprintf( file, " { " ); |
|
140 for( a=0; a<entry->iElements.size(); a++ ) |
|
141 { |
|
142 if( a!=0 ) fprintf( file, ", " ); |
|
143 fprintf( file, "{0x%x,0x%x}", entry->iElements[a].iMajor, entry->iElements[a].iMinor ); |
|
144 } |
|
145 fprintf( file, " };\n" ); |
|
146 |
|
147 fprintf( file, "static const TAknsSrvImageTableDef K%s_FrameDef_%i = \n", aSkinName, i ); |
|
148 fprintf( file, " { %i, {EAknsSrvMPPtrAbsoluteROM,&K%s_FrameDef_%i_All[0]}, ", |
|
149 entry->iElements.size(), aSkinName, i ); |
|
150 TSDCImageAttributes attributes; |
|
151 attributes.iAttributeFlags = ESDCImageAttributeNone; |
|
152 attributes.iAlignmentFlags = ESDCImageAlignNone; |
|
153 attributes.iCoordX = 0; |
|
154 attributes.iCoordY = 0; |
|
155 attributes.iSizeW = 0; |
|
156 attributes.iSizeH = 0; |
|
157 OutputAttributes( file, attributes ); |
|
158 fprintf( file, " };\n" ); |
|
159 } |
|
160 |
|
161 fprintf( file, "\n// Application icon definitions\n"); |
|
162 for( i=0; i<iData->iAppIconDefVector.size(); i++ ) |
|
163 { |
|
164 TSDCAppIconDef* entry = iData->iAppIconDefVector[i]; |
|
165 |
|
166 fprintf( file, "static const TAknsItemID K%s_AppIconDef_%i_All[] = \n", aSkinName, i ); |
|
167 fprintf( file, " { " ); |
|
168 for( a=0; a<entry->iIcons.size(); a++ ) |
|
169 { |
|
170 if( a!=0 ) fprintf( file, ", " ); |
|
171 fprintf( file, "{0x%x,0x%x}", entry->iIcons[a].iMajor, entry->iIcons[a].iMinor ); |
|
172 } |
|
173 fprintf( file, " };\n" ); |
|
174 |
|
175 fprintf( file, "static const TAknsSrvImageTableDef K%s_AppIconDef_%i = \n", aSkinName, i ); |
|
176 fprintf( file, " { %i, {EAknsSrvMPPtrAbsoluteROM,&K%s_AppIconDef_%i_All[0]}, ", |
|
177 entry->iIcons.size(), aSkinName, i ); |
|
178 TSDCImageAttributes attributes; |
|
179 attributes.iAttributeFlags = ESDCImageAttributeNone; |
|
180 attributes.iAlignmentFlags = ESDCImageAlignNone; |
|
181 attributes.iCoordX = 0; |
|
182 attributes.iCoordY = 0; |
|
183 attributes.iSizeW = 0; |
|
184 attributes.iSizeH = 0; |
|
185 OutputAttributes( file, attributes ); |
|
186 fprintf( file, " };\n" ); |
|
187 } |
|
188 |
|
189 fprintf( file, "\n// Bitmap animation definitions\n" ); |
|
190 for( i=0; i<iData->iBmpAnimDefVector.size(); i++ ) |
|
191 { |
|
192 TSDCBmpAnimDef* entry = iData->iBmpAnimDefVector[i]; |
|
193 |
|
194 fprintf( file, "static const TAknsItemID K%s_BmpAnimDef_%i_All[] = \n", aSkinName, i ); |
|
195 fprintf( file, " { " ); |
|
196 for( a=0; a<entry->iFrames.size(); a++ ) |
|
197 { |
|
198 if( a!=0 ) fprintf( file, ", " ); |
|
199 fprintf( file, "{0x%x,0x%x}", entry->iFrames[a].iIID.iMajor, entry->iFrames[a].iIID.iMinor ); |
|
200 } |
|
201 fprintf( file, " };\n" ); |
|
202 |
|
203 fprintf( file, "static const TAknsBmpAnimFrameInfo K%s_BmpAnimDef_%i_FramesAll[] = \n", aSkinName, i ); |
|
204 fprintf( file, " { " ); |
|
205 for( a=0; a<entry->iFrames.size(); a++ ) |
|
206 { |
|
207 if( a!=0 ) fprintf( file, ", " ); |
|
208 fprintf( file, "{%i,%i,%i}", entry->iFrames[a].iTime, entry->iFrames[a].iPosX, entry->iFrames[a].iPosY ); |
|
209 } |
|
210 fprintf( file, " };\n" ); |
|
211 |
|
212 fprintf( file, "static const TAknsSrvBmpAnimDef K%s_BmpAnimDef_%i = \n", aSkinName, i ); |
|
213 fprintf( file, " { %i, {EAknsSrvMPPtrAbsoluteROM,&K%s_BmpAnimDef_%i_All[0]}, ", |
|
214 entry->iFrames.size(), aSkinName, i ); |
|
215 fprintf( file, "{EAknsSrvMPPtrAbsoluteROM,&K%s_BmpAnimDef_%i_FramesAll[0]}, ", |
|
216 aSkinName, i ); |
|
217 fprintf( file, "%i, %i, ", entry->iInterval, entry->iPlayMode ); |
|
218 if( entry->iFlash ) |
|
219 { |
|
220 fprintf( file, "ETrue, " ); |
|
221 } |
|
222 else |
|
223 { |
|
224 fprintf( file, "EFalse, " ); |
|
225 } |
|
226 fprintf( file, "EFalse, " ); |
|
227 TSDCImageAttributes attributes; |
|
228 attributes.iAttributeFlags = ESDCImageAttributeNone; |
|
229 attributes.iAlignmentFlags = ESDCImageAlignNone; |
|
230 attributes.iCoordX = 0; |
|
231 attributes.iCoordY = 0; |
|
232 attributes.iSizeW = 0; |
|
233 attributes.iSizeH = 0; |
|
234 OutputAttributes( file, attributes ); |
|
235 fprintf( file, " };\n" ); |
|
236 } |
|
237 |
|
238 fprintf( file, "\n// String definitions\n"); |
|
239 for( i=0; i<iData->iStringDefVector.size(); i++ ) |
|
240 { |
|
241 TSDCStringDef* entry = iData->iStringDefVector[i]; |
|
242 |
|
243 char buf[512]; |
|
244 CSDCInput::ConvertToAsciiWithCPPEscapes( buf, entry->iString ); |
|
245 fprintf( file, "static const TText* const K%s_String_%i = _S(\"%s\");\n", aSkinName, i, buf ); |
|
246 |
|
247 fprintf( file, "static const TAknsSrvStringDef K%s_StringDef_%i =\n", aSkinName, i ); |
|
248 fprintf( file, " { {EAknsSrvMPPtrAbsoluteROM,K%s_String_%i} ", aSkinName, i ); |
|
249 fprintf( file, " };\n" ); |
|
250 } |
|
251 |
|
252 OutputClassList( file, false, aSkinName ); |
|
253 |
|
254 if( iData->iAppIconDefVector.size() > 0 ) OutputClassList( file, true, aSkinName ); |
|
255 |
|
256 fprintf( file, "\nstatic const TAknsSrvSkinDef K%s_MasterTable =\n", aSkinName ); |
|
257 fprintf( file, " { { 0x%x , 0x%x }, &K%s_BitmapClass, ", iData->iPid.iPID1, iData->iPid.iPID2, aSkinName ); |
|
258 if( iData->iAppIconDefVector.size() > 0 ) |
|
259 { |
|
260 fprintf( file, "&K%s_AppIconClass, ", aSkinName ); |
|
261 } |
|
262 else |
|
263 { |
|
264 fprintf( file, "0, " ); |
|
265 } |
|
266 fprintf( file, "0, { 0x%x , 0x%x }, { 0x%x , 0x%x } };\n", iData->iPalettePid.iPID1, iData->iPalettePid.iPID2, iData->iAHOverridePid.iPID1, iData->iAHOverridePid.iPID2 ); |
|
267 |
|
268 fprintf( file, "\nIMPORT_C const TAny* MasterTable();\n" ); |
|
269 fprintf( file, "EXPORT_C const TAny* MasterTable()\n" ); |
|
270 fprintf( file, " { return &K%s_MasterTable; }\n", aSkinName ); |
|
271 |
|
272 fprintf( file, "\nGLDEF_C TInt E32Dll(TDllReason /*aReason*/)\n" ); |
|
273 fprintf( file, " { return KErrNone; }\n" ); |
|
274 |
|
275 fprintf( file, "\n// End of file\n"); |
|
276 |
|
277 fclose( file ); |
|
278 file = NULL; |
|
279 |
|
280 file = fopen( aMmpFilename, "wt" ); |
|
281 if( !file ) throw CSDCException( ESDCFileOpenError, "Text output file for MMP generation can not be opened" ); |
|
282 |
|
283 fprintf( file, "// Generated skin content DLL project file for %s\n", aSkinName ); |
|
284 fprintf( file, "// Copyright (c) 2003,2004 Nokia. All rights reserved. Confidential.\n"); |
|
285 |
|
286 fprintf( file, "\nTARGETPATH system\\skins\\%08x\n", storageUid ); |
|
287 fprintf( file, "TARGET %08x.dll\n", iData->iPid.iPID1 ); |
|
288 fprintf( file, "TARGETTYPE DLL\n" ); |
|
289 fprintf( file, "UID 0x10005A26 0x%x\n", iData->iPid.iPID1 ); |
|
290 |
|
291 fprintf( file, "\nCAPABILITY CAP_GENERAL_DLL\n" ); |
|
292 |
|
293 fprintf( file, "\nUSERINCLUDE \\s60\\AknSkins\\srvinc\n" ); |
|
294 fprintf( file, "SYSTEMINCLUDE \\epoc32\\include \\epoc32\\include\\oem\n" ); |
|
295 |
|
296 fprintf( file, "\nLIBRARY euser.lib\n" ); |
|
297 |
|
298 fprintf( file, "\nSOURCE %s_ContentDLL.cpp\n", aSkinName ); |
|
299 fprintf( file, "\n#if defined(ARMCC)\n" ); |
|
300 fprintf( file, "MACRO AKNS_SDC_NO_CONST_SUPPORT\n" ); |
|
301 fprintf( file, "#endif\n" ); |
|
302 |
|
303 fprintf( file, "\n// End of file\n"); |
|
304 |
|
305 fclose( file ); |
|
306 } |
|
307 |
|
308 void CSDCInlOutput::OutputAttributes( FILE* aFile, const TSDCImageAttributes& aAttributes ) |
|
309 { |
|
310 fprintf( aFile, "%i, %i, %i, %i, %i, %i", aAttributes.iAttributeFlags, aAttributes.iAlignmentFlags, |
|
311 aAttributes.iCoordX, aAttributes.iCoordY, aAttributes.iSizeW, aAttributes.iSizeH ); |
|
312 } |
|
313 |
|
314 void CSDCInlOutput::OutputClassList( FILE* aFile, const bool aAppIconClass, const char* aSkinName ) |
|
315 { |
|
316 const char* className = "BitmapClass"; |
|
317 if( aAppIconClass ) className = "AppIconClass"; |
|
318 |
|
319 fprintf( aFile, "\n// Class content list\n"); |
|
320 int entries = 0; |
|
321 fprintf( aFile, "static const TAknsSrvDef K%s_%s_All[] = {\n", aSkinName, className ); |
|
322 |
|
323 int i; |
|
324 for( i=0; i<iData->iBitmapDefVector.size(); i++ ) |
|
325 { |
|
326 TSDCBitmapDef* entry = iData->iBitmapDefVector[i]; |
|
327 |
|
328 if( entry->iAppIconBitmap == aAppIconClass ) |
|
329 { |
|
330 if( entry->iMaskMBMIndex!=-1 ) |
|
331 { |
|
332 fprintf( aFile, " { {0x%x,0x%x}, EAknsITMaskedBitmap, AKNS_DTPP(K%s_BitmapDef_%i) },\n", |
|
333 entry->iIID.iMajor, entry->iIID.iMinor, aSkinName, i ); |
|
334 entries++; |
|
335 } |
|
336 else |
|
337 { |
|
338 fprintf( aFile, " { {0x%x,0x%x}, EAknsITBitmap, AKNS_DTPP(K%s_BitmapDef_%i) },\n", |
|
339 entry->iIID.iMajor, entry->iIID.iMinor, aSkinName, i ); |
|
340 entries++; |
|
341 } |
|
342 } |
|
343 } |
|
344 |
|
345 if( aAppIconClass ) |
|
346 { |
|
347 for( i=0; i<iData->iAppIconDefVector.size(); i++ ) |
|
348 { |
|
349 TSDCAppIconDef* entry = iData->iAppIconDefVector[i]; |
|
350 |
|
351 fprintf( aFile, " { {0x%x,0x%x}, EAknsITImageTable, AKNS_DTPP(K%s_AppIconDef_%i) },\n", |
|
352 entry->iIID.iMajor, entry->iIID.iMinor, aSkinName, i ); |
|
353 entries++; |
|
354 } |
|
355 } |
|
356 else |
|
357 { |
|
358 for( i=0; i<iData->iColorTableDefVector.size(); i++ ) |
|
359 { |
|
360 TSDCColorTableDef* entry = iData->iColorTableDefVector[i]; |
|
361 |
|
362 fprintf( aFile, " { {0x%x,0x%x}, EAknsITColorTable, AKNS_DTPP(K%s_ColorTableDef_%i) },\n", |
|
363 entry->iIID.iMajor, entry->iIID.iMinor, aSkinName, i ); |
|
364 entries++; |
|
365 } |
|
366 |
|
367 for( i=0; i<iData->iFrameDefVector.size(); i++ ) |
|
368 { |
|
369 TSDCFrameDef* entry = iData->iFrameDefVector[i]; |
|
370 |
|
371 fprintf( aFile, " { {0x%x,0x%x}, EAknsITImageTable, AKNS_DTPP(K%s_FrameDef_%i) },\n", |
|
372 entry->iIID.iMajor, entry->iIID.iMinor, aSkinName, i ); |
|
373 entries++; |
|
374 } |
|
375 |
|
376 for( i=0; i<iData->iBmpAnimDefVector.size(); i++ ) |
|
377 { |
|
378 TSDCBmpAnimDef* entry = iData->iBmpAnimDefVector[i]; |
|
379 |
|
380 fprintf( aFile, " { {0x%x,0x%x}, EAknsITBmpAnim, AKNS_DTPP(K%s_BmpAnimDef_%i) },\n", |
|
381 entry->iIID.iMajor, entry->iIID.iMinor, aSkinName, i ); |
|
382 entries++; |
|
383 } |
|
384 |
|
385 for( i=0; i<iData->iStringDefVector.size(); i++ ) |
|
386 { |
|
387 TSDCStringDef* entry = iData->iStringDefVector[i]; |
|
388 |
|
389 fprintf( aFile, " { {0x%x,0x%x}, EAknsITString, AKNS_DTPP(K%s_StringDef_%i) },\n", |
|
390 entry->iIID.iMajor, entry->iIID.iMinor, aSkinName, i ); |
|
391 entries++; |
|
392 } |
|
393 } |
|
394 |
|
395 fprintf( aFile, " };\n" ); |
|
396 fprintf( aFile, "static const TAknsSrvClassDef K%s_%s = { &K%s_%s_All[0], %i };\n", aSkinName, className, aSkinName, className, entries ); |
|
397 } |
|
398 |
|
399 // End of file |