|
1 /* |
|
2 * Copyright (c) 2005-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 the License "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 |
|
18 |
|
19 #include "messages.h" |
|
20 #include "main.h" |
|
21 |
|
22 Message::Message(String aMessage, int aIndex, String aTextIndex, bool aActivated, int aMessageType) |
|
23 :iMessage(aMessage), |
|
24 iIndex(aIndex), |
|
25 iTextIndex(aTextIndex), |
|
26 iActivated(aActivated), |
|
27 iMessageType(aMessageType) |
|
28 { |
|
29 } |
|
30 |
|
31 Message::~Message() |
|
32 { |
|
33 } |
|
34 |
|
35 void Message::SetActivationStatus(bool aActivationStatus) |
|
36 { |
|
37 iActivated = aActivationStatus; |
|
38 } |
|
39 |
|
40 bool Message::GetActivated() |
|
41 { |
|
42 return iActivated; |
|
43 } |
|
44 |
|
45 String Message::GetMessageOutput() |
|
46 { |
|
47 String messageOutput; |
|
48 if(iMessageType == KError) |
|
49 { |
|
50 messageOutput = "Error"; |
|
51 } |
|
52 else if(iMessageType == KWarning) |
|
53 { |
|
54 messageOutput = "Warning"; |
|
55 } |
|
56 else |
|
57 { |
|
58 // add fall back code |
|
59 } |
|
60 messageOutput += ": ("; |
|
61 messageOutput += iTextIndex; |
|
62 messageOutput += ") "; |
|
63 messageOutput += iMessage; |
|
64 |
|
65 return messageOutput; |
|
66 } |
|
67 |
|
68 int Message::GetIndex() |
|
69 { |
|
70 return iIndex; |
|
71 } |
|
72 |
|
73 String Message::GetTextIndex() |
|
74 { |
|
75 return iTextIndex; |
|
76 } |
|
77 |
|
78 Message * MessageArray::GetEntry(int aEntry) |
|
79 { |
|
80 MessageArrayIterator next(*this); |
|
81 Message * pRequiredMessage; |
|
82 while ((pRequiredMessage = next() ) != NULL) |
|
83 { |
|
84 if( pRequiredMessage->GetIndex() == aEntry ) |
|
85 { // this comparison returns true if the label is the same as the declared label |
|
86 return pRequiredMessage; |
|
87 } |
|
88 } |
|
89 return NULL; |
|
90 } |
|
91 |
|
92 Message * MessageArray::GetTextEntry(String aEntry) |
|
93 { |
|
94 MessageArrayIterator next(*this); |
|
95 Message * pRequiredMessage; |
|
96 while ((pRequiredMessage = next() ) != NULL) |
|
97 { |
|
98 if( pRequiredMessage->GetTextIndex() == aEntry ) |
|
99 { // this comparison returns true if the label is the same as the declared label |
|
100 return pRequiredMessage; |
|
101 } |
|
102 } |
|
103 return NULL; |
|
104 } |
|
105 |
|
106 void MessageArray::Add(Message * pNewItem) |
|
107 { |
|
108 Array::Add(pNewItem); |
|
109 } |
|
110 |
|
111 MessageArrayIterator::MessageArrayIterator(const MessageArray & c) |
|
112 :ArrayIterator(c) |
|
113 {} |
|
114 |
|
115 Message* MessageArrayIterator::operator() () |
|
116 { |
|
117 return (Message *) ArrayIterator::operator() (); |
|
118 } |
|
119 |
|
120 MessageArray::MessageArray() |
|
121 { |
|
122 const String LT_001_Message = "rls item used more than once."; // Warns if an rls item is used in more than one place but is not declared using the 'multi' keyword. Emitted once for each rls item to which this applies. |
|
123 Add(new Message(LT_001_Message, LT_001, "001", true, KWarning)); |
|
124 |
|
125 const String LT_002_Message = "if the rls item really must be exactly the same in all the places it is referenced from for the code to work, declare the rls item as 'multi', for example 'rls_string multi ss1 \"hello\"'. If localizers are free to change them independently, duplicate the rls item and reference a different copy each time."; // Gives information about the 'multi' keyword, only emitted once. |
|
126 Add(new Message(LT_002_Message, LT_002, "002", true, KWarning)); |
|
127 |
|
128 const String LT_003_Message = "rls item redefined."; // Warns if two rls items have the same label. |
|
129 Add(new Message(LT_003_Message, LT_003, "003", true, KWarning)); |
|
130 |
|
131 const String LT_004_Message = "unused rls item."; // . |
|
132 Add(new Message(LT_004_Message, LT_004, "004", true, KWarning)); |
|
133 |
|
134 const String LT_005_Message = "rls item not preceded by a localisation tag."; // . |
|
135 Add(new Message(LT_005_Message, LT_005, "005", true, KWarning)); |
|
136 |
|
137 const String LT_006_Message = "specified command not previously declared."; // Warns if a command is used in a localisation comment which has not been defined with @declaretag. |
|
138 Add(new Message(LT_006_Message, LT_006, "006", true, KWarning)); |
|
139 |
|
140 const String LT_007_Message = "specified command has already been used in this comment."; // Warns if a command is used more than once in a localisation comment. |
|
141 Add(new Message(LT_007_Message, LT_007, "007", true, KWarning)); |
|
142 |
|
143 const String LT_008_Message = "this tag cannot be used with this rls type."; // Warns if in a localisation comment a tag is used which has not been declared with either @tagoptional or @tagrequired for this rls type. |
|
144 Add(new Message(LT_008_Message, LT_008, "008", true, KWarning)); |
|
145 |
|
146 const String LT_009_Message = "tag declared as void but has arguments."; // . |
|
147 Add(new Message(LT_009_Message, LT_009, "009", true, KWarning)); |
|
148 |
|
149 const String LT_010_Message = "tag declared as single but does not have one argument."; // . |
|
150 Add(new Message(LT_010_Message, LT_010, "010", true, KWarning)); |
|
151 |
|
152 const String LT_011_Message = "tag declared as multiple must have at least one argument."; // . |
|
153 Add(new Message(LT_011_Message, LT_011, "011", true, KWarning)); |
|
154 |
|
155 const String LT_012_Message = "tag declared as text, must have at least one word after it."; // . |
|
156 Add(new Message(LT_012_Message, LT_012, "012", true, KWarning)); |
|
157 |
|
158 const String LT_013_Message = "required tag not present. Tag name = "; // A tag declared with @tagrequired for this rls type is not present. |
|
159 Add(new Message(LT_013_Message, LT_013, "013", true, KWarning)); |
|
160 |
|
161 const String LT_014_Message = "parameter(s) not legal for this tag."; // In a localisation comment a parameter is used with a tag which has not been declared with @tagvalue. |
|
162 Add(new Message(LT_014_Message, LT_014, "014", true, KWarning)); |
|
163 |
|
164 const String LT_015_Message = "first word must start with an @ symbol."; // Warns if the first word in a localisation comment tag does not start with an @ symbol. N.B. This does not warn that an arbitrary line in a localisation comment does not start with an @ symbol as at this point have not checked whether this is a multi line comment. |
|
165 Add(new Message(LT_015_Message, LT_015, "015", true, KWarning)); |
|
166 |
|
167 const String LT_016_Message = "invalid declaration line."; // This will be produced if an @declaretag line does not have exactly three words on it. i.e. should be of form @declaretag type tag-name . This warning might be produced if the line following this line does not start with an @ symbol. |
|
168 Add(new Message(LT_016_Message, LT_016, "016", true, KWarning)); |
|
169 |
|
170 const String LT_017_Message = "illegal type."; // Emits a warning if in a @declaretag line the type is not one of void, single, multiple or text. |
|
171 Add(new Message(LT_017_Message, LT_017, "017", true, KWarning)); |
|
172 |
|
173 const String LT_018_Message = "declared tag should not start with an @ symbol."; // In a @declaretag line the tag-name should not start with an @symbol, i.e. @declaretag single localise not @declaretag single @localise |
|
174 Add(new Message(LT_018_Message, LT_018, "018", true, KWarning)); |
|
175 |
|
176 const String LT_019_Message = "redefinition of already declared tag."; // If two @declaretag lines appear for a particular tag. |
|
177 Add(new Message(LT_019_Message, LT_019, "019", true, KWarning)); |
|
178 |
|
179 const String LT_020_Message = "tag value line must consist of three distinct tokens."; // i.e. @tagvalue localise yes |
|
180 Add(new Message(LT_020_Message, LT_020, "020", true, KWarning)); |
|
181 |
|
182 const String LT_021_Message = "tag name must not start with an @ symbol in @tagvalue statement."; // . |
|
183 Add(new Message(LT_021_Message, LT_021, "021", true, KWarning)); |
|
184 |
|
185 const String LT_022_Message = "parameter already added for this tag type."; // i.e. two or more instances of @tagvalue localise yes |
|
186 Add(new Message(LT_022_Message, LT_022, "022", true, KWarning)); |
|
187 |
|
188 const String LT_023_Message = "tag requirement line must consist of three distinct tokens."; // i.e. @tagrequired localise rls_string |
|
189 Add(new Message(LT_023_Message, LT_023, "023", true, KWarning)); |
|
190 |
|
191 const String LT_024_Message = "second word should not begin with an @ symbol in @tagrequired line."; // . |
|
192 Add(new Message(LT_024_Message, LT_024, "024", true, KWarning)); |
|
193 |
|
194 const String LT_025_Message = "parameter already declared as optional or required."; // Emitted on trying to redeclare a tag as required or optional, regardless of whether this is consistent with the previous declaration. |
|
195 Add(new Message(LT_025_Message, LT_025, "025", true, KWarning)); |
|
196 |
|
197 const String LT_026_Message = "line has too many or too few parameters."; // UNUSED: Emitted on @tagoptional lines if there are less than two or more than four parameters, as must be one of the following forms: @tagoptional localise rls_string, @tagoptional localise=yes rls_string, @tagoptional localise =yes rls_string, @tagoptional localise= yes rls_string, @tagoptional localise = yes rls_string |
|
198 Add(new Message(LT_026_Message, LT_026, "026", true, KWarning)); |
|
199 |
|
200 const String LT_027_Message = "invalid declaration of optional tag, more than one equals sign found in line."; // . |
|
201 Add(new Message(LT_027_Message, LT_027, "027", true, KWarning)); |
|
202 |
|
203 const String LT_028_Message = "invalid declaration of optional tag."; // UNUSED: Emitted for syntax errors, more than one equals sign, missing tag name, missing default value if an = sign is present, = signs in odd places. |
|
204 Add(new Message(LT_028_Message, LT_028, "028", true, KWarning)); |
|
205 |
|
206 const String LT_029_Message = "invalid declaration of optional tag, missing default value or rls item."; // UNUSED. |
|
207 Add(new Message(LT_029_Message, LT_029, "029", true, KWarning)); |
|
208 |
|
209 const String LT_030_Message = "localised output file could not be produced."; // Warns if there are problems saving a copy of the rpp file after adding the default values to tags which have tags missing. |
|
210 Add(new Message(LT_030_Message, LT_030, "030", true, KWarning)); |
|
211 |
|
212 const String LT_031_Message = "internal error! rls type not handled."; // Emits error if try to use an rls item which is unknown, i.e. trying to use rls_chocolate |
|
213 Add(new Message(LT_031_Message, LT_031, "031", true, KError)); |
|
214 |
|
215 const String LT_032_Message = "text length of rls string exceeds specified limit."; // Emits error if the length of the string given exceeds the length of the string specified in brackets, i.e. rls_string<5> STRING_1 "Hello World" as length of Hello World is > 5. This is an error rather than a warning as in the future the value <x> will be relevant to the storage used to store the string. |
|
216 Add(new Message(LT_032_Message, LT_032, "032", true, KError)); |
|
217 |
|
218 const String LT_033_Message = "rls_string or rls_string8 used for character constant: use rls_long, rls_word or rls_byte."; // character constants should be declared as a number type (future requirement about storage allocaltion based on the type used), i.e. rls_byte CHAR_1 'a' not rls_string CHAR_1 'a' |
|
219 Add(new Message(LT_033_Message, LT_033, "033", true, KWarning)); |
|
220 |
|
221 const String LT_034_Message = "could not find value to substitute in for label."; // UNUSED. |
|
222 Add(new Message(LT_034_Message, LT_034, "034", true, KWarning)); |
|
223 |
|
224 const String LT_035_Message = "invalid declaration of optional tag, expecting rls item but found token: "; // . |
|
225 Add(new Message(LT_035_Message, LT_035, "035", true, KWarning)); |
|
226 |
|
227 const String LT_036_Message = "invalid declaration of required tag, unknown rls type found, rls type = "; // . |
|
228 Add(new Message(LT_036_Message, LT_036, "036", true, KWarning)); |
|
229 |
|
230 const String LT_037_Message = "localised output file could not be produced."; // Warning emitted if rcomp is not able to replace the existing rpp file with a localised version (with default tags added for optional non-present tags. |
|
231 Add(new Message(LT_037_Message, LT_037, "037", true, KWarning)); |
|
232 |
|
233 const String LT_038_Message = "invalid declaration of optional tag, rls item name found where command name expected."; // . |
|
234 Add(new Message(LT_038_Message, LT_038, "038", true, KWarning)); |
|
235 |
|
236 const String LT_039_Message = "invalid declaration of optional tag, equal sign found at the start of command name."; // . |
|
237 Add(new Message(LT_039_Message, LT_039, "039", true, KWarning)); |
|
238 |
|
239 const String LT_040_Message = "invalid declaration of optional tag, rls item found where command name expected."; // . |
|
240 Add(new Message(LT_040_Message, LT_040, "040", true, KWarning)); |
|
241 |
|
242 const String LT_041_Message = "invalid declaration of optional tag, rls item found where default value expected."; // . |
|
243 Add(new Message(LT_041_Message, LT_041, "041", true, KWarning)); |
|
244 |
|
245 const String LT_042_Message = "invalid declaration of optional tag, incorrect syntax for declaring default value."; // . |
|
246 Add(new Message(LT_042_Message, LT_042, "042", true, KWarning)); |
|
247 |
|
248 const String LT_043_Message = "invalid declaration of optional tag, found unknown tokens at end of line, first unknown token is: "; // . |
|
249 Add(new Message(LT_043_Message, LT_043, "043", true, KWarning)); |
|
250 |
|
251 const String LT_044_Message = "invalid declaration of optional tag, end of line reached unexpectedly."; // . |
|
252 Add(new Message(LT_044_Message, LT_044, "044", true, KWarning)); |
|
253 |
|
254 /* This warning has been added to hopefully fix a long standing defect where labels which |
|
255 * have not been declared are silently included in the emitted resource file. More |
|
256 * details at defect INC061459 */ |
|
257 const String LT_045_Message = "the following label is used but has not been declared: "; |
|
258 Add(new Message(LT_045_Message, LT_045, "045", true, KWarning)); |
|
259 |
|
260 const String LT_046_Message = "the STRUCT that this resource is based on contains a STRUCT data member which has not been used in this resource, the missing element is: "; |
|
261 Add(new Message(LT_046_Message, LT_046, "046", true, KWarning)); |
|
262 |
|
263 const String LT_047_Message = "the STRUCT that this resource is based on contains a STRUCT[] data member which has not been used in this resource, the missing element is: "; |
|
264 Add(new Message(LT_047_Message, LT_047, "047", true, KWarning)); |
|
265 |
|
266 } |