|
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: Package output. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "SDCGlobals.h" |
|
19 #include "SDCPkgOutput.h" |
|
20 #include "SDCException.h" |
|
21 #include "SDCInput.h" |
|
22 #include "AknsConstants.hrh" |
|
23 |
|
24 ////////////////////////////////////////////////////////////////////// |
|
25 // Construction/Destruction |
|
26 ////////////////////////////////////////////////////////////////////// |
|
27 |
|
28 CSDCPkgOutput::CSDCPkgOutput() |
|
29 { |
|
30 |
|
31 } |
|
32 |
|
33 CSDCPkgOutput::~CSDCPkgOutput() |
|
34 { |
|
35 |
|
36 } |
|
37 |
|
38 ////////////////////////////////////////////////////////////////////// |
|
39 // Other methods |
|
40 ////////////////////////////////////////////////////////////////////// |
|
41 |
|
42 void CSDCPkgOutput::Output( CSDCData* aData, const char* aSkinName, |
|
43 const char* aPkgFilename, const char* aDrmDefFilename ) |
|
44 { |
|
45 bool drm = false; |
|
46 if( aDrmDefFilename && (strlen(aDrmDefFilename)>0) ) |
|
47 { |
|
48 drm = true; |
|
49 } |
|
50 |
|
51 TSDCPID storagePid = aData->iParentPid; |
|
52 if( (storagePid.iPID1==0) && (storagePid.iPID2==0) ) |
|
53 { |
|
54 storagePid = aData->iPid; |
|
55 } |
|
56 |
|
57 FILE* file = fopen( aPkgFilename, "wt" ); |
|
58 if( !file ) throw CSDCException( ESDCFileOpenError, "Can not open PKG output file for writing" ); |
|
59 |
|
60 FILE* drmFile = NULL; |
|
61 if( drm ) |
|
62 { |
|
63 drmFile = fopen( aDrmDefFilename, "wt" ); |
|
64 if( !drmFile ) throw CSDCException( ESDCFileOpenError, "Can not open DRM def output file for writing" ); |
|
65 |
|
66 fprintf( drmFile, "skin\n"); |
|
67 } |
|
68 |
|
69 fprintf( file, "; File created with SkinCompiler v%i.%i.%i\n;\n", gPlatformMajor, gPlatformMinor, gVersionMinor ); |
|
70 fprintf( file, ";\n; Installation file for %s skin\n;\n", aSkinName ); |
|
71 fprintf( file, "&EN\n" ); |
|
72 |
|
73 fprintf( file, ";\n; Package header\n;\n" ); |
|
74 |
|
75 // real uid is given, assume signed package generation |
|
76 if( aData->iPid.iPID2 == 0 ) |
|
77 { |
|
78 fprintf( file, "#{\"%s\"},(%#010x),1,0,0\n", aSkinName, aData->iPid.iPID1 ); |
|
79 } |
|
80 else |
|
81 { |
|
82 fprintf( file, "#{\"%s\"},(0xA00000EB),1,0,0,TYPE=SP\n", aSkinName ); |
|
83 } |
|
84 fprintf( file, ";\n; Supports Series 60 v3.x\n; This line indicates that this installation is for the Series 60 platform v3.x\n; This line must appear _exactly_ as shown below in the sis file\n; If this line is missing or incorrect, the sis file will not be able\n; to be installed on Series 60 v3.x platforms\n;\n" ); |
|
85 fprintf( file, "[0x101f7961], 0, 0, 0, {\"Series60v3.0\"}\n" ); |
|
86 fprintf( file, ";\n; Supports Series 60 v5.x\n; This line indicates that this installation is for the Series 60 platform v5.x\n; This line must appear _exactly_ as shown below in the sis file\n; If this line is missing or incorrect, the sis file will not be able\n; to be installed on Series 60 v5.x platforms\n;\n" ); |
|
87 fprintf( file, "[0x1028315F], 0, 0, 0, {\"Series60v5.0\"}\n" ); |
|
88 fprintf( file, ";\n; Requires Series 60 Skins Support\n;\n" ); |
|
89 fprintf( file, "(0xA00000EB), 0, 0, 0, {\"Series60SkinsSupport\"}\n"); |
|
90 |
|
91 if( aData->IsScalable() ) |
|
92 { |
|
93 fprintf( file, ";\n; Requires Series 60 Scalable Skins Support\n;\n" ); |
|
94 fprintf( file, "(0x10207113), 0, 0, 0, {\"Series60ScalableSkinsSupport\"}\n"); |
|
95 } |
|
96 |
|
97 |
|
98 fprintf( file, ";\n; Non-localised vendor name\n;\n" ); |
|
99 if (wcslen(aData->iAuthor) == 0) |
|
100 { |
|
101 fprintf( file, ":\"Unknown Vendor\"\n" ); |
|
102 } |
|
103 else |
|
104 { |
|
105 char vendorBuf[512]; |
|
106 CSDCInput::ConvertToAscii( vendorBuf, aData->iAuthor ); |
|
107 fprintf( file, ":\"%s\"\n", vendorBuf ); |
|
108 } |
|
109 |
|
110 fprintf( file, ";\n; Localised vendor name\n;\n" ); |
|
111 fprintf( file, "%%{\"Vendor-EN\"}\n" ); |
|
112 |
|
113 fprintf( file, ";\n; Files to install\n;\n"); |
|
114 |
|
115 char trgPath[256]; |
|
116 |
|
117 fprintf( file, "IF package(0x102032be) ; Check for S60 3.1 stub sis\n"); |
|
118 //-------- New 3.1 compatible install directory |
|
119 if( storagePid.iPID2 == 0 ) |
|
120 { |
|
121 sprintf( trgPath, "!:\\resource\\skins\\%08x", storagePid.iPID1 ); |
|
122 } |
|
123 else |
|
124 { |
|
125 sprintf( trgPath, "!:\\resource\\skins\\%08x%08x", storagePid.iPID1, storagePid.iPID2 ); |
|
126 } |
|
127 |
|
128 fprintf( file, "\"%s.mbm\" - \"%s\\%s.mbm\"\n", aSkinName, trgPath, aSkinName ); |
|
129 if( aData->IsScalable() ) |
|
130 { |
|
131 fprintf( file, "\"%s.mif\" - \"%s\\%s.mif\"\n", aSkinName, trgPath, aSkinName ); |
|
132 } |
|
133 |
|
134 fprintf( file, "ELSE\n"); |
|
135 //-------- 3.0 compatible install directory |
|
136 if( storagePid.iPID2 == 0 ) |
|
137 { |
|
138 sprintf( trgPath, "!:\\private\\10207114\\import\\%08x", storagePid.iPID1 ); |
|
139 } |
|
140 else |
|
141 { |
|
142 sprintf( trgPath, "!:\\private\\10207114\\import\\%08x%08x", storagePid.iPID1, storagePid.iPID2 ); |
|
143 } |
|
144 |
|
145 fprintf( file, "\"%s.mbm\" - \"%s\\%s.mbm\"\n", aSkinName, trgPath, aSkinName ); |
|
146 if( aData->IsScalable() ) |
|
147 { |
|
148 fprintf( file, "\"%s.mif\" - \"%s\\%s.mif\"\n", aSkinName, trgPath, aSkinName ); |
|
149 } |
|
150 fprintf( file, "ENDIF\n") ; |
|
151 // ------- ENDIF |
|
152 if( drm ) |
|
153 { |
|
154 fprintf( file, ";SKN file %s.skn moved to DRM definition file\n", aSkinName ); |
|
155 fprintf( drmFile, "%s.skn\n", aSkinName ); |
|
156 } |
|
157 else |
|
158 { |
|
159 fprintf( file, "\"%s.skn\" - \"%s\\%s.skn\"\n", aSkinName, trgPath, aSkinName ); |
|
160 } |
|
161 |
|
162 // Append a dummy ini file |
|
163 if( storagePid.iPID2 == 0 ) |
|
164 { |
|
165 fprintf( file, ";Dummy entry for the possible skin .ini file, so that it gets removed on uninstall\n"); |
|
166 fprintf( file, "\"\" - \"!:\\private\\10207114\\import\\%08x\\%08x.ini\",FN\n",storagePid.iPID1,storagePid.iPID1 ); |
|
167 } |
|
168 else |
|
169 { |
|
170 fprintf( file, ";Dummy entry for the possible skin .ini file, so that it gets removed on uninstall\n"); |
|
171 fprintf( file, "\"\" - \"!:\\private\\10207114\\import\\%08x%08x\\%08x%08x.ini\",FN\n",storagePid.iPID1,storagePid.iPID2,storagePid.iPID1,storagePid.iPID2 ); |
|
172 } |
|
173 |
|
174 |
|
175 vector<wchar_t*> soundFiles; |
|
176 int i; |
|
177 for( i=0; i<aData->iStringDefVector.size(); i++ ) |
|
178 { |
|
179 TSDCStringDef* entry = aData->iStringDefVector[i]; |
|
180 if( entry->iIID.iMajor == EAknsMajorSound ) |
|
181 { |
|
182 bool alreadyAppended = false; |
|
183 for( int a=0; a<soundFiles.size(); a++ ) |
|
184 { |
|
185 if( !wcsicmp( entry->iString, soundFiles[a] ) ) |
|
186 { |
|
187 alreadyAppended = true; |
|
188 } |
|
189 } |
|
190 if( !alreadyAppended ) |
|
191 { |
|
192 soundFiles.push_back( entry->iString ); |
|
193 } |
|
194 } |
|
195 } |
|
196 |
|
197 char buffer[512]; |
|
198 for( i=0; i<soundFiles.size(); i++ ) |
|
199 { |
|
200 if( i==0 ) |
|
201 { |
|
202 fprintf( file, ";\n; Sound files\n;\n"); |
|
203 } |
|
204 CSDCInput::ConvertToAscii( buffer, soundFiles[i] ); |
|
205 if( drm ) |
|
206 { |
|
207 fprintf( file, ";Sound file %s moved to DRM definition file\n", buffer ); |
|
208 fprintf( drmFile, "%s\n", buffer ); |
|
209 } |
|
210 else |
|
211 { |
|
212 fprintf( file, "\"%s\" - \"%s\\%s\"\n", buffer, trgPath, buffer ); |
|
213 } |
|
214 } |
|
215 |
|
216 fprintf( file, ";\n; End of file\n;\n" ); |
|
217 fclose( file ); |
|
218 if( drmFile ) fclose( drmFile ); |
|
219 |
|
220 } |
|
221 |
|
222 // End of file |