|
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 if ($#ARGV != 2) |
|
18 { |
|
19 die "usage: iconlist iconloads out-file\n"; |
|
20 } |
|
21 |
|
22 my %iconList = ReadIconList($ARGV[0]); |
|
23 my @iconLoads = ReadIconLoads($ARGV[1]); |
|
24 |
|
25 my @result; |
|
26 my $count = 0; |
|
27 open (OUTFILE, ">$ARGV[2]") || die "Couldn't open $ARGV[2] for output\n"; |
|
28 for my $k (0 .. $#iconLoads) |
|
29 { |
|
30 my $name = $iconLoads[$k][0]; |
|
31 my $bitmapId = 16384+$iconLoads[$k][1]; |
|
32 my $maskId = 16384+$iconLoads[$k][2]; |
|
33 |
|
34 $result[$count][2] = $name; |
|
35 $result[$count][3] = $bitmapId; |
|
36 $result[$count][4] = $maskId; |
|
37 $result[$count][5] = $iconLoads[$k][3]; |
|
38 $result[$count][6] = $iconLoads[$k][4]; |
|
39 $result[$count][7] = $iconLoads[$k][5]; |
|
40 $result[$count][8] = $iconLoads[$k][6]; |
|
41 $result[$count][9] = $iconLoads[$k][7]; |
|
42 if (exists $iconList{$name}{$bitmapId}) |
|
43 { |
|
44 #print "$name,$bitmapId\n"; |
|
45 my $major = $iconList{$name}{$bitmapId}[1]; |
|
46 my $minor = $iconList{$name}{$bitmapId}[2]; |
|
47 $result[$count][0] = $major; |
|
48 $result[$count][1] = $minor; |
|
49 if ($name eq "series60skin") |
|
50 { |
|
51 #try to find out fallback file |
|
52 my $mask = 0; |
|
53 if ($result[$count][4] >= 0) |
|
54 { |
|
55 $mask = 1; |
|
56 } |
|
57 $result[$count][2] = ""; |
|
58 $result[$count][3] = -1; |
|
59 $result[$count][4] = -1; |
|
60 foreach my $f (keys %iconList) |
|
61 { |
|
62 if ($f eq "series60skin") |
|
63 { |
|
64 } |
|
65 else |
|
66 { |
|
67 for my $id ( keys %{ $iconList{$f} } ) |
|
68 { |
|
69 if (($iconList{$f}{$id}[1] eq $major) && ($iconList{$f}{$id}[2] eq $minor)) |
|
70 { |
|
71 $result[$count][2] = $f; |
|
72 $result[$count][3] = $id; |
|
73 if ($mask) |
|
74 { |
|
75 $result[$count][4] = $id + 1; |
|
76 } |
|
77 } |
|
78 } |
|
79 } |
|
80 } |
|
81 } |
|
82 $count += 1; |
|
83 } |
|
84 else |
|
85 { |
|
86 $result[$count][0] = -1; |
|
87 $result[$count][1] = -1; |
|
88 if ($name eq "series60skin") |
|
89 { |
|
90 print "skin ID not found from $name,$bitmapId, cannot store to precache\n"; |
|
91 } |
|
92 else |
|
93 { |
|
94 print "skin ID not found from $name,$bitmapId\n"; |
|
95 $count += 1; |
|
96 } |
|
97 } |
|
98 } |
|
99 |
|
100 for my $k (0 .. $#result) |
|
101 { |
|
102 if ($result[$count][8] == 0 && $result[$count][9] == 0) # rotation and color |
|
103 { |
|
104 if (length($result[$k][2]) > 0) |
|
105 { |
|
106 my $temp = $result[$k][2]; |
|
107 if ($temp eq "avkon") |
|
108 { |
|
109 $temp = "avkon2"; |
|
110 } |
|
111 $result[$k][2] = "z:\\\\resource\\\\apps\\\\" . $temp . ".mif"; |
|
112 } |
|
113 print OUTFILE "ICON2\n"; |
|
114 print OUTFILE " {\n"; |
|
115 print OUTFILE " skin_id_major = $result[$k][0];\n"; |
|
116 print OUTFILE " skin_id_minor = $result[$k][1];\n"; |
|
117 print OUTFILE " fallback_icon_file = \"$result[$k][2]\";\n"; |
|
118 print OUTFILE " fallback_icon_id = $result[$k][3];\n"; |
|
119 print OUTFILE " fallback_mask_id = $result[$k][4];\n"; |
|
120 print OUTFILE " icon_width = $result[$k][5];\n"; |
|
121 print OUTFILE " icon_height = $result[$k][6];\n"; |
|
122 print OUTFILE " icon_mode = $result[$k][7];\n"; |
|
123 print OUTFILE " },\n"; |
|
124 } |
|
125 } |
|
126 |
|
127 close OUTFILE; |
|
128 exit(0); |
|
129 |
|
130 sub ReadIconList |
|
131 { |
|
132 my $file = shift; |
|
133 my %iconList; |
|
134 open (INFILE, "<$file") || die "Couldn't open $file for input\n"; |
|
135 my $line = <INFILE>; # ignore heading line |
|
136 while ($line=<INFILE>) |
|
137 { |
|
138 chomp($line); |
|
139 my @array = split(/,/,$line); |
|
140 my $iconId = $array[0]; |
|
141 my $name = lc($array[1]); |
|
142 if ($name =~ m/\Aseries60skin/) |
|
143 { |
|
144 $name = "series60skin"; |
|
145 } |
|
146 else |
|
147 { |
|
148 if ($name =~ m/(\S+)\.(\S+)/) #remove extension |
|
149 { |
|
150 $name =$1; |
|
151 } |
|
152 } |
|
153 $iconList{$name}{$iconId}[0] = $array[2]; # filename |
|
154 $iconList{$name}{$iconId}[1] = $array[3]; # major id |
|
155 $iconList{$name}{$iconId}[2] = $array[4]; # minor id |
|
156 #print "add,$name,$iconId\n"; |
|
157 } |
|
158 close INFILE; |
|
159 return %iconList; |
|
160 } |
|
161 |
|
162 sub ReadIconLoads |
|
163 { |
|
164 my $file = shift; |
|
165 my @iconLoads; |
|
166 open (INFILE, "<$file") || die "Couldn't open $file for input\n"; |
|
167 my $count = 0; |
|
168 while ($line=<INFILE>) |
|
169 { |
|
170 $line =~ s/'//g; |
|
171 if ($line =~ m/AKNICON load,(.*)/) |
|
172 { |
|
173 my @array = split(/,/,$1); |
|
174 my $name = lc($array[0]); |
|
175 ($name,my $path) = SplitPath($name); |
|
176 if ($name =~ m/(\S+)\.(\S+)/) #remove extension |
|
177 { |
|
178 $name =$1; |
|
179 } |
|
180 if ($name eq "avkon2") |
|
181 { |
|
182 $name = "avkon"; |
|
183 } |
|
184 $iconLoads[$count][0] = $name; |
|
185 $iconLoads[$count][1] = $array[1]; |
|
186 $iconLoads[$count][2] = $array[2]; |
|
187 $iconLoads[$count][3] = $array[3]; #width |
|
188 $iconLoads[$count][4] = $array[4]; #height |
|
189 $iconLoads[$count][5] = $array[5]; |
|
190 $iconLoads[$count][6] = $array[6]; |
|
191 $iconLoads[$count][7] = $array[7]; |
|
192 $iconLoads[$count][8] = $array[8]; # DisableCompression |
|
193 |
|
194 if ($iconLoads[$count][6] != 0) |
|
195 { |
|
196 print "cannot precache because rotation is not zero, rotation = $iconLoads[$count][6]\n"; |
|
197 } |
|
198 elsif ($iconLoads[$count][7] != 0) |
|
199 { |
|
200 print "cannot precache because color is not zero, color = $iconLoads[$count][7]\n"; |
|
201 } |
|
202 elsif ($iconLoads[$count][8]) |
|
203 { |
|
204 print "cannot precache because compression is disabled, compression = $iconLoads[$count][8]\n"; |
|
205 } |
|
206 elsif ($iconLoads[$count][3] == 0 || $iconLoads[$count][4] == 0) |
|
207 { |
|
208 print "cannot precache because icon size is zero, width = $iconLoads[$count][3], height = $iconLoads[$count][4]\n"; |
|
209 } |
|
210 else |
|
211 { |
|
212 $count++; |
|
213 } |
|
214 } |
|
215 } |
|
216 close INFILE; |
|
217 return @iconLoads; |
|
218 } |
|
219 |
|
220 # take a full path name as input, return name and path |
|
221 sub SplitPath { |
|
222 if ($_[0] =~ m/\\((\w|[.]|[-])+)(\z)/) |
|
223 { |
|
224 return $1,$`; |
|
225 } |
|
226 else |
|
227 { |
|
228 return $_[0]; |
|
229 } |
|
230 } |