|
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 |
|
19 // INCLUDE FILES |
|
20 |
|
21 #include <stdlib.h> |
|
22 #include <string.h> |
|
23 #include <windows.h> |
|
24 |
|
25 #include "SDCGlobals.h" |
|
26 #include "SDCReader.h" |
|
27 #include "SDCMBMOutput.h" |
|
28 #include "SDCInlOutput.h" |
|
29 #include "SDCBinOutput.h" |
|
30 #include "SDCPkgOutput.h" |
|
31 #include "SDCIIDConstants.h" |
|
32 #include "SDCDebugOutput.h" |
|
33 |
|
34 // LOCAL VARIABLES |
|
35 |
|
36 static char sourceFile[512]; |
|
37 static char skinName[512]; |
|
38 static char mbmPath[512]; |
|
39 static char sknPath[512]; |
|
40 static char dllPath[512]; |
|
41 static char iidFile[512]; |
|
42 static bool forceSystem = false; |
|
43 static bool forceNormal = false; |
|
44 static bool drmEnabled = false; |
|
45 |
|
46 // SANITY CHECKS |
|
47 |
|
48 // To ensure skin binary compatibility, 2.6 must NOT support |
|
49 // scalable skins. Similarly, 2.8 and 3.0 must support scalable skins. |
|
50 // 2.7 is considered a part of 2.8 branch. |
|
51 // |
|
52 // Do not change these (such a compiler is major compatibility risk). |
|
53 // Alter your build configuration instead. |
|
54 // |
|
55 #if defined(__SERIES60_26__) |
|
56 #if defined(RD_ENHANCED_SKINNING) || defined(RD_SCALABLE_UI) |
|
57 #error S60 release 2.6 detected, but enhanced skinning or scalable UI is enabled! This combination is invalid, and would produce incompatible binaries. |
|
58 #endif |
|
59 #endif |
|
60 #if defined(__SERIES60_27__) || defined(__SERIES60_28__) || defined(__SERIES60_30__) || defined(__SERIES60_31__) |
|
61 #if !defined(RD_ENHANCED_SKINNING) || !defined(RD_SCALABLE_UI) |
|
62 #error S60 release 2.8/3.0 detected, but either enhanced skinning or scalable UI is not enabled! This combination is invalid, and would produce incompatible binaries. |
|
63 #endif |
|
64 #endif |
|
65 |
|
66 ////////////////////////////////////////////////////////////////////// |
|
67 // Functions |
|
68 ////////////////////////////////////////////////////////////////////// |
|
69 |
|
70 void Syntax() |
|
71 { |
|
72 printf("Syntax: AknSkinDescCompiler [options] input skinname\n\n"); |
|
73 printf("Where options [-mpath] [-tpath] [-spath] [-ifile]\n"); |
|
74 printf(" input: Input file in ASCII or UTF-16 format.\n"); |
|
75 printf(" Example: MySkin.txt\n"); |
|
76 printf(" skinname: Skin name used as filename prefix.\n"); |
|
77 printf(" Example: MySkin\n"); |
|
78 printf("Options -mpath: Path for MBM/MIF generation list.\n"); |
|
79 printf(" Example: -m..\\mbmlist\\\n"); |
|
80 printf(" -tpath: Path for SKN (and possible PKG) target.\n"); |
|
81 printf(" Example: -t..\\output\\\n"); |
|
82 printf(" -spath: Path for system skin CPP and MMP.\n"); |
|
83 printf(" Example: -s..\\dllsrc\\\n"); |
|
84 printf(" -ifile: Item ID extension list.\n"); |
|
85 printf(" Example: -iNewPhoneIIDs.txt\n"); |
|
86 printf(" --drm Suppress SKN and sounds from PKG file.\n"); |
|
87 } |
|
88 |
|
89 void AppendBackslash( char* aBuf ) |
|
90 { |
|
91 if( strlen( aBuf ) > 0 ) |
|
92 { |
|
93 if( aBuf[ strlen(aBuf)-1 ] != '\\' ) strcat( aBuf, "\\" ); |
|
94 } |
|
95 } |
|
96 |
|
97 bool ParseArguments( int argc, char** argv ) |
|
98 { |
|
99 strcpy( sourceFile, "" ); |
|
100 strcpy( skinName, "" ); |
|
101 strcpy( mbmPath, "" ); |
|
102 strcpy( sknPath, "" ); |
|
103 strcpy( dllPath, "" ); |
|
104 strcpy( iidFile, "" ); |
|
105 |
|
106 int fileParam = 0; |
|
107 for( int i=1; i<argc; i++ ) |
|
108 { |
|
109 if( stricmp( "--drm", argv[i] ) == 0 ) |
|
110 { |
|
111 drmEnabled = true; |
|
112 } |
|
113 else if( stricmp( "--forcesystem", argv[i] ) == 0 ) |
|
114 { |
|
115 forceSystem = true; |
|
116 } |
|
117 else if( stricmp( "--forcenormal", argv[i] ) == 0 ) |
|
118 { |
|
119 forceNormal = true; |
|
120 } |
|
121 else if( strnicmp( "-m", argv[i], 2 ) == 0 ) |
|
122 { |
|
123 strcpy( mbmPath, argv[i]+2 ); |
|
124 AppendBackslash( mbmPath ); |
|
125 } |
|
126 else if( strnicmp( "-t", argv[i], 2 ) == 0 ) |
|
127 { |
|
128 strcpy( sknPath, argv[i]+2 ); |
|
129 AppendBackslash( sknPath ); |
|
130 } |
|
131 else if( strnicmp( "-s", argv[i], 2 ) == 0 ) |
|
132 { |
|
133 strcpy( dllPath, argv[i]+2 ); |
|
134 AppendBackslash( dllPath ); |
|
135 } |
|
136 else if( strnicmp( "-i", argv[i], 2 ) == 0 ) |
|
137 { |
|
138 strcpy( iidFile, argv[i]+2 ); |
|
139 } |
|
140 else |
|
141 { |
|
142 if( fileParam == 0 ) |
|
143 { |
|
144 strcpy( sourceFile, argv[i] ); |
|
145 fileParam++; |
|
146 } |
|
147 else if( fileParam == 1 ) |
|
148 { |
|
149 strcpy( skinName, argv[i] ); |
|
150 fileParam++; |
|
151 } |
|
152 } |
|
153 } |
|
154 |
|
155 if( fileParam != 2 ) return false; |
|
156 return true; |
|
157 } |
|
158 |
|
159 ////////////////////////////////////////////////////////////////////// |
|
160 // GeneratePID |
|
161 ////////////////////////////////////////////////////////////////////// |
|
162 |
|
163 void GeneratePID( CSDCData* data ) |
|
164 { |
|
165 SYSTEMTIME sysTime; |
|
166 GetSystemTime( &sysTime ); |
|
167 FILETIME fileTime; |
|
168 SystemTimeToFileTime( &sysTime, &fileTime ); |
|
169 ULARGE_INTEGER currentTime; |
|
170 currentTime.LowPart = fileTime.dwLowDateTime; |
|
171 currentTime.HighPart = fileTime.dwHighDateTime; |
|
172 |
|
173 sysTime.wYear = 2003; |
|
174 sysTime.wMonth = 1; |
|
175 sysTime.wDay = 1; |
|
176 sysTime.wHour = 0; |
|
177 sysTime.wMinute = 0; |
|
178 sysTime.wSecond = 0; |
|
179 sysTime.wMilliseconds = 0; |
|
180 SystemTimeToFileTime( &sysTime, &fileTime ); |
|
181 ULARGE_INTEGER epochTime; |
|
182 epochTime.LowPart = fileTime.dwLowDateTime; |
|
183 epochTime.HighPart = fileTime.dwHighDateTime; |
|
184 |
|
185 ULARGE_INTEGER timeStamp; |
|
186 timeStamp.QuadPart = currentTime.QuadPart - epochTime.QuadPart; |
|
187 timeStamp.QuadPart = timeStamp.QuadPart >> 20; |
|
188 |
|
189 srand( gInput.iHash ^ currentTime.HighPart ^ currentTime.LowPart ); |
|
190 |
|
191 // Timestamp |
|
192 data->iPid.iPID2 = timeStamp.LowPart; |
|
193 if( data->iPid.iPID2 == 0 ) data->iPid.iPID2 += 1; |
|
194 |
|
195 // Random number |
|
196 data->iPid.iPID1 = rand(); |
|
197 data->iPid.iPID1 = data->iPid.iPID1 << 8; |
|
198 data->iPid.iPID1 ^= rand(); |
|
199 data->iPid.iPID1 = data->iPid.iPID1 << 8; |
|
200 data->iPid.iPID1 ^= rand(); |
|
201 data->iPid.iPID1 = data->iPid.iPID1 << 8; |
|
202 data->iPid.iPID1 ^= rand(); |
|
203 } |
|
204 |
|
205 ////////////////////////////////////////////////////////////////////// |
|
206 // Main function |
|
207 ////////////////////////////////////////////////////////////////////// |
|
208 |
|
209 int main( int argc, char** argv ) |
|
210 { |
|
211 printf("======================================================================\n"); |
|
212 printf("Skin Compiler v%i.%i.%i ("__DATE__") for S60 Platform.\nCopyright (c) 2003-2008 Nokia. All rights reserved.\n", gPlatformMajor, gPlatformMinor, gVersionMinor ); |
|
213 printf("======================================================================\n"); |
|
214 |
|
215 printf("\n"); |
|
216 |
|
217 if( !ParseArguments( argc, argv ) ) |
|
218 { |
|
219 Syntax(); |
|
220 return 1; |
|
221 } |
|
222 |
|
223 try |
|
224 { |
|
225 SDCIIDConstants::Initialize( iidFile ); |
|
226 } |
|
227 catch( CSDCException e ) |
|
228 { |
|
229 e.Print(); |
|
230 printf("\nItem ID extension list is invalid, INITIALIZATION FAILED!\n"); |
|
231 return 3; |
|
232 } |
|
233 |
|
234 printf("Phase 0: Parameter summary.\n"); |
|
235 printf(" Source file: %s\n", sourceFile ); |
|
236 printf(" Skin name: %s\n", skinName ); |
|
237 if( strlen(mbmPath)>0 ) printf(" MBM/MIF list path: %s\n", mbmPath ); |
|
238 if( strlen(sknPath)>0 ) printf(" SKN output path: %s\n", sknPath ); |
|
239 if( strlen(dllPath)>0 ) printf(" System skin output path: %s\n", dllPath ); |
|
240 if( forceSystem ) printf(" Forcing skin type to be SYSTEM\n"); |
|
241 if( forceNormal ) printf(" Forcing skin type to be NORMAL\n"); |
|
242 if( drmEnabled ) printf(" DRM compatibility mode, PKG generation will be altered\n"); |
|
243 |
|
244 |
|
245 CSDCData* data = NULL; |
|
246 bool error = false; |
|
247 try |
|
248 { |
|
249 data = new CSDCData(); |
|
250 |
|
251 printf("\nPhase 1: Input parsing.\n"); |
|
252 printf(" Opening source file %s ...\n", sourceFile ); |
|
253 gInput.Open( sourceFile ); |
|
254 printf(" Parsing file ...\n"); |
|
255 data->SetBmpPath( L".\\" ); |
|
256 CSDCReader reader( data ); |
|
257 reader.Parse(); |
|
258 printf(" Completed.\n"); |
|
259 gInput.iLineNumber = -1; |
|
260 |
|
261 if( forceSystem ) |
|
262 { |
|
263 if( data->IsScalable() ) |
|
264 printf("WARNING: Scalable skin, force parameter has no effect.\n"); |
|
265 else |
|
266 data->iSkinType |= 0x1; |
|
267 } |
|
268 if( forceNormal ) |
|
269 { |
|
270 if( data->IsScalable() ) |
|
271 printf("WARNING: Scalable skin, force parameter has no effect.\n"); |
|
272 else |
|
273 if( (data->iSkinType&0x1) != 0 ) data->iSkinType^=0x1; |
|
274 } |
|
275 |
|
276 bool systemSkin = false; |
|
277 printf("NOTE: Skintype: " ); |
|
278 if( data->IsScalable() ) |
|
279 { |
|
280 printf("Scalable "); |
|
281 } |
|
282 else if( (data->iSkinType & 0x1) != 0 ) |
|
283 { |
|
284 printf("System "); |
|
285 systemSkin = true; |
|
286 } |
|
287 else |
|
288 { |
|
289 printf("Normal "); |
|
290 } |
|
291 if( (data->iSkinType & 0x2) != 0 ) |
|
292 { |
|
293 printf("LangOverride="); |
|
294 switch( data->iSkinType & 0xff00 ) |
|
295 { |
|
296 case 0x100: printf("AH "); break; |
|
297 default: printf("Unknown "); break; |
|
298 } |
|
299 |
|
300 printf("Parent=0x%08x 0x%08x", data->iParentPid.iPID2, data->iParentPid.iPID1 ); |
|
301 } |
|
302 printf("\n"); |
|
303 |
|
304 if( systemSkin ) |
|
305 { |
|
306 throw new CSDCException( ESDCContentError, "System skins are no longer supported, please use scalable skin type instead" ); |
|
307 } |
|
308 |
|
309 if( (data->iAHOverridePid.iPID1!=0) || (data->iAHOverridePid.iPID1!=0) ) |
|
310 { |
|
311 printf("NOTE: Associated A&H override is: 0x%08x 0x%08x", data->iAHOverridePid.iPID2, data->iAHOverridePid.iPID1 ); |
|
312 } |
|
313 |
|
314 if( (data->iPid.iPID1==0) && (data->iPid.iPID2==0) ) |
|
315 { |
|
316 GeneratePID( data ); |
|
317 printf("NOTE: Generated package ID for this skin is 0x%08x 0x%08x\n", data->iPid.iPID2, data->iPid.iPID1 ); |
|
318 } |
|
319 |
|
320 |
|
321 printf("\nPhase 2: Output for MBM/MIF generation.\n"); |
|
322 char namebuf[512]; |
|
323 strcpy( namebuf, skinName ); |
|
324 char namebuf2[512]; |
|
325 strcpy( namebuf2, mbmPath ); |
|
326 strcat( namebuf2, skinName ); |
|
327 if( data->IsScalable() ) |
|
328 { |
|
329 strcat( namebuf2, "_MIFList.txt" ); |
|
330 } |
|
331 else |
|
332 { |
|
333 strcat( namebuf2, "_MBMList.txt" ); |
|
334 } |
|
335 printf(" Writing MBM/MIF list for %s to %s ...\n", namebuf, namebuf2 ); |
|
336 CSDCMBMOutput mbmOutput; |
|
337 mbmOutput.Output( data, namebuf, namebuf2 ); |
|
338 printf(" Completed.\n"); |
|
339 |
|
340 printf("\nPhase 3: Output for skin content.\n"); |
|
341 if( systemSkin ) |
|
342 { |
|
343 strcpy( namebuf, dllPath ); |
|
344 strcat( namebuf, skinName ); |
|
345 strcat( namebuf, "_ContentDLL.cpp" ); |
|
346 strcpy( namebuf2, dllPath ); |
|
347 strcat( namebuf2, skinName ); |
|
348 strcat( namebuf2, "_ContentDLL.mmp" ); |
|
349 printf(" Writing CPP and MMP files for %s to %s and %s ...\n", skinName, namebuf, namebuf2 ); |
|
350 CSDCInlOutput inlOutput; |
|
351 inlOutput.Output( data, skinName, namebuf, namebuf2 ); |
|
352 printf(" Completed.\n"); |
|
353 } |
|
354 else |
|
355 { |
|
356 if( strlen(dllPath)>0 ) |
|
357 { |
|
358 printf("WARNING: System skin CPP/MMP path not used.\n"); |
|
359 } |
|
360 printf(" Skipping CPP and MMP file creation (non-system skin).\n"); |
|
361 } |
|
362 |
|
363 strcpy( namebuf, sknPath ); |
|
364 strcat( namebuf, skinName ); |
|
365 strcat( namebuf, ".skn" ); |
|
366 strcpy( namebuf2, skinName ); |
|
367 printf(" Writing SKN file (that uses MBM/MIF %s) to %s ...\n", namebuf2, namebuf ); |
|
368 CSDCBinOutput binOutput; |
|
369 binOutput.Output( data, namebuf2, namebuf, systemSkin ); |
|
370 printf(" Completed.\n"); |
|
371 |
|
372 if( !systemSkin ) |
|
373 { |
|
374 strcpy( namebuf, sknPath ); |
|
375 strcat( namebuf, skinName ); |
|
376 strcat( namebuf, ".pkg" ); |
|
377 if( drmEnabled ) |
|
378 { |
|
379 strcpy( namebuf2, sknPath ); |
|
380 strcat( namebuf2, "datafiles.def" ); |
|
381 } |
|
382 else |
|
383 { |
|
384 strcpy( namebuf2, "" ); |
|
385 } |
|
386 printf(" Writing PKG file for %s to %s ", skinName, namebuf ); |
|
387 if( drmEnabled ) printf("\n and DRM definition file to %s ", namebuf2 ); |
|
388 printf("...\n" ); |
|
389 CSDCPkgOutput pkgOutput; |
|
390 pkgOutput.Output( data, skinName, namebuf, namebuf2 ); |
|
391 printf(" Completed.\n"); |
|
392 } |
|
393 else |
|
394 { |
|
395 printf(" Skipping PKG file creation (system skin).\n"); |
|
396 } |
|
397 } |
|
398 catch( CSDCException e ) |
|
399 { |
|
400 printf("\n----------------------------------------------------------------------\n"); |
|
401 |
|
402 e.Print(); |
|
403 error = true; |
|
404 |
|
405 printf("----------------------------------------------------------------------\n"); |
|
406 } |
|
407 delete data; |
|
408 |
|
409 printf("\n======================================================================\n"); |
|
410 |
|
411 if( error ) |
|
412 { |
|
413 printf("\nAborted, ERRORS ENCOUNTERED!\n"); |
|
414 printf("\n======================================================================\n"); |
|
415 return 2; |
|
416 } |
|
417 |
|
418 printf("\nCompleted successfully.\n"); |
|
419 printf("\n======================================================================\n"); |
|
420 return 0; |
|
421 } |
|
422 |
|
423 // End of file |