|
1 # |
|
2 # Copyright (c) 2009 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 # |
|
16 |
|
17 my $KAknsConstants_h = "\\epoc32\\include\\middleware\\AknsConstants.h"; |
|
18 my $KAknsConstants_hrh = "\\epoc32\\include\\middleware\\AknsConstants.hrh"; |
|
19 |
|
20 if ($#ARGV != 2) |
|
21 { |
|
22 die "usage: MIFList-file build-path out-file\n"; |
|
23 } |
|
24 |
|
25 my @mifList = ReadMifList($ARGV[0]); |
|
26 my $path = $ARGV[1]; |
|
27 open (OUTFILE, ">$ARGV[2]") || die "Couldn't open $ARGV[2] for output\n"; |
|
28 print OUTFILE "Icon ID,file name,SVG name,Skin ID major,Skin ID minor\n"; |
|
29 |
|
30 (my $mifName,my $mifPath) = SplitPath($ARGV[0]); |
|
31 |
|
32 my %skins = ReadAknsConstants_h($path.$KAknsConstants_h); |
|
33 my %skinIDVals = ReadAknsConstants_hrh($path.$KAknsConstants_hrh); |
|
34 |
|
35 for my $k (0 .. $#mifList) |
|
36 { |
|
37 (my $name,my $path) = SplitPath($mifList[$k]); |
|
38 my $iconId = 2* $k + 16384; |
|
39 $name =~ s/_//g; |
|
40 if ($name =~ m/(\S+)\.(\S+)/) #remove extension |
|
41 { |
|
42 $name =$1; |
|
43 } |
|
44 #print "$k,$name,$path\n"; |
|
45 if (exists $skins{$name}) |
|
46 { |
|
47 my $major = $skins{$name}[0]; |
|
48 my $minor = $skins{$name}[1]; |
|
49 my $majorVal = -1; |
|
50 if (exists $skinIDVals{$major}) |
|
51 { |
|
52 $majorVal = $skinIDVals{$major}; |
|
53 } |
|
54 else |
|
55 { |
|
56 print "not found major $major\n"; |
|
57 } |
|
58 my $minorVal = -1; |
|
59 if (exists $skinIDVals{$minor}) |
|
60 { |
|
61 $minorVal = $skinIDVals{$minor}; |
|
62 } |
|
63 else |
|
64 { |
|
65 print "not found minor $minor\n"; |
|
66 } |
|
67 printf(OUTFILE "%d,%s,%s,0x%x,0x%x\n",$iconId,$mifName,$mifList[$k],$majorVal,$minorVal); |
|
68 #print "found,$majorVal,$minorVal\n"; |
|
69 } |
|
70 else |
|
71 { |
|
72 #print "not found $name\n"; |
|
73 } |
|
74 } |
|
75 |
|
76 my $incPath = $path . "\\epoc32\\include"; |
|
77 opendir DIR,$incPath; |
|
78 my @files = readdir DIR; |
|
79 foreach my $f (@files) |
|
80 { |
|
81 if ($f =~ /(\S+)\.mbg\z/i) |
|
82 { |
|
83 my $fName = lc(embm . $1); |
|
84 my %list = ReadMbg($incPath . "\\" . $f); |
|
85 foreach my $k (keys %list) |
|
86 { |
|
87 my $svgName = lc($k); |
|
88 my $iconId = $list{$k}; |
|
89 my $ind = index($svgName,$fName); |
|
90 if ($ind >= 0) |
|
91 { |
|
92 $ind += length($fName); |
|
93 my $svg = substr($svgName,$ind); |
|
94 $svg =~ s/_//g; |
|
95 if (exists $skins{$svg}) |
|
96 { |
|
97 my $major = $skins{$svg}[0]; |
|
98 my $minor = $skins{$svg}[1]; |
|
99 my $majorVal = -1; |
|
100 if (exists $skinIDVals{$major}) |
|
101 { |
|
102 $majorVal = $skinIDVals{$major}; |
|
103 } |
|
104 else |
|
105 { |
|
106 print "not found major $major\n"; |
|
107 } |
|
108 my $minorVal = -1; |
|
109 if (exists $skinIDVals{$minor}) |
|
110 { |
|
111 $minorVal = $skinIDVals{$minor}; |
|
112 } |
|
113 else |
|
114 { |
|
115 print "not found minor $minor\n"; |
|
116 } |
|
117 printf(OUTFILE "%d,%s,%s,0x%x,0x%x\n",$iconId,$f,$k,$majorVal,$minorVal); |
|
118 #print "found,$majorVal,$minorVal\n"; |
|
119 } |
|
120 else |
|
121 { |
|
122 #print "not found $svg\n"; |
|
123 } |
|
124 } |
|
125 else |
|
126 { |
|
127 print "not found,$svgName,$fName\n"; |
|
128 } |
|
129 } |
|
130 } |
|
131 } |
|
132 close DIR; |
|
133 |
|
134 |
|
135 close OUTFILE; |
|
136 |
|
137 exit(0); |
|
138 |
|
139 sub ReadMifList |
|
140 { |
|
141 my $file = shift; |
|
142 my @mifList; |
|
143 open (INFILE, "<$file") || die "Couldn't open $file for input\n"; |
|
144 while (my $line=<INFILE>) |
|
145 { |
|
146 #if ($line =~ m/\S+\s+(\S+)(\.svg)/) |
|
147 if ($line =~ m/\S+\s+(\S+)/) |
|
148 { |
|
149 push(@mifList,$1); |
|
150 } |
|
151 #else |
|
152 # { |
|
153 # print "$line\n"; |
|
154 # } |
|
155 } |
|
156 close INFILE; |
|
157 return @mifList; |
|
158 } |
|
159 |
|
160 sub ReadMbg |
|
161 { |
|
162 my $file = shift; |
|
163 my %mifList; |
|
164 open (INFILE, "<$file") || die "Couldn't open $file for input\n"; |
|
165 while (my $line=<INFILE>) |
|
166 { |
|
167 if ($line =~ m/(\S+)\s*=\s*(\d+),/) |
|
168 { |
|
169 $mifList{$1}=$2; |
|
170 } |
|
171 #else |
|
172 # { |
|
173 # print "$line\n"; |
|
174 # } |
|
175 } |
|
176 close INFILE; |
|
177 return %mifList; |
|
178 } |
|
179 |
|
180 sub ReadAknsConstants_h |
|
181 { |
|
182 my $file = shift; |
|
183 my %list; |
|
184 my $state = 0; |
|
185 my $name; |
|
186 open (INFILE, "<$file") || die "Couldn't open $file for input\n"; |
|
187 while (my $line=<INFILE>) |
|
188 { |
|
189 if ($line =~ m/TAknsItemID\s+KAknsIID(\S+)\s*=/) |
|
190 { |
|
191 $state = 1; |
|
192 $name = lc($1); |
|
193 } |
|
194 else |
|
195 { |
|
196 if ($state == 1) |
|
197 { |
|
198 if ($line =~ m/\{\s*(\S+)\s*,\s*(\S+)\s*\}/) |
|
199 { |
|
200 $list{$name}[0] = $1; |
|
201 $list{$name}[1] = $2; |
|
202 } |
|
203 $state = 0; |
|
204 } |
|
205 } |
|
206 } |
|
207 close INFILE; |
|
208 return %list; |
|
209 } |
|
210 |
|
211 sub ReadAknsConstants_hrh |
|
212 { |
|
213 my $file = shift; |
|
214 my %list; |
|
215 my $state = 0; |
|
216 my $name; |
|
217 open (INFILE, "<$file") || die "Couldn't open $file for input\n"; |
|
218 while (my $line=<INFILE>) |
|
219 { |
|
220 if ($line =~ m/\s*(\S+)\s*=\s*(\S+)(,|\s+)/) |
|
221 { |
|
222 my $n = $1; |
|
223 my $val = hex($2); |
|
224 $list{$n} = $val; |
|
225 #print "$n,$val\n"; |
|
226 } |
|
227 } |
|
228 close INFILE; |
|
229 return %list; |
|
230 } |
|
231 |
|
232 # take a full path name as input, return name and path |
|
233 sub SplitPath { |
|
234 if ($_[0] =~ m/\\((\w|[.]|[-])+)(\z)/) |
|
235 { |
|
236 return $1,$`; |
|
237 } |
|
238 else |
|
239 { |
|
240 return $_[0]; |
|
241 } |
|
242 } |