sl@0
|
1 |
// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// e32\euser\us_exec.cpp
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
#include "us_std.h"
|
sl@0
|
19 |
#include "us_data.h"
|
sl@0
|
20 |
#include <e32des8_private.h>
|
sl@0
|
21 |
#include <e32kpan.h>
|
sl@0
|
22 |
#include <unicode.h>
|
sl@0
|
23 |
#include <videodriver.h>
|
sl@0
|
24 |
#include "CompareImp.h"
|
sl@0
|
25 |
#include <e32atomics.h>
|
sl@0
|
26 |
|
sl@0
|
27 |
#include "locmapping.h"
|
sl@0
|
28 |
|
sl@0
|
29 |
#ifdef __VC32__
|
sl@0
|
30 |
#pragma setlocale("english")
|
sl@0
|
31 |
#endif
|
sl@0
|
32 |
|
sl@0
|
33 |
_LIT(KLitSpace, " ");
|
sl@0
|
34 |
_LIT(KLitOpeningBracket, "(");
|
sl@0
|
35 |
_LIT(KLitMinusSign, "-");
|
sl@0
|
36 |
_LIT(KLitZeroPad, "0");
|
sl@0
|
37 |
|
sl@0
|
38 |
#ifdef SYMBIAN_DISTINCT_LOCALE_MODEL
|
sl@0
|
39 |
_LIT(KFindLan, "elocl_lan.");
|
sl@0
|
40 |
_LIT(KFindReg, "elocl_reg.");
|
sl@0
|
41 |
_LIT(KFindCol, "elocl_col.");
|
sl@0
|
42 |
_LIT(KLoc, "elocl.");
|
sl@0
|
43 |
#endif
|
sl@0
|
44 |
|
sl@0
|
45 |
// Private use area ranges of printable/non-printable characters.
|
sl@0
|
46 |
// This is a sorted list of numbers indicating the ranges in which characters
|
sl@0
|
47 |
// are printable and non-printable. The elements 0, 2, 4... are the first
|
sl@0
|
48 |
// characters of printable ranges and The elements 1, 3, 5... are the first
|
sl@0
|
49 |
// characters of non-printable ranges
|
sl@0
|
50 |
// We will assume that anything in the End User Sub-area is printable.
|
sl@0
|
51 |
static const TInt PUAPrintableRanges[] =
|
sl@0
|
52 |
{
|
sl@0
|
53 |
0xE000, 0xF6D9, // End user area + unassigned corporate use area
|
sl@0
|
54 |
0xF6DB, 0xF6DC, // Replacement for character not in font
|
sl@0
|
55 |
0xF6DE, 0xF700, // various EIKON and Agenda symbols
|
sl@0
|
56 |
0x10000, KMaxTInt // everything else printable
|
sl@0
|
57 |
};
|
sl@0
|
58 |
|
sl@0
|
59 |
static TBool IsPUAPrintable(TInt aChar)
|
sl@0
|
60 |
{
|
sl@0
|
61 |
if (0x110000 <= aChar)
|
sl@0
|
62 |
return 0; // non-characters not printable
|
sl@0
|
63 |
TInt i = 0;
|
sl@0
|
64 |
while (PUAPrintableRanges[i] <= aChar)
|
sl@0
|
65 |
++i;
|
sl@0
|
66 |
return i & 1;
|
sl@0
|
67 |
}
|
sl@0
|
68 |
|
sl@0
|
69 |
|
sl@0
|
70 |
|
sl@0
|
71 |
|
sl@0
|
72 |
EXPORT_C TBool User::JustInTime()
|
sl@0
|
73 |
/**
|
sl@0
|
74 |
Tests whether just-in-time debugging is on or off.
|
sl@0
|
75 |
|
sl@0
|
76 |
The function is used by the Kernel, on the Emulator, to decide whether to do
|
sl@0
|
77 |
just-in-time debugging for panics. The function applies to the current process.
|
sl@0
|
78 |
|
sl@0
|
79 |
Unless overridden by calling User::SetJustInTime(EFalse), just-in-time debugging
|
sl@0
|
80 |
is on by default.
|
sl@0
|
81 |
|
sl@0
|
82 |
@return True, if just-in-time debugging is on. False otherwise.
|
sl@0
|
83 |
@see RProcess::JustInTime
|
sl@0
|
84 |
*/
|
sl@0
|
85 |
{
|
sl@0
|
86 |
|
sl@0
|
87 |
return RProcess().JustInTime();
|
sl@0
|
88 |
}
|
sl@0
|
89 |
|
sl@0
|
90 |
|
sl@0
|
91 |
|
sl@0
|
92 |
|
sl@0
|
93 |
EXPORT_C void User::SetJustInTime(const TBool aBoolean)
|
sl@0
|
94 |
/**
|
sl@0
|
95 |
Sets just-in-time debugging for this process on or off.
|
sl@0
|
96 |
|
sl@0
|
97 |
While the function can be called by code running on both the Emulator and ARM,
|
sl@0
|
98 |
it only has an effect on the Emulator. Turning just-in-time debugging off
|
sl@0
|
99 |
prevents the debug Emulator closing down when a panic occurs.
|
sl@0
|
100 |
|
sl@0
|
101 |
By default, just-in-time debugging is on.
|
sl@0
|
102 |
|
sl@0
|
103 |
Note that the emulator handles panics in the nomal manner, i.e. by killing
|
sl@0
|
104 |
the thread.
|
sl@0
|
105 |
|
sl@0
|
106 |
@param aBoolean ETrue, if just-in-time debugging is to be set on. EFalse,
|
sl@0
|
107 |
if just-in-time debugging is to be set off.
|
sl@0
|
108 |
EFalse causes _asm 3 calls to be disabled.
|
sl@0
|
109 |
@see RProcess::SetJustInTime
|
sl@0
|
110 |
*/
|
sl@0
|
111 |
{
|
sl@0
|
112 |
|
sl@0
|
113 |
RProcess().SetJustInTime(aBoolean);
|
sl@0
|
114 |
}
|
sl@0
|
115 |
|
sl@0
|
116 |
|
sl@0
|
117 |
extern const LCharSet* GetLocaleDefaultCharSet();
|
sl@0
|
118 |
extern const LCharSet* GetLocalePreferredCharSet();
|
sl@0
|
119 |
|
sl@0
|
120 |
// Convert to folded.
|
sl@0
|
121 |
EXPORT_C TUint User::Fold(TUint aChar)
|
sl@0
|
122 |
/**
|
sl@0
|
123 |
@deprecated
|
sl@0
|
124 |
|
sl@0
|
125 |
Folds the specified character.
|
sl@0
|
126 |
|
sl@0
|
127 |
Folding converts the character to a form which can be used in tolerant
|
sl@0
|
128 |
comparisons without control over the operations performed. Tolerant comparisons
|
sl@0
|
129 |
are those which ignore character differences like case and accents.
|
sl@0
|
130 |
|
sl@0
|
131 |
The result of folding a character depends on the locale and on whether this
|
sl@0
|
132 |
is a UNICODE build or not.
|
sl@0
|
133 |
|
sl@0
|
134 |
Note that for a non-UNICODE build, if the binary value of the character aChar
|
sl@0
|
135 |
is greater than or equal to 0x100, then the character returned is the same as
|
sl@0
|
136 |
the character passed to the function.
|
sl@0
|
137 |
|
sl@0
|
138 |
@param aChar The character to be folded.
|
sl@0
|
139 |
|
sl@0
|
140 |
@return The folded character.
|
sl@0
|
141 |
|
sl@0
|
142 |
@see TChar::Fold()
|
sl@0
|
143 |
*/
|
sl@0
|
144 |
{
|
sl@0
|
145 |
// ASCII chars excluding 'i's can be handled by naive folding
|
sl@0
|
146 |
if (aChar < 0x80 && aChar != 'I')
|
sl@0
|
147 |
return (aChar >= 'A' && aChar <= 'Z') ? (aChar | 0x0020) : aChar;
|
sl@0
|
148 |
else
|
sl@0
|
149 |
return TUnicode(aChar).Fold(TChar::EFoldStandard,GetLocaleCharSet()->iCharDataSet);
|
sl@0
|
150 |
}
|
sl@0
|
151 |
|
sl@0
|
152 |
|
sl@0
|
153 |
|
sl@0
|
154 |
|
sl@0
|
155 |
// Convert to a folded version, specifying the folding methods.
|
sl@0
|
156 |
EXPORT_C TUint User::Fold(TUint aChar,TInt aFlags)
|
sl@0
|
157 |
/**
|
sl@0
|
158 |
Folds the character according to a specified folding method.
|
sl@0
|
159 |
|
sl@0
|
160 |
@param aChar The character to be folded.
|
sl@0
|
161 |
@param aFlags A set of flags defining the folding method. They are:
|
sl@0
|
162 |
|
sl@0
|
163 |
TChar::EFoldCase, convert characters to their lower case form,
|
sl@0
|
164 |
if any;
|
sl@0
|
165 |
|
sl@0
|
166 |
TChar::EFoldAccents, strip accents;
|
sl@0
|
167 |
|
sl@0
|
168 |
TChar::EFoldDigits, convert digits representing values 0..9 to
|
sl@0
|
169 |
characters '0'..'9';
|
sl@0
|
170 |
|
sl@0
|
171 |
TChar::EFoldSpaces, convert all spaces (ordinary, fixed-width,
|
sl@0
|
172 |
ideographic, etc.) to ' ';
|
sl@0
|
173 |
|
sl@0
|
174 |
TChar::EFoldKana, convert hiragana to katakana;
|
sl@0
|
175 |
|
sl@0
|
176 |
TChar::EFoldWidth, fold full width and half width variants to
|
sl@0
|
177 |
their standard forms;
|
sl@0
|
178 |
|
sl@0
|
179 |
TChar::EFoldAll, use all of the above folding methods.
|
sl@0
|
180 |
|
sl@0
|
181 |
@return The folded character.
|
sl@0
|
182 |
@see TChar::Fold()
|
sl@0
|
183 |
*/
|
sl@0
|
184 |
{
|
sl@0
|
185 |
return TUnicode(aChar).Fold(aFlags,GetLocaleCharSet()->iCharDataSet);
|
sl@0
|
186 |
}
|
sl@0
|
187 |
|
sl@0
|
188 |
|
sl@0
|
189 |
|
sl@0
|
190 |
|
sl@0
|
191 |
// Convert to collated.
|
sl@0
|
192 |
EXPORT_C TUint User::Collate(TUint aChar)
|
sl@0
|
193 |
/**
|
sl@0
|
194 |
Converts the character to its collated form.
|
sl@0
|
195 |
|
sl@0
|
196 |
Collating is the process of removing differences between characters that are
|
sl@0
|
197 |
deemed unimportant for the purposes of ordering characters. The result of
|
sl@0
|
198 |
the conversion depends on the locale and on whether this is a UNICODE build
|
sl@0
|
199 |
or not.
|
sl@0
|
200 |
|
sl@0
|
201 |
Note that for a non UNICODE build, if the binary value of the character aChar
|
sl@0
|
202 |
is greater than or equal to 0x100, then the character returned is the same as
|
sl@0
|
203 |
the character passed to the function.
|
sl@0
|
204 |
|
sl@0
|
205 |
@param aChar The character to be folded.
|
sl@0
|
206 |
|
sl@0
|
207 |
@return The converted character.
|
sl@0
|
208 |
*/
|
sl@0
|
209 |
{
|
sl@0
|
210 |
return TUnicode(aChar).Fold(TChar::EFoldStandard,GetLocaleCharSet()->iCharDataSet);
|
sl@0
|
211 |
}
|
sl@0
|
212 |
|
sl@0
|
213 |
|
sl@0
|
214 |
|
sl@0
|
215 |
|
sl@0
|
216 |
// Convert to lower case.
|
sl@0
|
217 |
EXPORT_C TUint User::LowerCase(TUint aChar)
|
sl@0
|
218 |
/**
|
sl@0
|
219 |
Converts the specified character to lower case.
|
sl@0
|
220 |
|
sl@0
|
221 |
The result of the conversion depends on the locale and on whether this is
|
sl@0
|
222 |
a UNICODE build or not.
|
sl@0
|
223 |
|
sl@0
|
224 |
Note that for a non-UNICODE build, if the binary value of the character
|
sl@0
|
225 |
aChar is greater than or equal to 0x100, then the character returned is
|
sl@0
|
226 |
the same as the character passed to the function.
|
sl@0
|
227 |
|
sl@0
|
228 |
@param aChar The character to be converted to lower case.
|
sl@0
|
229 |
|
sl@0
|
230 |
@return The lower case character.
|
sl@0
|
231 |
*/
|
sl@0
|
232 |
{
|
sl@0
|
233 |
// ASCII chars excluding 'i's can be handled by naive folding
|
sl@0
|
234 |
if (aChar < 0x80 && aChar != 'I')
|
sl@0
|
235 |
return (aChar >= 'A' && aChar <= 'Z') ? (aChar | 0x0020) : aChar;
|
sl@0
|
236 |
else
|
sl@0
|
237 |
return TUnicode(aChar).GetLowerCase(GetLocaleCharSet()->iCharDataSet);
|
sl@0
|
238 |
}
|
sl@0
|
239 |
|
sl@0
|
240 |
|
sl@0
|
241 |
|
sl@0
|
242 |
|
sl@0
|
243 |
// Convert to upper case.
|
sl@0
|
244 |
EXPORT_C TUint User::UpperCase(TUint aChar)
|
sl@0
|
245 |
/**
|
sl@0
|
246 |
Converts a specified character to upper case.
|
sl@0
|
247 |
|
sl@0
|
248 |
The result of the conversion depends on the locale and on whether this is
|
sl@0
|
249 |
a UNICODE build or not.
|
sl@0
|
250 |
|
sl@0
|
251 |
Note that for a non UNICODE build, if the binary value of the character aChar
|
sl@0
|
252 |
is greater than or equal to 0x100, then the character returned is the same as
|
sl@0
|
253 |
the character passed to the function.
|
sl@0
|
254 |
|
sl@0
|
255 |
@param aChar The character to be converted to upper case.
|
sl@0
|
256 |
|
sl@0
|
257 |
@return The upper case character.
|
sl@0
|
258 |
*/
|
sl@0
|
259 |
{
|
sl@0
|
260 |
// ASCII chars excluding 'i's can be handled by naive folding
|
sl@0
|
261 |
if (aChar < 0x80 && aChar != 'i')
|
sl@0
|
262 |
return (aChar >= 'a' && aChar <= 'z') ? (aChar & ~0x0020) : aChar;
|
sl@0
|
263 |
else
|
sl@0
|
264 |
return TUnicode(aChar).GetUpperCase(GetLocaleCharSet()->iCharDataSet);
|
sl@0
|
265 |
}
|
sl@0
|
266 |
|
sl@0
|
267 |
|
sl@0
|
268 |
|
sl@0
|
269 |
|
sl@0
|
270 |
// Return the title case version of a character, which is the case of composite characters like Dz.
|
sl@0
|
271 |
EXPORT_C TUint User::TitleCase(TUint aChar)
|
sl@0
|
272 |
/**
|
sl@0
|
273 |
Converts a specified character to its title case version.
|
sl@0
|
274 |
|
sl@0
|
275 |
@param aChar The character to be converted.
|
sl@0
|
276 |
|
sl@0
|
277 |
@return The converted character.
|
sl@0
|
278 |
*/
|
sl@0
|
279 |
{
|
sl@0
|
280 |
return TUnicode(aChar).GetTitleCase(GetLocaleCharSet()->iCharDataSet);
|
sl@0
|
281 |
}
|
sl@0
|
282 |
|
sl@0
|
283 |
|
sl@0
|
284 |
|
sl@0
|
285 |
|
sl@0
|
286 |
EXPORT_C TUint TChar::GetUpperCase() const
|
sl@0
|
287 |
/**
|
sl@0
|
288 |
Gets the character value after conversion to uppercase or the character's
|
sl@0
|
289 |
own value, if no uppercase form exists.
|
sl@0
|
290 |
|
sl@0
|
291 |
The character object itself is not changed.
|
sl@0
|
292 |
|
sl@0
|
293 |
@return The character value after conversion to uppercase.
|
sl@0
|
294 |
*/
|
sl@0
|
295 |
{
|
sl@0
|
296 |
return User::UpperCase(iChar);
|
sl@0
|
297 |
}
|
sl@0
|
298 |
|
sl@0
|
299 |
|
sl@0
|
300 |
|
sl@0
|
301 |
|
sl@0
|
302 |
EXPORT_C TUint TChar::GetLowerCase() const
|
sl@0
|
303 |
/**
|
sl@0
|
304 |
Gets the character value after conversion to lowercase or the character's
|
sl@0
|
305 |
own value, if no lowercase form exists.
|
sl@0
|
306 |
|
sl@0
|
307 |
The character object itself is not changed.
|
sl@0
|
308 |
|
sl@0
|
309 |
@return The character value after conversion to lowercase.
|
sl@0
|
310 |
*/
|
sl@0
|
311 |
{
|
sl@0
|
312 |
return User::LowerCase(iChar);
|
sl@0
|
313 |
}
|
sl@0
|
314 |
|
sl@0
|
315 |
|
sl@0
|
316 |
|
sl@0
|
317 |
|
sl@0
|
318 |
EXPORT_C TUint TChar::GetTitleCase() const
|
sl@0
|
319 |
/**
|
sl@0
|
320 |
Gets the character value after conversion to titlecase or the character's
|
sl@0
|
321 |
own value, if no titlecase form exists.
|
sl@0
|
322 |
|
sl@0
|
323 |
The titlecase form of a character is identical to its uppercase form unless
|
sl@0
|
324 |
a specific titlecase form exists.
|
sl@0
|
325 |
|
sl@0
|
326 |
@return The value of the character value after conversion to titlecase form.
|
sl@0
|
327 |
*/
|
sl@0
|
328 |
{
|
sl@0
|
329 |
return User::TitleCase(iChar);
|
sl@0
|
330 |
}
|
sl@0
|
331 |
|
sl@0
|
332 |
|
sl@0
|
333 |
|
sl@0
|
334 |
|
sl@0
|
335 |
EXPORT_C TBool TChar::IsLower() const
|
sl@0
|
336 |
/**
|
sl@0
|
337 |
Tests whether the character is lowercase.
|
sl@0
|
338 |
|
sl@0
|
339 |
@return True, if the character is lowercase; false, otherwise.
|
sl@0
|
340 |
*/
|
sl@0
|
341 |
{
|
sl@0
|
342 |
return GetCategory() == TChar::ELlCategory;
|
sl@0
|
343 |
}
|
sl@0
|
344 |
|
sl@0
|
345 |
|
sl@0
|
346 |
|
sl@0
|
347 |
|
sl@0
|
348 |
EXPORT_C TBool TChar::IsUpper() const
|
sl@0
|
349 |
/**
|
sl@0
|
350 |
Tests whether the character is uppercase.
|
sl@0
|
351 |
|
sl@0
|
352 |
@return True, if the character is uppercase; false, otherwise.
|
sl@0
|
353 |
*/
|
sl@0
|
354 |
{
|
sl@0
|
355 |
return GetCategory() == TChar::ELuCategory;
|
sl@0
|
356 |
}
|
sl@0
|
357 |
|
sl@0
|
358 |
|
sl@0
|
359 |
|
sl@0
|
360 |
// Return TRUE if the character is title case, which is the case of composite characters like Dz.
|
sl@0
|
361 |
EXPORT_C TBool TChar::IsTitle() const
|
sl@0
|
362 |
/**
|
sl@0
|
363 |
Tests whether this character is in titlecase.
|
sl@0
|
364 |
|
sl@0
|
365 |
@return True, if this character is in titlecase; false, otherwise.
|
sl@0
|
366 |
*/
|
sl@0
|
367 |
{
|
sl@0
|
368 |
return GetCategory() == TChar::ELtCategory;
|
sl@0
|
369 |
}
|
sl@0
|
370 |
|
sl@0
|
371 |
|
sl@0
|
372 |
|
sl@0
|
373 |
|
sl@0
|
374 |
EXPORT_C TBool TChar::IsAlpha() const
|
sl@0
|
375 |
/**
|
sl@0
|
376 |
Tests whether the character is alphabetic.
|
sl@0
|
377 |
|
sl@0
|
378 |
For Unicode, the function returns TRUE for all letters, including those from
|
sl@0
|
379 |
syllabaries and ideographic scripts. The function returns FALSE for letter-like
|
sl@0
|
380 |
characters that are in fact diacritics. Specifically, the function returns
|
sl@0
|
381 |
TRUE for categories: ELuCategory, ELtCategory, ELlCategory, and ELoCategory;
|
sl@0
|
382 |
it returns FALSE for all other categories including ELmCategory.
|
sl@0
|
383 |
|
sl@0
|
384 |
@return True, if the character is alphabetic; false, otherwise.
|
sl@0
|
385 |
|
sl@0
|
386 |
@see TChar::IsAlphaDigit()
|
sl@0
|
387 |
@see TChar::TCategory
|
sl@0
|
388 |
*/
|
sl@0
|
389 |
{
|
sl@0
|
390 |
return GetCategory() <= TChar::EMaxLetterOrLetterModifierCategory;
|
sl@0
|
391 |
}
|
sl@0
|
392 |
|
sl@0
|
393 |
|
sl@0
|
394 |
|
sl@0
|
395 |
|
sl@0
|
396 |
EXPORT_C TBool TChar::IsDigit() const
|
sl@0
|
397 |
/**
|
sl@0
|
398 |
Tests whether the character is a standard decimal digit.
|
sl@0
|
399 |
|
sl@0
|
400 |
For Unicode, this function returns TRUE only
|
sl@0
|
401 |
for the digits '0'...'9' (U+0030...U+0039),
|
sl@0
|
402 |
not for other digits in scripts like Arabic, Tamil, etc.
|
sl@0
|
403 |
|
sl@0
|
404 |
@return True, if the character is a standard decimal digit; false, otherwise.
|
sl@0
|
405 |
|
sl@0
|
406 |
@see TChar::GetCategory()
|
sl@0
|
407 |
@see TChar::GetNumericValue
|
sl@0
|
408 |
*/
|
sl@0
|
409 |
{
|
sl@0
|
410 |
return iChar >= '0' && iChar <= '9'; // standard decimal digits only
|
sl@0
|
411 |
}
|
sl@0
|
412 |
|
sl@0
|
413 |
|
sl@0
|
414 |
|
sl@0
|
415 |
|
sl@0
|
416 |
EXPORT_C TBool TChar::IsAlphaDigit() const
|
sl@0
|
417 |
/**
|
sl@0
|
418 |
Tests whether the character is alphabetic or a decimal digit.
|
sl@0
|
419 |
|
sl@0
|
420 |
It is identical to (IsAlpha()||IsDigit()).
|
sl@0
|
421 |
|
sl@0
|
422 |
@return True, if the character is alphabetic or a decimal digit; false, otherwise.
|
sl@0
|
423 |
|
sl@0
|
424 |
@see TChar::IsAlpha()
|
sl@0
|
425 |
@see TChar::IsDigit()
|
sl@0
|
426 |
*/
|
sl@0
|
427 |
{
|
sl@0
|
428 |
TInt cat = (TInt)GetCategory();
|
sl@0
|
429 |
return cat <= TChar::EMaxLetterOrLetterModifierCategory ||
|
sl@0
|
430 |
(iChar < 256 && cat == TChar::ENdCategory); // accept any letter, but accept only standard digits
|
sl@0
|
431 |
}
|
sl@0
|
432 |
|
sl@0
|
433 |
|
sl@0
|
434 |
|
sl@0
|
435 |
|
sl@0
|
436 |
EXPORT_C TBool TChar::IsHexDigit() const
|
sl@0
|
437 |
/**
|
sl@0
|
438 |
Tests whether the character is a hexadecimal digit (0-9, a-f, A-F).
|
sl@0
|
439 |
|
sl@0
|
440 |
@return True, if the character is a hexadecimal digit; false, otherwise.
|
sl@0
|
441 |
*/
|
sl@0
|
442 |
{
|
sl@0
|
443 |
/*
|
sl@0
|
444 |
The following code will actually run faster than the non-Unicode version, which needs
|
sl@0
|
445 |
to call the Exec function.
|
sl@0
|
446 |
*/
|
sl@0
|
447 |
return iChar <= 'f' && iChar >= '0' &&
|
sl@0
|
448 |
(iChar <= '9' || iChar >= 'a' || (iChar >= 'A' && iChar <= 'F')); // only standard hex digits will do
|
sl@0
|
449 |
}
|
sl@0
|
450 |
|
sl@0
|
451 |
|
sl@0
|
452 |
|
sl@0
|
453 |
|
sl@0
|
454 |
EXPORT_C TBool TChar::IsSpace() const
|
sl@0
|
455 |
/**
|
sl@0
|
456 |
Tests whether the character is a white space character.
|
sl@0
|
457 |
|
sl@0
|
458 |
White space includes spaces, tabs and separators.
|
sl@0
|
459 |
|
sl@0
|
460 |
For Unicode, the function returns TRUE for all characters in the categories:
|
sl@0
|
461 |
EZsCategory, EZlCategory and EZpCategory, and also for the characters 0x0009
|
sl@0
|
462 |
(horizontal tab), 0x000A (linefeed), 0x000B (vertical tab), 0x000C (form feed),
|
sl@0
|
463 |
and 0x000D (carriage return).
|
sl@0
|
464 |
|
sl@0
|
465 |
@return True, if the character is white space; false, otherwise.
|
sl@0
|
466 |
|
sl@0
|
467 |
@see TChar::TCategory
|
sl@0
|
468 |
*/
|
sl@0
|
469 |
{
|
sl@0
|
470 |
/*
|
sl@0
|
471 |
The Unicode characters 0009 .. 000D (tab, linefeed, vertical tab, formfeed, carriage return)
|
sl@0
|
472 |
have the category Cc (control); however, we want to avoid breaking traditional programs
|
sl@0
|
473 |
by getting IsSpace() to return TRUE for them.
|
sl@0
|
474 |
*/
|
sl@0
|
475 |
return (iChar <= 0x000D && iChar >= 0x0009) ||
|
sl@0
|
476 |
(GetCategory() & 0xF0) == TChar::ESeparatorGroup;
|
sl@0
|
477 |
}
|
sl@0
|
478 |
|
sl@0
|
479 |
|
sl@0
|
480 |
|
sl@0
|
481 |
|
sl@0
|
482 |
EXPORT_C TBool TChar::IsPunctuation() const
|
sl@0
|
483 |
/**
|
sl@0
|
484 |
Tests whether the character is a punctuation character.
|
sl@0
|
485 |
|
sl@0
|
486 |
For Unicode, punctuation characters are any character in the categories:
|
sl@0
|
487 |
EPcCategory, EPdCategory, EPsCategory, EPeCategory, EPiCategory,
|
sl@0
|
488 |
EPfCategory, EPoCategory.
|
sl@0
|
489 |
|
sl@0
|
490 |
@return True, if the character is punctuation; false, otherwise.
|
sl@0
|
491 |
|
sl@0
|
492 |
@see TChar::TCategory
|
sl@0
|
493 |
*/
|
sl@0
|
494 |
{
|
sl@0
|
495 |
return (GetCategory() & 0xF0) == TChar::EPunctuationGroup;
|
sl@0
|
496 |
}
|
sl@0
|
497 |
|
sl@0
|
498 |
|
sl@0
|
499 |
|
sl@0
|
500 |
|
sl@0
|
501 |
EXPORT_C TBool TChar::IsGraph() const
|
sl@0
|
502 |
/**
|
sl@0
|
503 |
Tests whether the character is a graphic character.
|
sl@0
|
504 |
|
sl@0
|
505 |
For Unicode, graphic characters include printable characters but not the space
|
sl@0
|
506 |
character. Specifically, graphic characters are any character except those
|
sl@0
|
507 |
in categories: EZsCategory,EZlCategory,EZpCategory, ECcCategory,ECfCategory,
|
sl@0
|
508 |
ECsCategory, ECoCategory, and ,ECnCategory.
|
sl@0
|
509 |
|
sl@0
|
510 |
Note that for ISO Latin-1, all alphanumeric and punctuation characters are
|
sl@0
|
511 |
graphic.
|
sl@0
|
512 |
|
sl@0
|
513 |
@return True, if the character is a graphic character; false, otherwise.
|
sl@0
|
514 |
|
sl@0
|
515 |
@see TChar::TCategory
|
sl@0
|
516 |
*/
|
sl@0
|
517 |
{
|
sl@0
|
518 |
TUint type = TUnicode(iChar).GetCategory(0);
|
sl@0
|
519 |
return type <= TChar::EMaxGraphicCategory ||
|
sl@0
|
520 |
(type == TChar::ECoCategory && IsPUAPrintable(iChar));
|
sl@0
|
521 |
}
|
sl@0
|
522 |
|
sl@0
|
523 |
|
sl@0
|
524 |
|
sl@0
|
525 |
|
sl@0
|
526 |
EXPORT_C TBool TChar::IsPrint() const
|
sl@0
|
527 |
/**
|
sl@0
|
528 |
Tests whether the character is a printable character.
|
sl@0
|
529 |
|
sl@0
|
530 |
For Unicode, printable characters are any character except those in categories:
|
sl@0
|
531 |
ECcCategory, ECfCategory, ECsCategory, ECoCategory and ECnCategory.
|
sl@0
|
532 |
|
sl@0
|
533 |
Note that for ISO Latin-1, all alphanumeric and punctuation characters, plus
|
sl@0
|
534 |
space, are printable.
|
sl@0
|
535 |
|
sl@0
|
536 |
@return True, if the character is printable; false, otherwise.
|
sl@0
|
537 |
|
sl@0
|
538 |
@see TChar::TCategory
|
sl@0
|
539 |
*/
|
sl@0
|
540 |
{
|
sl@0
|
541 |
TUint type = TUnicode(iChar).GetCategory(0);
|
sl@0
|
542 |
return type <= TChar::EMaxPrintableCategory ||
|
sl@0
|
543 |
(type == TChar::ECoCategory && IsPUAPrintable(iChar));
|
sl@0
|
544 |
}
|
sl@0
|
545 |
|
sl@0
|
546 |
|
sl@0
|
547 |
|
sl@0
|
548 |
|
sl@0
|
549 |
EXPORT_C TBool TChar::IsControl() const
|
sl@0
|
550 |
/**
|
sl@0
|
551 |
Tests whether the character is a control character.
|
sl@0
|
552 |
|
sl@0
|
553 |
For Unicode, the function returns TRUE for all characters in the categories:
|
sl@0
|
554 |
ECcCategory, ECfCategory, ECsCategory, ECoCategory and ECnCategoryCc.
|
sl@0
|
555 |
|
sl@0
|
556 |
@return True, if the character is a control character; false, otherwise.
|
sl@0
|
557 |
|
sl@0
|
558 |
@see TChar::TCategory
|
sl@0
|
559 |
*/
|
sl@0
|
560 |
{
|
sl@0
|
561 |
return GetCategory() == TChar::ECcCategory;
|
sl@0
|
562 |
}
|
sl@0
|
563 |
|
sl@0
|
564 |
|
sl@0
|
565 |
|
sl@0
|
566 |
|
sl@0
|
567 |
EXPORT_C TBool TChar::IsAssigned() const
|
sl@0
|
568 |
/**
|
sl@0
|
569 |
Tests whether this character has an assigned meaning in the Unicode encoding.
|
sl@0
|
570 |
|
sl@0
|
571 |
All characters outside the range 0x0000 - 0xFFFF are unassigned and there
|
sl@0
|
572 |
are also many unassigned characters within the Unicode range.
|
sl@0
|
573 |
|
sl@0
|
574 |
Locales can change the assigned/unassigned status of characters. This means
|
sl@0
|
575 |
that the precise behaviour of this function is locale-dependent.
|
sl@0
|
576 |
|
sl@0
|
577 |
@return True, if this character has an assigned meaning; false, otherwise.
|
sl@0
|
578 |
*/
|
sl@0
|
579 |
{
|
sl@0
|
580 |
return GetCategory() <= TChar::EMaxAssignedCategory;
|
sl@0
|
581 |
}
|
sl@0
|
582 |
|
sl@0
|
583 |
|
sl@0
|
584 |
|
sl@0
|
585 |
|
sl@0
|
586 |
EXPORT_C void TChar::GetInfo(TCharInfo& aInfo) const
|
sl@0
|
587 |
/**
|
sl@0
|
588 |
Gets this character;s standard category information.
|
sl@0
|
589 |
|
sl@0
|
590 |
This includes everything except its CJK width and decomposition, if any.
|
sl@0
|
591 |
|
sl@0
|
592 |
@param aInfo On return, contains the character's standard category information.
|
sl@0
|
593 |
*/
|
sl@0
|
594 |
{
|
sl@0
|
595 |
TUnicode(iChar).GetInfo(aInfo,GetLocaleCharSet()->iCharDataSet);
|
sl@0
|
596 |
}
|
sl@0
|
597 |
|
sl@0
|
598 |
|
sl@0
|
599 |
|
sl@0
|
600 |
|
sl@0
|
601 |
EXPORT_C TChar::TCategory TChar::GetCategory() const
|
sl@0
|
602 |
/**
|
sl@0
|
603 |
Gets this character's Unicode category.
|
sl@0
|
604 |
|
sl@0
|
605 |
@return This character's Unicode category.
|
sl@0
|
606 |
*/
|
sl@0
|
607 |
{
|
sl@0
|
608 |
//for unicode non private user area just use the default charset
|
sl@0
|
609 |
if (iChar>=0xE000 && iChar<=0xF8FF)
|
sl@0
|
610 |
return TUnicode(iChar).GetCategory(GetLocaleCharSet()->iCharDataSet);
|
sl@0
|
611 |
else
|
sl@0
|
612 |
return TUnicode(iChar).GetCategory(GetLocaleDefaultCharSet()->iCharDataSet);
|
sl@0
|
613 |
}
|
sl@0
|
614 |
|
sl@0
|
615 |
|
sl@0
|
616 |
|
sl@0
|
617 |
|
sl@0
|
618 |
EXPORT_C TChar::TBdCategory TChar::GetBdCategory() const
|
sl@0
|
619 |
/**
|
sl@0
|
620 |
Gets the bi-directional category of a character.
|
sl@0
|
621 |
|
sl@0
|
622 |
For more information on the bi-directional algorithm, see Unicode Technical
|
sl@0
|
623 |
Report No. 9 available at: http://www.unicode.org/unicode/reports/tr9/.
|
sl@0
|
624 |
|
sl@0
|
625 |
@return The character's bi-directional category.
|
sl@0
|
626 |
*/
|
sl@0
|
627 |
{
|
sl@0
|
628 |
return TUnicode(iChar).GetBdCategory(GetLocaleCharSet()->iCharDataSet);
|
sl@0
|
629 |
}
|
sl@0
|
630 |
|
sl@0
|
631 |
|
sl@0
|
632 |
|
sl@0
|
633 |
|
sl@0
|
634 |
EXPORT_C TInt TChar::GetCombiningClass() const
|
sl@0
|
635 |
/**
|
sl@0
|
636 |
Gets this character's combining class.
|
sl@0
|
637 |
|
sl@0
|
638 |
Note that diacritics and other combining characters have non-zero combining
|
sl@0
|
639 |
classes.
|
sl@0
|
640 |
|
sl@0
|
641 |
@return The combining class.
|
sl@0
|
642 |
*/
|
sl@0
|
643 |
{
|
sl@0
|
644 |
//for unicode non private user area just use the default charset
|
sl@0
|
645 |
if (iChar>=0xE000 && iChar<=0xF8FF)
|
sl@0
|
646 |
return TUnicode(iChar).GetCombiningClass(GetLocaleCharSet()->iCharDataSet);
|
sl@0
|
647 |
else
|
sl@0
|
648 |
return TUnicode(iChar).GetCombiningClass(GetLocaleDefaultCharSet()->iCharDataSet);
|
sl@0
|
649 |
}
|
sl@0
|
650 |
|
sl@0
|
651 |
|
sl@0
|
652 |
|
sl@0
|
653 |
|
sl@0
|
654 |
EXPORT_C TBool TChar::IsMirrored() const
|
sl@0
|
655 |
/**
|
sl@0
|
656 |
Tests whether this character has the mirrored property.
|
sl@0
|
657 |
|
sl@0
|
658 |
Mirrored characters, like ( ) [ ] < >, change direction according to the
|
sl@0
|
659 |
directionality of the surrounding characters. For example, an opening
|
sl@0
|
660 |
parenthesis 'faces right' in Hebrew or Arabic, and to say that 2 < 3 you would
|
sl@0
|
661 |
have to say that 3 > 2, where the '>' is, in this example, a less-than sign to
|
sl@0
|
662 |
be read right-to-left.
|
sl@0
|
663 |
|
sl@0
|
664 |
@return True, if this character has the mirrored property; false, otherwise.
|
sl@0
|
665 |
*/
|
sl@0
|
666 |
{
|
sl@0
|
667 |
return TUnicode(iChar).IsMirrored(GetLocaleCharSet()->iCharDataSet);
|
sl@0
|
668 |
}
|
sl@0
|
669 |
|
sl@0
|
670 |
|
sl@0
|
671 |
|
sl@0
|
672 |
|
sl@0
|
673 |
EXPORT_C TInt TChar::GetNumericValue() const
|
sl@0
|
674 |
/**
|
sl@0
|
675 |
Gets the integer numeric value of this character.
|
sl@0
|
676 |
|
sl@0
|
677 |
Numeric values need not be in the range 0..9; the Unicode character set
|
sl@0
|
678 |
includes various other numeric characters such as the Roman and Tamil numerals
|
sl@0
|
679 |
for 500, 1000, etc.
|
sl@0
|
680 |
|
sl@0
|
681 |
@return The numeric value: -1 if the character has no integer numeric
|
sl@0
|
682 |
value,-2 if the character has a fractional numeric value.
|
sl@0
|
683 |
*/
|
sl@0
|
684 |
{
|
sl@0
|
685 |
return TUnicode(iChar).GetNumericValue(GetLocaleCharSet()->iCharDataSet);
|
sl@0
|
686 |
}
|
sl@0
|
687 |
|
sl@0
|
688 |
|
sl@0
|
689 |
|
sl@0
|
690 |
|
sl@0
|
691 |
EXPORT_C TChar::TCjkWidth TChar::GetCjkWidth() const
|
sl@0
|
692 |
/**
|
sl@0
|
693 |
Gets the Chinese, Japanese, Korean (CJK) notional width.
|
sl@0
|
694 |
|
sl@0
|
695 |
Some display systems used in East Asia display characters on a grid of
|
sl@0
|
696 |
fixed-width character cells like the standard MSDOS display mode.
|
sl@0
|
697 |
|
sl@0
|
698 |
Some characters, e.g. the Japanese katakana syllabary, take up a single
|
sl@0
|
699 |
character cell and some characters, e.g., kanji, Chinese characters used in
|
sl@0
|
700 |
Japanese, take up two. These are called half-width and full-width characters.
|
sl@0
|
701 |
This property is fixed and cannot be overridden for particular locales.
|
sl@0
|
702 |
|
sl@0
|
703 |
For more information on returned widths, see Unicode Technical Report 11 on
|
sl@0
|
704 |
East Asian Width available at: http://www.unicode.org/unicode/reports/tr11/
|
sl@0
|
705 |
|
sl@0
|
706 |
@return The notional width of an east Asian character.
|
sl@0
|
707 |
*/
|
sl@0
|
708 |
{
|
sl@0
|
709 |
return TUnicode(iChar).GetCjkWidth();
|
sl@0
|
710 |
}
|
sl@0
|
711 |
|
sl@0
|
712 |
|
sl@0
|
713 |
|
sl@0
|
714 |
|
sl@0
|
715 |
/**
|
sl@0
|
716 |
Composes a string of Unicode characters to produce a single character result.
|
sl@0
|
717 |
|
sl@0
|
718 |
For example, 0061 ('a') and 030A (combining ring above) compose to give 00E5
|
sl@0
|
719 |
('a' with ring above).
|
sl@0
|
720 |
|
sl@0
|
721 |
A canonical decomposition is a relationship between a string of characters -
|
sl@0
|
722 |
usually a base character and one or more diacritics - and a composed character.
|
sl@0
|
723 |
The Unicode standard requires that compliant software treats composed
|
sl@0
|
724 |
characters identically with their canonical decompositions. The mappings used
|
sl@0
|
725 |
by these functions are fixed and cannot be overridden for particular locales.
|
sl@0
|
726 |
|
sl@0
|
727 |
@param aResult If successful, the composed character value. If unsuccessful,
|
sl@0
|
728 |
this value contains 0xFFFF.
|
sl@0
|
729 |
@param aSource String of source Unicode characters.
|
sl@0
|
730 |
|
sl@0
|
731 |
@return True, if the compose operation is successful in combining the entire
|
sl@0
|
732 |
sequence of characters in the descriptor into a single compound
|
sl@0
|
733 |
character; false, otherwise.
|
sl@0
|
734 |
*/
|
sl@0
|
735 |
|
sl@0
|
736 |
EXPORT_C TBool TChar::Compose(TUint& aResult,const TDesC16& aSource)
|
sl@0
|
737 |
{
|
sl@0
|
738 |
aResult = 0xFFFF;
|
sl@0
|
739 |
if(aSource.Length() > 0)
|
sl@0
|
740 |
{
|
sl@0
|
741 |
TChar combined;
|
sl@0
|
742 |
if(::CombineAsMuchAsPossible(aSource, combined) == aSource.Length())
|
sl@0
|
743 |
{
|
sl@0
|
744 |
aResult = (TUint)combined;
|
sl@0
|
745 |
return ETrue;
|
sl@0
|
746 |
}
|
sl@0
|
747 |
}
|
sl@0
|
748 |
return EFalse;
|
sl@0
|
749 |
}
|
sl@0
|
750 |
|
sl@0
|
751 |
|
sl@0
|
752 |
|
sl@0
|
753 |
|
sl@0
|
754 |
/**
|
sl@0
|
755 |
Maps this character to its maximal canonical decomposition.
|
sl@0
|
756 |
|
sl@0
|
757 |
For example, 01E1 ('a' with dot above and macron) decomposes into 0061 ('a')
|
sl@0
|
758 |
0307 (dot) and 0304 (macron).
|
sl@0
|
759 |
|
sl@0
|
760 |
Note that this function is used during collation, as performed by
|
sl@0
|
761 |
the Mem::CompareC() function, to convert the compared strings to their maximal
|
sl@0
|
762 |
canonical decompositions.
|
sl@0
|
763 |
|
sl@0
|
764 |
@param aResult If successful, the descriptor represents the canonical decomposition
|
sl@0
|
765 |
of this character. If unsuccessful, the descriptor is empty.
|
sl@0
|
766 |
|
sl@0
|
767 |
@return True if decomposition is successful; false, otherwise.
|
sl@0
|
768 |
|
sl@0
|
769 |
@see Mem::CompareC()
|
sl@0
|
770 |
@see TChar::Compose()
|
sl@0
|
771 |
*/
|
sl@0
|
772 |
EXPORT_C TBool TChar::Decompose(TPtrC16& aResult) const
|
sl@0
|
773 |
{
|
sl@0
|
774 |
return ::DecomposeChar(iChar, aResult);
|
sl@0
|
775 |
}
|
sl@0
|
776 |
|
sl@0
|
777 |
|
sl@0
|
778 |
|
sl@0
|
779 |
|
sl@0
|
780 |
EXPORT_C TInt TFindChunk::Next(TFullName &aResult)
|
sl@0
|
781 |
/**
|
sl@0
|
782 |
Finds the full name of the next chunk which matches the match pattern.
|
sl@0
|
783 |
|
sl@0
|
784 |
@param aResult A reference to a TBuf descriptor with a defined maximum length.
|
sl@0
|
785 |
If a matching chunk is found, its full name is set into
|
sl@0
|
786 |
this descriptor.
|
sl@0
|
787 |
If no matching chunk is found, the descriptor length is set
|
sl@0
|
788 |
to zero.
|
sl@0
|
789 |
|
sl@0
|
790 |
@return KErrNone, if a matching chunk is found;
|
sl@0
|
791 |
KErrNotFound otherwise.
|
sl@0
|
792 |
*/
|
sl@0
|
793 |
{
|
sl@0
|
794 |
return NextObject(aResult,EChunk);
|
sl@0
|
795 |
}
|
sl@0
|
796 |
|
sl@0
|
797 |
|
sl@0
|
798 |
|
sl@0
|
799 |
|
sl@0
|
800 |
|
sl@0
|
801 |
EXPORT_C TUint8 * RChunk::Base() const
|
sl@0
|
802 |
/**
|
sl@0
|
803 |
Gets a pointer to the base of the chunk's reserved region.
|
sl@0
|
804 |
|
sl@0
|
805 |
@return A pointer to the base of the chunk's reserved region.
|
sl@0
|
806 |
*/
|
sl@0
|
807 |
{
|
sl@0
|
808 |
|
sl@0
|
809 |
return(Exec::ChunkBase(iHandle));
|
sl@0
|
810 |
}
|
sl@0
|
811 |
|
sl@0
|
812 |
|
sl@0
|
813 |
|
sl@0
|
814 |
|
sl@0
|
815 |
EXPORT_C TInt RChunk::Size() const
|
sl@0
|
816 |
/**
|
sl@0
|
817 |
Gets the current size of this chunk's committed region.
|
sl@0
|
818 |
|
sl@0
|
819 |
@return The size of the chunk's committed region.
|
sl@0
|
820 |
*/
|
sl@0
|
821 |
{
|
sl@0
|
822 |
|
sl@0
|
823 |
return(Exec::ChunkSize(iHandle));
|
sl@0
|
824 |
}
|
sl@0
|
825 |
|
sl@0
|
826 |
|
sl@0
|
827 |
|
sl@0
|
828 |
|
sl@0
|
829 |
EXPORT_C TInt RChunk::Bottom() const
|
sl@0
|
830 |
/**
|
sl@0
|
831 |
Gets the offset of the bottom of the double ended chunk's committed region
|
sl@0
|
832 |
from the base of the chunk's reserved region.
|
sl@0
|
833 |
|
sl@0
|
834 |
Note that the lowest valid address in a double ended chunk is the sum of the
|
sl@0
|
835 |
base of the chunk's reserved region plus the value of Bottom().
|
sl@0
|
836 |
|
sl@0
|
837 |
@return The offset of the bottom of the chunk's committed region from the
|
sl@0
|
838 |
base of the chunk's reserved region.
|
sl@0
|
839 |
*/
|
sl@0
|
840 |
{
|
sl@0
|
841 |
|
sl@0
|
842 |
return(Exec::ChunkBottom(iHandle));
|
sl@0
|
843 |
}
|
sl@0
|
844 |
|
sl@0
|
845 |
|
sl@0
|
846 |
|
sl@0
|
847 |
|
sl@0
|
848 |
EXPORT_C TInt RChunk::Top() const
|
sl@0
|
849 |
/**
|
sl@0
|
850 |
Gets the offset of the top of the double ended chunk's committed region
|
sl@0
|
851 |
from the base of the chunk's reserved region.
|
sl@0
|
852 |
|
sl@0
|
853 |
Note that the highest valid address in a double ended chunk is the the sum
|
sl@0
|
854 |
of the base of the chunk's reserved region plus the value of Top() - 1.
|
sl@0
|
855 |
|
sl@0
|
856 |
@return The offset of the top of the chunk's committed region from the base
|
sl@0
|
857 |
of the chunk's reserved region.
|
sl@0
|
858 |
*/
|
sl@0
|
859 |
{
|
sl@0
|
860 |
|
sl@0
|
861 |
return(Exec::ChunkTop(iHandle));
|
sl@0
|
862 |
}
|
sl@0
|
863 |
|
sl@0
|
864 |
|
sl@0
|
865 |
EXPORT_C TInt RChunk::MaxSize() const
|
sl@0
|
866 |
/**
|
sl@0
|
867 |
Gets the maximum size of this chunk.
|
sl@0
|
868 |
|
sl@0
|
869 |
This maximum size of this chunk is set when the chunk is created.
|
sl@0
|
870 |
|
sl@0
|
871 |
@return The maximum size of this chunk.
|
sl@0
|
872 |
*/
|
sl@0
|
873 |
{
|
sl@0
|
874 |
|
sl@0
|
875 |
return(Exec::ChunkMaxSize(iHandle));
|
sl@0
|
876 |
}
|
sl@0
|
877 |
|
sl@0
|
878 |
/**
|
sl@0
|
879 |
Finds the full name of the next LDD factory object which matches the match pattern.
|
sl@0
|
880 |
|
sl@0
|
881 |
@param aResult A reference to a TBuf descriptor with a defined maximum length.
|
sl@0
|
882 |
If a matching LDD factory object is found, its full name is set into
|
sl@0
|
883 |
this descriptor.
|
sl@0
|
884 |
If no matching LDD factory object is found, the descriptor length is set
|
sl@0
|
885 |
to zero.
|
sl@0
|
886 |
|
sl@0
|
887 |
@return KErrNone, if a matching LDD factory object is found;
|
sl@0
|
888 |
KErrNotFound otherwise.
|
sl@0
|
889 |
*/
|
sl@0
|
890 |
EXPORT_C TInt TFindLogicalDevice::Next(TFullName &aResult)
|
sl@0
|
891 |
{
|
sl@0
|
892 |
return NextObject(aResult,ELogicalDevice);
|
sl@0
|
893 |
}
|
sl@0
|
894 |
|
sl@0
|
895 |
/**
|
sl@0
|
896 |
Finds the full name of the next PDD factory object which matches the match pattern.
|
sl@0
|
897 |
|
sl@0
|
898 |
@param aResult A reference to a TBuf descriptor with a defined maximum length.
|
sl@0
|
899 |
If a matching PDD factory object is found, its full name is set into
|
sl@0
|
900 |
this descriptor.
|
sl@0
|
901 |
If no matching PDD factory object is found, the descriptor length is set
|
sl@0
|
902 |
to zero.
|
sl@0
|
903 |
|
sl@0
|
904 |
@return KErrNone, if a matching PDD factory object is found;
|
sl@0
|
905 |
KErrNotFound otherwise.
|
sl@0
|
906 |
*/
|
sl@0
|
907 |
EXPORT_C TInt TFindPhysicalDevice::Next(TFullName &aResult)
|
sl@0
|
908 |
{
|
sl@0
|
909 |
return NextObject(aResult,EPhysicalDevice);
|
sl@0
|
910 |
}
|
sl@0
|
911 |
|
sl@0
|
912 |
/**
|
sl@0
|
913 |
Gets the device capabilities.
|
sl@0
|
914 |
|
sl@0
|
915 |
@param aDes A descriptor into which capability's information is to be written.
|
sl@0
|
916 |
*/
|
sl@0
|
917 |
EXPORT_C void RDevice::GetCaps(TDes8 &aDes) const
|
sl@0
|
918 |
{
|
sl@0
|
919 |
|
sl@0
|
920 |
Exec::LogicalDeviceGetCaps(iHandle,aDes);
|
sl@0
|
921 |
}
|
sl@0
|
922 |
|
sl@0
|
923 |
/**
|
sl@0
|
924 |
Checks if a device supports a particular version.
|
sl@0
|
925 |
|
sl@0
|
926 |
@param aVer The requested device version.
|
sl@0
|
927 |
|
sl@0
|
928 |
@return ETrue if supported, EFalse if not.
|
sl@0
|
929 |
*/
|
sl@0
|
930 |
EXPORT_C TBool RDevice::QueryVersionSupported(const TVersion &aVer) const
|
sl@0
|
931 |
{
|
sl@0
|
932 |
|
sl@0
|
933 |
return(Exec::LogicalDeviceQueryVersionSupported(iHandle,aVer));
|
sl@0
|
934 |
}
|
sl@0
|
935 |
|
sl@0
|
936 |
/**
|
sl@0
|
937 |
Checks if a specified unit number, additional info and a specific PDD is supported.
|
sl@0
|
938 |
|
sl@0
|
939 |
@param aUnit The requested unit number.
|
sl@0
|
940 |
@param aPhysicalDevice The requested PDD name.
|
sl@0
|
941 |
@param anInfo The additional information.
|
sl@0
|
942 |
|
sl@0
|
943 |
@return ETrue if supported, EFalse if not.
|
sl@0
|
944 |
*/
|
sl@0
|
945 |
EXPORT_C TBool RDevice::IsAvailable(TInt aUnit, const TDesC* aPhysicalDevice, const TDesC8* anInfo) const
|
sl@0
|
946 |
{
|
sl@0
|
947 |
TInt r;
|
sl@0
|
948 |
if(aPhysicalDevice)
|
sl@0
|
949 |
{
|
sl@0
|
950 |
TBuf8<KMaxKernelName> physicalDevice;
|
sl@0
|
951 |
physicalDevice.Copy(*aPhysicalDevice);
|
sl@0
|
952 |
r = Exec::LogicalDeviceIsAvailable(iHandle,aUnit,(TDesC8*)&physicalDevice,anInfo);
|
sl@0
|
953 |
}
|
sl@0
|
954 |
else
|
sl@0
|
955 |
r = Exec::LogicalDeviceIsAvailable(iHandle,aUnit,(TDesC8*)NULL,anInfo);
|
sl@0
|
956 |
|
sl@0
|
957 |
return r;
|
sl@0
|
958 |
}
|
sl@0
|
959 |
|
sl@0
|
960 |
|
sl@0
|
961 |
/**
|
sl@0
|
962 |
Queues an asynchronous request for the device driver, taking no parameters.
|
sl@0
|
963 |
|
sl@0
|
964 |
The request is handled on the kernel-side by the logical channel's
|
sl@0
|
965 |
DLogicalChannelBase::Request().
|
sl@0
|
966 |
|
sl@0
|
967 |
Outstanding requests can be cancelled by calling DoCancel().
|
sl@0
|
968 |
|
sl@0
|
969 |
@param aReqNo A number identifying the request to the logical channel.
|
sl@0
|
970 |
@param aStatus The request status object for this request.
|
sl@0
|
971 |
*/
|
sl@0
|
972 |
EXPORT_C void RBusLogicalChannel::DoRequest(TInt aReqNo,TRequestStatus &aStatus)
|
sl@0
|
973 |
{
|
sl@0
|
974 |
|
sl@0
|
975 |
TAny *a[2];
|
sl@0
|
976 |
a[0]=NULL;
|
sl@0
|
977 |
a[1]=NULL;
|
sl@0
|
978 |
aStatus=KRequestPending;
|
sl@0
|
979 |
Exec::ChannelRequest(iHandle,~aReqNo,&aStatus,&a[0]);
|
sl@0
|
980 |
}
|
sl@0
|
981 |
|
sl@0
|
982 |
|
sl@0
|
983 |
|
sl@0
|
984 |
|
sl@0
|
985 |
/**
|
sl@0
|
986 |
Queues an asynchronous request for the device driver, taking one parameter.
|
sl@0
|
987 |
|
sl@0
|
988 |
The request is handled on the kernel-side by the logical channel's
|
sl@0
|
989 |
DLogicalChannelBase::Request().
|
sl@0
|
990 |
|
sl@0
|
991 |
Outstanding requests can be cancelled by calling DoCancel().
|
sl@0
|
992 |
|
sl@0
|
993 |
@param aReqNo A number identifying the request to the logical channel.
|
sl@0
|
994 |
@param aStatus The request status object for this request.
|
sl@0
|
995 |
@param a1 A 32-bit value passed to the kernel-side. Its meaning depends
|
sl@0
|
996 |
on the device driver requirements.
|
sl@0
|
997 |
*/
|
sl@0
|
998 |
EXPORT_C void RBusLogicalChannel::DoRequest(TInt aReqNo,TRequestStatus &aStatus,TAny *a1)
|
sl@0
|
999 |
{
|
sl@0
|
1000 |
|
sl@0
|
1001 |
TAny *a[2];
|
sl@0
|
1002 |
a[0]=a1;
|
sl@0
|
1003 |
a[1]=NULL;
|
sl@0
|
1004 |
aStatus=KRequestPending;
|
sl@0
|
1005 |
Exec::ChannelRequest(iHandle,~aReqNo,&aStatus,&a[0]);
|
sl@0
|
1006 |
}
|
sl@0
|
1007 |
|
sl@0
|
1008 |
|
sl@0
|
1009 |
|
sl@0
|
1010 |
|
sl@0
|
1011 |
/**
|
sl@0
|
1012 |
Queues an asynchronous request for the device driver, taking two parameters.
|
sl@0
|
1013 |
|
sl@0
|
1014 |
The request is handled on the kernel-side by the logical channel's
|
sl@0
|
1015 |
DLogicalChannelBase::Request().
|
sl@0
|
1016 |
|
sl@0
|
1017 |
Outstanding requests can be cancelled by calling DoCancel().
|
sl@0
|
1018 |
|
sl@0
|
1019 |
@param aReqNo A number identifying the request to the logical channel.
|
sl@0
|
1020 |
@param aStatus The request status object for this request.
|
sl@0
|
1021 |
@param a1 A 32-bit value passed to the kernel-side. Its meaning depends
|
sl@0
|
1022 |
on the device driver requirements.
|
sl@0
|
1023 |
@param a2 A 32-bit value passed to the kernel-side. Its meaning depends
|
sl@0
|
1024 |
on the device driver requirements.
|
sl@0
|
1025 |
*/
|
sl@0
|
1026 |
EXPORT_C void RBusLogicalChannel::DoRequest(TInt aReqNo,TRequestStatus &aStatus,TAny *a1,TAny *a2)
|
sl@0
|
1027 |
{
|
sl@0
|
1028 |
|
sl@0
|
1029 |
TAny *a[2];
|
sl@0
|
1030 |
a[0]=a1;
|
sl@0
|
1031 |
a[1]=a2;
|
sl@0
|
1032 |
aStatus=KRequestPending;
|
sl@0
|
1033 |
Exec::ChannelRequest(iHandle,~aReqNo,&aStatus,&a[0]);
|
sl@0
|
1034 |
}
|
sl@0
|
1035 |
|
sl@0
|
1036 |
|
sl@0
|
1037 |
|
sl@0
|
1038 |
|
sl@0
|
1039 |
/**
|
sl@0
|
1040 |
Cancels one or more outstanding asynchronous requests.
|
sl@0
|
1041 |
|
sl@0
|
1042 |
All outstanding requests complete with KErrCancel.
|
sl@0
|
1043 |
|
sl@0
|
1044 |
@param aRequestMask A set of bits identifying the requests to be cancelled.
|
sl@0
|
1045 |
Each bit can be used to identify a separate outstanding
|
sl@0
|
1046 |
request. It is up to the driver to define how the bits map
|
sl@0
|
1047 |
to those outstanding requests.
|
sl@0
|
1048 |
*/
|
sl@0
|
1049 |
EXPORT_C void RBusLogicalChannel::DoCancel(TUint aRequestMask)
|
sl@0
|
1050 |
{
|
sl@0
|
1051 |
|
sl@0
|
1052 |
Exec::ChannelRequest(iHandle,KMaxTInt,(TAny*)aRequestMask,0);
|
sl@0
|
1053 |
}
|
sl@0
|
1054 |
|
sl@0
|
1055 |
|
sl@0
|
1056 |
|
sl@0
|
1057 |
|
sl@0
|
1058 |
/**
|
sl@0
|
1059 |
Makes a synchronous request to the device driver, taking no parameters.
|
sl@0
|
1060 |
|
sl@0
|
1061 |
This function does not return until the request has completed, successfully
|
sl@0
|
1062 |
or otherwise.
|
sl@0
|
1063 |
|
sl@0
|
1064 |
@param aFunction A number identifying the request.
|
sl@0
|
1065 |
|
sl@0
|
1066 |
@return KErrNone, if successful; otherwise one of the other system-wide
|
sl@0
|
1067 |
error codes.
|
sl@0
|
1068 |
The value returned depends on the implementation of the device driver.
|
sl@0
|
1069 |
*/
|
sl@0
|
1070 |
EXPORT_C TInt RBusLogicalChannel::DoControl(TInt aFunction)
|
sl@0
|
1071 |
{
|
sl@0
|
1072 |
|
sl@0
|
1073 |
return Exec::ChannelRequest(iHandle,aFunction,NULL,NULL);
|
sl@0
|
1074 |
}
|
sl@0
|
1075 |
|
sl@0
|
1076 |
|
sl@0
|
1077 |
|
sl@0
|
1078 |
|
sl@0
|
1079 |
/**
|
sl@0
|
1080 |
Makes a synchronous request to the device driver, taking one parameter.
|
sl@0
|
1081 |
|
sl@0
|
1082 |
This function does not return until the request has completed, successfully
|
sl@0
|
1083 |
or otherwise.
|
sl@0
|
1084 |
|
sl@0
|
1085 |
@param aFunction A number identifying the request.
|
sl@0
|
1086 |
@param a1 A 32-bit value passed to the kernel-side. Its meaning depends
|
sl@0
|
1087 |
on the device driver requirements.
|
sl@0
|
1088 |
|
sl@0
|
1089 |
@return KErrNone, if successful; otherwise one of the other system-wide
|
sl@0
|
1090 |
error codes.
|
sl@0
|
1091 |
The value returned depends on the implementation of the device driver.
|
sl@0
|
1092 |
*/
|
sl@0
|
1093 |
EXPORT_C TInt RBusLogicalChannel::DoControl(TInt aFunction,TAny *a1)
|
sl@0
|
1094 |
{
|
sl@0
|
1095 |
|
sl@0
|
1096 |
return Exec::ChannelRequest(iHandle,aFunction,a1,NULL);
|
sl@0
|
1097 |
}
|
sl@0
|
1098 |
|
sl@0
|
1099 |
|
sl@0
|
1100 |
|
sl@0
|
1101 |
|
sl@0
|
1102 |
/**
|
sl@0
|
1103 |
Makes a synchronous request to the device driver, taking two parameters.
|
sl@0
|
1104 |
|
sl@0
|
1105 |
This function does not return until the request has completed, successfully
|
sl@0
|
1106 |
or otherwise.
|
sl@0
|
1107 |
|
sl@0
|
1108 |
@param aFunction A number identifying the request.
|
sl@0
|
1109 |
@param a1 A 32-bit value passed to the kernel-side. Its meaning depends
|
sl@0
|
1110 |
on the device driver requirements.
|
sl@0
|
1111 |
@param a2 A 32-bit value passed to the kernel-side. Its meaning depends
|
sl@0
|
1112 |
on the device driver requirements.
|
sl@0
|
1113 |
|
sl@0
|
1114 |
@return KErrNone, if successful; otherwise one of the other system-wide
|
sl@0
|
1115 |
error codes.
|
sl@0
|
1116 |
The value returned depends on the implementation of the device driver.
|
sl@0
|
1117 |
*/
|
sl@0
|
1118 |
EXPORT_C TInt RBusLogicalChannel::DoControl(TInt aFunction,TAny *a1,TAny *a2)
|
sl@0
|
1119 |
{
|
sl@0
|
1120 |
|
sl@0
|
1121 |
return Exec::ChannelRequest(iHandle,aFunction,a1,a2);
|
sl@0
|
1122 |
}
|
sl@0
|
1123 |
|
sl@0
|
1124 |
|
sl@0
|
1125 |
|
sl@0
|
1126 |
|
sl@0
|
1127 |
EXPORT_C void User::WaitForAnyRequest()
|
sl@0
|
1128 |
/**
|
sl@0
|
1129 |
Waits for any asynchronous request to complete.
|
sl@0
|
1130 |
|
sl@0
|
1131 |
The current thread waits on its request semaphore.
|
sl@0
|
1132 |
|
sl@0
|
1133 |
The function completes, and control returns to the caller when the current
|
sl@0
|
1134 |
thread's request semaphore is signalled by any of the service providers which
|
sl@0
|
1135 |
handle these asynchronous requests.
|
sl@0
|
1136 |
|
sl@0
|
1137 |
The request status of all outstanding asynchronous requests must be examined
|
sl@0
|
1138 |
to determine which request is complete.
|
sl@0
|
1139 |
|
sl@0
|
1140 |
@see TRequestStatus
|
sl@0
|
1141 |
*/
|
sl@0
|
1142 |
{
|
sl@0
|
1143 |
|
sl@0
|
1144 |
Exec::WaitForAnyRequest();
|
sl@0
|
1145 |
}
|
sl@0
|
1146 |
|
sl@0
|
1147 |
|
sl@0
|
1148 |
|
sl@0
|
1149 |
|
sl@0
|
1150 |
EXPORT_C void User::WaitForRequest(TRequestStatus &aStatus)
|
sl@0
|
1151 |
/**
|
sl@0
|
1152 |
Waits for a specific asynchronous request to complete.
|
sl@0
|
1153 |
|
sl@0
|
1154 |
The current thread waits on its request semaphore.
|
sl@0
|
1155 |
|
sl@0
|
1156 |
The function completes and control returns to the caller when the current
|
sl@0
|
1157 |
thread's request semaphore is signalled by the service provider handling the
|
sl@0
|
1158 |
request associated with aStatus. Before signalling, the service provider sets
|
sl@0
|
1159 |
an appropriate value in aStatus, other than KRequestPending.
|
sl@0
|
1160 |
|
sl@0
|
1161 |
Note that if other asynchronous requests complete before the one associated
|
sl@0
|
1162 |
with aStatus, the request semaphore is adjusted so that knowledge of their
|
sl@0
|
1163 |
completion is not lost. In this a case, a subsequent call to
|
sl@0
|
1164 |
User::WaitForAnyRequest() or User::WaitForRequest() will complete and return
|
sl@0
|
1165 |
immediately.
|
sl@0
|
1166 |
|
sl@0
|
1167 |
@param aStatus A reference to the request status object associated with the
|
sl@0
|
1168 |
specific asynchronous request.
|
sl@0
|
1169 |
|
sl@0
|
1170 |
@see KRequestPending
|
sl@0
|
1171 |
*/
|
sl@0
|
1172 |
{
|
sl@0
|
1173 |
|
sl@0
|
1174 |
TInt i=(-1);
|
sl@0
|
1175 |
do
|
sl@0
|
1176 |
{
|
sl@0
|
1177 |
i++;
|
sl@0
|
1178 |
Exec::WaitForAnyRequest();
|
sl@0
|
1179 |
} while (aStatus==KRequestPending);
|
sl@0
|
1180 |
if (i)
|
sl@0
|
1181 |
Exec::RequestSignal(i);
|
sl@0
|
1182 |
}
|
sl@0
|
1183 |
|
sl@0
|
1184 |
|
sl@0
|
1185 |
|
sl@0
|
1186 |
|
sl@0
|
1187 |
EXPORT_C void User::WaitForRequest(TRequestStatus &aStatus1,TRequestStatus &aStatus2)
|
sl@0
|
1188 |
/**
|
sl@0
|
1189 |
Waits for either of two specific asynchronous requests to complete.
|
sl@0
|
1190 |
|
sl@0
|
1191 |
The current thread waits on its request semaphore.
|
sl@0
|
1192 |
|
sl@0
|
1193 |
The function completes and control returns to the caller when the current
|
sl@0
|
1194 |
thread's request semaphore is signalled by either the service provider handling
|
sl@0
|
1195 |
the request associated with aStatus1 or the service provider handling the
|
sl@0
|
1196 |
request associated with aStatus2. Before signalling, the completing service
|
sl@0
|
1197 |
provider sets an appropriate value in the status object, other
|
sl@0
|
1198 |
than KRequestPending.
|
sl@0
|
1199 |
|
sl@0
|
1200 |
Note that if other asynchronous requests complete before the ones associated
|
sl@0
|
1201 |
with aStatus1 and aStatus2, the request semaphore is adjusted so that knowledge
|
sl@0
|
1202 |
of their completion is not lost. In this a case, a subsequent call to
|
sl@0
|
1203 |
User::WaitForAnyRequest() or User::WaitForRequest() will complete and return
|
sl@0
|
1204 |
immediately.
|
sl@0
|
1205 |
|
sl@0
|
1206 |
@param aStatus1 A reference to the request status object associated with the
|
sl@0
|
1207 |
first specific asynchronous request.
|
sl@0
|
1208 |
@param aStatus2 A reference to the request status object associated with the
|
sl@0
|
1209 |
second specific asynchronous request.
|
sl@0
|
1210 |
|
sl@0
|
1211 |
@see KRequestPending
|
sl@0
|
1212 |
*/
|
sl@0
|
1213 |
{
|
sl@0
|
1214 |
|
sl@0
|
1215 |
TInt i=(-1);
|
sl@0
|
1216 |
do
|
sl@0
|
1217 |
{
|
sl@0
|
1218 |
i++;
|
sl@0
|
1219 |
Exec::WaitForAnyRequest();
|
sl@0
|
1220 |
} while (aStatus1==KRequestPending && aStatus2==KRequestPending);
|
sl@0
|
1221 |
if (i)
|
sl@0
|
1222 |
Exec::RequestSignal(i);
|
sl@0
|
1223 |
}
|
sl@0
|
1224 |
|
sl@0
|
1225 |
|
sl@0
|
1226 |
|
sl@0
|
1227 |
|
sl@0
|
1228 |
EXPORT_C void User::WaitForNRequest(TRequestStatus * aStatusArray[], TInt aNum)
|
sl@0
|
1229 |
/**
|
sl@0
|
1230 |
Waits for any one of specific asynchronous requests to complete.
|
sl@0
|
1231 |
|
sl@0
|
1232 |
The current thread waits on its request semaphore.
|
sl@0
|
1233 |
|
sl@0
|
1234 |
The function completes and control returns to the caller when the current
|
sl@0
|
1235 |
thread's request semaphore is signalled by the service provider handling
|
sl@0
|
1236 |
the request associated with any member of aStatusArray[]. Before signalling,
|
sl@0
|
1237 |
the completing service provider sets an appropriate value in the status object,
|
sl@0
|
1238 |
other than KRequestPending.
|
sl@0
|
1239 |
|
sl@0
|
1240 |
Note that if other asynchronous requests complete before the ones associated
|
sl@0
|
1241 |
with aStatusArray the request semaphore is adjusted so that knowledge
|
sl@0
|
1242 |
of their completion is not lost. In this a case, a subsequent call to
|
sl@0
|
1243 |
User::WaitForAnyRequest() or User::WaitForRequest() will complete and return
|
sl@0
|
1244 |
immediately.
|
sl@0
|
1245 |
@param aStatusArray[] An array of pointers to the request status objects
|
sl@0
|
1246 |
@param TInt aNum The size of aStatusArray[]
|
sl@0
|
1247 |
*/
|
sl@0
|
1248 |
{
|
sl@0
|
1249 |
TRequestStatus* aptr;
|
sl@0
|
1250 |
TBool m = ETrue;
|
sl@0
|
1251 |
TInt i = (-1);
|
sl@0
|
1252 |
do
|
sl@0
|
1253 |
{
|
sl@0
|
1254 |
i++;
|
sl@0
|
1255 |
Exec::WaitForAnyRequest();
|
sl@0
|
1256 |
for(TInt j = 0; j<aNum; j++)
|
sl@0
|
1257 |
{
|
sl@0
|
1258 |
aptr = aStatusArray[j];
|
sl@0
|
1259 |
if(aptr)
|
sl@0
|
1260 |
{
|
sl@0
|
1261 |
if(aptr->Int()!= KRequestPending)
|
sl@0
|
1262 |
{
|
sl@0
|
1263 |
m = EFalse;
|
sl@0
|
1264 |
break;
|
sl@0
|
1265 |
}
|
sl@0
|
1266 |
}
|
sl@0
|
1267 |
}
|
sl@0
|
1268 |
}while(m);
|
sl@0
|
1269 |
if(i)
|
sl@0
|
1270 |
Exec::RequestSignal(i);
|
sl@0
|
1271 |
}
|
sl@0
|
1272 |
|
sl@0
|
1273 |
|
sl@0
|
1274 |
|
sl@0
|
1275 |
|
sl@0
|
1276 |
EXPORT_C TInt TFindLibrary::Next(TFullName &aResult)
|
sl@0
|
1277 |
/**
|
sl@0
|
1278 |
Finds the next DLL whose full name matches the match pattern.
|
sl@0
|
1279 |
|
sl@0
|
1280 |
If a DLL with a matching name is found, the function copies the full name of
|
sl@0
|
1281 |
the DLL into the descriptor aResult.
|
sl@0
|
1282 |
|
sl@0
|
1283 |
@param aResult A buffer for the fullname of the DLL. This is a template
|
sl@0
|
1284 |
specialisation of TBuf defining a modifiable buffer descriptor
|
sl@0
|
1285 |
taking a maximum length of KMaxFullName.
|
sl@0
|
1286 |
If no matching DLL is found, the descriptor length is
|
sl@0
|
1287 |
set to zero.
|
sl@0
|
1288 |
|
sl@0
|
1289 |
@return KErrNone, if a matching DLL is found;
|
sl@0
|
1290 |
KErrNotFound, otherwise.
|
sl@0
|
1291 |
*/
|
sl@0
|
1292 |
{
|
sl@0
|
1293 |
return NextObject(aResult,ELibrary);
|
sl@0
|
1294 |
}
|
sl@0
|
1295 |
|
sl@0
|
1296 |
|
sl@0
|
1297 |
|
sl@0
|
1298 |
|
sl@0
|
1299 |
EXPORT_C TLibraryFunction RLibrary::Lookup(TInt anOrdinal) const
|
sl@0
|
1300 |
/**
|
sl@0
|
1301 |
Gets a pointer to the function at the specified ordinal within this DLL.
|
sl@0
|
1302 |
|
sl@0
|
1303 |
@param anOrdinal The ordinal of the required function in this DLL.
|
sl@0
|
1304 |
This value must be positive.
|
sl@0
|
1305 |
|
sl@0
|
1306 |
@return A pointer to the function at position anOrdinal in this DLL.
|
sl@0
|
1307 |
The value is NULL if there is no function at that ordinal.
|
sl@0
|
1308 |
|
sl@0
|
1309 |
@panic USER 116 if anOrdinal is negative
|
sl@0
|
1310 |
*/
|
sl@0
|
1311 |
{
|
sl@0
|
1312 |
__ASSERT_ALWAYS(anOrdinal>=0,Panic(EBadLookupOrdinal));
|
sl@0
|
1313 |
return (Exec::LibraryLookup(iHandle,anOrdinal));
|
sl@0
|
1314 |
}
|
sl@0
|
1315 |
|
sl@0
|
1316 |
|
sl@0
|
1317 |
|
sl@0
|
1318 |
EXPORT_C TFileName RLibrary::FileName() const
|
sl@0
|
1319 |
/**
|
sl@0
|
1320 |
Gets the name of the DLL's file.
|
sl@0
|
1321 |
|
sl@0
|
1322 |
@return The DLL's filname.
|
sl@0
|
1323 |
*/
|
sl@0
|
1324 |
{
|
sl@0
|
1325 |
|
sl@0
|
1326 |
TFileName n;
|
sl@0
|
1327 |
TPtr8 n8(((TUint8*)n.Ptr()) + KMaxFileName, KMaxFileName);
|
sl@0
|
1328 |
Exec::LibraryFileName(iHandle,n8);
|
sl@0
|
1329 |
n.Copy(n8);
|
sl@0
|
1330 |
return(n);
|
sl@0
|
1331 |
}
|
sl@0
|
1332 |
|
sl@0
|
1333 |
|
sl@0
|
1334 |
|
sl@0
|
1335 |
|
sl@0
|
1336 |
EXPORT_C TUidType RLibrary::Type() const
|
sl@0
|
1337 |
/**
|
sl@0
|
1338 |
Gets this DLL's UID type.
|
sl@0
|
1339 |
|
sl@0
|
1340 |
The UID type is a property of a Symbian OS file; for a DLL, its value is set
|
sl@0
|
1341 |
during the building of that DLL.
|
sl@0
|
1342 |
|
sl@0
|
1343 |
@return The UID type of this DLL. Note that the first TUid component of
|
sl@0
|
1344 |
the TUidType has the value KDynamicLibraryUid.
|
sl@0
|
1345 |
*/
|
sl@0
|
1346 |
{
|
sl@0
|
1347 |
|
sl@0
|
1348 |
TUidType u;
|
sl@0
|
1349 |
Exec::LibraryType(iHandle,u);
|
sl@0
|
1350 |
return(u);
|
sl@0
|
1351 |
}
|
sl@0
|
1352 |
|
sl@0
|
1353 |
|
sl@0
|
1354 |
|
sl@0
|
1355 |
|
sl@0
|
1356 |
EXPORT_C TInt RLibrary::GetRamSizes(TInt& aCodeSize, TInt& aConstDataSize)
|
sl@0
|
1357 |
/**
|
sl@0
|
1358 |
Gets the current size of the code and the const data for this DLL.
|
sl@0
|
1359 |
|
sl@0
|
1360 |
This function can be called on a RAM loaded DLL or a ROM based DLL.
|
sl@0
|
1361 |
|
sl@0
|
1362 |
@param aCodeSize The current size of the code for a RAM loaded DLL.
|
sl@0
|
1363 |
This is zero for a ROM based DLL.
|
sl@0
|
1364 |
|
sl@0
|
1365 |
@param aConstDataSize The current size of the const data for a RAM loaded DLL.
|
sl@0
|
1366 |
This is zero for a ROM based DLL.
|
sl@0
|
1367 |
|
sl@0
|
1368 |
@return KErrNone if successful, otherwise one of the system-wide error codes.
|
sl@0
|
1369 |
*/
|
sl@0
|
1370 |
{
|
sl@0
|
1371 |
TModuleMemoryInfo info;
|
sl@0
|
1372 |
TInt r=Exec::LibraryGetMemoryInfo(iHandle,info);
|
sl@0
|
1373 |
if (r==KErrNone)
|
sl@0
|
1374 |
{
|
sl@0
|
1375 |
aCodeSize=info.iCodeSize;
|
sl@0
|
1376 |
aConstDataSize=info.iConstDataSize;
|
sl@0
|
1377 |
}
|
sl@0
|
1378 |
return r;
|
sl@0
|
1379 |
}
|
sl@0
|
1380 |
|
sl@0
|
1381 |
|
sl@0
|
1382 |
|
sl@0
|
1383 |
|
sl@0
|
1384 |
/**
|
sl@0
|
1385 |
Sets the home time to a specified time value.
|
sl@0
|
1386 |
|
sl@0
|
1387 |
@param aTime A reference to a time representation object containing the time
|
sl@0
|
1388 |
value.
|
sl@0
|
1389 |
|
sl@0
|
1390 |
@return KErrNone if successful or one of the system-wide error codes.
|
sl@0
|
1391 |
|
sl@0
|
1392 |
@deprecated Set the time using User::SetUTCTime if the UTC time is known;
|
sl@0
|
1393 |
otherwise, use the timezone server to set the time.
|
sl@0
|
1394 |
|
sl@0
|
1395 |
@capability WriteDeviceData
|
sl@0
|
1396 |
*/
|
sl@0
|
1397 |
EXPORT_C TInt User::SetHomeTime(const TTime &aTime)
|
sl@0
|
1398 |
{
|
sl@0
|
1399 |
return(Exec::SetUTCTimeAndOffset(aTime.Int64(),0,ETimeSetTime|ETimeSetLocalTime,0));
|
sl@0
|
1400 |
}
|
sl@0
|
1401 |
|
sl@0
|
1402 |
/**
|
sl@0
|
1403 |
Sets the secure home time to a specified time value.
|
sl@0
|
1404 |
|
sl@0
|
1405 |
@param aTime A reference to a time representation object containing the
|
sl@0
|
1406 |
secure time value.
|
sl@0
|
1407 |
|
sl@0
|
1408 |
@return KErrNone if successful or one of the system-wide error codes.
|
sl@0
|
1409 |
|
sl@0
|
1410 |
@capability TCB
|
sl@0
|
1411 |
@capability WriteDeviceData
|
sl@0
|
1412 |
*/
|
sl@0
|
1413 |
EXPORT_C TInt User::SetHomeTimeSecure(const TTime &aTime)
|
sl@0
|
1414 |
{
|
sl@0
|
1415 |
return(Exec::SetUTCTimeAndOffset(aTime.Int64(),0,ETimeSetTime|ETimeSetLocalTime|ETimeSetSecure,0));
|
sl@0
|
1416 |
}
|
sl@0
|
1417 |
|
sl@0
|
1418 |
|
sl@0
|
1419 |
|
sl@0
|
1420 |
/**
|
sl@0
|
1421 |
Sets the UTC time to a specified time value.
|
sl@0
|
1422 |
|
sl@0
|
1423 |
@param aUTCTime A reference to a time representation object containing the time
|
sl@0
|
1424 |
value.
|
sl@0
|
1425 |
|
sl@0
|
1426 |
@return KErrNone if successful or one of the system-wide error codes.
|
sl@0
|
1427 |
|
sl@0
|
1428 |
@capability WriteDeviceData
|
sl@0
|
1429 |
*/
|
sl@0
|
1430 |
EXPORT_C TInt User::SetUTCTime(const TTime &aUTCTime)
|
sl@0
|
1431 |
{
|
sl@0
|
1432 |
return(Exec::SetUTCTimeAndOffset(aUTCTime.Int64(),0,ETimeSetTime,0));
|
sl@0
|
1433 |
}
|
sl@0
|
1434 |
|
sl@0
|
1435 |
/**
|
sl@0
|
1436 |
Sets the secure UTC time to a specified time value.
|
sl@0
|
1437 |
|
sl@0
|
1438 |
@param aUTCTime A reference to a time representation object containing the secure time
|
sl@0
|
1439 |
value.
|
sl@0
|
1440 |
|
sl@0
|
1441 |
@return KErrNone if successful or one of the system-wide error codes.
|
sl@0
|
1442 |
|
sl@0
|
1443 |
@capability TCB
|
sl@0
|
1444 |
@capability WriteDeviceData
|
sl@0
|
1445 |
*/
|
sl@0
|
1446 |
EXPORT_C TInt User::SetUTCTimeSecure(const TTime &aUTCTime)
|
sl@0
|
1447 |
{
|
sl@0
|
1448 |
return(Exec::SetUTCTimeAndOffset(aUTCTime.Int64(),0,ETimeSetTime|ETimeSetSecure,0));
|
sl@0
|
1449 |
}
|
sl@0
|
1450 |
|
sl@0
|
1451 |
/**
|
sl@0
|
1452 |
Gets the UTC offset - the difference between UTC and the current local time
|
sl@0
|
1453 |
due to any time zones and daylight savings time that may be in effect. A positive
|
sl@0
|
1454 |
offset indicates a time ahead of UTC, a negative offset indicates a time behind UTC.
|
sl@0
|
1455 |
|
sl@0
|
1456 |
@return The UTC offset, in seconds.
|
sl@0
|
1457 |
*/
|
sl@0
|
1458 |
EXPORT_C TTimeIntervalSeconds User::UTCOffset()
|
sl@0
|
1459 |
{
|
sl@0
|
1460 |
return(TTimeIntervalSeconds(Exec::UTCOffset()));
|
sl@0
|
1461 |
}
|
sl@0
|
1462 |
|
sl@0
|
1463 |
|
sl@0
|
1464 |
/**
|
sl@0
|
1465 |
Sets the UTC offset to the given number of seconds. This should include both time
|
sl@0
|
1466 |
zone differences and the effect of any applicable daylight savings time.
|
sl@0
|
1467 |
A positive offset indicates a time ahead of UTC, a negative offset indicates a time
|
sl@0
|
1468 |
behind UTC.
|
sl@0
|
1469 |
|
sl@0
|
1470 |
@param aOffset The UTC offset, in seconds.
|
sl@0
|
1471 |
|
sl@0
|
1472 |
@capability WriteDeviceData
|
sl@0
|
1473 |
*/
|
sl@0
|
1474 |
EXPORT_C void User::SetUTCOffset(TTimeIntervalSeconds aOffset)
|
sl@0
|
1475 |
{
|
sl@0
|
1476 |
Exec::SetUTCTimeAndOffset(0,aOffset.Int(),ETimeSetOffset,0);
|
sl@0
|
1477 |
}
|
sl@0
|
1478 |
|
sl@0
|
1479 |
|
sl@0
|
1480 |
/**
|
sl@0
|
1481 |
Sets the UTC time and UTC offset to the specified values, atomically. This is equivalent
|
sl@0
|
1482 |
to calling both SetUTCTime and SetUTCOffset, but without the possibility of an incorrect
|
sl@0
|
1483 |
time being observed between the two calls. If the operation is not successful, an error
|
sl@0
|
1484 |
code will be returned and both the time and offset will be left unchanged.
|
sl@0
|
1485 |
|
sl@0
|
1486 |
@param aUTCTime A reference to a time representation object containing the time
|
sl@0
|
1487 |
value.
|
sl@0
|
1488 |
@param aOffset The UTC offset, in seconds.
|
sl@0
|
1489 |
|
sl@0
|
1490 |
@return KErrNone if successful or one of the system-wide error codes.
|
sl@0
|
1491 |
|
sl@0
|
1492 |
@capability WriteDeviceData
|
sl@0
|
1493 |
*/
|
sl@0
|
1494 |
EXPORT_C TInt User::SetUTCTimeAndOffset(const TTime &aUTCTime, TTimeIntervalSeconds aOffset)
|
sl@0
|
1495 |
{
|
sl@0
|
1496 |
return(Exec::SetUTCTimeAndOffset(aUTCTime.Int64(),aOffset.Int(),ETimeSetTime|ETimeSetOffset,0));
|
sl@0
|
1497 |
}
|
sl@0
|
1498 |
|
sl@0
|
1499 |
|
sl@0
|
1500 |
/**
|
sl@0
|
1501 |
Gets the current tick count.
|
sl@0
|
1502 |
|
sl@0
|
1503 |
The period between ticks is usually 1/64 second, but may be hardware dependent.
|
sl@0
|
1504 |
|
sl@0
|
1505 |
@return The machine dependent tick count.
|
sl@0
|
1506 |
*/
|
sl@0
|
1507 |
EXPORT_C TUint User::TickCount()
|
sl@0
|
1508 |
{
|
sl@0
|
1509 |
|
sl@0
|
1510 |
return(Exec::TickCount());
|
sl@0
|
1511 |
}
|
sl@0
|
1512 |
|
sl@0
|
1513 |
|
sl@0
|
1514 |
|
sl@0
|
1515 |
|
sl@0
|
1516 |
EXPORT_C TTimeIntervalSeconds User::InactivityTime()
|
sl@0
|
1517 |
/**
|
sl@0
|
1518 |
Gets the time since the last user activity.
|
sl@0
|
1519 |
|
sl@0
|
1520 |
@return The time interval.
|
sl@0
|
1521 |
*/
|
sl@0
|
1522 |
{
|
sl@0
|
1523 |
|
sl@0
|
1524 |
return TTimeIntervalSeconds(Exec::UserInactivityTime());
|
sl@0
|
1525 |
}
|
sl@0
|
1526 |
|
sl@0
|
1527 |
|
sl@0
|
1528 |
|
sl@0
|
1529 |
|
sl@0
|
1530 |
/**
|
sl@0
|
1531 |
Resets all user inactivity timers.
|
sl@0
|
1532 |
*/
|
sl@0
|
1533 |
EXPORT_C void User::ResetInactivityTime()
|
sl@0
|
1534 |
{
|
sl@0
|
1535 |
Exec::ResetInactivityTime();
|
sl@0
|
1536 |
}
|
sl@0
|
1537 |
|
sl@0
|
1538 |
|
sl@0
|
1539 |
|
sl@0
|
1540 |
|
sl@0
|
1541 |
/**
|
sl@0
|
1542 |
Gets the nanokernel tick count.
|
sl@0
|
1543 |
|
sl@0
|
1544 |
This is the current value of the machine's millisecond tick counter.
|
sl@0
|
1545 |
|
sl@0
|
1546 |
On the emulator the resolution defaults to 5 milliseconds; however
|
sl@0
|
1547 |
you can change it to N milliseconds when you launch the emulator
|
sl@0
|
1548 |
from the command line by specifying -Dtimerresolution=N as a parameter
|
sl@0
|
1549 |
to epoc.exe, for example:
|
sl@0
|
1550 |
@code
|
sl@0
|
1551 |
epoc.exe -Dtimerresolution=3
|
sl@0
|
1552 |
@endcode
|
sl@0
|
1553 |
|
sl@0
|
1554 |
On most hardware the resolution is about 1 millisecond.
|
sl@0
|
1555 |
|
sl@0
|
1556 |
You can get the nanokernel tick period in microseconds by calling
|
sl@0
|
1557 |
into the Hardware Abstraction Layer:
|
sl@0
|
1558 |
|
sl@0
|
1559 |
@code
|
sl@0
|
1560 |
TInt nanokernel_tick_period;
|
sl@0
|
1561 |
HAL::Get(HAL::ENanoTickPeriod, nanokernel_tick_period);
|
sl@0
|
1562 |
@endcode
|
sl@0
|
1563 |
|
sl@0
|
1564 |
@return The nanokernel tick count.
|
sl@0
|
1565 |
*/
|
sl@0
|
1566 |
EXPORT_C TUint32 User::NTickCount()
|
sl@0
|
1567 |
{
|
sl@0
|
1568 |
|
sl@0
|
1569 |
return Exec::NTickCount();
|
sl@0
|
1570 |
}
|
sl@0
|
1571 |
|
sl@0
|
1572 |
|
sl@0
|
1573 |
|
sl@0
|
1574 |
|
sl@0
|
1575 |
/**
|
sl@0
|
1576 |
Gets the fast counter.
|
sl@0
|
1577 |
|
sl@0
|
1578 |
This is the current value of the machine's high resolution timer. If a high
|
sl@0
|
1579 |
resolution timer is not available, it uses the millisecond timer instead.
|
sl@0
|
1580 |
|
sl@0
|
1581 |
The freqency of this counter can be determined by reading the HAL attribute
|
sl@0
|
1582 |
EFastCounterFrequency.
|
sl@0
|
1583 |
|
sl@0
|
1584 |
This function is intended for use in profiling and testing; it should not be
|
sl@0
|
1585 |
used in production code. User::NTickCount() should be used instead.
|
sl@0
|
1586 |
|
sl@0
|
1587 |
This is because the implementation of the FastCounter is platform-specific:
|
sl@0
|
1588 |
its frequency can be anywhere from a few KHz to many MHz. It may also not
|
sl@0
|
1589 |
be activated when needed, since it is expensive in terms of clock cycles and
|
sl@0
|
1590 |
battery life, and use of a platform-specific API may be necessary to enable
|
sl@0
|
1591 |
it.
|
sl@0
|
1592 |
|
sl@0
|
1593 |
@return The fast counter value.
|
sl@0
|
1594 |
|
sl@0
|
1595 |
@see User::NTickCount()
|
sl@0
|
1596 |
*/
|
sl@0
|
1597 |
EXPORT_C TUint32 User::FastCounter()
|
sl@0
|
1598 |
{
|
sl@0
|
1599 |
|
sl@0
|
1600 |
return Exec::FastCounter();
|
sl@0
|
1601 |
}
|
sl@0
|
1602 |
|
sl@0
|
1603 |
|
sl@0
|
1604 |
|
sl@0
|
1605 |
|
sl@0
|
1606 |
EXPORT_C TTimerLockSpec User::LockPeriod()
|
sl@0
|
1607 |
/**
|
sl@0
|
1608 |
Returns which of the periods the clock is currently in.
|
sl@0
|
1609 |
|
sl@0
|
1610 |
@return The fraction of a second at which the timer completes.
|
sl@0
|
1611 |
*/
|
sl@0
|
1612 |
{
|
sl@0
|
1613 |
|
sl@0
|
1614 |
return(Exec::LockPeriod());
|
sl@0
|
1615 |
}
|
sl@0
|
1616 |
|
sl@0
|
1617 |
|
sl@0
|
1618 |
|
sl@0
|
1619 |
|
sl@0
|
1620 |
EXPORT_C TName RHandleBase::Name() const
|
sl@0
|
1621 |
/**
|
sl@0
|
1622 |
Gets the name of the handle.
|
sl@0
|
1623 |
|
sl@0
|
1624 |
@return The name of the handle.
|
sl@0
|
1625 |
*/
|
sl@0
|
1626 |
{
|
sl@0
|
1627 |
|
sl@0
|
1628 |
TName n;
|
sl@0
|
1629 |
TPtr8 n8(((TUint8*)n.Ptr()) + KMaxName, KMaxName);
|
sl@0
|
1630 |
Exec::HandleName(iHandle,n8);
|
sl@0
|
1631 |
n.Copy(n8);
|
sl@0
|
1632 |
return(n);
|
sl@0
|
1633 |
}
|
sl@0
|
1634 |
|
sl@0
|
1635 |
|
sl@0
|
1636 |
|
sl@0
|
1637 |
|
sl@0
|
1638 |
EXPORT_C TFullName RHandleBase::FullName() const
|
sl@0
|
1639 |
/**
|
sl@0
|
1640 |
Gets the full name of the handle.
|
sl@0
|
1641 |
|
sl@0
|
1642 |
Note: This method is stack consuming (it takes 512 bytes on stack to execute).
|
sl@0
|
1643 |
For an alternative way to obtain the full name of the object, see RHandleBase::FullName(TDes& aName) const.
|
sl@0
|
1644 |
|
sl@0
|
1645 |
@see RHandleBase::FullName(TDes& aName) const
|
sl@0
|
1646 |
@return The full name of the handle.
|
sl@0
|
1647 |
*/
|
sl@0
|
1648 |
{
|
sl@0
|
1649 |
|
sl@0
|
1650 |
TFullName n;
|
sl@0
|
1651 |
TPtr8 n8(((TUint8*)n.Ptr()) + KMaxFullName, KMaxFullName);
|
sl@0
|
1652 |
Exec::HandleFullName(iHandle,n8);
|
sl@0
|
1653 |
n.Copy(n8);
|
sl@0
|
1654 |
return(n);
|
sl@0
|
1655 |
}
|
sl@0
|
1656 |
|
sl@0
|
1657 |
|
sl@0
|
1658 |
|
sl@0
|
1659 |
|
sl@0
|
1660 |
EXPORT_C void RHandleBase::FullName(TDes& aName) const
|
sl@0
|
1661 |
/**
|
sl@0
|
1662 |
Gets the full name of the handle.
|
sl@0
|
1663 |
|
sl@0
|
1664 |
@param aName On return, contains the full name of the handle.
|
sl@0
|
1665 |
|
sl@0
|
1666 |
@panic KERN-EXEC 35, If full name of the handler is longer that the maximum length of aName descriptor.
|
sl@0
|
1667 |
To avoid this, the maximum length of aName should be at least KMaxFullName.
|
sl@0
|
1668 |
@see KMaxFullName
|
sl@0
|
1669 |
*/
|
sl@0
|
1670 |
{
|
sl@0
|
1671 |
|
sl@0
|
1672 |
// Kernel will copy string in n8, whose data lives in the upper half of aName desciptor data
|
sl@0
|
1673 |
TPtr8 n8(((TUint8*)aName.Ptr()) + aName.MaxLength(), aName.MaxLength());
|
sl@0
|
1674 |
Exec::HandleFullName(iHandle,n8);
|
sl@0
|
1675 |
aName.Copy(n8); // Expands 8bit descriptor into 16bit unicode descriptor.
|
sl@0
|
1676 |
}
|
sl@0
|
1677 |
|
sl@0
|
1678 |
|
sl@0
|
1679 |
|
sl@0
|
1680 |
|
sl@0
|
1681 |
EXPORT_C void RHandleBase::HandleInfo(THandleInfo* anInfo)
|
sl@0
|
1682 |
/**
|
sl@0
|
1683 |
Gets information about the handle.
|
sl@0
|
1684 |
|
sl@0
|
1685 |
@param anInfo A pointer to a THandleInfo object supplied by the caller;
|
sl@0
|
1686 |
on return, contains the handle information.
|
sl@0
|
1687 |
*/
|
sl@0
|
1688 |
{
|
sl@0
|
1689 |
|
sl@0
|
1690 |
Exec::HandleInfo(iHandle,anInfo);
|
sl@0
|
1691 |
}
|
sl@0
|
1692 |
|
sl@0
|
1693 |
EXPORT_C TInt RHandleBase::BTraceId() const
|
sl@0
|
1694 |
/**
|
sl@0
|
1695 |
Returns a unique object identifier for use with BTrace
|
sl@0
|
1696 |
*/
|
sl@0
|
1697 |
{
|
sl@0
|
1698 |
return Exec::GetBTraceId(iHandle);
|
sl@0
|
1699 |
}
|
sl@0
|
1700 |
|
sl@0
|
1701 |
|
sl@0
|
1702 |
|
sl@0
|
1703 |
EXPORT_C TUint RHandleBase::Attributes() const
|
sl@0
|
1704 |
//
|
sl@0
|
1705 |
// Get handle attributes
|
sl@0
|
1706 |
//
|
sl@0
|
1707 |
{
|
sl@0
|
1708 |
|
sl@0
|
1709 |
return Exec::HandleAttributes(iHandle);
|
sl@0
|
1710 |
}
|
sl@0
|
1711 |
|
sl@0
|
1712 |
|
sl@0
|
1713 |
|
sl@0
|
1714 |
|
sl@0
|
1715 |
EXPORT_C TInt User::AllocLen(const TAny *aCell)
|
sl@0
|
1716 |
/**
|
sl@0
|
1717 |
Gets the length of the specified allocated heap cell.
|
sl@0
|
1718 |
|
sl@0
|
1719 |
The cell is assumed to be in the current thread's heap.
|
sl@0
|
1720 |
|
sl@0
|
1721 |
@param aCell A pointer to the allocated cell whose length
|
sl@0
|
1722 |
is to be fetched.
|
sl@0
|
1723 |
|
sl@0
|
1724 |
@return The length of the allocated cell.
|
sl@0
|
1725 |
*/
|
sl@0
|
1726 |
{
|
sl@0
|
1727 |
|
sl@0
|
1728 |
return(GetHeap()->AllocLen(aCell));
|
sl@0
|
1729 |
}
|
sl@0
|
1730 |
|
sl@0
|
1731 |
|
sl@0
|
1732 |
|
sl@0
|
1733 |
|
sl@0
|
1734 |
EXPORT_C TAny* User::Alloc(TInt aSize)
|
sl@0
|
1735 |
/**
|
sl@0
|
1736 |
Allocates a cell of specified size from the current thread's heap.
|
sl@0
|
1737 |
|
sl@0
|
1738 |
If there is insufficient memory available on the heap from which to allocate a cell
|
sl@0
|
1739 |
of the required size, the function returns NULL.
|
sl@0
|
1740 |
|
sl@0
|
1741 |
The resulting size of the allocated cell may be rounded up to a value greater
|
sl@0
|
1742 |
than aSize, but is guaranteed to be not less than aSize.
|
sl@0
|
1743 |
|
sl@0
|
1744 |
@param aSize The size of the cell to be allocated from the current thread's
|
sl@0
|
1745 |
heap.
|
sl@0
|
1746 |
|
sl@0
|
1747 |
@return A pointer to the allocated cell. NULL, if there is insufficient memory
|
sl@0
|
1748 |
available.
|
sl@0
|
1749 |
|
sl@0
|
1750 |
@panic USER 47, if the maximum unsigned value of aSize is greater
|
sl@0
|
1751 |
than or equal to KMaxTInt/2. For example,
|
sl@0
|
1752 |
calling Alloc(-1) raises this panic.
|
sl@0
|
1753 |
*/
|
sl@0
|
1754 |
{
|
sl@0
|
1755 |
|
sl@0
|
1756 |
return(GetHeap()->Alloc(aSize));
|
sl@0
|
1757 |
}
|
sl@0
|
1758 |
|
sl@0
|
1759 |
|
sl@0
|
1760 |
|
sl@0
|
1761 |
|
sl@0
|
1762 |
EXPORT_C TAny* User::AllocL(TInt aSize)
|
sl@0
|
1763 |
/**
|
sl@0
|
1764 |
Allocates a cell of specified size from the current thread's heap, and leaves
|
sl@0
|
1765 |
if there is insufficient memory in the heap.
|
sl@0
|
1766 |
|
sl@0
|
1767 |
The resulting size of the allocated cell may be rounded up to a value greater
|
sl@0
|
1768 |
than aSize, but is guaranteed to be not less than aSize.
|
sl@0
|
1769 |
|
sl@0
|
1770 |
@param aSize The size of the cell to be allocated from the current thread's
|
sl@0
|
1771 |
heap.
|
sl@0
|
1772 |
|
sl@0
|
1773 |
@return A pointer to the allocated cell.
|
sl@0
|
1774 |
|
sl@0
|
1775 |
@panic USER 47, if the maximum unsigned value of aSize is greater
|
sl@0
|
1776 |
than or equal to KMaxTInt/2. For example,
|
sl@0
|
1777 |
calling Alloc(-1) raises this panic.
|
sl@0
|
1778 |
*/
|
sl@0
|
1779 |
{
|
sl@0
|
1780 |
|
sl@0
|
1781 |
return(GetHeap()->AllocL(aSize));
|
sl@0
|
1782 |
}
|
sl@0
|
1783 |
|
sl@0
|
1784 |
|
sl@0
|
1785 |
|
sl@0
|
1786 |
|
sl@0
|
1787 |
EXPORT_C TAny *User::AllocLC(TInt aSize)
|
sl@0
|
1788 |
/**
|
sl@0
|
1789 |
Allocates a cell of specified size from the current thread's default heap, and,
|
sl@0
|
1790 |
if successful, places a pointer to the cell onto the cleanup stack.
|
sl@0
|
1791 |
|
sl@0
|
1792 |
The function leaves if there is insufficient memory in the heap.
|
sl@0
|
1793 |
|
sl@0
|
1794 |
The resulting size of the allocated cell may be rounded up to a value greater
|
sl@0
|
1795 |
than aSize, but is guaranteed to be not less than aSize.
|
sl@0
|
1796 |
|
sl@0
|
1797 |
@param aSize The size of the cell to be allocated from the current thread's
|
sl@0
|
1798 |
default heap.
|
sl@0
|
1799 |
|
sl@0
|
1800 |
@return A pointer to the allocated cell.
|
sl@0
|
1801 |
|
sl@0
|
1802 |
@panic USER 47, if the maximum unsigned value of aSize is greater
|
sl@0
|
1803 |
than or equal to KMaxTInt/2. For example,
|
sl@0
|
1804 |
calling Alloc(-1) raises this panic.
|
sl@0
|
1805 |
*/
|
sl@0
|
1806 |
{
|
sl@0
|
1807 |
|
sl@0
|
1808 |
return(GetHeap()->AllocLC(aSize));
|
sl@0
|
1809 |
}
|
sl@0
|
1810 |
|
sl@0
|
1811 |
|
sl@0
|
1812 |
|
sl@0
|
1813 |
|
sl@0
|
1814 |
EXPORT_C TAny* User::AllocZ(TInt aSize)
|
sl@0
|
1815 |
/**
|
sl@0
|
1816 |
Allocates a cell of specified size from the current thread's default heap,
|
sl@0
|
1817 |
and clears it to binary zeroes.
|
sl@0
|
1818 |
|
sl@0
|
1819 |
If there is insufficient memory available on the heap from which to allocate a cell
|
sl@0
|
1820 |
of the required size, the function returns NULL.
|
sl@0
|
1821 |
|
sl@0
|
1822 |
The resulting size of the allocated cell may be rounded up to a value greater
|
sl@0
|
1823 |
than aSize, but is guaranteed to be not less than aSize.
|
sl@0
|
1824 |
|
sl@0
|
1825 |
@param aSize The size of the cell to be allocated from the current thread's
|
sl@0
|
1826 |
default heap.
|
sl@0
|
1827 |
|
sl@0
|
1828 |
@return A pointer to the allocated cell. NULL, if there is insufficient memory
|
sl@0
|
1829 |
available.
|
sl@0
|
1830 |
|
sl@0
|
1831 |
@panic USER 47, if the maximum unsigned value of aSize is greater
|
sl@0
|
1832 |
than or equal to KMaxTInt/2. For example,
|
sl@0
|
1833 |
calling Alloc(-1) raises this panic.
|
sl@0
|
1834 |
*/
|
sl@0
|
1835 |
{
|
sl@0
|
1836 |
|
sl@0
|
1837 |
return GetHeap()->AllocZ(aSize);
|
sl@0
|
1838 |
}
|
sl@0
|
1839 |
|
sl@0
|
1840 |
|
sl@0
|
1841 |
|
sl@0
|
1842 |
|
sl@0
|
1843 |
EXPORT_C TAny* User::AllocZL(TInt aSize)
|
sl@0
|
1844 |
/**
|
sl@0
|
1845 |
Allocates a cell of specified size from the current thread's default heap,
|
sl@0
|
1846 |
clears it to binary zeroes, and leaves if there is insufficient memory in
|
sl@0
|
1847 |
the heap.
|
sl@0
|
1848 |
|
sl@0
|
1849 |
The resulting size of the allocated cell may be rounded up to a value greater
|
sl@0
|
1850 |
than aSize, but is guaranteed to be not less than aSize.
|
sl@0
|
1851 |
|
sl@0
|
1852 |
@param aSize The size of the cell to be allocated from the current thread's
|
sl@0
|
1853 |
heap.
|
sl@0
|
1854 |
|
sl@0
|
1855 |
@return A pointer to the allocated cell.
|
sl@0
|
1856 |
|
sl@0
|
1857 |
@panic USER 47, if the maximum unsigned value of aSize is greater
|
sl@0
|
1858 |
than or equal to KMaxTInt/2. For example,
|
sl@0
|
1859 |
calling Alloc(-1) raises this panic.
|
sl@0
|
1860 |
*/
|
sl@0
|
1861 |
{
|
sl@0
|
1862 |
|
sl@0
|
1863 |
return GetHeap()->AllocZL(aSize);
|
sl@0
|
1864 |
}
|
sl@0
|
1865 |
|
sl@0
|
1866 |
|
sl@0
|
1867 |
|
sl@0
|
1868 |
|
sl@0
|
1869 |
EXPORT_C TInt User::Available(TInt &aBiggestBlock)
|
sl@0
|
1870 |
/**
|
sl@0
|
1871 |
Gets the total free space currently available on the current thread's
|
sl@0
|
1872 |
default heap, and the space available in the largest free block.
|
sl@0
|
1873 |
|
sl@0
|
1874 |
The space available represents the total space which can be allocated.
|
sl@0
|
1875 |
|
sl@0
|
1876 |
Note that compressing the heap may reduce the total free space available and the space
|
sl@0
|
1877 |
available in the largest free block.
|
sl@0
|
1878 |
|
sl@0
|
1879 |
@param aBiggestBlock On return, contains the space available in the largest
|
sl@0
|
1880 |
free block on the current thread's default heap.
|
sl@0
|
1881 |
|
sl@0
|
1882 |
@return The total free space currently available on the current thread's heap.
|
sl@0
|
1883 |
*/
|
sl@0
|
1884 |
{
|
sl@0
|
1885 |
|
sl@0
|
1886 |
return(GetHeap()->Available(aBiggestBlock));
|
sl@0
|
1887 |
}
|
sl@0
|
1888 |
|
sl@0
|
1889 |
|
sl@0
|
1890 |
|
sl@0
|
1891 |
|
sl@0
|
1892 |
EXPORT_C void User::Check()
|
sl@0
|
1893 |
/**
|
sl@0
|
1894 |
Checks the validity of the current thread's default heap.
|
sl@0
|
1895 |
|
sl@0
|
1896 |
The function walks through the list of allocated cells and the list of free
|
sl@0
|
1897 |
cells checking that the heap is consistent and complete.
|
sl@0
|
1898 |
|
sl@0
|
1899 |
@panic USER 47 if any corruption is found, specifically a bad allocated
|
sl@0
|
1900 |
heap cell size.
|
sl@0
|
1901 |
@panic USER 48 if any corruption is found, specifically a bad allocated
|
sl@0
|
1902 |
heap cell address.
|
sl@0
|
1903 |
@panic USER 49 if any corruption is found, specifically a bad free heap
|
sl@0
|
1904 |
cell address.
|
sl@0
|
1905 |
*/
|
sl@0
|
1906 |
{
|
sl@0
|
1907 |
|
sl@0
|
1908 |
GetHeap()->Check();
|
sl@0
|
1909 |
}
|
sl@0
|
1910 |
|
sl@0
|
1911 |
|
sl@0
|
1912 |
|
sl@0
|
1913 |
|
sl@0
|
1914 |
EXPORT_C void User::Free(TAny *aCell)
|
sl@0
|
1915 |
/**
|
sl@0
|
1916 |
Frees the specified cell and returns it to the current thread's default heap.
|
sl@0
|
1917 |
|
sl@0
|
1918 |
@param aCell A pointer to a valid cell to be freed. If NULL this function
|
sl@0
|
1919 |
call will be ignored.
|
sl@0
|
1920 |
|
sl@0
|
1921 |
@panic USER 42, if aCell is not NULL and does not point to a valid cell.
|
sl@0
|
1922 |
*/
|
sl@0
|
1923 |
{
|
sl@0
|
1924 |
|
sl@0
|
1925 |
if (aCell)
|
sl@0
|
1926 |
GetHeap()->Free(aCell);
|
sl@0
|
1927 |
}
|
sl@0
|
1928 |
|
sl@0
|
1929 |
|
sl@0
|
1930 |
|
sl@0
|
1931 |
|
sl@0
|
1932 |
EXPORT_C void User::FreeZ(TAny * &aCell)
|
sl@0
|
1933 |
/**
|
sl@0
|
1934 |
Frees the specified cell, returns it to the current thread's default heap, and resets
|
sl@0
|
1935 |
the pointer to NULL.
|
sl@0
|
1936 |
|
sl@0
|
1937 |
@param aCell A reference to a pointer to a valid cell to be freed. If NULL
|
sl@0
|
1938 |
this function call will be ignored.
|
sl@0
|
1939 |
|
sl@0
|
1940 |
@panic USER 42, if aCell is not NULL and does not point to a valid cell.
|
sl@0
|
1941 |
*/
|
sl@0
|
1942 |
{
|
sl@0
|
1943 |
|
sl@0
|
1944 |
if (aCell)
|
sl@0
|
1945 |
GetHeap()->FreeZ(aCell);
|
sl@0
|
1946 |
}
|
sl@0
|
1947 |
|
sl@0
|
1948 |
|
sl@0
|
1949 |
|
sl@0
|
1950 |
|
sl@0
|
1951 |
EXPORT_C TAny* User::ReAlloc(TAny* aCell, TInt aSize, TInt aMode)
|
sl@0
|
1952 |
/**
|
sl@0
|
1953 |
Increases or decreases the size of an existing cell in the current
|
sl@0
|
1954 |
thread's heap.
|
sl@0
|
1955 |
|
sl@0
|
1956 |
If the cell is being decreased in size, then it is guaranteed not to move,
|
sl@0
|
1957 |
and the function returns the pointer originally passed in aCell. Note that the
|
sl@0
|
1958 |
length of the cell will be the same if the difference between the old size
|
sl@0
|
1959 |
and the new size is smaller than the minimum cell size.
|
sl@0
|
1960 |
|
sl@0
|
1961 |
If the cell is being increased in size, i.e. aSize is bigger than its
|
sl@0
|
1962 |
current size, then the function tries to grow the cell in place.
|
sl@0
|
1963 |
If successful, then the function returns the pointer originally
|
sl@0
|
1964 |
passed in aCell. If unsuccessful, then:
|
sl@0
|
1965 |
-# if the cell cannot be moved, i.e. aMode has the ENeverMove bit set, then
|
sl@0
|
1966 |
the function returns NULL.
|
sl@0
|
1967 |
-# if the cell can be moved, i.e. aMode does not have the ENeverMove bit set,
|
sl@0
|
1968 |
then the function tries to allocate a new replacement cell, and, if
|
sl@0
|
1969 |
successful, returns a pointer to the new cell; if unsuccessful, it
|
sl@0
|
1970 |
returns NULL.
|
sl@0
|
1971 |
|
sl@0
|
1972 |
Note that in debug mode, the function returns NULL if the cell cannot be grown
|
sl@0
|
1973 |
in place, regardless of whether the ENeverMove bit is set.
|
sl@0
|
1974 |
|
sl@0
|
1975 |
If the reallocated cell is at a different location from the original cell, then
|
sl@0
|
1976 |
the content of the original cell is copied to the reallocated cell.
|
sl@0
|
1977 |
|
sl@0
|
1978 |
If the supplied pointer, aCell is NULL, then the function attempts to allocate
|
sl@0
|
1979 |
a new cell, but only if the cell can be moved, i.e. aMode does not have
|
sl@0
|
1980 |
the ENeverMove bit set.
|
sl@0
|
1981 |
|
sl@0
|
1982 |
Note the following general points:
|
sl@0
|
1983 |
- If reallocation fails, the content of the original cell is preserved.
|
sl@0
|
1984 |
- The resulting size of the re-allocated cell may be rounded up to a value
|
sl@0
|
1985 |
greater than aSize, but is guaranteed to be not less than aSize.
|
sl@0
|
1986 |
|
sl@0
|
1987 |
@param aCell A pointer to the cell to be reallocated. This may be NULL.
|
sl@0
|
1988 |
|
sl@0
|
1989 |
@param aSize The new size of the cell. This may be bigger or smaller than the
|
sl@0
|
1990 |
size of the original cell. The value can also be zero, but this is
|
sl@0
|
1991 |
interpreted as a request for a cell of minimum size; the net
|
sl@0
|
1992 |
effect is the same as if the caller had explicitly requested
|
sl@0
|
1993 |
a cell of minimum size.
|
sl@0
|
1994 |
Note that the minimum size of a heap cell is device dependent.
|
sl@0
|
1995 |
|
sl@0
|
1996 |
@param aMode Flags controlling the reallocation. The only bit which has any
|
sl@0
|
1997 |
effect on this function is that defined by the enumeration
|
sl@0
|
1998 |
ENeverMove of the enum RAllocator::TReAllocMode.
|
sl@0
|
1999 |
If this is set, then any successful reallocation guarantees not
|
sl@0
|
2000 |
to have changed the start address of the cell.
|
sl@0
|
2001 |
By default, this parameter is zero.
|
sl@0
|
2002 |
|
sl@0
|
2003 |
@return A pointer to the reallocated cell. This may be the same as the original
|
sl@0
|
2004 |
pointer supplied through aCell. NULL if there is insufficient memory to
|
sl@0
|
2005 |
reallocate the cell, or to grow it in place.
|
sl@0
|
2006 |
|
sl@0
|
2007 |
@panic USER 42, if aCell is not NULL, and does not point to a valid cell.
|
sl@0
|
2008 |
@panic USER 47, if the maximum unsigned value of aSize is greater
|
sl@0
|
2009 |
than or equal to KMaxTInt/2. For example,
|
sl@0
|
2010 |
calling ReAlloc(someptr,-1) raises this panic.
|
sl@0
|
2011 |
|
sl@0
|
2012 |
@see RAllocator::TReAllocMode
|
sl@0
|
2013 |
*/
|
sl@0
|
2014 |
{
|
sl@0
|
2015 |
|
sl@0
|
2016 |
return GetHeap()->ReAlloc(aCell, aSize, aMode);
|
sl@0
|
2017 |
}
|
sl@0
|
2018 |
|
sl@0
|
2019 |
|
sl@0
|
2020 |
|
sl@0
|
2021 |
|
sl@0
|
2022 |
EXPORT_C TAny* User::ReAllocL(TAny* aCell, TInt aSize, TInt aMode)
|
sl@0
|
2023 |
/**
|
sl@0
|
2024 |
Increases or decreases the size of an existing cell, and leaves
|
sl@0
|
2025 |
if there is insufficient memory in the current thread's default heap.
|
sl@0
|
2026 |
|
sl@0
|
2027 |
If the cell is being decreased in size, then it is guaranteed not to move,
|
sl@0
|
2028 |
and the function returns the pointer originally passed in aCell. Note that the
|
sl@0
|
2029 |
length of the cell will be the same if the difference between the old size
|
sl@0
|
2030 |
and the new size is smaller than the minimum cell size.
|
sl@0
|
2031 |
|
sl@0
|
2032 |
If the cell is being increased in size, i.e. aSize is bigger than its
|
sl@0
|
2033 |
current size, then the function tries to grow the cell in place.
|
sl@0
|
2034 |
If successful, then the function returns the pointer originally
|
sl@0
|
2035 |
passed in aCell. If unsuccessful, then:
|
sl@0
|
2036 |
-# if the cell cannot be moved, i.e. aMode has the ENeverMove bit set, then
|
sl@0
|
2037 |
the function leaves.
|
sl@0
|
2038 |
-# if the cell can be moved, i.e. aMode does not have the ENeverMove bit set,
|
sl@0
|
2039 |
then the function tries to allocate a new replacement cell, and, if
|
sl@0
|
2040 |
successful, returns a pointer to the new cell; if unsuccessful, it
|
sl@0
|
2041 |
leaves.
|
sl@0
|
2042 |
|
sl@0
|
2043 |
Note that in debug mode, the function leaves if the cell cannot be grown
|
sl@0
|
2044 |
in place, regardless of whether the ENeverMove bit is set.
|
sl@0
|
2045 |
|
sl@0
|
2046 |
If the reallocated cell is at a different location from the original cell, then
|
sl@0
|
2047 |
the content of the original cell is copied to the reallocated cell.
|
sl@0
|
2048 |
|
sl@0
|
2049 |
If the supplied pointer, aCell is NULL, then the function attempts to allocate
|
sl@0
|
2050 |
a new cell, but only if the cell can be moved, i.e. aMode does not have
|
sl@0
|
2051 |
the ENeverMove bit set.
|
sl@0
|
2052 |
|
sl@0
|
2053 |
Note the following general points:
|
sl@0
|
2054 |
- If reallocation fails, the content of the original cell is preserved.
|
sl@0
|
2055 |
- The resulting size of the re-allocated cell may be rounded up to a value
|
sl@0
|
2056 |
greater than aSize, but is guaranteed to be not less than aSize.
|
sl@0
|
2057 |
|
sl@0
|
2058 |
@param aCell A pointer to the cell to be reallocated. This may be NULL.
|
sl@0
|
2059 |
|
sl@0
|
2060 |
@param aSize The new size of the cell. This may be bigger or smaller than the
|
sl@0
|
2061 |
size of the original cell. The value can also be zero, but this is
|
sl@0
|
2062 |
interpreted as a request for a cell of minimum size; the net
|
sl@0
|
2063 |
effect is the same as if the caller had explicitly requested
|
sl@0
|
2064 |
a cell of minimum size.
|
sl@0
|
2065 |
Note that the minimum size of a heap cell is device dependent.
|
sl@0
|
2066 |
|
sl@0
|
2067 |
@param aMode Flags controlling the reallocation. The only bit which has any
|
sl@0
|
2068 |
effect on this function is that defined by the enumeration
|
sl@0
|
2069 |
ENeverMove of the enum RAllocator::TReAllocMode.
|
sl@0
|
2070 |
If this is set, then any successful reallocation guarantees not
|
sl@0
|
2071 |
to have changed the start address of the cell.
|
sl@0
|
2072 |
By default, this parameter is zero.
|
sl@0
|
2073 |
|
sl@0
|
2074 |
@return A pointer to the reallocated cell. This may be the same as the original
|
sl@0
|
2075 |
pointer supplied through aCell.
|
sl@0
|
2076 |
|
sl@0
|
2077 |
@panic USER 42, if aCell is not NULL, and does not point to a valid cell.
|
sl@0
|
2078 |
@panic USER 47, if the maximum unsigned value of aSize is greater
|
sl@0
|
2079 |
than or equal to KMaxTInt/2. For example,
|
sl@0
|
2080 |
calling ReAlloc(someptr,-1) raises this panic.
|
sl@0
|
2081 |
|
sl@0
|
2082 |
@see RAllocator::TReAllocMode
|
sl@0
|
2083 |
*/
|
sl@0
|
2084 |
{
|
sl@0
|
2085 |
|
sl@0
|
2086 |
return GetHeap()->ReAllocL(aCell, aSize, aMode);
|
sl@0
|
2087 |
}
|
sl@0
|
2088 |
|
sl@0
|
2089 |
|
sl@0
|
2090 |
|
sl@0
|
2091 |
|
sl@0
|
2092 |
EXPORT_C RAllocator& User::Allocator()
|
sl@0
|
2093 |
/**
|
sl@0
|
2094 |
Gets the current thread's default current heap.
|
sl@0
|
2095 |
|
sl@0
|
2096 |
@return The current heap.
|
sl@0
|
2097 |
*/
|
sl@0
|
2098 |
{
|
sl@0
|
2099 |
|
sl@0
|
2100 |
return *GetHeap();
|
sl@0
|
2101 |
}
|
sl@0
|
2102 |
|
sl@0
|
2103 |
|
sl@0
|
2104 |
|
sl@0
|
2105 |
|
sl@0
|
2106 |
EXPORT_C TInt User::AllocSize(TInt &aTotalAllocSize)
|
sl@0
|
2107 |
/**
|
sl@0
|
2108 |
Gets the total number of cells allocated on the current thread's default heap,
|
sl@0
|
2109 |
and the total space allocated to them.
|
sl@0
|
2110 |
|
sl@0
|
2111 |
@param aTotalAllocSize On return, contains the total space allocated to
|
sl@0
|
2112 |
the cells.
|
sl@0
|
2113 |
|
sl@0
|
2114 |
@return The number of cells currently allocated on the current thread's heap.
|
sl@0
|
2115 |
*/
|
sl@0
|
2116 |
{
|
sl@0
|
2117 |
|
sl@0
|
2118 |
return(GetHeap()->AllocSize(aTotalAllocSize));
|
sl@0
|
2119 |
}
|
sl@0
|
2120 |
|
sl@0
|
2121 |
|
sl@0
|
2122 |
|
sl@0
|
2123 |
|
sl@0
|
2124 |
EXPORT_C TInt User::CountAllocCells()
|
sl@0
|
2125 |
/**
|
sl@0
|
2126 |
Gets the total number of cells allocated on the current thread's default heap.
|
sl@0
|
2127 |
|
sl@0
|
2128 |
|
sl@0
|
2129 |
@return The number of cells allocated on the current thread's default user heap.
|
sl@0
|
2130 |
*/
|
sl@0
|
2131 |
{
|
sl@0
|
2132 |
return(GetHeap()->Count());
|
sl@0
|
2133 |
}
|
sl@0
|
2134 |
|
sl@0
|
2135 |
|
sl@0
|
2136 |
|
sl@0
|
2137 |
|
sl@0
|
2138 |
EXPORT_C TInt User::CountAllocCells(TInt &aFreeCount)
|
sl@0
|
2139 |
/**
|
sl@0
|
2140 |
Gets the the total number of cells allocated, and the number of free cells,
|
sl@0
|
2141 |
on the current thread's default heap.
|
sl@0
|
2142 |
|
sl@0
|
2143 |
@param aFreeCount On return, contains the number of free cells
|
sl@0
|
2144 |
on the current thread's default heap.
|
sl@0
|
2145 |
|
sl@0
|
2146 |
@return The number of cells allocated on the current thread's default heap.
|
sl@0
|
2147 |
*/
|
sl@0
|
2148 |
{
|
sl@0
|
2149 |
|
sl@0
|
2150 |
return(GetHeap()->Count(aFreeCount));
|
sl@0
|
2151 |
}
|
sl@0
|
2152 |
|
sl@0
|
2153 |
|
sl@0
|
2154 |
|
sl@0
|
2155 |
|
sl@0
|
2156 |
EXPORT_C RAllocator* User::SwitchAllocator(RAllocator* aA)
|
sl@0
|
2157 |
/**
|
sl@0
|
2158 |
Changes the current thread's heap.
|
sl@0
|
2159 |
|
sl@0
|
2160 |
@param aA A pointer to the new heap handle.
|
sl@0
|
2161 |
|
sl@0
|
2162 |
@return A pointer to the old heap handle.
|
sl@0
|
2163 |
*/
|
sl@0
|
2164 |
{
|
sl@0
|
2165 |
|
sl@0
|
2166 |
#ifdef __USERSIDE_THREAD_DATA__
|
sl@0
|
2167 |
// Just cache the pointer user-side. We still need to let the kernel know what's going on so
|
sl@0
|
2168 |
// the heap can be cleaned up correctly later.
|
sl@0
|
2169 |
LocalThreadData()->iHeap=aA;
|
sl@0
|
2170 |
#endif
|
sl@0
|
2171 |
return Exec::HeapSwitch(aA);
|
sl@0
|
2172 |
}
|
sl@0
|
2173 |
|
sl@0
|
2174 |
// The suffix table
|
sl@0
|
2175 |
const TText16* const __DefaultDateSuffixTable[KMaxSuffixes] =
|
sl@0
|
2176 |
{
|
sl@0
|
2177 |
_S16("st"),_S16("nd"),_S16("rd"),_S16("th"),_S16("th"),
|
sl@0
|
2178 |
_S16("th"),_S16("th"),_S16("th"),_S16("th"),_S16("th"),
|
sl@0
|
2179 |
_S16("th"),_S16("th"),_S16("th"),_S16("th"),_S16("th"),
|
sl@0
|
2180 |
_S16("th"),_S16("th"),_S16("th"),_S16("th"),_S16("th"),
|
sl@0
|
2181 |
_S16("st"),_S16("nd"),_S16("rd"),_S16("th"),_S16("th"),
|
sl@0
|
2182 |
_S16("th"),_S16("th"),_S16("th"),_S16("th"),_S16("th"),
|
sl@0
|
2183 |
_S16("st")
|
sl@0
|
2184 |
};
|
sl@0
|
2185 |
|
sl@0
|
2186 |
// The day names
|
sl@0
|
2187 |
const TText16* const __DefaultDayTable[KMaxDays] =
|
sl@0
|
2188 |
{
|
sl@0
|
2189 |
_S16("Monday"),
|
sl@0
|
2190 |
_S16("Tuesday"),
|
sl@0
|
2191 |
_S16("Wednesday"),
|
sl@0
|
2192 |
_S16("Thursday"),
|
sl@0
|
2193 |
_S16("Friday"),
|
sl@0
|
2194 |
_S16("Saturday"),
|
sl@0
|
2195 |
_S16("Sunday")
|
sl@0
|
2196 |
};
|
sl@0
|
2197 |
|
sl@0
|
2198 |
// The abbreviated day names
|
sl@0
|
2199 |
const TText16* const __DefaultDayAbbTable[KMaxDays] =
|
sl@0
|
2200 |
{
|
sl@0
|
2201 |
_S16("Mon"),
|
sl@0
|
2202 |
_S16("Tue"),
|
sl@0
|
2203 |
_S16("Wed"),
|
sl@0
|
2204 |
_S16("Thu"),
|
sl@0
|
2205 |
_S16("Fri"),
|
sl@0
|
2206 |
_S16("Sat"),
|
sl@0
|
2207 |
_S16("Sun")
|
sl@0
|
2208 |
};
|
sl@0
|
2209 |
|
sl@0
|
2210 |
// The month names
|
sl@0
|
2211 |
const TText16* const __DefaultMonthTable[KMaxMonths] =
|
sl@0
|
2212 |
{
|
sl@0
|
2213 |
_S16("January"),
|
sl@0
|
2214 |
_S16("February"),
|
sl@0
|
2215 |
_S16("March"),
|
sl@0
|
2216 |
_S16("April"),
|
sl@0
|
2217 |
_S16("May"),
|
sl@0
|
2218 |
_S16("June"),
|
sl@0
|
2219 |
_S16("July"),
|
sl@0
|
2220 |
_S16("August"),
|
sl@0
|
2221 |
_S16("September"),
|
sl@0
|
2222 |
_S16("October"),
|
sl@0
|
2223 |
_S16("November"),
|
sl@0
|
2224 |
_S16("December")
|
sl@0
|
2225 |
};
|
sl@0
|
2226 |
|
sl@0
|
2227 |
// The abbreviated month names
|
sl@0
|
2228 |
const TText16* const __DefaultMonthAbbTable[KMaxMonths] =
|
sl@0
|
2229 |
{
|
sl@0
|
2230 |
_S16("Jan"),
|
sl@0
|
2231 |
_S16("Feb"),
|
sl@0
|
2232 |
_S16("Mar"),
|
sl@0
|
2233 |
_S16("Apr"),
|
sl@0
|
2234 |
_S16("May"),
|
sl@0
|
2235 |
_S16("Jun"),
|
sl@0
|
2236 |
_S16("Jul"),
|
sl@0
|
2237 |
_S16("Aug"),
|
sl@0
|
2238 |
_S16("Sep"),
|
sl@0
|
2239 |
_S16("Oct"),
|
sl@0
|
2240 |
_S16("Nov"),
|
sl@0
|
2241 |
_S16("Dec")
|
sl@0
|
2242 |
};
|
sl@0
|
2243 |
|
sl@0
|
2244 |
// The am/pm strings
|
sl@0
|
2245 |
const TText16* const __DefaultAmPmTable[KMaxAmPms] =
|
sl@0
|
2246 |
{
|
sl@0
|
2247 |
_S16("am"),
|
sl@0
|
2248 |
_S16("pm")
|
sl@0
|
2249 |
};
|
sl@0
|
2250 |
|
sl@0
|
2251 |
const TText16* const __DefaultLMsgTable[ELocaleMessages_LastMsg] =
|
sl@0
|
2252 |
{
|
sl@0
|
2253 |
// Fileserver
|
sl@0
|
2254 |
_S16("Retry"), // Button 1
|
sl@0
|
2255 |
_S16("Stop"), // Button 2
|
sl@0
|
2256 |
_S16("Put the disk back"), // Put the card back - line1
|
sl@0
|
2257 |
_S16("or data will be lost"), // Put the card back - line2
|
sl@0
|
2258 |
_S16("Batteries too low"), // Low power - line1
|
sl@0
|
2259 |
_S16("Cannot complete write to disk"), // Low power - line2
|
sl@0
|
2260 |
_S16("Disk error - cannot complete write"), // Disk error - line1
|
sl@0
|
2261 |
_S16("Retry or data will be lost"), // Disk error - line2
|
sl@0
|
2262 |
// SoundDriver
|
sl@0
|
2263 |
_S16("Chimes"), // Chimes
|
sl@0
|
2264 |
_S16("Rings"), // Rings
|
sl@0
|
2265 |
_S16("Signal"), // Signal
|
sl@0
|
2266 |
// MediaDriver diskname (max 16 chars)
|
sl@0
|
2267 |
_S16("Internal"), // Internal
|
sl@0
|
2268 |
_S16("External(01)"), // External(01)
|
sl@0
|
2269 |
_S16("External(02)"), // External(02)
|
sl@0
|
2270 |
_S16("External(03)"), // External(03)
|
sl@0
|
2271 |
_S16("External(04)"), // External(04)
|
sl@0
|
2272 |
_S16("External(05)"), // External(05)
|
sl@0
|
2273 |
_S16("External(06)"), // External(06)
|
sl@0
|
2274 |
_S16("External(07)"), // External(07)
|
sl@0
|
2275 |
_S16("External(08)"), // External(08)
|
sl@0
|
2276 |
// MediaDriver socketname (max 16 chars)
|
sl@0
|
2277 |
_S16("Socket(01)"), // Socket(01)
|
sl@0
|
2278 |
_S16("Socket(02)"), // Socket(02)
|
sl@0
|
2279 |
_S16("Socket(03)"), // Socket(03)
|
sl@0
|
2280 |
_S16("Socket(04)") // Socket(04)
|
sl@0
|
2281 |
};
|
sl@0
|
2282 |
|
sl@0
|
2283 |
LOCAL_C void LocaleLanguageGet(SLocaleLanguage& locale)
|
sl@0
|
2284 |
{
|
sl@0
|
2285 |
TPckg<SLocaleLanguage> localeLanguageBuf(locale);
|
sl@0
|
2286 |
TInt r = RProperty::Get(KUidSystemCategory, KLocaleLanguageKey, localeLanguageBuf);
|
sl@0
|
2287 |
__ASSERT_DEBUG(r == KErrNone || r == KErrNotFound, Panic(EBadLocaleParameter));
|
sl@0
|
2288 |
if(r == KErrNotFound)
|
sl@0
|
2289 |
{
|
sl@0
|
2290 |
locale.iLanguage = ELangEnglish;
|
sl@0
|
2291 |
locale.iDateSuffixTable = (const TText16*)__DefaultDateSuffixTable;
|
sl@0
|
2292 |
locale.iDayTable = (const TText16*)__DefaultDayTable;
|
sl@0
|
2293 |
locale.iDayAbbTable = (const TText16*)__DefaultDayAbbTable;
|
sl@0
|
2294 |
locale.iMonthTable = (const TText16*)__DefaultMonthTable;
|
sl@0
|
2295 |
locale.iMonthAbbTable = (const TText16*)__DefaultMonthAbbTable;
|
sl@0
|
2296 |
locale.iAmPmTable = (const TText16*)__DefaultAmPmTable;
|
sl@0
|
2297 |
locale.iMsgTable = (const TText16* const*)__DefaultLMsgTable;
|
sl@0
|
2298 |
}
|
sl@0
|
2299 |
}
|
sl@0
|
2300 |
|
sl@0
|
2301 |
LOCAL_C void LocaleSettingsGet(SLocaleLocaleSettings& locale)
|
sl@0
|
2302 |
{
|
sl@0
|
2303 |
TPckg<SLocaleLocaleSettings> localeSettingsBuf(locale);
|
sl@0
|
2304 |
TInt r = RProperty::Get(KUidSystemCategory, KLocaleDataExtraKey, localeSettingsBuf);
|
sl@0
|
2305 |
__ASSERT_DEBUG(r == KErrNone || r == KErrNotFound, Panic(EBadLocaleParameter));
|
sl@0
|
2306 |
if(r == KErrNotFound)
|
sl@0
|
2307 |
{
|
sl@0
|
2308 |
Mem::Copy(&locale.iCurrencySymbol[0], _S16("\x00a3"), sizeof(TText16) << 2);
|
sl@0
|
2309 |
locale.iLocaleExtraSettingsDllPtr = NULL;
|
sl@0
|
2310 |
}
|
sl@0
|
2311 |
}
|
sl@0
|
2312 |
|
sl@0
|
2313 |
LOCAL_C void LocaleTimeDateFormatGet(SLocaleTimeDateFormat& locale)
|
sl@0
|
2314 |
{
|
sl@0
|
2315 |
TPckg<SLocaleTimeDateFormat> localeTimeDateFormatBuf(locale);
|
sl@0
|
2316 |
TInt r = RProperty::Get(KUidSystemCategory, KLocaleTimeDateFormatKey, localeTimeDateFormatBuf);
|
sl@0
|
2317 |
__ASSERT_DEBUG(r == KErrNone || r == KErrNotFound, Panic(EBadLocaleParameter));
|
sl@0
|
2318 |
if(r == KErrNotFound)
|
sl@0
|
2319 |
{
|
sl@0
|
2320 |
Mem::Copy(&locale.iShortDateFormatSpec[0], _S16("%F%*D/%*M/%Y"), sizeof(TText16) * 13);
|
sl@0
|
2321 |
Mem::Copy(&locale.iLongDateFormatSpec[0], _S16("%F%*D%X %N %Y"), sizeof(TText16) * 14);
|
sl@0
|
2322 |
Mem::Copy(&locale.iTimeFormatSpec[0], _S16("%F%*I:%T:%S %*A"), sizeof(TText16) * 16);
|
sl@0
|
2323 |
locale.iLocaleTimeDateFormatDllPtr = NULL;
|
sl@0
|
2324 |
}
|
sl@0
|
2325 |
}
|
sl@0
|
2326 |
|
sl@0
|
2327 |
EXPORT_C void TDayName::Set(TDay aDay)
|
sl@0
|
2328 |
/**
|
sl@0
|
2329 |
Re-retrieves the current locale's text for the specified day of the week.
|
sl@0
|
2330 |
|
sl@0
|
2331 |
@param aDay Identifies the day of the week.
|
sl@0
|
2332 |
|
sl@0
|
2333 |
@panic USER 184, if the specified day is outside the permitted range.
|
sl@0
|
2334 |
*/
|
sl@0
|
2335 |
{
|
sl@0
|
2336 |
|
sl@0
|
2337 |
__ASSERT_ALWAYS(aDay>=EMonday && aDay<=ESunday,Panic(EBadLocaleParameter));
|
sl@0
|
2338 |
SLocaleLanguage localeLanguage;
|
sl@0
|
2339 |
LocaleLanguageGet(localeLanguage);
|
sl@0
|
2340 |
Copy((reinterpret_cast<const TText* const*>(localeLanguage.iDayTable))[aDay]);
|
sl@0
|
2341 |
}
|
sl@0
|
2342 |
|
sl@0
|
2343 |
|
sl@0
|
2344 |
|
sl@0
|
2345 |
|
sl@0
|
2346 |
EXPORT_C void TDayNameAbb::Set(TDay aDay)
|
sl@0
|
2347 |
/**
|
sl@0
|
2348 |
Re-retrieves the current locale's abbreviated text for the specified day of
|
sl@0
|
2349 |
the week.
|
sl@0
|
2350 |
|
sl@0
|
2351 |
@param aDay Identifies the day of the week.
|
sl@0
|
2352 |
|
sl@0
|
2353 |
@panic USER 184, if the specified day is outside the permitted range.
|
sl@0
|
2354 |
*/
|
sl@0
|
2355 |
{
|
sl@0
|
2356 |
|
sl@0
|
2357 |
__ASSERT_ALWAYS(aDay>=EMonday && aDay<=ESunday,Panic(EBadLocaleParameter));
|
sl@0
|
2358 |
SLocaleLanguage localeLanguage;
|
sl@0
|
2359 |
LocaleLanguageGet(localeLanguage);
|
sl@0
|
2360 |
Copy((reinterpret_cast<const TText* const*>(localeLanguage.iDayAbbTable))[aDay]);
|
sl@0
|
2361 |
}
|
sl@0
|
2362 |
|
sl@0
|
2363 |
|
sl@0
|
2364 |
|
sl@0
|
2365 |
|
sl@0
|
2366 |
EXPORT_C void TMonthName::Set(TMonth aMonth)
|
sl@0
|
2367 |
/**
|
sl@0
|
2368 |
Re-retrieves the current locale's text for the specified month.
|
sl@0
|
2369 |
|
sl@0
|
2370 |
@param aMonth Identifies the month.
|
sl@0
|
2371 |
|
sl@0
|
2372 |
@panic USER 184, if the specified month is outside the permitted range.
|
sl@0
|
2373 |
*/
|
sl@0
|
2374 |
{
|
sl@0
|
2375 |
|
sl@0
|
2376 |
__ASSERT_ALWAYS(aMonth>=EJanuary && aMonth<=EDecember,Panic(EBadLocaleParameter));
|
sl@0
|
2377 |
SLocaleLanguage localeLanguage;
|
sl@0
|
2378 |
LocaleLanguageGet(localeLanguage);
|
sl@0
|
2379 |
Copy((reinterpret_cast<const TText* const*>(localeLanguage.iMonthTable))[aMonth]);
|
sl@0
|
2380 |
}
|
sl@0
|
2381 |
|
sl@0
|
2382 |
|
sl@0
|
2383 |
|
sl@0
|
2384 |
|
sl@0
|
2385 |
EXPORT_C void TMonthNameAbb::Set(TMonth aMonth)
|
sl@0
|
2386 |
/**
|
sl@0
|
2387 |
Re-retrieves the current locale's abbreviated text for the specified month.
|
sl@0
|
2388 |
|
sl@0
|
2389 |
@param aMonth Identifies the month.
|
sl@0
|
2390 |
|
sl@0
|
2391 |
@panic USER 184, if the specified month is outside the permitted range.
|
sl@0
|
2392 |
*/
|
sl@0
|
2393 |
{
|
sl@0
|
2394 |
|
sl@0
|
2395 |
__ASSERT_ALWAYS(aMonth>=EJanuary && aMonth<=EDecember,Panic(EBadLocaleParameter));
|
sl@0
|
2396 |
SLocaleLanguage localeLanguage;
|
sl@0
|
2397 |
LocaleLanguageGet(localeLanguage);
|
sl@0
|
2398 |
Copy((reinterpret_cast<const TText* const*>(localeLanguage.iMonthAbbTable))[aMonth]);
|
sl@0
|
2399 |
}
|
sl@0
|
2400 |
|
sl@0
|
2401 |
|
sl@0
|
2402 |
|
sl@0
|
2403 |
|
sl@0
|
2404 |
EXPORT_C void TDateSuffix::Set(TInt aSuffix)
|
sl@0
|
2405 |
/**
|
sl@0
|
2406 |
Re-retrieves the current locale's date suffix text for the specified day of
|
sl@0
|
2407 |
the month.
|
sl@0
|
2408 |
|
sl@0
|
2409 |
@param aSuffix A value identifying the day of the month. The value can
|
sl@0
|
2410 |
range from 0 to 30 so that the first day of the month is
|
sl@0
|
2411 |
identified by 0, the second day by 1 etc.
|
sl@0
|
2412 |
|
sl@0
|
2413 |
@panic USER 69, if aDateSuffix is outside the range 0 to 30.
|
sl@0
|
2414 |
*/
|
sl@0
|
2415 |
{
|
sl@0
|
2416 |
|
sl@0
|
2417 |
__ASSERT_ALWAYS(aSuffix>=0 && aSuffix<KMaxSuffixes,Panic(ETLoclSuffixOutOfRange));
|
sl@0
|
2418 |
SLocaleLanguage localeLanguage;
|
sl@0
|
2419 |
LocaleLanguageGet(localeLanguage);
|
sl@0
|
2420 |
Copy((reinterpret_cast<const TText* const*>(localeLanguage.iDateSuffixTable))[aSuffix]);
|
sl@0
|
2421 |
}
|
sl@0
|
2422 |
|
sl@0
|
2423 |
|
sl@0
|
2424 |
|
sl@0
|
2425 |
|
sl@0
|
2426 |
EXPORT_C void TAmPmName::Set(TAmPm aSelector)
|
sl@0
|
2427 |
/**
|
sl@0
|
2428 |
Re-retrieves the current locale's text for identifying time before or after
|
sl@0
|
2429 |
noon as identified by the specified selector.
|
sl@0
|
2430 |
|
sl@0
|
2431 |
@param aSelector The am/pm selector.
|
sl@0
|
2432 |
|
sl@0
|
2433 |
@panic USER 69, if aDateSuffix is outside the range 0 to 30.
|
sl@0
|
2434 |
*/
|
sl@0
|
2435 |
{
|
sl@0
|
2436 |
|
sl@0
|
2437 |
__ASSERT_ALWAYS(aSelector==EAm || aSelector==EPm,Panic(ETLoclSuffixOutOfRange));
|
sl@0
|
2438 |
SLocaleLanguage localeLanguage;
|
sl@0
|
2439 |
LocaleLanguageGet(localeLanguage);
|
sl@0
|
2440 |
Copy((reinterpret_cast<const TText* const*>(localeLanguage.iAmPmTable))[aSelector]);
|
sl@0
|
2441 |
}
|
sl@0
|
2442 |
|
sl@0
|
2443 |
|
sl@0
|
2444 |
|
sl@0
|
2445 |
|
sl@0
|
2446 |
EXPORT_C void TCurrencySymbol::Set()
|
sl@0
|
2447 |
/**
|
sl@0
|
2448 |
Re-retrieves the current locale's currency symbol(s).
|
sl@0
|
2449 |
*/
|
sl@0
|
2450 |
{
|
sl@0
|
2451 |
SLocaleLocaleSettings locale;
|
sl@0
|
2452 |
LocaleSettingsGet(locale);
|
sl@0
|
2453 |
Copy(&locale.iCurrencySymbol[0]);
|
sl@0
|
2454 |
}
|
sl@0
|
2455 |
|
sl@0
|
2456 |
|
sl@0
|
2457 |
|
sl@0
|
2458 |
|
sl@0
|
2459 |
EXPORT_C void TShortDateFormatSpec::Set()
|
sl@0
|
2460 |
/**
|
sl@0
|
2461 |
Sets the contents of the short date format specification from the system-wide
|
sl@0
|
2462 |
settings.
|
sl@0
|
2463 |
*/
|
sl@0
|
2464 |
{
|
sl@0
|
2465 |
SLocaleTimeDateFormat locale;
|
sl@0
|
2466 |
LocaleTimeDateFormatGet(locale);
|
sl@0
|
2467 |
Copy(&locale.iShortDateFormatSpec[0]);
|
sl@0
|
2468 |
}
|
sl@0
|
2469 |
|
sl@0
|
2470 |
|
sl@0
|
2471 |
|
sl@0
|
2472 |
|
sl@0
|
2473 |
EXPORT_C void TLongDateFormatSpec::Set()
|
sl@0
|
2474 |
/**
|
sl@0
|
2475 |
Sets the contents of the long date format specification from the system-wide
|
sl@0
|
2476 |
settings.
|
sl@0
|
2477 |
*/
|
sl@0
|
2478 |
{
|
sl@0
|
2479 |
SLocaleTimeDateFormat locale;
|
sl@0
|
2480 |
LocaleTimeDateFormatGet(locale);
|
sl@0
|
2481 |
Copy(&locale.iLongDateFormatSpec[0]);
|
sl@0
|
2482 |
}
|
sl@0
|
2483 |
|
sl@0
|
2484 |
|
sl@0
|
2485 |
|
sl@0
|
2486 |
|
sl@0
|
2487 |
EXPORT_C void TTimeFormatSpec::Set()
|
sl@0
|
2488 |
/**
|
sl@0
|
2489 |
Sets the contents of the time string format specification from the system-wide
|
sl@0
|
2490 |
settings.
|
sl@0
|
2491 |
*/
|
sl@0
|
2492 |
{
|
sl@0
|
2493 |
SLocaleTimeDateFormat locale;
|
sl@0
|
2494 |
LocaleTimeDateFormatGet(locale);
|
sl@0
|
2495 |
Copy(&locale.iTimeFormatSpec[0]);
|
sl@0
|
2496 |
}
|
sl@0
|
2497 |
|
sl@0
|
2498 |
|
sl@0
|
2499 |
|
sl@0
|
2500 |
|
sl@0
|
2501 |
EXPORT_C TInt User::SetCurrencySymbol(const TDesC& aSymbol)
|
sl@0
|
2502 |
/**
|
sl@0
|
2503 |
Sets the system wide currency symbol.
|
sl@0
|
2504 |
|
sl@0
|
2505 |
On successful return from this function, a call to the Set() member function
|
sl@0
|
2506 |
of a TCurrencySymbol object fetches the new currency symbol.
|
sl@0
|
2507 |
|
sl@0
|
2508 |
@capability WriteDeviceData
|
sl@0
|
2509 |
|
sl@0
|
2510 |
@param aSymbol A reference to the descriptor containing the currency symbol
|
sl@0
|
2511 |
to be set.
|
sl@0
|
2512 |
|
sl@0
|
2513 |
@return KErrNone if successful, otherwise one of the other system wide error codes.
|
sl@0
|
2514 |
|
sl@0
|
2515 |
@panic USER 119, if the length of aSymbol is greater than KMaxCurrencySymbol.
|
sl@0
|
2516 |
|
sl@0
|
2517 |
@see TCurrencySymbol
|
sl@0
|
2518 |
@see TCurrencySymbol::Set()
|
sl@0
|
2519 |
@see KMaxCurrencySymbol
|
sl@0
|
2520 |
*/
|
sl@0
|
2521 |
{
|
sl@0
|
2522 |
|
sl@0
|
2523 |
TExtendedLocale locale;
|
sl@0
|
2524 |
return locale.SetCurrencySymbol(aSymbol);
|
sl@0
|
2525 |
}
|
sl@0
|
2526 |
|
sl@0
|
2527 |
|
sl@0
|
2528 |
|
sl@0
|
2529 |
|
sl@0
|
2530 |
EXPORT_C TLanguage User::Language()
|
sl@0
|
2531 |
/**
|
sl@0
|
2532 |
Gets the language of the current locale.
|
sl@0
|
2533 |
|
sl@0
|
2534 |
@return One of the TLanguage enumerators identifying the language of the
|
sl@0
|
2535 |
current locale.
|
sl@0
|
2536 |
*/
|
sl@0
|
2537 |
{
|
sl@0
|
2538 |
|
sl@0
|
2539 |
SLocaleLanguage localeLanguage;
|
sl@0
|
2540 |
LocaleLanguageGet(localeLanguage);
|
sl@0
|
2541 |
return localeLanguage.iLanguage;
|
sl@0
|
2542 |
}
|
sl@0
|
2543 |
|
sl@0
|
2544 |
EXPORT_C TRegionCode User::RegionCode()
|
sl@0
|
2545 |
{
|
sl@0
|
2546 |
#ifdef SYMBIAN_DISTINCT_LOCALE_MODEL
|
sl@0
|
2547 |
TLocale locale;
|
sl@0
|
2548 |
locale.Refresh();
|
sl@0
|
2549 |
return static_cast<TRegionCode>(locale.RegionCode());
|
sl@0
|
2550 |
#else
|
sl@0
|
2551 |
return static_cast<TRegionCode>(0);
|
sl@0
|
2552 |
#endif
|
sl@0
|
2553 |
}
|
sl@0
|
2554 |
|
sl@0
|
2555 |
|
sl@0
|
2556 |
EXPORT_C TLocale::TLocale()
|
sl@0
|
2557 |
/**
|
sl@0
|
2558 |
Default constructor.
|
sl@0
|
2559 |
|
sl@0
|
2560 |
It constructs the object with the system's locale settings.
|
sl@0
|
2561 |
|
sl@0
|
2562 |
A single copy of the locale information is maintained by the system. This
|
sl@0
|
2563 |
copy may be refreshed under application control with TLocale::Refresh(), and
|
sl@0
|
2564 |
the settings may be saved to the system with TLocale::Set(). However, the
|
sl@0
|
2565 |
settings are never updated by the system apart from under application control.
|
sl@0
|
2566 |
This enables applications to guarantee that consistent locale information
|
sl@0
|
2567 |
is used.
|
sl@0
|
2568 |
|
sl@0
|
2569 |
@see TLocale::Refresh()
|
sl@0
|
2570 |
@see TLocale::Set()
|
sl@0
|
2571 |
*/
|
sl@0
|
2572 |
{
|
sl@0
|
2573 |
|
sl@0
|
2574 |
Refresh();
|
sl@0
|
2575 |
}
|
sl@0
|
2576 |
|
sl@0
|
2577 |
|
sl@0
|
2578 |
const TUint8 __DefaultDateSeparator[KMaxDateSeparators] = { 0, '/', '/', 0 };
|
sl@0
|
2579 |
const TUint8 __DefaultTimeSeparator[KMaxTimeSeparators] = { 0, ':', ':', 0 };
|
sl@0
|
2580 |
|
sl@0
|
2581 |
void TLocale::SetDefaults()
|
sl@0
|
2582 |
{
|
sl@0
|
2583 |
iCountryCode = 44;
|
sl@0
|
2584 |
iUniversalTimeOffset = 0;
|
sl@0
|
2585 |
iDateFormat = EDateEuropean;
|
sl@0
|
2586 |
iTimeFormat = ETime12;
|
sl@0
|
2587 |
iCurrencySymbolPosition = ELocaleBefore;
|
sl@0
|
2588 |
iCurrencySpaceBetween = EFalse;
|
sl@0
|
2589 |
iCurrencyDecimalPlaces = 2;
|
sl@0
|
2590 |
iNegativeCurrencyFormat = TNegativeCurrencyFormat(EFalse);
|
sl@0
|
2591 |
iCurrencyTriadsAllowed = ETrue;
|
sl@0
|
2592 |
iThousandsSeparator = ',';
|
sl@0
|
2593 |
iDecimalSeparator = '.';
|
sl@0
|
2594 |
TInt i=0;
|
sl@0
|
2595 |
for(; i<KMaxDateSeparators; i++)
|
sl@0
|
2596 |
iDateSeparator[i] = __DefaultDateSeparator[i];
|
sl@0
|
2597 |
for(i=0; i<KMaxTimeSeparators; i++)
|
sl@0
|
2598 |
iTimeSeparator[i] = __DefaultTimeSeparator[i];
|
sl@0
|
2599 |
iAmPmSymbolPosition = ELocaleAfter;
|
sl@0
|
2600 |
iAmPmSpaceBetween = ETrue;
|
sl@0
|
2601 |
iHomeDaylightSavingZone = EDstEuropean;
|
sl@0
|
2602 |
iWorkDays = 0x1f;
|
sl@0
|
2603 |
iStartOfWeek = EMonday;
|
sl@0
|
2604 |
iClockFormat = EClockAnalog;
|
sl@0
|
2605 |
iUnitsGeneral = EUnitsImperial;
|
sl@0
|
2606 |
iUnitsDistanceLong = EUnitsImperial;
|
sl@0
|
2607 |
iUnitsDistanceShort = EUnitsImperial;
|
sl@0
|
2608 |
iExtraNegativeCurrencyFormatFlags = 0;
|
sl@0
|
2609 |
iLanguageDowngrade[0] = ELangNone;
|
sl@0
|
2610 |
iLanguageDowngrade[1] = ELangNone;
|
sl@0
|
2611 |
iLanguageDowngrade[2] = ELangNone;
|
sl@0
|
2612 |
#ifdef SYMBIAN_DISTINCT_LOCALE_MODEL
|
sl@0
|
2613 |
iRegionCode = ERegGBR;
|
sl@0
|
2614 |
#else
|
sl@0
|
2615 |
iRegionCode = 0;
|
sl@0
|
2616 |
#endif
|
sl@0
|
2617 |
iDigitType = EDigitTypeWestern;
|
sl@0
|
2618 |
iDeviceTimeState = TDeviceTimeState(EDeviceUserTime);
|
sl@0
|
2619 |
}
|
sl@0
|
2620 |
|
sl@0
|
2621 |
EXPORT_C void TLocale::Refresh()
|
sl@0
|
2622 |
/**
|
sl@0
|
2623 |
Refreshes the contents of this object with the system's locale settings.
|
sl@0
|
2624 |
*/
|
sl@0
|
2625 |
{
|
sl@0
|
2626 |
|
sl@0
|
2627 |
|
sl@0
|
2628 |
TPckg<TLocale> localeDataBuf(*this);
|
sl@0
|
2629 |
TInt r = RProperty::Get(KUidSystemCategory, KLocaleDataKey, localeDataBuf);
|
sl@0
|
2630 |
__ASSERT_DEBUG(r == KErrNone || r == KErrNotFound, Panic(EBadLocaleParameter));
|
sl@0
|
2631 |
if(r == KErrNone)
|
sl@0
|
2632 |
{
|
sl@0
|
2633 |
iUniversalTimeOffset = Exec::UTCOffset();
|
sl@0
|
2634 |
iDaylightSaving = 0;
|
sl@0
|
2635 |
}
|
sl@0
|
2636 |
else if(r == KErrNotFound)
|
sl@0
|
2637 |
{
|
sl@0
|
2638 |
SetDefaults();
|
sl@0
|
2639 |
}
|
sl@0
|
2640 |
}
|
sl@0
|
2641 |
|
sl@0
|
2642 |
|
sl@0
|
2643 |
|
sl@0
|
2644 |
|
sl@0
|
2645 |
EXPORT_C TInt TLocale::Set() const
|
sl@0
|
2646 |
/**
|
sl@0
|
2647 |
Transfers the locale settings from this object to the system. Note that
|
sl@0
|
2648 |
the timezone offset and daylight savings flags are ignored as setting these
|
sl@0
|
2649 |
through TLocale is no longer supported.
|
sl@0
|
2650 |
|
sl@0
|
2651 |
After this function has been called, other applications may use the new
|
sl@0
|
2652 |
settings for newly-constructed TLocale objects,
|
sl@0
|
2653 |
or if they use TLocale::Refresh(), to refresh their settings from
|
sl@0
|
2654 |
the system copy.
|
sl@0
|
2655 |
|
sl@0
|
2656 |
@capability WriteDeviceData
|
sl@0
|
2657 |
|
sl@0
|
2658 |
@return KErrNone if successful, otherwise one of the other system wide error codes.
|
sl@0
|
2659 |
|
sl@0
|
2660 |
@see TLocale::Refresh()
|
sl@0
|
2661 |
*/
|
sl@0
|
2662 |
{
|
sl@0
|
2663 |
TPckg<TLocale> localeDataBuf(*this);
|
sl@0
|
2664 |
TInt r = RProperty::Set(KUidSystemCategory, KLocaleDataKey, localeDataBuf);
|
sl@0
|
2665 |
if(r == KErrNone)
|
sl@0
|
2666 |
{
|
sl@0
|
2667 |
Exec::NotifyChanges(EChangesLocale);
|
sl@0
|
2668 |
}
|
sl@0
|
2669 |
return r;
|
sl@0
|
2670 |
}
|
sl@0
|
2671 |
|
sl@0
|
2672 |
TInt TExtendedLocale::DoLoadLocale(const TDesC& aLocaleDllName, TLibraryFunction* aExportList)
|
sl@0
|
2673 |
{
|
sl@0
|
2674 |
RLoader loader;
|
sl@0
|
2675 |
TInt r = loader.LoadLocale(aLocaleDllName, aExportList);
|
sl@0
|
2676 |
return r;
|
sl@0
|
2677 |
}
|
sl@0
|
2678 |
|
sl@0
|
2679 |
#ifdef SYMBIAN_DISTINCT_LOCALE_MODEL
|
sl@0
|
2680 |
void TExtendedLocale::DoUpdateLanguageSettingsV2(TLibraryFunction* aExportList)
|
sl@0
|
2681 |
{
|
sl@0
|
2682 |
iLocale.iDigitType = EDigitTypeWestern;
|
sl@0
|
2683 |
iLocale.iLanguageDowngrade[0] = ELangNone;
|
sl@0
|
2684 |
iLocale.iLanguageDowngrade[1] = ELangNone;
|
sl@0
|
2685 |
iLocale.iLanguageDowngrade[2] = ELangNone;
|
sl@0
|
2686 |
|
sl@0
|
2687 |
iLanguageSettings.iLanguage = (TLanguage)aExportList[FnLanguageV2]();
|
sl@0
|
2688 |
iLanguageSettings.iDateSuffixTable = (const TText*)aExportList[FnDateSuffixTableV2]();
|
sl@0
|
2689 |
iLanguageSettings.iDayTable = (const TText*)aExportList[FnDayTableV2]();
|
sl@0
|
2690 |
iLanguageSettings.iDayAbbTable = (const TText*)aExportList[FnDayAbbTableV2]();
|
sl@0
|
2691 |
iLanguageSettings.iMonthTable = (const TText*)aExportList[FnMonthTableV2]();
|
sl@0
|
2692 |
iLanguageSettings.iMonthAbbTable = (const TText*)aExportList[FnMonthAbbTableV2]();
|
sl@0
|
2693 |
iLanguageSettings.iAmPmTable = (const TText*)aExportList[FnAmPmTableV2]();
|
sl@0
|
2694 |
iLanguageSettings.iMsgTable = (const TText16* const*)aExportList[FnMsgTableV2]();
|
sl@0
|
2695 |
|
sl@0
|
2696 |
TDigitType digitType = (TDigitType)aExportList[FnDigitTypeV2]();
|
sl@0
|
2697 |
iLocale.SetDigitType(digitType);
|
sl@0
|
2698 |
|
sl@0
|
2699 |
TLanguage* languageDowngrade = (TLanguage*)aExportList[FnLanguageDowngradeTableV2]();
|
sl@0
|
2700 |
iLocale.SetLanguageDowngrade(0,*(languageDowngrade));
|
sl@0
|
2701 |
iLocale.SetLanguageDowngrade(1,*(languageDowngrade+1));
|
sl@0
|
2702 |
iLocale.SetLanguageDowngrade(2,*(languageDowngrade+2));
|
sl@0
|
2703 |
}
|
sl@0
|
2704 |
|
sl@0
|
2705 |
void TExtendedLocale::DoUpdateLocaleSettingsV2(TLibraryFunction* aExportList)
|
sl@0
|
2706 |
{
|
sl@0
|
2707 |
|
sl@0
|
2708 |
Mem::Copy(&iLocaleExtraSettings.iCurrencySymbol[0], (const TAny*)aExportList[FnCurrencySymbolV2](), sizeof(TText) * (KMaxCurrencySymbol+1));
|
sl@0
|
2709 |
iLocaleExtraSettings.iLocaleExtraSettingsDllPtr = (TAny*)aExportList[FnCurrencySymbolV2]();
|
sl@0
|
2710 |
Mem::Copy(&iLocaleTimeDateFormat.iShortDateFormatSpec[0], (const TAny*)aExportList[FnShortDateFormatSpecV2](), sizeof(TText) * (KMaxShortDateFormatSpec+1));
|
sl@0
|
2711 |
Mem::Copy(&iLocaleTimeDateFormat.iLongDateFormatSpec[0], (const TAny*)aExportList[FnLongDateFormatSpecV2](), sizeof(TText) * (KMaxLongDateFormatSpec+1)) ;
|
sl@0
|
2712 |
Mem::Copy(&iLocaleTimeDateFormat.iTimeFormatSpec[0], (const TAny*)aExportList[FnTimeFormatSpecV2](), sizeof(TText) * (KMaxTimeFormatSpec+1));
|
sl@0
|
2713 |
iLocaleTimeDateFormat.iLocaleTimeDateFormatDllPtr = (TAny*)aExportList[FnCurrencySymbolV2]();
|
sl@0
|
2714 |
|
sl@0
|
2715 |
iLocale.iExtraNegativeCurrencyFormatFlags=0x80000000;
|
sl@0
|
2716 |
|
sl@0
|
2717 |
typedef void (*TLibFn)(TLocale*);
|
sl@0
|
2718 |
((TLibFn)aExportList[FnLocaleDataV2])(&iLocale);
|
sl@0
|
2719 |
|
sl@0
|
2720 |
if (iLocale.iExtraNegativeCurrencyFormatFlags&0x80000000)
|
sl@0
|
2721 |
iLocale.iExtraNegativeCurrencyFormatFlags=0;
|
sl@0
|
2722 |
}
|
sl@0
|
2723 |
#endif
|
sl@0
|
2724 |
|
sl@0
|
2725 |
void TExtendedLocale::DoUpdateLanguageSettings(TLibraryFunction* aExportList)
|
sl@0
|
2726 |
{
|
sl@0
|
2727 |
iLanguageSettings.iLanguage = (TLanguage)aExportList[FnLanguage]();
|
sl@0
|
2728 |
iLanguageSettings.iDateSuffixTable = (const TText*)aExportList[FnDateSuffixTable]();
|
sl@0
|
2729 |
iLanguageSettings.iDayTable = (const TText*)aExportList[FnDayTable]();
|
sl@0
|
2730 |
iLanguageSettings.iDayAbbTable = (const TText*)aExportList[FnDayAbbTable]();
|
sl@0
|
2731 |
iLanguageSettings.iMonthTable = (const TText*)aExportList[FnMonthTable]();
|
sl@0
|
2732 |
iLanguageSettings.iMonthAbbTable = (const TText*)aExportList[FnMonthAbbTable]();
|
sl@0
|
2733 |
iLanguageSettings.iAmPmTable = (const TText*)aExportList[FnAmPmTable]();
|
sl@0
|
2734 |
iLanguageSettings.iMsgTable = (const TText16* const*)aExportList[FnMsgTable]();
|
sl@0
|
2735 |
}
|
sl@0
|
2736 |
|
sl@0
|
2737 |
void TExtendedLocale::DoUpdateLocaleSettings(TLibraryFunction* aExportList)
|
sl@0
|
2738 |
{
|
sl@0
|
2739 |
Mem::Copy(&iLocaleExtraSettings.iCurrencySymbol[0], (const TAny*)aExportList[FnCurrencySymbol](), sizeof(TText) * (KMaxCurrencySymbol+1));
|
sl@0
|
2740 |
iLocaleExtraSettings.iLocaleExtraSettingsDllPtr = (TAny*)aExportList[FnDateSuffixTable]();
|
sl@0
|
2741 |
}
|
sl@0
|
2742 |
|
sl@0
|
2743 |
void TExtendedLocale::DoUpdateTimeDateFormat(TLibraryFunction* aExportList)
|
sl@0
|
2744 |
{
|
sl@0
|
2745 |
Mem::Copy(&iLocaleTimeDateFormat.iShortDateFormatSpec[0], (const TAny*)aExportList[FnShortDateFormatSpec](), sizeof(TText) * (KMaxShortDateFormatSpec+1));
|
sl@0
|
2746 |
Mem::Copy(&iLocaleTimeDateFormat.iLongDateFormatSpec[0], (const TAny*)aExportList[FnLongDateFormatSpec](), sizeof(TText) * (KMaxLongDateFormatSpec+1)) ;
|
sl@0
|
2747 |
Mem::Copy(&iLocaleTimeDateFormat.iTimeFormatSpec[0], (const TAny*)aExportList[FnTimeFormatSpec](), sizeof(TText) * (KMaxTimeFormatSpec+1));
|
sl@0
|
2748 |
iLocaleTimeDateFormat.iLocaleTimeDateFormatDllPtr = (TAny*)aExportList[FnDateSuffixTable]();
|
sl@0
|
2749 |
}
|
sl@0
|
2750 |
|
sl@0
|
2751 |
/**
|
sl@0
|
2752 |
Default constructor.
|
sl@0
|
2753 |
|
sl@0
|
2754 |
It constructs an empty object
|
sl@0
|
2755 |
|
sl@0
|
2756 |
This is an empty copy of TExtendedLocale. To get the system locale you can
|
sl@0
|
2757 |
use TExtendedLocale::LoadSystemSettings. The current settings may be saved to the system
|
sl@0
|
2758 |
with TLocale::SaveSystemSettings().
|
sl@0
|
2759 |
|
sl@0
|
2760 |
@see TExtendedLocale::LoadSystemSettings
|
sl@0
|
2761 |
@see TExtendedLocale::SaveSystemSettings
|
sl@0
|
2762 |
*/
|
sl@0
|
2763 |
EXPORT_C TExtendedLocale::TExtendedLocale()
|
sl@0
|
2764 |
: iLocale(0)
|
sl@0
|
2765 |
{
|
sl@0
|
2766 |
|
sl@0
|
2767 |
Mem::FillZ(&iLanguageSettings, sizeof(TExtendedLocale) - sizeof(TLocale));
|
sl@0
|
2768 |
}
|
sl@0
|
2769 |
|
sl@0
|
2770 |
/**
|
sl@0
|
2771 |
Load system wide locale settings
|
sl@0
|
2772 |
|
sl@0
|
2773 |
It initialises this TExtendedLocale with the system wide locale settings.
|
sl@0
|
2774 |
The settings stored in the TExtendedLocale are overwritten with the system
|
sl@0
|
2775 |
wide locale.
|
sl@0
|
2776 |
|
sl@0
|
2777 |
@see TExtendedLocale::SaveSystemSettings
|
sl@0
|
2778 |
*/
|
sl@0
|
2779 |
EXPORT_C void TExtendedLocale::LoadSystemSettings()
|
sl@0
|
2780 |
{
|
sl@0
|
2781 |
LocaleLanguageGet(iLanguageSettings);
|
sl@0
|
2782 |
LocaleSettingsGet(iLocaleExtraSettings);
|
sl@0
|
2783 |
LocaleTimeDateFormatGet(iLocaleTimeDateFormat);
|
sl@0
|
2784 |
iDefaultCharSet = GetLocaleCharSet();
|
sl@0
|
2785 |
iPreferredCharSet = GetLocalePreferredCharSet();
|
sl@0
|
2786 |
iLocale.Refresh();
|
sl@0
|
2787 |
}
|
sl@0
|
2788 |
|
sl@0
|
2789 |
/**
|
sl@0
|
2790 |
Make the current locale information system wide
|
sl@0
|
2791 |
|
sl@0
|
2792 |
It overwrites the system wide locale information with the locale information
|
sl@0
|
2793 |
stored in this TExtendedLocale.
|
sl@0
|
2794 |
This will generate a notification for system locale changes.
|
sl@0
|
2795 |
In case of an error, the locale might be in an unconsistent state.
|
sl@0
|
2796 |
|
sl@0
|
2797 |
@capability WriteDeviceData
|
sl@0
|
2798 |
|
sl@0
|
2799 |
@return KErrNone if successful, otherwise one of the other system wide error codes.
|
sl@0
|
2800 |
*/
|
sl@0
|
2801 |
EXPORT_C TInt TExtendedLocale::SaveSystemSettings()
|
sl@0
|
2802 |
{
|
sl@0
|
2803 |
|
sl@0
|
2804 |
TPckg<SLocaleLanguage> localeLanguageBuf(iLanguageSettings);
|
sl@0
|
2805 |
TInt r = RProperty::Set(KUidSystemCategory, KLocaleLanguageKey, localeLanguageBuf);
|
sl@0
|
2806 |
if(r != KErrNone)
|
sl@0
|
2807 |
return r;
|
sl@0
|
2808 |
|
sl@0
|
2809 |
TPckg<SLocaleLocaleSettings> localeSettingsBuf(iLocaleExtraSettings);
|
sl@0
|
2810 |
r = RProperty::Set(KUidSystemCategory, KLocaleDataExtraKey, localeSettingsBuf);
|
sl@0
|
2811 |
if(r != KErrNone)
|
sl@0
|
2812 |
return r;
|
sl@0
|
2813 |
|
sl@0
|
2814 |
TPckg<SLocaleTimeDateFormat> localeTimeDateFormatBuf(iLocaleTimeDateFormat);
|
sl@0
|
2815 |
r = RProperty::Set(KUidSystemCategory, KLocaleTimeDateFormatKey, localeTimeDateFormatBuf);
|
sl@0
|
2816 |
if(r != KErrNone)
|
sl@0
|
2817 |
return r;
|
sl@0
|
2818 |
|
sl@0
|
2819 |
r = Exec::SetGlobalUserData(ELocaleDefaultCharSet, (TInt)iDefaultCharSet);
|
sl@0
|
2820 |
if(r != KErrNone)
|
sl@0
|
2821 |
return r;
|
sl@0
|
2822 |
|
sl@0
|
2823 |
r = Exec::SetGlobalUserData(ELocalePreferredCharSet, (TInt)iPreferredCharSet);
|
sl@0
|
2824 |
|
sl@0
|
2825 |
if(r == KErrNone)
|
sl@0
|
2826 |
{
|
sl@0
|
2827 |
iLocale.Set();
|
sl@0
|
2828 |
}
|
sl@0
|
2829 |
|
sl@0
|
2830 |
return r;
|
sl@0
|
2831 |
}
|
sl@0
|
2832 |
|
sl@0
|
2833 |
#ifdef SYMBIAN_DISTINCT_LOCALE_MODEL
|
sl@0
|
2834 |
TInt TExtendedLocale::CheckLocaleDllName(const TDesC& aLocaleDllName, TInt& languageID)
|
sl@0
|
2835 |
{
|
sl@0
|
2836 |
languageID = 0;
|
sl@0
|
2837 |
|
sl@0
|
2838 |
if(aLocaleDllName.Find(KLoc) == KErrNotFound)
|
sl@0
|
2839 |
return KErrNotFound;
|
sl@0
|
2840 |
|
sl@0
|
2841 |
TInt len = aLocaleDllName.Length() - 6; //6 is the length of KLoc.
|
sl@0
|
2842 |
TPtrC ptr = aLocaleDllName.Right(len);
|
sl@0
|
2843 |
for(TInt i =0; i< len; i++)
|
sl@0
|
2844 |
{
|
sl@0
|
2845 |
if(ptr[i] >= '0' && ptr[i] <= '9')
|
sl@0
|
2846 |
{
|
sl@0
|
2847 |
languageID = languageID*10 + (ptr[i] - '0');
|
sl@0
|
2848 |
}
|
sl@0
|
2849 |
else
|
sl@0
|
2850 |
{
|
sl@0
|
2851 |
languageID = 0;
|
sl@0
|
2852 |
return KErrNotFound;
|
sl@0
|
2853 |
}
|
sl@0
|
2854 |
}
|
sl@0
|
2855 |
return KErrNone;
|
sl@0
|
2856 |
}
|
sl@0
|
2857 |
|
sl@0
|
2858 |
//add file extension, such as "elocl_lan" will be "elocl_lan.012"
|
sl@0
|
2859 |
void TExtendedLocale::AddExtension(TDes& aFileName, TInt aExtension)
|
sl@0
|
2860 |
{
|
sl@0
|
2861 |
if (aExtension < 10)
|
sl@0
|
2862 |
{
|
sl@0
|
2863 |
aFileName.AppendNum(0);
|
sl@0
|
2864 |
aFileName.AppendNum(0);
|
sl@0
|
2865 |
aFileName.AppendNum(aExtension);
|
sl@0
|
2866 |
}
|
sl@0
|
2867 |
else if (aExtension < 100)
|
sl@0
|
2868 |
{
|
sl@0
|
2869 |
aFileName.AppendNum(0);
|
sl@0
|
2870 |
aFileName.AppendNum(aExtension);
|
sl@0
|
2871 |
}
|
sl@0
|
2872 |
else
|
sl@0
|
2873 |
{
|
sl@0
|
2874 |
aFileName.AppendNum(aExtension);
|
sl@0
|
2875 |
}
|
sl@0
|
2876 |
return;
|
sl@0
|
2877 |
}
|
sl@0
|
2878 |
#endif
|
sl@0
|
2879 |
|
sl@0
|
2880 |
/**
|
sl@0
|
2881 |
Loads a locale Dll and get the locale information
|
sl@0
|
2882 |
|
sl@0
|
2883 |
It loads a locale DLL and it initialises the contents of this TExtendedLocale
|
sl@0
|
2884 |
with the locale information stored in the DLL. The locale information is only
|
sl@0
|
2885 |
stored in this TExtendedLocale. If you want to set the system wide settings with
|
sl@0
|
2886 |
the locale information in the DLL, you can call TExtendedLocale::SaveSystemSettings
|
sl@0
|
2887 |
after calling this function.
|
sl@0
|
2888 |
|
sl@0
|
2889 |
@param aLocaleDllName The name of the locale DLL to be loaded
|
sl@0
|
2890 |
@return KErrNone if successful, system wide error if not
|
sl@0
|
2891 |
|
sl@0
|
2892 |
@see TExtendedLocale::SaveSystemSettings
|
sl@0
|
2893 |
*/
|
sl@0
|
2894 |
EXPORT_C TInt TExtendedLocale::LoadLocale(const TDesC& aLocaleDllName)
|
sl@0
|
2895 |
{
|
sl@0
|
2896 |
#ifdef SYMBIAN_DISTINCT_LOCALE_MODEL
|
sl@0
|
2897 |
TLibraryFunction data[KNumLocaleExports];
|
sl@0
|
2898 |
TInt r = DoLoadLocale(aLocaleDllName, &data[0]);
|
sl@0
|
2899 |
if(r == KErrNone)
|
sl@0
|
2900 |
{
|
sl@0
|
2901 |
iLocale.iExtraNegativeCurrencyFormatFlags=0x80000000;
|
sl@0
|
2902 |
iLocale.iLanguageDowngrade[0] = ELangNone;
|
sl@0
|
2903 |
iLocale.iLanguageDowngrade[1] = ELangNone;
|
sl@0
|
2904 |
iLocale.iLanguageDowngrade[2] = ELangNone;
|
sl@0
|
2905 |
iLocale.iDigitType = EDigitTypeWestern;
|
sl@0
|
2906 |
|
sl@0
|
2907 |
typedef void (*TLibFn)(TLocale*);
|
sl@0
|
2908 |
((TLibFn)data[FnLocaleData])(&iLocale);
|
sl@0
|
2909 |
|
sl@0
|
2910 |
//Locale daylightsavings unchanged - we have travelled through space, not time
|
sl@0
|
2911 |
if (iLocale.iExtraNegativeCurrencyFormatFlags&0x80000000)
|
sl@0
|
2912 |
iLocale.iExtraNegativeCurrencyFormatFlags=0;
|
sl@0
|
2913 |
|
sl@0
|
2914 |
DoUpdateLanguageSettings(&data[0]);
|
sl@0
|
2915 |
DoUpdateLocaleSettings(&data[0]);
|
sl@0
|
2916 |
DoUpdateTimeDateFormat(&data[0]);
|
sl@0
|
2917 |
|
sl@0
|
2918 |
iPreferredCharSet = (const LCharSet*)data[FnCharSet]();
|
sl@0
|
2919 |
iDefaultCharSet = iPreferredCharSet;
|
sl@0
|
2920 |
return r;
|
sl@0
|
2921 |
}
|
sl@0
|
2922 |
else if(r == KErrNotFound)
|
sl@0
|
2923 |
{
|
sl@0
|
2924 |
TInt lan = 0;
|
sl@0
|
2925 |
TInt reg = 0;
|
sl@0
|
2926 |
TInt col = 0;
|
sl@0
|
2927 |
TInt languageID = -1;
|
sl@0
|
2928 |
TInt err = CheckLocaleDllName(aLocaleDllName, languageID);
|
sl@0
|
2929 |
if (err != KErrNone)
|
sl@0
|
2930 |
return err;
|
sl@0
|
2931 |
|
sl@0
|
2932 |
TInt i = 0;
|
sl@0
|
2933 |
while (i < KLocMapLength) //binary search later
|
sl@0
|
2934 |
{
|
sl@0
|
2935 |
if ((LocaleMapping[i].iOldLocaleId) == languageID)
|
sl@0
|
2936 |
{
|
sl@0
|
2937 |
lan = LocaleMapping[i].iNewLocaleID[0];
|
sl@0
|
2938 |
reg = LocaleMapping[i].iNewLocaleID[1];
|
sl@0
|
2939 |
col = LocaleMapping[i].iNewLocaleID[2];
|
sl@0
|
2940 |
break;
|
sl@0
|
2941 |
}
|
sl@0
|
2942 |
i++;
|
sl@0
|
2943 |
}
|
sl@0
|
2944 |
if(i == KLocMapLength)
|
sl@0
|
2945 |
return KErrNotFound;
|
sl@0
|
2946 |
|
sl@0
|
2947 |
TBuf<15> lanptr = KFindLan();
|
sl@0
|
2948 |
TBuf<15> regptr = KFindReg();
|
sl@0
|
2949 |
TBuf<15> colptr = KFindCol();
|
sl@0
|
2950 |
AddExtension(lanptr, lan);
|
sl@0
|
2951 |
AddExtension(regptr, reg);
|
sl@0
|
2952 |
AddExtension(colptr, col);
|
sl@0
|
2953 |
err = LoadLocale(lanptr, regptr, colptr);
|
sl@0
|
2954 |
|
sl@0
|
2955 |
return err;
|
sl@0
|
2956 |
}
|
sl@0
|
2957 |
return r;
|
sl@0
|
2958 |
#else
|
sl@0
|
2959 |
TLibraryFunction data[KNumLocaleExports];
|
sl@0
|
2960 |
TInt r = DoLoadLocale(aLocaleDllName, &data[0]);
|
sl@0
|
2961 |
if(r == KErrNone)
|
sl@0
|
2962 |
{
|
sl@0
|
2963 |
iLocale.iExtraNegativeCurrencyFormatFlags=0x80000000;
|
sl@0
|
2964 |
iLocale.iLanguageDowngrade[0] = ELangNone;
|
sl@0
|
2965 |
iLocale.iLanguageDowngrade[1] = ELangNone;
|
sl@0
|
2966 |
iLocale.iLanguageDowngrade[2] = ELangNone;
|
sl@0
|
2967 |
iLocale.iDigitType = EDigitTypeWestern;
|
sl@0
|
2968 |
|
sl@0
|
2969 |
typedef void (*TLibFn)(TLocale*);
|
sl@0
|
2970 |
((TLibFn)data[FnLocaleData])(&iLocale);
|
sl@0
|
2971 |
|
sl@0
|
2972 |
//Locale daylightsavings unchanged - we have travelled through space, not time
|
sl@0
|
2973 |
if (iLocale.iExtraNegativeCurrencyFormatFlags&0x80000000)
|
sl@0
|
2974 |
iLocale.iExtraNegativeCurrencyFormatFlags=0;
|
sl@0
|
2975 |
|
sl@0
|
2976 |
DoUpdateLanguageSettings(&data[0]);
|
sl@0
|
2977 |
DoUpdateLocaleSettings(&data[0]);
|
sl@0
|
2978 |
DoUpdateTimeDateFormat(&data[0]);
|
sl@0
|
2979 |
|
sl@0
|
2980 |
iPreferredCharSet = (const LCharSet*)data[FnCharSet]();
|
sl@0
|
2981 |
iDefaultCharSet = iPreferredCharSet;
|
sl@0
|
2982 |
}
|
sl@0
|
2983 |
return r;
|
sl@0
|
2984 |
#endif
|
sl@0
|
2985 |
}
|
sl@0
|
2986 |
|
sl@0
|
2987 |
/**
|
sl@0
|
2988 |
Loads locale data from three locale dlls, which are language, region, and collation locale dlls
|
sl@0
|
2989 |
|
sl@0
|
2990 |
It loads three locale DLLs and it initialises the contents of this TExtendedLocale
|
sl@0
|
2991 |
with the locale information stored in the DLLs. The locale information is only
|
sl@0
|
2992 |
stored in this TExtendedLocale. If you want to set the system wide settings with
|
sl@0
|
2993 |
the locale information in the DLL, you can call TExtendedLocale::SaveSystemSettings
|
sl@0
|
2994 |
after calling this function.
|
sl@0
|
2995 |
|
sl@0
|
2996 |
@param aLanguageLocaleDllName The name of the language locale DLL to be loaded
|
sl@0
|
2997 |
@param aRegionLocaleDllName The name of the region locale DLL to be loaded
|
sl@0
|
2998 |
@param aCollationLocaleDllName The name of the collation locale DLL to be loaded
|
sl@0
|
2999 |
|
sl@0
|
3000 |
@return KErrNone if successful, system wide error if not
|
sl@0
|
3001 |
|
sl@0
|
3002 |
@see TExtendedLocale::SaveSystemSettings
|
sl@0
|
3003 |
*/
|
sl@0
|
3004 |
#ifdef SYMBIAN_DISTINCT_LOCALE_MODEL
|
sl@0
|
3005 |
EXPORT_C TInt TExtendedLocale::LoadLocale(const TDesC& aLanguageLocaleDllName,
|
sl@0
|
3006 |
const TDesC& aRegionLocaleDllName,
|
sl@0
|
3007 |
const TDesC& aCollationLocaleDllName)
|
sl@0
|
3008 |
{
|
sl@0
|
3009 |
|
sl@0
|
3010 |
TInt err = LoadLocaleAspect(aLanguageLocaleDllName);
|
sl@0
|
3011 |
if(err != KErrNone)
|
sl@0
|
3012 |
return err;
|
sl@0
|
3013 |
|
sl@0
|
3014 |
err = LoadLocaleAspect(aRegionLocaleDllName);
|
sl@0
|
3015 |
if(err != KErrNone)
|
sl@0
|
3016 |
return err;
|
sl@0
|
3017 |
|
sl@0
|
3018 |
err = LoadLocaleAspect(aCollationLocaleDllName);
|
sl@0
|
3019 |
if(err != KErrNone)
|
sl@0
|
3020 |
return err;
|
sl@0
|
3021 |
|
sl@0
|
3022 |
return err;
|
sl@0
|
3023 |
}
|
sl@0
|
3024 |
#else
|
sl@0
|
3025 |
EXPORT_C TInt TExtendedLocale::LoadLocale(const TDesC& /*aLanguageLocaleDllName*/,
|
sl@0
|
3026 |
const TDesC& /*aRegionLocaleDllName*/,
|
sl@0
|
3027 |
const TDesC& /*aCollationLocaleDllName*/)
|
sl@0
|
3028 |
{
|
sl@0
|
3029 |
return KErrNotSupported;
|
sl@0
|
3030 |
}
|
sl@0
|
3031 |
#endif
|
sl@0
|
3032 |
|
sl@0
|
3033 |
/**
|
sl@0
|
3034 |
Loads a DLL and get some locale information
|
sl@0
|
3035 |
|
sl@0
|
3036 |
It loads the specified locale DLL and depending on the aAspectGroup it overwrites
|
sl@0
|
3037 |
locale information in this TExtendedLocale with the locale information stored in the
|
sl@0
|
3038 |
DLL. aAspectGroup is a bitmap of TLocaleAspect values specifying what to be overwritten.
|
sl@0
|
3039 |
The locale information is only stored in this TExtendedLocale. If you want to set the
|
sl@0
|
3040 |
system wide settings with the locale information in the DLL, you can call
|
sl@0
|
3041 |
TExtendedLocale::SaveSystemSettings after calling this function.
|
sl@0
|
3042 |
|
sl@0
|
3043 |
@param aAspectGroup A bitmap of TLocaleAspect values specifying what to be overwritten in
|
sl@0
|
3044 |
this TExtendedLocale. (eg.: ELocaleLanguageSettings | ELocaleTimeDateSettings)
|
sl@0
|
3045 |
@param aLocaleDllName The name of the locale DLL to be loaded
|
sl@0
|
3046 |
|
sl@0
|
3047 |
@return KErrNone if the method is successful, a system wide error code if not
|
sl@0
|
3048 |
|
sl@0
|
3049 |
@see TLocaleAspect
|
sl@0
|
3050 |
@see TExtendedLocale::SaveSystemSettings
|
sl@0
|
3051 |
*/
|
sl@0
|
3052 |
EXPORT_C TInt TExtendedLocale::LoadLocaleAspect(TUint aAspectGroup, const TDesC& aLocaleDllName)
|
sl@0
|
3053 |
{
|
sl@0
|
3054 |
#ifdef SYMBIAN_DISTINCT_LOCALE_MODEL
|
sl@0
|
3055 |
TLibraryFunction data[KNumLocaleExports];
|
sl@0
|
3056 |
TInt r = DoLoadLocale(aLocaleDllName, &data[0]);
|
sl@0
|
3057 |
if(r == KErrNone)
|
sl@0
|
3058 |
{
|
sl@0
|
3059 |
if(aAspectGroup & ELocaleLanguageSettings)
|
sl@0
|
3060 |
{
|
sl@0
|
3061 |
DoUpdateLanguageSettings(&data[0]);
|
sl@0
|
3062 |
}
|
sl@0
|
3063 |
if(aAspectGroup & ELocaleCollateSetting)
|
sl@0
|
3064 |
{
|
sl@0
|
3065 |
iPreferredCharSet = (const LCharSet*)data[FnCharSet]();
|
sl@0
|
3066 |
iDefaultCharSet = iPreferredCharSet;
|
sl@0
|
3067 |
}
|
sl@0
|
3068 |
if(aAspectGroup & ELocaleLocaleSettings)
|
sl@0
|
3069 |
{
|
sl@0
|
3070 |
DoUpdateLocaleSettings(&data[0]);
|
sl@0
|
3071 |
}
|
sl@0
|
3072 |
if(aAspectGroup & ELocaleTimeDateSettings)
|
sl@0
|
3073 |
{
|
sl@0
|
3074 |
DoUpdateTimeDateFormat(&data[0]);
|
sl@0
|
3075 |
}
|
sl@0
|
3076 |
return r;
|
sl@0
|
3077 |
}
|
sl@0
|
3078 |
|
sl@0
|
3079 |
else if (r == KErrNotFound)
|
sl@0
|
3080 |
{
|
sl@0
|
3081 |
TInt lan = 0;
|
sl@0
|
3082 |
TInt reg = 0;
|
sl@0
|
3083 |
TInt col = 0;
|
sl@0
|
3084 |
TInt languageID = -1;
|
sl@0
|
3085 |
TInt err = CheckLocaleDllName(aLocaleDllName, languageID);
|
sl@0
|
3086 |
if(err != KErrNone)
|
sl@0
|
3087 |
return err;
|
sl@0
|
3088 |
|
sl@0
|
3089 |
TInt i = 0;
|
sl@0
|
3090 |
while (i < KLocMapLength)
|
sl@0
|
3091 |
{
|
sl@0
|
3092 |
if ((LocaleMapping[i].iOldLocaleId) == languageID)
|
sl@0
|
3093 |
{
|
sl@0
|
3094 |
lan = LocaleMapping[i].iNewLocaleID[0];
|
sl@0
|
3095 |
reg = LocaleMapping[i].iNewLocaleID[1];
|
sl@0
|
3096 |
col = LocaleMapping[i].iNewLocaleID[2];
|
sl@0
|
3097 |
break;
|
sl@0
|
3098 |
}
|
sl@0
|
3099 |
i++;
|
sl@0
|
3100 |
}
|
sl@0
|
3101 |
if(i == KLocMapLength)
|
sl@0
|
3102 |
return KErrNotFound;
|
sl@0
|
3103 |
|
sl@0
|
3104 |
TBuf<15> lanptr = KFindLan();
|
sl@0
|
3105 |
TBuf<15> regptr = KFindReg();
|
sl@0
|
3106 |
TBuf<15> colptr = KFindCol();
|
sl@0
|
3107 |
AddExtension(lanptr, lan);
|
sl@0
|
3108 |
AddExtension(regptr, reg);
|
sl@0
|
3109 |
AddExtension(colptr, col);
|
sl@0
|
3110 |
|
sl@0
|
3111 |
switch (aAspectGroup)
|
sl@0
|
3112 |
{
|
sl@0
|
3113 |
case ELocaleCollateSetting:
|
sl@0
|
3114 |
{
|
sl@0
|
3115 |
err = LoadLocaleAspect(colptr);
|
sl@0
|
3116 |
break;
|
sl@0
|
3117 |
}
|
sl@0
|
3118 |
case ELocaleLocaleSettings:
|
sl@0
|
3119 |
{
|
sl@0
|
3120 |
err = LoadLocaleAspect(regptr);
|
sl@0
|
3121 |
break;
|
sl@0
|
3122 |
}
|
sl@0
|
3123 |
|
sl@0
|
3124 |
case ELocaleLanguageSettings:
|
sl@0
|
3125 |
{
|
sl@0
|
3126 |
err = LoadLocaleAspect(lanptr);
|
sl@0
|
3127 |
break;
|
sl@0
|
3128 |
}
|
sl@0
|
3129 |
}
|
sl@0
|
3130 |
return err;
|
sl@0
|
3131 |
}
|
sl@0
|
3132 |
|
sl@0
|
3133 |
return r;
|
sl@0
|
3134 |
#else
|
sl@0
|
3135 |
TLibraryFunction data[KNumLocaleExports];
|
sl@0
|
3136 |
TInt r = DoLoadLocale(aLocaleDllName, &data[0]);
|
sl@0
|
3137 |
if(r == KErrNone)
|
sl@0
|
3138 |
{
|
sl@0
|
3139 |
if(aAspectGroup & ELocaleLanguageSettings)
|
sl@0
|
3140 |
{
|
sl@0
|
3141 |
DoUpdateLanguageSettings(&data[0]);
|
sl@0
|
3142 |
}
|
sl@0
|
3143 |
if(aAspectGroup & ELocaleCollateSetting)
|
sl@0
|
3144 |
{
|
sl@0
|
3145 |
iPreferredCharSet = (const LCharSet*)data[FnCharSet]();
|
sl@0
|
3146 |
iDefaultCharSet = iPreferredCharSet;
|
sl@0
|
3147 |
}
|
sl@0
|
3148 |
if(aAspectGroup & ELocaleLocaleSettings)
|
sl@0
|
3149 |
{
|
sl@0
|
3150 |
DoUpdateLocaleSettings(&data[0]);
|
sl@0
|
3151 |
}
|
sl@0
|
3152 |
if(aAspectGroup & ELocaleTimeDateSettings)
|
sl@0
|
3153 |
{
|
sl@0
|
3154 |
DoUpdateTimeDateFormat(&data[0]);
|
sl@0
|
3155 |
}
|
sl@0
|
3156 |
}
|
sl@0
|
3157 |
return r;
|
sl@0
|
3158 |
#endif
|
sl@0
|
3159 |
}
|
sl@0
|
3160 |
|
sl@0
|
3161 |
/**
|
sl@0
|
3162 |
Loads a DLL and get some locale information
|
sl@0
|
3163 |
|
sl@0
|
3164 |
It loads the specified locale DLL, and it overwrites
|
sl@0
|
3165 |
locale information in this TExtendedLocale with the locale information stored in the
|
sl@0
|
3166 |
DLL. The locale information is only stored in this TExtendedLocale. If you want to set the
|
sl@0
|
3167 |
system wide settings with the locale information in the DLL, you can call
|
sl@0
|
3168 |
TExtendedLocale::SaveSystemSettings after calling this function.
|
sl@0
|
3169 |
|
sl@0
|
3170 |
@param aLocaleDllName The name of the locale DLL to be loaded
|
sl@0
|
3171 |
|
sl@0
|
3172 |
@return KErrNone if the method is successful, a system wide error code if not
|
sl@0
|
3173 |
|
sl@0
|
3174 |
@see TExtendedLocale::SaveSystemSettings
|
sl@0
|
3175 |
*/
|
sl@0
|
3176 |
#ifdef SYMBIAN_DISTINCT_LOCALE_MODEL
|
sl@0
|
3177 |
EXPORT_C TInt TExtendedLocale::LoadLocaleAspect(const TDesC& aLocaleDllName)
|
sl@0
|
3178 |
{
|
sl@0
|
3179 |
TLibraryFunction data[KNumLocaleExports];
|
sl@0
|
3180 |
|
sl@0
|
3181 |
TInt result = aLocaleDllName.Find(KFindReg);
|
sl@0
|
3182 |
if(result != KErrNotFound)
|
sl@0
|
3183 |
{
|
sl@0
|
3184 |
result = DoLoadLocale(aLocaleDllName, &data[0]);
|
sl@0
|
3185 |
if(result == KErrNone)
|
sl@0
|
3186 |
{
|
sl@0
|
3187 |
DoUpdateLocaleSettingsV2(&data[0]);
|
sl@0
|
3188 |
return result;
|
sl@0
|
3189 |
}
|
sl@0
|
3190 |
}
|
sl@0
|
3191 |
|
sl@0
|
3192 |
result= aLocaleDllName.Find(KFindLan);
|
sl@0
|
3193 |
if(result != KErrNotFound)
|
sl@0
|
3194 |
{
|
sl@0
|
3195 |
result = DoLoadLocale(aLocaleDllName, &data[0]);
|
sl@0
|
3196 |
if(result == KErrNone)
|
sl@0
|
3197 |
{
|
sl@0
|
3198 |
DoUpdateLanguageSettingsV2(&data[0]);
|
sl@0
|
3199 |
return result;
|
sl@0
|
3200 |
}
|
sl@0
|
3201 |
}
|
sl@0
|
3202 |
|
sl@0
|
3203 |
result = aLocaleDllName.Find(KFindCol);
|
sl@0
|
3204 |
if(result != KErrNotFound)
|
sl@0
|
3205 |
{
|
sl@0
|
3206 |
result = DoLoadLocale(aLocaleDllName, &data[0]);
|
sl@0
|
3207 |
if(result == KErrNone)
|
sl@0
|
3208 |
{
|
sl@0
|
3209 |
iPreferredCharSet = (const LCharSet*)data[1]();
|
sl@0
|
3210 |
iDefaultCharSet = iPreferredCharSet;
|
sl@0
|
3211 |
return result;
|
sl@0
|
3212 |
}
|
sl@0
|
3213 |
}
|
sl@0
|
3214 |
|
sl@0
|
3215 |
return KErrNotFound;
|
sl@0
|
3216 |
}
|
sl@0
|
3217 |
#else
|
sl@0
|
3218 |
EXPORT_C TInt TExtendedLocale::LoadLocaleAspect(const TDesC& /*aLocaleDllName*/)
|
sl@0
|
3219 |
{
|
sl@0
|
3220 |
return KErrNotSupported;
|
sl@0
|
3221 |
}
|
sl@0
|
3222 |
#endif
|
sl@0
|
3223 |
|
sl@0
|
3224 |
/**
|
sl@0
|
3225 |
Sets the currency symbol
|
sl@0
|
3226 |
|
sl@0
|
3227 |
It sets the currency symbol. The maximum lenght for the currency symbol is
|
sl@0
|
3228 |
KMaxCurrencySymbol. Trying to pass a descriptor longer than that, will result
|
sl@0
|
3229 |
in a panic.
|
sl@0
|
3230 |
|
sl@0
|
3231 |
@param aSymbol The new currency symbol
|
sl@0
|
3232 |
|
sl@0
|
3233 |
@panic USER 119, if the length of aSymbol is greater than KMaxCurrencySymbol.
|
sl@0
|
3234 |
|
sl@0
|
3235 |
@capability WriteDeviceData
|
sl@0
|
3236 |
|
sl@0
|
3237 |
@return KErrNone if successful, otherwise one of the other system wide error codes.
|
sl@0
|
3238 |
*/
|
sl@0
|
3239 |
EXPORT_C TInt TExtendedLocale::SetCurrencySymbol(const TDesC &aSymbol)
|
sl@0
|
3240 |
{
|
sl@0
|
3241 |
__ASSERT_ALWAYS(aSymbol.Length()<=KMaxCurrencySymbol,::Panic(ECurrencySymbolOverflow));
|
sl@0
|
3242 |
|
sl@0
|
3243 |
LocaleSettingsGet(iLocaleExtraSettings);
|
sl@0
|
3244 |
Mem::Copy(&iLocaleExtraSettings.iCurrencySymbol[0], aSymbol.Ptr(), aSymbol.Length()*sizeof(TText) );
|
sl@0
|
3245 |
iLocaleExtraSettings.iCurrencySymbol[aSymbol.Length()] = 0;
|
sl@0
|
3246 |
TInt r = RProperty::Set(KUidSystemCategory, KLocaleDataExtraKey, TPckg<SLocaleLocaleSettings>(iLocaleExtraSettings));
|
sl@0
|
3247 |
return r;
|
sl@0
|
3248 |
}
|
sl@0
|
3249 |
|
sl@0
|
3250 |
/**
|
sl@0
|
3251 |
Returns the name of the DLL containing the given bits of locale information
|
sl@0
|
3252 |
|
sl@0
|
3253 |
Given the bits of locale information specified in aLocaleDataSet, it returns the name
|
sl@0
|
3254 |
of the locale DLL storing the information. TExtendedLocale can contain information from
|
sl@0
|
3255 |
different DLLs.
|
sl@0
|
3256 |
|
sl@0
|
3257 |
@param aLocaleDataSet The TLocaleAspect specifying a group of locale properties
|
sl@0
|
3258 |
@param aDllName The descriptor that will contain the name of DLL containing the specifying
|
sl@0
|
3259 |
bits of locale information (valid if the method is successful)
|
sl@0
|
3260 |
|
sl@0
|
3261 |
@return KErrNone if successful, system wide error otherwise
|
sl@0
|
3262 |
*/
|
sl@0
|
3263 |
EXPORT_C TInt TExtendedLocale::GetLocaleDllName(TLocaleAspect aLocaleDataSet, TDes& aDllName)
|
sl@0
|
3264 |
{
|
sl@0
|
3265 |
TBuf8<KMaxFullName> buf;
|
sl@0
|
3266 |
TAny* ptr = 0;
|
sl@0
|
3267 |
switch(aLocaleDataSet)
|
sl@0
|
3268 |
{
|
sl@0
|
3269 |
case ELocaleLanguageSettings:
|
sl@0
|
3270 |
ptr = (TAny*)iLanguageSettings.iDateSuffixTable;
|
sl@0
|
3271 |
break;
|
sl@0
|
3272 |
case ELocaleCollateSetting:
|
sl@0
|
3273 |
ptr = (TAny*)iPreferredCharSet;
|
sl@0
|
3274 |
break;
|
sl@0
|
3275 |
case ELocaleLocaleSettings:
|
sl@0
|
3276 |
ptr = (TAny*)iLocaleExtraSettings.iLocaleExtraSettingsDllPtr;
|
sl@0
|
3277 |
break;
|
sl@0
|
3278 |
case ELocaleTimeDateSettings:
|
sl@0
|
3279 |
ptr = (TAny*)iLocaleTimeDateFormat.iLocaleTimeDateFormatDllPtr;
|
sl@0
|
3280 |
break;
|
sl@0
|
3281 |
}
|
sl@0
|
3282 |
TInt r = Exec::GetModuleNameFromAddress(ptr, buf);
|
sl@0
|
3283 |
if (r == KErrNone)
|
sl@0
|
3284 |
{
|
sl@0
|
3285 |
aDllName.Copy(buf);
|
sl@0
|
3286 |
}
|
sl@0
|
3287 |
return r;
|
sl@0
|
3288 |
}
|
sl@0
|
3289 |
|
sl@0
|
3290 |
/**
|
sl@0
|
3291 |
Get the Currency Symbol from SLocaleLocaleSettings object
|
sl@0
|
3292 |
|
sl@0
|
3293 |
@return TPtrC Pointer holding the Currency Symbol
|
sl@0
|
3294 |
*/
|
sl@0
|
3295 |
EXPORT_C TPtrC TExtendedLocale::GetCurrencySymbol()
|
sl@0
|
3296 |
{
|
sl@0
|
3297 |
TPtrC outCurrencySymbolPtr(iLocaleExtraSettings.iCurrencySymbol);
|
sl@0
|
3298 |
return outCurrencySymbolPtr;
|
sl@0
|
3299 |
}
|
sl@0
|
3300 |
|
sl@0
|
3301 |
/**
|
sl@0
|
3302 |
Get the Long Date Format from SLocaleTimeDateFormat object
|
sl@0
|
3303 |
|
sl@0
|
3304 |
@return TPtrC Pointer holding the Long Date Format
|
sl@0
|
3305 |
*/
|
sl@0
|
3306 |
EXPORT_C TPtrC TExtendedLocale::GetLongDateFormatSpec()
|
sl@0
|
3307 |
{
|
sl@0
|
3308 |
TPtrC outLongDateFormatPtr(iLocaleTimeDateFormat.iLongDateFormatSpec);
|
sl@0
|
3309 |
return outLongDateFormatPtr;
|
sl@0
|
3310 |
}
|
sl@0
|
3311 |
|
sl@0
|
3312 |
/**
|
sl@0
|
3313 |
Get the Short Date Format from SLocaleTimeDateFormat object
|
sl@0
|
3314 |
|
sl@0
|
3315 |
@return TPtrC Pointer holding the Short Date Format
|
sl@0
|
3316 |
*/
|
sl@0
|
3317 |
EXPORT_C TPtrC TExtendedLocale::GetShortDateFormatSpec()
|
sl@0
|
3318 |
{
|
sl@0
|
3319 |
TPtrC outShortDateFormatPtr(iLocaleTimeDateFormat.iShortDateFormatSpec);
|
sl@0
|
3320 |
return outShortDateFormatPtr;
|
sl@0
|
3321 |
}
|
sl@0
|
3322 |
|
sl@0
|
3323 |
/**
|
sl@0
|
3324 |
Get the Time Format from SLocaleTimeDateFormat object
|
sl@0
|
3325 |
|
sl@0
|
3326 |
@return TPtrC Pointer holding the Time Format
|
sl@0
|
3327 |
*/
|
sl@0
|
3328 |
EXPORT_C TPtrC TExtendedLocale::GetTimeFormatSpec()
|
sl@0
|
3329 |
{
|
sl@0
|
3330 |
TPtrC outTimeFormatPtr(iLocaleTimeDateFormat.iTimeFormatSpec);
|
sl@0
|
3331 |
return outTimeFormatPtr;
|
sl@0
|
3332 |
}
|
sl@0
|
3333 |
|
sl@0
|
3334 |
EXPORT_C TInt UserSvr::LocalePropertiesSetDefaults()
|
sl@0
|
3335 |
{
|
sl@0
|
3336 |
_LIT_SECURITY_POLICY_C1(KLocaleWritePolicy,ECapabilityWriteDeviceData);
|
sl@0
|
3337 |
_LIT_SECURITY_POLICY_PASS(KLocaleReadPolicy);
|
sl@0
|
3338 |
|
sl@0
|
3339 |
TInt r = RProperty::Define(KUidSystemCategory, KLocaleLanguageKey, RProperty::EByteArray, KLocaleReadPolicy, KLocaleWritePolicy, sizeof(TPckg<SLocaleLanguage>));
|
sl@0
|
3340 |
if(r != KErrNone && r != KErrAlreadyExists)
|
sl@0
|
3341 |
return r;
|
sl@0
|
3342 |
|
sl@0
|
3343 |
SLocaleLanguage localeLanguage;
|
sl@0
|
3344 |
localeLanguage.iLanguage = ELangEnglish;
|
sl@0
|
3345 |
localeLanguage.iDateSuffixTable = (const TText16*)__DefaultDateSuffixTable;
|
sl@0
|
3346 |
localeLanguage.iDayTable = (const TText16*)__DefaultDayTable;
|
sl@0
|
3347 |
localeLanguage.iDayAbbTable = (const TText16*)__DefaultDayAbbTable;
|
sl@0
|
3348 |
localeLanguage.iMonthTable = (const TText16*)__DefaultMonthTable;
|
sl@0
|
3349 |
localeLanguage.iMonthAbbTable = (const TText16*)__DefaultMonthAbbTable;
|
sl@0
|
3350 |
localeLanguage.iAmPmTable = (const TText16*)__DefaultAmPmTable;
|
sl@0
|
3351 |
localeLanguage.iMsgTable = (const TText16* const*)__DefaultLMsgTable;
|
sl@0
|
3352 |
r = RProperty::Set(KUidSystemCategory, KLocaleLanguageKey, TPckg<SLocaleLanguage>(localeLanguage));
|
sl@0
|
3353 |
if(r != KErrNone)
|
sl@0
|
3354 |
return r;
|
sl@0
|
3355 |
|
sl@0
|
3356 |
r = RProperty::Define(KUidSystemCategory, KLocaleDataKey, RProperty::EByteArray, KLocaleReadPolicy, KLocaleWritePolicy, sizeof(TPckg<TLocale>));
|
sl@0
|
3357 |
if(r != KErrNone && r != KErrAlreadyExists)
|
sl@0
|
3358 |
return r;
|
sl@0
|
3359 |
|
sl@0
|
3360 |
TLocale locale(0);
|
sl@0
|
3361 |
locale.SetDefaults();
|
sl@0
|
3362 |
|
sl@0
|
3363 |
r = RProperty::Set(KUidSystemCategory, KLocaleDataKey, TPckg<TLocale>(locale));
|
sl@0
|
3364 |
if(r != KErrNone)
|
sl@0
|
3365 |
return r;
|
sl@0
|
3366 |
|
sl@0
|
3367 |
r = RProperty::Define(KUidSystemCategory, KLocaleDataExtraKey, RProperty::EByteArray, KLocaleReadPolicy, KLocaleWritePolicy, sizeof(TPckg<SLocaleLocaleSettings>));
|
sl@0
|
3368 |
if(r != KErrNone && r != KErrAlreadyExists)
|
sl@0
|
3369 |
return r;
|
sl@0
|
3370 |
|
sl@0
|
3371 |
SLocaleLocaleSettings localeSettings;
|
sl@0
|
3372 |
Mem::Copy(&localeSettings.iCurrencySymbol[0], _S16("\x00a3"), sizeof(TText16) * 2);
|
sl@0
|
3373 |
|
sl@0
|
3374 |
r = RProperty::Set(KUidSystemCategory, KLocaleDataExtraKey, TPckg<SLocaleLocaleSettings>(localeSettings));
|
sl@0
|
3375 |
if(r != KErrNone)
|
sl@0
|
3376 |
return r;
|
sl@0
|
3377 |
|
sl@0
|
3378 |
r = RProperty::Define(KUidSystemCategory, KLocaleTimeDateFormatKey, RProperty::EByteArray, KLocaleReadPolicy, KLocaleWritePolicy, sizeof(TPckg<SLocaleLocaleSettings>));
|
sl@0
|
3379 |
if(r != KErrNone && r != KErrAlreadyExists)
|
sl@0
|
3380 |
return r;
|
sl@0
|
3381 |
|
sl@0
|
3382 |
SLocaleTimeDateFormat localeTimeDateFormat;
|
sl@0
|
3383 |
Mem::Copy(&localeTimeDateFormat.iShortDateFormatSpec[0], _S16("%F%*D/%*M/%Y"), sizeof(TText16) * 13);
|
sl@0
|
3384 |
Mem::Copy(&localeTimeDateFormat.iLongDateFormatSpec[0], _S16("%F%*D%X %N %Y"), sizeof(TText16) * 14);
|
sl@0
|
3385 |
Mem::Copy(&localeTimeDateFormat.iTimeFormatSpec[0], _S16("%F%*I:%T:%S %*A"), sizeof(TText16) * 16);
|
sl@0
|
3386 |
|
sl@0
|
3387 |
r = RProperty::Set(KUidSystemCategory, KLocaleTimeDateFormatKey, TPckg<SLocaleTimeDateFormat>(localeTimeDateFormat));
|
sl@0
|
3388 |
if(r != KErrNone)
|
sl@0
|
3389 |
return r;
|
sl@0
|
3390 |
|
sl@0
|
3391 |
TInt charSet = (TInt)GetLocaleDefaultCharSet();
|
sl@0
|
3392 |
r = Exec::SetGlobalUserData(ELocaleDefaultCharSet, charSet);
|
sl@0
|
3393 |
if(r != KErrNone)
|
sl@0
|
3394 |
return r;
|
sl@0
|
3395 |
|
sl@0
|
3396 |
r = Exec::SetGlobalUserData(ELocalePreferredCharSet, charSet);
|
sl@0
|
3397 |
|
sl@0
|
3398 |
return r;
|
sl@0
|
3399 |
}
|
sl@0
|
3400 |
|
sl@0
|
3401 |
|
sl@0
|
3402 |
// TOverflowHandler class created to handle the descriptor overflow in TLoacle::FormatCurrency
|
sl@0
|
3403 |
NONSHARABLE_CLASS(TOverflowHandler) : public TDesOverflow
|
sl@0
|
3404 |
{
|
sl@0
|
3405 |
void Overflow(TDes& aDes);
|
sl@0
|
3406 |
};
|
sl@0
|
3407 |
|
sl@0
|
3408 |
void TOverflowHandler::Overflow(TDes&)
|
sl@0
|
3409 |
{
|
sl@0
|
3410 |
Panic(ETDes16Overflow);
|
sl@0
|
3411 |
}
|
sl@0
|
3412 |
|
sl@0
|
3413 |
|
sl@0
|
3414 |
|
sl@0
|
3415 |
|
sl@0
|
3416 |
EXPORT_C void TLocale::FormatCurrency(TDes& aText, TInt aAmount)
|
sl@0
|
3417 |
/**
|
sl@0
|
3418 |
Renders a currency value as text, based on the locale's currency and numeric
|
sl@0
|
3419 |
format settings.
|
sl@0
|
3420 |
|
sl@0
|
3421 |
These settings include the currency symbol, the symbol's position and the
|
sl@0
|
3422 |
way negative values are formatted.
|
sl@0
|
3423 |
|
sl@0
|
3424 |
@param aText On return, contains the currency value as text, formatted
|
sl@0
|
3425 |
according to the locale's currency format settings.
|
sl@0
|
3426 |
@param aAmount The currency value to be formatted.
|
sl@0
|
3427 |
|
sl@0
|
3428 |
@panic USER 11, if aText is not long enough to hold the formatted value.
|
sl@0
|
3429 |
*/
|
sl@0
|
3430 |
{
|
sl@0
|
3431 |
TOverflowHandler overflowHandler;
|
sl@0
|
3432 |
FormatCurrency(aText,overflowHandler,aAmount);
|
sl@0
|
3433 |
}
|
sl@0
|
3434 |
|
sl@0
|
3435 |
|
sl@0
|
3436 |
|
sl@0
|
3437 |
|
sl@0
|
3438 |
EXPORT_C void TLocale::FormatCurrency(TDes& aText, TInt64 aAmount)
|
sl@0
|
3439 |
/**
|
sl@0
|
3440 |
Renders a currency value as text, based on the locale's currency and numeric
|
sl@0
|
3441 |
format settings.
|
sl@0
|
3442 |
|
sl@0
|
3443 |
These settings include the currency symbol, the symbol's position and the
|
sl@0
|
3444 |
way negative values are formatted.
|
sl@0
|
3445 |
|
sl@0
|
3446 |
@param aText On return, contains the currency value as text, formatted
|
sl@0
|
3447 |
according to the locale's currency format settings.
|
sl@0
|
3448 |
@param aAmount The currency value to be formatted.
|
sl@0
|
3449 |
|
sl@0
|
3450 |
@panic USER 11, if aText is not long enough to hold the formatted value.
|
sl@0
|
3451 |
*/
|
sl@0
|
3452 |
{
|
sl@0
|
3453 |
TOverflowHandler overflowHandler;
|
sl@0
|
3454 |
FormatCurrency(aText,overflowHandler, aAmount);
|
sl@0
|
3455 |
}
|
sl@0
|
3456 |
|
sl@0
|
3457 |
|
sl@0
|
3458 |
|
sl@0
|
3459 |
|
sl@0
|
3460 |
EXPORT_C void TLocale::FormatCurrency(TDes& aText, TDesOverflow& aOverflowHandler, TInt aAmount)
|
sl@0
|
3461 |
/**
|
sl@0
|
3462 |
Renders a currency value as text, based on the locale's currency and numeric
|
sl@0
|
3463 |
format settings.
|
sl@0
|
3464 |
|
sl@0
|
3465 |
These settings include the currency symbol, the symbol's position and the
|
sl@0
|
3466 |
way negative values are formatted. If aText is not long enough to hold the
|
sl@0
|
3467 |
formatted currency value, the overflow handler's Overflow() function is called.
|
sl@0
|
3468 |
|
sl@0
|
3469 |
@param aText On return, contains the currency value as text,
|
sl@0
|
3470 |
formatted according to the locale's currency format
|
sl@0
|
3471 |
settings.
|
sl@0
|
3472 |
@param aOverflowHandler An object derived from TDesOverflow which handles
|
sl@0
|
3473 |
descriptor overflows.
|
sl@0
|
3474 |
@param aAmount The currency value to be formatted.
|
sl@0
|
3475 |
*/
|
sl@0
|
3476 |
{
|
sl@0
|
3477 |
TInt64 aLongerInt(aAmount);
|
sl@0
|
3478 |
FormatCurrency(aText, aOverflowHandler, aLongerInt);
|
sl@0
|
3479 |
}
|
sl@0
|
3480 |
|
sl@0
|
3481 |
|
sl@0
|
3482 |
|
sl@0
|
3483 |
|
sl@0
|
3484 |
EXPORT_C void TLocale::FormatCurrency(TDes& aText, TDesOverflow& aOverflowHandler, TInt64 aAmount)
|
sl@0
|
3485 |
/**
|
sl@0
|
3486 |
Renders a currency value as text, based on the locale's currency and numeric
|
sl@0
|
3487 |
format settings.
|
sl@0
|
3488 |
|
sl@0
|
3489 |
These settings include the currency symbol, the symbol's position and the
|
sl@0
|
3490 |
way negative values are formatted. If aText is not long enough to hold the
|
sl@0
|
3491 |
formatted currency value, the overflow handler's Overflow() function is called.
|
sl@0
|
3492 |
|
sl@0
|
3493 |
@param aText On return, contains the currency value as text,
|
sl@0
|
3494 |
formatted according to the locale's currency format
|
sl@0
|
3495 |
settings.
|
sl@0
|
3496 |
@param aOverflowHandler An object derived from TDesOverflow which handles
|
sl@0
|
3497 |
descriptor overflows.
|
sl@0
|
3498 |
@param aAmount The currency value to be formatted.
|
sl@0
|
3499 |
*/
|
sl@0
|
3500 |
{
|
sl@0
|
3501 |
// aAmount is in cents (or equivalent) rather than dollars (or equivalent)
|
sl@0
|
3502 |
const TBool amountIsNegative=(aAmount<0);
|
sl@0
|
3503 |
if (amountIsNegative)
|
sl@0
|
3504 |
{
|
sl@0
|
3505 |
aAmount=-aAmount;
|
sl@0
|
3506 |
}
|
sl@0
|
3507 |
aText.Num(aAmount, EDecimal);
|
sl@0
|
3508 |
const TInt currencyDecimalPlaces=CurrencyDecimalPlaces();
|
sl@0
|
3509 |
TInt positionOfDecimalSeparator=aText.Length();
|
sl@0
|
3510 |
if (currencyDecimalPlaces>0)
|
sl@0
|
3511 |
{
|
sl@0
|
3512 |
while (positionOfDecimalSeparator <= currencyDecimalPlaces)
|
sl@0
|
3513 |
{
|
sl@0
|
3514 |
if (aText.Length() == aText.MaxLength())
|
sl@0
|
3515 |
{
|
sl@0
|
3516 |
aOverflowHandler.Overflow(aText);
|
sl@0
|
3517 |
return;
|
sl@0
|
3518 |
}
|
sl@0
|
3519 |
aText.Insert(0,KLitZeroPad);
|
sl@0
|
3520 |
++positionOfDecimalSeparator;
|
sl@0
|
3521 |
}
|
sl@0
|
3522 |
positionOfDecimalSeparator=aText.Length();
|
sl@0
|
3523 |
positionOfDecimalSeparator-=currencyDecimalPlaces;
|
sl@0
|
3524 |
TBuf<1> decimalSeparator;
|
sl@0
|
3525 |
decimalSeparator.Append(DecimalSeparator());
|
sl@0
|
3526 |
if (aText.Length() == aText.MaxLength())
|
sl@0
|
3527 |
{
|
sl@0
|
3528 |
aOverflowHandler.Overflow(aText);
|
sl@0
|
3529 |
return;
|
sl@0
|
3530 |
}
|
sl@0
|
3531 |
aText.Insert(positionOfDecimalSeparator, decimalSeparator);
|
sl@0
|
3532 |
}
|
sl@0
|
3533 |
if (CurrencyTriadsAllowed())
|
sl@0
|
3534 |
{
|
sl@0
|
3535 |
TBuf<1> thousandsSeparator;
|
sl@0
|
3536 |
thousandsSeparator.Append(ThousandsSeparator());
|
sl@0
|
3537 |
TInt numberOfThousandsSeparator = positionOfDecimalSeparator/3;
|
sl@0
|
3538 |
if ((aText.Length()+numberOfThousandsSeparator) > aText.MaxLength())
|
sl@0
|
3539 |
{
|
sl@0
|
3540 |
aOverflowHandler.Overflow(aText);
|
sl@0
|
3541 |
return;
|
sl@0
|
3542 |
}
|
sl@0
|
3543 |
for (TInt i=positionOfDecimalSeparator-3; i>0; i-=3)
|
sl@0
|
3544 |
{
|
sl@0
|
3545 |
aText.Insert(i, thousandsSeparator);
|
sl@0
|
3546 |
}
|
sl@0
|
3547 |
}
|
sl@0
|
3548 |
TInt positionToInsertCurrencySymbol = 0;
|
sl@0
|
3549 |
switch (CurrencySymbolPosition())
|
sl@0
|
3550 |
{
|
sl@0
|
3551 |
case ELocaleBefore:
|
sl@0
|
3552 |
{
|
sl@0
|
3553 |
if ((amountIsNegative) && (NegativeCurrencySymbolOpposite()))
|
sl@0
|
3554 |
{
|
sl@0
|
3555 |
positionToInsertCurrencySymbol=aText.Length();
|
sl@0
|
3556 |
}
|
sl@0
|
3557 |
else
|
sl@0
|
3558 |
positionToInsertCurrencySymbol=0;
|
sl@0
|
3559 |
}
|
sl@0
|
3560 |
break;
|
sl@0
|
3561 |
case ELocaleAfter:
|
sl@0
|
3562 |
{
|
sl@0
|
3563 |
if ((amountIsNegative) && (NegativeCurrencySymbolOpposite()))
|
sl@0
|
3564 |
{
|
sl@0
|
3565 |
positionToInsertCurrencySymbol=0;
|
sl@0
|
3566 |
}
|
sl@0
|
3567 |
else
|
sl@0
|
3568 |
positionToInsertCurrencySymbol=aText.Length();
|
sl@0
|
3569 |
}
|
sl@0
|
3570 |
break;
|
sl@0
|
3571 |
default:
|
sl@0
|
3572 |
Panic(ETRegionOutOfRange);
|
sl@0
|
3573 |
break;
|
sl@0
|
3574 |
}
|
sl@0
|
3575 |
if (CurrencySpaceBetween())
|
sl@0
|
3576 |
{
|
sl@0
|
3577 |
if (aText.Length() == aText.MaxLength())
|
sl@0
|
3578 |
{
|
sl@0
|
3579 |
aOverflowHandler.Overflow(aText);
|
sl@0
|
3580 |
return;
|
sl@0
|
3581 |
}
|
sl@0
|
3582 |
if ((amountIsNegative) && (NegativeLoseSpace()))
|
sl@0
|
3583 |
{
|
sl@0
|
3584 |
// don't add the space
|
sl@0
|
3585 |
}
|
sl@0
|
3586 |
else
|
sl@0
|
3587 |
{
|
sl@0
|
3588 |
aText.Insert(positionToInsertCurrencySymbol, KLitSpace);
|
sl@0
|
3589 |
if (positionToInsertCurrencySymbol>0)
|
sl@0
|
3590 |
{
|
sl@0
|
3591 |
++positionToInsertCurrencySymbol;
|
sl@0
|
3592 |
}
|
sl@0
|
3593 |
}
|
sl@0
|
3594 |
}
|
sl@0
|
3595 |
TCurrencySymbol theCurrencySymbol;
|
sl@0
|
3596 |
if ((aText.Length()+theCurrencySymbol.Length()) > aText.MaxLength())
|
sl@0
|
3597 |
{
|
sl@0
|
3598 |
aOverflowHandler.Overflow(aText);
|
sl@0
|
3599 |
return;
|
sl@0
|
3600 |
}
|
sl@0
|
3601 |
aText.Insert(positionToInsertCurrencySymbol,theCurrencySymbol);
|
sl@0
|
3602 |
if (amountIsNegative)
|
sl@0
|
3603 |
{
|
sl@0
|
3604 |
TInt positionToInsertInterveningMinusSign = 0;
|
sl@0
|
3605 |
if ((CurrencySpaceBetween()) && !(NegativeLoseSpace()))
|
sl@0
|
3606 |
{
|
sl@0
|
3607 |
if (positionToInsertCurrencySymbol>0)
|
sl@0
|
3608 |
{
|
sl@0
|
3609 |
positionToInsertInterveningMinusSign = positionToInsertCurrencySymbol-1;
|
sl@0
|
3610 |
}
|
sl@0
|
3611 |
else
|
sl@0
|
3612 |
{
|
sl@0
|
3613 |
positionToInsertInterveningMinusSign = theCurrencySymbol.Length()+1;
|
sl@0
|
3614 |
}
|
sl@0
|
3615 |
}
|
sl@0
|
3616 |
else
|
sl@0
|
3617 |
{
|
sl@0
|
3618 |
if (positionToInsertCurrencySymbol>0)
|
sl@0
|
3619 |
{
|
sl@0
|
3620 |
positionToInsertInterveningMinusSign = positionToInsertCurrencySymbol;
|
sl@0
|
3621 |
}
|
sl@0
|
3622 |
else
|
sl@0
|
3623 |
{
|
sl@0
|
3624 |
positionToInsertInterveningMinusSign = theCurrencySymbol.Length();
|
sl@0
|
3625 |
}
|
sl@0
|
3626 |
}
|
sl@0
|
3627 |
switch (NegativeCurrencyFormat())
|
sl@0
|
3628 |
{
|
sl@0
|
3629 |
case EInBrackets:
|
sl@0
|
3630 |
{
|
sl@0
|
3631 |
if ((aText.Length()+2) > aText.MaxLength())
|
sl@0
|
3632 |
{
|
sl@0
|
3633 |
aOverflowHandler.Overflow(aText);
|
sl@0
|
3634 |
return;
|
sl@0
|
3635 |
}
|
sl@0
|
3636 |
aText.Insert(0, KLitOpeningBracket);
|
sl@0
|
3637 |
aText.Append(')');
|
sl@0
|
3638 |
}
|
sl@0
|
3639 |
break;
|
sl@0
|
3640 |
case ELeadingMinusSign:
|
sl@0
|
3641 |
{
|
sl@0
|
3642 |
if (aText.Length() == aText.MaxLength())
|
sl@0
|
3643 |
{
|
sl@0
|
3644 |
aOverflowHandler.Overflow(aText);
|
sl@0
|
3645 |
return;
|
sl@0
|
3646 |
}
|
sl@0
|
3647 |
aText.Insert(0, KLitMinusSign);
|
sl@0
|
3648 |
}
|
sl@0
|
3649 |
break;
|
sl@0
|
3650 |
case ETrailingMinusSign:
|
sl@0
|
3651 |
{
|
sl@0
|
3652 |
if (aText.Length() == aText.MaxLength())
|
sl@0
|
3653 |
{
|
sl@0
|
3654 |
aOverflowHandler.Overflow(aText);
|
sl@0
|
3655 |
return;
|
sl@0
|
3656 |
}
|
sl@0
|
3657 |
aText.Append(KLitMinusSign);
|
sl@0
|
3658 |
}
|
sl@0
|
3659 |
break;
|
sl@0
|
3660 |
case EInterveningMinusSign:
|
sl@0
|
3661 |
{
|
sl@0
|
3662 |
if (aText.Length() == aText.MaxLength())
|
sl@0
|
3663 |
{
|
sl@0
|
3664 |
aOverflowHandler.Overflow(aText);
|
sl@0
|
3665 |
return;
|
sl@0
|
3666 |
}
|
sl@0
|
3667 |
aText.Insert(positionToInsertInterveningMinusSign, KLitMinusSign);
|
sl@0
|
3668 |
}
|
sl@0
|
3669 |
break;
|
sl@0
|
3670 |
default:
|
sl@0
|
3671 |
Panic(ETRegionOutOfRange);
|
sl@0
|
3672 |
break;
|
sl@0
|
3673 |
}
|
sl@0
|
3674 |
}
|
sl@0
|
3675 |
}
|
sl@0
|
3676 |
|
sl@0
|
3677 |
|
sl@0
|
3678 |
EXPORT_C void TLocaleMessageText::Set(TLocaleMessage aMsgNo)
|
sl@0
|
3679 |
//
|
sl@0
|
3680 |
// Get some text from Locale
|
sl@0
|
3681 |
//
|
sl@0
|
3682 |
{
|
sl@0
|
3683 |
if(TUint(aMsgNo) < ELocaleMessages_LastMsg)
|
sl@0
|
3684 |
{
|
sl@0
|
3685 |
SLocaleLanguage localeLanguage;
|
sl@0
|
3686 |
LocaleLanguageGet(localeLanguage);
|
sl@0
|
3687 |
Copy((reinterpret_cast<const TText* const*>(localeLanguage.iMsgTable))[aMsgNo]);
|
sl@0
|
3688 |
}
|
sl@0
|
3689 |
else
|
sl@0
|
3690 |
SetLength(0);
|
sl@0
|
3691 |
}
|
sl@0
|
3692 |
|
sl@0
|
3693 |
|
sl@0
|
3694 |
|
sl@0
|
3695 |
|
sl@0
|
3696 |
EXPORT_C TInt TFindServer::Next(TFullName &aResult)
|
sl@0
|
3697 |
/**
|
sl@0
|
3698 |
Gets the full name of the next server which matches the match pattern.
|
sl@0
|
3699 |
|
sl@0
|
3700 |
@param aResult A reference to a descriptor with a defined maximum length.
|
sl@0
|
3701 |
If a matching server is found, its full name is set into
|
sl@0
|
3702 |
this descriptor. If no matching server is found,
|
sl@0
|
3703 |
the descriptor length is set to zero.
|
sl@0
|
3704 |
|
sl@0
|
3705 |
@return KErrNone if a matching server is found, KErrNotFound otherwise.
|
sl@0
|
3706 |
*/
|
sl@0
|
3707 |
{
|
sl@0
|
3708 |
return NextObject(aResult,EServer);
|
sl@0
|
3709 |
}
|
sl@0
|
3710 |
|
sl@0
|
3711 |
|
sl@0
|
3712 |
|
sl@0
|
3713 |
|
sl@0
|
3714 |
EXPORT_C void RServer2::Receive(RMessage2& aMessage, TRequestStatus &aStatus)
|
sl@0
|
3715 |
//
|
sl@0
|
3716 |
// Receive a message from the server asynchronously.
|
sl@0
|
3717 |
//
|
sl@0
|
3718 |
{
|
sl@0
|
3719 |
|
sl@0
|
3720 |
aStatus=KRequestPending;
|
sl@0
|
3721 |
Exec::ServerReceive(iHandle, aStatus, &aMessage);
|
sl@0
|
3722 |
}
|
sl@0
|
3723 |
|
sl@0
|
3724 |
EXPORT_C void RServer2::Cancel()
|
sl@0
|
3725 |
//
|
sl@0
|
3726 |
// Cancel a pending message receive.
|
sl@0
|
3727 |
//
|
sl@0
|
3728 |
{
|
sl@0
|
3729 |
|
sl@0
|
3730 |
Exec::ServerCancel(iHandle);
|
sl@0
|
3731 |
}
|
sl@0
|
3732 |
|
sl@0
|
3733 |
|
sl@0
|
3734 |
|
sl@0
|
3735 |
|
sl@0
|
3736 |
EXPORT_C TInt TFindMutex::Next(TFullName &aResult)
|
sl@0
|
3737 |
/**
|
sl@0
|
3738 |
Finds the next global mutex whose full name matches the match pattern.
|
sl@0
|
3739 |
|
sl@0
|
3740 |
If a global mutex with a matching name is found, the function copies its full
|
sl@0
|
3741 |
name into the specified descriptor. It also saves the find-handle associated
|
sl@0
|
3742 |
with the global mutex into the TFindHandleBase part of this object.
|
sl@0
|
3743 |
|
sl@0
|
3744 |
@param aResult A reference to a descriptor with a defined maximum length.
|
sl@0
|
3745 |
If a matching global mutex is found, its full name is set
|
sl@0
|
3746 |
into this descriptor.
|
sl@0
|
3747 |
If no matching global mutex is found, the descriptor length
|
sl@0
|
3748 |
is set to zero.
|
sl@0
|
3749 |
|
sl@0
|
3750 |
@return KErrNone if a matching global mutex is found;
|
sl@0
|
3751 |
KErrNotFound otherwise.
|
sl@0
|
3752 |
*/
|
sl@0
|
3753 |
{
|
sl@0
|
3754 |
return NextObject(aResult,EMutex);
|
sl@0
|
3755 |
}
|
sl@0
|
3756 |
|
sl@0
|
3757 |
|
sl@0
|
3758 |
|
sl@0
|
3759 |
|
sl@0
|
3760 |
/**
|
sl@0
|
3761 |
Acquire the mutex, waiting for it to become free if necessary.
|
sl@0
|
3762 |
|
sl@0
|
3763 |
This function checks if the mutex is currently held. If not the mutex is marked
|
sl@0
|
3764 |
as held by the current thread and the call returns immediately. If the mutex is
|
sl@0
|
3765 |
held by another thread the current thread will suspend until the mutex becomes
|
sl@0
|
3766 |
free. If the mutex is already held by the current thread a count is maintained
|
sl@0
|
3767 |
of how many times the thread has acquired the mutex.
|
sl@0
|
3768 |
*/
|
sl@0
|
3769 |
EXPORT_C void RMutex::Wait()
|
sl@0
|
3770 |
{
|
sl@0
|
3771 |
|
sl@0
|
3772 |
Exec::MutexWait(iHandle);
|
sl@0
|
3773 |
}
|
sl@0
|
3774 |
|
sl@0
|
3775 |
|
sl@0
|
3776 |
|
sl@0
|
3777 |
|
sl@0
|
3778 |
/**
|
sl@0
|
3779 |
Release the mutex.
|
sl@0
|
3780 |
|
sl@0
|
3781 |
This function decrements the count of how many times the current thread has
|
sl@0
|
3782 |
acquired this mutex. If the count is now zero the mutex is marked as free and,
|
sl@0
|
3783 |
if any other threads are waiting for the mutex to become free, the highest
|
sl@0
|
3784 |
priority among those is made ready to run. However the mutex is not marked as
|
sl@0
|
3785 |
held by any thread - the thread which has just been awakened must actually run
|
sl@0
|
3786 |
in order to acquire the mutex.
|
sl@0
|
3787 |
|
sl@0
|
3788 |
@pre The mutex must previously have been acquired by the current thread calling
|
sl@0
|
3789 |
Wait().
|
sl@0
|
3790 |
|
sl@0
|
3791 |
@panic KERN-EXEC 1 If the mutex has not previously been acquired by the current
|
sl@0
|
3792 |
thread calling Wait().
|
sl@0
|
3793 |
*/
|
sl@0
|
3794 |
EXPORT_C void RMutex::Signal()
|
sl@0
|
3795 |
{
|
sl@0
|
3796 |
|
sl@0
|
3797 |
Exec::MutexSignal(iHandle);
|
sl@0
|
3798 |
}
|
sl@0
|
3799 |
|
sl@0
|
3800 |
|
sl@0
|
3801 |
|
sl@0
|
3802 |
/**
|
sl@0
|
3803 |
Test if this mutex is held by the current thread.
|
sl@0
|
3804 |
@return True if the current thread has waited on the mutex, false otherwise.
|
sl@0
|
3805 |
*/
|
sl@0
|
3806 |
EXPORT_C TBool RMutex::IsHeld()
|
sl@0
|
3807 |
{
|
sl@0
|
3808 |
return Exec::MutexIsHeld(iHandle);
|
sl@0
|
3809 |
}
|
sl@0
|
3810 |
|
sl@0
|
3811 |
|
sl@0
|
3812 |
/** Wait on a condition variable
|
sl@0
|
3813 |
|
sl@0
|
3814 |
This call releases the specified mutex then atomically blocks the current
|
sl@0
|
3815 |
thread on this condition variable. The atomicity here is with respect to the
|
sl@0
|
3816 |
condition variable and mutex concerned. Specifically if the condition variable
|
sl@0
|
3817 |
is signalled at any time after the mutex is released then this thread will be
|
sl@0
|
3818 |
awakened. Once the thread has awakened it will reacquire the specified mutex
|
sl@0
|
3819 |
before this call returns (except in the case where the condition variable has
|
sl@0
|
3820 |
been deleted).
|
sl@0
|
3821 |
|
sl@0
|
3822 |
The usage pattern for this is as follows:
|
sl@0
|
3823 |
|
sl@0
|
3824 |
@code
|
sl@0
|
3825 |
mutex.Wait();
|
sl@0
|
3826 |
while(!CONDITION)
|
sl@0
|
3827 |
condvar.Wait(mutex);
|
sl@0
|
3828 |
STATEMENTS;
|
sl@0
|
3829 |
mutex.Signal();
|
sl@0
|
3830 |
@endcode
|
sl@0
|
3831 |
|
sl@0
|
3832 |
where CONDITION is an arbitrary condition involving any number of user-side
|
sl@0
|
3833 |
variables whose integrity is protected by the mutex.
|
sl@0
|
3834 |
|
sl@0
|
3835 |
It is necessary to loop while testing the condition because there is **no** guarantee
|
sl@0
|
3836 |
that the condition has been satisfied when the condition variable is signalled.
|
sl@0
|
3837 |
Different threads may be waiting on different conditions or the condition may
|
sl@0
|
3838 |
have already been absorbed by another thread. All that can be said is that the
|
sl@0
|
3839 |
thread will awaken whenever something happens which **might** affect the condition.
|
sl@0
|
3840 |
|
sl@0
|
3841 |
It needs to be stressed that if:
|
sl@0
|
3842 |
|
sl@0
|
3843 |
@code
|
sl@0
|
3844 |
condvar.Wait(mutex);
|
sl@0
|
3845 |
@endcode
|
sl@0
|
3846 |
|
sl@0
|
3847 |
completes, it does not necessarily mean that the condition is yet satisfied, hence the necessity for the loop.
|
sl@0
|
3848 |
|
sl@0
|
3849 |
@param aMutex The mutex to be released and reacquired.
|
sl@0
|
3850 |
@return KErrNone if the condition variable has been signalled.
|
sl@0
|
3851 |
KErrInUse if another thread is already waiting on this condition
|
sl@0
|
3852 |
variable in conjunction with a different mutex.
|
sl@0
|
3853 |
KErrGeneral if the condition variable is deleted.
|
sl@0
|
3854 |
|
sl@0
|
3855 |
@pre The specified mutex is held by the current thread.
|
sl@0
|
3856 |
@post The specified mutex is held by the current thread unless the return
|
sl@0
|
3857 |
value is KErrGeneral in which case the condition variable no longer
|
sl@0
|
3858 |
exists.
|
sl@0
|
3859 |
|
sl@0
|
3860 |
@panic KERN-EXEC 0 if either the condition variable or mutex handles are not
|
sl@0
|
3861 |
valid.
|
sl@0
|
3862 |
@panic KERN-EXEC 54 if the current thread does not hold the specified mutex.
|
sl@0
|
3863 |
|
sl@0
|
3864 |
@see RCondVar::Signal()
|
sl@0
|
3865 |
@see RCondVar::Broadcast()
|
sl@0
|
3866 |
*/
|
sl@0
|
3867 |
EXPORT_C TInt RCondVar::Wait(RMutex& aMutex)
|
sl@0
|
3868 |
{
|
sl@0
|
3869 |
return Exec::CondVarWait(iHandle, aMutex.Handle(), 0);
|
sl@0
|
3870 |
}
|
sl@0
|
3871 |
|
sl@0
|
3872 |
|
sl@0
|
3873 |
|
sl@0
|
3874 |
/** Wait on a condition variable with timeout
|
sl@0
|
3875 |
|
sl@0
|
3876 |
This is the same as RCondVar::Wait(RMutex) except that there is a time limit on
|
sl@0
|
3877 |
how long the current thread will block while waiting for the condition variable.
|
sl@0
|
3878 |
|
sl@0
|
3879 |
@param aMutex The mutex to be released and reacquired.
|
sl@0
|
3880 |
@param aTimeout The maximum time to wait in microseconds.
|
sl@0
|
3881 |
0 means no maximum.
|
sl@0
|
3882 |
@return KErrNone if the condition variable has been signalled.
|
sl@0
|
3883 |
KErrInUse if another thread is already waiting on this condition
|
sl@0
|
3884 |
variable in conjunction with a different mutex.
|
sl@0
|
3885 |
KErrGeneral if the condition variable is deleted.
|
sl@0
|
3886 |
KErrTimedOut if the timeout expired before the condition variable was
|
sl@0
|
3887 |
signalled.
|
sl@0
|
3888 |
|
sl@0
|
3889 |
@pre The specified mutex is held by the current thread.
|
sl@0
|
3890 |
@post The specified mutex is held by the current thread unless the return
|
sl@0
|
3891 |
value is KErrGeneral in which case the condition variable no longer
|
sl@0
|
3892 |
exists.
|
sl@0
|
3893 |
|
sl@0
|
3894 |
@panic KERN-EXEC 0 if either the condition variable or mutex handles are not
|
sl@0
|
3895 |
valid.
|
sl@0
|
3896 |
@panic KERN-EXEC 54 if the current thread does not hold the specified mutex.
|
sl@0
|
3897 |
|
sl@0
|
3898 |
@see RCondVar::Wait(RMutex)
|
sl@0
|
3899 |
*/
|
sl@0
|
3900 |
EXPORT_C TInt RCondVar::TimedWait(RMutex& aMutex, TInt aTimeout)
|
sl@0
|
3901 |
{
|
sl@0
|
3902 |
return Exec::CondVarWait(iHandle, aMutex.Handle(), aTimeout);
|
sl@0
|
3903 |
}
|
sl@0
|
3904 |
|
sl@0
|
3905 |
|
sl@0
|
3906 |
/** Signal a condition variable
|
sl@0
|
3907 |
|
sl@0
|
3908 |
This unblocks a single thread which is currently blocked on the condition
|
sl@0
|
3909 |
variable. The highest priority waiting thread which is not explicitly suspended
|
sl@0
|
3910 |
will be the one unblocked. If there are no threads currently waiting this call
|
sl@0
|
3911 |
does nothing.
|
sl@0
|
3912 |
|
sl@0
|
3913 |
It is not required that any mutex is held when calling this function but it is
|
sl@0
|
3914 |
recommended that the mutex associated with the condition variable is held since
|
sl@0
|
3915 |
otherwise a race condition can result from the condition variable being signalled
|
sl@0
|
3916 |
just after the waiting thread testing the condition and before it calls Wait().
|
sl@0
|
3917 |
|
sl@0
|
3918 |
*/
|
sl@0
|
3919 |
EXPORT_C void RCondVar::Signal()
|
sl@0
|
3920 |
{
|
sl@0
|
3921 |
Exec::CondVarSignal(iHandle);
|
sl@0
|
3922 |
}
|
sl@0
|
3923 |
|
sl@0
|
3924 |
|
sl@0
|
3925 |
|
sl@0
|
3926 |
/** Broadcast to a condition variable
|
sl@0
|
3927 |
|
sl@0
|
3928 |
This unblocks all threads which are currently blocked on the condition
|
sl@0
|
3929 |
variable. If there are no threads currently waiting this call does nothing.
|
sl@0
|
3930 |
|
sl@0
|
3931 |
It is not required that any mutex is held when calling this function but it is
|
sl@0
|
3932 |
recommended that the mutex associated with the condition variable is held since
|
sl@0
|
3933 |
otherwise a race condition can result from the condition variable being signalled
|
sl@0
|
3934 |
just after the waiting thread testing the condition and before it calls Wait().
|
sl@0
|
3935 |
|
sl@0
|
3936 |
*/
|
sl@0
|
3937 |
EXPORT_C void RCondVar::Broadcast()
|
sl@0
|
3938 |
{
|
sl@0
|
3939 |
Exec::CondVarBroadcast(iHandle);
|
sl@0
|
3940 |
}
|
sl@0
|
3941 |
|
sl@0
|
3942 |
|
sl@0
|
3943 |
|
sl@0
|
3944 |
|
sl@0
|
3945 |
EXPORT_C TInt TFindProcess::Next(TFullName &aResult)
|
sl@0
|
3946 |
/**
|
sl@0
|
3947 |
Gets the full name of the next process which matches the match pattern.
|
sl@0
|
3948 |
|
sl@0
|
3949 |
@param aResult A reference to a TBuf descriptor with a defined maximum length.
|
sl@0
|
3950 |
If a matching process is found, its full name is set into
|
sl@0
|
3951 |
this descriptor. If no matching process is found, the descriptor
|
sl@0
|
3952 |
length is set to zero.
|
sl@0
|
3953 |
|
sl@0
|
3954 |
@return KErrNone if successful, otherwise one of the other system-wide error
|
sl@0
|
3955 |
codes.
|
sl@0
|
3956 |
*/
|
sl@0
|
3957 |
{
|
sl@0
|
3958 |
return NextObject(aResult,EProcess);
|
sl@0
|
3959 |
}
|
sl@0
|
3960 |
|
sl@0
|
3961 |
|
sl@0
|
3962 |
|
sl@0
|
3963 |
|
sl@0
|
3964 |
EXPORT_C TUidType RProcess::Type() const
|
sl@0
|
3965 |
/**
|
sl@0
|
3966 |
Gets the Uid type associated with the process.
|
sl@0
|
3967 |
|
sl@0
|
3968 |
@return A reference to a TUidType object containing the process type.
|
sl@0
|
3969 |
*/
|
sl@0
|
3970 |
{
|
sl@0
|
3971 |
|
sl@0
|
3972 |
TUidType u;
|
sl@0
|
3973 |
Exec::ProcessType(iHandle,u);
|
sl@0
|
3974 |
return(u);
|
sl@0
|
3975 |
}
|
sl@0
|
3976 |
|
sl@0
|
3977 |
|
sl@0
|
3978 |
|
sl@0
|
3979 |
|
sl@0
|
3980 |
EXPORT_C TProcessId RProcess::Id() const
|
sl@0
|
3981 |
/**
|
sl@0
|
3982 |
Gets the Id of this process.
|
sl@0
|
3983 |
|
sl@0
|
3984 |
@return The Id of this process.
|
sl@0
|
3985 |
*/
|
sl@0
|
3986 |
{
|
sl@0
|
3987 |
|
sl@0
|
3988 |
return TProcessId( (TUint)Exec::ProcessId(iHandle) );
|
sl@0
|
3989 |
}
|
sl@0
|
3990 |
|
sl@0
|
3991 |
|
sl@0
|
3992 |
|
sl@0
|
3993 |
|
sl@0
|
3994 |
EXPORT_C void RProcess::Resume()
|
sl@0
|
3995 |
/**
|
sl@0
|
3996 |
Makes the first thread in the process eligible for execution.
|
sl@0
|
3997 |
|
sl@0
|
3998 |
@panic KERN-EXEC 32 if the process is not yet fully loaded.
|
sl@0
|
3999 |
|
sl@0
|
4000 |
@see RThread::Resume()
|
sl@0
|
4001 |
*/
|
sl@0
|
4002 |
{
|
sl@0
|
4003 |
|
sl@0
|
4004 |
Exec::ProcessResume(iHandle);
|
sl@0
|
4005 |
}
|
sl@0
|
4006 |
|
sl@0
|
4007 |
|
sl@0
|
4008 |
|
sl@0
|
4009 |
EXPORT_C TFileName RProcess::FileName() const
|
sl@0
|
4010 |
/**
|
sl@0
|
4011 |
Gets a copy of the full path name of the loaded executable on which this
|
sl@0
|
4012 |
process is based.
|
sl@0
|
4013 |
|
sl@0
|
4014 |
This is the file name which is passed to the Create() member function of this
|
sl@0
|
4015 |
RProcess.
|
sl@0
|
4016 |
|
sl@0
|
4017 |
@return A TBuf descriptor with a defined maximum length containing the full
|
sl@0
|
4018 |
path name of the file.
|
sl@0
|
4019 |
|
sl@0
|
4020 |
@see RProcess::Create()
|
sl@0
|
4021 |
*/
|
sl@0
|
4022 |
{
|
sl@0
|
4023 |
|
sl@0
|
4024 |
TFileName n;
|
sl@0
|
4025 |
TPtr8 n8(((TUint8*)n.Ptr()) + KMaxFileName, KMaxFileName);
|
sl@0
|
4026 |
Exec::ProcessFileName(iHandle,n8);
|
sl@0
|
4027 |
n.Copy(n8);
|
sl@0
|
4028 |
return(n);
|
sl@0
|
4029 |
}
|
sl@0
|
4030 |
|
sl@0
|
4031 |
|
sl@0
|
4032 |
|
sl@0
|
4033 |
|
sl@0
|
4034 |
EXPORT_C void User::CommandLine(TDes &aCommand)
|
sl@0
|
4035 |
/**
|
sl@0
|
4036 |
Gets a copy of the data which is passed as an argument to the thread function
|
sl@0
|
4037 |
of the current process's main thread when it is first scheduled to run.
|
sl@0
|
4038 |
|
sl@0
|
4039 |
@param aCommand A modifiable descriptor supplied by the caller into which the
|
sl@0
|
4040 |
argument data is put. The descriptor must be big enough to
|
sl@0
|
4041 |
contain the expected data, otherwise the function raises
|
sl@0
|
4042 |
a panic.
|
sl@0
|
4043 |
|
sl@0
|
4044 |
@see User::CommandLineLength()
|
sl@0
|
4045 |
*/
|
sl@0
|
4046 |
{
|
sl@0
|
4047 |
TPtr8 aCommand8((TUint8*)aCommand.Ptr(),aCommand.MaxLength()<<1);
|
sl@0
|
4048 |
Exec::ProcessCommandLine(KCurrentProcessHandle,aCommand8);
|
sl@0
|
4049 |
aCommand.SetLength(aCommand8.Length()>>1);
|
sl@0
|
4050 |
}
|
sl@0
|
4051 |
|
sl@0
|
4052 |
|
sl@0
|
4053 |
|
sl@0
|
4054 |
|
sl@0
|
4055 |
EXPORT_C TInt User::CommandLineLength()
|
sl@0
|
4056 |
/**
|
sl@0
|
4057 |
Gets the length of the data which is passed as an argument to the thread
|
sl@0
|
4058 |
function of the current process's main thread when it is first scheduled
|
sl@0
|
4059 |
to run.
|
sl@0
|
4060 |
|
sl@0
|
4061 |
@return The length of the argument data.
|
sl@0
|
4062 |
*/
|
sl@0
|
4063 |
{
|
sl@0
|
4064 |
return Exec::ProcessCommandLineLength(KCurrentProcessHandle);
|
sl@0
|
4065 |
}
|
sl@0
|
4066 |
|
sl@0
|
4067 |
|
sl@0
|
4068 |
|
sl@0
|
4069 |
|
sl@0
|
4070 |
EXPORT_C TExitType RProcess::ExitType() const
|
sl@0
|
4071 |
/**
|
sl@0
|
4072 |
Tests whether the process has ended and, if it has ended, return how it ended.
|
sl@0
|
4073 |
|
sl@0
|
4074 |
This information allows the caller to distinguish between normal termination
|
sl@0
|
4075 |
and a panic.
|
sl@0
|
4076 |
|
sl@0
|
4077 |
@return An enumeration whose enumerators describe how the process has ended.
|
sl@0
|
4078 |
*/
|
sl@0
|
4079 |
{
|
sl@0
|
4080 |
|
sl@0
|
4081 |
return(Exec::ProcessExitType(iHandle));
|
sl@0
|
4082 |
}
|
sl@0
|
4083 |
|
sl@0
|
4084 |
|
sl@0
|
4085 |
|
sl@0
|
4086 |
|
sl@0
|
4087 |
EXPORT_C TInt RProcess::ExitReason() const
|
sl@0
|
4088 |
/**
|
sl@0
|
4089 |
Gets the specific reason associated with the end of this process.
|
sl@0
|
4090 |
|
sl@0
|
4091 |
The reason number together with the category name is a way of distinguishing
|
sl@0
|
4092 |
between different causes of process termination.
|
sl@0
|
4093 |
|
sl@0
|
4094 |
If the process has panicked, this value is the panic number. If the process
|
sl@0
|
4095 |
has ended as a result of a call to Kill(), then the value is the one supplied
|
sl@0
|
4096 |
by Kill().
|
sl@0
|
4097 |
|
sl@0
|
4098 |
If the process has not ended, then the returned value is zero.
|
sl@0
|
4099 |
|
sl@0
|
4100 |
@return The reason associated with the end of the process.
|
sl@0
|
4101 |
|
sl@0
|
4102 |
@see RProcess::Kill()
|
sl@0
|
4103 |
*/
|
sl@0
|
4104 |
{
|
sl@0
|
4105 |
|
sl@0
|
4106 |
return(Exec::ProcessExitReason(iHandle));
|
sl@0
|
4107 |
}
|
sl@0
|
4108 |
|
sl@0
|
4109 |
|
sl@0
|
4110 |
|
sl@0
|
4111 |
|
sl@0
|
4112 |
EXPORT_C TExitCategoryName RProcess::ExitCategory() const
|
sl@0
|
4113 |
/**
|
sl@0
|
4114 |
Gets the name of the category associated with the end of the process.
|
sl@0
|
4115 |
|
sl@0
|
4116 |
The category name together with the reason number is a way of distinguishing
|
sl@0
|
4117 |
between different causes of process termination.
|
sl@0
|
4118 |
|
sl@0
|
4119 |
If the process has panicked, the category name is the panic category name;
|
sl@0
|
4120 |
for example, E32USER-CBase or KERN-EXEC. If the process has ended as a result
|
sl@0
|
4121 |
of a call to Kill(), then the category name is Kill.
|
sl@0
|
4122 |
|
sl@0
|
4123 |
If the process has not ended, then the category name is empty, i.e. the length
|
sl@0
|
4124 |
of the category name is zero.
|
sl@0
|
4125 |
|
sl@0
|
4126 |
@return A descriptor with a defined maximum length containing the
|
sl@0
|
4127 |
name of the category associated with the end of the process.
|
sl@0
|
4128 |
|
sl@0
|
4129 |
@see RProcess::Kill()
|
sl@0
|
4130 |
*/
|
sl@0
|
4131 |
{
|
sl@0
|
4132 |
|
sl@0
|
4133 |
TExitCategoryName n;
|
sl@0
|
4134 |
TPtr8 n8(((TUint8*)n.Ptr()) + KMaxExitCategoryName, KMaxExitCategoryName);
|
sl@0
|
4135 |
Exec::ProcessExitCategory(iHandle,n8);
|
sl@0
|
4136 |
n.Copy(n8);
|
sl@0
|
4137 |
return(n);
|
sl@0
|
4138 |
}
|
sl@0
|
4139 |
|
sl@0
|
4140 |
|
sl@0
|
4141 |
|
sl@0
|
4142 |
|
sl@0
|
4143 |
EXPORT_C TProcessPriority RProcess::Priority() const
|
sl@0
|
4144 |
/**
|
sl@0
|
4145 |
Gets the priority of this process.
|
sl@0
|
4146 |
|
sl@0
|
4147 |
@return One of the TProcessPriority enumerator values.
|
sl@0
|
4148 |
*/
|
sl@0
|
4149 |
{
|
sl@0
|
4150 |
|
sl@0
|
4151 |
return(Exec::ProcessPriority(iHandle));
|
sl@0
|
4152 |
}
|
sl@0
|
4153 |
|
sl@0
|
4154 |
|
sl@0
|
4155 |
|
sl@0
|
4156 |
|
sl@0
|
4157 |
EXPORT_C TInt RProcess::SetPriority(TProcessPriority aPriority) const
|
sl@0
|
4158 |
/**
|
sl@0
|
4159 |
Sets the priority of this process to one of the values defined by theTProcessPriority
|
sl@0
|
4160 |
enumeration. The priority can be set to one of the four values:
|
sl@0
|
4161 |
|
sl@0
|
4162 |
EPriorityLow
|
sl@0
|
4163 |
|
sl@0
|
4164 |
EPriorityBackground
|
sl@0
|
4165 |
|
sl@0
|
4166 |
EPriorityForeground
|
sl@0
|
4167 |
|
sl@0
|
4168 |
EPriorityHigh
|
sl@0
|
4169 |
|
sl@0
|
4170 |
The absolute priority of all threads owned by the process (and all threads
|
sl@0
|
4171 |
owned by those threads etc.) are re-calculated.
|
sl@0
|
4172 |
|
sl@0
|
4173 |
Notes:
|
sl@0
|
4174 |
|
sl@0
|
4175 |
The priority values EPriorityWindowServer, EPriorityFileServer, EPriorityRealTimeServer
|
sl@0
|
4176 |
and EPrioritySupervisor are internal to Symbian OS and any attempt to explicitly
|
sl@0
|
4177 |
set any of these priority values causes a KERN-EXEC 14 panic to be raised.
|
sl@0
|
4178 |
|
sl@0
|
4179 |
Any attempt to set the priority of a process which is protected and is different
|
sl@0
|
4180 |
from the process owning the thread which invokes this function, causes a KERN-EXEC
|
sl@0
|
4181 |
1 panic to be raised.
|
sl@0
|
4182 |
|
sl@0
|
4183 |
A process can set its own priority whether it is protected or not.
|
sl@0
|
4184 |
|
sl@0
|
4185 |
@param aPriority The priority value.
|
sl@0
|
4186 |
|
sl@0
|
4187 |
@return KErrNone, if successful; otherwise one of the other system-wide
|
sl@0
|
4188 |
error codes.
|
sl@0
|
4189 |
|
sl@0
|
4190 |
*/
|
sl@0
|
4191 |
{
|
sl@0
|
4192 |
|
sl@0
|
4193 |
return Exec::ProcessSetPriority(iHandle,aPriority);
|
sl@0
|
4194 |
}
|
sl@0
|
4195 |
|
sl@0
|
4196 |
|
sl@0
|
4197 |
|
sl@0
|
4198 |
|
sl@0
|
4199 |
/**
|
sl@0
|
4200 |
Tests whether "Just In Time" debugging is enabled or not for this process.
|
sl@0
|
4201 |
|
sl@0
|
4202 |
@return True, when "Just In Time" debugging is enabled. False otherwise.
|
sl@0
|
4203 |
@see RProcess::SetJustInTime
|
sl@0
|
4204 |
*/
|
sl@0
|
4205 |
|
sl@0
|
4206 |
EXPORT_C TBool RProcess::JustInTime() const
|
sl@0
|
4207 |
{
|
sl@0
|
4208 |
|
sl@0
|
4209 |
return (Exec::ProcessFlags(iHandle) & KProcessFlagJustInTime) != 0;
|
sl@0
|
4210 |
}
|
sl@0
|
4211 |
|
sl@0
|
4212 |
|
sl@0
|
4213 |
/**
|
sl@0
|
4214 |
Enables or disables "Just In Time" debugging for this process.
|
sl@0
|
4215 |
This will only have an effect when running on the emulator.
|
sl@0
|
4216 |
|
sl@0
|
4217 |
"Just In Time" debugging catches a thread just before it executes a panic
|
sl@0
|
4218 |
or exception routine. Capturing a thread early, before it is terminated,
|
sl@0
|
4219 |
allows the developer to more closely inspect what went wrong, before the
|
sl@0
|
4220 |
kernel removes the thread. In some cases, the developer can modify context,
|
sl@0
|
4221 |
program counter, and variables to recover the thread. This is only possible
|
sl@0
|
4222 |
on the emulator.
|
sl@0
|
4223 |
|
sl@0
|
4224 |
By default, "Just In Time" debugging is enabled.
|
sl@0
|
4225 |
|
sl@0
|
4226 |
@param aBoolean ETrue, to enable just-in-time debugging.
|
sl@0
|
4227 |
EFalse, to disable just-in-time debugging.
|
sl@0
|
4228 |
*/
|
sl@0
|
4229 |
EXPORT_C void RProcess::SetJustInTime(TBool aState) const
|
sl@0
|
4230 |
{
|
sl@0
|
4231 |
|
sl@0
|
4232 |
TUint32 set = aState ? KProcessFlagJustInTime : 0;
|
sl@0
|
4233 |
Exec::ProcessSetFlags(iHandle, KProcessFlagJustInTime, set);
|
sl@0
|
4234 |
}
|
sl@0
|
4235 |
|
sl@0
|
4236 |
|
sl@0
|
4237 |
|
sl@0
|
4238 |
|
sl@0
|
4239 |
EXPORT_C TInt RProcess::SecureApi(TInt /*aState*/)
|
sl@0
|
4240 |
{
|
sl@0
|
4241 |
return ESecureApiOn;
|
sl@0
|
4242 |
}
|
sl@0
|
4243 |
|
sl@0
|
4244 |
EXPORT_C TInt RProcess::DataCaging(TInt /*aState*/)
|
sl@0
|
4245 |
{
|
sl@0
|
4246 |
return EDataCagingOn;
|
sl@0
|
4247 |
}
|
sl@0
|
4248 |
|
sl@0
|
4249 |
|
sl@0
|
4250 |
|
sl@0
|
4251 |
EXPORT_C TInt RProcess::GetMemoryInfo(TModuleMemoryInfo& aInfo) const
|
sl@0
|
4252 |
/**
|
sl@0
|
4253 |
Gets the size and base address of the code and various data
|
sl@0
|
4254 |
sections of the process.
|
sl@0
|
4255 |
|
sl@0
|
4256 |
The run addresses are also returned.
|
sl@0
|
4257 |
|
sl@0
|
4258 |
@param aInfo On successful return, contains the base address and size of the
|
sl@0
|
4259 |
sections.
|
sl@0
|
4260 |
|
sl@0
|
4261 |
@return KErrNone, if successful; otherwise one of the other system wide error
|
sl@0
|
4262 |
codes.
|
sl@0
|
4263 |
*/
|
sl@0
|
4264 |
{
|
sl@0
|
4265 |
|
sl@0
|
4266 |
return Exec::ProcessGetMemoryInfo(iHandle,aInfo);
|
sl@0
|
4267 |
}
|
sl@0
|
4268 |
|
sl@0
|
4269 |
|
sl@0
|
4270 |
EXPORT_C TAny* RProcess::ExeExportData(void)
|
sl@0
|
4271 |
/**
|
sl@0
|
4272 |
Retrieves pointer to named symbol export data from the current process, i.e. the
|
sl@0
|
4273 |
process calling this function.
|
sl@0
|
4274 |
|
sl@0
|
4275 |
@return Pointer to export data when it is present, NULL if export data not found
|
sl@0
|
4276 |
@internalTechnology
|
sl@0
|
4277 |
@released
|
sl@0
|
4278 |
*/
|
sl@0
|
4279 |
{
|
sl@0
|
4280 |
|
sl@0
|
4281 |
return Exec::ProcessExeExportData();
|
sl@0
|
4282 |
}
|
sl@0
|
4283 |
|
sl@0
|
4284 |
|
sl@0
|
4285 |
|
sl@0
|
4286 |
EXPORT_C TInt TFindSemaphore::Next(TFullName &aResult)
|
sl@0
|
4287 |
/**
|
sl@0
|
4288 |
Finds the next global semaphore whose full name matches the match pattern.
|
sl@0
|
4289 |
|
sl@0
|
4290 |
If a global semaphore with a matching name is found, the function copies its
|
sl@0
|
4291 |
full name into the descriptor aResult. It also saves the find-handle associated
|
sl@0
|
4292 |
with the global semaphore into the TFindHandleBase part of this TFindSemaphore
|
sl@0
|
4293 |
object.
|
sl@0
|
4294 |
|
sl@0
|
4295 |
@param aResult A reference to a TBuf descriptor with a defined maximum length.
|
sl@0
|
4296 |
If a matching global semaphore is found, its full name is set
|
sl@0
|
4297 |
into this descriptor.
|
sl@0
|
4298 |
If no matching global semaphore is found, the descriptor length
|
sl@0
|
4299 |
is set to zero.
|
sl@0
|
4300 |
|
sl@0
|
4301 |
@return KErrNone if a matching global semaphore is found;
|
sl@0
|
4302 |
KErrNotFound otherwise.
|
sl@0
|
4303 |
*/
|
sl@0
|
4304 |
{
|
sl@0
|
4305 |
return NextObject(aResult,ESemaphore);
|
sl@0
|
4306 |
}
|
sl@0
|
4307 |
|
sl@0
|
4308 |
|
sl@0
|
4309 |
|
sl@0
|
4310 |
|
sl@0
|
4311 |
EXPORT_C void RSemaphore::Wait()
|
sl@0
|
4312 |
/**
|
sl@0
|
4313 |
Waits for a signal on the semaphore.
|
sl@0
|
4314 |
|
sl@0
|
4315 |
The function decrements the semaphore count by one and returns immediately
|
sl@0
|
4316 |
if it is zero or positive.
|
sl@0
|
4317 |
|
sl@0
|
4318 |
If the semaphore count is negative after being decremented, the calling thread is
|
sl@0
|
4319 |
added to a queue of threads maintained by this semaphore.
|
sl@0
|
4320 |
|
sl@0
|
4321 |
The thread waits until the semaphore is signalled. More than one thread can
|
sl@0
|
4322 |
be waiting on a particular semaphore at a time. When there are multiple threads
|
sl@0
|
4323 |
waiting on a semaphore, they are released in priority order.
|
sl@0
|
4324 |
|
sl@0
|
4325 |
If the semaphore is deleted, all threads waiting on that semaphore are released.
|
sl@0
|
4326 |
*/
|
sl@0
|
4327 |
{
|
sl@0
|
4328 |
|
sl@0
|
4329 |
Exec::SemaphoreWait(iHandle, 0);
|
sl@0
|
4330 |
}
|
sl@0
|
4331 |
|
sl@0
|
4332 |
|
sl@0
|
4333 |
|
sl@0
|
4334 |
|
sl@0
|
4335 |
EXPORT_C TInt RSemaphore::Wait(TInt aTimeout)
|
sl@0
|
4336 |
/**
|
sl@0
|
4337 |
Waits for a signal on the semaphore, or a timeout.
|
sl@0
|
4338 |
|
sl@0
|
4339 |
@param aTimeout The timeout value in micoseconds
|
sl@0
|
4340 |
|
sl@0
|
4341 |
@return KErrNone if the wait has completed normally.
|
sl@0
|
4342 |
KErrTimedOut if the timeout has expired.
|
sl@0
|
4343 |
KErrGeneral if the semaphore is being reset, i.e the semaphore
|
sl@0
|
4344 |
is about to be deleted.
|
sl@0
|
4345 |
KErrArgument if aTimeout is negative;
|
sl@0
|
4346 |
otherwise one of the other system wide error codes.
|
sl@0
|
4347 |
*/
|
sl@0
|
4348 |
{
|
sl@0
|
4349 |
|
sl@0
|
4350 |
return Exec::SemaphoreWait(iHandle, aTimeout);
|
sl@0
|
4351 |
}
|
sl@0
|
4352 |
|
sl@0
|
4353 |
|
sl@0
|
4354 |
|
sl@0
|
4355 |
|
sl@0
|
4356 |
EXPORT_C void RSemaphore::Signal()
|
sl@0
|
4357 |
/**
|
sl@0
|
4358 |
Signals the semaphore once.
|
sl@0
|
4359 |
|
sl@0
|
4360 |
The function increments the semaphore count by one. If the count was negative
|
sl@0
|
4361 |
before being incremented, the highest priority thread waiting on the semaphore's queue
|
sl@0
|
4362 |
of threads is removed from that queue and, provided that it is not suspended
|
sl@0
|
4363 |
for any other reason, is marked as ready to run.
|
sl@0
|
4364 |
*/
|
sl@0
|
4365 |
{
|
sl@0
|
4366 |
|
sl@0
|
4367 |
Exec::SemaphoreSignal1(iHandle);
|
sl@0
|
4368 |
}
|
sl@0
|
4369 |
|
sl@0
|
4370 |
|
sl@0
|
4371 |
|
sl@0
|
4372 |
|
sl@0
|
4373 |
EXPORT_C void RSemaphore::Signal(TInt aCount)
|
sl@0
|
4374 |
/**
|
sl@0
|
4375 |
Signals the semaphore one or more times.
|
sl@0
|
4376 |
|
sl@0
|
4377 |
The function increments the semaphore count. If the count was negative
|
sl@0
|
4378 |
before being incremented, the highest priority thread waiting on the semaphore's queue
|
sl@0
|
4379 |
of threads is removed from that queue and, provided that it is not suspended
|
sl@0
|
4380 |
for any other reason, is marked as ready to run.
|
sl@0
|
4381 |
|
sl@0
|
4382 |
@param aCount The number of times the semaphore is to be signalled.
|
sl@0
|
4383 |
*/
|
sl@0
|
4384 |
{
|
sl@0
|
4385 |
|
sl@0
|
4386 |
__ASSERT_ALWAYS(aCount>=0,Panic(ESemSignalCountNegative));
|
sl@0
|
4387 |
Exec::SemaphoreSignalN(iHandle,aCount);
|
sl@0
|
4388 |
}
|
sl@0
|
4389 |
|
sl@0
|
4390 |
|
sl@0
|
4391 |
|
sl@0
|
4392 |
|
sl@0
|
4393 |
EXPORT_C RCriticalSection::RCriticalSection()
|
sl@0
|
4394 |
: iBlocked(1)
|
sl@0
|
4395 |
/**
|
sl@0
|
4396 |
Default constructor.
|
sl@0
|
4397 |
*/
|
sl@0
|
4398 |
{}
|
sl@0
|
4399 |
|
sl@0
|
4400 |
|
sl@0
|
4401 |
|
sl@0
|
4402 |
|
sl@0
|
4403 |
EXPORT_C void RCriticalSection::Close()
|
sl@0
|
4404 |
/**
|
sl@0
|
4405 |
Closes the handle to the critical section.
|
sl@0
|
4406 |
|
sl@0
|
4407 |
As a critical section object is implemented using a semaphore, this has the
|
sl@0
|
4408 |
effect of closing the handle to the semaphore.
|
sl@0
|
4409 |
*/
|
sl@0
|
4410 |
{
|
sl@0
|
4411 |
|
sl@0
|
4412 |
RSemaphore::Close();
|
sl@0
|
4413 |
}
|
sl@0
|
4414 |
|
sl@0
|
4415 |
|
sl@0
|
4416 |
|
sl@0
|
4417 |
|
sl@0
|
4418 |
EXPORT_C void RCriticalSection::Wait()
|
sl@0
|
4419 |
/**
|
sl@0
|
4420 |
Waits for the critical section to become free.
|
sl@0
|
4421 |
|
sl@0
|
4422 |
If no other thread is in the critical section, control returns immediately
|
sl@0
|
4423 |
and the current thread can continue into the section.
|
sl@0
|
4424 |
|
sl@0
|
4425 |
If another thread is already in the critical section, the current thread is
|
sl@0
|
4426 |
marked as waiting (on a semaphore); the current thread is added to a queue
|
sl@0
|
4427 |
of threads maintained by this critical section.
|
sl@0
|
4428 |
*/
|
sl@0
|
4429 |
{
|
sl@0
|
4430 |
|
sl@0
|
4431 |
if (__e32_atomic_add_acq32(&iBlocked, KMaxTUint32) != 1)
|
sl@0
|
4432 |
RSemaphore::Wait();
|
sl@0
|
4433 |
}
|
sl@0
|
4434 |
|
sl@0
|
4435 |
|
sl@0
|
4436 |
|
sl@0
|
4437 |
|
sl@0
|
4438 |
EXPORT_C void RCriticalSection::Signal()
|
sl@0
|
4439 |
/**
|
sl@0
|
4440 |
Signals an exit from the critical section.
|
sl@0
|
4441 |
|
sl@0
|
4442 |
A thread calls this function when it exits from the critical section.
|
sl@0
|
4443 |
The first eligible thread waiting on the critical section's queue of threads
|
sl@0
|
4444 |
is removed from that queue and, provided that it is not suspended for any other
|
sl@0
|
4445 |
reason, is marked as ready to run. That thread will, therefore, be the next to
|
sl@0
|
4446 |
proceed into the critical section.
|
sl@0
|
4447 |
*/
|
sl@0
|
4448 |
{
|
sl@0
|
4449 |
|
sl@0
|
4450 |
__ASSERT_ALWAYS(iBlocked<1,Panic(ECriticalSectionStraySignal));
|
sl@0
|
4451 |
if (TInt(__e32_atomic_add_rel32(&iBlocked, 1)) < 0)
|
sl@0
|
4452 |
RSemaphore::Signal();
|
sl@0
|
4453 |
}
|
sl@0
|
4454 |
|
sl@0
|
4455 |
|
sl@0
|
4456 |
|
sl@0
|
4457 |
|
sl@0
|
4458 |
EXPORT_C TInt TFindThread::Next(TFullName &aResult)
|
sl@0
|
4459 |
/**
|
sl@0
|
4460 |
Gets the full name of the next global thread which matches the match pattern.
|
sl@0
|
4461 |
|
sl@0
|
4462 |
@param aResult A reference to a TBuf descriptor with a defined maximum length.
|
sl@0
|
4463 |
If a matching global thread is found, its full name is set into
|
sl@0
|
4464 |
this descriptor. If no matching global thread is found,
|
sl@0
|
4465 |
the descriptor length is set to zero.
|
sl@0
|
4466 |
|
sl@0
|
4467 |
@return KErrNone if successful, otherwise one of the other system-wide error
|
sl@0
|
4468 |
codes.
|
sl@0
|
4469 |
*/
|
sl@0
|
4470 |
{
|
sl@0
|
4471 |
return NextObject(aResult,EThread);
|
sl@0
|
4472 |
}
|
sl@0
|
4473 |
|
sl@0
|
4474 |
|
sl@0
|
4475 |
|
sl@0
|
4476 |
|
sl@0
|
4477 |
EXPORT_C TThreadId RThread::Id() const
|
sl@0
|
4478 |
/**
|
sl@0
|
4479 |
Gets the Id of this thread.
|
sl@0
|
4480 |
|
sl@0
|
4481 |
@return The Id of this thread.
|
sl@0
|
4482 |
*/
|
sl@0
|
4483 |
{
|
sl@0
|
4484 |
|
sl@0
|
4485 |
return TThreadId( (TUint)Exec::ThreadId(iHandle) );
|
sl@0
|
4486 |
}
|
sl@0
|
4487 |
|
sl@0
|
4488 |
|
sl@0
|
4489 |
|
sl@0
|
4490 |
|
sl@0
|
4491 |
EXPORT_C void RThread::HandleCount(TInt& aProcessHandleCount, TInt& aThreadHandleCount) const
|
sl@0
|
4492 |
/**
|
sl@0
|
4493 |
Gets the number of handles open in this thread, and the number of handles open
|
sl@0
|
4494 |
in the process which owns this thread.
|
sl@0
|
4495 |
|
sl@0
|
4496 |
@param aProcessHandleCount On return, contains the number of handles open in
|
sl@0
|
4497 |
the process which owns this thread.
|
sl@0
|
4498 |
@param aThreadHandleCount On return, contains the number of handles open in
|
sl@0
|
4499 |
this thread.
|
sl@0
|
4500 |
*/
|
sl@0
|
4501 |
{
|
sl@0
|
4502 |
|
sl@0
|
4503 |
Exec::HandleCount(iHandle,aProcessHandleCount,aThreadHandleCount);
|
sl@0
|
4504 |
}
|
sl@0
|
4505 |
|
sl@0
|
4506 |
|
sl@0
|
4507 |
|
sl@0
|
4508 |
|
sl@0
|
4509 |
EXPORT_C TExceptionHandler User::ExceptionHandler()
|
sl@0
|
4510 |
/**
|
sl@0
|
4511 |
Gets a pointer to the exception handler for the current thread.
|
sl@0
|
4512 |
|
sl@0
|
4513 |
@return A pointer to the exception handler.
|
sl@0
|
4514 |
*/
|
sl@0
|
4515 |
{
|
sl@0
|
4516 |
return(Exec::ExceptionHandler(KCurrentThreadHandle));
|
sl@0
|
4517 |
}
|
sl@0
|
4518 |
|
sl@0
|
4519 |
|
sl@0
|
4520 |
|
sl@0
|
4521 |
|
sl@0
|
4522 |
EXPORT_C TInt User::SetExceptionHandler(TExceptionHandler aHandler,TUint32 aMask)
|
sl@0
|
4523 |
/**
|
sl@0
|
4524 |
Sets a new exception handler for the current thread. Note that the handler is not
|
sl@0
|
4525 |
guaranteed to receive floating point exceptions (KExceptionFpe) when a hardware
|
sl@0
|
4526 |
floating point implementation is in use - see User::SetFloatingPointMode for
|
sl@0
|
4527 |
hardware floating point modes and whether they cause user-trappable exceptions.
|
sl@0
|
4528 |
|
sl@0
|
4529 |
@param aHandler The new exception handler.
|
sl@0
|
4530 |
@param aMask One or more flags defining the exception categories which
|
sl@0
|
4531 |
the handler can handle.
|
sl@0
|
4532 |
|
sl@0
|
4533 |
@return KErrNone if successful, otherwise another of the system-wide error codes.
|
sl@0
|
4534 |
|
sl@0
|
4535 |
@see KExceptionAbort
|
sl@0
|
4536 |
@see KExceptionKill
|
sl@0
|
4537 |
@see KExceptionUserInterrupt
|
sl@0
|
4538 |
@see KExceptionFpe
|
sl@0
|
4539 |
@see KExceptionFault
|
sl@0
|
4540 |
@see KExceptionInteger
|
sl@0
|
4541 |
@see KExceptionDebug
|
sl@0
|
4542 |
*/
|
sl@0
|
4543 |
{
|
sl@0
|
4544 |
return(Exec::SetExceptionHandler(KCurrentThreadHandle, aHandler, aMask));
|
sl@0
|
4545 |
}
|
sl@0
|
4546 |
|
sl@0
|
4547 |
|
sl@0
|
4548 |
|
sl@0
|
4549 |
|
sl@0
|
4550 |
EXPORT_C void User::ModifyExceptionMask(TUint32 aClearMask, TUint32 aSetMask)
|
sl@0
|
4551 |
/**
|
sl@0
|
4552 |
Changes the set of exceptions which the current thread's exception
|
sl@0
|
4553 |
handler can deal with.
|
sl@0
|
4554 |
|
sl@0
|
4555 |
aClearMask is the set of flags defining the set of exceptions which the
|
sl@0
|
4556 |
exception handler no longer deals with, while aSetMask is the set of flags
|
sl@0
|
4557 |
defining the new set of exceptions to be set.
|
sl@0
|
4558 |
|
sl@0
|
4559 |
Flag clearing is done before flag setting.
|
sl@0
|
4560 |
|
sl@0
|
4561 |
@param aClearMask One or more flags defining the exceptions which the current
|
sl@0
|
4562 |
exception handler no longer deals with.
|
sl@0
|
4563 |
@param aSetMask One or more flags defining the new set of exceptions which
|
sl@0
|
4564 |
the current exception handler is to deal with.
|
sl@0
|
4565 |
*/
|
sl@0
|
4566 |
{
|
sl@0
|
4567 |
Exec::ModifyExceptionMask(KCurrentThreadHandle, aClearMask, aSetMask);
|
sl@0
|
4568 |
}
|
sl@0
|
4569 |
|
sl@0
|
4570 |
|
sl@0
|
4571 |
|
sl@0
|
4572 |
|
sl@0
|
4573 |
_LIT(KLitUserExec, "USER-EXEC");
|
sl@0
|
4574 |
EXPORT_C TInt User::RaiseException(TExcType aType)
|
sl@0
|
4575 |
/**
|
sl@0
|
4576 |
Raises an exception of a specified type on the current thread.
|
sl@0
|
4577 |
|
sl@0
|
4578 |
If the thread has an exception handler to handle this type of exception,
|
sl@0
|
4579 |
then it is called.
|
sl@0
|
4580 |
|
sl@0
|
4581 |
If the thread has no exception handler to handle this type of exception, then
|
sl@0
|
4582 |
the function raises a USER-EXEC 3 panic.
|
sl@0
|
4583 |
|
sl@0
|
4584 |
Note that exception handlers are executed in the context of the thread on which
|
sl@0
|
4585 |
the exception is raised; control returns to the point of the exception.
|
sl@0
|
4586 |
|
sl@0
|
4587 |
@param aType The type of exception.
|
sl@0
|
4588 |
|
sl@0
|
4589 |
@return KErrNone if successful, otherwise another of the system-wide
|
sl@0
|
4590 |
error codes.
|
sl@0
|
4591 |
*/
|
sl@0
|
4592 |
{
|
sl@0
|
4593 |
if (Exec::IsExceptionHandled(KCurrentThreadHandle,aType,ETrue))
|
sl@0
|
4594 |
{
|
sl@0
|
4595 |
Exec::ThreadSetFlags(KCurrentThreadHandle, 0, KThreadFlagLastChance);
|
sl@0
|
4596 |
TUint32 type = aType;
|
sl@0
|
4597 |
User::HandleException(&type);
|
sl@0
|
4598 |
}
|
sl@0
|
4599 |
else
|
sl@0
|
4600 |
User::Panic(KLitUserExec, ECausedException);
|
sl@0
|
4601 |
return KErrNone;
|
sl@0
|
4602 |
}
|
sl@0
|
4603 |
|
sl@0
|
4604 |
|
sl@0
|
4605 |
|
sl@0
|
4606 |
|
sl@0
|
4607 |
EXPORT_C TBool User::IsExceptionHandled(TExcType aType)
|
sl@0
|
4608 |
/**
|
sl@0
|
4609 |
Tests whether the specified exception type can be handled by the
|
sl@0
|
4610 |
current thread.
|
sl@0
|
4611 |
|
sl@0
|
4612 |
@param aType The type of exception.
|
sl@0
|
4613 |
|
sl@0
|
4614 |
@return True, if the thread has an exception handler which can handle
|
sl@0
|
4615 |
an exception of type aType.
|
sl@0
|
4616 |
False, if the thread has no exception handler or the thread has
|
sl@0
|
4617 |
an exception handler which cannot handle the exception defined
|
sl@0
|
4618 |
by aType.
|
sl@0
|
4619 |
*/
|
sl@0
|
4620 |
{
|
sl@0
|
4621 |
return (Exec::IsExceptionHandled(KCurrentThreadHandle,aType,EFalse));
|
sl@0
|
4622 |
}
|
sl@0
|
4623 |
|
sl@0
|
4624 |
|
sl@0
|
4625 |
|
sl@0
|
4626 |
|
sl@0
|
4627 |
EXPORT_C void RThread::Context(TDes8 &aDes) const
|
sl@0
|
4628 |
/**
|
sl@0
|
4629 |
Gets the register contents of this thread.
|
sl@0
|
4630 |
|
sl@0
|
4631 |
@param aDes On return, contains the register contents, starting with R0.
|
sl@0
|
4632 |
*/
|
sl@0
|
4633 |
{
|
sl@0
|
4634 |
|
sl@0
|
4635 |
Exec::ThreadContext(iHandle,aDes);
|
sl@0
|
4636 |
}
|
sl@0
|
4637 |
|
sl@0
|
4638 |
|
sl@0
|
4639 |
|
sl@0
|
4640 |
|
sl@0
|
4641 |
EXPORT_C void RThread::Resume() const
|
sl@0
|
4642 |
/**
|
sl@0
|
4643 |
Makes the thread eligible for execution.
|
sl@0
|
4644 |
|
sl@0
|
4645 |
After a thread is created, it is put into a suspended state; the thread is
|
sl@0
|
4646 |
not eligible to run until Resume() is called.
|
sl@0
|
4647 |
|
sl@0
|
4648 |
This function must also be called to resume execution of this thread after
|
sl@0
|
4649 |
it has been explicitly suspended by a call to Suspend().
|
sl@0
|
4650 |
|
sl@0
|
4651 |
Note that when a thread is created, it is given the priority EPriorityNormal
|
sl@0
|
4652 |
by default. The fact that a thread is initially put into a suspended state
|
sl@0
|
4653 |
means that the thread priority can be changed by calling the thread's
|
sl@0
|
4654 |
SetPriority() member function before the thread is started by a call to Resume().
|
sl@0
|
4655 |
*/
|
sl@0
|
4656 |
{
|
sl@0
|
4657 |
|
sl@0
|
4658 |
Exec::ThreadResume(iHandle);
|
sl@0
|
4659 |
}
|
sl@0
|
4660 |
|
sl@0
|
4661 |
|
sl@0
|
4662 |
|
sl@0
|
4663 |
|
sl@0
|
4664 |
EXPORT_C void RThread::Suspend() const
|
sl@0
|
4665 |
/**
|
sl@0
|
4666 |
Suspends execution of this thread.
|
sl@0
|
4667 |
|
sl@0
|
4668 |
The thread is not scheduled to run until a subsequent call to Resume() is made.
|
sl@0
|
4669 |
*/
|
sl@0
|
4670 |
{
|
sl@0
|
4671 |
|
sl@0
|
4672 |
Exec::ThreadSuspend(iHandle);
|
sl@0
|
4673 |
}
|
sl@0
|
4674 |
|
sl@0
|
4675 |
|
sl@0
|
4676 |
|
sl@0
|
4677 |
|
sl@0
|
4678 |
EXPORT_C TThreadPriority RThread::Priority() const
|
sl@0
|
4679 |
/**
|
sl@0
|
4680 |
Gets the priority of this thread.
|
sl@0
|
4681 |
|
sl@0
|
4682 |
@return The priority.
|
sl@0
|
4683 |
*/
|
sl@0
|
4684 |
{
|
sl@0
|
4685 |
|
sl@0
|
4686 |
return(Exec::ThreadPriority(iHandle));
|
sl@0
|
4687 |
}
|
sl@0
|
4688 |
|
sl@0
|
4689 |
|
sl@0
|
4690 |
|
sl@0
|
4691 |
|
sl@0
|
4692 |
EXPORT_C void RThread::SetProcessPriority(TProcessPriority aPriority) const
|
sl@0
|
4693 |
/**
|
sl@0
|
4694 |
Sets the priority of the process which owns this thread to one of the values
|
sl@0
|
4695 |
defined by the TProcessPriority enumeration.
|
sl@0
|
4696 |
|
sl@0
|
4697 |
The priority can be set to one of the four values:
|
sl@0
|
4698 |
|
sl@0
|
4699 |
EPriorityLow
|
sl@0
|
4700 |
|
sl@0
|
4701 |
EPriorityBackground
|
sl@0
|
4702 |
|
sl@0
|
4703 |
EPriorityForeground
|
sl@0
|
4704 |
|
sl@0
|
4705 |
EPriorityHigh
|
sl@0
|
4706 |
|
sl@0
|
4707 |
The absolute priority of all threads owned by the process (and all threads
|
sl@0
|
4708 |
owned by those threads etc.) are re-calculated.
|
sl@0
|
4709 |
|
sl@0
|
4710 |
Note:
|
sl@0
|
4711 |
|
sl@0
|
4712 |
The use of the priority values EPriorityWindowServer, EPriorityFileServer,
|
sl@0
|
4713 |
EPriorityRealTimeServer and EPrioritySupervisor is restricted to Symbian OS,
|
sl@0
|
4714 |
and any attempt to explicitly set any of these priority values raises a KERN-EXEC
|
sl@0
|
4715 |
14 panic.
|
sl@0
|
4716 |
|
sl@0
|
4717 |
@param aPriority The priority value.
|
sl@0
|
4718 |
|
sl@0
|
4719 |
@deprecated Not allowed on threads in a different process.
|
sl@0
|
4720 |
Replace with RProcess::SetPriority or RMessagePtr2::SetProcessPriority
|
sl@0
|
4721 |
*/
|
sl@0
|
4722 |
{
|
sl@0
|
4723 |
|
sl@0
|
4724 |
Exec::ThreadSetProcessPriority(iHandle,aPriority);
|
sl@0
|
4725 |
}
|
sl@0
|
4726 |
|
sl@0
|
4727 |
|
sl@0
|
4728 |
|
sl@0
|
4729 |
|
sl@0
|
4730 |
EXPORT_C TProcessPriority RThread::ProcessPriority() const
|
sl@0
|
4731 |
/**
|
sl@0
|
4732 |
Gets the priority of the process which owns this thread.
|
sl@0
|
4733 |
|
sl@0
|
4734 |
@return The process priority.
|
sl@0
|
4735 |
*/
|
sl@0
|
4736 |
{
|
sl@0
|
4737 |
|
sl@0
|
4738 |
return(Exec::ThreadProcessPriority(iHandle));
|
sl@0
|
4739 |
}
|
sl@0
|
4740 |
|
sl@0
|
4741 |
|
sl@0
|
4742 |
|
sl@0
|
4743 |
|
sl@0
|
4744 |
EXPORT_C void RThread::SetPriority(TThreadPriority aPriority) const
|
sl@0
|
4745 |
/**
|
sl@0
|
4746 |
Sets the priority of the thread to one of the values defined by
|
sl@0
|
4747 |
the TThreadPriority enumeration.
|
sl@0
|
4748 |
|
sl@0
|
4749 |
The resulting absolute priority of the thread depends on the value of aPriority
|
sl@0
|
4750 |
and the priority of the owning process.
|
sl@0
|
4751 |
|
sl@0
|
4752 |
Use of the priority value EPriorityNull is restricted to Symbian OS, and any
|
sl@0
|
4753 |
attempt to explicitly set this value causes a KERN-EXEC 14 panic to be raised.
|
sl@0
|
4754 |
|
sl@0
|
4755 |
@param aPriority The priority value.
|
sl@0
|
4756 |
|
sl@0
|
4757 |
@capability ProtServ if aPriority is EPriorityAbsoluteRealTime1 or higher
|
sl@0
|
4758 |
|
sl@0
|
4759 |
@panic KERN-EXEC 14, if aPriority is invalid or set to EPriorityNull
|
sl@0
|
4760 |
@panic KERN-EXEC 46, if aPriority is EPriorityAbsoluteRealTime1 or higher
|
sl@0
|
4761 |
and calling process does not have ProtServ capability
|
sl@0
|
4762 |
*/
|
sl@0
|
4763 |
{
|
sl@0
|
4764 |
|
sl@0
|
4765 |
Exec::ThreadSetPriority(iHandle,aPriority);
|
sl@0
|
4766 |
}
|
sl@0
|
4767 |
|
sl@0
|
4768 |
|
sl@0
|
4769 |
|
sl@0
|
4770 |
|
sl@0
|
4771 |
EXPORT_C User::TCritical User::Critical(RThread aThread)
|
sl@0
|
4772 |
/**
|
sl@0
|
4773 |
Gets the critical state associated with the specified thread.
|
sl@0
|
4774 |
|
sl@0
|
4775 |
@param aThread The thread whose critical state is to be retrieved.
|
sl@0
|
4776 |
|
sl@0
|
4777 |
@return The critical state.
|
sl@0
|
4778 |
|
sl@0
|
4779 |
@see User::SetCritical()
|
sl@0
|
4780 |
*/
|
sl@0
|
4781 |
{
|
sl@0
|
4782 |
TUint32 flags = Exec::ThreadFlags(aThread.Handle());
|
sl@0
|
4783 |
if (flags & KThreadFlagSystemPermanent)
|
sl@0
|
4784 |
return ESystemPermanent;
|
sl@0
|
4785 |
if (flags & KThreadFlagSystemCritical)
|
sl@0
|
4786 |
return ESystemCritical;
|
sl@0
|
4787 |
if (flags & KThreadFlagProcessPermanent)
|
sl@0
|
4788 |
return EProcessPermanent;
|
sl@0
|
4789 |
if (flags & KThreadFlagProcessCritical)
|
sl@0
|
4790 |
return EProcessCritical;
|
sl@0
|
4791 |
return ENotCritical;
|
sl@0
|
4792 |
}
|
sl@0
|
4793 |
|
sl@0
|
4794 |
|
sl@0
|
4795 |
|
sl@0
|
4796 |
|
sl@0
|
4797 |
EXPORT_C User::TCritical User::Critical()
|
sl@0
|
4798 |
/**
|
sl@0
|
4799 |
Gets the critical state associated with the current thread.
|
sl@0
|
4800 |
|
sl@0
|
4801 |
@return The critical state.
|
sl@0
|
4802 |
|
sl@0
|
4803 |
@see User::SetCritical()
|
sl@0
|
4804 |
*/
|
sl@0
|
4805 |
{
|
sl@0
|
4806 |
RThread me;
|
sl@0
|
4807 |
return User::Critical(me);
|
sl@0
|
4808 |
}
|
sl@0
|
4809 |
|
sl@0
|
4810 |
|
sl@0
|
4811 |
|
sl@0
|
4812 |
|
sl@0
|
4813 |
/**
|
sl@0
|
4814 |
Sets up or changes the effect that termination of the current
|
sl@0
|
4815 |
thread has, either on its owning process, or on the whole system.
|
sl@0
|
4816 |
|
sl@0
|
4817 |
The precise effect of thread termination is defined by
|
sl@0
|
4818 |
the following specific values of the TCritical enum:
|
sl@0
|
4819 |
- ENotCritical
|
sl@0
|
4820 |
- EProcessCritical
|
sl@0
|
4821 |
- EProcessPermanent
|
sl@0
|
4822 |
- ESystemCritical
|
sl@0
|
4823 |
- ESystemPermanent
|
sl@0
|
4824 |
|
sl@0
|
4825 |
Notes:
|
sl@0
|
4826 |
-# The enum value EAllThreadsCritical cannot be set using this function. It is
|
sl@0
|
4827 |
associated with a process, not a thread, and, if appropriate, should be set
|
sl@0
|
4828 |
using User::SetProcessCritical().
|
sl@0
|
4829 |
-# The states associated with ENotCritical, EProcessCritical,
|
sl@0
|
4830 |
EProcessPermanent, ESystemCritical and ESystemPermanent
|
sl@0
|
4831 |
are all mutually exclusive, i.e. the thread can only be in one of these states
|
sl@0
|
4832 |
at any one time
|
sl@0
|
4833 |
|
sl@0
|
4834 |
@param aCritical The state to be set.
|
sl@0
|
4835 |
|
sl@0
|
4836 |
@return KErrNone, if successful;
|
sl@0
|
4837 |
KErrArgument, if EAllThreadsCritical is passed - this is a
|
sl@0
|
4838 |
state associated with a process, and
|
sl@0
|
4839 |
you use User::SetProcessCritical() to set it.
|
sl@0
|
4840 |
|
sl@0
|
4841 |
@capability ProtServ if aCritical==ESystemCritical or ESystemPermanent
|
sl@0
|
4842 |
|
sl@0
|
4843 |
@see User::Critical()
|
sl@0
|
4844 |
@see User::ProcessCritical()
|
sl@0
|
4845 |
@see User::SetProcessCritical()
|
sl@0
|
4846 |
*/
|
sl@0
|
4847 |
EXPORT_C TInt User::SetCritical(TCritical aCritical)
|
sl@0
|
4848 |
{
|
sl@0
|
4849 |
const TUint32 clear = KThreadFlagSystemPermanent | KThreadFlagSystemCritical |
|
sl@0
|
4850 |
KThreadFlagProcessPermanent | KThreadFlagProcessCritical;
|
sl@0
|
4851 |
TUint32 set;
|
sl@0
|
4852 |
switch (aCritical)
|
sl@0
|
4853 |
{
|
sl@0
|
4854 |
case ENotCritical: set = 0; break;
|
sl@0
|
4855 |
case EProcessCritical: set = KThreadFlagProcessCritical; break;
|
sl@0
|
4856 |
case EProcessPermanent: set = KThreadFlagProcessPermanent; break;
|
sl@0
|
4857 |
case ESystemCritical: set = KThreadFlagSystemCritical; break;
|
sl@0
|
4858 |
case ESystemPermanent: set = KThreadFlagSystemPermanent; break;
|
sl@0
|
4859 |
default: return KErrArgument;
|
sl@0
|
4860 |
}
|
sl@0
|
4861 |
Exec::ThreadSetFlags(KCurrentThreadHandle, clear, set);
|
sl@0
|
4862 |
return KErrNone;
|
sl@0
|
4863 |
}
|
sl@0
|
4864 |
|
sl@0
|
4865 |
|
sl@0
|
4866 |
|
sl@0
|
4867 |
|
sl@0
|
4868 |
EXPORT_C TInt User::SetRealtimeState(TRealtimeState aState)
|
sl@0
|
4869 |
{
|
sl@0
|
4870 |
const TUint32 clear = KThreadFlagRealtime | KThreadFlagRealtimeTest;
|
sl@0
|
4871 |
TUint32 set;
|
sl@0
|
4872 |
switch (aState)
|
sl@0
|
4873 |
{
|
sl@0
|
4874 |
case ERealtimeStateOff: set = 0; break;
|
sl@0
|
4875 |
case ERealtimeStateOn: set = KThreadFlagRealtime; break;
|
sl@0
|
4876 |
case ERealtimeStateWarn: set = KThreadFlagRealtime|KThreadFlagRealtimeTest; break;
|
sl@0
|
4877 |
default: return KErrArgument;
|
sl@0
|
4878 |
}
|
sl@0
|
4879 |
Exec::ThreadSetFlags(KCurrentThreadHandle, clear, set);
|
sl@0
|
4880 |
return KErrNone;
|
sl@0
|
4881 |
}
|
sl@0
|
4882 |
|
sl@0
|
4883 |
|
sl@0
|
4884 |
|
sl@0
|
4885 |
|
sl@0
|
4886 |
EXPORT_C User::TCritical User::ProcessCritical(RProcess aProcess)
|
sl@0
|
4887 |
/**
|
sl@0
|
4888 |
Gets the critical state associated with the specified process.
|
sl@0
|
4889 |
|
sl@0
|
4890 |
@param aProcess The process whose critical state is to be retrieved.
|
sl@0
|
4891 |
|
sl@0
|
4892 |
@return The critical state.
|
sl@0
|
4893 |
|
sl@0
|
4894 |
@see User::SetProcessCritical()
|
sl@0
|
4895 |
*/
|
sl@0
|
4896 |
{
|
sl@0
|
4897 |
TUint32 flags = Exec::ProcessFlags(aProcess.Handle());
|
sl@0
|
4898 |
if (flags & KProcessFlagSystemPermanent)
|
sl@0
|
4899 |
return ESystemPermanent;
|
sl@0
|
4900 |
if (flags & KProcessFlagSystemCritical)
|
sl@0
|
4901 |
return ESystemCritical;
|
sl@0
|
4902 |
if (flags & (KThreadFlagProcessPermanent | KThreadFlagProcessCritical))
|
sl@0
|
4903 |
return EAllThreadsCritical;
|
sl@0
|
4904 |
return ENotCritical;
|
sl@0
|
4905 |
}
|
sl@0
|
4906 |
|
sl@0
|
4907 |
|
sl@0
|
4908 |
|
sl@0
|
4909 |
|
sl@0
|
4910 |
EXPORT_C User::TCritical User::ProcessCritical()
|
sl@0
|
4911 |
/**
|
sl@0
|
4912 |
Gets the critical state associated with the current process.
|
sl@0
|
4913 |
|
sl@0
|
4914 |
@return The critical state.
|
sl@0
|
4915 |
|
sl@0
|
4916 |
@see User::SetProcessCritical()
|
sl@0
|
4917 |
*/
|
sl@0
|
4918 |
{
|
sl@0
|
4919 |
RProcess me;
|
sl@0
|
4920 |
return User::ProcessCritical(me);
|
sl@0
|
4921 |
}
|
sl@0
|
4922 |
|
sl@0
|
4923 |
|
sl@0
|
4924 |
|
sl@0
|
4925 |
|
sl@0
|
4926 |
EXPORT_C TInt User::SetProcessCritical(TCritical aCritical)
|
sl@0
|
4927 |
/**
|
sl@0
|
4928 |
Sets up or changes the effect that termination of subsequently created threads
|
sl@0
|
4929 |
will have, either on the owning process, or on the whole system.
|
sl@0
|
4930 |
|
sl@0
|
4931 |
It is important to note that we are not referring to threads that have already
|
sl@0
|
4932 |
been created, but threads that will be created subsequent to a call to this function.
|
sl@0
|
4933 |
|
sl@0
|
4934 |
The precise effect of thread termination is defined by the following specific
|
sl@0
|
4935 |
values of the TCritical enum:
|
sl@0
|
4936 |
- ENotCritical
|
sl@0
|
4937 |
- EAllThreadsCritical
|
sl@0
|
4938 |
- ESystemCritical
|
sl@0
|
4939 |
- ESystemPermanent
|
sl@0
|
4940 |
|
sl@0
|
4941 |
Notes:
|
sl@0
|
4942 |
-# The enum values EProcessCritical and EProcessPermanent cannot be set using
|
sl@0
|
4943 |
this function. They are states associated with
|
sl@0
|
4944 |
a thread, not a process, and, if appropriate, should be set
|
sl@0
|
4945 |
using User::SetCritical().
|
sl@0
|
4946 |
-# The states associated with ENotCritical, EAllThreadsCritical,
|
sl@0
|
4947 |
ESystemCritical and ESystemPermanent are all mutually exclusive, i.e. the
|
sl@0
|
4948 |
process can only be in one of these states at any one time.
|
sl@0
|
4949 |
|
sl@0
|
4950 |
@param aCritical The state to be set.
|
sl@0
|
4951 |
|
sl@0
|
4952 |
@return KErrNone, if successful;
|
sl@0
|
4953 |
KErrArgument, if either EProcessCritical or EProcessPermanent
|
sl@0
|
4954 |
is passed - these are states associated with a thread, and
|
sl@0
|
4955 |
you use User::SetCritical() to set them.
|
sl@0
|
4956 |
|
sl@0
|
4957 |
@capability ProtServ if aCritical==ESystemCritical or ESystemPermanent
|
sl@0
|
4958 |
|
sl@0
|
4959 |
@see User::ProcessCritical()
|
sl@0
|
4960 |
@see User::SetCritical()
|
sl@0
|
4961 |
@see User::Critical()
|
sl@0
|
4962 |
*/
|
sl@0
|
4963 |
{
|
sl@0
|
4964 |
const TUint32 clear = KProcessFlagSystemPermanent | KProcessFlagSystemCritical |
|
sl@0
|
4965 |
KThreadFlagProcessPermanent | KThreadFlagProcessCritical;
|
sl@0
|
4966 |
TUint32 set;
|
sl@0
|
4967 |
switch (aCritical)
|
sl@0
|
4968 |
{
|
sl@0
|
4969 |
case ENotCritical: set = 0; break;
|
sl@0
|
4970 |
case EAllThreadsCritical: set = KThreadFlagProcessCritical; break;
|
sl@0
|
4971 |
case ESystemCritical: set = KProcessFlagSystemCritical; break;
|
sl@0
|
4972 |
case ESystemPermanent: set = KProcessFlagSystemPermanent|KProcessFlagSystemCritical; break;
|
sl@0
|
4973 |
default: return KErrArgument;
|
sl@0
|
4974 |
}
|
sl@0
|
4975 |
Exec::ProcessSetFlags(KCurrentProcessHandle, clear, set);
|
sl@0
|
4976 |
return KErrNone;
|
sl@0
|
4977 |
}
|
sl@0
|
4978 |
|
sl@0
|
4979 |
|
sl@0
|
4980 |
|
sl@0
|
4981 |
|
sl@0
|
4982 |
EXPORT_C TBool User::PriorityControl()
|
sl@0
|
4983 |
/**
|
sl@0
|
4984 |
Tests whether the current process allows other processes to switch its priority
|
sl@0
|
4985 |
between 'foreground' and 'background'.
|
sl@0
|
4986 |
|
sl@0
|
4987 |
@return True, if the current process allows other processes to switch its priority;
|
sl@0
|
4988 |
false, otherwise.
|
sl@0
|
4989 |
*/
|
sl@0
|
4990 |
{
|
sl@0
|
4991 |
return Exec::ProcessFlags(KCurrentProcessHandle) & KProcessFlagPriorityControl;
|
sl@0
|
4992 |
}
|
sl@0
|
4993 |
|
sl@0
|
4994 |
|
sl@0
|
4995 |
|
sl@0
|
4996 |
|
sl@0
|
4997 |
EXPORT_C void User::SetPriorityControl(TBool aEnable)
|
sl@0
|
4998 |
/**
|
sl@0
|
4999 |
Allows the current process to choose to have its priority switched by another
|
sl@0
|
5000 |
process between 'foreground' and 'background'.
|
sl@0
|
5001 |
|
sl@0
|
5002 |
By default a process does not allow this.
|
sl@0
|
5003 |
|
sl@0
|
5004 |
@param aEnable If ETrue, allows other processes to switch the current process's
|
sl@0
|
5005 |
priority.
|
sl@0
|
5006 |
If EFalse, prevents other processes from switching the current
|
sl@0
|
5007 |
process's priority.
|
sl@0
|
5008 |
*/
|
sl@0
|
5009 |
{
|
sl@0
|
5010 |
TUint32 set = aEnable ? KProcessFlagPriorityControl : 0;
|
sl@0
|
5011 |
Exec::ProcessSetFlags(KCurrentProcessHandle, KProcessFlagPriorityControl, set);
|
sl@0
|
5012 |
}
|
sl@0
|
5013 |
|
sl@0
|
5014 |
|
sl@0
|
5015 |
|
sl@0
|
5016 |
EXPORT_C TInt RThread::RequestCount() const
|
sl@0
|
5017 |
/**
|
sl@0
|
5018 |
Gets this thread's request semaphore count.
|
sl@0
|
5019 |
|
sl@0
|
5020 |
The request semaphore is created when a thread is created, and is used to
|
sl@0
|
5021 |
support asynchronous requests.
|
sl@0
|
5022 |
|
sl@0
|
5023 |
A negative value implies that this thread is waiting for at least
|
sl@0
|
5024 |
one asynchronous request to complete.
|
sl@0
|
5025 |
|
sl@0
|
5026 |
@return This thread's request semaphore count.
|
sl@0
|
5027 |
*/
|
sl@0
|
5028 |
{
|
sl@0
|
5029 |
|
sl@0
|
5030 |
return(Exec::ThreadRequestCount(iHandle));
|
sl@0
|
5031 |
}
|
sl@0
|
5032 |
|
sl@0
|
5033 |
|
sl@0
|
5034 |
|
sl@0
|
5035 |
|
sl@0
|
5036 |
EXPORT_C TExitType RThread::ExitType() const
|
sl@0
|
5037 |
/**
|
sl@0
|
5038 |
Tests whether the thread has ended and, if it has ended, return how it ended.
|
sl@0
|
5039 |
|
sl@0
|
5040 |
This information allows the caller to distinguish between normal termination
|
sl@0
|
5041 |
and a panic.
|
sl@0
|
5042 |
|
sl@0
|
5043 |
@return An enumeration whose enumerators describe how the thread has ended.
|
sl@0
|
5044 |
*/
|
sl@0
|
5045 |
{
|
sl@0
|
5046 |
|
sl@0
|
5047 |
return(Exec::ThreadExitType(iHandle));
|
sl@0
|
5048 |
}
|
sl@0
|
5049 |
|
sl@0
|
5050 |
|
sl@0
|
5051 |
|
sl@0
|
5052 |
|
sl@0
|
5053 |
EXPORT_C TInt RThread::ExitReason() const
|
sl@0
|
5054 |
/**
|
sl@0
|
5055 |
Gets the specific reason associated with the end of this thread.
|
sl@0
|
5056 |
|
sl@0
|
5057 |
The reason number together with the category name is a way of distinguishing
|
sl@0
|
5058 |
between different causes of thread termination.
|
sl@0
|
5059 |
|
sl@0
|
5060 |
If the thread has panicked, this value is the panic number. If the thread
|
sl@0
|
5061 |
has ended as a result of a call to Kill(), then the value is the one supplied
|
sl@0
|
5062 |
by Kill().
|
sl@0
|
5063 |
|
sl@0
|
5064 |
If the thread is still alive, then the returned value is zero.
|
sl@0
|
5065 |
|
sl@0
|
5066 |
@return The reason associated with the end of the thread.
|
sl@0
|
5067 |
*/
|
sl@0
|
5068 |
{
|
sl@0
|
5069 |
|
sl@0
|
5070 |
return(Exec::ThreadExitReason(iHandle));
|
sl@0
|
5071 |
}
|
sl@0
|
5072 |
|
sl@0
|
5073 |
|
sl@0
|
5074 |
|
sl@0
|
5075 |
|
sl@0
|
5076 |
EXPORT_C TExitCategoryName RThread::ExitCategory() const
|
sl@0
|
5077 |
/**
|
sl@0
|
5078 |
Gets the name of the category associated with the end of the thread.
|
sl@0
|
5079 |
|
sl@0
|
5080 |
The category name together with the reason number is a way of distinguishing
|
sl@0
|
5081 |
between different causes of thread termination.
|
sl@0
|
5082 |
|
sl@0
|
5083 |
If the thread has panicked, the category name is the panic category name;
|
sl@0
|
5084 |
for example, E32USER-CBase or KERN-EXEC. If the thread has ended as a result
|
sl@0
|
5085 |
of call to Kill(), then the category name is Kill.
|
sl@0
|
5086 |
|
sl@0
|
5087 |
If the thread has not ended, then the category name is empty, i.e. the length
|
sl@0
|
5088 |
of the category name is zero.
|
sl@0
|
5089 |
|
sl@0
|
5090 |
@return A TBuf descriptor with a defined maximum length containing the name
|
sl@0
|
5091 |
of the category associated with the end of the thread.
|
sl@0
|
5092 |
|
sl@0
|
5093 |
@see TBuf
|
sl@0
|
5094 |
*/
|
sl@0
|
5095 |
{
|
sl@0
|
5096 |
TExitCategoryName n;
|
sl@0
|
5097 |
TPtr8 n8(((TUint8*)n.Ptr()) + KMaxExitCategoryName, KMaxExitCategoryName);
|
sl@0
|
5098 |
Exec::ThreadExitCategory(iHandle,n8);
|
sl@0
|
5099 |
n.Copy(n8);
|
sl@0
|
5100 |
return(n);
|
sl@0
|
5101 |
}
|
sl@0
|
5102 |
|
sl@0
|
5103 |
|
sl@0
|
5104 |
|
sl@0
|
5105 |
|
sl@0
|
5106 |
EXPORT_C TInt RThread::StackInfo(TThreadStackInfo& aInfo) const
|
sl@0
|
5107 |
/**
|
sl@0
|
5108 |
Gets information about a thread's user mode stack.
|
sl@0
|
5109 |
|
sl@0
|
5110 |
@param aInfo The TThreadStackInfo object to write the stack infomation to.
|
sl@0
|
5111 |
|
sl@0
|
5112 |
@return KErrNone, if sucessful;
|
sl@0
|
5113 |
KErrGeneral, if the thread doesn't have a user mode stack,
|
sl@0
|
5114 |
or it has terminated.
|
sl@0
|
5115 |
|
sl@0
|
5116 |
@see TThreadStackInfo
|
sl@0
|
5117 |
*/
|
sl@0
|
5118 |
{
|
sl@0
|
5119 |
return(Exec::ThreadStackInfo(iHandle,aInfo));
|
sl@0
|
5120 |
}
|
sl@0
|
5121 |
|
sl@0
|
5122 |
|
sl@0
|
5123 |
|
sl@0
|
5124 |
|
sl@0
|
5125 |
EXPORT_C TInt RThread::GetCpuTime(TTimeIntervalMicroSeconds& aCpuTime) const
|
sl@0
|
5126 |
/**
|
sl@0
|
5127 |
Gets the CPU usage for this thread.
|
sl@0
|
5128 |
|
sl@0
|
5129 |
This function is not supported on version 8.0b or 8.1b, and returns
|
sl@0
|
5130 |
KErrNotSupported. From 9.1 onwards it may be supported if the kernel has been
|
sl@0
|
5131 |
compiled with the MONITOR_THREAD_CPU_TIME macro defined.
|
sl@0
|
5132 |
|
sl@0
|
5133 |
@param aCpuTime A reference to a time interval object supplied by the caller.
|
sl@0
|
5134 |
|
sl@0
|
5135 |
@return KErrNone - if thread CPU time is available.
|
sl@0
|
5136 |
|
sl@0
|
5137 |
KErrNotSupported - if this feature is not supported on this
|
sl@0
|
5138 |
version or build of the OS.
|
sl@0
|
5139 |
*/
|
sl@0
|
5140 |
{
|
sl@0
|
5141 |
return Exec::ThreadGetCpuTime(iHandle, (TInt64&)aCpuTime.Int64());
|
sl@0
|
5142 |
}
|
sl@0
|
5143 |
|
sl@0
|
5144 |
|
sl@0
|
5145 |
|
sl@0
|
5146 |
|
sl@0
|
5147 |
EXPORT_C void User::After(TTimeIntervalMicroSeconds32 aInterval)
|
sl@0
|
5148 |
/**
|
sl@0
|
5149 |
Suspends the current thread until a specified time interval has expired.
|
sl@0
|
5150 |
|
sl@0
|
5151 |
The resolution of the timer depends on the hardware, but is normally
|
sl@0
|
5152 |
1 Symbian OS tick (approximately 1/64 second).
|
sl@0
|
5153 |
|
sl@0
|
5154 |
@param aInterval The time interval for which the current thread is to be
|
sl@0
|
5155 |
suspended, in microseconds.
|
sl@0
|
5156 |
|
sl@0
|
5157 |
@panic USER 86, if the time interval is negative.
|
sl@0
|
5158 |
*/
|
sl@0
|
5159 |
{
|
sl@0
|
5160 |
|
sl@0
|
5161 |
__ASSERT_ALWAYS(aInterval.Int()>=0,::Panic(EExecAfterTimeNegative));
|
sl@0
|
5162 |
TRequestStatus s=KRequestPending;
|
sl@0
|
5163 |
Exec::After(aInterval.Int(),s);
|
sl@0
|
5164 |
User::WaitForRequest(s);
|
sl@0
|
5165 |
}
|
sl@0
|
5166 |
|
sl@0
|
5167 |
|
sl@0
|
5168 |
|
sl@0
|
5169 |
|
sl@0
|
5170 |
EXPORT_C void User::AfterHighRes(TTimeIntervalMicroSeconds32 aInterval)
|
sl@0
|
5171 |
/**
|
sl@0
|
5172 |
Suspends the current thread until a specified time interval has expired to
|
sl@0
|
5173 |
a resolution of 1ms .
|
sl@0
|
5174 |
|
sl@0
|
5175 |
@param aInterval The time interval for which the current thread is to be
|
sl@0
|
5176 |
suspended, in microseconds.
|
sl@0
|
5177 |
|
sl@0
|
5178 |
@panic USER 86, if the time interval is negative.
|
sl@0
|
5179 |
*/
|
sl@0
|
5180 |
{
|
sl@0
|
5181 |
|
sl@0
|
5182 |
__ASSERT_ALWAYS(aInterval.Int()>=0,::Panic(EExecAfterTimeNegative));
|
sl@0
|
5183 |
TRequestStatus s=KRequestPending;
|
sl@0
|
5184 |
Exec::AfterHighRes(aInterval.Int(),s);
|
sl@0
|
5185 |
User::WaitForRequest(s);
|
sl@0
|
5186 |
}
|
sl@0
|
5187 |
|
sl@0
|
5188 |
|
sl@0
|
5189 |
|
sl@0
|
5190 |
|
sl@0
|
5191 |
EXPORT_C TInt User::At(const TTime &aTime)
|
sl@0
|
5192 |
/**
|
sl@0
|
5193 |
Suspends the current thread until the specified absolute time, in the current time zone.
|
sl@0
|
5194 |
|
sl@0
|
5195 |
If the machine is off at that time, the machine will be turned on again.
|
sl@0
|
5196 |
|
sl@0
|
5197 |
@param aTime The absolute time, in the current time zone, until which the current thread is to
|
sl@0
|
5198 |
be suspended.
|
sl@0
|
5199 |
|
sl@0
|
5200 |
@return On completion, contains the status of the request to suspend the
|
sl@0
|
5201 |
current thread:
|
sl@0
|
5202 |
|
sl@0
|
5203 |
KErrNone - suspension of the current thread completed normally at
|
sl@0
|
5204 |
the requested time.
|
sl@0
|
5205 |
|
sl@0
|
5206 |
KErrAbort - suspension of the current thread was aborted
|
sl@0
|
5207 |
because the system time changed.
|
sl@0
|
5208 |
|
sl@0
|
5209 |
KErrUnderflow - the requested completion time is in the past.
|
sl@0
|
5210 |
|
sl@0
|
5211 |
KErrOverFlow - the requested completion time is too far in the future.
|
sl@0
|
5212 |
*/
|
sl@0
|
5213 |
{
|
sl@0
|
5214 |
|
sl@0
|
5215 |
TRequestStatus s=KRequestPending;
|
sl@0
|
5216 |
TInt64 time=aTime.Int64();
|
sl@0
|
5217 |
time -= ((TInt64)User::UTCOffset().Int()) * 1000000;
|
sl@0
|
5218 |
Exec::At(time,s);
|
sl@0
|
5219 |
User::WaitForRequest(s);
|
sl@0
|
5220 |
return(s.Int());
|
sl@0
|
5221 |
}
|
sl@0
|
5222 |
|
sl@0
|
5223 |
|
sl@0
|
5224 |
|
sl@0
|
5225 |
|
sl@0
|
5226 |
EXPORT_C void RTimer::Cancel()
|
sl@0
|
5227 |
/**
|
sl@0
|
5228 |
Cancels any outstanding request for a timer event.
|
sl@0
|
5229 |
|
sl@0
|
5230 |
Any outstanding timer event completes with KErrCancel.
|
sl@0
|
5231 |
*/
|
sl@0
|
5232 |
{
|
sl@0
|
5233 |
|
sl@0
|
5234 |
Exec::TimerCancel(iHandle);
|
sl@0
|
5235 |
}
|
sl@0
|
5236 |
|
sl@0
|
5237 |
|
sl@0
|
5238 |
|
sl@0
|
5239 |
|
sl@0
|
5240 |
EXPORT_C void RTimer::After(TRequestStatus &aStatus,TTimeIntervalMicroSeconds32 aInterval)
|
sl@0
|
5241 |
//
|
sl@0
|
5242 |
// Request a relative timer.
|
sl@0
|
5243 |
//
|
sl@0
|
5244 |
/**
|
sl@0
|
5245 |
Requests an event after the specified interval.
|
sl@0
|
5246 |
|
sl@0
|
5247 |
The counter for this type of request stops during power-down.
|
sl@0
|
5248 |
A 5 second timer will complete late if, for example, the machine is turned off
|
sl@0
|
5249 |
2 seconds after the request is made.
|
sl@0
|
5250 |
|
sl@0
|
5251 |
@param aStatus On completion, contains the status of the request.
|
sl@0
|
5252 |
This is KErrNone if the timer completed normally at the
|
sl@0
|
5253 |
requested time, otherwise another of the
|
sl@0
|
5254 |
system-wide error codes.
|
sl@0
|
5255 |
|
sl@0
|
5256 |
@param aInterval The time interval, in microseconds, after which an event
|
sl@0
|
5257 |
is to occur.
|
sl@0
|
5258 |
|
sl@0
|
5259 |
@panic USER 87, if aInterval is negative.
|
sl@0
|
5260 |
@panic KERN-EXEC 15, if this function is called while a request for a timer
|
sl@0
|
5261 |
event is still outstanding.
|
sl@0
|
5262 |
*/
|
sl@0
|
5263 |
{
|
sl@0
|
5264 |
|
sl@0
|
5265 |
__ASSERT_ALWAYS(aInterval.Int()>=0,::Panic(ERTimerAfterTimeNegative));
|
sl@0
|
5266 |
aStatus=KRequestPending;
|
sl@0
|
5267 |
Exec::TimerAfter(iHandle,aStatus,aInterval.Int());
|
sl@0
|
5268 |
}
|
sl@0
|
5269 |
|
sl@0
|
5270 |
|
sl@0
|
5271 |
|
sl@0
|
5272 |
|
sl@0
|
5273 |
EXPORT_C void RTimer::AfterTicks(TRequestStatus& aStatus, TInt aTicks)
|
sl@0
|
5274 |
//
|
sl@0
|
5275 |
// Request a relative timer in system ticks.
|
sl@0
|
5276 |
//
|
sl@0
|
5277 |
/**
|
sl@0
|
5278 |
Requests an event after the specified interval.
|
sl@0
|
5279 |
|
sl@0
|
5280 |
The counter for this type of request stops during power-down.
|
sl@0
|
5281 |
A 5 tick timer will complete late if, for example, the machine is turned off
|
sl@0
|
5282 |
2 ticks after the request is made.
|
sl@0
|
5283 |
|
sl@0
|
5284 |
@param aStatus On completion, contains the status of the request.
|
sl@0
|
5285 |
This is KErrNone if the timer completed normally at the
|
sl@0
|
5286 |
requested time, otherwise another of the
|
sl@0
|
5287 |
system-wide error codes.
|
sl@0
|
5288 |
|
sl@0
|
5289 |
@param aTicks The time interval, in system ticks, after which an event
|
sl@0
|
5290 |
is to occur.
|
sl@0
|
5291 |
|
sl@0
|
5292 |
@panic USER 87, if aTicks is negative.
|
sl@0
|
5293 |
@panic KERN-EXEC 15, if this function is called while a request for a timer
|
sl@0
|
5294 |
event is still outstanding.
|
sl@0
|
5295 |
*/
|
sl@0
|
5296 |
{
|
sl@0
|
5297 |
__ASSERT_ALWAYS(aTicks >= 0, ::Panic(ERTimerAfterTimeNegative));
|
sl@0
|
5298 |
aStatus = KRequestPending;
|
sl@0
|
5299 |
Exec::TimerAfter(iHandle, aStatus, -aTicks);
|
sl@0
|
5300 |
}
|
sl@0
|
5301 |
|
sl@0
|
5302 |
|
sl@0
|
5303 |
|
sl@0
|
5304 |
|
sl@0
|
5305 |
EXPORT_C void RTimer::HighRes(TRequestStatus &aStatus,TTimeIntervalMicroSeconds32 aInterval)
|
sl@0
|
5306 |
//
|
sl@0
|
5307 |
// Request a relative timer to a resolution of 1ms.
|
sl@0
|
5308 |
//
|
sl@0
|
5309 |
/**
|
sl@0
|
5310 |
Requests an event after the specified interval to a resolution of 1ms.
|
sl@0
|
5311 |
The "HighRes timer" counter stops during power-down (the same as "after timer").
|
sl@0
|
5312 |
|
sl@0
|
5313 |
@param aStatus On completion, contains the status of the request.
|
sl@0
|
5314 |
This is KErrNone if the timer completed normally at the
|
sl@0
|
5315 |
requested time, otherwise another of the
|
sl@0
|
5316 |
system-wide error codes.
|
sl@0
|
5317 |
|
sl@0
|
5318 |
@param aInterval The time interval, in microseconds, after which an event
|
sl@0
|
5319 |
is to occur.
|
sl@0
|
5320 |
|
sl@0
|
5321 |
@panic USER 87, if aInterval is negative.
|
sl@0
|
5322 |
@panic KERN-EXEC 15, if this function is called while a request for a timer
|
sl@0
|
5323 |
event is still outstanding.
|
sl@0
|
5324 |
*/
|
sl@0
|
5325 |
{
|
sl@0
|
5326 |
|
sl@0
|
5327 |
__ASSERT_ALWAYS(aInterval.Int()>=0,::Panic(ERTimerAfterTimeNegative));
|
sl@0
|
5328 |
aStatus=KRequestPending;
|
sl@0
|
5329 |
Exec::TimerHighRes(iHandle,aStatus,aInterval.Int());
|
sl@0
|
5330 |
}
|
sl@0
|
5331 |
|
sl@0
|
5332 |
|
sl@0
|
5333 |
|
sl@0
|
5334 |
|
sl@0
|
5335 |
EXPORT_C void RTimer::At(TRequestStatus &aStatus,const TTime &aTime)
|
sl@0
|
5336 |
//
|
sl@0
|
5337 |
// Request an absolute timer.
|
sl@0
|
5338 |
//
|
sl@0
|
5339 |
/**
|
sl@0
|
5340 |
Requests an event at a given system time (in the current time zone).
|
sl@0
|
5341 |
|
sl@0
|
5342 |
If the machine is off at that time, it is automatically turned on.
|
sl@0
|
5343 |
|
sl@0
|
5344 |
@param aStatus On completion, contains the status of the request:
|
sl@0
|
5345 |
KErrNone, the timer completed normally at the requested time;
|
sl@0
|
5346 |
KErrCancel, the timer was cancelled;
|
sl@0
|
5347 |
KErrAbort, the timer was aborted because the system time changed;
|
sl@0
|
5348 |
KErrUnderflow, the requested completion time is in the past;
|
sl@0
|
5349 |
KErrOverFlow, the requested completion time is too far in the future;
|
sl@0
|
5350 |
@param aTime The time at which the timer will expire.
|
sl@0
|
5351 |
|
sl@0
|
5352 |
@panic KERN-EXEC 15, if this function is called while a request for a timer
|
sl@0
|
5353 |
event is still outstanding.
|
sl@0
|
5354 |
*/
|
sl@0
|
5355 |
{
|
sl@0
|
5356 |
|
sl@0
|
5357 |
aStatus=KRequestPending;
|
sl@0
|
5358 |
TInt64 time=aTime.Int64();
|
sl@0
|
5359 |
time -= ((TInt64)User::UTCOffset().Int()) * 1000000;
|
sl@0
|
5360 |
Exec::TimerAt(iHandle,aStatus,I64LOW(time),I64HIGH(time));
|
sl@0
|
5361 |
}
|
sl@0
|
5362 |
|
sl@0
|
5363 |
|
sl@0
|
5364 |
|
sl@0
|
5365 |
|
sl@0
|
5366 |
EXPORT_C void RTimer::AtUTC(TRequestStatus &aStatus,const TTime &aUTCTime)
|
sl@0
|
5367 |
//
|
sl@0
|
5368 |
// Request an absolute timer in UTC time.
|
sl@0
|
5369 |
//
|
sl@0
|
5370 |
/**
|
sl@0
|
5371 |
Requests an event at a given UTC time.
|
sl@0
|
5372 |
|
sl@0
|
5373 |
If the machine is off at that time, it is automatically turned on.
|
sl@0
|
5374 |
|
sl@0
|
5375 |
@param aStatus On completion, contains the status of the request:
|
sl@0
|
5376 |
KErrNone, the timer completed normally at the requested time;
|
sl@0
|
5377 |
KErrCancel, the timer was cancelled;
|
sl@0
|
5378 |
KErrAbort, the timer was aborted because the system time changed;
|
sl@0
|
5379 |
KErrUnderflow, the requested completion time is in the past;
|
sl@0
|
5380 |
KErrOverFlow, the requested completion time is too far in the future;
|
sl@0
|
5381 |
@param aTime The time at which the timer will expire.
|
sl@0
|
5382 |
|
sl@0
|
5383 |
@panic KERN-EXEC 15, if this function is called while a request for a timer
|
sl@0
|
5384 |
event is still outstanding.
|
sl@0
|
5385 |
*/
|
sl@0
|
5386 |
{
|
sl@0
|
5387 |
|
sl@0
|
5388 |
aStatus=KRequestPending;
|
sl@0
|
5389 |
Exec::TimerAt(iHandle,aStatus,I64LOW(aUTCTime.Int64()),I64HIGH(aUTCTime.Int64()));
|
sl@0
|
5390 |
}
|
sl@0
|
5391 |
|
sl@0
|
5392 |
|
sl@0
|
5393 |
|
sl@0
|
5394 |
|
sl@0
|
5395 |
EXPORT_C void RTimer::Lock(TRequestStatus &aStatus,TTimerLockSpec aLock)
|
sl@0
|
5396 |
//
|
sl@0
|
5397 |
// Request an absolute timer.
|
sl@0
|
5398 |
//
|
sl@0
|
5399 |
/**
|
sl@0
|
5400 |
Requests an event on a specified second fraction.
|
sl@0
|
5401 |
|
sl@0
|
5402 |
@param aStatus On completion, contains the status of the request:
|
sl@0
|
5403 |
KErrGeneral, the first time this is called;
|
sl@0
|
5404 |
KErrNone, the timer completed normally at the requested time;
|
sl@0
|
5405 |
KErrCancel, the timer was cancelled;
|
sl@0
|
5406 |
KErrAbort, the timer was aborted because the system time changed;
|
sl@0
|
5407 |
KErrUnderflow, the requested completion time is in the past;
|
sl@0
|
5408 |
KErrOverFlow, the requested completion time is too far in the future.
|
sl@0
|
5409 |
@param aLock The fraction of a second at which the timer completes.
|
sl@0
|
5410 |
|
sl@0
|
5411 |
@panic KERN-EXEC 15, if this function is called while a request for a timer
|
sl@0
|
5412 |
event is still outstanding.
|
sl@0
|
5413 |
*/
|
sl@0
|
5414 |
{
|
sl@0
|
5415 |
aStatus=KRequestPending;
|
sl@0
|
5416 |
Exec::TimerLock(iHandle,aStatus,aLock);
|
sl@0
|
5417 |
}
|
sl@0
|
5418 |
|
sl@0
|
5419 |
|
sl@0
|
5420 |
/**
|
sl@0
|
5421 |
Requests an event to be triggered when aSeconds is exactly, (ie not greater or
|
sl@0
|
5422 |
less than), the time elapsed (to the nearest second) since the last user activity.
|
sl@0
|
5423 |
If the event trigger time has been "missed", instead of triggering late,
|
sl@0
|
5424 |
the timer waits for the next user activity, to try and satisfy the condition.
|
sl@0
|
5425 |
|
sl@0
|
5426 |
That is to say, if there was user activity within the last aSeconds,
|
sl@0
|
5427 |
the event will be triggered after aSeconds of continuous inactivity following that activity.
|
sl@0
|
5428 |
Otherwise, if there has been no such activity within this time, an event is
|
sl@0
|
5429 |
triggered after aSeconds of continuous inactivity following the next user activity
|
sl@0
|
5430 |
in the future.
|
sl@0
|
5431 |
|
sl@0
|
5432 |
It follows from this, that you can request an event directly after the next
|
sl@0
|
5433 |
user activity by supplying a time interval of zero.
|
sl@0
|
5434 |
|
sl@0
|
5435 |
|
sl@0
|
5436 |
@param aStatus On completion, contains the status of the request:
|
sl@0
|
5437 |
KErrNone, the timer completed normally;
|
sl@0
|
5438 |
KErrCancel, the timer was cancelled;
|
sl@0
|
5439 |
KErrArgument, if aSeconds is less then zero;
|
sl@0
|
5440 |
KErrOverflow, if aSecond reaches its limit (which is platform specific but greater then one and a half day).
|
sl@0
|
5441 |
@param aSeconds The time interval in seconds.
|
sl@0
|
5442 |
|
sl@0
|
5443 |
@panic KERN-EXEC 15, if this function is called while a request for a timer
|
sl@0
|
5444 |
event is still outstanding.
|
sl@0
|
5445 |
*/
|
sl@0
|
5446 |
EXPORT_C void RTimer::Inactivity(TRequestStatus &aStatus, TTimeIntervalSeconds aSeconds)
|
sl@0
|
5447 |
{
|
sl@0
|
5448 |
aStatus=KRequestPending;
|
sl@0
|
5449 |
Exec::TimerInactivity(iHandle, aStatus, aSeconds.Int());
|
sl@0
|
5450 |
}
|
sl@0
|
5451 |
|
sl@0
|
5452 |
|
sl@0
|
5453 |
|
sl@0
|
5454 |
|
sl@0
|
5455 |
EXPORT_C TInt RChangeNotifier::Logon(TRequestStatus& aStatus) const
|
sl@0
|
5456 |
/**
|
sl@0
|
5457 |
Issues a request for notification when changes occur in the environment.
|
sl@0
|
5458 |
|
sl@0
|
5459 |
A switch in locale, or crossing over past midnight, are examples of changes
|
sl@0
|
5460 |
that are reported.
|
sl@0
|
5461 |
|
sl@0
|
5462 |
When a change in the environment occurs, the request completes and the
|
sl@0
|
5463 |
TRquestStatus object will contain one or more of the bit values defined
|
sl@0
|
5464 |
by the TChanges enum.
|
sl@0
|
5465 |
|
sl@0
|
5466 |
Alternatively, if an outstanding request is cancelled by a call to
|
sl@0
|
5467 |
this handle's LogonCancel() member function, then the request completes
|
sl@0
|
5468 |
with a KErrCancel.
|
sl@0
|
5469 |
|
sl@0
|
5470 |
Note that if this is the first notification request after creation of
|
sl@0
|
5471 |
the change notifier, then this request completes immediately.
|
sl@0
|
5472 |
|
sl@0
|
5473 |
@param aStatus A reference to the request status object.
|
sl@0
|
5474 |
|
sl@0
|
5475 |
@return KErrInUse, if there is an outstanding request; KErrNone otherwise.
|
sl@0
|
5476 |
|
sl@0
|
5477 |
@see TChanges
|
sl@0
|
5478 |
@see RChangeNotifier::Logon()
|
sl@0
|
5479 |
*/
|
sl@0
|
5480 |
{
|
sl@0
|
5481 |
|
sl@0
|
5482 |
aStatus=KRequestPending;
|
sl@0
|
5483 |
return(Exec::ChangeNotifierLogon(iHandle,aStatus));
|
sl@0
|
5484 |
}
|
sl@0
|
5485 |
|
sl@0
|
5486 |
|
sl@0
|
5487 |
|
sl@0
|
5488 |
|
sl@0
|
5489 |
EXPORT_C TInt RChangeNotifier::LogonCancel() const
|
sl@0
|
5490 |
/**
|
sl@0
|
5491 |
Cancels an outstanding change notification request.
|
sl@0
|
5492 |
|
sl@0
|
5493 |
@return KErrGeneral, if there is no outstanding request; KErrNone otherwise.
|
sl@0
|
5494 |
|
sl@0
|
5495 |
@see RChangeNotifier::Logon()
|
sl@0
|
5496 |
*/
|
sl@0
|
5497 |
{
|
sl@0
|
5498 |
|
sl@0
|
5499 |
return(Exec::ChangeNotifierLogoff(iHandle));
|
sl@0
|
5500 |
}
|
sl@0
|
5501 |
|
sl@0
|
5502 |
|
sl@0
|
5503 |
|
sl@0
|
5504 |
|
sl@0
|
5505 |
EXPORT_C void UserSvr::CaptureEventHook()
|
sl@0
|
5506 |
//
|
sl@0
|
5507 |
// Capture the event hook
|
sl@0
|
5508 |
//
|
sl@0
|
5509 |
{
|
sl@0
|
5510 |
|
sl@0
|
5511 |
Exec::CaptureEventHook();
|
sl@0
|
5512 |
}
|
sl@0
|
5513 |
|
sl@0
|
5514 |
EXPORT_C void UserSvr::ReleaseEventHook()
|
sl@0
|
5515 |
//
|
sl@0
|
5516 |
// Release the event hook
|
sl@0
|
5517 |
//
|
sl@0
|
5518 |
{
|
sl@0
|
5519 |
|
sl@0
|
5520 |
Exec::ReleaseEventHook();
|
sl@0
|
5521 |
}
|
sl@0
|
5522 |
|
sl@0
|
5523 |
EXPORT_C void UserSvr::RequestEvent(TRawEventBuf &anEvent,TRequestStatus &aStatus)
|
sl@0
|
5524 |
//
|
sl@0
|
5525 |
// Request the next event.
|
sl@0
|
5526 |
//
|
sl@0
|
5527 |
{
|
sl@0
|
5528 |
|
sl@0
|
5529 |
aStatus=KRequestPending;
|
sl@0
|
5530 |
Exec::RequestEvent(anEvent,aStatus);
|
sl@0
|
5531 |
}
|
sl@0
|
5532 |
|
sl@0
|
5533 |
EXPORT_C void UserSvr::RequestEventCancel()
|
sl@0
|
5534 |
//
|
sl@0
|
5535 |
// Cancel the event request.
|
sl@0
|
5536 |
//
|
sl@0
|
5537 |
{
|
sl@0
|
5538 |
|
sl@0
|
5539 |
Exec::RequestEventCancel();
|
sl@0
|
5540 |
}
|
sl@0
|
5541 |
|
sl@0
|
5542 |
/**
|
sl@0
|
5543 |
Add an event to the queue.
|
sl@0
|
5544 |
|
sl@0
|
5545 |
@param anEvent The raw hardware event to be added to the event queue.
|
sl@0
|
5546 |
@return KErrNone, if successful; KErrPermissionDenied, if the caller has
|
sl@0
|
5547 |
insufficient capability; otherwise, one of the other system-wide error codes.
|
sl@0
|
5548 |
|
sl@0
|
5549 |
@capability SwEvent
|
sl@0
|
5550 |
@capability PowerMgmt for ESwitchOff, ERestartSystem, ECaseOpen and ECaseClose
|
sl@0
|
5551 |
*/
|
sl@0
|
5552 |
EXPORT_C TInt UserSvr::AddEvent(const TRawEvent& anEvent)
|
sl@0
|
5553 |
{
|
sl@0
|
5554 |
|
sl@0
|
5555 |
return(Exec::AddEvent(anEvent));
|
sl@0
|
5556 |
}
|
sl@0
|
5557 |
|
sl@0
|
5558 |
EXPORT_C void UserSvr::ScreenInfo(TDes8 &anInfo)
|
sl@0
|
5559 |
//
|
sl@0
|
5560 |
// Get the screen info.
|
sl@0
|
5561 |
//
|
sl@0
|
5562 |
{
|
sl@0
|
5563 |
|
sl@0
|
5564 |
Exec::HalFunction(EHalGroupDisplay,EDisplayHalScreenInfo,(TAny*)&anInfo,NULL);
|
sl@0
|
5565 |
}
|
sl@0
|
5566 |
|
sl@0
|
5567 |
#ifdef __USERSIDE_THREAD_DATA__
|
sl@0
|
5568 |
|
sl@0
|
5569 |
EXPORT_C TAny* UserSvr::DllTls(TInt aHandle)
|
sl@0
|
5570 |
//
|
sl@0
|
5571 |
// Return the value of the Thread Local Storage variable.
|
sl@0
|
5572 |
//
|
sl@0
|
5573 |
{
|
sl@0
|
5574 |
return LocalThreadData()->DllTls(aHandle, KDllUid_Default);
|
sl@0
|
5575 |
}
|
sl@0
|
5576 |
|
sl@0
|
5577 |
EXPORT_C TAny* UserSvr::DllTls(TInt aHandle, TInt aDllUid)
|
sl@0
|
5578 |
//
|
sl@0
|
5579 |
// Return the value of the Thread Local Storage variable.
|
sl@0
|
5580 |
//
|
sl@0
|
5581 |
{
|
sl@0
|
5582 |
return LocalThreadData()->DllTls(aHandle, aDllUid);
|
sl@0
|
5583 |
}
|
sl@0
|
5584 |
|
sl@0
|
5585 |
#else
|
sl@0
|
5586 |
|
sl@0
|
5587 |
EXPORT_C TAny* UserSvr::DllTls(TInt aHandle)
|
sl@0
|
5588 |
//
|
sl@0
|
5589 |
// Return the value of the Thread Local Storage variable.
|
sl@0
|
5590 |
//
|
sl@0
|
5591 |
{
|
sl@0
|
5592 |
|
sl@0
|
5593 |
return Exec::DllTls(aHandle, KDllUid_Default);
|
sl@0
|
5594 |
}
|
sl@0
|
5595 |
|
sl@0
|
5596 |
EXPORT_C TAny* UserSvr::DllTls(TInt aHandle, TInt aDllUid)
|
sl@0
|
5597 |
//
|
sl@0
|
5598 |
// Return the value of the Thread Local Storage variable.
|
sl@0
|
5599 |
//
|
sl@0
|
5600 |
{
|
sl@0
|
5601 |
|
sl@0
|
5602 |
return Exec::DllTls(aHandle, aDllUid);
|
sl@0
|
5603 |
}
|
sl@0
|
5604 |
|
sl@0
|
5605 |
#endif
|
sl@0
|
5606 |
|
sl@0
|
5607 |
EXPORT_C void UserSvr::DllFileName(TInt aHandle, TDes& aFileName)
|
sl@0
|
5608 |
//
|
sl@0
|
5609 |
// Return the filename of this dll
|
sl@0
|
5610 |
//
|
sl@0
|
5611 |
{
|
sl@0
|
5612 |
TBuf8<KMaxFileName> n8;
|
sl@0
|
5613 |
Exec::DllFileName(aHandle, n8);
|
sl@0
|
5614 |
aFileName.Copy(n8);
|
sl@0
|
5615 |
}
|
sl@0
|
5616 |
|
sl@0
|
5617 |
EXPORT_C TBool UserSvr::TestBootSequence()
|
sl@0
|
5618 |
//
|
sl@0
|
5619 |
// Is the machine being booted by the test department?
|
sl@0
|
5620 |
//
|
sl@0
|
5621 |
{
|
sl@0
|
5622 |
|
sl@0
|
5623 |
return Exec::HalFunction(EHalGroupPower,EPowerHalTestBootSequence,NULL,NULL);
|
sl@0
|
5624 |
}
|
sl@0
|
5625 |
|
sl@0
|
5626 |
/**
|
sl@0
|
5627 |
Register whether the W/S takes care of turning the screen on
|
sl@0
|
5628 |
*/
|
sl@0
|
5629 |
EXPORT_C void UserSvr::WsRegisterSwitchOnScreenHandling(TBool aState)
|
sl@0
|
5630 |
{
|
sl@0
|
5631 |
|
sl@0
|
5632 |
Exec::HalFunction(EHalGroupDisplay,EDisplayHalWsRegisterSwitchOnScreenHandling,(TAny*)aState,NULL);
|
sl@0
|
5633 |
}
|
sl@0
|
5634 |
|
sl@0
|
5635 |
EXPORT_C void UserSvr::WsSwitchOnScreen()
|
sl@0
|
5636 |
//
|
sl@0
|
5637 |
// W/S switch on the screen
|
sl@0
|
5638 |
//
|
sl@0
|
5639 |
{
|
sl@0
|
5640 |
|
sl@0
|
5641 |
Exec::HalFunction(EHalGroupDisplay,EDisplayHalWsSwitchOnScreen,NULL,NULL);
|
sl@0
|
5642 |
}
|
sl@0
|
5643 |
|
sl@0
|
5644 |
|
sl@0
|
5645 |
EXPORT_C TUint32 UserSvr::DebugMask()
|
sl@0
|
5646 |
/**
|
sl@0
|
5647 |
Return the kernel debug mask at index 0
|
sl@0
|
5648 |
*/
|
sl@0
|
5649 |
{
|
sl@0
|
5650 |
return Exec::DebugMask();
|
sl@0
|
5651 |
}
|
sl@0
|
5652 |
|
sl@0
|
5653 |
|
sl@0
|
5654 |
EXPORT_C TUint32 UserSvr::DebugMask(TUint aIndex)
|
sl@0
|
5655 |
/**
|
sl@0
|
5656 |
Return the kernel debug mask at the given index position
|
sl@0
|
5657 |
|
sl@0
|
5658 |
@param aIndex An index of which 32 bit mask word is to be accessed
|
sl@0
|
5659 |
*/
|
sl@0
|
5660 |
{
|
sl@0
|
5661 |
return Exec::DebugMaskIndex(aIndex);
|
sl@0
|
5662 |
}
|
sl@0
|
5663 |
|
sl@0
|
5664 |
|
sl@0
|
5665 |
|
sl@0
|
5666 |
EXPORT_C TTrapHandler *User::TrapHandler()
|
sl@0
|
5667 |
/**
|
sl@0
|
5668 |
Gets a pointer to the current thread's trap handler.
|
sl@0
|
5669 |
|
sl@0
|
5670 |
Note that TTrapHandler is an abstract base class; a trap handler must be
|
sl@0
|
5671 |
implemented as a derived class.
|
sl@0
|
5672 |
|
sl@0
|
5673 |
@return A pointer to the current thread's trap handler, if any. NULL, if no
|
sl@0
|
5674 |
pre-existing trap handler is set.
|
sl@0
|
5675 |
*/
|
sl@0
|
5676 |
{
|
sl@0
|
5677 |
|
sl@0
|
5678 |
return GetTrapHandler();
|
sl@0
|
5679 |
}
|
sl@0
|
5680 |
|
sl@0
|
5681 |
|
sl@0
|
5682 |
|
sl@0
|
5683 |
|
sl@0
|
5684 |
EXPORT_C TTrapHandler *User::SetTrapHandler(TTrapHandler *aHandler)
|
sl@0
|
5685 |
/**
|
sl@0
|
5686 |
Sets the current thread's trap handler and returns a pointer to any pre-existing
|
sl@0
|
5687 |
trap handler.
|
sl@0
|
5688 |
|
sl@0
|
5689 |
Pass a NULL pointer to this function to clear the trap handler.
|
sl@0
|
5690 |
|
sl@0
|
5691 |
The trap handler works with the TRAP mechanism to handle the effects of a
|
sl@0
|
5692 |
leave.
|
sl@0
|
5693 |
|
sl@0
|
5694 |
Note that TTrapHandler is an abstract base class; a trap handler must be
|
sl@0
|
5695 |
implemented as a derived class.
|
sl@0
|
5696 |
|
sl@0
|
5697 |
@param aHandler A pointer to the trap handler which is to be installed as
|
sl@0
|
5698 |
the current thread's trap handler.
|
sl@0
|
5699 |
|
sl@0
|
5700 |
@return A pointer to the current thread's pre-existing trap handler, if any.
|
sl@0
|
5701 |
NULL, if no pre-existing trap handler is set.
|
sl@0
|
5702 |
|
sl@0
|
5703 |
@see TRAP
|
sl@0
|
5704 |
@see TRAPD
|
sl@0
|
5705 |
*/
|
sl@0
|
5706 |
{
|
sl@0
|
5707 |
|
sl@0
|
5708 |
TTrapHandler* prev;
|
sl@0
|
5709 |
#if defined(__USERSIDE_THREAD_DATA__) && defined(__LEAVE_EQUALS_THROW__)
|
sl@0
|
5710 |
prev = LocalThreadData()->iTrapHandler;
|
sl@0
|
5711 |
#else
|
sl@0
|
5712 |
prev = Exec::SetTrapHandler(aHandler);
|
sl@0
|
5713 |
#endif
|
sl@0
|
5714 |
#ifdef __USERSIDE_THREAD_DATA__
|
sl@0
|
5715 |
LocalThreadData()->iTrapHandler = aHandler;
|
sl@0
|
5716 |
#endif
|
sl@0
|
5717 |
return prev;
|
sl@0
|
5718 |
}
|
sl@0
|
5719 |
|
sl@0
|
5720 |
#ifndef __LEAVE_EQUALS_THROW__
|
sl@0
|
5721 |
EXPORT_C TTrapHandler* User::MarkCleanupStack()
|
sl@0
|
5722 |
/**
|
sl@0
|
5723 |
If there's a TTrapHandler installed marks the cleanup stack and returns
|
sl@0
|
5724 |
the TTrapHandler for subsequent use in UnMarkCleanupStack.
|
sl@0
|
5725 |
|
sl@0
|
5726 |
Only intended for use in the defintion of TRAP and TRAPD and only when
|
sl@0
|
5727 |
User::Leave is defined in terms of THROW.
|
sl@0
|
5728 |
|
sl@0
|
5729 |
@return A pointer to the current thread's pre-existing trap handler, if any.
|
sl@0
|
5730 |
NULL, if no pre-existing trap handler is set.
|
sl@0
|
5731 |
|
sl@0
|
5732 |
@see TRAP
|
sl@0
|
5733 |
@see TRAPD
|
sl@0
|
5734 |
*/
|
sl@0
|
5735 |
{
|
sl@0
|
5736 |
return (TTrapHandler*)0;
|
sl@0
|
5737 |
}
|
sl@0
|
5738 |
|
sl@0
|
5739 |
|
sl@0
|
5740 |
EXPORT_C void User::UnMarkCleanupStack(TTrapHandler* /*aHandler*/)
|
sl@0
|
5741 |
/**
|
sl@0
|
5742 |
If passed a non-null TTrapHandler unmarks the cleanup stack.
|
sl@0
|
5743 |
|
sl@0
|
5744 |
Only intended for use in the defintion of TRAP and TRAPD and only when
|
sl@0
|
5745 |
User::Leave is defined in terms of THROW.
|
sl@0
|
5746 |
|
sl@0
|
5747 |
@see TRAP
|
sl@0
|
5748 |
@see TRAPD
|
sl@0
|
5749 |
*/
|
sl@0
|
5750 |
{}
|
sl@0
|
5751 |
|
sl@0
|
5752 |
#else
|
sl@0
|
5753 |
|
sl@0
|
5754 |
EXPORT_C TTrapHandler* User::MarkCleanupStack()
|
sl@0
|
5755 |
/**
|
sl@0
|
5756 |
If there's a TTrapHandler installed marks the cleanup stack and returns
|
sl@0
|
5757 |
the TTrapHandler for subsequent use in UnMarkCleanupStack.
|
sl@0
|
5758 |
|
sl@0
|
5759 |
Only intended for use in the defintion of TRAP and TRAPD and only when
|
sl@0
|
5760 |
User::Leave is defined in terms of THROW.
|
sl@0
|
5761 |
|
sl@0
|
5762 |
@return A pointer to the current thread's pre-existing trap handler, if any.
|
sl@0
|
5763 |
NULL, if no pre-existing trap handler is set.
|
sl@0
|
5764 |
|
sl@0
|
5765 |
@see TRAP
|
sl@0
|
5766 |
@see TRAPD
|
sl@0
|
5767 |
*/
|
sl@0
|
5768 |
{
|
sl@0
|
5769 |
|
sl@0
|
5770 |
TTrapHandler* pH = GetTrapHandler();
|
sl@0
|
5771 |
if (pH)
|
sl@0
|
5772 |
pH->Trap();
|
sl@0
|
5773 |
return pH;
|
sl@0
|
5774 |
}
|
sl@0
|
5775 |
|
sl@0
|
5776 |
EXPORT_C void User::UnMarkCleanupStack(TTrapHandler* aHandler)
|
sl@0
|
5777 |
/**
|
sl@0
|
5778 |
If passed a non-null TTrapHandler unmarks the cleanup stack.
|
sl@0
|
5779 |
|
sl@0
|
5780 |
Only intended for use in the defintion of TRAP and TRAPD and only when
|
sl@0
|
5781 |
User::Leave is defined in terms of THROW.
|
sl@0
|
5782 |
|
sl@0
|
5783 |
@see TRAP
|
sl@0
|
5784 |
@see TRAPD
|
sl@0
|
5785 |
*/
|
sl@0
|
5786 |
{
|
sl@0
|
5787 |
|
sl@0
|
5788 |
if (aHandler)
|
sl@0
|
5789 |
aHandler->UnTrap();
|
sl@0
|
5790 |
}
|
sl@0
|
5791 |
|
sl@0
|
5792 |
#endif
|
sl@0
|
5793 |
|
sl@0
|
5794 |
|
sl@0
|
5795 |
EXPORT_C TInt User::Beep(TInt aFrequency,TTimeIntervalMicroSeconds32 aDuration)
|
sl@0
|
5796 |
/**
|
sl@0
|
5797 |
Makes a beep tone with a specified frequency and duration.
|
sl@0
|
5798 |
|
sl@0
|
5799 |
This function should not be used. It exists to maintain compatibility with
|
sl@0
|
5800 |
older versions of Symban OS.
|
sl@0
|
5801 |
*/
|
sl@0
|
5802 |
{
|
sl@0
|
5803 |
|
sl@0
|
5804 |
return Exec::HalFunction(EHalGroupSound,ESoundHalBeep,(TAny*)aFrequency,(TAny*)aDuration.Int());
|
sl@0
|
5805 |
}
|
sl@0
|
5806 |
|
sl@0
|
5807 |
|
sl@0
|
5808 |
|
sl@0
|
5809 |
|
sl@0
|
5810 |
// Unused, exists only for BC reasons
|
sl@0
|
5811 |
EXPORT_C TInt UserSvr::HalGet(TInt, TAny*)
|
sl@0
|
5812 |
{
|
sl@0
|
5813 |
return KErrNotSupported;
|
sl@0
|
5814 |
}
|
sl@0
|
5815 |
|
sl@0
|
5816 |
// Unused, exists only for BC reasons
|
sl@0
|
5817 |
EXPORT_C TInt UserSvr::HalSet(TInt, TAny*)
|
sl@0
|
5818 |
{
|
sl@0
|
5819 |
return KErrNotSupported;
|
sl@0
|
5820 |
}
|
sl@0
|
5821 |
|
sl@0
|
5822 |
EXPORT_C TInt UserSvr::HalFunction(TInt aGroup, TInt aFunction, TAny* a1, TAny* a2)
|
sl@0
|
5823 |
{
|
sl@0
|
5824 |
|
sl@0
|
5825 |
return Exec::HalFunction(aGroup, aFunction, a1, a2);
|
sl@0
|
5826 |
}
|
sl@0
|
5827 |
|
sl@0
|
5828 |
EXPORT_C TInt UserSvr::HalFunction(TInt aGroup, TInt aFunction, TAny* a1, TAny* a2, TInt aDeviceNumber)
|
sl@0
|
5829 |
{
|
sl@0
|
5830 |
|
sl@0
|
5831 |
return Exec::HalFunction(aGroup | (aDeviceNumber<<16), aFunction, a1, a2);
|
sl@0
|
5832 |
}
|
sl@0
|
5833 |
|
sl@0
|
5834 |
/**
|
sl@0
|
5835 |
@capability WriteDeviceData
|
sl@0
|
5836 |
*/
|
sl@0
|
5837 |
EXPORT_C TInt UserSvr::SetMemoryThresholds(TInt aLowThreshold, TInt aGoodThreshold)
|
sl@0
|
5838 |
{
|
sl@0
|
5839 |
return Exec::SetMemoryThresholds(aLowThreshold,aGoodThreshold);
|
sl@0
|
5840 |
}
|
sl@0
|
5841 |
|
sl@0
|
5842 |
/**
|
sl@0
|
5843 |
@deprecated
|
sl@0
|
5844 |
@internalAll
|
sl@0
|
5845 |
@return EFalse
|
sl@0
|
5846 |
*/
|
sl@0
|
5847 |
EXPORT_C TBool UserSvr::IpcV1Available()
|
sl@0
|
5848 |
{
|
sl@0
|
5849 |
return EFalse;
|
sl@0
|
5850 |
}
|
sl@0
|
5851 |
|
sl@0
|
5852 |
|
sl@0
|
5853 |
|
sl@0
|
5854 |
EXPORT_C void User::SetDebugMask(TUint32 aVal)
|
sl@0
|
5855 |
/**
|
sl@0
|
5856 |
Sets the debug mask.
|
sl@0
|
5857 |
|
sl@0
|
5858 |
@param aVal A set of bit values as defined in nk_trace.h
|
sl@0
|
5859 |
*/
|
sl@0
|
5860 |
{
|
sl@0
|
5861 |
Exec::SetDebugMask(aVal);
|
sl@0
|
5862 |
}
|
sl@0
|
5863 |
|
sl@0
|
5864 |
EXPORT_C void User::SetDebugMask(TUint32 aVal, TUint aIndex)
|
sl@0
|
5865 |
/**
|
sl@0
|
5866 |
Sets the debug mask at the given index
|
sl@0
|
5867 |
|
sl@0
|
5868 |
@param aVal A set of bit values as defined in nk_trace.h
|
sl@0
|
5869 |
@param aIndex An index of which 32 bit mask word is to be accessed
|
sl@0
|
5870 |
*/
|
sl@0
|
5871 |
{
|
sl@0
|
5872 |
Exec::SetDebugMaskIndex(aVal, aIndex);
|
sl@0
|
5873 |
}
|
sl@0
|
5874 |
|
sl@0
|
5875 |
|
sl@0
|
5876 |
/**
|
sl@0
|
5877 |
Gets machine information.
|
sl@0
|
5878 |
|
sl@0
|
5879 |
@publishedPartner
|
sl@0
|
5880 |
@deprecated Use HAL::Get() from the HAL library instead.
|
sl@0
|
5881 |
*/
|
sl@0
|
5882 |
EXPORT_C TInt UserHal::MachineInfo(TDes8& anInfo)
|
sl@0
|
5883 |
{
|
sl@0
|
5884 |
TInt bufLength=anInfo.MaxLength();
|
sl@0
|
5885 |
__ASSERT_ALWAYS(bufLength==sizeof(TMachineInfoV2) || bufLength==sizeof(TMachineInfoV1),Panic(ETDes8BadDescriptorType));
|
sl@0
|
5886 |
|
sl@0
|
5887 |
// assemble a TMachineInfoV1 buffer
|
sl@0
|
5888 |
TMachineInfoV2* info=&((TMachineInfoV2Buf&)anInfo)();
|
sl@0
|
5889 |
// Variant stuff
|
sl@0
|
5890 |
TVariantInfoV01Buf infoBuf;
|
sl@0
|
5891 |
TInt r = Exec::HalFunction(EHalGroupVariant, EVariantHalVariantInfo, (TAny*)&infoBuf, NULL);
|
sl@0
|
5892 |
if (KErrNone != r) return r; // must always be implemented!
|
sl@0
|
5893 |
TVariantInfoV01& variantInfo = infoBuf();
|
sl@0
|
5894 |
|
sl@0
|
5895 |
info->iRomVersion=variantInfo.iRomVersion;
|
sl@0
|
5896 |
info->iMachineUniqueId=variantInfo.iMachineUniqueId;
|
sl@0
|
5897 |
info->iLedCapabilities=variantInfo.iLedCapabilities;
|
sl@0
|
5898 |
info->iProcessorClockInKHz=variantInfo.iProcessorClockInKHz;
|
sl@0
|
5899 |
info->iSpeedFactor=variantInfo.iSpeedFactor;
|
sl@0
|
5900 |
|
sl@0
|
5901 |
// Video driver stuff
|
sl@0
|
5902 |
TVideoInfoV01Buf vidinfoBuf;
|
sl@0
|
5903 |
r = Exec::HalFunction(EHalGroupDisplay, EDisplayHalCurrentModeInfo, (TAny*)&vidinfoBuf, NULL);
|
sl@0
|
5904 |
if (KErrNone == r)
|
sl@0
|
5905 |
{
|
sl@0
|
5906 |
TVideoInfoV01& vidinfo = vidinfoBuf();
|
sl@0
|
5907 |
info->iDisplaySizeInPixels=vidinfo.iSizeInPixels;
|
sl@0
|
5908 |
info->iPhysicalScreenSize=vidinfo.iSizeInTwips;
|
sl@0
|
5909 |
}
|
sl@0
|
5910 |
else // no display driver
|
sl@0
|
5911 |
{
|
sl@0
|
5912 |
info->iDisplaySizeInPixels.iWidth=0;
|
sl@0
|
5913 |
info->iDisplaySizeInPixels.iHeight=0;
|
sl@0
|
5914 |
info->iPhysicalScreenSize.iWidth=0;
|
sl@0
|
5915 |
info->iPhysicalScreenSize.iHeight=0;
|
sl@0
|
5916 |
}
|
sl@0
|
5917 |
TInt colors = 0;
|
sl@0
|
5918 |
r = Exec::HalFunction(EHalGroupDisplay, EDisplayHalColors, &colors, NULL);
|
sl@0
|
5919 |
info->iMaximumDisplayColors=(KErrNone == r)?colors:0;
|
sl@0
|
5920 |
TInt val;
|
sl@0
|
5921 |
info->iBacklightPresent= (KErrNone == Exec::HalFunction(EHalGroupDisplay, EDisplayHalBacklightOn, &val, NULL));
|
sl@0
|
5922 |
|
sl@0
|
5923 |
// Pointing device stuff
|
sl@0
|
5924 |
TDigitiserInfoV01Buf xyinfoBuf;
|
sl@0
|
5925 |
r = Exec::HalFunction(EHalGroupDigitiser, EDigitiserHalXYInfo, (TAny*)&xyinfoBuf, NULL);
|
sl@0
|
5926 |
if (KErrNone == r)
|
sl@0
|
5927 |
{
|
sl@0
|
5928 |
info->iXYInputType=EXYInputPointer; // XY is Digitiser
|
sl@0
|
5929 |
TDigitiserInfoV01& xyinfo = xyinfoBuf();
|
sl@0
|
5930 |
info->iXYInputSizeInPixels=xyinfo.iDigitiserSize;
|
sl@0
|
5931 |
info->iOffsetToDisplayInPixels=xyinfo.iOffsetToDisplay;
|
sl@0
|
5932 |
}
|
sl@0
|
5933 |
else
|
sl@0
|
5934 |
{
|
sl@0
|
5935 |
TMouseInfoV01Buf mouseinfoBuf;
|
sl@0
|
5936 |
r = Exec::HalFunction(EHalGroupMouse, EMouseHalMouseInfo, (TAny*)&mouseinfoBuf, NULL);
|
sl@0
|
5937 |
if (KErrNone == r)
|
sl@0
|
5938 |
{
|
sl@0
|
5939 |
info->iXYInputType=EXYInputMouse; // XY is Mouse
|
sl@0
|
5940 |
TMouseInfoV01& mouseinfo = mouseinfoBuf();
|
sl@0
|
5941 |
info->iXYInputSizeInPixels=mouseinfo.iMouseAreaSize;
|
sl@0
|
5942 |
info->iOffsetToDisplayInPixels=mouseinfo.iOffsetToDisplay;
|
sl@0
|
5943 |
}
|
sl@0
|
5944 |
else
|
sl@0
|
5945 |
{
|
sl@0
|
5946 |
info->iXYInputType=EXYInputNone; // no XY
|
sl@0
|
5947 |
info->iXYInputSizeInPixels.iWidth=0;
|
sl@0
|
5948 |
info->iXYInputSizeInPixels.iHeight=0;
|
sl@0
|
5949 |
info->iOffsetToDisplayInPixels.iX=0;
|
sl@0
|
5950 |
info->iOffsetToDisplayInPixels.iY=0;
|
sl@0
|
5951 |
}
|
sl@0
|
5952 |
}
|
sl@0
|
5953 |
|
sl@0
|
5954 |
// Keyboard stuff
|
sl@0
|
5955 |
TKeyboardInfoV01Buf kbdinfoBuf;
|
sl@0
|
5956 |
info->iKeyboardPresent= (KErrNone == Exec::HalFunction(EHalGroupKeyboard, EKeyboardHalKeyboardInfo, (TAny*)&kbdinfoBuf, NULL));
|
sl@0
|
5957 |
|
sl@0
|
5958 |
// Unused, obsolete parameters
|
sl@0
|
5959 |
info->iKeyboardId=0;
|
sl@0
|
5960 |
info->iDisplayId=0;
|
sl@0
|
5961 |
if(bufLength==sizeof(TMachineInfoV2))
|
sl@0
|
5962 |
{
|
sl@0
|
5963 |
// assemble a TMachineInfoV2 buffer
|
sl@0
|
5964 |
info->iLanguageIndex=0;
|
sl@0
|
5965 |
info->iKeyboardIndex=0;
|
sl@0
|
5966 |
}
|
sl@0
|
5967 |
|
sl@0
|
5968 |
anInfo.SetLength(bufLength);
|
sl@0
|
5969 |
|
sl@0
|
5970 |
return KErrNone;
|
sl@0
|
5971 |
}
|
sl@0
|
5972 |
|
sl@0
|
5973 |
/**
|
sl@0
|
5974 |
Gets memory information.
|
sl@0
|
5975 |
|
sl@0
|
5976 |
@see HAL::Get()
|
sl@0
|
5977 |
|
sl@0
|
5978 |
@publishedPartner
|
sl@0
|
5979 |
@deprecated Use HAL::Get() from the HAL library instead with attributes EMemoryRAM, EMemoryRAMFree or EMemoryROM.
|
sl@0
|
5980 |
*/
|
sl@0
|
5981 |
EXPORT_C TInt UserHal::MemoryInfo(TDes8& anInfo)
|
sl@0
|
5982 |
{
|
sl@0
|
5983 |
return Exec::HalFunction(EHalGroupKernel,EKernelHalMemoryInfo,(TAny*)&anInfo,NULL);
|
sl@0
|
5984 |
}
|
sl@0
|
5985 |
|
sl@0
|
5986 |
/**
|
sl@0
|
5987 |
Gets ROM configuration information.
|
sl@0
|
5988 |
|
sl@0
|
5989 |
@publishedPartner
|
sl@0
|
5990 |
@deprecated No replacement.
|
sl@0
|
5991 |
*/
|
sl@0
|
5992 |
EXPORT_C TInt UserHal::RomInfo(TDes8& anInfo)
|
sl@0
|
5993 |
{
|
sl@0
|
5994 |
return Exec::HalFunction(EHalGroupKernel,EKernelHalRomInfo,(TAny*)&anInfo,NULL);
|
sl@0
|
5995 |
}
|
sl@0
|
5996 |
|
sl@0
|
5997 |
|
sl@0
|
5998 |
|
sl@0
|
5999 |
|
sl@0
|
6000 |
/**
|
sl@0
|
6001 |
Gets drive information.
|
sl@0
|
6002 |
|
sl@0
|
6003 |
@param anInfo A package buffer (TPckgBuf) containing a TDriveInfoV1 structure.
|
sl@0
|
6004 |
On return, this structure will contain the drive information.
|
sl@0
|
6005 |
|
sl@0
|
6006 |
@return KErrNone
|
sl@0
|
6007 |
|
sl@0
|
6008 |
@see TDriveInfoV1Buf
|
sl@0
|
6009 |
@see TDriveInfoV1
|
sl@0
|
6010 |
@see TPckgBuf
|
sl@0
|
6011 |
*/
|
sl@0
|
6012 |
EXPORT_C TInt UserHal::DriveInfo(TDes8& anInfo)
|
sl@0
|
6013 |
{
|
sl@0
|
6014 |
TDriveInfoV1Buf8 anInfo8;
|
sl@0
|
6015 |
TInt r = Exec::HalFunction(EHalGroupMedia,EMediaHalDriveInfo,(TAny*)&anInfo8,NULL);
|
sl@0
|
6016 |
TDriveInfoV18& driveInfo8 = anInfo8();
|
sl@0
|
6017 |
TDriveInfoV1* driveInfo = NULL;
|
sl@0
|
6018 |
switch(((SBuf8*)&anInfo)->length>>KShiftDesType8) //type
|
sl@0
|
6019 |
{
|
sl@0
|
6020 |
case EPtr:
|
sl@0
|
6021 |
driveInfo = &((TPckg<TDriveInfoV1>&)anInfo)();
|
sl@0
|
6022 |
break;
|
sl@0
|
6023 |
case EBuf:
|
sl@0
|
6024 |
driveInfo = &((TDriveInfoV1Buf&)anInfo)();
|
sl@0
|
6025 |
break;
|
sl@0
|
6026 |
default:
|
sl@0
|
6027 |
__ASSERT_ALWAYS(EFalse,Panic(ETDes8BadDescriptorType));
|
sl@0
|
6028 |
}
|
sl@0
|
6029 |
|
sl@0
|
6030 |
// A compile time assert to make sure that this function is examined if TDriveInfoV1
|
sl@0
|
6031 |
// structure changes
|
sl@0
|
6032 |
extern int TDriveInfoV1_structure_assert[(
|
sl@0
|
6033 |
_FOFF(TDriveInfoV1,iRegisteredDriveBitmask)+4 == sizeof(TDriveInfoV1)
|
sl@0
|
6034 |
&&
|
sl@0
|
6035 |
sizeof(TDriveInfoV1) == 816
|
sl@0
|
6036 |
)?1:-1];
|
sl@0
|
6037 |
(void)TDriveInfoV1_structure_assert;
|
sl@0
|
6038 |
|
sl@0
|
6039 |
// Set length to size of old EKA1 TDriveInfoV1 (Will Panic if not big enough)
|
sl@0
|
6040 |
TInt len = (TUint)_FOFF(TDriveInfoV1,iRegisteredDriveBitmask);
|
sl@0
|
6041 |
anInfo.SetLength(len);
|
sl@0
|
6042 |
|
sl@0
|
6043 |
// Fill in info for old EKA1 TDriveInfoV1
|
sl@0
|
6044 |
driveInfo->iTotalSupportedDrives = driveInfo8.iTotalSupportedDrives;
|
sl@0
|
6045 |
driveInfo->iTotalSockets = driveInfo8.iTotalSockets;
|
sl@0
|
6046 |
driveInfo->iRuggedFileSystem = driveInfo8.iRuggedFileSystem;
|
sl@0
|
6047 |
TInt index;
|
sl@0
|
6048 |
for(index=0;index<KMaxLocalDrives;index++)
|
sl@0
|
6049 |
driveInfo->iDriveName[index].Copy(driveInfo8.iDriveName[index]);
|
sl@0
|
6050 |
for(index=0;index<KMaxPBusSockets;index++)
|
sl@0
|
6051 |
driveInfo->iSocketName[index].Copy(driveInfo8.iSocketName[index]);
|
sl@0
|
6052 |
|
sl@0
|
6053 |
// If anInfo is big enough then set new EKA2 members of TDriveInfoV1
|
sl@0
|
6054 |
if((TUint)anInfo.MaxLength()>=(TUint)sizeof(TDriveInfoV1))
|
sl@0
|
6055 |
{
|
sl@0
|
6056 |
anInfo.SetLength(sizeof(TDriveInfoV1));
|
sl@0
|
6057 |
driveInfo->iRegisteredDriveBitmask = driveInfo8.iRegisteredDriveBitmask;
|
sl@0
|
6058 |
}
|
sl@0
|
6059 |
return r;
|
sl@0
|
6060 |
}
|
sl@0
|
6061 |
|
sl@0
|
6062 |
|
sl@0
|
6063 |
|
sl@0
|
6064 |
|
sl@0
|
6065 |
/**
|
sl@0
|
6066 |
Gets the startup reason.
|
sl@0
|
6067 |
|
sl@0
|
6068 |
@see HAL::Get()
|
sl@0
|
6069 |
|
sl@0
|
6070 |
@publishedPartner
|
sl@0
|
6071 |
@deprecated Use HAL::Get() from the HAL library instead with attributes ESystemStartupReason.
|
sl@0
|
6072 |
*/
|
sl@0
|
6073 |
EXPORT_C TInt UserHal::StartupReason(TMachineStartupType& aReason)
|
sl@0
|
6074 |
{
|
sl@0
|
6075 |
return Exec::HalFunction(EHalGroupKernel,EKernelHalStartupReason,(TAny*)&aReason,NULL);
|
sl@0
|
6076 |
}
|
sl@0
|
6077 |
|
sl@0
|
6078 |
|
sl@0
|
6079 |
|
sl@0
|
6080 |
|
sl@0
|
6081 |
/**
|
sl@0
|
6082 |
Gets the reason why the kernel last faulted.
|
sl@0
|
6083 |
|
sl@0
|
6084 |
@param aReason An integer that, on return, contains the reason code describing
|
sl@0
|
6085 |
why the kernel faulted. This is the fault number passed
|
sl@0
|
6086 |
in a call to Kern::Fault().
|
sl@0
|
6087 |
|
sl@0
|
6088 |
@return KErrNone
|
sl@0
|
6089 |
|
sl@0
|
6090 |
@see Kern::Fault()
|
sl@0
|
6091 |
*/
|
sl@0
|
6092 |
EXPORT_C TInt UserHal::FaultReason(TInt &aReason)
|
sl@0
|
6093 |
{
|
sl@0
|
6094 |
|
sl@0
|
6095 |
return Exec::HalFunction(EHalGroupKernel,EKernelHalFaultReason,(TAny *)&aReason,NULL);
|
sl@0
|
6096 |
}
|
sl@0
|
6097 |
|
sl@0
|
6098 |
|
sl@0
|
6099 |
|
sl@0
|
6100 |
|
sl@0
|
6101 |
/**
|
sl@0
|
6102 |
Gets the exception Id that describes the type of fault when
|
sl@0
|
6103 |
the kernel last faulted.
|
sl@0
|
6104 |
|
sl@0
|
6105 |
The Id is the value contained in TArmExcInfo::iExcCode.
|
sl@0
|
6106 |
|
sl@0
|
6107 |
@param anId An integer that, on return, contains the exception Id.
|
sl@0
|
6108 |
|
sl@0
|
6109 |
@return KErrNone
|
sl@0
|
6110 |
|
sl@0
|
6111 |
@see TArmExcInfo::iExcCode
|
sl@0
|
6112 |
@see TArmExcInfo
|
sl@0
|
6113 |
*/
|
sl@0
|
6114 |
EXPORT_C TInt UserHal::ExceptionId(TInt &anId)
|
sl@0
|
6115 |
{
|
sl@0
|
6116 |
|
sl@0
|
6117 |
return Exec::HalFunction(EHalGroupKernel,EKernelHalExceptionId, (TAny *)&anId, NULL);
|
sl@0
|
6118 |
}
|
sl@0
|
6119 |
|
sl@0
|
6120 |
|
sl@0
|
6121 |
|
sl@0
|
6122 |
/**
|
sl@0
|
6123 |
Gets the available exception information that describes the last kernel fault.
|
sl@0
|
6124 |
|
sl@0
|
6125 |
@param aInfo A TExcInfo structure that, on return, contains the available
|
sl@0
|
6126 |
exception information.
|
sl@0
|
6127 |
|
sl@0
|
6128 |
@return KErrNone
|
sl@0
|
6129 |
|
sl@0
|
6130 |
@see TExcInfo
|
sl@0
|
6131 |
*/
|
sl@0
|
6132 |
EXPORT_C TInt UserHal::ExceptionInfo(TExcInfo &aInfo)
|
sl@0
|
6133 |
{
|
sl@0
|
6134 |
|
sl@0
|
6135 |
return Exec::HalFunction(EHalGroupKernel,EKernelHalExceptionInfo, (TAny *)&aInfo, NULL);
|
sl@0
|
6136 |
}
|
sl@0
|
6137 |
|
sl@0
|
6138 |
|
sl@0
|
6139 |
|
sl@0
|
6140 |
|
sl@0
|
6141 |
/**
|
sl@0
|
6142 |
Gets the page size for this device.
|
sl@0
|
6143 |
|
sl@0
|
6144 |
@param anId An integer that, on return, contains the page size, in bytes,
|
sl@0
|
6145 |
for this device.
|
sl@0
|
6146 |
|
sl@0
|
6147 |
@return KErrNone
|
sl@0
|
6148 |
*/
|
sl@0
|
6149 |
EXPORT_C TInt UserHal::PageSizeInBytes(TInt& aSize)
|
sl@0
|
6150 |
{
|
sl@0
|
6151 |
|
sl@0
|
6152 |
return Exec::HalFunction(EHalGroupKernel,EKernelHalPageSizeInBytes,(TAny*)&aSize,NULL);
|
sl@0
|
6153 |
}
|
sl@0
|
6154 |
|
sl@0
|
6155 |
|
sl@0
|
6156 |
|
sl@0
|
6157 |
|
sl@0
|
6158 |
/**
|
sl@0
|
6159 |
Switches the device off.
|
sl@0
|
6160 |
|
sl@0
|
6161 |
@return KErrNone, if successful; KErrPermissionDenied, if the calling process
|
sl@0
|
6162 |
has insufficient capability.
|
sl@0
|
6163 |
|
sl@0
|
6164 |
@capability PowerMgmt
|
sl@0
|
6165 |
*/
|
sl@0
|
6166 |
EXPORT_C TInt UserHal::SwitchOff()
|
sl@0
|
6167 |
{
|
sl@0
|
6168 |
if(!RProcess().HasCapability(ECapabilityPowerMgmt,__PLATSEC_DIAGNOSTIC_STRING("Checked by UserHal::SwitchOff")))
|
sl@0
|
6169 |
return KErrPermissionDenied;
|
sl@0
|
6170 |
TInt r = Power::EnableWakeupEvents(EPwStandby);
|
sl@0
|
6171 |
if(r!=KErrNone)
|
sl@0
|
6172 |
return r;
|
sl@0
|
6173 |
TRequestStatus s;
|
sl@0
|
6174 |
Power::RequestWakeupEventNotification(s);
|
sl@0
|
6175 |
Power::PowerDown();
|
sl@0
|
6176 |
User::WaitForRequest(s);
|
sl@0
|
6177 |
return s.Int();
|
sl@0
|
6178 |
// return Exec::HalFunction(EHalGroupPower,EPowerHalSwitchOff,NULL,NULL);
|
sl@0
|
6179 |
}
|
sl@0
|
6180 |
|
sl@0
|
6181 |
|
sl@0
|
6182 |
|
sl@0
|
6183 |
|
sl@0
|
6184 |
/**
|
sl@0
|
6185 |
Sets the calibration data for the digitiser (i.e. XY) input device.
|
sl@0
|
6186 |
|
sl@0
|
6187 |
@param aCalibration The calibration data.
|
sl@0
|
6188 |
|
sl@0
|
6189 |
@return KErrNone, if successful; KErrPermissionDenied, if the calling process
|
sl@0
|
6190 |
has insufficient capability.
|
sl@0
|
6191 |
|
sl@0
|
6192 |
@see TDigitizerCalibration
|
sl@0
|
6193 |
|
sl@0
|
6194 |
@capability WriteDeviceData
|
sl@0
|
6195 |
*/
|
sl@0
|
6196 |
EXPORT_C TInt UserHal::SetXYInputCalibration(const TDigitizerCalibration& aCalibration)
|
sl@0
|
6197 |
{
|
sl@0
|
6198 |
return Exec::HalFunction(EHalGroupDigitiser,EDigitiserHalSetXYInputCalibration,(TAny*)&aCalibration,NULL);
|
sl@0
|
6199 |
}
|
sl@0
|
6200 |
|
sl@0
|
6201 |
|
sl@0
|
6202 |
|
sl@0
|
6203 |
|
sl@0
|
6204 |
/**
|
sl@0
|
6205 |
Gets the points on the display that the user should point to in order
|
sl@0
|
6206 |
to calibrate the digitiser (i.e. XY) input device.
|
sl@0
|
6207 |
|
sl@0
|
6208 |
@param aCalibration A TDigitizerCalibration object that, on return, contains
|
sl@0
|
6209 |
the appropriate information.
|
sl@0
|
6210 |
|
sl@0
|
6211 |
@return KerrNone, if successful; otherwise one of the other system wide
|
sl@0
|
6212 |
error codes.
|
sl@0
|
6213 |
*/
|
sl@0
|
6214 |
EXPORT_C TInt UserHal::CalibrationPoints(TDigitizerCalibration& aCalibration)
|
sl@0
|
6215 |
{
|
sl@0
|
6216 |
|
sl@0
|
6217 |
return Exec::HalFunction(EHalGroupDigitiser,EDigitiserHalCalibrationPoints,(TAny*)&aCalibration,NULL);
|
sl@0
|
6218 |
}
|
sl@0
|
6219 |
|
sl@0
|
6220 |
|
sl@0
|
6221 |
|
sl@0
|
6222 |
|
sl@0
|
6223 |
/**
|
sl@0
|
6224 |
Gets the platform tick period.
|
sl@0
|
6225 |
|
sl@0
|
6226 |
@param aTime The tick period in microseconds.
|
sl@0
|
6227 |
|
sl@0
|
6228 |
@return KErrNone, if successful; otherwise one of the other system wide
|
sl@0
|
6229 |
error codes.
|
sl@0
|
6230 |
*/
|
sl@0
|
6231 |
EXPORT_C TInt UserHal::TickPeriod(TTimeIntervalMicroSeconds32 &aTime)
|
sl@0
|
6232 |
{
|
sl@0
|
6233 |
|
sl@0
|
6234 |
return Exec::HalFunction(EHalGroupKernel,EKernelHalTickPeriod,(TAny*)&aTime,NULL);
|
sl@0
|
6235 |
}
|
sl@0
|
6236 |
|
sl@0
|
6237 |
|
sl@0
|
6238 |
|
sl@0
|
6239 |
/**
|
sl@0
|
6240 |
Saves the current digitiser (i.e. XY) input device calibration data.
|
sl@0
|
6241 |
|
sl@0
|
6242 |
@return KErrNone, if successful; otherwise one of the other system wide
|
sl@0
|
6243 |
error codes, e.g. KErrNotSupported.
|
sl@0
|
6244 |
*/
|
sl@0
|
6245 |
EXPORT_C TInt UserHal::SaveXYInputCalibration()
|
sl@0
|
6246 |
{
|
sl@0
|
6247 |
|
sl@0
|
6248 |
return Exec::HalFunction(EHalGroupDigitiser,EDigitiserHalSaveXYInputCalibration,NULL,NULL);
|
sl@0
|
6249 |
}
|
sl@0
|
6250 |
|
sl@0
|
6251 |
|
sl@0
|
6252 |
|
sl@0
|
6253 |
|
sl@0
|
6254 |
/**
|
sl@0
|
6255 |
Restores the digitiser (i.e. XY) input device calibration data.
|
sl@0
|
6256 |
|
sl@0
|
6257 |
@param aType A TDigitizerCalibration object that, on return, contains
|
sl@0
|
6258 |
the calibration data.
|
sl@0
|
6259 |
|
sl@0
|
6260 |
@return KErrNone, if successful; KErrPermissionDenied, if the calling process
|
sl@0
|
6261 |
has insufficient capability; otherwise one of the other system wide
|
sl@0
|
6262 |
error codes, e.g. KErrNotSupported.
|
sl@0
|
6263 |
|
sl@0
|
6264 |
@capability WriteDeviceData
|
sl@0
|
6265 |
*/
|
sl@0
|
6266 |
EXPORT_C TInt UserHal::RestoreXYInputCalibration(TDigitizerCalibrationType aType)
|
sl@0
|
6267 |
{
|
sl@0
|
6268 |
return Exec::HalFunction(EHalGroupDigitiser,EDigitiserHalRestoreXYInputCalibration,(TAny*)aType,NULL);
|
sl@0
|
6269 |
}
|
sl@0
|
6270 |
|
sl@0
|
6271 |
|
sl@0
|
6272 |
|
sl@0
|
6273 |
|
sl@0
|
6274 |
/**
|
sl@0
|
6275 |
Gets the machine configuration.
|
sl@0
|
6276 |
|
sl@0
|
6277 |
@param aConfig On return contains the machine configuration data.
|
sl@0
|
6278 |
@param aSize On return, contains the size of the data.
|
sl@0
|
6279 |
|
sl@0
|
6280 |
@return KErrNone, if sucessful, otherwise one of the other system-wide
|
sl@0
|
6281 |
error codes.
|
sl@0
|
6282 |
|
sl@0
|
6283 |
@capability ReadDeviceData
|
sl@0
|
6284 |
*/
|
sl@0
|
6285 |
EXPORT_C TInt User::MachineConfiguration(TDes8& aConfig,TInt& aSize)
|
sl@0
|
6286 |
{
|
sl@0
|
6287 |
return(Exec::MachineConfiguration(aConfig,aSize));
|
sl@0
|
6288 |
}
|
sl@0
|
6289 |
|
sl@0
|
6290 |
|
sl@0
|
6291 |
|
sl@0
|
6292 |
|
sl@0
|
6293 |
EXPORT_C TInt RDebug::Print(TRefByValue<const TDesC> aFmt,...)
|
sl@0
|
6294 |
//
|
sl@0
|
6295 |
// Print to the comms port
|
sl@0
|
6296 |
//
|
sl@0
|
6297 |
{
|
sl@0
|
6298 |
|
sl@0
|
6299 |
TestOverflowTruncate overflow;
|
sl@0
|
6300 |
// coverity[var_decl]
|
sl@0
|
6301 |
VA_LIST list;
|
sl@0
|
6302 |
VA_START(list,aFmt);
|
sl@0
|
6303 |
TBuf<0x100> buf;
|
sl@0
|
6304 |
// coverity[uninit_use_in_call]
|
sl@0
|
6305 |
TRAP_IGNORE(buf.AppendFormatList(aFmt,list,&overflow)); // ignore leave in TTimeOverflowLeave::Overflow()
|
sl@0
|
6306 |
#ifdef _UNICODE
|
sl@0
|
6307 |
TPtr8 p(buf.Collapse());
|
sl@0
|
6308 |
Exec::DebugPrint((TAny*)&p, 0);
|
sl@0
|
6309 |
#else
|
sl@0
|
6310 |
Exec::DebugPrint((TAny*)&buf, 0);
|
sl@0
|
6311 |
#endif
|
sl@0
|
6312 |
return 0;
|
sl@0
|
6313 |
}
|
sl@0
|
6314 |
|
sl@0
|
6315 |
class TestOverflowTruncate8 : public TDes8Overflow
|
sl@0
|
6316 |
{
|
sl@0
|
6317 |
public:
|
sl@0
|
6318 |
virtual void Overflow(TDes8& /*aDes*/) {}
|
sl@0
|
6319 |
};
|
sl@0
|
6320 |
|
sl@0
|
6321 |
EXPORT_C void RDebug::Printf(const char* aFmt, ...)
|
sl@0
|
6322 |
//
|
sl@0
|
6323 |
// Print to the comms port
|
sl@0
|
6324 |
//
|
sl@0
|
6325 |
{
|
sl@0
|
6326 |
|
sl@0
|
6327 |
TestOverflowTruncate8 overflow;
|
sl@0
|
6328 |
// coverity[var_decl]
|
sl@0
|
6329 |
VA_LIST list;
|
sl@0
|
6330 |
VA_START(list,aFmt);
|
sl@0
|
6331 |
TPtrC8 fmt((const TText8*)aFmt);
|
sl@0
|
6332 |
TBuf8<0x100> buf;
|
sl@0
|
6333 |
// coverity[uninit_use_in_call]
|
sl@0
|
6334 |
TRAP_IGNORE(buf.AppendFormatList(fmt,list,&overflow));
|
sl@0
|
6335 |
Exec::DebugPrint((TAny*)&buf, 0);
|
sl@0
|
6336 |
}
|
sl@0
|
6337 |
|
sl@0
|
6338 |
EXPORT_C void RDebug::RawPrint(const TDesC8& aDes)
|
sl@0
|
6339 |
{
|
sl@0
|
6340 |
Exec::DebugPrint((TAny*)&aDes, 1);
|
sl@0
|
6341 |
}
|
sl@0
|
6342 |
|
sl@0
|
6343 |
EXPORT_C void RDebug::RawPrint(const TDesC16& aDes)
|
sl@0
|
6344 |
//
|
sl@0
|
6345 |
// Print to the comms port
|
sl@0
|
6346 |
//
|
sl@0
|
6347 |
{
|
sl@0
|
6348 |
TBuf8<0x100> aDes8;
|
sl@0
|
6349 |
if(aDes.Length()>0x100)
|
sl@0
|
6350 |
{
|
sl@0
|
6351 |
TPtrC ptr(aDes.Ptr(), 0x100);
|
sl@0
|
6352 |
aDes8.Copy(ptr);
|
sl@0
|
6353 |
}
|
sl@0
|
6354 |
else
|
sl@0
|
6355 |
aDes8.Copy(aDes);
|
sl@0
|
6356 |
Exec::DebugPrint((TAny*)&aDes8, 1);
|
sl@0
|
6357 |
}
|
sl@0
|
6358 |
|
sl@0
|
6359 |
EXPORT_C TUint32 Math::Random()
|
sl@0
|
6360 |
/**
|
sl@0
|
6361 |
Gets 32 random bits from the kernel's random pool.
|
sl@0
|
6362 |
|
sl@0
|
6363 |
@return The 32 random bits.
|
sl@0
|
6364 |
*/
|
sl@0
|
6365 |
{
|
sl@0
|
6366 |
|
sl@0
|
6367 |
return Exec::MathRandom();
|
sl@0
|
6368 |
}
|
sl@0
|
6369 |
|
sl@0
|
6370 |
|
sl@0
|
6371 |
|
sl@0
|
6372 |
EXPORT_C void User::IMB_Range(TAny* aStart, TAny* aEnd)
|
sl@0
|
6373 |
/**
|
sl@0
|
6374 |
Does the necessary preparations to guarantee correct execution of code in the
|
sl@0
|
6375 |
specified virtual address range.
|
sl@0
|
6376 |
|
sl@0
|
6377 |
The function assumes that this code has been loaded or modified by user code.
|
sl@0
|
6378 |
Calling this function against uncommitted memory region is considered as S/W
|
sl@0
|
6379 |
bug and may generate exception on some memory models.
|
sl@0
|
6380 |
|
sl@0
|
6381 |
The specified addresses are associated with a user writable code chunk as
|
sl@0
|
6382 |
created by RChunk::CreateLocalCode().
|
sl@0
|
6383 |
|
sl@0
|
6384 |
The function cleans the data cache to ensure that written data has been
|
sl@0
|
6385 |
committed to main memory and then flushes the instruction cache and branch
|
sl@0
|
6386 |
target buffer (BTB) to ensure that the code is loaded from main memory when
|
sl@0
|
6387 |
it is executed.
|
sl@0
|
6388 |
The Kernel uses the size of the range specified to decide whether to clean/flush
|
sl@0
|
6389 |
line-by-line or to simply clean/flush the entire cache.
|
sl@0
|
6390 |
|
sl@0
|
6391 |
@param aStart The start virtual address of the region.
|
sl@0
|
6392 |
@param aEnd The end virtual address of the region. This location is not within
|
sl@0
|
6393 |
the region.
|
sl@0
|
6394 |
|
sl@0
|
6395 |
@see RChunk::CreateLocalCode()
|
sl@0
|
6396 |
@see UserHeap::ChunkHeap()
|
sl@0
|
6397 |
*/
|
sl@0
|
6398 |
{
|
sl@0
|
6399 |
|
sl@0
|
6400 |
Exec::IMB_Range(aStart,(TUint32)aEnd-(TUint32)aStart);
|
sl@0
|
6401 |
}
|
sl@0
|
6402 |
|
sl@0
|
6403 |
|
sl@0
|
6404 |
|
sl@0
|
6405 |
|
sl@0
|
6406 |
/**
|
sl@0
|
6407 |
Sets the specified handle into the specified environment data slot
|
sl@0
|
6408 |
for this process.
|
sl@0
|
6409 |
|
sl@0
|
6410 |
The APPARC framework (class CApaApplication etc.) uses some of the slots internally,
|
sl@0
|
6411 |
so programs that use this framework should ensure that they only use slots available
|
sl@0
|
6412 |
for public use.
|
sl@0
|
6413 |
|
sl@0
|
6414 |
@param aSlot An index that identifies the environment data slot.
|
sl@0
|
6415 |
This is a value relative to zero;
|
sl@0
|
6416 |
i.e. 0 is the first item/slot.
|
sl@0
|
6417 |
This can range from 0 to 15.
|
sl@0
|
6418 |
@param aHandle The handle to be passed to this process.
|
sl@0
|
6419 |
|
sl@0
|
6420 |
@return KErrNone, always.
|
sl@0
|
6421 |
|
sl@0
|
6422 |
@panic KERN-EXEC 46 if this function is called by a thread running
|
sl@0
|
6423 |
in a process that is not the creator of this process, or
|
sl@0
|
6424 |
the handle is not local.
|
sl@0
|
6425 |
@panic KERN-EXEC 51 if aSlot is negative or is greater than or equal to
|
sl@0
|
6426 |
the value of KArgIndex.
|
sl@0
|
6427 |
@panic KERN-EXEC 52 if the specified slot is already in use.
|
sl@0
|
6428 |
|
sl@0
|
6429 |
@see CApaApplication
|
sl@0
|
6430 |
@see CApaCommandLine::EnvironmentSlotForPublicUse()
|
sl@0
|
6431 |
*/
|
sl@0
|
6432 |
EXPORT_C TInt RProcess::SetParameter(TInt aSlot, RHandleBase aHandle)
|
sl@0
|
6433 |
{
|
sl@0
|
6434 |
return Exec::ProcessSetHandleParameter(iHandle, aSlot, aHandle.Handle());
|
sl@0
|
6435 |
}
|
sl@0
|
6436 |
|
sl@0
|
6437 |
|
sl@0
|
6438 |
|
sl@0
|
6439 |
|
sl@0
|
6440 |
/**
|
sl@0
|
6441 |
Sets the specified 16-bit descriptor data into the specified environment
|
sl@0
|
6442 |
data slot for this process.
|
sl@0
|
6443 |
|
sl@0
|
6444 |
The APPARC framework (class CApaApplication etc.) uses some of the slots internally,
|
sl@0
|
6445 |
so programs that use this framework should ensure that they only use slots available
|
sl@0
|
6446 |
for public use.
|
sl@0
|
6447 |
|
sl@0
|
6448 |
@param aSlot An index that identifies the environment data slot.
|
sl@0
|
6449 |
This is a value relative to zero;
|
sl@0
|
6450 |
i.e. 0 is the first item/slot.
|
sl@0
|
6451 |
This can range from 0 to 15.
|
sl@0
|
6452 |
@param aDes The 16-bit descriptor containing data be passed to this process.
|
sl@0
|
6453 |
|
sl@0
|
6454 |
@return KErrNone, if successful, otherwise one of the other system
|
sl@0
|
6455 |
wide error codes.
|
sl@0
|
6456 |
|
sl@0
|
6457 |
@panic KERN-EXEC 46 if this function is called by a thread running
|
sl@0
|
6458 |
in a process that is not the creator of this process.
|
sl@0
|
6459 |
@panic KERN-EXEC 51 if aSlot is negative or is greater than or equal to
|
sl@0
|
6460 |
the value of KArgIndex.
|
sl@0
|
6461 |
@panic KERN-EXEC 52 if the specified slot is already in use.
|
sl@0
|
6462 |
@panic KERN-EXEC 53 if the length of data passed is negative.
|
sl@0
|
6463 |
|
sl@0
|
6464 |
@see CApaApplication
|
sl@0
|
6465 |
@see CApaCommandLine::EnvironmentSlotForPublicUse()
|
sl@0
|
6466 |
*/
|
sl@0
|
6467 |
EXPORT_C TInt RProcess::SetParameter(TInt aSlot, const TDesC16& aDes)
|
sl@0
|
6468 |
{
|
sl@0
|
6469 |
return Exec::ProcessSetDataParameter(iHandle, aSlot, (const TUint8*)aDes.Ptr(), 2*aDes.Length());
|
sl@0
|
6470 |
}
|
sl@0
|
6471 |
|
sl@0
|
6472 |
|
sl@0
|
6473 |
|
sl@0
|
6474 |
|
sl@0
|
6475 |
/**
|
sl@0
|
6476 |
Sets the specified 8-bit descriptor data into the specified environment
|
sl@0
|
6477 |
data slot for this process.
|
sl@0
|
6478 |
|
sl@0
|
6479 |
The APPARC framework (class CApaApplication etc.) uses some of the slots internally,
|
sl@0
|
6480 |
so programs that use this framework should ensure that they only use slots available
|
sl@0
|
6481 |
for public use.
|
sl@0
|
6482 |
|
sl@0
|
6483 |
@param aSlot An index that identifies the environment data slot.
|
sl@0
|
6484 |
This is a value relative to zero;
|
sl@0
|
6485 |
i.e. 0 is the first item/slot.
|
sl@0
|
6486 |
This can range from 0 to 15.
|
sl@0
|
6487 |
@param aDes The 8-bit descriptor containing data be passed to this process.
|
sl@0
|
6488 |
|
sl@0
|
6489 |
@return KErrNone, if successful, otherwise one of the other system
|
sl@0
|
6490 |
wide error codes.
|
sl@0
|
6491 |
|
sl@0
|
6492 |
@panic KERN-EXEC 46 if this function is called by a thread running
|
sl@0
|
6493 |
in a process that is not the creator of this process.
|
sl@0
|
6494 |
@panic KERN-EXEC 51 if aSlot is negative or is greater than or equal to
|
sl@0
|
6495 |
the value of KArgIndex.
|
sl@0
|
6496 |
@panic KERN-EXEC 52 if the specified slot is already in use.
|
sl@0
|
6497 |
@panic KERN-EXEC 53 if the length of data passed is negative.
|
sl@0
|
6498 |
|
sl@0
|
6499 |
@see CApaApplication
|
sl@0
|
6500 |
@see CApaCommandLine::EnvironmentSlotForPublicUse()
|
sl@0
|
6501 |
*/
|
sl@0
|
6502 |
EXPORT_C TInt RProcess::SetParameter(TInt aSlot, const TDesC8& aDes)
|
sl@0
|
6503 |
{
|
sl@0
|
6504 |
return Exec::ProcessSetDataParameter(iHandle, aSlot, aDes.Ptr(), aDes.Length());
|
sl@0
|
6505 |
}
|
sl@0
|
6506 |
|
sl@0
|
6507 |
|
sl@0
|
6508 |
|
sl@0
|
6509 |
|
sl@0
|
6510 |
/**
|
sl@0
|
6511 |
Sets the specfied sub-session into the specified environment
|
sl@0
|
6512 |
data slot for this process.
|
sl@0
|
6513 |
|
sl@0
|
6514 |
The APPARC framework (class CApaApplication etc.) uses some of the slots internally,
|
sl@0
|
6515 |
so programs that use this framework should ensure that they only use slots available
|
sl@0
|
6516 |
for public use.
|
sl@0
|
6517 |
|
sl@0
|
6518 |
@param aSlot An index that identifies the environment data slot.
|
sl@0
|
6519 |
This is a value relative to zero;
|
sl@0
|
6520 |
i.e. 0 is the first item/slot.
|
sl@0
|
6521 |
This can range from 0 to 15.
|
sl@0
|
6522 |
@param aSession The sub-session.
|
sl@0
|
6523 |
|
sl@0
|
6524 |
@return KErrNone, if successful, otherwise one of the other system
|
sl@0
|
6525 |
wide error codes.
|
sl@0
|
6526 |
|
sl@0
|
6527 |
@panic KERN-EXEC 46 if this function is called by a thread running
|
sl@0
|
6528 |
in a process that is not the creator of this process.
|
sl@0
|
6529 |
@panic KERN-EXEC 51 if aSlot is negative or is greater than or equal to
|
sl@0
|
6530 |
the value of KArgIndex.
|
sl@0
|
6531 |
@panic KERN-EXEC 52 if the specified slot is already in use.
|
sl@0
|
6532 |
@panic KERN-EXEC 53 if the length of data passed is negative.
|
sl@0
|
6533 |
|
sl@0
|
6534 |
@see CApaApplication
|
sl@0
|
6535 |
@see CApaCommandLine::EnvironmentSlotForPublicUse()
|
sl@0
|
6536 |
*/
|
sl@0
|
6537 |
EXPORT_C TInt RProcess::SetParameter(TInt aSlot, const RSubSessionBase& aSession)
|
sl@0
|
6538 |
{
|
sl@0
|
6539 |
TInt handle = aSession.SubSessionHandle();
|
sl@0
|
6540 |
return Exec::ProcessSetDataParameter(iHandle, aSlot, (const TUint8*)&handle, sizeof(handle));
|
sl@0
|
6541 |
}
|
sl@0
|
6542 |
|
sl@0
|
6543 |
|
sl@0
|
6544 |
|
sl@0
|
6545 |
|
sl@0
|
6546 |
/**
|
sl@0
|
6547 |
Sets the specfied integer value into the specified environment
|
sl@0
|
6548 |
data slot for this process.
|
sl@0
|
6549 |
|
sl@0
|
6550 |
The APPARC framework (class CApaApplication etc.) uses some of the slots internally,
|
sl@0
|
6551 |
so programs that use this framework should ensure that they only use slots available
|
sl@0
|
6552 |
for public use.
|
sl@0
|
6553 |
|
sl@0
|
6554 |
@param aSlot An index that identifies the environment data slot.
|
sl@0
|
6555 |
This is a value relative to zero;
|
sl@0
|
6556 |
i.e. 0 is the first item/slot.
|
sl@0
|
6557 |
This can range from 0 to 15.
|
sl@0
|
6558 |
@param aData The integer value.
|
sl@0
|
6559 |
|
sl@0
|
6560 |
@return KErrNone, if successful, otherwise one of the other system
|
sl@0
|
6561 |
wide error codes.
|
sl@0
|
6562 |
|
sl@0
|
6563 |
@panic KERN-EXEC 46 if this function is called by a thread running
|
sl@0
|
6564 |
in a process that is not the creator of this process.
|
sl@0
|
6565 |
@panic KERN-EXEC 51 if aSlot is negative or is greater than or equal to
|
sl@0
|
6566 |
the value of KArgIndex.
|
sl@0
|
6567 |
@panic KERN-EXEC 52 if the specified slot is already in use.
|
sl@0
|
6568 |
@panic KERN-EXEC 53 if the length of data passed is negative.
|
sl@0
|
6569 |
|
sl@0
|
6570 |
@see CApaApplication
|
sl@0
|
6571 |
@see CApaCommandLine::EnvironmentSlotForPublicUse()
|
sl@0
|
6572 |
*/
|
sl@0
|
6573 |
EXPORT_C TInt RProcess::SetParameter(TInt aSlot, TInt aData)
|
sl@0
|
6574 |
{
|
sl@0
|
6575 |
return Exec::ProcessSetDataParameter(iHandle, aSlot, (TUint8*)&aData, sizeof(aData));
|
sl@0
|
6576 |
}
|
sl@0
|
6577 |
|
sl@0
|
6578 |
|
sl@0
|
6579 |
|
sl@0
|
6580 |
|
sl@0
|
6581 |
EXPORT_C TInt User::GetTIntParameter(TInt aSlot, TInt& aData)
|
sl@0
|
6582 |
/**
|
sl@0
|
6583 |
Gets the specified environment data item belonging to the
|
sl@0
|
6584 |
current process; this is assumed to be a 32 bit value.
|
sl@0
|
6585 |
|
sl@0
|
6586 |
Environment data may be stored in the process and is passed to a child process
|
sl@0
|
6587 |
on creation of that child process.
|
sl@0
|
6588 |
|
sl@0
|
6589 |
On successful return from this function, the data item is deleted from
|
sl@0
|
6590 |
the process.
|
sl@0
|
6591 |
|
sl@0
|
6592 |
@param aSlot An index that identifies the data item.
|
sl@0
|
6593 |
This is an index whose value is relative to zero;
|
sl@0
|
6594 |
i.e. 0 is the first item/slot.
|
sl@0
|
6595 |
This can range from 0 to 15, i.e. there are 16 slots.
|
sl@0
|
6596 |
|
sl@0
|
6597 |
@param aData On sucessful return, contains the environment data item.
|
sl@0
|
6598 |
|
sl@0
|
6599 |
@return KErrNone, if successful;
|
sl@0
|
6600 |
KErrNotFound, if there is no data;
|
sl@0
|
6601 |
KErrArgument, if the data is not binary data, or the data item in the
|
sl@0
|
6602 |
process is longer than 32 bits.
|
sl@0
|
6603 |
|
sl@0
|
6604 |
@panic KERN-EXEC 51, if aSlot is negative or is greater than or equal to 16.
|
sl@0
|
6605 |
*/
|
sl@0
|
6606 |
{
|
sl@0
|
6607 |
TInt ret = Exec::ProcessGetDataParameter(aSlot, (TUint8*)&aData, sizeof(TInt));
|
sl@0
|
6608 |
if (ret < 0)
|
sl@0
|
6609 |
return ret;
|
sl@0
|
6610 |
return KErrNone;
|
sl@0
|
6611 |
}
|
sl@0
|
6612 |
|
sl@0
|
6613 |
|
sl@0
|
6614 |
|
sl@0
|
6615 |
|
sl@0
|
6616 |
EXPORT_C TInt User::ParameterLength(TInt aSlot)
|
sl@0
|
6617 |
/**
|
sl@0
|
6618 |
Gets the length of the specified item of environment data belonging to the
|
sl@0
|
6619 |
current process.
|
sl@0
|
6620 |
|
sl@0
|
6621 |
Environment data may be stored in the process and is passed to a child process
|
sl@0
|
6622 |
on creation of that child process.
|
sl@0
|
6623 |
|
sl@0
|
6624 |
@param aSlot An index that identifies the data item whose length is to be
|
sl@0
|
6625 |
retrieved. This is an index whose value is relative to zero;
|
sl@0
|
6626 |
i.e. 0 is the first item/slot.
|
sl@0
|
6627 |
This can range from 0 to 15, i.e. there are 16 slots.
|
sl@0
|
6628 |
|
sl@0
|
6629 |
@return KErrNotFound, if there is no data;
|
sl@0
|
6630 |
KErrArgument, if the data is not binary data;
|
sl@0
|
6631 |
The length of the data item.
|
sl@0
|
6632 |
|
sl@0
|
6633 |
@panic KERN-EXEC 51, if aSlot is negative or is greater than or equal to 16.
|
sl@0
|
6634 |
*/
|
sl@0
|
6635 |
{
|
sl@0
|
6636 |
TInt ret = Exec::ProcessDataParameterLength(aSlot);
|
sl@0
|
6637 |
return ret;
|
sl@0
|
6638 |
}
|
sl@0
|
6639 |
|
sl@0
|
6640 |
|
sl@0
|
6641 |
|
sl@0
|
6642 |
|
sl@0
|
6643 |
EXPORT_C TInt User::GetDesParameter(TInt aSlot, TDes8& aDes)
|
sl@0
|
6644 |
/**
|
sl@0
|
6645 |
Gets the specified environment data item belonging to the
|
sl@0
|
6646 |
current process; this is assumed to be an 8-bit descriptor.
|
sl@0
|
6647 |
|
sl@0
|
6648 |
Environment data may be stored in the process and is passed to a child process
|
sl@0
|
6649 |
on creation of that child process.
|
sl@0
|
6650 |
|
sl@0
|
6651 |
On successful return from this function, the data item is deleted from
|
sl@0
|
6652 |
the process.
|
sl@0
|
6653 |
|
sl@0
|
6654 |
@param aSlot An index that identifies the data item.
|
sl@0
|
6655 |
This is an index whose value is relative to zero;
|
sl@0
|
6656 |
i.e. 0 is the first item/slot.
|
sl@0
|
6657 |
This can range from 0 to 15, i.e. there are 16 slots.
|
sl@0
|
6658 |
|
sl@0
|
6659 |
@param aDes On sucessful return, contains the environment data item; the
|
sl@0
|
6660 |
length of the descriptor is set to the length of the data item.
|
sl@0
|
6661 |
|
sl@0
|
6662 |
@return KErrNone, if successful;
|
sl@0
|
6663 |
KErrNotFound, if there is no data;
|
sl@0
|
6664 |
KErrArgument, if the data is not binary data, or the data item in the
|
sl@0
|
6665 |
process is longer than the maximum length of aDes.
|
sl@0
|
6666 |
|
sl@0
|
6667 |
@panic KERN-EXEC 51, if aSlot is negative or is greater than or equal to 16.
|
sl@0
|
6668 |
*/
|
sl@0
|
6669 |
{
|
sl@0
|
6670 |
TInt ret = Exec::ProcessGetDataParameter(aSlot, (TUint8*)aDes.Ptr(), aDes.MaxLength());
|
sl@0
|
6671 |
if (ret < 0)
|
sl@0
|
6672 |
return ret;
|
sl@0
|
6673 |
aDes.SetLength(ret);
|
sl@0
|
6674 |
return KErrNone;
|
sl@0
|
6675 |
}
|
sl@0
|
6676 |
|
sl@0
|
6677 |
|
sl@0
|
6678 |
|
sl@0
|
6679 |
|
sl@0
|
6680 |
EXPORT_C TInt User::GetDesParameter(TInt aSlot, TDes16& aDes)
|
sl@0
|
6681 |
/**
|
sl@0
|
6682 |
Gets the specified environment data item belonging to the
|
sl@0
|
6683 |
current process; this is assumed to be an 16-bit descriptor.
|
sl@0
|
6684 |
|
sl@0
|
6685 |
Environment data may be stored in the process and is passed to a child process
|
sl@0
|
6686 |
on creation of that child process.
|
sl@0
|
6687 |
|
sl@0
|
6688 |
On successful return from this function, the data item is deleted from
|
sl@0
|
6689 |
the process.
|
sl@0
|
6690 |
|
sl@0
|
6691 |
@param aSlot An index that identifies the data item.
|
sl@0
|
6692 |
This is an index whose value is relative to zero;
|
sl@0
|
6693 |
i.e. 0 is the first item/slot.
|
sl@0
|
6694 |
This can range from 0 to 15, i.e. there are 16 slots.
|
sl@0
|
6695 |
|
sl@0
|
6696 |
@param aDes On sucessful return, contains the environment data item; the
|
sl@0
|
6697 |
length of the descriptor is set to the length of the data item.
|
sl@0
|
6698 |
|
sl@0
|
6699 |
@return KErrNone, if successful;
|
sl@0
|
6700 |
KErrNotFound, if there is no data;
|
sl@0
|
6701 |
KErrArgument, if the data is not binary data, or the data item in the
|
sl@0
|
6702 |
process is longer than the maximum length of aDes.
|
sl@0
|
6703 |
|
sl@0
|
6704 |
@panic KERN-EXEC 51, if aSlot is negative or is greater than or equal to 16.
|
sl@0
|
6705 |
*/
|
sl@0
|
6706 |
{
|
sl@0
|
6707 |
TInt ret = Exec::ProcessGetDataParameter(aSlot, (TUint8*)aDes.Ptr(), 2*aDes.MaxLength());
|
sl@0
|
6708 |
if (ret < 0)
|
sl@0
|
6709 |
return ret;
|
sl@0
|
6710 |
aDes.SetLength(ret/2);
|
sl@0
|
6711 |
return KErrNone;
|
sl@0
|
6712 |
}
|
sl@0
|
6713 |
|
sl@0
|
6714 |
/**
|
sl@0
|
6715 |
Gets the linear address of the exception descriptor for the code module in which
|
sl@0
|
6716 |
a specified code address resides.
|
sl@0
|
6717 |
|
sl@0
|
6718 |
@param aCodeAddress The code address in question.
|
sl@0
|
6719 |
@return The address of the exception descriptor, or zero if there is none.
|
sl@0
|
6720 |
|
sl@0
|
6721 |
*/
|
sl@0
|
6722 |
EXPORT_C TLinAddr UserSvr::ExceptionDescriptor(TLinAddr aCodeAddress)
|
sl@0
|
6723 |
{
|
sl@0
|
6724 |
return Exec::ExceptionDescriptor(aCodeAddress);
|
sl@0
|
6725 |
}
|
sl@0
|
6726 |
|
sl@0
|
6727 |
EXPORT_C TInt User::SetFloatingPointMode(TFloatingPointMode aMode, TFloatingPointRoundingMode aRoundingMode)
|
sl@0
|
6728 |
/**
|
sl@0
|
6729 |
Sets the hardware floating point mode for the current thread. This does not affect
|
sl@0
|
6730 |
software floating point calculations. The rounding mode can also be set. New threads created
|
sl@0
|
6731 |
by this thread will inherit the mode, thus to set the mode for a whole process, call this
|
sl@0
|
6732 |
method before you create any new threads.
|
sl@0
|
6733 |
|
sl@0
|
6734 |
@param aMode The floating point calculation mode to use.
|
sl@0
|
6735 |
@param aRoundingMode The floating point rounding mode to use, defaults to nearest.
|
sl@0
|
6736 |
|
sl@0
|
6737 |
@return KErrNone if successful, KErrNotSupported if the hardware does not support the
|
sl@0
|
6738 |
chosen mode, or there is no floating point hardware present.
|
sl@0
|
6739 |
|
sl@0
|
6740 |
@see TFloatingPointMode
|
sl@0
|
6741 |
@see TFloatingPointRoundingMode
|
sl@0
|
6742 |
*/
|
sl@0
|
6743 |
{
|
sl@0
|
6744 |
return(Exec::SetFloatingPointMode(aMode, aRoundingMode));
|
sl@0
|
6745 |
}
|
sl@0
|
6746 |
|
sl@0
|
6747 |
|
sl@0
|
6748 |
EXPORT_C TUint32 E32Loader::PagingPolicy()
|
sl@0
|
6749 |
/**
|
sl@0
|
6750 |
Accessor function returns the code paging policy, as defined at ROM build time.
|
sl@0
|
6751 |
|
sl@0
|
6752 |
@return Code paging policy only. This function applies
|
sl@0
|
6753 |
EKernelConfigCodePagingPolicyMask to the config flags
|
sl@0
|
6754 |
before returning the value.
|
sl@0
|
6755 |
*/
|
sl@0
|
6756 |
{
|
sl@0
|
6757 |
return Exec::KernelConfigFlags() & EKernelConfigCodePagingPolicyMask;
|
sl@0
|
6758 |
}
|
sl@0
|
6759 |
|
sl@0
|
6760 |
|
sl@0
|
6761 |
/** Queue a notifier to detect system idle
|
sl@0
|
6762 |
|
sl@0
|
6763 |
@internalTechnology
|
sl@0
|
6764 |
@prototype
|
sl@0
|
6765 |
*/
|
sl@0
|
6766 |
EXPORT_C void User::NotifyOnIdle(TRequestStatus& aStatus)
|
sl@0
|
6767 |
{
|
sl@0
|
6768 |
aStatus = KRequestPending;
|
sl@0
|
6769 |
Exec::NotifyOnIdle(&aStatus);
|
sl@0
|
6770 |
}
|
sl@0
|
6771 |
|
sl@0
|
6772 |
|
sl@0
|
6773 |
/** Cancel a miscellaneous notification requested by this thread
|
sl@0
|
6774 |
|
sl@0
|
6775 |
Cancels a currently outstanding notification for system idle or object
|
sl@0
|
6776 |
deletion.
|
sl@0
|
6777 |
|
sl@0
|
6778 |
@internalTechnology
|
sl@0
|
6779 |
@prototype
|
sl@0
|
6780 |
*/
|
sl@0
|
6781 |
EXPORT_C void User::CancelMiscNotifier(TRequestStatus& aStatus)
|
sl@0
|
6782 |
{
|
sl@0
|
6783 |
Exec::CancelMiscNotifier(&aStatus);
|
sl@0
|
6784 |
}
|
sl@0
|
6785 |
|
sl@0
|
6786 |
|
sl@0
|
6787 |
/** Queue a notifier to detect destruction of this object
|
sl@0
|
6788 |
|
sl@0
|
6789 |
To cancel the notifier, use User::CancelMiscNotifier().
|
sl@0
|
6790 |
|
sl@0
|
6791 |
@internalTechnology
|
sl@0
|
6792 |
@prototype
|
sl@0
|
6793 |
*/
|
sl@0
|
6794 |
EXPORT_C void RHandleBase::NotifyDestruction(TRequestStatus& aStatus)
|
sl@0
|
6795 |
{
|
sl@0
|
6796 |
aStatus = KRequestPending;
|
sl@0
|
6797 |
Exec::NotifyObjectDestruction(iHandle, &aStatus);
|
sl@0
|
6798 |
}
|
sl@0
|
6799 |
|