os/kernelhwsrv/kernel/eka/euser/us_exec.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kernel/eka/euser/us_exec.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,6799 @@
     1.4 +// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// e32\euser\us_exec.cpp
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#include "us_std.h"
    1.22 +#include "us_data.h"
    1.23 +#include <e32des8_private.h>
    1.24 +#include <e32kpan.h>
    1.25 +#include <unicode.h>
    1.26 +#include <videodriver.h>
    1.27 +#include "CompareImp.h"
    1.28 +#include <e32atomics.h>
    1.29 +
    1.30 +#include "locmapping.h"
    1.31 +
    1.32 +#ifdef __VC32__
    1.33 +  #pragma setlocale("english")
    1.34 +#endif
    1.35 +
    1.36 +_LIT(KLitSpace, " ");
    1.37 +_LIT(KLitOpeningBracket, "(");
    1.38 +_LIT(KLitMinusSign, "-");
    1.39 +_LIT(KLitZeroPad, "0");
    1.40 +
    1.41 +#ifdef SYMBIAN_DISTINCT_LOCALE_MODEL
    1.42 +_LIT(KFindLan, "elocl_lan.");
    1.43 +_LIT(KFindReg, "elocl_reg.");
    1.44 +_LIT(KFindCol, "elocl_col.");
    1.45 +_LIT(KLoc, "elocl.");
    1.46 +#endif
    1.47 +
    1.48 +// Private use area ranges of printable/non-printable characters.
    1.49 +// This is a sorted list of numbers indicating the ranges in which characters
    1.50 +// are printable and non-printable. The elements 0, 2, 4... are the first
    1.51 +// characters of printable ranges and The elements 1, 3, 5... are the first
    1.52 +// characters of non-printable ranges
    1.53 +// We will assume that anything in the End User Sub-area is printable.
    1.54 +static const TInt PUAPrintableRanges[] =
    1.55 +	{
    1.56 +	0xE000, 0xF6D9,		// End user area + unassigned corporate use area
    1.57 +	0xF6DB, 0xF6DC,		// Replacement for character not in font
    1.58 +	0xF6DE, 0xF700,		// various EIKON and Agenda symbols
    1.59 +	0x10000, KMaxTInt	// everything else printable
    1.60 +	};
    1.61 +
    1.62 +static TBool IsPUAPrintable(TInt aChar)
    1.63 +	{
    1.64 +	if (0x110000 <= aChar)
    1.65 +		return 0;	// non-characters not printable
    1.66 +	TInt i = 0;
    1.67 +	while (PUAPrintableRanges[i] <= aChar)
    1.68 +		++i;
    1.69 +	return i & 1;
    1.70 +	}
    1.71 +
    1.72 +
    1.73 +
    1.74 +
    1.75 +EXPORT_C TBool User::JustInTime()
    1.76 +/**
    1.77 +Tests whether just-in-time debugging is on or off.
    1.78 +
    1.79 +The function is used by the Kernel, on the Emulator, to decide whether to do
    1.80 +just-in-time debugging for panics. The function applies to the current process.
    1.81 +
    1.82 +Unless overridden by calling User::SetJustInTime(EFalse), just-in-time debugging 
    1.83 +is on by default.
    1.84 +
    1.85 +@return True, if just-in-time debugging is on. False otherwise.
    1.86 +@see RProcess::JustInTime
    1.87 +*/
    1.88 +	{
    1.89 +
    1.90 +	return RProcess().JustInTime();
    1.91 +	}
    1.92 +
    1.93 +
    1.94 +
    1.95 +
    1.96 +EXPORT_C void User::SetJustInTime(const TBool aBoolean)
    1.97 +/**
    1.98 +Sets just-in-time debugging for this process on or off.
    1.99 +
   1.100 +While the function can be called by code running on both the Emulator and ARM,
   1.101 +it only has an effect on the Emulator. Turning just-in-time debugging off
   1.102 +prevents the debug Emulator closing down when a panic occurs.
   1.103 +
   1.104 +By default, just-in-time debugging is on.
   1.105 +
   1.106 +Note that the emulator handles panics in the nomal manner, i.e. by killing 
   1.107 +the thread.
   1.108 +
   1.109 +@param aBoolean ETrue, if just-in-time debugging is to be set on. EFalse, 
   1.110 +                if just-in-time debugging is to be set off.
   1.111 +                EFalse causes _asm 3 calls to be disabled.
   1.112 +@see RProcess::SetJustInTime
   1.113 +*/
   1.114 +	{
   1.115 +
   1.116 +	RProcess().SetJustInTime(aBoolean);
   1.117 +	}
   1.118 +
   1.119 +
   1.120 +extern const LCharSet* GetLocaleDefaultCharSet();
   1.121 +extern const LCharSet* GetLocalePreferredCharSet();
   1.122 +
   1.123 +// Convert to folded.
   1.124 +EXPORT_C TUint User::Fold(TUint aChar)
   1.125 +/**
   1.126 +@deprecated
   1.127 +
   1.128 +Folds the specified character.
   1.129 +
   1.130 +Folding converts the character to a form which can be used in tolerant
   1.131 +comparisons without control over the operations performed. Tolerant comparisons
   1.132 +are those which ignore character differences like case and accents.
   1.133 +
   1.134 +The result of folding a character depends on the locale and on whether this 
   1.135 +is a UNICODE build or not.
   1.136 +
   1.137 +Note that for a non-UNICODE build, if the binary value of the character aChar
   1.138 +is greater than or equal to 0x100, then the character returned is the same as
   1.139 +the character passed to the function.
   1.140 +
   1.141 +@param aChar The character to be folded.
   1.142 +
   1.143 +@return The folded character.
   1.144 +
   1.145 +@see TChar::Fold()
   1.146 +*/
   1.147 +	{
   1.148 +	// ASCII chars excluding 'i's can be handled by naive folding
   1.149 +	if (aChar < 0x80 && aChar != 'I')
   1.150 +		return (aChar >= 'A' && aChar <= 'Z') ? (aChar | 0x0020) : aChar;
   1.151 +	else
   1.152 +		return TUnicode(aChar).Fold(TChar::EFoldStandard,GetLocaleCharSet()->iCharDataSet);
   1.153 +	}
   1.154 +
   1.155 +
   1.156 +
   1.157 +
   1.158 +// Convert to a folded version, specifying the folding methods.
   1.159 +EXPORT_C TUint User::Fold(TUint aChar,TInt aFlags)
   1.160 +/**
   1.161 +Folds the character according to a specified folding method.
   1.162 +
   1.163 +@param aChar  The character to be folded.
   1.164 +@param aFlags A set of flags defining the folding method. They are:
   1.165 +
   1.166 +              TChar::EFoldCase, convert characters to their lower case form,
   1.167 +              if any;
   1.168 +              
   1.169 +              TChar::EFoldAccents, strip accents;
   1.170 +              
   1.171 +              TChar::EFoldDigits, convert digits representing values 0..9 to
   1.172 +              characters '0'..'9';
   1.173 +              
   1.174 +              TChar::EFoldSpaces, convert all spaces (ordinary, fixed-width,
   1.175 +              ideographic, etc.) to ' ';
   1.176 +              
   1.177 +              TChar::EFoldKana, convert hiragana to katakana;
   1.178 +              
   1.179 +              TChar::EFoldWidth, fold full width and half width variants to
   1.180 +              their standard forms;
   1.181 +              
   1.182 +              TChar::EFoldAll, use all of the above folding methods.
   1.183 +              
   1.184 +@return The folded character.
   1.185 +@see TChar::Fold()
   1.186 +*/
   1.187 +	{
   1.188 +	return TUnicode(aChar).Fold(aFlags,GetLocaleCharSet()->iCharDataSet);
   1.189 +	}
   1.190 +
   1.191 +
   1.192 +
   1.193 +
   1.194 +// Convert to collated.
   1.195 +EXPORT_C TUint User::Collate(TUint aChar)
   1.196 +/**
   1.197 +Converts the character to its collated form.
   1.198 +
   1.199 +Collating is the process of removing differences between characters that are 
   1.200 +deemed unimportant for the purposes of ordering characters. The result of 
   1.201 +the conversion depends on the locale and on whether this is a UNICODE build 
   1.202 +or not.
   1.203 +
   1.204 +Note that for a non UNICODE build, if the binary value of the character aChar
   1.205 +is greater than or equal to 0x100, then the character returned is the same as
   1.206 +the character passed to the function.
   1.207 +
   1.208 +@param aChar The character to be folded.
   1.209 +
   1.210 +@return The converted character.
   1.211 +*/
   1.212 +	{
   1.213 +	return TUnicode(aChar).Fold(TChar::EFoldStandard,GetLocaleCharSet()->iCharDataSet);
   1.214 +	}
   1.215 +
   1.216 +
   1.217 +
   1.218 +
   1.219 +// Convert to lower case.
   1.220 +EXPORT_C TUint User::LowerCase(TUint aChar)
   1.221 +/**
   1.222 +Converts the specified character to lower case.
   1.223 +
   1.224 +The result of the conversion depends on the locale and on whether this is
   1.225 +a UNICODE build or not.
   1.226 +
   1.227 +Note that for a non-UNICODE build, if the binary value of the character
   1.228 +aChar is greater than or equal to 0x100, then the character returned is
   1.229 +the same as the character passed to the function.
   1.230 +
   1.231 +@param aChar The character to be converted to lower case.
   1.232 +
   1.233 +@return The lower case character.
   1.234 +*/
   1.235 +	{
   1.236 +	// ASCII chars excluding 'i's can be handled by naive folding
   1.237 +	if (aChar < 0x80 && aChar != 'I')
   1.238 +		return (aChar >= 'A' && aChar <= 'Z') ? (aChar | 0x0020) : aChar;
   1.239 +	else
   1.240 +		return TUnicode(aChar).GetLowerCase(GetLocaleCharSet()->iCharDataSet);
   1.241 +	}
   1.242 +
   1.243 +
   1.244 +
   1.245 +
   1.246 +// Convert to upper case.
   1.247 +EXPORT_C TUint User::UpperCase(TUint aChar)
   1.248 +/**
   1.249 +Converts a specified character to upper case.
   1.250 +
   1.251 +The result of the conversion depends on the locale and on whether this is
   1.252 +a UNICODE build or not.
   1.253 +
   1.254 +Note that for a non UNICODE build, if the binary value of the character aChar
   1.255 +is greater than or equal to 0x100, then the character returned is the same as
   1.256 +the character passed to the function.
   1.257 +
   1.258 +@param aChar The character to be converted to upper case.
   1.259 +
   1.260 +@return The upper case character.
   1.261 +*/
   1.262 +	{
   1.263 +	// ASCII chars excluding 'i's can be handled by naive folding
   1.264 +	if (aChar < 0x80 && aChar != 'i')
   1.265 +		return (aChar >= 'a' && aChar <= 'z') ? (aChar & ~0x0020) : aChar;
   1.266 +	else
   1.267 +		return TUnicode(aChar).GetUpperCase(GetLocaleCharSet()->iCharDataSet);
   1.268 +	}
   1.269 +
   1.270 +
   1.271 +
   1.272 +
   1.273 +// Return the title case version of a character, which is the case of composite characters like Dz.
   1.274 +EXPORT_C TUint User::TitleCase(TUint aChar)
   1.275 +/**
   1.276 +Converts a specified character to its title case version.
   1.277 +
   1.278 +@param aChar The character to be converted.
   1.279 +
   1.280 +@return The converted character.
   1.281 +*/
   1.282 +	{
   1.283 +	return TUnicode(aChar).GetTitleCase(GetLocaleCharSet()->iCharDataSet);
   1.284 +	}
   1.285 +
   1.286 +
   1.287 +
   1.288 +
   1.289 +EXPORT_C TUint TChar::GetUpperCase() const
   1.290 +/**
   1.291 +Gets the character value after conversion to uppercase or the character's 
   1.292 +own value, if no uppercase form exists.
   1.293 +
   1.294 +The character object itself is not changed.
   1.295 +
   1.296 +@return The character value after conversion to uppercase.
   1.297 +*/
   1.298 +	{
   1.299 +	return User::UpperCase(iChar);
   1.300 +	}
   1.301 +
   1.302 +
   1.303 +
   1.304 +
   1.305 +EXPORT_C TUint TChar::GetLowerCase() const
   1.306 +/**
   1.307 +Gets the character value after conversion to lowercase or the character's 
   1.308 +own value, if no lowercase form exists.
   1.309 +
   1.310 +The character object itself is not changed.
   1.311 +
   1.312 +@return The character value after conversion to lowercase.
   1.313 +*/
   1.314 +	{
   1.315 +	return User::LowerCase(iChar);
   1.316 +	}
   1.317 +
   1.318 +
   1.319 +
   1.320 +
   1.321 +EXPORT_C TUint TChar::GetTitleCase() const
   1.322 +/**
   1.323 +Gets the character value after conversion to titlecase or the character's 
   1.324 +own value, if no titlecase form exists.
   1.325 +
   1.326 +The titlecase form of a character is identical to its uppercase form unless 
   1.327 +a specific titlecase form exists.
   1.328 +
   1.329 +@return The value of the character value after conversion to titlecase form.
   1.330 +*/
   1.331 +	{
   1.332 +	return User::TitleCase(iChar);
   1.333 +	}
   1.334 +
   1.335 +
   1.336 +
   1.337 +
   1.338 +EXPORT_C TBool TChar::IsLower() const
   1.339 +/**
   1.340 +Tests whether the character is lowercase.
   1.341 +
   1.342 +@return True, if the character is lowercase; false, otherwise.
   1.343 +*/
   1.344 +	{
   1.345 +	return GetCategory() == TChar::ELlCategory;
   1.346 +	}
   1.347 +
   1.348 +
   1.349 +
   1.350 +
   1.351 +EXPORT_C TBool TChar::IsUpper() const
   1.352 +/**
   1.353 +Tests whether the character is uppercase.
   1.354 +
   1.355 +@return True, if the character is uppercase; false, otherwise.
   1.356 +*/
   1.357 +	{
   1.358 +	return GetCategory() == TChar::ELuCategory;
   1.359 +	}
   1.360 +
   1.361 +
   1.362 +
   1.363 +// Return TRUE if the character is title case, which is the case of composite characters like Dz.
   1.364 +EXPORT_C TBool TChar::IsTitle() const
   1.365 +/**
   1.366 +Tests whether this character is in titlecase.
   1.367 +
   1.368 +@return True, if this character is in titlecase; false, otherwise.
   1.369 +*/
   1.370 +	{
   1.371 +	return GetCategory() == TChar::ELtCategory;
   1.372 +	}
   1.373 +
   1.374 +
   1.375 +
   1.376 +
   1.377 +EXPORT_C TBool TChar::IsAlpha() const
   1.378 +/**
   1.379 +Tests whether the character is alphabetic.
   1.380 +
   1.381 +For Unicode, the function returns TRUE for all letters, including those from 
   1.382 +syllabaries and ideographic scripts. The function returns FALSE for letter-like 
   1.383 +characters that are in fact diacritics. Specifically, the function returns 
   1.384 +TRUE for categories: ELuCategory, ELtCategory, ELlCategory, and ELoCategory; 
   1.385 +it returns FALSE for all other categories including ELmCategory.
   1.386 +
   1.387 +@return True, if the character is alphabetic; false, otherwise.
   1.388 +
   1.389 +@see TChar::IsAlphaDigit()
   1.390 +@see TChar::TCategory
   1.391 +*/
   1.392 +	{
   1.393 +	return GetCategory() <= TChar::EMaxLetterOrLetterModifierCategory;
   1.394 +	}
   1.395 +
   1.396 +
   1.397 +
   1.398 +
   1.399 +EXPORT_C TBool TChar::IsDigit() const
   1.400 +/**
   1.401 +Tests whether the character is a standard decimal digit.
   1.402 +
   1.403 +For Unicode, this function returns TRUE only
   1.404 +for the digits '0'...'9' (U+0030...U+0039), 
   1.405 +not for other digits in scripts like Arabic, Tamil, etc.
   1.406 +
   1.407 +@return True, if the character is a standard decimal digit; false, otherwise.
   1.408 +
   1.409 +@see TChar::GetCategory()
   1.410 +@see TChar::GetNumericValue
   1.411 +*/
   1.412 +	{
   1.413 +	return iChar >= '0' && iChar <= '9'; // standard decimal digits only
   1.414 +	}
   1.415 +
   1.416 +
   1.417 +
   1.418 +
   1.419 +EXPORT_C TBool TChar::IsAlphaDigit() const
   1.420 +/**
   1.421 +Tests whether the character is alphabetic or a decimal digit.
   1.422 +
   1.423 +It is identical to (IsAlpha()||IsDigit()).
   1.424 +
   1.425 +@return True, if the character is alphabetic or a decimal digit; false, otherwise.
   1.426 +
   1.427 +@see TChar::IsAlpha()
   1.428 +@see TChar::IsDigit()
   1.429 +*/
   1.430 +	{
   1.431 +	TInt cat = (TInt)GetCategory();
   1.432 +	return cat <= TChar::EMaxLetterOrLetterModifierCategory ||
   1.433 +		   (iChar < 256 && cat == TChar::ENdCategory);	// accept any letter, but accept only standard digits
   1.434 +	}
   1.435 +
   1.436 +
   1.437 +
   1.438 +
   1.439 +EXPORT_C TBool TChar::IsHexDigit() const
   1.440 +/** 
   1.441 +Tests whether the character is a hexadecimal digit (0-9, a-f, A-F).
   1.442 +
   1.443 +@return True, if the character is a hexadecimal digit; false, otherwise.
   1.444 +*/
   1.445 +	{
   1.446 +	/*
   1.447 +	The following code will actually run faster than the non-Unicode version, which needs
   1.448 +	to call the Exec function.
   1.449 +	*/
   1.450 +	return iChar <= 'f' && iChar >= '0' &&
   1.451 +		   (iChar <= '9' || iChar >= 'a' || (iChar >= 'A' && iChar <= 'F'));	// only standard hex digits will do
   1.452 +	}
   1.453 +
   1.454 +
   1.455 +
   1.456 +
   1.457 +EXPORT_C TBool TChar::IsSpace() const
   1.458 +/**
   1.459 +Tests whether the character is a white space character.
   1.460 +
   1.461 +White space includes spaces, tabs and separators.
   1.462 +
   1.463 +For Unicode, the function returns TRUE for all characters in the categories: 
   1.464 +EZsCategory, EZlCategory and EZpCategory, and also for the characters 0x0009 
   1.465 +(horizontal tab), 0x000A (linefeed), 0x000B (vertical tab), 0x000C (form feed), 
   1.466 +and 0x000D (carriage return).
   1.467 +
   1.468 +@return True, if the character is white space; false, otherwise.
   1.469 +
   1.470 +@see TChar::TCategory
   1.471 +*/
   1.472 +	{
   1.473 +	/*
   1.474 +	The Unicode characters 0009 .. 000D (tab, linefeed, vertical tab, formfeed, carriage return)
   1.475 +	have the category Cc (control); however, we want to avoid breaking traditional programs
   1.476 +	by getting IsSpace() to return TRUE for them.
   1.477 +	*/
   1.478 +	return (iChar <= 0x000D && iChar >= 0x0009) ||
   1.479 +		   (GetCategory() & 0xF0) == TChar::ESeparatorGroup;
   1.480 +	}
   1.481 +
   1.482 +
   1.483 +
   1.484 +
   1.485 +EXPORT_C TBool TChar::IsPunctuation() const
   1.486 +/**
   1.487 +Tests whether the character is a punctuation character.
   1.488 +
   1.489 +For Unicode, punctuation characters are any character in the categories:
   1.490 +EPcCategory, EPdCategory, EPsCategory, EPeCategory, EPiCategory,
   1.491 +EPfCategory, EPoCategory.
   1.492 +
   1.493 +@return True, if the character is punctuation; false, otherwise.
   1.494 +
   1.495 +@see TChar::TCategory
   1.496 +*/
   1.497 +	{
   1.498 +	return (GetCategory() & 0xF0) == TChar::EPunctuationGroup;
   1.499 +	}
   1.500 +
   1.501 +
   1.502 +
   1.503 +
   1.504 +EXPORT_C TBool TChar::IsGraph() const
   1.505 +/**
   1.506 +Tests whether the character is a graphic character.
   1.507 +
   1.508 +For Unicode, graphic characters include printable characters but not the space 
   1.509 +character. Specifically, graphic characters are any character except those 
   1.510 +in categories: EZsCategory,EZlCategory,EZpCategory, ECcCategory,ECfCategory,
   1.511 +ECsCategory, ECoCategory, and ,ECnCategory.
   1.512 +
   1.513 +Note that for ISO Latin-1, all alphanumeric and punctuation characters are 
   1.514 +graphic.
   1.515 +
   1.516 +@return True, if the character is a graphic character; false, otherwise.
   1.517 +
   1.518 +@see TChar::TCategory
   1.519 +*/
   1.520 +	{
   1.521 +	TUint type = TUnicode(iChar).GetCategory(0);
   1.522 +	return type <= TChar::EMaxGraphicCategory ||
   1.523 +		(type == TChar::ECoCategory && IsPUAPrintable(iChar));
   1.524 +	}
   1.525 +
   1.526 +
   1.527 +
   1.528 +
   1.529 +EXPORT_C TBool TChar::IsPrint() const
   1.530 +/**
   1.531 +Tests whether the character is a printable character.
   1.532 +
   1.533 +For Unicode, printable characters are any character except those in categories: 
   1.534 +ECcCategory, ECfCategory, ECsCategory, ECoCategory and ECnCategory.
   1.535 +
   1.536 +Note that for ISO Latin-1, all alphanumeric and punctuation characters, plus 
   1.537 +space, are printable.
   1.538 +
   1.539 +@return True, if the character is printable; false, otherwise.
   1.540 +
   1.541 +@see TChar::TCategory
   1.542 +*/
   1.543 +	{
   1.544 +	TUint type = TUnicode(iChar).GetCategory(0);
   1.545 +	return type <= TChar::EMaxPrintableCategory ||
   1.546 +		(type == TChar::ECoCategory && IsPUAPrintable(iChar));
   1.547 +	}
   1.548 +
   1.549 +
   1.550 +
   1.551 +
   1.552 +EXPORT_C TBool TChar::IsControl() const
   1.553 +/**
   1.554 +Tests whether the character is a control character.
   1.555 +
   1.556 +For Unicode, the function returns TRUE for all characters in the categories: 
   1.557 +ECcCategory, ECfCategory, ECsCategory, ECoCategory and ECnCategoryCc.
   1.558 +
   1.559 +@return True, if the character is a control character; false, otherwise.
   1.560 +
   1.561 +@see TChar::TCategory
   1.562 +*/
   1.563 +	{
   1.564 +	return GetCategory() == TChar::ECcCategory;
   1.565 +	}
   1.566 +
   1.567 +
   1.568 +
   1.569 +
   1.570 +EXPORT_C TBool TChar::IsAssigned() const
   1.571 +/**
   1.572 +Tests whether this character has an assigned meaning in the Unicode encoding.
   1.573 +
   1.574 +All characters outside the range 0x0000 - 0xFFFF are unassigned and there 
   1.575 +are also many unassigned characters within the Unicode range.
   1.576 +
   1.577 +Locales can change the assigned/unassigned status of characters. This means 
   1.578 +that the precise behaviour of this function is locale-dependent.
   1.579 +
   1.580 +@return True, if this character has an assigned meaning; false, otherwise.
   1.581 +*/
   1.582 +	{
   1.583 +	return GetCategory() <= TChar::EMaxAssignedCategory;
   1.584 +	}
   1.585 +
   1.586 +
   1.587 +
   1.588 +
   1.589 +EXPORT_C void TChar::GetInfo(TCharInfo& aInfo) const
   1.590 +/** 
   1.591 +Gets this character;s standard category information. 
   1.592 +
   1.593 +This includes everything except its CJK width and decomposition, if any.
   1.594 +
   1.595 +@param aInfo On return, contains the character's standard category information.
   1.596 +*/
   1.597 +	{
   1.598 +	TUnicode(iChar).GetInfo(aInfo,GetLocaleCharSet()->iCharDataSet);
   1.599 +	}
   1.600 +
   1.601 +
   1.602 +
   1.603 +
   1.604 +EXPORT_C TChar::TCategory TChar::GetCategory() const
   1.605 +/**
   1.606 +Gets this character's Unicode category.
   1.607 +
   1.608 +@return This character's Unicode category.
   1.609 +*/
   1.610 +	{
   1.611 +	//for unicode non private user area just use the default charset
   1.612 +	if (iChar>=0xE000 && iChar<=0xF8FF)
   1.613 +		return TUnicode(iChar).GetCategory(GetLocaleCharSet()->iCharDataSet);
   1.614 +	else
   1.615 +		return TUnicode(iChar).GetCategory(GetLocaleDefaultCharSet()->iCharDataSet);
   1.616 +	}
   1.617 +
   1.618 +
   1.619 +
   1.620 +
   1.621 +EXPORT_C TChar::TBdCategory TChar::GetBdCategory() const
   1.622 +/**
   1.623 +Gets the bi-directional category of a character.
   1.624 +
   1.625 +For more information on the bi-directional algorithm, see Unicode Technical 
   1.626 +Report No. 9 available at: http://www.unicode.org/unicode/reports/tr9/.
   1.627 +
   1.628 +@return The character's bi-directional category.
   1.629 +*/
   1.630 +	{
   1.631 +	return TUnicode(iChar).GetBdCategory(GetLocaleCharSet()->iCharDataSet);
   1.632 +	}
   1.633 +
   1.634 +
   1.635 +
   1.636 +
   1.637 +EXPORT_C TInt TChar::GetCombiningClass() const
   1.638 +/**
   1.639 +Gets this character's combining class.
   1.640 +
   1.641 +Note that diacritics and other combining characters have non-zero combining 
   1.642 +classes.
   1.643 +
   1.644 +@return The combining class.
   1.645 +*/
   1.646 +	{
   1.647 +	//for unicode non private user area just use the default charset
   1.648 +	if (iChar>=0xE000 && iChar<=0xF8FF)
   1.649 +		return TUnicode(iChar).GetCombiningClass(GetLocaleCharSet()->iCharDataSet);
   1.650 +	else
   1.651 +		return TUnicode(iChar).GetCombiningClass(GetLocaleDefaultCharSet()->iCharDataSet);
   1.652 +	}
   1.653 +
   1.654 +
   1.655 +
   1.656 +
   1.657 +EXPORT_C TBool TChar::IsMirrored() const
   1.658 +/**
   1.659 +Tests whether this character has the mirrored property.
   1.660 +
   1.661 +Mirrored characters, like ( ) [ ] < >, change direction according to the
   1.662 +directionality of the surrounding characters. For example, an opening
   1.663 +parenthesis 'faces right' in Hebrew or Arabic, and to say that 2 < 3 you would
   1.664 +have to say that 3 > 2, where the '>' is, in this example, a less-than sign to
   1.665 +be read right-to-left.
   1.666 +
   1.667 +@return True, if this character has the mirrored property; false, otherwise.
   1.668 +*/
   1.669 +	{
   1.670 +	return TUnicode(iChar).IsMirrored(GetLocaleCharSet()->iCharDataSet);
   1.671 +	}
   1.672 +
   1.673 +
   1.674 +
   1.675 +
   1.676 +EXPORT_C TInt TChar::GetNumericValue() const
   1.677 +/**
   1.678 +Gets the integer numeric value of this character.
   1.679 +
   1.680 +Numeric values need not be in the range 0..9; the Unicode character set
   1.681 +includes various other numeric characters such as the Roman and Tamil numerals
   1.682 +for 500, 1000, etc.
   1.683 +
   1.684 +@return The numeric value: -1 if the character has no integer numeric 
   1.685 +        value,-2 if the character has a fractional numeric value.
   1.686 +*/
   1.687 +	{
   1.688 +	return TUnicode(iChar).GetNumericValue(GetLocaleCharSet()->iCharDataSet);
   1.689 +	}
   1.690 +
   1.691 +
   1.692 +
   1.693 +
   1.694 +EXPORT_C TChar::TCjkWidth TChar::GetCjkWidth() const
   1.695 +/**
   1.696 +Gets the Chinese, Japanese, Korean (CJK) notional width.
   1.697 +
   1.698 +Some display systems used in East Asia display characters on a grid of
   1.699 +fixed-width character cells like the standard MSDOS display mode.
   1.700 +
   1.701 +Some characters, e.g. the Japanese katakana syllabary, take up a single
   1.702 +character cell and some characters, e.g., kanji, Chinese characters used in
   1.703 +Japanese, take up two. These are called half-width and full-width characters.
   1.704 +This property is fixed and cannot be overridden for particular locales.
   1.705 +
   1.706 +For more information on returned widths, see Unicode Technical Report 11 on 
   1.707 +East Asian Width available at: http://www.unicode.org/unicode/reports/tr11/
   1.708 +
   1.709 +@return The notional width of an east Asian character.
   1.710 +*/
   1.711 +	{
   1.712 +	return TUnicode(iChar).GetCjkWidth();
   1.713 +	}
   1.714 +
   1.715 +
   1.716 +
   1.717 +
   1.718 +/**
   1.719 +Composes a string of Unicode characters to produce a single character result.
   1.720 +
   1.721 +For example, 0061 ('a') and 030A (combining ring above) compose to give 00E5 
   1.722 +('a' with ring above).
   1.723 +
   1.724 +A canonical decomposition is a relationship between a string of characters -  
   1.725 +usually a base character and one or more diacritics - and a composed character. 
   1.726 +The Unicode standard requires that compliant software treats composed
   1.727 +characters identically with their canonical decompositions. The mappings used
   1.728 +by these functions are fixed and cannot be overridden for particular locales.
   1.729 +
   1.730 +@param aResult If successful, the composed character value. If unsuccessful, 
   1.731 +               this value contains 0xFFFF.
   1.732 +@param aSource String of source Unicode characters.
   1.733 +
   1.734 +@return True, if the compose operation is successful in combining the entire
   1.735 +		sequence of characters in the descriptor into a single compound
   1.736 +		character; false, otherwise.
   1.737 +*/
   1.738 +
   1.739 +EXPORT_C TBool TChar::Compose(TUint& aResult,const TDesC16& aSource)
   1.740 +	{
   1.741 +	aResult = 0xFFFF;
   1.742 +	if(aSource.Length() > 0)
   1.743 +		{
   1.744 +		TChar combined;
   1.745 +		if(::CombineAsMuchAsPossible(aSource, combined) == aSource.Length())
   1.746 +			{
   1.747 +			aResult = (TUint)combined;
   1.748 +			return ETrue;
   1.749 +			}
   1.750 +		}
   1.751 +	return EFalse;
   1.752 +	}
   1.753 +
   1.754 +
   1.755 +
   1.756 +
   1.757 +/**
   1.758 +Maps this character to its maximal canonical decomposition.
   1.759 +
   1.760 +For example, 01E1 ('a' with dot above and macron) decomposes into 0061 ('a') 
   1.761 +0307 (dot) and 0304 (macron).
   1.762 +
   1.763 +Note that this function is used during collation, as performed by
   1.764 +the Mem::CompareC() function, to convert the compared strings to their maximal
   1.765 +canonical decompositions.
   1.766 +
   1.767 +@param aResult If successful, the descriptor represents the canonical decomposition 
   1.768 +               of this character. If unsuccessful, the descriptor is empty.
   1.769 +               
   1.770 +@return True if decomposition is successful; false, otherwise.
   1.771 +
   1.772 +@see Mem::CompareC()
   1.773 +@see TChar::Compose()
   1.774 +*/
   1.775 +EXPORT_C TBool TChar::Decompose(TPtrC16& aResult) const
   1.776 +	{
   1.777 +	return ::DecomposeChar(iChar, aResult);
   1.778 +	}
   1.779 +
   1.780 +
   1.781 +
   1.782 +
   1.783 +EXPORT_C TInt TFindChunk::Next(TFullName &aResult)
   1.784 +/**
   1.785 +Finds the full name of the next chunk which matches the match pattern.
   1.786 +
   1.787 +@param aResult A reference to a TBuf descriptor with a defined maximum length. 
   1.788 +               If a matching chunk is found, its full name is set into
   1.789 +               this descriptor.
   1.790 +               If no matching chunk is found, the descriptor length is set
   1.791 +               to zero.
   1.792 +               
   1.793 +@return KErrNone, if a matching chunk is found;
   1.794 +        KErrNotFound otherwise.
   1.795 +*/
   1.796 +	{
   1.797 +	return NextObject(aResult,EChunk);
   1.798 +	}
   1.799 +
   1.800 +
   1.801 +
   1.802 +
   1.803 +
   1.804 +EXPORT_C TUint8 * RChunk::Base() const
   1.805 +/**
   1.806 +Gets a pointer to the base of the chunk's reserved region.
   1.807 +
   1.808 +@return A pointer to the base of the chunk's reserved region.
   1.809 +*/
   1.810 +	{
   1.811 +
   1.812 +	return(Exec::ChunkBase(iHandle));
   1.813 +	}
   1.814 +
   1.815 +
   1.816 +
   1.817 +
   1.818 +EXPORT_C TInt RChunk::Size() const
   1.819 +/**
   1.820 +Gets the current size of this chunk's committed region.
   1.821 +
   1.822 +@return The size of the chunk's committed region.
   1.823 +*/
   1.824 +	{
   1.825 +
   1.826 +	return(Exec::ChunkSize(iHandle));
   1.827 +	}
   1.828 +
   1.829 +
   1.830 +
   1.831 +
   1.832 +EXPORT_C TInt RChunk::Bottom() const
   1.833 +/**
   1.834 +Gets the offset of the bottom of the double ended chunk's committed region 
   1.835 +from the base of the chunk's reserved region.
   1.836 +
   1.837 +Note that the lowest valid address in a double ended chunk is the sum of the 
   1.838 +base of the chunk's reserved region plus the value of Bottom().
   1.839 +
   1.840 +@return The offset of the bottom of the chunk's committed region from the 
   1.841 +        base of the chunk's reserved region.
   1.842 +*/
   1.843 +	{
   1.844 +
   1.845 +	return(Exec::ChunkBottom(iHandle));
   1.846 +	}
   1.847 +
   1.848 +
   1.849 +
   1.850 +
   1.851 +EXPORT_C TInt RChunk::Top() const
   1.852 +/**
   1.853 +Gets the offset of the top of the double ended chunk's committed region 
   1.854 +from the base of the chunk's reserved region.
   1.855 +
   1.856 +Note that the highest valid address in a double ended chunk is the the sum 
   1.857 +of the base of the chunk's reserved region plus the value of Top() - 1.
   1.858 +
   1.859 +@return The offset of the top of the chunk's committed region from the base 
   1.860 +        of the chunk's reserved region.
   1.861 +*/
   1.862 +	{
   1.863 +
   1.864 +	return(Exec::ChunkTop(iHandle));
   1.865 +	}
   1.866 +
   1.867 +
   1.868 +EXPORT_C TInt RChunk::MaxSize() const
   1.869 +/**
   1.870 +Gets the maximum size of this chunk.
   1.871 +
   1.872 +This maximum size of this chunk is set when the chunk is created.
   1.873 +
   1.874 +@return The maximum size of this chunk.
   1.875 +*/
   1.876 +	{
   1.877 +
   1.878 +	return(Exec::ChunkMaxSize(iHandle));
   1.879 +	}
   1.880 +
   1.881 +/**
   1.882 +Finds the full name of the next LDD factory object which matches the match pattern.
   1.883 +
   1.884 +@param aResult A reference to a TBuf descriptor with a defined maximum length. 
   1.885 +               If a matching LDD factory object is found, its full name is set into
   1.886 +               this descriptor.
   1.887 +               If no matching LDD factory object is found, the descriptor length is set
   1.888 +               to zero.
   1.889 +               
   1.890 +@return KErrNone, if a matching LDD factory object is found;
   1.891 +        KErrNotFound otherwise.
   1.892 +*/
   1.893 +EXPORT_C TInt TFindLogicalDevice::Next(TFullName &aResult)
   1.894 +	{
   1.895 +	return NextObject(aResult,ELogicalDevice);
   1.896 +	}
   1.897 +
   1.898 +/**
   1.899 +Finds the full name of the next PDD factory object which matches the match pattern.
   1.900 +
   1.901 +@param aResult A reference to a TBuf descriptor with a defined maximum length. 
   1.902 +               If a matching PDD factory object is found, its full name is set into
   1.903 +               this descriptor.
   1.904 +               If no matching PDD factory object is found, the descriptor length is set
   1.905 +               to zero.
   1.906 +               
   1.907 +@return KErrNone, if a matching PDD factory object is found;
   1.908 +        KErrNotFound otherwise.
   1.909 +*/
   1.910 +EXPORT_C TInt TFindPhysicalDevice::Next(TFullName &aResult)
   1.911 +	{
   1.912 +	return NextObject(aResult,EPhysicalDevice);
   1.913 +	}
   1.914 +
   1.915 +/**
   1.916 +Gets the device capabilities.
   1.917 +
   1.918 +@param aDes	A descriptor into which capability's information is to be written.
   1.919 +*/
   1.920 +EXPORT_C void RDevice::GetCaps(TDes8 &aDes) const
   1.921 +	{
   1.922 +
   1.923 +	Exec::LogicalDeviceGetCaps(iHandle,aDes);
   1.924 +	}
   1.925 +
   1.926 +/**
   1.927 +Checks if a device supports a particular version.
   1.928 +
   1.929 +@param aVer	The requested device version.
   1.930 +
   1.931 +@return	ETrue if supported, EFalse if not.
   1.932 +*/
   1.933 +EXPORT_C TBool RDevice::QueryVersionSupported(const TVersion &aVer) const
   1.934 +	{
   1.935 +
   1.936 +	return(Exec::LogicalDeviceQueryVersionSupported(iHandle,aVer));
   1.937 +	}
   1.938 +
   1.939 +/**
   1.940 +Checks if a specified unit number, additional info and a specific PDD is supported.
   1.941 +
   1.942 +@param aUnit			The requested unit number.
   1.943 +@param aPhysicalDevice	The requested PDD name.
   1.944 +@param anInfo			The additional information.
   1.945 +
   1.946 +@return ETrue if supported, EFalse if not. 
   1.947 +*/
   1.948 +EXPORT_C TBool RDevice::IsAvailable(TInt aUnit, const TDesC* aPhysicalDevice, const TDesC8* anInfo) const
   1.949 +	{
   1.950 +	TInt r;
   1.951 +	if(aPhysicalDevice)
   1.952 +		{
   1.953 +		TBuf8<KMaxKernelName> physicalDevice;
   1.954 +		physicalDevice.Copy(*aPhysicalDevice);
   1.955 +		r = Exec::LogicalDeviceIsAvailable(iHandle,aUnit,(TDesC8*)&physicalDevice,anInfo);
   1.956 +		}
   1.957 +	else
   1.958 +		r = Exec::LogicalDeviceIsAvailable(iHandle,aUnit,(TDesC8*)NULL,anInfo);
   1.959 +
   1.960 +	return r;
   1.961 +	}
   1.962 +
   1.963 +
   1.964 +/**
   1.965 +Queues an asynchronous request for the device driver, taking no parameters.
   1.966 + 
   1.967 +The request is handled on the kernel-side by the logical channel's
   1.968 +DLogicalChannelBase::Request().
   1.969 +
   1.970 +Outstanding requests can be cancelled by calling DoCancel().
   1.971 +
   1.972 +@param aReqNo   A number identifying the request to the logical channel. 
   1.973 +@param aStatus  The request status object for this request.     
   1.974 +*/
   1.975 +EXPORT_C void RBusLogicalChannel::DoRequest(TInt aReqNo,TRequestStatus &aStatus)
   1.976 +	{
   1.977 +
   1.978 +	TAny *a[2];
   1.979 +	a[0]=NULL;
   1.980 +	a[1]=NULL;
   1.981 +	aStatus=KRequestPending;
   1.982 +	Exec::ChannelRequest(iHandle,~aReqNo,&aStatus,&a[0]);
   1.983 +	}
   1.984 +
   1.985 +
   1.986 +
   1.987 +
   1.988 +/**
   1.989 +Queues an asynchronous request for the device driver, taking one parameter.
   1.990 + 
   1.991 +The request is handled on the kernel-side by the logical channel's
   1.992 +DLogicalChannelBase::Request().
   1.993 +
   1.994 +Outstanding requests can be cancelled by calling DoCancel().
   1.995 +
   1.996 +@param aReqNo   A number identifying the request to the logical channel. 
   1.997 +@param aStatus  The request status object for this request.
   1.998 +@param a1       A 32-bit value passed to the kernel-side. Its meaning depends
   1.999 +                on the device driver requirements.           
  1.1000 +*/
  1.1001 +EXPORT_C void RBusLogicalChannel::DoRequest(TInt aReqNo,TRequestStatus &aStatus,TAny *a1)
  1.1002 +	{
  1.1003 +
  1.1004 +	TAny *a[2];
  1.1005 +	a[0]=a1;
  1.1006 +	a[1]=NULL;
  1.1007 +	aStatus=KRequestPending;
  1.1008 +	Exec::ChannelRequest(iHandle,~aReqNo,&aStatus,&a[0]);
  1.1009 +	}
  1.1010 +
  1.1011 +
  1.1012 +
  1.1013 +
  1.1014 +/**
  1.1015 +Queues an asynchronous request for the device driver, taking two parameters.
  1.1016 + 
  1.1017 +The request is handled on the kernel-side by the logical channel's
  1.1018 +DLogicalChannelBase::Request().
  1.1019 +
  1.1020 +Outstanding requests can be cancelled by calling DoCancel().
  1.1021 +
  1.1022 +@param aReqNo   A number identifying the request to the logical channel. 
  1.1023 +@param aStatus  The request status object for this request.
  1.1024 +@param a1       A 32-bit value passed to the kernel-side. Its meaning depends
  1.1025 +                on the device driver requirements.           
  1.1026 +@param a2       A 32-bit value passed to the kernel-side. Its meaning depends
  1.1027 +                on the device driver requirements.           
  1.1028 +*/
  1.1029 +EXPORT_C void RBusLogicalChannel::DoRequest(TInt aReqNo,TRequestStatus &aStatus,TAny *a1,TAny *a2)
  1.1030 +	{
  1.1031 +
  1.1032 +	TAny *a[2];
  1.1033 +	a[0]=a1;
  1.1034 +	a[1]=a2;
  1.1035 +	aStatus=KRequestPending;
  1.1036 +	Exec::ChannelRequest(iHandle,~aReqNo,&aStatus,&a[0]);
  1.1037 +	}
  1.1038 +
  1.1039 +
  1.1040 +
  1.1041 +
  1.1042 +/**
  1.1043 +Cancels one or more outstanding asynchronous requests.
  1.1044 +
  1.1045 +All outstanding requests complete with KErrCancel.
  1.1046 +
  1.1047 +@param aRequestMask A set of bits identifying the requests to be cancelled.
  1.1048 +                    Each bit can be used to identify a separate outstanding
  1.1049 +                    request. It is up to the driver to define how the bits map
  1.1050 +                    to those outstanding requests.
  1.1051 +*/
  1.1052 +EXPORT_C void RBusLogicalChannel::DoCancel(TUint aRequestMask)
  1.1053 +	{
  1.1054 +
  1.1055 +	Exec::ChannelRequest(iHandle,KMaxTInt,(TAny*)aRequestMask,0);
  1.1056 +	}
  1.1057 +
  1.1058 +
  1.1059 +
  1.1060 +
  1.1061 +/**
  1.1062 +Makes a synchronous request to the device driver, taking no parameters.
  1.1063 +
  1.1064 +This function does not return until the request has completed, successfully
  1.1065 +or otherwise.
  1.1066 +
  1.1067 +@param aFunction A number identifying the request.
  1.1068 +
  1.1069 +@return KErrNone, if successful; otherwise one of the other system-wide
  1.1070 +        error codes.
  1.1071 +        The value returned depends on the implementation of the device driver.
  1.1072 +*/
  1.1073 +EXPORT_C TInt RBusLogicalChannel::DoControl(TInt aFunction)
  1.1074 +	{
  1.1075 +
  1.1076 +	return Exec::ChannelRequest(iHandle,aFunction,NULL,NULL);
  1.1077 +	}
  1.1078 +
  1.1079 +
  1.1080 +
  1.1081 +
  1.1082 +/**
  1.1083 +Makes a synchronous request to the device driver, taking one parameter.
  1.1084 +
  1.1085 +This function does not return until the request has completed, successfully
  1.1086 +or otherwise.
  1.1087 +
  1.1088 +@param aFunction A number identifying the request.
  1.1089 +@param a1        A 32-bit value passed to the kernel-side. Its meaning depends
  1.1090 +                 on the device driver requirements.           
  1.1091 +
  1.1092 +@return KErrNone, if successful; otherwise one of the other system-wide
  1.1093 +        error codes.
  1.1094 +        The value returned depends on the implementation of the device driver.
  1.1095 +*/
  1.1096 +EXPORT_C TInt RBusLogicalChannel::DoControl(TInt aFunction,TAny *a1)
  1.1097 +	{
  1.1098 +
  1.1099 +	return Exec::ChannelRequest(iHandle,aFunction,a1,NULL);
  1.1100 +	}
  1.1101 +
  1.1102 +
  1.1103 +
  1.1104 +
  1.1105 +/**
  1.1106 +Makes a synchronous request to the device driver, taking two parameters.
  1.1107 +
  1.1108 +This function does not return until the request has completed, successfully
  1.1109 +or otherwise.
  1.1110 +
  1.1111 +@param aFunction A number identifying the request.
  1.1112 +@param a1        A 32-bit value passed to the kernel-side. Its meaning depends
  1.1113 +                 on the device driver requirements.           
  1.1114 +@param a2        A 32-bit value passed to the kernel-side. Its meaning depends
  1.1115 +                 on the device driver requirements.           
  1.1116 +
  1.1117 +@return KErrNone, if successful; otherwise one of the other system-wide
  1.1118 +        error codes.
  1.1119 +        The value returned depends on the implementation of the device driver.
  1.1120 +*/
  1.1121 +EXPORT_C TInt RBusLogicalChannel::DoControl(TInt aFunction,TAny *a1,TAny *a2)
  1.1122 +	{
  1.1123 +
  1.1124 +	return Exec::ChannelRequest(iHandle,aFunction,a1,a2);
  1.1125 +	}
  1.1126 +
  1.1127 +
  1.1128 +
  1.1129 +
  1.1130 +EXPORT_C void User::WaitForAnyRequest()
  1.1131 +/**
  1.1132 +Waits for any asynchronous request to complete.
  1.1133 +
  1.1134 +The current thread waits on its request semaphore.
  1.1135 +
  1.1136 +The function completes, and control returns to the caller when the current 
  1.1137 +thread's request semaphore is signalled by any of the service providers which 
  1.1138 +handle these asynchronous requests.
  1.1139 +
  1.1140 +The request status of all outstanding asynchronous requests must be examined 
  1.1141 +to determine which request is complete.
  1.1142 +
  1.1143 +@see TRequestStatus
  1.1144 +*/
  1.1145 +	{
  1.1146 +
  1.1147 +	Exec::WaitForAnyRequest();
  1.1148 +	}
  1.1149 +
  1.1150 +
  1.1151 +
  1.1152 +
  1.1153 +EXPORT_C void User::WaitForRequest(TRequestStatus &aStatus)
  1.1154 +/**
  1.1155 +Waits for a specific asynchronous request to complete.
  1.1156 +
  1.1157 +The current thread waits on its request semaphore.
  1.1158 +
  1.1159 +The function completes and control returns to the caller when the current 
  1.1160 +thread's request semaphore is signalled by the service provider handling the 
  1.1161 +request associated with aStatus. Before signalling, the service provider sets 
  1.1162 +an appropriate value in aStatus, other than KRequestPending.
  1.1163 +
  1.1164 +Note that if other asynchronous requests complete before the one associated
  1.1165 +with aStatus, the request semaphore is adjusted so that knowledge of their
  1.1166 +completion is not lost. In this a case, a subsequent call to
  1.1167 +User::WaitForAnyRequest() or User::WaitForRequest() will complete and return
  1.1168 +immediately.
  1.1169 +
  1.1170 +@param aStatus A reference to the request status object associated with the 
  1.1171 +               specific asynchronous request.
  1.1172 +               
  1.1173 +@see KRequestPending
  1.1174 +*/
  1.1175 +	{
  1.1176 +
  1.1177 +	TInt i=(-1);
  1.1178 +	do
  1.1179 +		{
  1.1180 +		i++;
  1.1181 +		Exec::WaitForAnyRequest();
  1.1182 +		} while (aStatus==KRequestPending);
  1.1183 +	if (i)
  1.1184 +		Exec::RequestSignal(i);
  1.1185 +	}
  1.1186 +
  1.1187 +
  1.1188 +
  1.1189 +
  1.1190 +EXPORT_C void User::WaitForRequest(TRequestStatus &aStatus1,TRequestStatus &aStatus2)
  1.1191 +/**
  1.1192 +Waits for either of two specific asynchronous requests to complete.
  1.1193 +
  1.1194 +The current thread waits on its request semaphore.
  1.1195 +
  1.1196 +The function completes and control returns to the caller when the current 
  1.1197 +thread's request semaphore is signalled by either the service provider handling 
  1.1198 +the request associated with aStatus1 or the service provider handling the 
  1.1199 +request associated with aStatus2. Before signalling, the completing service 
  1.1200 +provider sets an appropriate value in the status object, other
  1.1201 +than KRequestPending.
  1.1202 +
  1.1203 +Note that if other asynchronous requests complete before the ones associated
  1.1204 +with aStatus1 and aStatus2, the request semaphore is adjusted so that knowledge
  1.1205 +of their completion is not lost. In this a case, a subsequent call to
  1.1206 +User::WaitForAnyRequest() or User::WaitForRequest() will complete and return
  1.1207 +immediately.
  1.1208 +
  1.1209 +@param aStatus1 A reference to the request status object associated with the 
  1.1210 +                first specific asynchronous request.
  1.1211 +@param aStatus2 A reference to the request status object associated with the 
  1.1212 +                second specific asynchronous request.
  1.1213 +
  1.1214 +@see KRequestPending                
  1.1215 +*/
  1.1216 +	{
  1.1217 +
  1.1218 +	TInt i=(-1);
  1.1219 +	do
  1.1220 +		{
  1.1221 +		i++;
  1.1222 +		Exec::WaitForAnyRequest();
  1.1223 +		} while (aStatus1==KRequestPending && aStatus2==KRequestPending);
  1.1224 +	if (i)
  1.1225 +		Exec::RequestSignal(i);
  1.1226 +	}
  1.1227 +
  1.1228 +
  1.1229 +
  1.1230 +
  1.1231 +EXPORT_C void User::WaitForNRequest(TRequestStatus * aStatusArray[], TInt aNum)
  1.1232 +/**
  1.1233 + Waits for any one of  specific asynchronous requests to complete.
  1.1234 +  
  1.1235 +The current thread waits on its request semaphore.
  1.1236 +
  1.1237 +The function completes and control returns to the caller when the current 
  1.1238 +thread's request semaphore is signalled by the service provider handling 
  1.1239 +the request associated with any member of aStatusArray[]. Before signalling, 
  1.1240 +the completing service provider sets an appropriate value in the status object, 
  1.1241 +other than KRequestPending.
  1.1242 + 
  1.1243 +Note that if other asynchronous requests complete before the ones associated
  1.1244 +with aStatusArray the request semaphore is adjusted so that knowledge
  1.1245 +of their completion is not lost. In this a case, a subsequent call to
  1.1246 +User::WaitForAnyRequest() or User::WaitForRequest() will complete and return
  1.1247 +immediately. 
  1.1248 +@param aStatusArray[] 	An array of pointers to the request status objects
  1.1249 +@param TInt aNum    	The size of aStatusArray[]
  1.1250 +*/
  1.1251 +	{
  1.1252 +     	TRequestStatus* aptr;
  1.1253 +     	TBool m = ETrue;
  1.1254 +     	TInt i = (-1);
  1.1255 +     	do
  1.1256 +		{
  1.1257 +	 	i++;
  1.1258 +        	Exec::WaitForAnyRequest();
  1.1259 +        	for(TInt j = 0; j<aNum; j++)
  1.1260 +        		{
  1.1261 +         		aptr =  aStatusArray[j];
  1.1262 +         		if(aptr)
  1.1263 +         			{
  1.1264 +         			if(aptr->Int()!= KRequestPending)
  1.1265 +         				{	
  1.1266 +         				m = EFalse;	
  1.1267 +         				break;
  1.1268 +         				}
  1.1269 +         			}
  1.1270 +        		}
  1.1271 +     		}while(m);
  1.1272 +	if(i)
  1.1273 +		Exec::RequestSignal(i);	
  1.1274 +	}
  1.1275 +
  1.1276 +
  1.1277 +
  1.1278 +
  1.1279 +EXPORT_C TInt TFindLibrary::Next(TFullName &aResult)
  1.1280 +/**
  1.1281 +Finds the next DLL whose full name matches the match pattern.
  1.1282 +
  1.1283 +If a DLL with a matching name is found, the function copies the full name of
  1.1284 +the DLL into the descriptor aResult.
  1.1285 +
  1.1286 +@param aResult A buffer for the fullname of the DLL. This is a template
  1.1287 +               specialisation of TBuf defining a modifiable buffer descriptor
  1.1288 +               taking a maximum length of KMaxFullName.
  1.1289 +               If no matching DLL is found, the descriptor length is
  1.1290 +               set to zero. 
  1.1291 +               
  1.1292 +@return KErrNone, if a matching DLL is found;
  1.1293 +        KErrNotFound, otherwise.
  1.1294 +*/
  1.1295 +	{
  1.1296 +	return NextObject(aResult,ELibrary);
  1.1297 +	}
  1.1298 +
  1.1299 +
  1.1300 +
  1.1301 +
  1.1302 +EXPORT_C TLibraryFunction RLibrary::Lookup(TInt anOrdinal) const
  1.1303 +/**
  1.1304 +Gets a pointer to the function at the specified ordinal within this DLL.
  1.1305 +
  1.1306 +@param anOrdinal The ordinal of the required function in this DLL.
  1.1307 +                 This value must be positive.
  1.1308 +
  1.1309 +@return A pointer to the function at position anOrdinal in this DLL.
  1.1310 +        The value is NULL if there is no function at that ordinal. 
  1.1311 +        
  1.1312 +@panic USER 116 if anOrdinal is negative
  1.1313 +*/
  1.1314 +	{
  1.1315 +	__ASSERT_ALWAYS(anOrdinal>=0,Panic(EBadLookupOrdinal));
  1.1316 +	return (Exec::LibraryLookup(iHandle,anOrdinal));
  1.1317 +	}
  1.1318 +
  1.1319 +
  1.1320 +
  1.1321 +EXPORT_C TFileName RLibrary::FileName() const
  1.1322 +/**
  1.1323 +Gets the name of the DLL's file.
  1.1324 +
  1.1325 +@return The DLL's filname.
  1.1326 +*/
  1.1327 +	{
  1.1328 +
  1.1329 +	TFileName n;
  1.1330 +	TPtr8 n8(((TUint8*)n.Ptr()) + KMaxFileName, KMaxFileName);
  1.1331 +	Exec::LibraryFileName(iHandle,n8);
  1.1332 +	n.Copy(n8);
  1.1333 +	return(n);
  1.1334 +	}
  1.1335 +
  1.1336 +
  1.1337 +
  1.1338 +
  1.1339 +EXPORT_C TUidType RLibrary::Type() const
  1.1340 +/**
  1.1341 +Gets this DLL's UID type.
  1.1342 +
  1.1343 +The UID type is a property of a Symbian OS file; for a DLL, its value is set
  1.1344 +during the building of that DLL.
  1.1345 +
  1.1346 +@return The UID type of this DLL. Note that the first TUid component of
  1.1347 +        the TUidType has the value KDynamicLibraryUid.
  1.1348 +*/
  1.1349 +	{
  1.1350 +
  1.1351 +	TUidType u;
  1.1352 +	Exec::LibraryType(iHandle,u);
  1.1353 +	return(u);
  1.1354 +	}
  1.1355 +
  1.1356 +
  1.1357 +
  1.1358 +
  1.1359 +EXPORT_C TInt RLibrary::GetRamSizes(TInt& aCodeSize, TInt& aConstDataSize)
  1.1360 +/**
  1.1361 +Gets the current size of the code and the const data for this DLL.
  1.1362 +
  1.1363 +This function can be called on a RAM loaded DLL or a ROM based DLL.
  1.1364 +
  1.1365 +@param aCodeSize      The current size of the code for a RAM loaded DLL.
  1.1366 +                      This is zero for a ROM based DLL.
  1.1367 +
  1.1368 +@param aConstDataSize The current size of the const data for a RAM loaded DLL.
  1.1369 +                      This is zero for a ROM based DLL.
  1.1370 +
  1.1371 +@return KErrNone if successful, otherwise one of the system-wide error codes. 
  1.1372 +*/
  1.1373 +	{
  1.1374 +	TModuleMemoryInfo info;
  1.1375 +	TInt r=Exec::LibraryGetMemoryInfo(iHandle,info);
  1.1376 +	if (r==KErrNone)
  1.1377 +		{
  1.1378 +		aCodeSize=info.iCodeSize;
  1.1379 +		aConstDataSize=info.iConstDataSize;
  1.1380 +		}
  1.1381 +	return r;
  1.1382 +	}
  1.1383 +
  1.1384 +
  1.1385 +
  1.1386 +
  1.1387 +/**
  1.1388 +Sets the home time to a specified time value.
  1.1389 +
  1.1390 +@param aTime A reference to a time representation object containing the time 
  1.1391 +             value.
  1.1392 +             
  1.1393 +@return KErrNone if successful or one of the system-wide error codes.
  1.1394 +
  1.1395 +@deprecated Set the time using User::SetUTCTime if the UTC time is known;
  1.1396 +			otherwise, use the timezone server to set the time.
  1.1397 +
  1.1398 +@capability WriteDeviceData
  1.1399 +*/
  1.1400 +EXPORT_C TInt User::SetHomeTime(const TTime &aTime)
  1.1401 +	{
  1.1402 +	return(Exec::SetUTCTimeAndOffset(aTime.Int64(),0,ETimeSetTime|ETimeSetLocalTime,0));
  1.1403 +	}
  1.1404 +
  1.1405 +/**
  1.1406 +Sets the secure home time to a specified time value.
  1.1407 +
  1.1408 +@param aTime A reference to a time representation object containing the 
  1.1409 +			 secure time value.
  1.1410 +             
  1.1411 +@return KErrNone if successful or one of the system-wide error codes.
  1.1412 +
  1.1413 +@capability TCB
  1.1414 +@capability WriteDeviceData
  1.1415 +*/
  1.1416 +EXPORT_C TInt User::SetHomeTimeSecure(const TTime &aTime)
  1.1417 +	{
  1.1418 +	return(Exec::SetUTCTimeAndOffset(aTime.Int64(),0,ETimeSetTime|ETimeSetLocalTime|ETimeSetSecure,0));
  1.1419 +	}
  1.1420 +
  1.1421 +
  1.1422 +
  1.1423 +/**
  1.1424 +Sets the UTC time to a specified time value.
  1.1425 +
  1.1426 +@param aUTCTime A reference to a time representation object containing the time 
  1.1427 +                value.
  1.1428 +             
  1.1429 +@return KErrNone if successful or one of the system-wide error codes.
  1.1430 +
  1.1431 +@capability WriteDeviceData
  1.1432 +*/
  1.1433 +EXPORT_C TInt User::SetUTCTime(const TTime &aUTCTime)
  1.1434 +	{
  1.1435 +	return(Exec::SetUTCTimeAndOffset(aUTCTime.Int64(),0,ETimeSetTime,0));
  1.1436 +	}
  1.1437 +
  1.1438 +/**
  1.1439 +Sets the secure UTC time to a specified time value.
  1.1440 +
  1.1441 +@param aUTCTime A reference to a time representation object containing the secure time 
  1.1442 +                value.
  1.1443 +             
  1.1444 +@return KErrNone if successful or one of the system-wide error codes.
  1.1445 +
  1.1446 +@capability TCB
  1.1447 +@capability WriteDeviceData
  1.1448 +*/
  1.1449 +EXPORT_C TInt User::SetUTCTimeSecure(const TTime &aUTCTime)
  1.1450 +	{
  1.1451 +	return(Exec::SetUTCTimeAndOffset(aUTCTime.Int64(),0,ETimeSetTime|ETimeSetSecure,0));
  1.1452 +	}
  1.1453 +
  1.1454 +/**
  1.1455 +Gets the UTC offset - the difference between UTC and the current local time
  1.1456 +due to any time zones and daylight savings time that may be in effect. A positive
  1.1457 +offset indicates a time ahead of UTC, a negative offset indicates a time behind UTC.
  1.1458 +
  1.1459 +@return The UTC offset, in seconds.
  1.1460 +*/
  1.1461 +EXPORT_C TTimeIntervalSeconds User::UTCOffset()
  1.1462 +	{
  1.1463 +	return(TTimeIntervalSeconds(Exec::UTCOffset()));
  1.1464 +	}
  1.1465 +
  1.1466 +
  1.1467 +/**
  1.1468 +Sets the UTC offset to the given number of seconds. This should include both time
  1.1469 +zone differences and the effect of any applicable daylight savings time.
  1.1470 +A positive offset indicates a time ahead of UTC, a negative offset indicates a time
  1.1471 +behind UTC.
  1.1472 +
  1.1473 +@param aOffset The UTC offset, in seconds.
  1.1474 +
  1.1475 +@capability WriteDeviceData
  1.1476 +*/
  1.1477 +EXPORT_C void User::SetUTCOffset(TTimeIntervalSeconds aOffset)
  1.1478 +	{
  1.1479 +	Exec::SetUTCTimeAndOffset(0,aOffset.Int(),ETimeSetOffset,0);
  1.1480 +	}
  1.1481 +
  1.1482 +
  1.1483 +/**
  1.1484 +Sets the UTC time and UTC offset to the specified values, atomically. This is equivalent
  1.1485 +to calling both SetUTCTime and SetUTCOffset, but without the possibility of an incorrect
  1.1486 +time being observed between the two calls. If the operation is not successful, an error
  1.1487 +code will be returned and both the time and offset will be left unchanged.
  1.1488 +
  1.1489 +@param aUTCTime A reference to a time representation object containing the time 
  1.1490 +                value.
  1.1491 +@param aOffset The UTC offset, in seconds.
  1.1492 +             
  1.1493 +@return KErrNone if successful or one of the system-wide error codes.
  1.1494 +
  1.1495 +@capability WriteDeviceData
  1.1496 +*/
  1.1497 +EXPORT_C TInt User::SetUTCTimeAndOffset(const TTime &aUTCTime, TTimeIntervalSeconds aOffset)
  1.1498 +	{
  1.1499 +	return(Exec::SetUTCTimeAndOffset(aUTCTime.Int64(),aOffset.Int(),ETimeSetTime|ETimeSetOffset,0));
  1.1500 +	}
  1.1501 +
  1.1502 +
  1.1503 +/**
  1.1504 +Gets the current tick count.
  1.1505 +
  1.1506 +The period between ticks is usually 1/64 second, but may be hardware dependent.
  1.1507 +
  1.1508 +@return The machine dependent tick count.
  1.1509 +*/
  1.1510 +EXPORT_C TUint User::TickCount()
  1.1511 +	{
  1.1512 +
  1.1513 +	return(Exec::TickCount());
  1.1514 +	}
  1.1515 +
  1.1516 +
  1.1517 +
  1.1518 +
  1.1519 +EXPORT_C TTimeIntervalSeconds User::InactivityTime()
  1.1520 +/**
  1.1521 +Gets the time since the last user activity.
  1.1522 +
  1.1523 +@return The time interval.
  1.1524 +*/
  1.1525 +	{
  1.1526 +
  1.1527 +	return TTimeIntervalSeconds(Exec::UserInactivityTime());
  1.1528 +	}
  1.1529 +
  1.1530 +
  1.1531 +
  1.1532 +
  1.1533 +/**
  1.1534 +Resets all user inactivity timers.
  1.1535 +*/
  1.1536 +EXPORT_C void User::ResetInactivityTime()
  1.1537 +	{
  1.1538 +	Exec::ResetInactivityTime();
  1.1539 +	}
  1.1540 +
  1.1541 +
  1.1542 +
  1.1543 +
  1.1544 +/**
  1.1545 +Gets the nanokernel tick count.
  1.1546 +
  1.1547 +This is the current value of the machine's millisecond tick counter.
  1.1548 +
  1.1549 +On the emulator the resolution defaults to 5 milliseconds; however
  1.1550 +you can change it to N milliseconds when you launch the emulator
  1.1551 +from the command line by specifying -Dtimerresolution=N as a parameter
  1.1552 +to epoc.exe, for example:
  1.1553 +@code
  1.1554 +epoc.exe -Dtimerresolution=3
  1.1555 +@endcode
  1.1556 +
  1.1557 +On most hardware the resolution is about 1 millisecond.
  1.1558 +
  1.1559 +You can get the nanokernel tick period in microseconds by calling
  1.1560 +into the Hardware Abstraction Layer:
  1.1561 +
  1.1562 +@code
  1.1563 +TInt nanokernel_tick_period;
  1.1564 +HAL::Get(HAL::ENanoTickPeriod, nanokernel_tick_period);
  1.1565 +@endcode
  1.1566 +
  1.1567 +@return The nanokernel tick count.
  1.1568 +*/
  1.1569 +EXPORT_C TUint32 User::NTickCount()
  1.1570 +	{
  1.1571 +
  1.1572 +	return Exec::NTickCount();
  1.1573 +	}
  1.1574 +
  1.1575 +
  1.1576 +
  1.1577 +
  1.1578 +/**
  1.1579 +Gets the fast counter.
  1.1580 +
  1.1581 +This is the current value of the machine's high resolution timer.  If a high
  1.1582 +resolution timer is not available, it uses the millisecond timer instead.
  1.1583 +
  1.1584 +The freqency of this counter can be determined by reading the HAL attribute
  1.1585 +EFastCounterFrequency.
  1.1586 +
  1.1587 +This function is intended for use in profiling and testing; it should not be
  1.1588 +used in production code. User::NTickCount() should be used instead.
  1.1589 +
  1.1590 +This is because the implementation of the FastCounter is platform-specific:
  1.1591 +its frequency can be anywhere from a few KHz to many MHz. It may also not
  1.1592 +be activated when needed, since it is expensive in terms of clock cycles and
  1.1593 +battery life, and use of a platform-specific API may be necessary to enable
  1.1594 +it.
  1.1595 +
  1.1596 +@return The fast counter value.
  1.1597 +
  1.1598 +@see User::NTickCount()
  1.1599 +*/
  1.1600 +EXPORT_C TUint32 User::FastCounter()
  1.1601 +	{
  1.1602 +
  1.1603 +	return Exec::FastCounter();
  1.1604 +	}
  1.1605 +
  1.1606 +
  1.1607 +
  1.1608 +
  1.1609 +EXPORT_C TTimerLockSpec User::LockPeriod()
  1.1610 +/**
  1.1611 +Returns which of the periods the clock is currently in.
  1.1612 +
  1.1613 +@return The fraction of a second at which the timer completes.
  1.1614 +*/
  1.1615 +	{
  1.1616 +
  1.1617 +	return(Exec::LockPeriod());
  1.1618 +	}
  1.1619 +
  1.1620 +
  1.1621 +
  1.1622 +
  1.1623 +EXPORT_C TName RHandleBase::Name() const
  1.1624 +/**
  1.1625 +Gets the name of the handle.
  1.1626 +
  1.1627 +@return The name of the handle.
  1.1628 +*/
  1.1629 +	{
  1.1630 +
  1.1631 +	TName n;
  1.1632 +	TPtr8 n8(((TUint8*)n.Ptr()) + KMaxName, KMaxName);
  1.1633 +	Exec::HandleName(iHandle,n8);
  1.1634 +	n.Copy(n8);
  1.1635 +	return(n);
  1.1636 +	}
  1.1637 +
  1.1638 +
  1.1639 +
  1.1640 +
  1.1641 +EXPORT_C TFullName RHandleBase::FullName() const
  1.1642 +/**
  1.1643 +Gets the full name of the handle.
  1.1644 +
  1.1645 +Note: This method is stack consuming (it takes 512 bytes on stack to execute).
  1.1646 +For an alternative way to obtain the full name of the object, see RHandleBase::FullName(TDes& aName) const.
  1.1647 +
  1.1648 +@see RHandleBase::FullName(TDes& aName) const
  1.1649 +@return The full name of the handle.
  1.1650 +*/
  1.1651 +	{
  1.1652 +
  1.1653 +	TFullName n;
  1.1654 +	TPtr8 n8(((TUint8*)n.Ptr()) + KMaxFullName, KMaxFullName);
  1.1655 +	Exec::HandleFullName(iHandle,n8);
  1.1656 +	n.Copy(n8);
  1.1657 +	return(n);
  1.1658 +	}
  1.1659 +
  1.1660 +
  1.1661 +
  1.1662 +
  1.1663 +EXPORT_C void RHandleBase::FullName(TDes& aName) const
  1.1664 +/**
  1.1665 +Gets the full name of the handle.
  1.1666 +
  1.1667 +@param aName On return, contains the full name of the handle.
  1.1668 +
  1.1669 +@panic KERN-EXEC 35, If full name of the handler is longer that the maximum length of aName descriptor.
  1.1670 +					 To avoid this, the maximum length of aName should be at least KMaxFullName.
  1.1671 +@see KMaxFullName
  1.1672 +*/
  1.1673 +	{
  1.1674 +
  1.1675 +	// Kernel will copy string in n8, whose data lives in the upper half of aName desciptor data
  1.1676 +	TPtr8 n8(((TUint8*)aName.Ptr()) + aName.MaxLength(), aName.MaxLength());
  1.1677 +	Exec::HandleFullName(iHandle,n8);
  1.1678 +	aName.Copy(n8); // Expands 8bit descriptor into 16bit unicode descriptor.
  1.1679 +	}
  1.1680 +
  1.1681 +
  1.1682 +
  1.1683 +
  1.1684 +EXPORT_C void RHandleBase::HandleInfo(THandleInfo* anInfo)
  1.1685 +/**
  1.1686 +Gets information about the handle.
  1.1687 +
  1.1688 +@param anInfo A pointer to a THandleInfo object supplied by the caller;
  1.1689 +              on return, contains the handle information. 
  1.1690 +*/
  1.1691 +	{
  1.1692 +
  1.1693 +	Exec::HandleInfo(iHandle,anInfo);
  1.1694 +	}
  1.1695 +
  1.1696 +EXPORT_C TInt RHandleBase::BTraceId() const
  1.1697 +/**
  1.1698 +Returns a unique object identifier for use with BTrace
  1.1699 +*/
  1.1700 +	{
  1.1701 +	return Exec::GetBTraceId(iHandle);
  1.1702 +	}
  1.1703 +
  1.1704 +
  1.1705 +
  1.1706 +EXPORT_C TUint RHandleBase::Attributes() const
  1.1707 +//
  1.1708 +// Get handle attributes
  1.1709 +//
  1.1710 +	{
  1.1711 +
  1.1712 +	return Exec::HandleAttributes(iHandle);
  1.1713 +	}
  1.1714 +
  1.1715 +
  1.1716 +
  1.1717 +
  1.1718 +EXPORT_C TInt User::AllocLen(const TAny *aCell)
  1.1719 +/**
  1.1720 +Gets the length of the specified allocated heap cell.
  1.1721 +
  1.1722 +The cell is assumed to be in the current thread's heap.
  1.1723 +
  1.1724 +@param aCell A pointer to the allocated cell whose length
  1.1725 +             is to be fetched.
  1.1726 +
  1.1727 +@return The length of the allocated cell.
  1.1728 +*/
  1.1729 +	{
  1.1730 +
  1.1731 +	return(GetHeap()->AllocLen(aCell));
  1.1732 +	}
  1.1733 +
  1.1734 +
  1.1735 +
  1.1736 +
  1.1737 +EXPORT_C TAny* User::Alloc(TInt aSize)
  1.1738 +/**
  1.1739 +Allocates a cell of specified size from the current thread's heap.
  1.1740 +
  1.1741 +If there is insufficient memory available on the heap from which to allocate a cell 
  1.1742 +of the required size, the function returns NULL.
  1.1743 +
  1.1744 +The resulting size of the allocated cell may be rounded up to a value greater 
  1.1745 +than aSize, but is guaranteed to be not less than aSize.
  1.1746 +
  1.1747 +@param aSize The size of the cell to be allocated from the current thread's 
  1.1748 +             heap.
  1.1749 +             
  1.1750 +@return A pointer to the allocated cell. NULL, if there is insufficient memory 
  1.1751 +        available.
  1.1752 +        
  1.1753 +@panic USER 47, if the maximum unsigned value of aSize is greater
  1.1754 +                than or equal to KMaxTInt/2. For example,
  1.1755 +                calling Alloc(-1) raises this panic.
  1.1756 +*/
  1.1757 +	{
  1.1758 +
  1.1759 +	return(GetHeap()->Alloc(aSize));
  1.1760 +	}
  1.1761 +
  1.1762 +
  1.1763 +
  1.1764 +
  1.1765 +EXPORT_C TAny* User::AllocL(TInt aSize)
  1.1766 +/**
  1.1767 +Allocates a cell of specified size from the current thread's heap, and leaves 
  1.1768 +if there is insufficient memory in the heap.
  1.1769 +
  1.1770 +The resulting size of the allocated cell may be rounded up to a value greater 
  1.1771 +than aSize, but is guaranteed to be not less than aSize.
  1.1772 +
  1.1773 +@param aSize The size of the cell to be allocated from the current thread's 
  1.1774 +             heap.
  1.1775 +
  1.1776 +@return A pointer to the allocated cell.
  1.1777 +
  1.1778 +@panic USER 47, if the maximum unsigned value of aSize is greater
  1.1779 +                than or equal to KMaxTInt/2. For example,
  1.1780 +                calling Alloc(-1) raises this panic.
  1.1781 +*/
  1.1782 +	{
  1.1783 +
  1.1784 +	return(GetHeap()->AllocL(aSize));
  1.1785 +	}
  1.1786 +
  1.1787 +
  1.1788 +
  1.1789 +
  1.1790 +EXPORT_C TAny *User::AllocLC(TInt aSize)
  1.1791 +/**
  1.1792 +Allocates a cell of specified size from the current thread's default heap, and,
  1.1793 +if successful, places a pointer to the cell onto the cleanup stack.
  1.1794 +
  1.1795 +The function leaves if there is insufficient memory in the heap.
  1.1796 +
  1.1797 +The resulting size of the allocated cell may be rounded up to a value greater 
  1.1798 +than aSize, but is guaranteed to be not less than aSize.
  1.1799 +
  1.1800 +@param aSize The size of the cell to be allocated from the current thread's
  1.1801 +             default heap.
  1.1802 +             
  1.1803 +@return A pointer to the allocated cell.
  1.1804 +
  1.1805 +@panic USER 47, if the maximum unsigned value of aSize is greater
  1.1806 +                than or equal to KMaxTInt/2. For example,
  1.1807 +                calling Alloc(-1) raises this panic.
  1.1808 +*/
  1.1809 +	{
  1.1810 +
  1.1811 +	return(GetHeap()->AllocLC(aSize));
  1.1812 +	}
  1.1813 +
  1.1814 +
  1.1815 +
  1.1816 +
  1.1817 +EXPORT_C TAny* User::AllocZ(TInt aSize)
  1.1818 +/**
  1.1819 +Allocates a cell of specified size from the current thread's default heap,
  1.1820 +and clears it to binary zeroes.
  1.1821 +
  1.1822 +If there is insufficient memory available on the heap from which to allocate a cell 
  1.1823 +of the required size, the function returns NULL.
  1.1824 +
  1.1825 +The resulting size of the allocated cell may be rounded up to a value greater 
  1.1826 +than aSize, but is guaranteed to be not less than aSize.
  1.1827 +
  1.1828 +@param aSize The size of the cell to be allocated from the current thread's 
  1.1829 +             default heap.
  1.1830 +             
  1.1831 +@return A pointer to the allocated cell. NULL, if there is insufficient memory 
  1.1832 +        available.
  1.1833 +        
  1.1834 +@panic USER 47, if the maximum unsigned value of aSize is greater
  1.1835 +                than or equal to KMaxTInt/2. For example,
  1.1836 +                calling Alloc(-1) raises this panic.
  1.1837 +*/
  1.1838 +	{
  1.1839 +
  1.1840 +	return GetHeap()->AllocZ(aSize);
  1.1841 +	}
  1.1842 +
  1.1843 +
  1.1844 +
  1.1845 +
  1.1846 +EXPORT_C TAny* User::AllocZL(TInt aSize)
  1.1847 +/**
  1.1848 +Allocates a cell of specified size from the current thread's default heap,
  1.1849 +clears it to binary zeroes, and leaves if there is insufficient memory in
  1.1850 +the heap.
  1.1851 +
  1.1852 +The resulting size of the allocated cell may be rounded up to a value greater 
  1.1853 +than aSize, but is guaranteed to be not less than aSize.
  1.1854 +
  1.1855 +@param aSize The size of the cell to be allocated from the current thread's 
  1.1856 +             heap.
  1.1857 +
  1.1858 +@return A pointer to the allocated cell.
  1.1859 +
  1.1860 +@panic USER 47, if the maximum unsigned value of aSize is greater
  1.1861 +                than or equal to KMaxTInt/2. For example,
  1.1862 +                calling Alloc(-1) raises this panic.
  1.1863 +*/
  1.1864 +	{
  1.1865 +
  1.1866 +	return GetHeap()->AllocZL(aSize);
  1.1867 +	}
  1.1868 +
  1.1869 +
  1.1870 +
  1.1871 +
  1.1872 +EXPORT_C TInt User::Available(TInt &aBiggestBlock)
  1.1873 +/**
  1.1874 +Gets the total free space currently available on the current thread's 
  1.1875 +default heap, and the space available in the largest free block.
  1.1876 +
  1.1877 +The space available represents the total space which can be allocated.
  1.1878 +
  1.1879 +Note that compressing the heap may reduce the total free space available and the space 
  1.1880 +available in the largest free block.
  1.1881 +
  1.1882 +@param aBiggestBlock On return, contains the space available in the largest
  1.1883 +                     free block on the current thread's default heap.
  1.1884 +                     
  1.1885 +@return The total free space currently available on the current thread's heap.
  1.1886 +*/
  1.1887 +	{
  1.1888 +
  1.1889 +	return(GetHeap()->Available(aBiggestBlock));
  1.1890 +	}
  1.1891 +
  1.1892 +
  1.1893 +
  1.1894 +
  1.1895 +EXPORT_C void User::Check()
  1.1896 +/**
  1.1897 +Checks the validity of the current thread's default heap.
  1.1898 +
  1.1899 +The function walks through the list of allocated cells and the list of free
  1.1900 +cells checking that the heap is consistent and complete.
  1.1901 +
  1.1902 +@panic USER 47 if any corruption is found, specifically	a bad allocated
  1.1903 +               heap cell size.
  1.1904 +@panic USER 48 if any corruption is found, specifically a bad allocated
  1.1905 +               heap cell address.
  1.1906 +@panic USER 49 if any corruption is found, specifically a bad free heap
  1.1907 +               cell address.
  1.1908 +*/
  1.1909 +	{
  1.1910 +
  1.1911 +	GetHeap()->Check();
  1.1912 +	}
  1.1913 +
  1.1914 +
  1.1915 +
  1.1916 +
  1.1917 +EXPORT_C void User::Free(TAny *aCell)
  1.1918 +/**
  1.1919 +Frees the specified cell and returns it to the current thread's default heap.
  1.1920 +
  1.1921 +@param aCell A pointer to a valid cell to be freed. If NULL this function 
  1.1922 +             call will be ignored.
  1.1923 +             
  1.1924 +@panic USER 42, if aCell is not NULL and does not point to a valid cell.
  1.1925 +*/
  1.1926 +	{
  1.1927 +
  1.1928 +	if (aCell)
  1.1929 +		GetHeap()->Free(aCell);
  1.1930 +	}
  1.1931 +
  1.1932 +
  1.1933 +
  1.1934 +
  1.1935 +EXPORT_C void User::FreeZ(TAny * &aCell)
  1.1936 +/**
  1.1937 +Frees the specified cell, returns it to the current thread's default heap, and resets 
  1.1938 +the pointer to NULL.
  1.1939 +
  1.1940 +@param aCell A reference to a pointer to a valid cell to be freed. If NULL 
  1.1941 +             this function call will be ignored.
  1.1942 +             
  1.1943 +@panic USER 42, if aCell is not NULL and does not point to a valid cell.             
  1.1944 +*/
  1.1945 +	{
  1.1946 +
  1.1947 +	if (aCell)
  1.1948 +		GetHeap()->FreeZ(aCell);
  1.1949 +	}
  1.1950 +
  1.1951 +
  1.1952 +
  1.1953 +
  1.1954 +EXPORT_C TAny* User::ReAlloc(TAny* aCell, TInt aSize, TInt aMode)
  1.1955 +/**
  1.1956 +Increases or decreases the size of an existing cell in the current
  1.1957 +thread's heap.
  1.1958 +
  1.1959 +If the cell is being decreased in size, then it is guaranteed not to move,
  1.1960 +and the function returns the pointer originally passed in aCell. Note that the
  1.1961 +length of the cell will be the same if the difference between the old size
  1.1962 +and the new size is smaller than the minimum cell size.
  1.1963 +
  1.1964 +If the cell is being increased in size, i.e. aSize is bigger than its
  1.1965 +current size, then the function tries to grow the cell in place.
  1.1966 +If successful, then the function returns the pointer originally
  1.1967 +passed in aCell. If unsuccessful, then:
  1.1968 +-# if the cell cannot be moved, i.e. aMode has the ENeverMove bit set, then
  1.1969 +   the function returns NULL.
  1.1970 +-# if the cell can be moved, i.e. aMode does not have the ENeverMove bit set,
  1.1971 +   then the function tries to allocate a new replacement cell, and, if
  1.1972 +   successful, returns a pointer to the new cell; if unsuccessful, it
  1.1973 +   returns NULL.
  1.1974 +
  1.1975 +Note that in debug mode, the function returns NULL if the cell cannot be grown
  1.1976 +in place, regardless of whether the ENeverMove bit is set.
  1.1977 +
  1.1978 +If the reallocated cell is at a different location from the original cell, then
  1.1979 +the content of the original cell is copied to the reallocated cell.
  1.1980 +
  1.1981 +If the supplied pointer, aCell is NULL, then the function attempts to allocate
  1.1982 +a new cell, but only if the cell can be moved, i.e. aMode does not have
  1.1983 +the ENeverMove bit set.
  1.1984 +
  1.1985 +Note the following general points:
  1.1986 +- If reallocation fails, the content of the original cell is preserved.
  1.1987 +- The resulting size of the re-allocated cell may be rounded up to a value
  1.1988 +  greater than aSize, but is guaranteed to be not less than aSize.
  1.1989 + 
  1.1990 +@param aCell A pointer to the cell to be reallocated. This may be NULL.
  1.1991 +
  1.1992 +@param aSize The new size of the cell. This may be bigger or smaller than the
  1.1993 +             size of the original cell. The value can also be zero, but this is
  1.1994 +             interpreted as a request for a cell of minimum size; the net
  1.1995 +             effect is the same as if the caller had explicitly requested
  1.1996 +             a cell of minimum size.
  1.1997 +             Note that the minimum size of a heap cell is device dependent.
  1.1998 +             
  1.1999 +@param aMode Flags controlling the reallocation. The only bit which has any
  1.2000 +             effect on this function is that defined by the enumeration
  1.2001 +             ENeverMove of the enum RAllocator::TReAllocMode.
  1.2002 +             If this is set, then any successful reallocation guarantees not
  1.2003 +             to have changed the start address of the cell.
  1.2004 +             By default, this parameter is zero.
  1.2005 +
  1.2006 +@return A pointer to the reallocated cell. This may be the same as the original
  1.2007 +        pointer supplied through aCell. NULL if there is insufficient memory to
  1.2008 +        reallocate the cell, or to grow it in place.
  1.2009 +
  1.2010 +@panic USER 42, if aCell is not NULL, and does not point to a valid cell.
  1.2011 +@panic USER 47, if the maximum unsigned value of aSize is greater
  1.2012 +                than or equal to KMaxTInt/2. For example,
  1.2013 +                calling ReAlloc(someptr,-1) raises this panic.
  1.2014 +
  1.2015 +@see RAllocator::TReAllocMode
  1.2016 +*/
  1.2017 +	{
  1.2018 +
  1.2019 +	return GetHeap()->ReAlloc(aCell, aSize, aMode);
  1.2020 +	}
  1.2021 +
  1.2022 +
  1.2023 +
  1.2024 +
  1.2025 +EXPORT_C TAny* User::ReAllocL(TAny* aCell, TInt aSize, TInt aMode)
  1.2026 +/**
  1.2027 +Increases or decreases the size of an existing cell, and leaves 
  1.2028 +if there is insufficient memory in the current thread's default heap.
  1.2029 +
  1.2030 +If the cell is being decreased in size, then it is guaranteed not to move,
  1.2031 +and the function returns the pointer originally passed in aCell. Note that the
  1.2032 +length of the cell will be the same if the difference between the old size
  1.2033 +and the new size is smaller than the minimum cell size.
  1.2034 +
  1.2035 +If the cell is being increased in size, i.e. aSize is bigger than its
  1.2036 +current size, then the function tries to grow the cell in place.
  1.2037 +If successful, then the function returns the pointer originally
  1.2038 +passed in aCell. If unsuccessful, then:
  1.2039 +-# if the cell cannot be moved, i.e. aMode has the ENeverMove bit set, then
  1.2040 +   the function leaves.
  1.2041 +-# if the cell can be moved, i.e. aMode does not have the ENeverMove bit set,
  1.2042 +   then the function tries to allocate a new replacement cell, and, if
  1.2043 +   successful, returns a pointer to the new cell; if unsuccessful, it
  1.2044 +   leaves.
  1.2045 +
  1.2046 +Note that in debug mode, the function leaves if the cell cannot be grown
  1.2047 +in place, regardless of whether the ENeverMove bit is set.
  1.2048 +
  1.2049 +If the reallocated cell is at a different location from the original cell, then
  1.2050 +the content of the original cell is copied to the reallocated cell.
  1.2051 +
  1.2052 +If the supplied pointer, aCell is NULL, then the function attempts to allocate
  1.2053 +a new cell, but only if the cell can be moved, i.e. aMode does not have
  1.2054 +the ENeverMove bit set.
  1.2055 +
  1.2056 +Note the following general points:
  1.2057 +- If reallocation fails, the content of the original cell is preserved.
  1.2058 +- The resulting size of the re-allocated cell may be rounded up to a value
  1.2059 +  greater than aSize, but is guaranteed to be not less than aSize.
  1.2060 +
  1.2061 +@param aCell A pointer to the cell to be reallocated. This may be NULL.
  1.2062 +
  1.2063 +@param aSize The new size of the cell. This may be bigger or smaller than the
  1.2064 +             size of the original cell. The value can also be zero, but this is
  1.2065 +             interpreted as a request for a cell of minimum size; the net
  1.2066 +             effect is the same as if the caller had explicitly requested
  1.2067 +             a cell of minimum size.
  1.2068 +             Note that the minimum size of a heap cell is device dependent.
  1.2069 +             
  1.2070 +@param aMode Flags controlling the reallocation. The only bit which has any
  1.2071 +             effect on this function is that defined by the enumeration
  1.2072 +             ENeverMove of the enum RAllocator::TReAllocMode.
  1.2073 +             If this is set, then any successful reallocation guarantees not
  1.2074 +             to have changed the start address of the cell.
  1.2075 +             By default, this parameter is zero.
  1.2076 +
  1.2077 +@return A pointer to the reallocated cell. This may be the same as the original
  1.2078 +        pointer supplied through aCell.
  1.2079 +
  1.2080 +@panic USER 42, if aCell is not NULL, and does not point to a valid cell.
  1.2081 +@panic USER 47, if the maximum unsigned value of aSize is greater
  1.2082 +                than or equal to KMaxTInt/2. For example,
  1.2083 +                calling ReAlloc(someptr,-1) raises this panic.
  1.2084 +
  1.2085 +@see RAllocator::TReAllocMode
  1.2086 +*/
  1.2087 +	{
  1.2088 +
  1.2089 +	return GetHeap()->ReAllocL(aCell, aSize, aMode);
  1.2090 +	}
  1.2091 +
  1.2092 +
  1.2093 +
  1.2094 +
  1.2095 +EXPORT_C RAllocator& User::Allocator()
  1.2096 +/**
  1.2097 +Gets the current thread's default current heap.
  1.2098 +
  1.2099 +@return The current heap.
  1.2100 +*/
  1.2101 +	{
  1.2102 +
  1.2103 +	return *GetHeap();
  1.2104 +	}		
  1.2105 +
  1.2106 +
  1.2107 +
  1.2108 +
  1.2109 +EXPORT_C TInt User::AllocSize(TInt &aTotalAllocSize)
  1.2110 +/**
  1.2111 +Gets the total number of cells allocated on the current thread's default heap, 
  1.2112 +and the total space allocated to them.
  1.2113 +
  1.2114 +@param aTotalAllocSize On return, contains the total space allocated to
  1.2115 +                       the cells.
  1.2116 +                       
  1.2117 +@return The number of cells currently allocated on the current thread's heap.
  1.2118 +*/
  1.2119 +	{
  1.2120 +
  1.2121 +	return(GetHeap()->AllocSize(aTotalAllocSize));
  1.2122 +	}
  1.2123 +
  1.2124 +
  1.2125 +
  1.2126 +
  1.2127 +EXPORT_C TInt User::CountAllocCells()
  1.2128 +/**
  1.2129 +Gets the total number of cells allocated on the current thread's default heap.
  1.2130 +
  1.2131 +
  1.2132 +@return The number of cells allocated on the current thread's default user heap.
  1.2133 +*/
  1.2134 +	{
  1.2135 +	return(GetHeap()->Count());
  1.2136 +	}  
  1.2137 +
  1.2138 +
  1.2139 +
  1.2140 +
  1.2141 +EXPORT_C TInt User::CountAllocCells(TInt &aFreeCount)
  1.2142 +/**
  1.2143 +Gets the the total number of cells allocated, and the number of free cells, 
  1.2144 +on the current thread's default heap.
  1.2145 +
  1.2146 +@param aFreeCount On return, contains the number of free cells 
  1.2147 +                  on the current thread's default heap.
  1.2148 +
  1.2149 +@return The number of cells allocated on the current thread's default heap.
  1.2150 +*/
  1.2151 +	{
  1.2152 +
  1.2153 +	return(GetHeap()->Count(aFreeCount));
  1.2154 +	}
  1.2155 +
  1.2156 +
  1.2157 +
  1.2158 +
  1.2159 +EXPORT_C RAllocator* User::SwitchAllocator(RAllocator* aA)
  1.2160 +/**
  1.2161 +Changes the current thread's heap.
  1.2162 +	
  1.2163 +@param aA A pointer to the new heap handle.
  1.2164 +
  1.2165 +@return A pointer to the old heap handle.
  1.2166 +*/
  1.2167 +	{
  1.2168 +	
  1.2169 +#ifdef __USERSIDE_THREAD_DATA__
  1.2170 +	// Just cache the pointer user-side.  We still need to let the kernel know what's going on so
  1.2171 +	// the heap can be cleaned up correctly later.
  1.2172 +	LocalThreadData()->iHeap=aA;
  1.2173 +#endif
  1.2174 +	return Exec::HeapSwitch(aA);
  1.2175 +	}
  1.2176 +
  1.2177 +// The suffix table
  1.2178 +const TText16* const __DefaultDateSuffixTable[KMaxSuffixes] =
  1.2179 +	{
  1.2180 +	_S16("st"),_S16("nd"),_S16("rd"),_S16("th"),_S16("th"),
  1.2181 +	_S16("th"),_S16("th"),_S16("th"),_S16("th"),_S16("th"),
  1.2182 +	_S16("th"),_S16("th"),_S16("th"),_S16("th"),_S16("th"),
  1.2183 +	_S16("th"),_S16("th"),_S16("th"),_S16("th"),_S16("th"),
  1.2184 +	_S16("st"),_S16("nd"),_S16("rd"),_S16("th"),_S16("th"),
  1.2185 +	_S16("th"),_S16("th"),_S16("th"),_S16("th"),_S16("th"),
  1.2186 +	_S16("st")
  1.2187 +	};
  1.2188 +
  1.2189 +// The day names
  1.2190 +const TText16* const __DefaultDayTable[KMaxDays] =
  1.2191 +	{
  1.2192 +	_S16("Monday"),
  1.2193 +	_S16("Tuesday"),
  1.2194 +	_S16("Wednesday"),
  1.2195 +	_S16("Thursday"),
  1.2196 +	_S16("Friday"),
  1.2197 +	_S16("Saturday"),
  1.2198 +	_S16("Sunday")
  1.2199 +	};
  1.2200 +
  1.2201 +// The abbreviated day names
  1.2202 +const TText16* const __DefaultDayAbbTable[KMaxDays] =
  1.2203 +	{
  1.2204 +	_S16("Mon"),
  1.2205 +	_S16("Tue"),
  1.2206 +	_S16("Wed"),
  1.2207 +	_S16("Thu"),
  1.2208 +	_S16("Fri"),
  1.2209 +	_S16("Sat"),
  1.2210 +	_S16("Sun")
  1.2211 +	};
  1.2212 +
  1.2213 +// The month names
  1.2214 +const TText16* const __DefaultMonthTable[KMaxMonths] =
  1.2215 +	{
  1.2216 +	_S16("January"),
  1.2217 +	_S16("February"),
  1.2218 +	_S16("March"),
  1.2219 +	_S16("April"),
  1.2220 +	_S16("May"),
  1.2221 +	_S16("June"),
  1.2222 +	_S16("July"),
  1.2223 +	_S16("August"),
  1.2224 +	_S16("September"),
  1.2225 +	_S16("October"),
  1.2226 +	_S16("November"),
  1.2227 +	_S16("December")
  1.2228 +	};
  1.2229 +
  1.2230 +// The abbreviated month names
  1.2231 +const TText16* const __DefaultMonthAbbTable[KMaxMonths] =
  1.2232 +	{
  1.2233 +	_S16("Jan"),
  1.2234 +	_S16("Feb"),
  1.2235 +	_S16("Mar"),
  1.2236 +	_S16("Apr"),
  1.2237 +	_S16("May"),
  1.2238 +	_S16("Jun"),
  1.2239 +	_S16("Jul"),
  1.2240 +	_S16("Aug"),
  1.2241 +	_S16("Sep"),
  1.2242 +	_S16("Oct"),
  1.2243 +	_S16("Nov"),
  1.2244 +	_S16("Dec")
  1.2245 +	};
  1.2246 +
  1.2247 +// The am/pm strings
  1.2248 +const TText16* const __DefaultAmPmTable[KMaxAmPms] =
  1.2249 +	{
  1.2250 +	_S16("am"),
  1.2251 +	_S16("pm")
  1.2252 +	};
  1.2253 +
  1.2254 +const TText16* const __DefaultLMsgTable[ELocaleMessages_LastMsg] =
  1.2255 +	{
  1.2256 +// Fileserver
  1.2257 +	_S16("Retry"),								// Button 1
  1.2258 +	_S16("Stop"),									// Button 2
  1.2259 +	_S16("Put the disk back"),					// Put the card back - line1
  1.2260 +	_S16("or data will be lost"),					// Put the card back - line2
  1.2261 +	_S16("Batteries too low"),					// Low power - line1
  1.2262 +	_S16("Cannot complete write to disk"),		// Low power - line2
  1.2263 +	_S16("Disk error - cannot complete write"),	// Disk error - line1
  1.2264 +	_S16("Retry or data will be lost"),			// Disk error - line2
  1.2265 +// SoundDriver
  1.2266 +	_S16("Chimes"),								// Chimes
  1.2267 +	_S16("Rings"),								// Rings
  1.2268 +	_S16("Signal"),								// Signal
  1.2269 +// MediaDriver diskname (max 16 chars)
  1.2270 +	_S16("Internal"),								// Internal
  1.2271 +	_S16("External(01)"),							// External(01)
  1.2272 +	_S16("External(02)"),							// External(02)
  1.2273 +	_S16("External(03)"),							// External(03)
  1.2274 +	_S16("External(04)"),							// External(04)
  1.2275 +	_S16("External(05)"),							// External(05)
  1.2276 +	_S16("External(06)"),							// External(06)
  1.2277 +	_S16("External(07)"),							// External(07)
  1.2278 +	_S16("External(08)"),							// External(08)
  1.2279 +// MediaDriver socketname (max 16 chars)
  1.2280 +	_S16("Socket(01)"),							// Socket(01)
  1.2281 +	_S16("Socket(02)"),							// Socket(02)
  1.2282 +	_S16("Socket(03)"),							// Socket(03)
  1.2283 +	_S16("Socket(04)")							// Socket(04)
  1.2284 +	};
  1.2285 +
  1.2286 +LOCAL_C void LocaleLanguageGet(SLocaleLanguage& locale)
  1.2287 +	{
  1.2288 +	TPckg<SLocaleLanguage> localeLanguageBuf(locale);
  1.2289 +	TInt r = RProperty::Get(KUidSystemCategory, KLocaleLanguageKey, localeLanguageBuf);
  1.2290 +	__ASSERT_DEBUG(r == KErrNone || r == KErrNotFound, Panic(EBadLocaleParameter));
  1.2291 +	if(r == KErrNotFound)
  1.2292 +		{
  1.2293 +		locale.iLanguage			= ELangEnglish;
  1.2294 +		locale.iDateSuffixTable		= (const TText16*)__DefaultDateSuffixTable;
  1.2295 +		locale.iDayTable			= (const TText16*)__DefaultDayTable;
  1.2296 +		locale.iDayAbbTable			= (const TText16*)__DefaultDayAbbTable;
  1.2297 +		locale.iMonthTable			= (const TText16*)__DefaultMonthTable;
  1.2298 +		locale.iMonthAbbTable		= (const TText16*)__DefaultMonthAbbTable;
  1.2299 +		locale.iAmPmTable			= (const TText16*)__DefaultAmPmTable;
  1.2300 +		locale.iMsgTable			= (const TText16* const*)__DefaultLMsgTable;
  1.2301 +		}
  1.2302 +	}
  1.2303 +
  1.2304 +LOCAL_C void LocaleSettingsGet(SLocaleLocaleSettings& locale)
  1.2305 +	{
  1.2306 +	TPckg<SLocaleLocaleSettings> localeSettingsBuf(locale);
  1.2307 +	TInt r = RProperty::Get(KUidSystemCategory, KLocaleDataExtraKey, localeSettingsBuf);
  1.2308 +	__ASSERT_DEBUG(r == KErrNone || r == KErrNotFound, Panic(EBadLocaleParameter));
  1.2309 +	if(r == KErrNotFound)
  1.2310 +		{
  1.2311 +		Mem::Copy(&locale.iCurrencySymbol[0], _S16("\x00a3"), sizeof(TText16) << 2);
  1.2312 +		locale.iLocaleExtraSettingsDllPtr = NULL;
  1.2313 +		}
  1.2314 +	}
  1.2315 +
  1.2316 +LOCAL_C void LocaleTimeDateFormatGet(SLocaleTimeDateFormat& locale)
  1.2317 +	{
  1.2318 +	TPckg<SLocaleTimeDateFormat> localeTimeDateFormatBuf(locale);
  1.2319 +	TInt r = RProperty::Get(KUidSystemCategory, KLocaleTimeDateFormatKey, localeTimeDateFormatBuf);
  1.2320 +	__ASSERT_DEBUG(r == KErrNone || r == KErrNotFound, Panic(EBadLocaleParameter));
  1.2321 +	if(r == KErrNotFound)
  1.2322 +		{
  1.2323 +		Mem::Copy(&locale.iShortDateFormatSpec[0], _S16("%F%*D/%*M/%Y"), sizeof(TText16) * 13);
  1.2324 +		Mem::Copy(&locale.iLongDateFormatSpec[0], _S16("%F%*D%X %N %Y"), sizeof(TText16) * 14);
  1.2325 +		Mem::Copy(&locale.iTimeFormatSpec[0], _S16("%F%*I:%T:%S %*A"), sizeof(TText16) * 16);
  1.2326 +		locale.iLocaleTimeDateFormatDllPtr = NULL;
  1.2327 +		}
  1.2328 +	}
  1.2329 +
  1.2330 +EXPORT_C void TDayName::Set(TDay aDay)
  1.2331 +/**
  1.2332 +Re-retrieves the current locale's text for the specified day of the week.
  1.2333 +
  1.2334 +@param aDay Identifies the day of the week.
  1.2335 +
  1.2336 +@panic USER 184, if the specified day is outside the permitted range.
  1.2337 +*/
  1.2338 +	{
  1.2339 +	
  1.2340 +	__ASSERT_ALWAYS(aDay>=EMonday && aDay<=ESunday,Panic(EBadLocaleParameter));
  1.2341 +	SLocaleLanguage localeLanguage;
  1.2342 +	LocaleLanguageGet(localeLanguage);
  1.2343 +	Copy((reinterpret_cast<const TText* const*>(localeLanguage.iDayTable))[aDay]);
  1.2344 +	}
  1.2345 +
  1.2346 +
  1.2347 +
  1.2348 +
  1.2349 +EXPORT_C void TDayNameAbb::Set(TDay aDay)
  1.2350 +/**
  1.2351 +Re-retrieves the current locale's abbreviated text for the specified day of 
  1.2352 +the week.
  1.2353 +
  1.2354 +@param aDay Identifies the day of the week.
  1.2355 +
  1.2356 +@panic USER 184, if the specified day is outside the permitted range.
  1.2357 +*/
  1.2358 +	{
  1.2359 +
  1.2360 +	__ASSERT_ALWAYS(aDay>=EMonday && aDay<=ESunday,Panic(EBadLocaleParameter));
  1.2361 +	SLocaleLanguage localeLanguage;
  1.2362 +	LocaleLanguageGet(localeLanguage);
  1.2363 +	Copy((reinterpret_cast<const TText* const*>(localeLanguage.iDayAbbTable))[aDay]);
  1.2364 +	}
  1.2365 +
  1.2366 +
  1.2367 +
  1.2368 +
  1.2369 +EXPORT_C void TMonthName::Set(TMonth aMonth)
  1.2370 +/**
  1.2371 +Re-retrieves the current locale's text for the specified month.
  1.2372 +
  1.2373 +@param aMonth Identifies the month.
  1.2374 +
  1.2375 +@panic USER 184, if the specified month is outside the permitted range.
  1.2376 +*/
  1.2377 +	{
  1.2378 +
  1.2379 +	__ASSERT_ALWAYS(aMonth>=EJanuary && aMonth<=EDecember,Panic(EBadLocaleParameter));
  1.2380 +	SLocaleLanguage localeLanguage;
  1.2381 +	LocaleLanguageGet(localeLanguage);
  1.2382 +	Copy((reinterpret_cast<const TText* const*>(localeLanguage.iMonthTable))[aMonth]);
  1.2383 +	}
  1.2384 +
  1.2385 +
  1.2386 +
  1.2387 +
  1.2388 +EXPORT_C void TMonthNameAbb::Set(TMonth aMonth)
  1.2389 +/**
  1.2390 +Re-retrieves the current locale's abbreviated text for the specified month.
  1.2391 +
  1.2392 +@param aMonth Identifies the month.
  1.2393 +
  1.2394 +@panic USER 184, if the specified month is outside the permitted range.
  1.2395 +*/
  1.2396 +	{
  1.2397 +
  1.2398 +	__ASSERT_ALWAYS(aMonth>=EJanuary && aMonth<=EDecember,Panic(EBadLocaleParameter));
  1.2399 +	SLocaleLanguage localeLanguage;
  1.2400 +	LocaleLanguageGet(localeLanguage);
  1.2401 +	Copy((reinterpret_cast<const TText* const*>(localeLanguage.iMonthAbbTable))[aMonth]);
  1.2402 +	}
  1.2403 +
  1.2404 +
  1.2405 +
  1.2406 +
  1.2407 +EXPORT_C void TDateSuffix::Set(TInt aSuffix)
  1.2408 +/**
  1.2409 +Re-retrieves the current locale's date suffix text for the specified day of 
  1.2410 +the month.
  1.2411 +
  1.2412 +@param aSuffix A value identifying the day of the month. The value can 
  1.2413 +               range from 0 to 30 so that the first day of the month is
  1.2414 +               identified by 0, the second day by 1 etc.
  1.2415 +                   
  1.2416 +@panic USER 69, if aDateSuffix is outside the range 0 to 30.
  1.2417 +*/
  1.2418 +	{
  1.2419 +
  1.2420 +	__ASSERT_ALWAYS(aSuffix>=0 && aSuffix<KMaxSuffixes,Panic(ETLoclSuffixOutOfRange));
  1.2421 +	SLocaleLanguage localeLanguage;
  1.2422 +	LocaleLanguageGet(localeLanguage);
  1.2423 +	Copy((reinterpret_cast<const TText* const*>(localeLanguage.iDateSuffixTable))[aSuffix]);
  1.2424 +	}
  1.2425 +
  1.2426 +
  1.2427 +
  1.2428 +
  1.2429 +EXPORT_C void TAmPmName::Set(TAmPm aSelector)
  1.2430 +/**
  1.2431 +Re-retrieves the current locale's text for identifying time before or after 
  1.2432 +noon as identified by the specified selector.
  1.2433 +
  1.2434 +@param aSelector The am/pm selector.
  1.2435 +
  1.2436 +@panic USER 69, if aDateSuffix is outside the range 0 to 30.
  1.2437 +*/
  1.2438 +	{
  1.2439 +
  1.2440 +	__ASSERT_ALWAYS(aSelector==EAm || aSelector==EPm,Panic(ETLoclSuffixOutOfRange));
  1.2441 +	SLocaleLanguage localeLanguage;
  1.2442 +	LocaleLanguageGet(localeLanguage);
  1.2443 +	Copy((reinterpret_cast<const TText* const*>(localeLanguage.iAmPmTable))[aSelector]);
  1.2444 +	}
  1.2445 +
  1.2446 +
  1.2447 +
  1.2448 +
  1.2449 +EXPORT_C void TCurrencySymbol::Set()
  1.2450 +/**
  1.2451 +Re-retrieves the current locale's currency symbol(s).
  1.2452 +*/
  1.2453 +	{
  1.2454 +	SLocaleLocaleSettings locale;
  1.2455 +	LocaleSettingsGet(locale);
  1.2456 +	Copy(&locale.iCurrencySymbol[0]);
  1.2457 +	}
  1.2458 +
  1.2459 +
  1.2460 +
  1.2461 +
  1.2462 +EXPORT_C void TShortDateFormatSpec::Set()
  1.2463 +/**
  1.2464 +Sets the contents of the short date format specification from the system-wide 
  1.2465 +settings.
  1.2466 +*/
  1.2467 +	{
  1.2468 +	SLocaleTimeDateFormat locale;
  1.2469 +	LocaleTimeDateFormatGet(locale);
  1.2470 +	Copy(&locale.iShortDateFormatSpec[0]);
  1.2471 +	}
  1.2472 +
  1.2473 +
  1.2474 +
  1.2475 +
  1.2476 +EXPORT_C void TLongDateFormatSpec::Set()
  1.2477 +/**
  1.2478 +Sets the contents of the long date format specification from the system-wide 
  1.2479 +settings.
  1.2480 +*/
  1.2481 +	{
  1.2482 +	SLocaleTimeDateFormat locale;
  1.2483 +	LocaleTimeDateFormatGet(locale);
  1.2484 +	Copy(&locale.iLongDateFormatSpec[0]);
  1.2485 +	}
  1.2486 +
  1.2487 +
  1.2488 +
  1.2489 +
  1.2490 +EXPORT_C void TTimeFormatSpec::Set()
  1.2491 +/**
  1.2492 +Sets the contents of the time string format specification from the system-wide
  1.2493 +settings.
  1.2494 +*/
  1.2495 +	{
  1.2496 +	SLocaleTimeDateFormat locale;
  1.2497 +	LocaleTimeDateFormatGet(locale);
  1.2498 +	Copy(&locale.iTimeFormatSpec[0]);
  1.2499 +	}
  1.2500 +
  1.2501 +
  1.2502 +
  1.2503 +
  1.2504 +EXPORT_C TInt User::SetCurrencySymbol(const TDesC& aSymbol)
  1.2505 +/**
  1.2506 +Sets the system wide currency symbol.
  1.2507 +
  1.2508 +On successful return from this function, a call to the Set() member function 
  1.2509 +of a TCurrencySymbol object fetches the new currency symbol.
  1.2510 +
  1.2511 +@capability WriteDeviceData
  1.2512 +
  1.2513 +@param aSymbol A reference to the descriptor containing the currency symbol 
  1.2514 +               to be set.
  1.2515 +               
  1.2516 +@return KErrNone if successful, otherwise one of the other system wide error codes.
  1.2517 +
  1.2518 +@panic USER 119, if the length of aSymbol is greater than KMaxCurrencySymbol. 
  1.2519 +
  1.2520 +@see TCurrencySymbol
  1.2521 +@see TCurrencySymbol::Set()
  1.2522 +@see KMaxCurrencySymbol
  1.2523 +*/
  1.2524 +	{
  1.2525 +
  1.2526 +	TExtendedLocale locale;
  1.2527 +	return locale.SetCurrencySymbol(aSymbol);
  1.2528 +	}
  1.2529 +
  1.2530 +
  1.2531 +
  1.2532 +
  1.2533 +EXPORT_C TLanguage User::Language()
  1.2534 +/**
  1.2535 +Gets the language of the current locale.
  1.2536 +
  1.2537 +@return One of the TLanguage enumerators identifying the language of the
  1.2538 +        current locale.
  1.2539 +*/
  1.2540 +	{
  1.2541 +
  1.2542 +	SLocaleLanguage localeLanguage;
  1.2543 +	LocaleLanguageGet(localeLanguage);
  1.2544 +	return localeLanguage.iLanguage;
  1.2545 +	}
  1.2546 +
  1.2547 +EXPORT_C TRegionCode User::RegionCode()
  1.2548 +	{
  1.2549 +#ifdef SYMBIAN_DISTINCT_LOCALE_MODEL
  1.2550 +	TLocale locale;
  1.2551 +	locale.Refresh();	
  1.2552 +	return static_cast<TRegionCode>(locale.RegionCode());
  1.2553 +#else
  1.2554 +	return static_cast<TRegionCode>(0);
  1.2555 +#endif
  1.2556 +	}
  1.2557 +
  1.2558 +
  1.2559 +EXPORT_C TLocale::TLocale()
  1.2560 +/**
  1.2561 +Default constructor.
  1.2562 +
  1.2563 +It constructs the object with the system's locale settings.
  1.2564 +
  1.2565 +A single copy of the locale information is maintained by the system. This 
  1.2566 +copy may be refreshed under application control with TLocale::Refresh(), and 
  1.2567 +the settings may be saved to the system with TLocale::Set(). However, the 
  1.2568 +settings are never updated by the system apart from under application control. 
  1.2569 +This enables applications to guarantee that consistent locale information 
  1.2570 +is used.
  1.2571 +
  1.2572 +@see TLocale::Refresh()
  1.2573 +@see TLocale::Set()
  1.2574 +*/
  1.2575 +	{
  1.2576 +
  1.2577 +	Refresh();
  1.2578 +	}
  1.2579 +
  1.2580 +
  1.2581 +const TUint8 __DefaultDateSeparator[KMaxDateSeparators] = { 0, '/', '/', 0 };
  1.2582 +const TUint8 __DefaultTimeSeparator[KMaxTimeSeparators] = { 0, ':', ':', 0 };
  1.2583 +
  1.2584 +void TLocale::SetDefaults()
  1.2585 +	{
  1.2586 +	iCountryCode = 44;
  1.2587 +	iUniversalTimeOffset = 0;
  1.2588 +	iDateFormat = EDateEuropean;
  1.2589 +	iTimeFormat = ETime12;
  1.2590 +	iCurrencySymbolPosition = ELocaleBefore;
  1.2591 +	iCurrencySpaceBetween = EFalse;
  1.2592 +	iCurrencyDecimalPlaces = 2;
  1.2593 +	iNegativeCurrencyFormat = TNegativeCurrencyFormat(EFalse);
  1.2594 +	iCurrencyTriadsAllowed = ETrue;
  1.2595 +	iThousandsSeparator = ',';
  1.2596 +	iDecimalSeparator = '.';
  1.2597 +	TInt i=0;
  1.2598 +	for(; i<KMaxDateSeparators; i++)
  1.2599 +		iDateSeparator[i] = __DefaultDateSeparator[i];
  1.2600 +	for(i=0; i<KMaxTimeSeparators; i++)
  1.2601 +		iTimeSeparator[i] = __DefaultTimeSeparator[i];
  1.2602 +	iAmPmSymbolPosition = ELocaleAfter;
  1.2603 +	iAmPmSpaceBetween = ETrue;
  1.2604 +	iHomeDaylightSavingZone = EDstEuropean;
  1.2605 +	iWorkDays = 0x1f;
  1.2606 +	iStartOfWeek = EMonday;
  1.2607 +	iClockFormat = EClockAnalog;
  1.2608 +	iUnitsGeneral = EUnitsImperial;
  1.2609 +	iUnitsDistanceLong =  EUnitsImperial;
  1.2610 +	iUnitsDistanceShort =  EUnitsImperial;
  1.2611 +	iExtraNegativeCurrencyFormatFlags = 0;
  1.2612 +	iLanguageDowngrade[0] = ELangNone;
  1.2613 +	iLanguageDowngrade[1] = ELangNone;
  1.2614 +	iLanguageDowngrade[2] = ELangNone;
  1.2615 +#ifdef SYMBIAN_DISTINCT_LOCALE_MODEL
  1.2616 +	iRegionCode = ERegGBR;
  1.2617 +#else
  1.2618 +	iRegionCode = 0;
  1.2619 +#endif
  1.2620 +	iDigitType = EDigitTypeWestern;
  1.2621 +	iDeviceTimeState = TDeviceTimeState(EDeviceUserTime);
  1.2622 +	}
  1.2623 +
  1.2624 +EXPORT_C void TLocale::Refresh()
  1.2625 +/**
  1.2626 +Refreshes the contents of this object with the system's locale settings.
  1.2627 +*/
  1.2628 +	{
  1.2629 +
  1.2630 +	
  1.2631 +	TPckg<TLocale> localeDataBuf(*this);
  1.2632 +	TInt r = RProperty::Get(KUidSystemCategory, KLocaleDataKey, localeDataBuf);
  1.2633 +	__ASSERT_DEBUG(r == KErrNone || r == KErrNotFound, Panic(EBadLocaleParameter));
  1.2634 +	if(r == KErrNone)
  1.2635 +		{
  1.2636 +		iUniversalTimeOffset = Exec::UTCOffset();
  1.2637 +		iDaylightSaving = 0;
  1.2638 +		}
  1.2639 +	else if(r == KErrNotFound)
  1.2640 +			{
  1.2641 +			SetDefaults();
  1.2642 +			}
  1.2643 +	}
  1.2644 +
  1.2645 +
  1.2646 +
  1.2647 +
  1.2648 +EXPORT_C TInt TLocale::Set() const
  1.2649 +/**
  1.2650 +Transfers the locale settings from this object to the system. Note that
  1.2651 +the timezone offset and daylight savings flags are ignored as setting these
  1.2652 +through TLocale is no longer supported.
  1.2653 +
  1.2654 +After this function has been called, other applications may use the new
  1.2655 +settings for newly-constructed TLocale objects,
  1.2656 +or if they use TLocale::Refresh(), to refresh their settings from
  1.2657 +the system copy.
  1.2658 +
  1.2659 +@capability WriteDeviceData
  1.2660 +
  1.2661 +@return KErrNone if successful, otherwise one of the other system wide error codes.
  1.2662 +
  1.2663 +@see TLocale::Refresh()
  1.2664 +*/
  1.2665 +	{
  1.2666 +	TPckg<TLocale> localeDataBuf(*this);
  1.2667 +	TInt r = RProperty::Set(KUidSystemCategory, KLocaleDataKey, localeDataBuf);
  1.2668 +	if(r == KErrNone)
  1.2669 +		{
  1.2670 +		Exec::NotifyChanges(EChangesLocale);
  1.2671 +		}
  1.2672 +	return r;
  1.2673 +	}
  1.2674 +
  1.2675 +TInt TExtendedLocale::DoLoadLocale(const TDesC& aLocaleDllName, TLibraryFunction* aExportList)
  1.2676 +	{
  1.2677 +	RLoader loader;
  1.2678 +	TInt r = loader.LoadLocale(aLocaleDllName, aExportList);
  1.2679 +	return r;
  1.2680 +	}
  1.2681 +
  1.2682 +#ifdef SYMBIAN_DISTINCT_LOCALE_MODEL
  1.2683 +void TExtendedLocale::DoUpdateLanguageSettingsV2(TLibraryFunction* aExportList)
  1.2684 +	{
  1.2685 +	iLocale.iDigitType = EDigitTypeWestern;
  1.2686 +	iLocale.iLanguageDowngrade[0] = ELangNone;
  1.2687 +	iLocale.iLanguageDowngrade[1] = ELangNone;
  1.2688 +	iLocale.iLanguageDowngrade[2] = ELangNone;
  1.2689 +	
  1.2690 +	iLanguageSettings.iLanguage = (TLanguage)aExportList[FnLanguageV2]();
  1.2691 +	iLanguageSettings.iDateSuffixTable = (const TText*)aExportList[FnDateSuffixTableV2]();
  1.2692 +	iLanguageSettings.iDayTable = (const TText*)aExportList[FnDayTableV2]();
  1.2693 +	iLanguageSettings.iDayAbbTable = (const TText*)aExportList[FnDayAbbTableV2]();
  1.2694 +	iLanguageSettings.iMonthTable = (const TText*)aExportList[FnMonthTableV2]();
  1.2695 +	iLanguageSettings.iMonthAbbTable = (const TText*)aExportList[FnMonthAbbTableV2]();
  1.2696 +	iLanguageSettings.iAmPmTable = (const TText*)aExportList[FnAmPmTableV2]();
  1.2697 +	iLanguageSettings.iMsgTable = (const TText16* const*)aExportList[FnMsgTableV2]();
  1.2698 +	
  1.2699 +	TDigitType digitType = (TDigitType)aExportList[FnDigitTypeV2]();	
  1.2700 +	iLocale.SetDigitType(digitType);
  1.2701 +
  1.2702 +	TLanguage* languageDowngrade = (TLanguage*)aExportList[FnLanguageDowngradeTableV2]();
  1.2703 +	iLocale.SetLanguageDowngrade(0,*(languageDowngrade));
  1.2704 +	iLocale.SetLanguageDowngrade(1,*(languageDowngrade+1));
  1.2705 +	iLocale.SetLanguageDowngrade(2,*(languageDowngrade+2));
  1.2706 +	}
  1.2707 +
  1.2708 +void TExtendedLocale::DoUpdateLocaleSettingsV2(TLibraryFunction* aExportList)
  1.2709 +	{
  1.2710 +	
  1.2711 +	Mem::Copy(&iLocaleExtraSettings.iCurrencySymbol[0], (const TAny*)aExportList[FnCurrencySymbolV2](), sizeof(TText) * (KMaxCurrencySymbol+1));
  1.2712 +	iLocaleExtraSettings.iLocaleExtraSettingsDllPtr = (TAny*)aExportList[FnCurrencySymbolV2]();
  1.2713 +	Mem::Copy(&iLocaleTimeDateFormat.iShortDateFormatSpec[0], (const TAny*)aExportList[FnShortDateFormatSpecV2](), sizeof(TText) * (KMaxShortDateFormatSpec+1));
  1.2714 +	Mem::Copy(&iLocaleTimeDateFormat.iLongDateFormatSpec[0], (const TAny*)aExportList[FnLongDateFormatSpecV2](), sizeof(TText) * (KMaxLongDateFormatSpec+1)) ;
  1.2715 +	Mem::Copy(&iLocaleTimeDateFormat.iTimeFormatSpec[0], (const TAny*)aExportList[FnTimeFormatSpecV2](), sizeof(TText) * (KMaxTimeFormatSpec+1));
  1.2716 +	iLocaleTimeDateFormat.iLocaleTimeDateFormatDllPtr = (TAny*)aExportList[FnCurrencySymbolV2]();
  1.2717 +	
  1.2718 +	iLocale.iExtraNegativeCurrencyFormatFlags=0x80000000;
  1.2719 +	
  1.2720 +	typedef void (*TLibFn)(TLocale*);
  1.2721 +	((TLibFn)aExportList[FnLocaleDataV2])(&iLocale);
  1.2722 +	
  1.2723 +	if (iLocale.iExtraNegativeCurrencyFormatFlags&0x80000000)
  1.2724 +		iLocale.iExtraNegativeCurrencyFormatFlags=0;		
  1.2725 +	}
  1.2726 +#endif
  1.2727 +	
  1.2728 +void TExtendedLocale::DoUpdateLanguageSettings(TLibraryFunction* aExportList)
  1.2729 +	{
  1.2730 +	iLanguageSettings.iLanguage = (TLanguage)aExportList[FnLanguage]();
  1.2731 +	iLanguageSettings.iDateSuffixTable = (const TText*)aExportList[FnDateSuffixTable]();
  1.2732 +	iLanguageSettings.iDayTable = (const TText*)aExportList[FnDayTable]();
  1.2733 +	iLanguageSettings.iDayAbbTable = (const TText*)aExportList[FnDayAbbTable]();
  1.2734 +	iLanguageSettings.iMonthTable = (const TText*)aExportList[FnMonthTable]();
  1.2735 +	iLanguageSettings.iMonthAbbTable = (const TText*)aExportList[FnMonthAbbTable]();
  1.2736 +	iLanguageSettings.iAmPmTable = (const TText*)aExportList[FnAmPmTable]();
  1.2737 +	iLanguageSettings.iMsgTable = (const TText16* const*)aExportList[FnMsgTable]();
  1.2738 +	}
  1.2739 +
  1.2740 +void TExtendedLocale::DoUpdateLocaleSettings(TLibraryFunction* aExportList)
  1.2741 +	{
  1.2742 +	Mem::Copy(&iLocaleExtraSettings.iCurrencySymbol[0], (const TAny*)aExportList[FnCurrencySymbol](), sizeof(TText) * (KMaxCurrencySymbol+1));
  1.2743 +	iLocaleExtraSettings.iLocaleExtraSettingsDllPtr = (TAny*)aExportList[FnDateSuffixTable]();
  1.2744 +	}
  1.2745 +
  1.2746 +void TExtendedLocale::DoUpdateTimeDateFormat(TLibraryFunction* aExportList)
  1.2747 +	{
  1.2748 +	Mem::Copy(&iLocaleTimeDateFormat.iShortDateFormatSpec[0], (const TAny*)aExportList[FnShortDateFormatSpec](), sizeof(TText) * (KMaxShortDateFormatSpec+1));
  1.2749 +	Mem::Copy(&iLocaleTimeDateFormat.iLongDateFormatSpec[0], (const TAny*)aExportList[FnLongDateFormatSpec](), sizeof(TText) * (KMaxLongDateFormatSpec+1)) ;
  1.2750 +	Mem::Copy(&iLocaleTimeDateFormat.iTimeFormatSpec[0], (const TAny*)aExportList[FnTimeFormatSpec](), sizeof(TText) * (KMaxTimeFormatSpec+1));
  1.2751 +	iLocaleTimeDateFormat.iLocaleTimeDateFormatDllPtr = (TAny*)aExportList[FnDateSuffixTable]();
  1.2752 +	}
  1.2753 +
  1.2754 +/**
  1.2755 +Default constructor.
  1.2756 +
  1.2757 +It constructs an empty object
  1.2758 +
  1.2759 +This is an empty copy of TExtendedLocale. To get the system locale you can
  1.2760 +use TExtendedLocale::LoadSystemSettings. The current settings may be saved to the system
  1.2761 +with TLocale::SaveSystemSettings().
  1.2762 +
  1.2763 +@see TExtendedLocale::LoadSystemSettings
  1.2764 +@see TExtendedLocale::SaveSystemSettings
  1.2765 +*/
  1.2766 +EXPORT_C TExtendedLocale::TExtendedLocale()
  1.2767 +	: iLocale(0)
  1.2768 +	{
  1.2769 +
  1.2770 +	Mem::FillZ(&iLanguageSettings, sizeof(TExtendedLocale) - sizeof(TLocale));
  1.2771 +	}
  1.2772 +
  1.2773 +/**
  1.2774 +Load system wide locale settings
  1.2775 +
  1.2776 +It initialises this TExtendedLocale with the system wide locale settings.
  1.2777 +The settings stored in the TExtendedLocale are overwritten with the system
  1.2778 +wide locale.
  1.2779 +
  1.2780 +@see TExtendedLocale::SaveSystemSettings
  1.2781 +*/
  1.2782 +EXPORT_C void TExtendedLocale::LoadSystemSettings()
  1.2783 +	{
  1.2784 +	LocaleLanguageGet(iLanguageSettings);
  1.2785 +	LocaleSettingsGet(iLocaleExtraSettings);
  1.2786 +	LocaleTimeDateFormatGet(iLocaleTimeDateFormat);
  1.2787 +	iDefaultCharSet = GetLocaleCharSet();
  1.2788 +	iPreferredCharSet = GetLocalePreferredCharSet();
  1.2789 +	iLocale.Refresh();
  1.2790 +	}
  1.2791 +
  1.2792 +/**
  1.2793 +Make the current locale information system wide
  1.2794 +
  1.2795 +It overwrites the system wide locale information with the locale information
  1.2796 +stored in this TExtendedLocale.
  1.2797 +This will generate a notification for system locale changes.
  1.2798 +In case of an error, the locale might be in an unconsistent state.
  1.2799 +
  1.2800 +@capability WriteDeviceData
  1.2801 +
  1.2802 +@return KErrNone if successful, otherwise one of the other system wide error codes.
  1.2803 +*/
  1.2804 +EXPORT_C TInt TExtendedLocale::SaveSystemSettings()
  1.2805 +	{
  1.2806 +
  1.2807 +	TPckg<SLocaleLanguage> localeLanguageBuf(iLanguageSettings);
  1.2808 +	TInt r = RProperty::Set(KUidSystemCategory, KLocaleLanguageKey, localeLanguageBuf);
  1.2809 +	if(r != KErrNone)
  1.2810 +		return r;
  1.2811 +
  1.2812 +	TPckg<SLocaleLocaleSettings> localeSettingsBuf(iLocaleExtraSettings);
  1.2813 +	r = RProperty::Set(KUidSystemCategory, KLocaleDataExtraKey, localeSettingsBuf);
  1.2814 +	if(r != KErrNone)
  1.2815 +		return r;
  1.2816 +
  1.2817 +	TPckg<SLocaleTimeDateFormat> localeTimeDateFormatBuf(iLocaleTimeDateFormat);
  1.2818 +	r = RProperty::Set(KUidSystemCategory, KLocaleTimeDateFormatKey, localeTimeDateFormatBuf);
  1.2819 +	if(r != KErrNone)
  1.2820 +		return r;
  1.2821 +
  1.2822 +	r = Exec::SetGlobalUserData(ELocaleDefaultCharSet, (TInt)iDefaultCharSet);
  1.2823 +	if(r != KErrNone)
  1.2824 +		return r;
  1.2825 +
  1.2826 +	r = Exec::SetGlobalUserData(ELocalePreferredCharSet, (TInt)iPreferredCharSet);
  1.2827 +
  1.2828 +	if(r == KErrNone)
  1.2829 +		{
  1.2830 +		iLocale.Set();
  1.2831 +		}
  1.2832 +
  1.2833 +	return r;
  1.2834 +	}
  1.2835 +
  1.2836 +#ifdef SYMBIAN_DISTINCT_LOCALE_MODEL
  1.2837 +TInt TExtendedLocale::CheckLocaleDllName(const TDesC& aLocaleDllName, TInt& languageID)
  1.2838 +	{
  1.2839 +	languageID = 0;
  1.2840 +	
  1.2841 +	if(aLocaleDllName.Find(KLoc) == KErrNotFound)
  1.2842 +		return KErrNotFound;	
  1.2843 +
  1.2844 +	TInt len = aLocaleDllName.Length() - 6;  //6 is the length of KLoc.
  1.2845 +	TPtrC ptr = aLocaleDllName.Right(len);
  1.2846 +	for(TInt i =0; i< len; i++)
  1.2847 +		{
  1.2848 +		if(ptr[i] >= '0' && ptr[i] <= '9')
  1.2849 +			{
  1.2850 +			languageID = languageID*10 + (ptr[i] - '0');
  1.2851 +			}
  1.2852 +		else
  1.2853 +			{
  1.2854 +			languageID = 0;
  1.2855 +			return KErrNotFound;
  1.2856 +			}
  1.2857 +		}
  1.2858 +	return KErrNone;	
  1.2859 +	}
  1.2860 +
  1.2861 +//add file extension, such as "elocl_lan" will be "elocl_lan.012"
  1.2862 +void TExtendedLocale::AddExtension(TDes& aFileName, TInt aExtension)
  1.2863 +	{			
  1.2864 +	if (aExtension < 10)
  1.2865 +		{
  1.2866 +		aFileName.AppendNum(0);
  1.2867 +		aFileName.AppendNum(0);
  1.2868 +		aFileName.AppendNum(aExtension);
  1.2869 +		}
  1.2870 +	else if (aExtension < 100)
  1.2871 +		{
  1.2872 +		aFileName.AppendNum(0);
  1.2873 +		aFileName.AppendNum(aExtension);
  1.2874 +		}
  1.2875 +	else
  1.2876 +		{
  1.2877 +		aFileName.AppendNum(aExtension);
  1.2878 +		}	
  1.2879 +	return;	
  1.2880 +	}
  1.2881 +#endif
  1.2882 +	
  1.2883 +/**
  1.2884 +Loads a locale Dll and get the locale information
  1.2885 +
  1.2886 +It loads a locale DLL and it initialises the contents of this TExtendedLocale
  1.2887 +with the locale information stored in the DLL. The locale information is only
  1.2888 +stored in this TExtendedLocale. If you want to set the system wide settings with
  1.2889 +the locale information in the DLL, you can call TExtendedLocale::SaveSystemSettings
  1.2890 +after calling this function.
  1.2891 +
  1.2892 +@param aLocaleDllName The name of the locale DLL to be loaded
  1.2893 +@return KErrNone if successful, system wide error if not
  1.2894 +
  1.2895 +@see TExtendedLocale::SaveSystemSettings 
  1.2896 +*/
  1.2897 +EXPORT_C TInt TExtendedLocale::LoadLocale(const TDesC& aLocaleDllName)
  1.2898 +	{
  1.2899 +#ifdef SYMBIAN_DISTINCT_LOCALE_MODEL
  1.2900 +	TLibraryFunction data[KNumLocaleExports];
  1.2901 +	TInt r = DoLoadLocale(aLocaleDllName, &data[0]);
  1.2902 +	if(r == KErrNone)
  1.2903 +		{
  1.2904 +		iLocale.iExtraNegativeCurrencyFormatFlags=0x80000000;
  1.2905 +	  	iLocale.iLanguageDowngrade[0] = ELangNone;
  1.2906 +		iLocale.iLanguageDowngrade[1] = ELangNone;
  1.2907 +  		iLocale.iLanguageDowngrade[2] = ELangNone;
  1.2908 +	  	iLocale.iDigitType = EDigitTypeWestern;
  1.2909 +
  1.2910 +		typedef void (*TLibFn)(TLocale*);
  1.2911 +		((TLibFn)data[FnLocaleData])(&iLocale);
  1.2912 +
  1.2913 +		//Locale daylightsavings unchanged - we have travelled through space, not time
  1.2914 +		if (iLocale.iExtraNegativeCurrencyFormatFlags&0x80000000)
  1.2915 +			iLocale.iExtraNegativeCurrencyFormatFlags=0;		
  1.2916 +		
  1.2917 +		DoUpdateLanguageSettings(&data[0]);
  1.2918 +		DoUpdateLocaleSettings(&data[0]);
  1.2919 +		DoUpdateTimeDateFormat(&data[0]);
  1.2920 +
  1.2921 +		iPreferredCharSet = (const LCharSet*)data[FnCharSet]();
  1.2922 +		iDefaultCharSet = iPreferredCharSet;
  1.2923 +		return r;
  1.2924 +		}
  1.2925 +	else if(r == KErrNotFound)
  1.2926 +	    {
  1.2927 +	    TInt lan = 0;
  1.2928 +		TInt reg = 0;
  1.2929 +		TInt col = 0;
  1.2930 +	     TInt languageID = -1;
  1.2931 +	     TInt err = CheckLocaleDllName(aLocaleDllName, languageID);
  1.2932 +	     if (err != KErrNone)
  1.2933 +	         return err;
  1.2934 +	      
  1.2935 +	     TInt i = 0;
  1.2936 +	     while (i < KLocMapLength)  //binary search later
  1.2937 +	         {
  1.2938 +	         if ((LocaleMapping[i].iOldLocaleId) == languageID)
  1.2939 +	             {
  1.2940 +	             lan = LocaleMapping[i].iNewLocaleID[0];
  1.2941 +	             reg = LocaleMapping[i].iNewLocaleID[1];
  1.2942 +	             col = LocaleMapping[i].iNewLocaleID[2];
  1.2943 +	             break;
  1.2944 +	             }   
  1.2945 +	         i++;
  1.2946 +	         }
  1.2947 +	     if(i == KLocMapLength)
  1.2948 +	        return KErrNotFound;
  1.2949 +	     
  1.2950 +	     TBuf<15> lanptr = KFindLan();
  1.2951 +	     TBuf<15> regptr = KFindReg();
  1.2952 +	     TBuf<15> colptr = KFindCol();   
  1.2953 +	     AddExtension(lanptr, lan);
  1.2954 +	     AddExtension(regptr, reg);
  1.2955 +	     AddExtension(colptr, col);  
  1.2956 +	     err = LoadLocale(lanptr, regptr, colptr);   
  1.2957 +	     
  1.2958 +	     return err; 
  1.2959 +	    }
  1.2960 +	return r;
  1.2961 +#else
  1.2962 +	TLibraryFunction data[KNumLocaleExports];
  1.2963 +	TInt r = DoLoadLocale(aLocaleDllName, &data[0]);
  1.2964 +	if(r == KErrNone)
  1.2965 +		{
  1.2966 +		iLocale.iExtraNegativeCurrencyFormatFlags=0x80000000;
  1.2967 +	  	iLocale.iLanguageDowngrade[0] = ELangNone;
  1.2968 +		iLocale.iLanguageDowngrade[1] = ELangNone;
  1.2969 +  		iLocale.iLanguageDowngrade[2] = ELangNone;
  1.2970 +	  	iLocale.iDigitType = EDigitTypeWestern;
  1.2971 +
  1.2972 +		typedef void (*TLibFn)(TLocale*);
  1.2973 +		((TLibFn)data[FnLocaleData])(&iLocale);
  1.2974 +
  1.2975 +		//Locale daylightsavings unchanged - we have travelled through space, not time
  1.2976 +		if (iLocale.iExtraNegativeCurrencyFormatFlags&0x80000000)
  1.2977 +			iLocale.iExtraNegativeCurrencyFormatFlags=0;		
  1.2978 +		
  1.2979 +		DoUpdateLanguageSettings(&data[0]);
  1.2980 +		DoUpdateLocaleSettings(&data[0]);
  1.2981 +		DoUpdateTimeDateFormat(&data[0]);
  1.2982 +
  1.2983 +		iPreferredCharSet = (const LCharSet*)data[FnCharSet]();
  1.2984 +		iDefaultCharSet = iPreferredCharSet;
  1.2985 +		}
  1.2986 +	return r;
  1.2987 +#endif
  1.2988 +	}
  1.2989 +
  1.2990 +/**
  1.2991 +Loads locale data from three locale dlls, which are language, region, and collation locale dlls
  1.2992 +
  1.2993 +It loads three locale DLLs and it initialises the contents of this TExtendedLocale
  1.2994 +with the locale information stored in the DLLs. The locale information is only
  1.2995 +stored in this TExtendedLocale. If you want to set the system wide settings with
  1.2996 +the locale information in the DLL, you can call TExtendedLocale::SaveSystemSettings
  1.2997 +after calling this function.
  1.2998 +
  1.2999 +@param aLanguageLocaleDllName The name of the language locale DLL to be loaded
  1.3000 +@param aRegionLocaleDllName The name of the region locale DLL to be loaded
  1.3001 +@param aCollationLocaleDllName The name of the collation locale DLL to be loaded
  1.3002 +
  1.3003 +@return KErrNone if successful, system wide error if not
  1.3004 +
  1.3005 +@see TExtendedLocale::SaveSystemSettings 
  1.3006 +*/
  1.3007 +#ifdef SYMBIAN_DISTINCT_LOCALE_MODEL
  1.3008 +EXPORT_C TInt TExtendedLocale::LoadLocale(const TDesC& aLanguageLocaleDllName, 
  1.3009 +		const TDesC& aRegionLocaleDllName, 
  1.3010 +		const TDesC& aCollationLocaleDllName)
  1.3011 +	{
  1.3012 +
  1.3013 +	TInt err = LoadLocaleAspect(aLanguageLocaleDllName);
  1.3014 +	if(err != KErrNone)
  1.3015 +		return err;
  1.3016 +	
  1.3017 +	err = LoadLocaleAspect(aRegionLocaleDllName);
  1.3018 +	if(err != KErrNone)
  1.3019 +		return err;
  1.3020 +	
  1.3021 +	err = LoadLocaleAspect(aCollationLocaleDllName);
  1.3022 +	if(err != KErrNone)
  1.3023 +		return err;	
  1.3024 +
  1.3025 +	return err;	
  1.3026 +	}
  1.3027 +#else
  1.3028 +EXPORT_C TInt TExtendedLocale::LoadLocale(const TDesC& /*aLanguageLocaleDllName*/, 
  1.3029 +        const TDesC& /*aRegionLocaleDllName*/, 
  1.3030 +        const TDesC& /*aCollationLocaleDllName*/)
  1.3031 +    {
  1.3032 +    return KErrNotSupported;
  1.3033 +    }
  1.3034 +#endif
  1.3035 +
  1.3036 +/**
  1.3037 +Loads a DLL and get some locale information
  1.3038 +
  1.3039 +It loads the specified locale DLL and depending on the aAspectGroup it overwrites
  1.3040 +locale information in this TExtendedLocale with the locale information stored in the
  1.3041 +DLL. aAspectGroup is a bitmap of TLocaleAspect values specifying what to be overwritten.
  1.3042 +The locale information is only stored in this TExtendedLocale. If you want to set the
  1.3043 +system wide settings with the locale information in the DLL, you can call
  1.3044 +TExtendedLocale::SaveSystemSettings after calling this function.
  1.3045 +
  1.3046 +@param aAspectGroup A bitmap of TLocaleAspect values specifying what to be overwritten in
  1.3047 +					this TExtendedLocale. (eg.: ELocaleLanguageSettings | ELocaleTimeDateSettings)
  1.3048 +@param aLocaleDllName The name of the locale DLL to be loaded
  1.3049 +
  1.3050 +@return KErrNone if the method is successful, a system wide error code if not
  1.3051 +
  1.3052 +@see TLocaleAspect
  1.3053 +@see TExtendedLocale::SaveSystemSettings
  1.3054 +*/
  1.3055 +EXPORT_C TInt TExtendedLocale::LoadLocaleAspect(TUint aAspectGroup, const TDesC& aLocaleDllName)
  1.3056 +	{
  1.3057 +#ifdef SYMBIAN_DISTINCT_LOCALE_MODEL
  1.3058 +	TLibraryFunction data[KNumLocaleExports];
  1.3059 +	TInt r = DoLoadLocale(aLocaleDllName, &data[0]);
  1.3060 +	if(r == KErrNone)
  1.3061 +		{
  1.3062 +		if(aAspectGroup & ELocaleLanguageSettings)
  1.3063 +			{
  1.3064 +			DoUpdateLanguageSettings(&data[0]);
  1.3065 +			}
  1.3066 +		if(aAspectGroup & ELocaleCollateSetting)
  1.3067 +			{
  1.3068 +			iPreferredCharSet = (const LCharSet*)data[FnCharSet]();
  1.3069 +			iDefaultCharSet = iPreferredCharSet;
  1.3070 +			}
  1.3071 +		if(aAspectGroup & ELocaleLocaleSettings)
  1.3072 +			{
  1.3073 +			DoUpdateLocaleSettings(&data[0]);
  1.3074 +			}
  1.3075 +		if(aAspectGroup & ELocaleTimeDateSettings)
  1.3076 +			{
  1.3077 +			DoUpdateTimeDateFormat(&data[0]);
  1.3078 +			}
  1.3079 +		return r;
  1.3080 +		}
  1.3081 +	
  1.3082 +	else if (r == KErrNotFound)
  1.3083 +	    {
  1.3084 +	    TInt lan = 0;
  1.3085 +		TInt reg = 0;
  1.3086 +		TInt col = 0;
  1.3087 +	    TInt languageID = -1;
  1.3088 +	    TInt err = CheckLocaleDllName(aLocaleDllName, languageID);
  1.3089 +	    if(err != KErrNone)
  1.3090 +	        return err;
  1.3091 +	    
  1.3092 +	    TInt i = 0;
  1.3093 +	    while (i < KLocMapLength)
  1.3094 +	        {
  1.3095 +	        if ((LocaleMapping[i].iOldLocaleId) == languageID)
  1.3096 +	            {
  1.3097 +	            lan = LocaleMapping[i].iNewLocaleID[0];
  1.3098 +	            reg = LocaleMapping[i].iNewLocaleID[1];
  1.3099 +	            col = LocaleMapping[i].iNewLocaleID[2];
  1.3100 +	            break;
  1.3101 +	            }   
  1.3102 +	        i++;
  1.3103 +	        }
  1.3104 +	    if(i == KLocMapLength)
  1.3105 +	        return KErrNotFound;
  1.3106 +	    
  1.3107 +	    TBuf<15> lanptr = KFindLan();
  1.3108 +	    TBuf<15> regptr = KFindReg();
  1.3109 +	    TBuf<15> colptr = KFindCol();   
  1.3110 +	    AddExtension(lanptr, lan);
  1.3111 +	    AddExtension(regptr, reg);
  1.3112 +	    AddExtension(colptr, col);  
  1.3113 +	    
  1.3114 +	    switch (aAspectGroup)
  1.3115 +	        {
  1.3116 +	        case ELocaleCollateSetting:
  1.3117 +	            {
  1.3118 +	            err = LoadLocaleAspect(colptr);
  1.3119 +	            break;          
  1.3120 +	            }
  1.3121 +	        case ELocaleLocaleSettings:
  1.3122 +	            {
  1.3123 +	            err = LoadLocaleAspect(regptr);
  1.3124 +	            break;
  1.3125 +	            }
  1.3126 +	            
  1.3127 +	        case ELocaleLanguageSettings:
  1.3128 +	            {
  1.3129 +	            err = LoadLocaleAspect(lanptr);
  1.3130 +	            break;
  1.3131 +	            }       
  1.3132 +	        }
  1.3133 +	    return err;
  1.3134 +	    }
  1.3135 +	
  1.3136 +	return r;
  1.3137 +#else
  1.3138 +	TLibraryFunction data[KNumLocaleExports];
  1.3139 +	TInt r = DoLoadLocale(aLocaleDllName, &data[0]);
  1.3140 +	if(r == KErrNone)
  1.3141 +		{
  1.3142 +		if(aAspectGroup & ELocaleLanguageSettings)
  1.3143 +			{
  1.3144 +			DoUpdateLanguageSettings(&data[0]);
  1.3145 +			}
  1.3146 +		if(aAspectGroup & ELocaleCollateSetting)
  1.3147 +			{
  1.3148 +			iPreferredCharSet = (const LCharSet*)data[FnCharSet]();
  1.3149 +			iDefaultCharSet = iPreferredCharSet;
  1.3150 +			}
  1.3151 +		if(aAspectGroup & ELocaleLocaleSettings)
  1.3152 +			{
  1.3153 +			DoUpdateLocaleSettings(&data[0]);
  1.3154 +			}
  1.3155 +		if(aAspectGroup & ELocaleTimeDateSettings)
  1.3156 +			{
  1.3157 +			DoUpdateTimeDateFormat(&data[0]);
  1.3158 +			}
  1.3159 +		}
  1.3160 +	return r;
  1.3161 +#endif
  1.3162 +	}
  1.3163 +
  1.3164 +/**
  1.3165 +Loads a DLL and get some locale information
  1.3166 +
  1.3167 +It loads the specified locale DLL, and it overwrites
  1.3168 +locale information in this TExtendedLocale with the locale information stored in the
  1.3169 +DLL. The locale information is only stored in this TExtendedLocale. If you want to set the
  1.3170 +system wide settings with the locale information in the DLL, you can call
  1.3171 +TExtendedLocale::SaveSystemSettings after calling this function.
  1.3172 +
  1.3173 +@param aLocaleDllName The name of the locale DLL to be loaded
  1.3174 +
  1.3175 +@return KErrNone if the method is successful, a system wide error code if not
  1.3176 +
  1.3177 +@see TExtendedLocale::SaveSystemSettings
  1.3178 +*/
  1.3179 +#ifdef SYMBIAN_DISTINCT_LOCALE_MODEL
  1.3180 +EXPORT_C TInt TExtendedLocale::LoadLocaleAspect(const TDesC& aLocaleDllName)
  1.3181 +	{
  1.3182 +	TLibraryFunction data[KNumLocaleExports];
  1.3183 +	
  1.3184 +	TInt result = aLocaleDllName.Find(KFindReg);
  1.3185 +	if(result != KErrNotFound)
  1.3186 +		{
  1.3187 +		result = DoLoadLocale(aLocaleDllName, &data[0]);
  1.3188 +		if(result == KErrNone)
  1.3189 +			{
  1.3190 +			DoUpdateLocaleSettingsV2(&data[0]);
  1.3191 +			return result;
  1.3192 +			}
  1.3193 +		}
  1.3194 +	
  1.3195 +	result= aLocaleDllName.Find(KFindLan);
  1.3196 +	if(result != KErrNotFound)
  1.3197 +		{
  1.3198 +		result = DoLoadLocale(aLocaleDllName, &data[0]);
  1.3199 +		if(result == KErrNone)
  1.3200 +			{
  1.3201 +			DoUpdateLanguageSettingsV2(&data[0]);	
  1.3202 +			return result;
  1.3203 +			}
  1.3204 +		}
  1.3205 +	
  1.3206 +	result = aLocaleDllName.Find(KFindCol);
  1.3207 +	if(result != KErrNotFound)
  1.3208 +		{
  1.3209 +		result = DoLoadLocale(aLocaleDllName, &data[0]);
  1.3210 +		if(result == KErrNone)
  1.3211 +			{
  1.3212 +			iPreferredCharSet = (const LCharSet*)data[1]();
  1.3213 +			iDefaultCharSet = iPreferredCharSet;
  1.3214 +			return result;
  1.3215 +			}
  1.3216 +		}
  1.3217 +	
  1.3218 +	return KErrNotFound;	
  1.3219 +	}
  1.3220 +#else
  1.3221 +EXPORT_C TInt TExtendedLocale::LoadLocaleAspect(const TDesC& /*aLocaleDllName*/)
  1.3222 +    {
  1.3223 +    return KErrNotSupported;    
  1.3224 +    }	
  1.3225 +#endif
  1.3226 +
  1.3227 +/**
  1.3228 +Sets the currency symbol
  1.3229 +
  1.3230 +It sets the currency symbol. The maximum lenght for the currency symbol is
  1.3231 +KMaxCurrencySymbol. Trying to pass a descriptor longer than that, will result
  1.3232 +in a panic.
  1.3233 +
  1.3234 +@param aSymbol The new currency symbol
  1.3235 +
  1.3236 +@panic USER 119, if the length of aSymbol is greater than KMaxCurrencySymbol.
  1.3237 +
  1.3238 +@capability WriteDeviceData
  1.3239 +
  1.3240 +@return KErrNone if successful, otherwise one of the other system wide error codes.
  1.3241 +*/
  1.3242 +EXPORT_C TInt TExtendedLocale::SetCurrencySymbol(const TDesC &aSymbol)
  1.3243 +	{
  1.3244 +	__ASSERT_ALWAYS(aSymbol.Length()<=KMaxCurrencySymbol,::Panic(ECurrencySymbolOverflow));
  1.3245 +	
  1.3246 +	LocaleSettingsGet(iLocaleExtraSettings);
  1.3247 +	Mem::Copy(&iLocaleExtraSettings.iCurrencySymbol[0], aSymbol.Ptr(), aSymbol.Length()*sizeof(TText) );    
  1.3248 +	iLocaleExtraSettings.iCurrencySymbol[aSymbol.Length()] = 0;
  1.3249 +	TInt r = RProperty::Set(KUidSystemCategory, KLocaleDataExtraKey, TPckg<SLocaleLocaleSettings>(iLocaleExtraSettings));
  1.3250 +	return r;
  1.3251 +	}
  1.3252 +
  1.3253 +/**
  1.3254 +Returns the name of the DLL containing the given bits of locale information
  1.3255 +
  1.3256 +Given the bits of locale information specified in aLocaleDataSet, it returns the name
  1.3257 +of the locale DLL storing the information. TExtendedLocale can contain information from
  1.3258 +different DLLs.
  1.3259 +
  1.3260 +@param aLocaleDataSet The TLocaleAspect specifying a group of locale properties
  1.3261 +@param aDllName The descriptor that will contain the name of DLL containing the specifying
  1.3262 +				bits of locale information (valid if the method is successful)
  1.3263 +
  1.3264 +@return KErrNone if successful, system wide error otherwise
  1.3265 +*/
  1.3266 +EXPORT_C TInt TExtendedLocale::GetLocaleDllName(TLocaleAspect aLocaleDataSet, TDes& aDllName)
  1.3267 +	{
  1.3268 + 	TBuf8<KMaxFullName> buf;
  1.3269 +	TAny* ptr = 0;
  1.3270 +	switch(aLocaleDataSet)
  1.3271 +		{
  1.3272 +		case ELocaleLanguageSettings:
  1.3273 +			ptr = (TAny*)iLanguageSettings.iDateSuffixTable;
  1.3274 +			break;
  1.3275 +		case ELocaleCollateSetting:
  1.3276 +			ptr = (TAny*)iPreferredCharSet;
  1.3277 +			break;
  1.3278 +		case ELocaleLocaleSettings:
  1.3279 +			ptr = (TAny*)iLocaleExtraSettings.iLocaleExtraSettingsDllPtr;
  1.3280 +			break;
  1.3281 +		case ELocaleTimeDateSettings:
  1.3282 +			ptr = (TAny*)iLocaleTimeDateFormat.iLocaleTimeDateFormatDllPtr;
  1.3283 +			break;
  1.3284 +		}
  1.3285 + 	TInt r = Exec::GetModuleNameFromAddress(ptr, buf);
  1.3286 + 	if (r == KErrNone)
  1.3287 +		{
  1.3288 + 		aDllName.Copy(buf);
  1.3289 + 		}
  1.3290 + 	return r;
  1.3291 +	}
  1.3292 +
  1.3293 +/**
  1.3294 +Get the Currency Symbol from SLocaleLocaleSettings object
  1.3295 +
  1.3296 +@return TPtrC Pointer holding the Currency Symbol
  1.3297 +*/
  1.3298 +EXPORT_C TPtrC TExtendedLocale::GetCurrencySymbol()
  1.3299 +	{
  1.3300 +	TPtrC outCurrencySymbolPtr(iLocaleExtraSettings.iCurrencySymbol);
  1.3301 +	return outCurrencySymbolPtr;
  1.3302 +	}
  1.3303 +	
  1.3304 +/**
  1.3305 +Get the Long Date Format from SLocaleTimeDateFormat object
  1.3306 +
  1.3307 +@return TPtrC Pointer holding the Long Date Format
  1.3308 +*/
  1.3309 +EXPORT_C TPtrC TExtendedLocale::GetLongDateFormatSpec()
  1.3310 +	{
  1.3311 +	TPtrC outLongDateFormatPtr(iLocaleTimeDateFormat.iLongDateFormatSpec);
  1.3312 +	return outLongDateFormatPtr;
  1.3313 +	}
  1.3314 +	
  1.3315 +/**
  1.3316 +Get the Short Date Format from SLocaleTimeDateFormat object
  1.3317 +
  1.3318 +@return TPtrC Pointer holding the Short Date Format
  1.3319 +*/
  1.3320 +EXPORT_C TPtrC TExtendedLocale::GetShortDateFormatSpec()
  1.3321 +	{
  1.3322 +	TPtrC outShortDateFormatPtr(iLocaleTimeDateFormat.iShortDateFormatSpec);
  1.3323 +	return outShortDateFormatPtr;
  1.3324 +	}
  1.3325 +	
  1.3326 +/**
  1.3327 +Get the Time Format from SLocaleTimeDateFormat object
  1.3328 +
  1.3329 +@return TPtrC Pointer holding the Time Format
  1.3330 +*/
  1.3331 +EXPORT_C TPtrC TExtendedLocale::GetTimeFormatSpec()
  1.3332 +	{
  1.3333 +	TPtrC outTimeFormatPtr(iLocaleTimeDateFormat.iTimeFormatSpec);
  1.3334 +	return outTimeFormatPtr;
  1.3335 +	}
  1.3336 +
  1.3337 +EXPORT_C TInt UserSvr::LocalePropertiesSetDefaults()
  1.3338 +	{
  1.3339 +	_LIT_SECURITY_POLICY_C1(KLocaleWritePolicy,ECapabilityWriteDeviceData);
  1.3340 +	_LIT_SECURITY_POLICY_PASS(KLocaleReadPolicy);
  1.3341 +
  1.3342 +	TInt r = RProperty::Define(KUidSystemCategory, KLocaleLanguageKey, RProperty::EByteArray, KLocaleReadPolicy, KLocaleWritePolicy, sizeof(TPckg<SLocaleLanguage>));
  1.3343 +	if(r != KErrNone && r != KErrAlreadyExists)
  1.3344 +		return r;
  1.3345 +	
  1.3346 +	SLocaleLanguage localeLanguage;
  1.3347 +	localeLanguage.iLanguage			= ELangEnglish;
  1.3348 +	localeLanguage.iDateSuffixTable		= (const TText16*)__DefaultDateSuffixTable;
  1.3349 +	localeLanguage.iDayTable			= (const TText16*)__DefaultDayTable;
  1.3350 +	localeLanguage.iDayAbbTable			= (const TText16*)__DefaultDayAbbTable;
  1.3351 +	localeLanguage.iMonthTable			= (const TText16*)__DefaultMonthTable;
  1.3352 +	localeLanguage.iMonthAbbTable		= (const TText16*)__DefaultMonthAbbTable;
  1.3353 +	localeLanguage.iAmPmTable			= (const TText16*)__DefaultAmPmTable;
  1.3354 +	localeLanguage.iMsgTable			= (const TText16* const*)__DefaultLMsgTable;
  1.3355 +	r = RProperty::Set(KUidSystemCategory, KLocaleLanguageKey, TPckg<SLocaleLanguage>(localeLanguage));
  1.3356 +	if(r != KErrNone)
  1.3357 +		return r;
  1.3358 +
  1.3359 +	r = RProperty::Define(KUidSystemCategory, KLocaleDataKey, RProperty::EByteArray, KLocaleReadPolicy, KLocaleWritePolicy, sizeof(TPckg<TLocale>));
  1.3360 +	if(r != KErrNone && r != KErrAlreadyExists)
  1.3361 +		return r;
  1.3362 +
  1.3363 +	TLocale locale(0);
  1.3364 +	locale.SetDefaults();
  1.3365 +
  1.3366 +	r = RProperty::Set(KUidSystemCategory, KLocaleDataKey, TPckg<TLocale>(locale));
  1.3367 +	if(r != KErrNone)
  1.3368 +		return r;
  1.3369 +
  1.3370 +	r = RProperty::Define(KUidSystemCategory, KLocaleDataExtraKey, RProperty::EByteArray, KLocaleReadPolicy, KLocaleWritePolicy, sizeof(TPckg<SLocaleLocaleSettings>));
  1.3371 +	if(r != KErrNone && r != KErrAlreadyExists)
  1.3372 +		return r;
  1.3373 +
  1.3374 +	SLocaleLocaleSettings localeSettings;
  1.3375 +	Mem::Copy(&localeSettings.iCurrencySymbol[0], _S16("\x00a3"), sizeof(TText16) * 2);
  1.3376 +
  1.3377 +	r = RProperty::Set(KUidSystemCategory, KLocaleDataExtraKey, TPckg<SLocaleLocaleSettings>(localeSettings));
  1.3378 +	if(r != KErrNone)
  1.3379 +		return r;
  1.3380 +
  1.3381 +	r = RProperty::Define(KUidSystemCategory, KLocaleTimeDateFormatKey, RProperty::EByteArray, KLocaleReadPolicy, KLocaleWritePolicy, sizeof(TPckg<SLocaleLocaleSettings>));
  1.3382 +	if(r != KErrNone && r != KErrAlreadyExists)
  1.3383 +		return r;
  1.3384 +
  1.3385 +	SLocaleTimeDateFormat localeTimeDateFormat;
  1.3386 +	Mem::Copy(&localeTimeDateFormat.iShortDateFormatSpec[0], _S16("%F%*D/%*M/%Y"), sizeof(TText16) * 13);
  1.3387 +	Mem::Copy(&localeTimeDateFormat.iLongDateFormatSpec[0], _S16("%F%*D%X %N %Y"), sizeof(TText16) * 14);
  1.3388 +	Mem::Copy(&localeTimeDateFormat.iTimeFormatSpec[0], _S16("%F%*I:%T:%S %*A"), sizeof(TText16) * 16);
  1.3389 +
  1.3390 +	r = RProperty::Set(KUidSystemCategory, KLocaleTimeDateFormatKey, TPckg<SLocaleTimeDateFormat>(localeTimeDateFormat));
  1.3391 +	if(r != KErrNone)
  1.3392 +		return r;
  1.3393 +
  1.3394 +	TInt charSet = (TInt)GetLocaleDefaultCharSet();
  1.3395 +	r = Exec::SetGlobalUserData(ELocaleDefaultCharSet, charSet);
  1.3396 +	if(r != KErrNone)
  1.3397 +		return r;
  1.3398 +
  1.3399 +	r = Exec::SetGlobalUserData(ELocalePreferredCharSet, charSet);
  1.3400 +
  1.3401 +	return r;
  1.3402 +	}
  1.3403 +
  1.3404 +
  1.3405 +// TOverflowHandler class created to handle the descriptor overflow in TLoacle::FormatCurrency
  1.3406 +NONSHARABLE_CLASS(TOverflowHandler) : public TDesOverflow
  1.3407 +	{
  1.3408 +	void Overflow(TDes& aDes);
  1.3409 +	};
  1.3410 +
  1.3411 +void TOverflowHandler::Overflow(TDes&)
  1.3412 +	{
  1.3413 +	Panic(ETDes16Overflow);
  1.3414 +	}
  1.3415 +
  1.3416 +
  1.3417 +
  1.3418 +
  1.3419 +EXPORT_C void TLocale::FormatCurrency(TDes& aText, TInt aAmount)
  1.3420 +/**
  1.3421 +Renders a currency value as text, based on the locale's currency and numeric 
  1.3422 +format settings. 
  1.3423 +
  1.3424 +These settings include the currency symbol, the symbol's position and the 
  1.3425 +way negative values are formatted.
  1.3426 +
  1.3427 +@param aText   On return, contains the currency value as text, formatted
  1.3428 +               according to the locale's currency format settings.
  1.3429 +@param aAmount The currency value to be formatted.
  1.3430 +
  1.3431 +@panic USER 11, if aText is not long enough to hold the formatted value.
  1.3432 +*/
  1.3433 +	{
  1.3434 +	TOverflowHandler overflowHandler;
  1.3435 +	FormatCurrency(aText,overflowHandler,aAmount);   
  1.3436 +	}
  1.3437 +
  1.3438 +
  1.3439 +
  1.3440 +
  1.3441 +EXPORT_C void TLocale::FormatCurrency(TDes& aText, TInt64 aAmount)
  1.3442 +/**
  1.3443 +Renders a currency value as text, based on the locale's currency and numeric 
  1.3444 +format settings. 
  1.3445 +
  1.3446 +These settings include the currency symbol, the symbol's position and the 
  1.3447 +way negative values are formatted.
  1.3448 +
  1.3449 +@param aText   On return, contains the currency value as text, formatted
  1.3450 +               according to the locale's currency format settings.
  1.3451 +@param aAmount The currency value to be formatted.
  1.3452 +
  1.3453 +@panic USER 11, if aText is not long enough to hold the formatted value.
  1.3454 +*/
  1.3455 +	{
  1.3456 +	TOverflowHandler overflowHandler;
  1.3457 +	FormatCurrency(aText,overflowHandler, aAmount);
  1.3458 +	}
  1.3459 +
  1.3460 +
  1.3461 +
  1.3462 +
  1.3463 +EXPORT_C void TLocale::FormatCurrency(TDes& aText, TDesOverflow& aOverflowHandler, TInt aAmount)
  1.3464 +/**
  1.3465 +Renders a currency value as text, based on the locale's currency and numeric 
  1.3466 +format settings. 
  1.3467 +
  1.3468 +These settings include the currency symbol, the symbol's position and the 
  1.3469 +way negative values are formatted. If aText is not long enough to hold the 
  1.3470 +formatted currency value, the overflow handler's Overflow() function is called.
  1.3471 +
  1.3472 +@param aText            On return, contains the currency value as text,
  1.3473 +                        formatted according to the locale's currency format
  1.3474 +                        settings.
  1.3475 +@param aOverflowHandler An object derived from TDesOverflow which handles
  1.3476 +                        descriptor overflows.
  1.3477 +@param aAmount          The currency value to be formatted.
  1.3478 +*/
  1.3479 +	{
  1.3480 +	TInt64 aLongerInt(aAmount);
  1.3481 +	FormatCurrency(aText, aOverflowHandler, aLongerInt); 
  1.3482 +	}
  1.3483 +
  1.3484 +
  1.3485 +
  1.3486 +
  1.3487 +EXPORT_C void TLocale::FormatCurrency(TDes& aText, TDesOverflow& aOverflowHandler, TInt64 aAmount)
  1.3488 +/**
  1.3489 +Renders a currency value as text, based on the locale's currency and numeric 
  1.3490 +format settings. 
  1.3491 +
  1.3492 +These settings include the currency symbol, the symbol's position and the 
  1.3493 +way negative values are formatted. If aText is not long enough to hold the 
  1.3494 +formatted currency value, the overflow handler's Overflow() function is called.
  1.3495 +
  1.3496 +@param aText            On return, contains the currency value as text,
  1.3497 +                        formatted according to the locale's currency format
  1.3498 +                        settings.
  1.3499 +@param aOverflowHandler An object derived from TDesOverflow which handles
  1.3500 +                        descriptor  overflows.
  1.3501 +@param aAmount          The currency value to be formatted.
  1.3502 +*/
  1.3503 +	{
  1.3504 +	// aAmount is in cents (or equivalent) rather than dollars (or equivalent)
  1.3505 +	const TBool amountIsNegative=(aAmount<0);
  1.3506 +	if (amountIsNegative)
  1.3507 +		{
  1.3508 +		aAmount=-aAmount;
  1.3509 +		}
  1.3510 +	aText.Num(aAmount, EDecimal);
  1.3511 +	const TInt currencyDecimalPlaces=CurrencyDecimalPlaces();
  1.3512 +	TInt positionOfDecimalSeparator=aText.Length();
  1.3513 +	if (currencyDecimalPlaces>0)
  1.3514 +		{
  1.3515 +		while (positionOfDecimalSeparator <= currencyDecimalPlaces)
  1.3516 +			{
  1.3517 +			if (aText.Length() == aText.MaxLength())
  1.3518 +				{
  1.3519 +				aOverflowHandler.Overflow(aText);
  1.3520 +				return;
  1.3521 +				}
  1.3522 +			aText.Insert(0,KLitZeroPad);
  1.3523 +			++positionOfDecimalSeparator;
  1.3524 +			}
  1.3525 +		positionOfDecimalSeparator=aText.Length();
  1.3526 +		positionOfDecimalSeparator-=currencyDecimalPlaces;
  1.3527 +		TBuf<1> decimalSeparator;
  1.3528 +		decimalSeparator.Append(DecimalSeparator());
  1.3529 +		if (aText.Length() == aText.MaxLength())
  1.3530 +			{
  1.3531 +			aOverflowHandler.Overflow(aText);
  1.3532 +			return;
  1.3533 +			}
  1.3534 +		aText.Insert(positionOfDecimalSeparator, decimalSeparator);
  1.3535 +		}
  1.3536 +	if (CurrencyTriadsAllowed())
  1.3537 +		{
  1.3538 +		TBuf<1> thousandsSeparator;
  1.3539 +		thousandsSeparator.Append(ThousandsSeparator());
  1.3540 +		TInt numberOfThousandsSeparator = positionOfDecimalSeparator/3;
  1.3541 +		if ((aText.Length()+numberOfThousandsSeparator) > aText.MaxLength())
  1.3542 +			{
  1.3543 +			aOverflowHandler.Overflow(aText);
  1.3544 +			return;
  1.3545 +			}
  1.3546 +		for (TInt i=positionOfDecimalSeparator-3; i>0; i-=3)
  1.3547 +			{
  1.3548 +			aText.Insert(i, thousandsSeparator);
  1.3549 +			}
  1.3550 +		}
  1.3551 +	TInt positionToInsertCurrencySymbol = 0; 
  1.3552 +	switch (CurrencySymbolPosition())
  1.3553 +		{
  1.3554 +		case ELocaleBefore:
  1.3555 +			{
  1.3556 +			if ((amountIsNegative) && (NegativeCurrencySymbolOpposite()))
  1.3557 +				{
  1.3558 +				positionToInsertCurrencySymbol=aText.Length();
  1.3559 +				}
  1.3560 +			else
  1.3561 +				positionToInsertCurrencySymbol=0;
  1.3562 +			}
  1.3563 +			break;
  1.3564 +		case ELocaleAfter:
  1.3565 +			{
  1.3566 +			if ((amountIsNegative) && (NegativeCurrencySymbolOpposite()))
  1.3567 +				{
  1.3568 +				positionToInsertCurrencySymbol=0;
  1.3569 +				}
  1.3570 +			else
  1.3571 +				positionToInsertCurrencySymbol=aText.Length();
  1.3572 +			}
  1.3573 +			break;
  1.3574 +		default:
  1.3575 +			Panic(ETRegionOutOfRange);
  1.3576 +			break;
  1.3577 +		}
  1.3578 +	if (CurrencySpaceBetween())
  1.3579 +		{
  1.3580 +		if (aText.Length() == aText.MaxLength())
  1.3581 +			{
  1.3582 +			aOverflowHandler.Overflow(aText);
  1.3583 +			return;
  1.3584 +			}
  1.3585 +		if ((amountIsNegative) && (NegativeLoseSpace()))
  1.3586 +			{
  1.3587 +			// don't add the space
  1.3588 +			}
  1.3589 +		else
  1.3590 +			{
  1.3591 +			aText.Insert(positionToInsertCurrencySymbol, KLitSpace); 
  1.3592 +			if (positionToInsertCurrencySymbol>0)
  1.3593 +				{
  1.3594 +				++positionToInsertCurrencySymbol;
  1.3595 +				}
  1.3596 +			}
  1.3597 +		}
  1.3598 +	TCurrencySymbol theCurrencySymbol;
  1.3599 +	if ((aText.Length()+theCurrencySymbol.Length()) > aText.MaxLength())
  1.3600 +		{
  1.3601 +		aOverflowHandler.Overflow(aText);
  1.3602 +		return;
  1.3603 +		}
  1.3604 +	aText.Insert(positionToInsertCurrencySymbol,theCurrencySymbol);
  1.3605 +	if (amountIsNegative)
  1.3606 +		{
  1.3607 +		TInt positionToInsertInterveningMinusSign = 0;
  1.3608 +		if ((CurrencySpaceBetween()) && !(NegativeLoseSpace()))
  1.3609 +			{
  1.3610 +			if (positionToInsertCurrencySymbol>0)
  1.3611 +				{
  1.3612 +				positionToInsertInterveningMinusSign = positionToInsertCurrencySymbol-1;
  1.3613 +				}
  1.3614 +			else
  1.3615 +				{
  1.3616 +				positionToInsertInterveningMinusSign = theCurrencySymbol.Length()+1;
  1.3617 +				}
  1.3618 +			}
  1.3619 +		else
  1.3620 +			{
  1.3621 +			if (positionToInsertCurrencySymbol>0)
  1.3622 +				{
  1.3623 +				positionToInsertInterveningMinusSign = positionToInsertCurrencySymbol;
  1.3624 +				}
  1.3625 +			else
  1.3626 +				{
  1.3627 +				positionToInsertInterveningMinusSign = theCurrencySymbol.Length();
  1.3628 +				}
  1.3629 +			}
  1.3630 +		switch (NegativeCurrencyFormat())
  1.3631 +			{
  1.3632 +			case EInBrackets:
  1.3633 +				{
  1.3634 +				if ((aText.Length()+2) > aText.MaxLength())
  1.3635 +					{
  1.3636 +					aOverflowHandler.Overflow(aText);
  1.3637 +					return;
  1.3638 +					}
  1.3639 +				aText.Insert(0, KLitOpeningBracket);
  1.3640 +				aText.Append(')');
  1.3641 +				}
  1.3642 +				break;
  1.3643 +			case ELeadingMinusSign:
  1.3644 +				{
  1.3645 +				if (aText.Length() == aText.MaxLength())
  1.3646 +					{
  1.3647 +					aOverflowHandler.Overflow(aText);
  1.3648 +					return;
  1.3649 +					}
  1.3650 +				aText.Insert(0, KLitMinusSign);
  1.3651 +				}
  1.3652 +				break;
  1.3653 +			case ETrailingMinusSign:
  1.3654 +				{
  1.3655 +				if (aText.Length() == aText.MaxLength())
  1.3656 +					{
  1.3657 +					aOverflowHandler.Overflow(aText);
  1.3658 +					return;
  1.3659 +					}
  1.3660 +				aText.Append(KLitMinusSign);
  1.3661 +				}
  1.3662 +				break;
  1.3663 +			case EInterveningMinusSign:
  1.3664 +				{
  1.3665 +				if (aText.Length() == aText.MaxLength())
  1.3666 +					{
  1.3667 +					aOverflowHandler.Overflow(aText);
  1.3668 +					return;
  1.3669 +					}
  1.3670 +				aText.Insert(positionToInsertInterveningMinusSign, KLitMinusSign);
  1.3671 +				}
  1.3672 +				break;
  1.3673 +			default:
  1.3674 +				Panic(ETRegionOutOfRange);
  1.3675 +				break;
  1.3676 +			}
  1.3677 +		}
  1.3678 +	}
  1.3679 +	
  1.3680 +
  1.3681 +EXPORT_C void TLocaleMessageText::Set(TLocaleMessage aMsgNo)
  1.3682 +//
  1.3683 +// Get some text from Locale
  1.3684 +//
  1.3685 +	{
  1.3686 +	if(TUint(aMsgNo) < ELocaleMessages_LastMsg)
  1.3687 +		{
  1.3688 +		SLocaleLanguage localeLanguage;
  1.3689 +		LocaleLanguageGet(localeLanguage);
  1.3690 +		Copy((reinterpret_cast<const TText* const*>(localeLanguage.iMsgTable))[aMsgNo]);
  1.3691 +		}
  1.3692 +	else
  1.3693 +		SetLength(0);
  1.3694 +	}
  1.3695 +
  1.3696 +
  1.3697 +
  1.3698 +
  1.3699 +EXPORT_C TInt TFindServer::Next(TFullName &aResult)
  1.3700 +/**
  1.3701 +Gets the full name of the next server which matches the match pattern.
  1.3702 +
  1.3703 +@param aResult A reference to a descriptor with a defined maximum length.
  1.3704 +               If a matching server is found, its full name is set into
  1.3705 +               this descriptor. If no matching server is found,
  1.3706 +               the descriptor length is set to zero.
  1.3707 +               
  1.3708 +@return KErrNone if a matching server is found, KErrNotFound otherwise.
  1.3709 +*/
  1.3710 +	{
  1.3711 +	return NextObject(aResult,EServer);
  1.3712 +	}
  1.3713 +
  1.3714 +
  1.3715 +
  1.3716 +
  1.3717 +EXPORT_C void RServer2::Receive(RMessage2& aMessage, TRequestStatus &aStatus)
  1.3718 +//
  1.3719 +// Receive a message from the server asynchronously.
  1.3720 +//
  1.3721 +	{
  1.3722 +
  1.3723 +	aStatus=KRequestPending;
  1.3724 +	Exec::ServerReceive(iHandle, aStatus, &aMessage);
  1.3725 +	}
  1.3726 +
  1.3727 +EXPORT_C void RServer2::Cancel()
  1.3728 +//
  1.3729 +// Cancel a pending message receive.
  1.3730 +//
  1.3731 +	{
  1.3732 +
  1.3733 +	Exec::ServerCancel(iHandle);
  1.3734 +	}
  1.3735 +
  1.3736 +
  1.3737 +
  1.3738 +
  1.3739 +EXPORT_C TInt TFindMutex::Next(TFullName &aResult)
  1.3740 +/**
  1.3741 +Finds the next global mutex whose full name matches the match pattern.
  1.3742 +
  1.3743 +If a global mutex with a matching name is found, the function copies its full 
  1.3744 +name into the specified descriptor. It also saves the find-handle associated 
  1.3745 +with the global mutex into the TFindHandleBase part of this object.
  1.3746 +
  1.3747 +@param aResult A reference to a descriptor with a defined maximum length. 
  1.3748 +               If a matching global mutex is found, its full name is set
  1.3749 +               into this descriptor. 
  1.3750 +               If no matching global mutex is found, the descriptor length
  1.3751 +               is set to zero.
  1.3752 +               
  1.3753 +@return KErrNone if a matching global mutex is found;
  1.3754 +        KErrNotFound otherwise.
  1.3755 +*/
  1.3756 +	{
  1.3757 +	return NextObject(aResult,EMutex);
  1.3758 +	}
  1.3759 +
  1.3760 +
  1.3761 +
  1.3762 +
  1.3763 +/**
  1.3764 +Acquire the mutex, waiting for it to become free if necessary.
  1.3765 +
  1.3766 +This function checks if the mutex is currently held. If not the mutex is marked
  1.3767 +as held by the current thread and the call returns immediately. If the mutex is
  1.3768 +held by another thread the current thread will suspend until the mutex becomes
  1.3769 +free. If the mutex is already held by the current thread a count is maintained
  1.3770 +of how many times the thread has acquired the mutex.
  1.3771 +*/
  1.3772 +EXPORT_C void RMutex::Wait()
  1.3773 +	{
  1.3774 +
  1.3775 +	Exec::MutexWait(iHandle);
  1.3776 +	}
  1.3777 +
  1.3778 +
  1.3779 +
  1.3780 +
  1.3781 +/**
  1.3782 +Release the mutex.
  1.3783 +
  1.3784 +This function decrements the count of how many times the current thread has
  1.3785 +acquired this mutex. If the count is now zero the mutex is marked as free and,
  1.3786 +if any other threads are waiting for the mutex to become free, the highest
  1.3787 +priority among those is made ready to run. However the mutex is not marked as
  1.3788 +held by any thread - the thread which has just been awakened must actually run
  1.3789 +in order to acquire the mutex.
  1.3790 +
  1.3791 +@pre The mutex must previously have been acquired by the current thread calling
  1.3792 +Wait().
  1.3793 +
  1.3794 +@panic KERN-EXEC 1 If the mutex has not previously been acquired by the current
  1.3795 +thread calling Wait().
  1.3796 +*/
  1.3797 +EXPORT_C void RMutex::Signal()
  1.3798 +	{
  1.3799 +
  1.3800 +	Exec::MutexSignal(iHandle);
  1.3801 +	}
  1.3802 +
  1.3803 +
  1.3804 +
  1.3805 +/**
  1.3806 +Test if this mutex is held by the current thread.
  1.3807 +@return True if the current thread has waited on the mutex, false otherwise.
  1.3808 +*/
  1.3809 +EXPORT_C TBool RMutex::IsHeld()
  1.3810 +	{
  1.3811 +	return Exec::MutexIsHeld(iHandle);
  1.3812 +	}
  1.3813 +
  1.3814 +
  1.3815 +/** Wait on a condition variable
  1.3816 +
  1.3817 +This call releases the specified mutex then atomically blocks the current
  1.3818 +thread on this condition variable. The atomicity here is with respect to the
  1.3819 +condition variable and mutex concerned. Specifically if the condition variable
  1.3820 +is signalled at any time after the mutex is released then this thread will be
  1.3821 +awakened. Once the thread has awakened it will reacquire the specified mutex
  1.3822 +before this call returns (except in the case where the condition variable has
  1.3823 +been deleted).
  1.3824 +
  1.3825 +The usage pattern for this is as follows:
  1.3826 +
  1.3827 +@code
  1.3828 +	mutex.Wait();
  1.3829 +	while(!CONDITION)
  1.3830 +		condvar.Wait(mutex);
  1.3831 +	STATEMENTS;
  1.3832 +	mutex.Signal();
  1.3833 +@endcode
  1.3834 +
  1.3835 +where CONDITION is an arbitrary condition involving any number of user-side
  1.3836 +variables whose integrity is protected by the mutex.
  1.3837 +
  1.3838 +It is necessary to loop while testing the condition because there is **no** guarantee
  1.3839 +that the condition has been satisfied when the condition variable is signalled.
  1.3840 +Different threads may be waiting on different conditions or the condition may
  1.3841 +have already been absorbed by another thread. All that can be said is that the
  1.3842 +thread will awaken whenever something happens which **might** affect the condition.
  1.3843 +
  1.3844 +It needs to be stressed that if:
  1.3845 +
  1.3846 +@code
  1.3847 +condvar.Wait(mutex);
  1.3848 +@endcode
  1.3849 +
  1.3850 +completes, it does not necessarily mean that the condition is yet satisfied, hence the necessity for the loop.
  1.3851 +
  1.3852 +@param	aMutex		The mutex to be released and reacquired.
  1.3853 +@return	KErrNone	if the condition variable has been signalled.
  1.3854 +		KErrInUse	if another thread is already waiting on this condition
  1.3855 +					variable in conjunction with a different mutex.
  1.3856 +		KErrGeneral	if the condition variable is deleted.
  1.3857 +
  1.3858 +@pre	The specified mutex is held by the current thread.
  1.3859 +@post	The specified mutex is held by the current thread unless the return
  1.3860 +		value is KErrGeneral in which case the condition variable no longer
  1.3861 +		exists.
  1.3862 +
  1.3863 +@panic	KERN-EXEC 0 if either the condition variable or mutex handles are not
  1.3864 +		valid.
  1.3865 +@panic	KERN-EXEC 54 if the current thread does not hold the specified mutex.
  1.3866 +
  1.3867 +@see	RCondVar::Signal()
  1.3868 +@see	RCondVar::Broadcast()
  1.3869 +*/
  1.3870 +EXPORT_C TInt RCondVar::Wait(RMutex& aMutex)
  1.3871 +	{
  1.3872 +	return Exec::CondVarWait(iHandle, aMutex.Handle(), 0);
  1.3873 +	}
  1.3874 +
  1.3875 +
  1.3876 +
  1.3877 +/** Wait on a condition variable with timeout
  1.3878 +
  1.3879 +This is the same as RCondVar::Wait(RMutex) except that there is a time limit on
  1.3880 +how long the current thread will block while waiting for the condition variable.
  1.3881 +
  1.3882 +@param	aMutex		The mutex to be released and reacquired.
  1.3883 +@param	aTimeout	The maximum time to wait in microseconds.
  1.3884 +					0 means no maximum.
  1.3885 +@return	KErrNone	if the condition variable has been signalled.
  1.3886 +		KErrInUse	if another thread is already waiting on this condition
  1.3887 +					variable in conjunction with a different mutex.
  1.3888 +		KErrGeneral	if the condition variable is deleted.
  1.3889 +		KErrTimedOut if the timeout expired before the condition variable was
  1.3890 +					signalled.
  1.3891 +
  1.3892 +@pre	The specified mutex is held by the current thread.
  1.3893 +@post	The specified mutex is held by the current thread unless the return
  1.3894 +		value is KErrGeneral in which case the condition variable no longer
  1.3895 +		exists.
  1.3896 +
  1.3897 +@panic	KERN-EXEC 0 if either the condition variable or mutex handles are not
  1.3898 +		valid.
  1.3899 +@panic	KERN-EXEC 54 if the current thread does not hold the specified mutex.
  1.3900 +
  1.3901 +@see	RCondVar::Wait(RMutex)
  1.3902 +*/
  1.3903 +EXPORT_C TInt RCondVar::TimedWait(RMutex& aMutex, TInt aTimeout)
  1.3904 +	{
  1.3905 +	return Exec::CondVarWait(iHandle, aMutex.Handle(), aTimeout);
  1.3906 +	}
  1.3907 +
  1.3908 +
  1.3909 +/** Signal a condition variable
  1.3910 +
  1.3911 +This unblocks a single thread which is currently blocked on the condition
  1.3912 +variable. The highest priority waiting thread which is not explicitly suspended
  1.3913 +will be the one unblocked. If there are no threads currently waiting this call
  1.3914 +does nothing.
  1.3915 +
  1.3916 +It is not required that any mutex is held when calling this function but it is
  1.3917 +recommended that the mutex associated with the condition variable is held since
  1.3918 +otherwise a race condition can result from the condition variable being signalled
  1.3919 +just after the waiting thread testing the condition and before it calls Wait().
  1.3920 +
  1.3921 +*/
  1.3922 +EXPORT_C void RCondVar::Signal()
  1.3923 +	{
  1.3924 +	Exec::CondVarSignal(iHandle);
  1.3925 +	}
  1.3926 +
  1.3927 +
  1.3928 +
  1.3929 +/** Broadcast to a condition variable
  1.3930 +
  1.3931 +This unblocks all threads which are currently blocked on the condition
  1.3932 +variable. If there are no threads currently waiting this call does nothing.
  1.3933 +
  1.3934 +It is not required that any mutex is held when calling this function but it is
  1.3935 +recommended that the mutex associated with the condition variable is held since
  1.3936 +otherwise a race condition can result from the condition variable being signalled
  1.3937 +just after the waiting thread testing the condition and before it calls Wait().
  1.3938 +
  1.3939 +*/
  1.3940 +EXPORT_C void RCondVar::Broadcast()
  1.3941 +	{
  1.3942 +	Exec::CondVarBroadcast(iHandle);
  1.3943 +	}
  1.3944 +
  1.3945 +
  1.3946 +
  1.3947 +
  1.3948 +EXPORT_C TInt TFindProcess::Next(TFullName &aResult)
  1.3949 +/**
  1.3950 +Gets the full name of the next process which matches the match pattern.
  1.3951 +
  1.3952 +@param aResult A reference to a TBuf descriptor with a defined maximum length.
  1.3953 +               If a matching process is found, its full name is set into
  1.3954 +               this descriptor. If no matching process is found, the descriptor
  1.3955 +               length is set to zero.
  1.3956 +
  1.3957 +@return KErrNone if successful, otherwise one of the other  system-wide error
  1.3958 +        codes.
  1.3959 +*/
  1.3960 +	{
  1.3961 +	return NextObject(aResult,EProcess);
  1.3962 +	}
  1.3963 +
  1.3964 +
  1.3965 +
  1.3966 +
  1.3967 +EXPORT_C TUidType RProcess::Type() const
  1.3968 +/**
  1.3969 +Gets the Uid type associated with the process. 
  1.3970 +
  1.3971 +@return A reference to a TUidType object containing the process type.
  1.3972 +*/
  1.3973 +	{
  1.3974 +
  1.3975 +	TUidType u;
  1.3976 +	Exec::ProcessType(iHandle,u);
  1.3977 +	return(u);
  1.3978 +	}
  1.3979 +
  1.3980 +
  1.3981 +
  1.3982 +
  1.3983 +EXPORT_C TProcessId RProcess::Id() const
  1.3984 +/**
  1.3985 +Gets the Id of this process.
  1.3986 +
  1.3987 +@return The Id of this process.
  1.3988 +*/
  1.3989 +	{
  1.3990 +
  1.3991 +	return TProcessId( (TUint)Exec::ProcessId(iHandle) );
  1.3992 +	}
  1.3993 +
  1.3994 +
  1.3995 +
  1.3996 +
  1.3997 +EXPORT_C void RProcess::Resume()
  1.3998 +/**
  1.3999 +Makes the first thread in the process eligible for execution.
  1.4000 +
  1.4001 +@panic KERN-EXEC 32 if the process is not yet fully loaded.
  1.4002 +
  1.4003 +@see RThread::Resume()
  1.4004 +*/
  1.4005 +	{
  1.4006 +
  1.4007 +	Exec::ProcessResume(iHandle);
  1.4008 +	}
  1.4009 +
  1.4010 +
  1.4011 +
  1.4012 +EXPORT_C TFileName RProcess::FileName() const
  1.4013 +/**
  1.4014 +Gets a copy of the full path name of the loaded executable on which this 
  1.4015 +process is based.
  1.4016 +
  1.4017 +This is the file name which is passed to the Create() member function of this 
  1.4018 +RProcess.
  1.4019 +
  1.4020 +@return A TBuf descriptor with a defined maximum length containing the full 
  1.4021 +        path name of the file.
  1.4022 +        
  1.4023 +@see RProcess::Create()
  1.4024 +*/
  1.4025 +	{
  1.4026 +
  1.4027 +	TFileName n;
  1.4028 +	TPtr8 n8(((TUint8*)n.Ptr()) + KMaxFileName, KMaxFileName);
  1.4029 +	Exec::ProcessFileName(iHandle,n8);
  1.4030 +	n.Copy(n8);
  1.4031 +	return(n);
  1.4032 +	}
  1.4033 +
  1.4034 +
  1.4035 +
  1.4036 +
  1.4037 +EXPORT_C void User::CommandLine(TDes &aCommand)
  1.4038 +/**
  1.4039 +Gets a copy of the data which is passed as an argument to the thread function
  1.4040 +of the current process's main thread when it is first scheduled to run.
  1.4041 +
  1.4042 +@param aCommand A modifiable descriptor supplied by the caller into which the
  1.4043 +                argument data is put. The descriptor must be big enough to
  1.4044 +                contain the expected data, otherwise the function raises
  1.4045 +                a panic.
  1.4046 +
  1.4047 +@see User::CommandLineLength()
  1.4048 +*/
  1.4049 +	{
  1.4050 +	TPtr8 aCommand8((TUint8*)aCommand.Ptr(),aCommand.MaxLength()<<1);
  1.4051 +	Exec::ProcessCommandLine(KCurrentProcessHandle,aCommand8);
  1.4052 +	aCommand.SetLength(aCommand8.Length()>>1);
  1.4053 +	}
  1.4054 +
  1.4055 +
  1.4056 +
  1.4057 +
  1.4058 +EXPORT_C TInt User::CommandLineLength()
  1.4059 +/**
  1.4060 +Gets the length of the data which is passed as an argument to the thread
  1.4061 +function of the current process's main thread when it is first scheduled
  1.4062 +to run.
  1.4063 +
  1.4064 +@return The length of the argument data.
  1.4065 +*/
  1.4066 +	{
  1.4067 +	return Exec::ProcessCommandLineLength(KCurrentProcessHandle);
  1.4068 +	}
  1.4069 +
  1.4070 +
  1.4071 +
  1.4072 +
  1.4073 +EXPORT_C TExitType RProcess::ExitType() const
  1.4074 +/**
  1.4075 +Tests whether the process has ended and, if it has ended, return how it ended.
  1.4076 +
  1.4077 +This information allows the caller to distinguish between normal termination 
  1.4078 +and a panic.
  1.4079 +
  1.4080 +@return An enumeration whose enumerators describe how the process has ended.
  1.4081 +*/
  1.4082 +	{
  1.4083 +
  1.4084 +	return(Exec::ProcessExitType(iHandle));
  1.4085 +	}
  1.4086 +
  1.4087 +
  1.4088 +
  1.4089 +
  1.4090 +EXPORT_C TInt RProcess::ExitReason() const
  1.4091 +/** 
  1.4092 +Gets the specific reason associated with the end of this process.
  1.4093 +
  1.4094 +The reason number together with the category name is a way of distinguishing
  1.4095 +between different causes of process termination.
  1.4096 +
  1.4097 +If the process has panicked, this value is the panic number. If the process 
  1.4098 +has ended as a result of a call to Kill(), then the value is the one supplied 
  1.4099 +by Kill().
  1.4100 +
  1.4101 +If the process has not ended, then the returned value is zero.
  1.4102 +
  1.4103 +@return The reason associated with the end of the process.
  1.4104 +
  1.4105 +@see RProcess::Kill()
  1.4106 +*/
  1.4107 +	{
  1.4108 +
  1.4109 +	return(Exec::ProcessExitReason(iHandle));
  1.4110 +	}
  1.4111 +
  1.4112 +
  1.4113 +
  1.4114 +
  1.4115 +EXPORT_C TExitCategoryName RProcess::ExitCategory() const
  1.4116 +/**
  1.4117 +Gets the name of the category associated with the end of the process.
  1.4118 +
  1.4119 +The category name together with the reason number is a way of distinguishing
  1.4120 +between different causes of process termination.
  1.4121 +
  1.4122 +If the process has panicked, the category name is the panic category name; 
  1.4123 +for example, E32USER-CBase or KERN-EXEC. If the process has ended as a result 
  1.4124 +of a call to Kill(), then the category name is Kill.
  1.4125 +
  1.4126 +If the process has not ended, then the category name is empty, i.e. the length 
  1.4127 +of the category name is zero.
  1.4128 +
  1.4129 +@return A descriptor with a defined maximum length containing the 
  1.4130 +        name of the category associated with the end of the process.
  1.4131 +        
  1.4132 +@see RProcess::Kill()
  1.4133 +*/
  1.4134 +	{
  1.4135 +
  1.4136 +	TExitCategoryName n;
  1.4137 +	TPtr8 n8(((TUint8*)n.Ptr()) + KMaxExitCategoryName, KMaxExitCategoryName);
  1.4138 +	Exec::ProcessExitCategory(iHandle,n8);
  1.4139 +	n.Copy(n8);
  1.4140 +	return(n);
  1.4141 +	}
  1.4142 +
  1.4143 +
  1.4144 +
  1.4145 +
  1.4146 +EXPORT_C TProcessPriority RProcess::Priority() const
  1.4147 +/**
  1.4148 +Gets the priority of this process.
  1.4149 +
  1.4150 +@return One of the TProcessPriority enumerator values.
  1.4151 +*/
  1.4152 +	{
  1.4153 +
  1.4154 +	return(Exec::ProcessPriority(iHandle));
  1.4155 +	}
  1.4156 +
  1.4157 +
  1.4158 +
  1.4159 +
  1.4160 +EXPORT_C TInt RProcess::SetPriority(TProcessPriority aPriority) const
  1.4161 +/**
  1.4162 +Sets the priority of this process to one of the values defined by theTProcessPriority 
  1.4163 +enumeration. The priority can be set to one of the four values:
  1.4164 +
  1.4165 +EPriorityLow
  1.4166 +
  1.4167 +EPriorityBackground
  1.4168 +
  1.4169 +EPriorityForeground
  1.4170 +
  1.4171 +EPriorityHigh
  1.4172 +
  1.4173 +The absolute priority of all threads owned by the process (and all threads 
  1.4174 +owned by those threads etc.) are re-calculated.
  1.4175 +
  1.4176 +Notes:
  1.4177 +
  1.4178 +The priority values EPriorityWindowServer, EPriorityFileServer, EPriorityRealTimeServer 
  1.4179 +and EPrioritySupervisor are internal to Symbian OS and any attempt to explicitly 
  1.4180 +set any of these priority values causes a KERN-EXEC 14 panic to be raised.
  1.4181 +
  1.4182 +Any attempt to set the priority of a process which is protected and is different 
  1.4183 +from the process owning the thread which invokes this function, causes a KERN-EXEC 
  1.4184 +1 panic to be raised.
  1.4185 +
  1.4186 +A process can set its own priority whether it is protected or not.
  1.4187 +
  1.4188 +@param aPriority The priority value.
  1.4189 +
  1.4190 +@return KErrNone, if successful; otherwise one of the other system-wide
  1.4191 +        error codes.
  1.4192 +
  1.4193 +*/
  1.4194 +	{
  1.4195 +
  1.4196 +	return Exec::ProcessSetPriority(iHandle,aPriority);
  1.4197 +	}
  1.4198 +
  1.4199 +
  1.4200 +
  1.4201 +
  1.4202 +/**
  1.4203 +Tests whether "Just In Time" debugging is enabled or not for this process.
  1.4204 +
  1.4205 +@return True, when "Just In Time" debugging is enabled. False otherwise.
  1.4206 +@see RProcess::SetJustInTime
  1.4207 +*/
  1.4208 +
  1.4209 +EXPORT_C TBool RProcess::JustInTime() const
  1.4210 +	{
  1.4211 +
  1.4212 +	return (Exec::ProcessFlags(iHandle) & KProcessFlagJustInTime) != 0;
  1.4213 +	}
  1.4214 +
  1.4215 +
  1.4216 +/**
  1.4217 +Enables or disables "Just In Time" debugging for this process.
  1.4218 +This will only have an effect when running on the emulator.
  1.4219 +
  1.4220 +"Just In Time" debugging catches a thread just before it executes a panic
  1.4221 +or exception routine.  Capturing a thread early, before it is terminated, 
  1.4222 +allows the developer to more closely inspect what went wrong, before the 
  1.4223 +kernel removes the thread.  In some cases, the developer can modify context,
  1.4224 +program counter, and variables to recover the thread.  This is only possible
  1.4225 +on the emulator.
  1.4226 +
  1.4227 +By default, "Just In Time" debugging is enabled.
  1.4228 +
  1.4229 +@param aBoolean ETrue, to enable just-in-time debugging.
  1.4230 +				EFalse, to disable just-in-time debugging.
  1.4231 +*/
  1.4232 +EXPORT_C void RProcess::SetJustInTime(TBool aState) const
  1.4233 +	{
  1.4234 +
  1.4235 +	TUint32 set = aState ? KProcessFlagJustInTime : 0;
  1.4236 +	Exec::ProcessSetFlags(iHandle, KProcessFlagJustInTime, set);
  1.4237 +	}
  1.4238 +
  1.4239 +
  1.4240 +
  1.4241 +
  1.4242 +EXPORT_C TInt RProcess::SecureApi(TInt /*aState*/)
  1.4243 +	{
  1.4244 +	return ESecureApiOn;
  1.4245 +	}
  1.4246 +
  1.4247 +EXPORT_C TInt RProcess::DataCaging(TInt /*aState*/)
  1.4248 +	{
  1.4249 +	return EDataCagingOn;
  1.4250 +	}
  1.4251 +
  1.4252 +
  1.4253 +
  1.4254 +EXPORT_C TInt RProcess::GetMemoryInfo(TModuleMemoryInfo& aInfo) const
  1.4255 +/**
  1.4256 +Gets the size and base address of the code and various data
  1.4257 +sections of the process.
  1.4258 +
  1.4259 +The run addresses are also returned.
  1.4260 +
  1.4261 +@param aInfo On successful return, contains the base address and size of the 
  1.4262 +             sections.
  1.4263 +             
  1.4264 +@return KErrNone, if successful; otherwise one of the other system wide error 
  1.4265 +        codes.
  1.4266 +*/
  1.4267 +	{
  1.4268 +
  1.4269 +	return Exec::ProcessGetMemoryInfo(iHandle,aInfo);
  1.4270 +	}
  1.4271 +	
  1.4272 +
  1.4273 +EXPORT_C TAny* RProcess::ExeExportData(void)
  1.4274 +/**
  1.4275 +Retrieves pointer to named symbol export data from the current process, i.e. the
  1.4276 +process calling this function.
  1.4277 +             
  1.4278 +@return Pointer to export data when it is present, NULL if export data not found
  1.4279 +@internalTechnology
  1.4280 +@released
  1.4281 +*/
  1.4282 +	{
  1.4283 +
  1.4284 +	return Exec::ProcessExeExportData();
  1.4285 +	}
  1.4286 +
  1.4287 +
  1.4288 +
  1.4289 +EXPORT_C TInt TFindSemaphore::Next(TFullName &aResult)
  1.4290 +/**
  1.4291 +Finds the next global semaphore whose full name matches the match pattern.
  1.4292 +
  1.4293 +If a global semaphore with a matching name is found, the function copies its 
  1.4294 +full name into the descriptor aResult. It also saves the find-handle associated 
  1.4295 +with the global semaphore into the TFindHandleBase part of this TFindSemaphore 
  1.4296 +object.
  1.4297 +
  1.4298 +@param aResult A reference to a TBuf descriptor with a defined maximum length. 
  1.4299 +               If a matching global semaphore is found, its full name is set
  1.4300 +               into this descriptor. 
  1.4301 +               If no matching global semaphore is found, the descriptor length
  1.4302 +               is set to zero. 
  1.4303 +               
  1.4304 +@return KErrNone if a matching global semaphore is found;
  1.4305 +        KErrNotFound otherwise.
  1.4306 +*/
  1.4307 +	{
  1.4308 +	return NextObject(aResult,ESemaphore);
  1.4309 +	}
  1.4310 +
  1.4311 +
  1.4312 +
  1.4313 +
  1.4314 +EXPORT_C void RSemaphore::Wait()
  1.4315 +/**
  1.4316 +Waits for a signal on the semaphore.
  1.4317 +
  1.4318 +The function decrements the semaphore count by one and returns immediately 
  1.4319 +if it is zero or positive.
  1.4320 +
  1.4321 +If the semaphore count is negative after being decremented, the calling thread is 
  1.4322 +added to a queue of threads maintained by this semaphore.
  1.4323 +
  1.4324 +The thread waits until the semaphore is signalled. More than one thread can 
  1.4325 +be waiting on a particular semaphore at a time. When there are multiple threads 
  1.4326 +waiting on a semaphore, they are released in priority order.
  1.4327 +
  1.4328 +If the semaphore is deleted, all threads waiting on that semaphore are released.
  1.4329 +*/
  1.4330 +	{
  1.4331 +
  1.4332 +	Exec::SemaphoreWait(iHandle, 0);
  1.4333 +	}
  1.4334 +
  1.4335 +
  1.4336 +
  1.4337 +
  1.4338 +EXPORT_C TInt RSemaphore::Wait(TInt aTimeout)
  1.4339 +/**
  1.4340 +Waits for a signal on the semaphore, or a timeout.
  1.4341 +
  1.4342 +@param aTimeout The timeout value in micoseconds
  1.4343 +
  1.4344 +@return KErrNone if the wait has completed normally.
  1.4345 +        KErrTimedOut if the timeout has expired.
  1.4346 +        KErrGeneral if the semaphore is being reset, i.e the semaphore
  1.4347 +        is about to  be deleted.
  1.4348 +        KErrArgument if aTimeout is negative;
  1.4349 +        otherwise one of the other system wide error codes.
  1.4350 +*/
  1.4351 +	{
  1.4352 +
  1.4353 +	return Exec::SemaphoreWait(iHandle, aTimeout);
  1.4354 +	}
  1.4355 +
  1.4356 +
  1.4357 +
  1.4358 +
  1.4359 +EXPORT_C void RSemaphore::Signal()
  1.4360 +/**
  1.4361 +Signals the semaphore once.
  1.4362 +
  1.4363 +The function increments the semaphore count by one. If the count was negative 
  1.4364 +before being incremented, the highest priority thread waiting on the semaphore's queue 
  1.4365 +of threads is removed from that queue and, provided that it is not suspended 
  1.4366 +for any other reason, is marked as ready to run.
  1.4367 +*/
  1.4368 +	{
  1.4369 +
  1.4370 +	Exec::SemaphoreSignal1(iHandle);
  1.4371 +	}
  1.4372 +
  1.4373 +
  1.4374 +
  1.4375 +
  1.4376 +EXPORT_C void RSemaphore::Signal(TInt aCount)
  1.4377 +/**
  1.4378 +Signals the semaphore one or more times.
  1.4379 +
  1.4380 +The function increments the semaphore count. If the count was negative 
  1.4381 +before being incremented, the highest priority thread waiting on the semaphore's queue 
  1.4382 +of threads is removed from that queue and, provided that it is not suspended 
  1.4383 +for any other reason, is marked as ready to run.
  1.4384 +
  1.4385 +@param aCount The number of times the semaphore is to be signalled.
  1.4386 +*/
  1.4387 +	{
  1.4388 +
  1.4389 +	__ASSERT_ALWAYS(aCount>=0,Panic(ESemSignalCountNegative));
  1.4390 +	Exec::SemaphoreSignalN(iHandle,aCount);
  1.4391 +	}
  1.4392 +
  1.4393 +
  1.4394 +
  1.4395 +
  1.4396 +EXPORT_C RCriticalSection::RCriticalSection()
  1.4397 +	: iBlocked(1)
  1.4398 +/**
  1.4399 +Default constructor.
  1.4400 +*/
  1.4401 +	{}
  1.4402 +
  1.4403 +
  1.4404 +
  1.4405 +
  1.4406 +EXPORT_C void RCriticalSection::Close()
  1.4407 +/**
  1.4408 +Closes the handle to the critical section.
  1.4409 +
  1.4410 +As a critical section object is implemented using a semaphore, this has the 
  1.4411 +effect of closing the handle to the semaphore.
  1.4412 +*/
  1.4413 +	{
  1.4414 +
  1.4415 +	RSemaphore::Close();
  1.4416 +	}
  1.4417 +
  1.4418 +
  1.4419 +
  1.4420 +
  1.4421 +EXPORT_C void RCriticalSection::Wait()
  1.4422 +/**
  1.4423 +Waits for the critical section to become free.
  1.4424 +
  1.4425 +If no other thread is in the critical section, control returns immediately 
  1.4426 +and the current thread can continue into the section.
  1.4427 +
  1.4428 +If another thread is already in the critical section, the current thread is 
  1.4429 +marked as waiting (on a semaphore); the current thread is added to a queue
  1.4430 +of threads maintained by this critical section.
  1.4431 +*/
  1.4432 +	{
  1.4433 +
  1.4434 +	if (__e32_atomic_add_acq32(&iBlocked, KMaxTUint32) != 1)
  1.4435 +		RSemaphore::Wait();
  1.4436 +	}
  1.4437 +
  1.4438 +
  1.4439 +
  1.4440 +
  1.4441 +EXPORT_C void RCriticalSection::Signal()
  1.4442 +/**
  1.4443 +Signals an exit from the critical section.
  1.4444 +
  1.4445 +A thread calls this function when it exits from the critical section.
  1.4446 +The first eligible thread waiting on the critical section's queue of threads
  1.4447 +is removed from that queue and, provided that it is not suspended for any other
  1.4448 +reason, is marked as ready to run. That thread will, therefore, be the next to
  1.4449 +proceed into the critical section.
  1.4450 +*/
  1.4451 +	{
  1.4452 +
  1.4453 +	__ASSERT_ALWAYS(iBlocked<1,Panic(ECriticalSectionStraySignal));
  1.4454 +	if (TInt(__e32_atomic_add_rel32(&iBlocked, 1)) < 0)
  1.4455 +		RSemaphore::Signal();
  1.4456 +	}
  1.4457 +
  1.4458 +
  1.4459 +
  1.4460 +
  1.4461 +EXPORT_C TInt TFindThread::Next(TFullName &aResult)
  1.4462 +/**
  1.4463 +Gets the full name of the next global thread which matches the match pattern.
  1.4464 +
  1.4465 +@param aResult A reference to a TBuf descriptor with a defined maximum length.
  1.4466 +               If a matching global thread is found, its full name is set into
  1.4467 +               this descriptor. If no matching global thread is found,
  1.4468 +               the descriptor length is set to zero.
  1.4469 +
  1.4470 +@return KErrNone if successful, otherwise one of the other system-wide error
  1.4471 +                 codes.
  1.4472 +*/
  1.4473 +	{
  1.4474 +	return NextObject(aResult,EThread);
  1.4475 +	}
  1.4476 +
  1.4477 +
  1.4478 +
  1.4479 +
  1.4480 +EXPORT_C TThreadId RThread::Id() const
  1.4481 +/**
  1.4482 +Gets the Id of this thread.
  1.4483 +
  1.4484 +@return The Id of this thread.
  1.4485 +*/
  1.4486 +	{
  1.4487 +
  1.4488 +	return TThreadId( (TUint)Exec::ThreadId(iHandle) );
  1.4489 +	}
  1.4490 +
  1.4491 +
  1.4492 +
  1.4493 +
  1.4494 +EXPORT_C void RThread::HandleCount(TInt& aProcessHandleCount, TInt& aThreadHandleCount) const
  1.4495 +/**
  1.4496 +Gets the number of handles open in this thread, and the number of handles open 
  1.4497 +in the process which owns this thread.
  1.4498 +
  1.4499 +@param aProcessHandleCount On return, contains the number of handles open in
  1.4500 +                           the process which owns this thread.
  1.4501 +@param aThreadHandleCount  On return, contains the number of handles open in
  1.4502 +                           this thread.
  1.4503 +*/
  1.4504 +	{
  1.4505 +
  1.4506 +	Exec::HandleCount(iHandle,aProcessHandleCount,aThreadHandleCount);
  1.4507 +	}
  1.4508 +
  1.4509 +
  1.4510 +
  1.4511 +
  1.4512 +EXPORT_C TExceptionHandler User::ExceptionHandler()
  1.4513 +/**
  1.4514 +Gets a pointer to the exception handler for the current thread.
  1.4515 +
  1.4516 +@return A pointer to the exception handler.
  1.4517 +*/
  1.4518 +	{
  1.4519 +	return(Exec::ExceptionHandler(KCurrentThreadHandle));
  1.4520 +	}
  1.4521 +
  1.4522 +
  1.4523 +
  1.4524 +
  1.4525 +EXPORT_C TInt User::SetExceptionHandler(TExceptionHandler aHandler,TUint32 aMask)
  1.4526 +/**
  1.4527 +Sets a new exception handler for the current thread. Note that the handler is not
  1.4528 +guaranteed to receive floating point exceptions (KExceptionFpe) when a hardware
  1.4529 +floating point implementation is in use - see User::SetFloatingPointMode for
  1.4530 +hardware floating point modes and whether they cause user-trappable exceptions.
  1.4531 +
  1.4532 +@param aHandler The new exception handler.
  1.4533 +@param aMask    One or more flags defining the exception categories which
  1.4534 +                the handler can handle.
  1.4535 +
  1.4536 +@return KErrNone if successful, otherwise another of the system-wide error codes.
  1.4537 +
  1.4538 +@see KExceptionAbort
  1.4539 +@see KExceptionKill
  1.4540 +@see KExceptionUserInterrupt
  1.4541 +@see KExceptionFpe
  1.4542 +@see KExceptionFault
  1.4543 +@see KExceptionInteger
  1.4544 +@see KExceptionDebug
  1.4545 +*/
  1.4546 +	{
  1.4547 +	return(Exec::SetExceptionHandler(KCurrentThreadHandle, aHandler, aMask));
  1.4548 +	}
  1.4549 +
  1.4550 +
  1.4551 +
  1.4552 +
  1.4553 +EXPORT_C void User::ModifyExceptionMask(TUint32 aClearMask, TUint32 aSetMask)
  1.4554 +/**
  1.4555 +Changes the set of exceptions which the current thread's exception
  1.4556 +handler can deal with.
  1.4557 +
  1.4558 +aClearMask is the set of flags defining the set of exceptions which the
  1.4559 +exception handler no longer deals with, while aSetMask is the set of flags
  1.4560 +defining the new set of exceptions to be set.
  1.4561 +
  1.4562 +Flag clearing is done before flag setting.
  1.4563 +
  1.4564 +@param  aClearMask One or more flags defining the exceptions which the current
  1.4565 +                   exception handler no longer deals with.
  1.4566 +@param  aSetMask   One or more flags defining the new set of exceptions which
  1.4567 +                   the current exception handler is to deal with.
  1.4568 +*/
  1.4569 +	{
  1.4570 +	Exec::ModifyExceptionMask(KCurrentThreadHandle, aClearMask, aSetMask);
  1.4571 +	}
  1.4572 +
  1.4573 +
  1.4574 +
  1.4575 +
  1.4576 +_LIT(KLitUserExec, "USER-EXEC");
  1.4577 +EXPORT_C TInt User::RaiseException(TExcType aType)
  1.4578 +/**
  1.4579 +Raises an exception of a specified type on the current thread.
  1.4580 +
  1.4581 +If the thread has an exception handler to handle this type of exception,
  1.4582 +then it is called.
  1.4583 +
  1.4584 +If the thread has no exception handler to handle this type of exception, then
  1.4585 +the function raises a USER-EXEC 3 panic.
  1.4586 +
  1.4587 +Note that exception handlers are executed in the context of the thread on which
  1.4588 +the exception is raised; control returns to the point of the exception. 
  1.4589 +
  1.4590 +@param aType The type of exception.
  1.4591 +
  1.4592 +@return KErrNone if successful, otherwise another of the system-wide
  1.4593 +        error codes.
  1.4594 +*/
  1.4595 +	{
  1.4596 +	if (Exec::IsExceptionHandled(KCurrentThreadHandle,aType,ETrue))
  1.4597 +		{
  1.4598 +		Exec::ThreadSetFlags(KCurrentThreadHandle, 0, KThreadFlagLastChance);
  1.4599 +		TUint32 type = aType;
  1.4600 +		User::HandleException(&type);
  1.4601 +		}
  1.4602 +	else
  1.4603 +		User::Panic(KLitUserExec, ECausedException);
  1.4604 +	return KErrNone;
  1.4605 +	}
  1.4606 +
  1.4607 +
  1.4608 +
  1.4609 +
  1.4610 +EXPORT_C TBool User::IsExceptionHandled(TExcType aType)
  1.4611 +/**
  1.4612 +Tests whether the specified exception type can be handled by the
  1.4613 +current thread.
  1.4614 +
  1.4615 +@param aType The type of exception.
  1.4616 +
  1.4617 +@return True, if the thread has an exception handler which can handle
  1.4618 +        an exception of type aType.
  1.4619 +        False, if the thread has no exception handler or the thread has
  1.4620 +        an exception handler which cannot handle the exception defined
  1.4621 +        by aType.
  1.4622 +*/
  1.4623 +	{
  1.4624 +	return (Exec::IsExceptionHandled(KCurrentThreadHandle,aType,EFalse));
  1.4625 +	}
  1.4626 +
  1.4627 +
  1.4628 +
  1.4629 +
  1.4630 +EXPORT_C void RThread::Context(TDes8 &aDes) const
  1.4631 +/**
  1.4632 +Gets the register contents of this thread.
  1.4633 +
  1.4634 +@param aDes On return, contains the register contents, starting with R0.
  1.4635 +*/
  1.4636 +	{
  1.4637 +
  1.4638 +	Exec::ThreadContext(iHandle,aDes);
  1.4639 +	}
  1.4640 +
  1.4641 +
  1.4642 +
  1.4643 +
  1.4644 +EXPORT_C void RThread::Resume() const
  1.4645 +/**
  1.4646 +Makes the thread eligible for execution.
  1.4647 +
  1.4648 +After a thread is created, it is put into a suspended state; the thread is 
  1.4649 +not eligible to run until Resume() is called.
  1.4650 +
  1.4651 +This function must also be called to resume execution of this thread after 
  1.4652 +it has been explicitly suspended by a call to Suspend().
  1.4653 +
  1.4654 +Note that when a thread is created, it is given the priority EPriorityNormal 
  1.4655 +by default. The fact that a thread is initially put into a suspended state 
  1.4656 +means that the thread priority can be changed by calling the thread's
  1.4657 +SetPriority() member function before the thread is started by a call to Resume().
  1.4658 +*/
  1.4659 +	{
  1.4660 +
  1.4661 +	Exec::ThreadResume(iHandle);
  1.4662 +	}
  1.4663 +
  1.4664 +
  1.4665 +
  1.4666 +
  1.4667 +EXPORT_C void RThread::Suspend() const
  1.4668 +/**
  1.4669 +Suspends execution of this thread.
  1.4670 +
  1.4671 +The thread is not scheduled to run until a subsequent call to Resume() is made.
  1.4672 +*/
  1.4673 +	{
  1.4674 +
  1.4675 +	Exec::ThreadSuspend(iHandle);
  1.4676 +	}
  1.4677 +
  1.4678 +
  1.4679 +
  1.4680 +
  1.4681 +EXPORT_C TThreadPriority RThread::Priority() const
  1.4682 +/**
  1.4683 +Gets the priority of this thread.
  1.4684 +
  1.4685 +@return The priority.
  1.4686 +*/
  1.4687 +	{
  1.4688 +
  1.4689 +	return(Exec::ThreadPriority(iHandle));
  1.4690 +	}
  1.4691 +
  1.4692 +
  1.4693 +
  1.4694 +
  1.4695 +EXPORT_C void RThread::SetProcessPriority(TProcessPriority aPriority) const
  1.4696 +/**
  1.4697 +Sets the priority of the process which owns this thread to one of the values 
  1.4698 +defined by the TProcessPriority enumeration.
  1.4699 +
  1.4700 +The priority can be set to one of the four values:
  1.4701 +
  1.4702 +EPriorityLow
  1.4703 +
  1.4704 +EPriorityBackground
  1.4705 +
  1.4706 +EPriorityForeground
  1.4707 +
  1.4708 +EPriorityHigh
  1.4709 +
  1.4710 +The absolute priority of all threads owned by the process (and all threads 
  1.4711 +owned by those threads etc.) are re-calculated.
  1.4712 +
  1.4713 +Note:
  1.4714 +
  1.4715 +The use of the priority values EPriorityWindowServer, EPriorityFileServer, 
  1.4716 +EPriorityRealTimeServer and EPrioritySupervisor is restricted to Symbian OS, 
  1.4717 +and any attempt to explicitly set any of these priority values raises a KERN-EXEC 
  1.4718 +14 panic.
  1.4719 +
  1.4720 +@param aPriority The priority value.
  1.4721 +
  1.4722 +@deprecated Not allowed on threads in a different process.
  1.4723 +			Replace with RProcess::SetPriority or RMessagePtr2::SetProcessPriority
  1.4724 +*/
  1.4725 +	{
  1.4726 +
  1.4727 +	Exec::ThreadSetProcessPriority(iHandle,aPriority);
  1.4728 +	}
  1.4729 +
  1.4730 +
  1.4731 +
  1.4732 +
  1.4733 +EXPORT_C TProcessPriority RThread::ProcessPriority() const
  1.4734 +/**
  1.4735 +Gets the priority of the process which owns this thread.
  1.4736 +
  1.4737 +@return The process priority.
  1.4738 +*/
  1.4739 +	{
  1.4740 +
  1.4741 +	return(Exec::ThreadProcessPriority(iHandle));
  1.4742 +	}
  1.4743 +
  1.4744 +
  1.4745 +
  1.4746 +
  1.4747 +EXPORT_C void RThread::SetPriority(TThreadPriority aPriority) const
  1.4748 +/**
  1.4749 +Sets the priority of the thread to one of the values defined by
  1.4750 +the TThreadPriority enumeration. 
  1.4751 +
  1.4752 +The resulting absolute priority of the thread depends on the value of aPriority 
  1.4753 +and the priority of the owning process.
  1.4754 +
  1.4755 +Use of the priority value EPriorityNull is restricted to Symbian OS, and any 
  1.4756 +attempt to explicitly set this value causes a KERN-EXEC 14 panic to be raised.
  1.4757 +
  1.4758 +@param aPriority The priority value.
  1.4759 +
  1.4760 +@capability ProtServ if aPriority is EPriorityAbsoluteRealTime1 or higher
  1.4761 +
  1.4762 +@panic KERN-EXEC 14, if aPriority is invalid or set to EPriorityNull
  1.4763 +@panic KERN-EXEC 46, if aPriority is EPriorityAbsoluteRealTime1 or higher
  1.4764 +                     and calling process does not have ProtServ capability
  1.4765 +*/
  1.4766 +	{
  1.4767 +
  1.4768 +	Exec::ThreadSetPriority(iHandle,aPriority);
  1.4769 +	}
  1.4770 +
  1.4771 +
  1.4772 +
  1.4773 +
  1.4774 +EXPORT_C User::TCritical User::Critical(RThread aThread)
  1.4775 +/**
  1.4776 +Gets the critical state associated with the specified thread.
  1.4777 +
  1.4778 +@param aThread The thread whose critical state is to be retrieved.
  1.4779 +
  1.4780 +@return The critical state.
  1.4781 +
  1.4782 +@see User::SetCritical()
  1.4783 +*/
  1.4784 +	{
  1.4785 +	TUint32 flags = Exec::ThreadFlags(aThread.Handle());
  1.4786 +	if (flags & KThreadFlagSystemPermanent)
  1.4787 +		return ESystemPermanent;
  1.4788 +	if (flags & KThreadFlagSystemCritical)
  1.4789 +		return ESystemCritical;
  1.4790 +	if (flags & KThreadFlagProcessPermanent)
  1.4791 +		return EProcessPermanent;
  1.4792 +	if (flags & KThreadFlagProcessCritical)
  1.4793 +		return EProcessCritical;
  1.4794 +	return ENotCritical;
  1.4795 +	}
  1.4796 +
  1.4797 +
  1.4798 +
  1.4799 +
  1.4800 +EXPORT_C User::TCritical User::Critical()
  1.4801 +/**
  1.4802 +Gets the critical state associated with the current thread.
  1.4803 +
  1.4804 +@return The critical state.
  1.4805 +	
  1.4806 +@see User::SetCritical()
  1.4807 +*/
  1.4808 +	{
  1.4809 +	RThread me;
  1.4810 +	return User::Critical(me);
  1.4811 +	}
  1.4812 +
  1.4813 +
  1.4814 +
  1.4815 +
  1.4816 +/**
  1.4817 +Sets up or changes the effect that termination of the current
  1.4818 +thread has, either on its owning process, or on the whole system.
  1.4819 +
  1.4820 +The precise effect of thread termination is defined by 
  1.4821 +the following specific values of the TCritical enum:
  1.4822 +- ENotCritical
  1.4823 +- EProcessCritical
  1.4824 +- EProcessPermanent
  1.4825 +- ESystemCritical
  1.4826 +- ESystemPermanent
  1.4827 +
  1.4828 +Notes:
  1.4829 +-# The enum value EAllThreadsCritical cannot be set using this function. It is
  1.4830 +associated with a process, not a thread, and, if appropriate, should be set
  1.4831 +using User::SetProcessCritical().
  1.4832 +-# The states associated with ENotCritical, EProcessCritical,
  1.4833 +EProcessPermanent, ESystemCritical and ESystemPermanent
  1.4834 +are all mutually exclusive, i.e. the thread can only be in one of these states
  1.4835 +at any one time
  1.4836 +
  1.4837 +@param aCritical The state to be set. 
  1.4838 +
  1.4839 +@return KErrNone, if successful;
  1.4840 +        KErrArgument, if EAllThreadsCritical is passed - this is a 
  1.4841 +        state associated with a process, and
  1.4842 +        you use User::SetProcessCritical() to set it.
  1.4843 +
  1.4844 +@capability ProtServ if aCritical==ESystemCritical or ESystemPermanent
  1.4845 +
  1.4846 +@see User::Critical()
  1.4847 +@see User::ProcessCritical()
  1.4848 +@see User::SetProcessCritical()
  1.4849 +*/
  1.4850 +EXPORT_C TInt User::SetCritical(TCritical aCritical)
  1.4851 +	{
  1.4852 +	const TUint32 clear =	KThreadFlagSystemPermanent | KThreadFlagSystemCritical |
  1.4853 +							KThreadFlagProcessPermanent | KThreadFlagProcessCritical;
  1.4854 +	TUint32 set;
  1.4855 +	switch (aCritical)
  1.4856 +		{
  1.4857 +		case ENotCritical:		set = 0;							break;
  1.4858 +		case EProcessCritical:	set = KThreadFlagProcessCritical;	break;
  1.4859 +		case EProcessPermanent:	set = KThreadFlagProcessPermanent;	break;
  1.4860 +		case ESystemCritical:	set = KThreadFlagSystemCritical;	break;
  1.4861 +		case ESystemPermanent:	set = KThreadFlagSystemPermanent;	break;
  1.4862 +		default:													return KErrArgument;
  1.4863 +		}
  1.4864 +	Exec::ThreadSetFlags(KCurrentThreadHandle, clear, set);
  1.4865 +	return KErrNone;
  1.4866 +	}
  1.4867 +
  1.4868 +
  1.4869 +
  1.4870 +
  1.4871 +EXPORT_C TInt User::SetRealtimeState(TRealtimeState aState)
  1.4872 +	{
  1.4873 +	const TUint32 clear =	KThreadFlagRealtime | KThreadFlagRealtimeTest;
  1.4874 +	TUint32 set;
  1.4875 +	switch (aState)
  1.4876 +		{
  1.4877 +		case ERealtimeStateOff:		set = 0;											break;
  1.4878 +		case ERealtimeStateOn:		set = KThreadFlagRealtime;							break;
  1.4879 +		case ERealtimeStateWarn:	set = KThreadFlagRealtime|KThreadFlagRealtimeTest;	break;
  1.4880 +		default:																		return KErrArgument;
  1.4881 +		}
  1.4882 +	Exec::ThreadSetFlags(KCurrentThreadHandle, clear, set);
  1.4883 +	return KErrNone;
  1.4884 +	}
  1.4885 +
  1.4886 +
  1.4887 +
  1.4888 +
  1.4889 +EXPORT_C User::TCritical User::ProcessCritical(RProcess aProcess)
  1.4890 +/**
  1.4891 +Gets the critical state associated with the specified process.
  1.4892 +
  1.4893 +@param aProcess The process whose critical state is to be retrieved.
  1.4894 +
  1.4895 +@return The critical state.
  1.4896 +
  1.4897 +@see User::SetProcessCritical()
  1.4898 +*/
  1.4899 +	{
  1.4900 +	TUint32 flags = Exec::ProcessFlags(aProcess.Handle());
  1.4901 +	if (flags & KProcessFlagSystemPermanent)
  1.4902 +		return ESystemPermanent;
  1.4903 +	if (flags & KProcessFlagSystemCritical)
  1.4904 +		return ESystemCritical;
  1.4905 +	if (flags & (KThreadFlagProcessPermanent | KThreadFlagProcessCritical))
  1.4906 +		return EAllThreadsCritical;
  1.4907 +	return ENotCritical;
  1.4908 +	}
  1.4909 +
  1.4910 +
  1.4911 +
  1.4912 +
  1.4913 +EXPORT_C User::TCritical User::ProcessCritical()
  1.4914 +/**
  1.4915 +Gets the critical state associated with the current process.
  1.4916 +
  1.4917 +@return The critical state.
  1.4918 +	
  1.4919 +@see User::SetProcessCritical()
  1.4920 +*/
  1.4921 +	{
  1.4922 +	RProcess me;
  1.4923 +	return User::ProcessCritical(me);
  1.4924 +	}
  1.4925 +
  1.4926 +
  1.4927 +
  1.4928 +
  1.4929 +EXPORT_C TInt User::SetProcessCritical(TCritical aCritical)
  1.4930 +/**
  1.4931 +Sets up or changes the effect that termination of subsequently created threads
  1.4932 +will have, either on the owning process, or on the whole system.
  1.4933 +
  1.4934 +It is important to note that we are not referring to threads that have already
  1.4935 +been created, but threads that will be created subsequent to a call to this function.
  1.4936 +
  1.4937 +The precise effect of thread termination is defined by the following specific
  1.4938 +values of the TCritical enum: 
  1.4939 +- ENotCritical
  1.4940 +- EAllThreadsCritical
  1.4941 +- ESystemCritical
  1.4942 +- ESystemPermanent
  1.4943 +
  1.4944 +Notes:
  1.4945 +-# The enum values EProcessCritical and EProcessPermanent cannot be set using
  1.4946 +this function. They are states associated with
  1.4947 +a thread, not a process, and, if appropriate, should be set
  1.4948 +using User::SetCritical().
  1.4949 +-# The states associated with ENotCritical, EAllThreadsCritical,
  1.4950 +ESystemCritical and ESystemPermanent are all mutually exclusive, i.e. the
  1.4951 +process can only be in one of these states at any one time.
  1.4952 +
  1.4953 +@param aCritical The state to be set. 
  1.4954 +
  1.4955 +@return KErrNone, if successful;
  1.4956 +        KErrArgument, if either EProcessCritical or EProcessPermanent
  1.4957 +        is passed - these are states associated with a thread, and
  1.4958 +        you use User::SetCritical() to set them.
  1.4959 +
  1.4960 +@capability ProtServ if aCritical==ESystemCritical or ESystemPermanent
  1.4961 +
  1.4962 +@see User::ProcessCritical()
  1.4963 +@see User::SetCritical()
  1.4964 +@see User::Critical()
  1.4965 +*/
  1.4966 +	{
  1.4967 +	const TUint32 clear =	KProcessFlagSystemPermanent | KProcessFlagSystemCritical |
  1.4968 +							KThreadFlagProcessPermanent | KThreadFlagProcessCritical;
  1.4969 +	TUint32 set;
  1.4970 +	switch (aCritical)
  1.4971 +		{
  1.4972 +		case ENotCritical:			set = 0;							break;
  1.4973 +		case EAllThreadsCritical:	set = KThreadFlagProcessCritical;	break;
  1.4974 +		case ESystemCritical:		set = KProcessFlagSystemCritical;	break;
  1.4975 +		case ESystemPermanent:		set = KProcessFlagSystemPermanent|KProcessFlagSystemCritical;	break;
  1.4976 +		default:														return KErrArgument;
  1.4977 +		}
  1.4978 +	Exec::ProcessSetFlags(KCurrentProcessHandle, clear, set);
  1.4979 +	return KErrNone;
  1.4980 +	}
  1.4981 +
  1.4982 +
  1.4983 +
  1.4984 +
  1.4985 +EXPORT_C TBool User::PriorityControl()
  1.4986 +/**
  1.4987 +Tests whether the current process allows other processes to switch its priority 
  1.4988 +between 'foreground' and 'background'.
  1.4989 +
  1.4990 +@return True, if the current process allows other processes to switch its priority;
  1.4991 +        false, otherwise.
  1.4992 +*/
  1.4993 +	{
  1.4994 +	return Exec::ProcessFlags(KCurrentProcessHandle) & KProcessFlagPriorityControl;
  1.4995 +	}
  1.4996 +
  1.4997 +
  1.4998 +
  1.4999 +
  1.5000 +EXPORT_C void User::SetPriorityControl(TBool aEnable)
  1.5001 +/**
  1.5002 +Allows the current process to choose to have its priority switched by another
  1.5003 +process between 'foreground' and 'background'.
  1.5004 +
  1.5005 +By default a process does not allow this.
  1.5006 +
  1.5007 +@param aEnable If ETrue, allows other processes to switch the current process's
  1.5008 +               priority.
  1.5009 +               If EFalse, prevents other processes from switching the current
  1.5010 +               process's priority.
  1.5011 +*/
  1.5012 +	{
  1.5013 +	TUint32 set = aEnable ? KProcessFlagPriorityControl : 0;
  1.5014 +	Exec::ProcessSetFlags(KCurrentProcessHandle, KProcessFlagPriorityControl, set);
  1.5015 +	}
  1.5016 +
  1.5017 +
  1.5018 +
  1.5019 +EXPORT_C TInt RThread::RequestCount() const
  1.5020 +/**
  1.5021 +Gets this thread's request semaphore count.
  1.5022 +
  1.5023 +The request semaphore is created when a thread is created, and is used to 
  1.5024 +support asynchronous requests.
  1.5025 +
  1.5026 +A negative value implies that this thread is waiting for at least
  1.5027 +one asynchronous request to complete.
  1.5028 +
  1.5029 +@return This thread's request semaphore count.
  1.5030 +*/
  1.5031 +	{
  1.5032 +
  1.5033 +	return(Exec::ThreadRequestCount(iHandle));
  1.5034 +	}
  1.5035 +
  1.5036 +
  1.5037 +
  1.5038 +
  1.5039 +EXPORT_C TExitType RThread::ExitType() const
  1.5040 +/**
  1.5041 +Tests whether the thread has ended and, if it has ended, return how it ended.
  1.5042 +
  1.5043 +This information allows the caller to distinguish between normal termination 
  1.5044 +and a panic.
  1.5045 +
  1.5046 +@return An enumeration whose enumerators describe how the thread has ended.
  1.5047 +*/
  1.5048 +	{
  1.5049 +
  1.5050 +	return(Exec::ThreadExitType(iHandle));
  1.5051 +	}
  1.5052 +
  1.5053 +
  1.5054 +
  1.5055 +
  1.5056 +EXPORT_C TInt RThread::ExitReason() const
  1.5057 +/**
  1.5058 +Gets the specific reason associated with the end of this thread.
  1.5059 +
  1.5060 +The reason number together with the category name is a way of distinguishing 
  1.5061 +between different causes of thread termination.
  1.5062 +
  1.5063 +If the thread has panicked, this value is the panic number. If the thread 
  1.5064 +has ended as a result of a call to Kill(), then the value is the one supplied 
  1.5065 +by Kill().
  1.5066 +
  1.5067 +If the thread is still alive, then the returned value is zero.
  1.5068 +
  1.5069 +@return The reason associated with the end of the thread.
  1.5070 +*/
  1.5071 +	{
  1.5072 +
  1.5073 +	return(Exec::ThreadExitReason(iHandle));
  1.5074 +	}
  1.5075 +
  1.5076 +
  1.5077 +
  1.5078 +
  1.5079 +EXPORT_C TExitCategoryName RThread::ExitCategory() const
  1.5080 +/**
  1.5081 +Gets the name of the category associated with the end of the thread.
  1.5082 +
  1.5083 +The category name together with the reason number is a way of distinguishing
  1.5084 +between different causes of thread termination.
  1.5085 +
  1.5086 +If the thread has panicked, the category name is the panic category name; 
  1.5087 +for example, E32USER-CBase or KERN-EXEC. If the thread has ended as a result 
  1.5088 +of call to Kill(), then the category name is Kill.
  1.5089 +
  1.5090 +If the thread has not ended, then the category name is empty, i.e. the length 
  1.5091 +of the category name is zero.
  1.5092 +
  1.5093 +@return A TBuf descriptor with a defined maximum length containing the name 
  1.5094 +        of the category associated with the end of the thread.
  1.5095 +
  1.5096 +@see TBuf
  1.5097 +*/
  1.5098 +	{
  1.5099 +	TExitCategoryName n;
  1.5100 +	TPtr8 n8(((TUint8*)n.Ptr()) + KMaxExitCategoryName, KMaxExitCategoryName);
  1.5101 +	Exec::ThreadExitCategory(iHandle,n8);
  1.5102 +	n.Copy(n8);
  1.5103 +	return(n);
  1.5104 +	}
  1.5105 +
  1.5106 +
  1.5107 +
  1.5108 +
  1.5109 +EXPORT_C TInt RThread::StackInfo(TThreadStackInfo& aInfo) const
  1.5110 +/**
  1.5111 +Gets information about a thread's user mode stack.
  1.5112 +
  1.5113 +@param aInfo The TThreadStackInfo object to write the stack infomation to.
  1.5114 +
  1.5115 +@return KErrNone, if sucessful;
  1.5116 +		KErrGeneral, if the thread doesn't have a user mode stack,
  1.5117 +		or it has terminated.
  1.5118 +
  1.5119 +@see TThreadStackInfo
  1.5120 +*/
  1.5121 +	{
  1.5122 +	return(Exec::ThreadStackInfo(iHandle,aInfo));
  1.5123 +	}
  1.5124 +
  1.5125 +
  1.5126 +
  1.5127 +
  1.5128 +EXPORT_C TInt RThread::GetCpuTime(TTimeIntervalMicroSeconds& aCpuTime) const
  1.5129 +/**
  1.5130 +Gets the CPU usage for this thread.
  1.5131 +
  1.5132 +This function is not supported on version 8.0b or 8.1b, and returns
  1.5133 +KErrNotSupported.  From 9.1 onwards it may be supported if the kernel has been
  1.5134 +compiled with the MONITOR_THREAD_CPU_TIME macro defined.
  1.5135 +
  1.5136 +@param aCpuTime A reference to a time interval object supplied by the caller. 
  1.5137 +                                
  1.5138 +@return KErrNone - if thread CPU time is available.
  1.5139 +
  1.5140 +        KErrNotSupported - if this feature is not supported on this
  1.5141 +        version or build of the OS.
  1.5142 +*/
  1.5143 +	{
  1.5144 +	return Exec::ThreadGetCpuTime(iHandle, (TInt64&)aCpuTime.Int64());
  1.5145 +	}
  1.5146 +
  1.5147 +
  1.5148 +
  1.5149 +
  1.5150 +EXPORT_C void User::After(TTimeIntervalMicroSeconds32 aInterval)
  1.5151 +/**
  1.5152 +Suspends the current thread until a specified time interval has expired.
  1.5153 +
  1.5154 +The resolution of the timer depends on the hardware, but is normally 
  1.5155 +1 Symbian OS tick (approximately 1/64 second).
  1.5156 +
  1.5157 +@param aInterval The time interval for which the current thread is to be 
  1.5158 +                  suspended, in microseconds.
  1.5159 +                  
  1.5160 +@panic USER 86, if the time interval is negative.
  1.5161 +*/
  1.5162 +	{
  1.5163 +
  1.5164 +	__ASSERT_ALWAYS(aInterval.Int()>=0,::Panic(EExecAfterTimeNegative));
  1.5165 +	TRequestStatus s=KRequestPending;
  1.5166 +	Exec::After(aInterval.Int(),s);
  1.5167 +	User::WaitForRequest(s);
  1.5168 +	}
  1.5169 +
  1.5170 +
  1.5171 +
  1.5172 +
  1.5173 +EXPORT_C void User::AfterHighRes(TTimeIntervalMicroSeconds32 aInterval)
  1.5174 +/**
  1.5175 +Suspends the current thread until a specified time interval has expired to
  1.5176 +a resolution of 1ms .
  1.5177 +
  1.5178 +@param aInterval The time interval for which the current thread is to be 
  1.5179 +                  suspended, in microseconds.
  1.5180 +                  
  1.5181 +@panic USER 86, if the time interval is negative.
  1.5182 +*/
  1.5183 +	{
  1.5184 +
  1.5185 +	__ASSERT_ALWAYS(aInterval.Int()>=0,::Panic(EExecAfterTimeNegative));
  1.5186 +	TRequestStatus s=KRequestPending;
  1.5187 +	Exec::AfterHighRes(aInterval.Int(),s);
  1.5188 +	User::WaitForRequest(s);
  1.5189 +	}
  1.5190 +
  1.5191 +
  1.5192 +
  1.5193 +
  1.5194 +EXPORT_C TInt User::At(const TTime &aTime)
  1.5195 +/**
  1.5196 +Suspends the current thread until the specified absolute time, in the current time zone.
  1.5197 +
  1.5198 +If the machine is off at that time, the machine will be turned on again.
  1.5199 +
  1.5200 +@param aTime The absolute time, in the current time zone, until which the current thread is to
  1.5201 +             be suspended.
  1.5202 +
  1.5203 +@return On completion, contains the status of the request to suspend the
  1.5204 +        current thread:
  1.5205 +
  1.5206 +        KErrNone - suspension of the current thread completed normally at 
  1.5207 +        the requested time.
  1.5208 +
  1.5209 +        KErrAbort - suspension of the current thread was aborted 
  1.5210 +        because the system time changed.
  1.5211 +
  1.5212 +        KErrUnderflow - the requested completion time is in the past.
  1.5213 +
  1.5214 +        KErrOverFlow - the requested completion time is too far in the future.
  1.5215 +*/
  1.5216 +	{
  1.5217 +
  1.5218 +	TRequestStatus s=KRequestPending;
  1.5219 +	TInt64 time=aTime.Int64();
  1.5220 +	time -= ((TInt64)User::UTCOffset().Int()) * 1000000;
  1.5221 +	Exec::At(time,s);
  1.5222 +	User::WaitForRequest(s);
  1.5223 +	return(s.Int());
  1.5224 +	}
  1.5225 +
  1.5226 +
  1.5227 +
  1.5228 +
  1.5229 +EXPORT_C void RTimer::Cancel()
  1.5230 +/**
  1.5231 +Cancels any outstanding request for a timer event.
  1.5232 +
  1.5233 +Any outstanding timer event completes with KErrCancel.
  1.5234 +*/
  1.5235 +	{
  1.5236 +
  1.5237 +	Exec::TimerCancel(iHandle);
  1.5238 +	}
  1.5239 +
  1.5240 +
  1.5241 +
  1.5242 +
  1.5243 +EXPORT_C void RTimer::After(TRequestStatus &aStatus,TTimeIntervalMicroSeconds32 aInterval)
  1.5244 +//
  1.5245 +// Request a relative timer.
  1.5246 +//
  1.5247 +/**
  1.5248 +Requests an event after the specified interval.
  1.5249 +
  1.5250 +The counter for this type of request stops during power-down.
  1.5251 +A 5 second timer will complete late if, for example, the machine is turned off
  1.5252 +2 seconds after the request is made.
  1.5253 +
  1.5254 +@param aStatus    On completion, contains the status of the request.
  1.5255 +                  This is KErrNone if the timer completed normally at the
  1.5256 +                  requested time, otherwise another of the
  1.5257 +                  system-wide error codes.
  1.5258 +
  1.5259 +@param aInterval  The time interval, in microseconds, after which an event
  1.5260 +                  is to occur.
  1.5261 +
  1.5262 +@panic USER 87, if aInterval is negative.
  1.5263 +@panic KERN-EXEC 15, if this function is called while a request for a timer
  1.5264 +       event is still outstanding.
  1.5265 +*/
  1.5266 +	{
  1.5267 +
  1.5268 +	__ASSERT_ALWAYS(aInterval.Int()>=0,::Panic(ERTimerAfterTimeNegative));
  1.5269 +	aStatus=KRequestPending;
  1.5270 +	Exec::TimerAfter(iHandle,aStatus,aInterval.Int());
  1.5271 +	}
  1.5272 +
  1.5273 +
  1.5274 +
  1.5275 +
  1.5276 +EXPORT_C void RTimer::AfterTicks(TRequestStatus& aStatus, TInt aTicks)
  1.5277 +//
  1.5278 +// Request a relative timer in system ticks.
  1.5279 +//
  1.5280 +/**
  1.5281 +Requests an event after the specified interval.
  1.5282 +
  1.5283 +The counter for this type of request stops during power-down.
  1.5284 +A 5 tick timer will complete late if, for example, the machine is turned off
  1.5285 +2 ticks after the request is made.
  1.5286 +
  1.5287 +@param aStatus    On completion, contains the status of the request.
  1.5288 +                  This is KErrNone if the timer completed normally at the
  1.5289 +                  requested time, otherwise another of the
  1.5290 +                  system-wide error codes.
  1.5291 +
  1.5292 +@param aTicks     The time interval, in system ticks, after which an event
  1.5293 +                  is to occur.
  1.5294 +
  1.5295 +@panic USER 87, if aTicks is negative.
  1.5296 +@panic KERN-EXEC 15, if this function is called while a request for a timer
  1.5297 +       event is still outstanding.
  1.5298 +*/
  1.5299 +	{
  1.5300 +	__ASSERT_ALWAYS(aTicks >= 0, ::Panic(ERTimerAfterTimeNegative));
  1.5301 +	aStatus = KRequestPending;
  1.5302 +	Exec::TimerAfter(iHandle, aStatus, -aTicks);
  1.5303 +	}
  1.5304 +
  1.5305 +
  1.5306 +
  1.5307 +
  1.5308 +EXPORT_C void RTimer::HighRes(TRequestStatus &aStatus,TTimeIntervalMicroSeconds32 aInterval)
  1.5309 +//
  1.5310 +// Request a relative timer to a resolution of 1ms.
  1.5311 +//
  1.5312 +/**
  1.5313 +Requests an event after the specified interval to a resolution of 1ms. 
  1.5314 +The "HighRes timer" counter stops during power-down (the same as "after timer"). 
  1.5315 +
  1.5316 +@param aStatus    On completion, contains the status of the request.
  1.5317 +                  This is KErrNone if the timer completed normally at the
  1.5318 +                  requested time, otherwise another of the
  1.5319 +                  system-wide error codes.
  1.5320 +
  1.5321 +@param aInterval  The time interval, in microseconds, after which an event
  1.5322 +                  is to occur.
  1.5323 +
  1.5324 +@panic USER 87, if aInterval is negative.
  1.5325 +@panic KERN-EXEC 15, if this function is called while a request for a timer
  1.5326 +       event is still outstanding.
  1.5327 +*/
  1.5328 +	{
  1.5329 +
  1.5330 +	__ASSERT_ALWAYS(aInterval.Int()>=0,::Panic(ERTimerAfterTimeNegative));
  1.5331 +	aStatus=KRequestPending;
  1.5332 +	Exec::TimerHighRes(iHandle,aStatus,aInterval.Int());
  1.5333 +	}
  1.5334 +
  1.5335 +
  1.5336 +
  1.5337 +
  1.5338 +EXPORT_C void RTimer::At(TRequestStatus &aStatus,const TTime &aTime)
  1.5339 +//
  1.5340 +// Request an absolute timer.
  1.5341 +//
  1.5342 +/**
  1.5343 +Requests an event at a given system time (in the current time zone).
  1.5344 +
  1.5345 +If the machine is off at that time, it is automatically turned on.
  1.5346 +
  1.5347 +@param aStatus On completion, contains the status of the request:
  1.5348 +               KErrNone, the timer completed normally at the requested time;
  1.5349 +               KErrCancel, the timer was cancelled;
  1.5350 +               KErrAbort, the timer was aborted because the system time changed;
  1.5351 +               KErrUnderflow, the requested completion time is in the past;
  1.5352 +               KErrOverFlow, the requested completion time is too far in the future;
  1.5353 +@param aTime   The time at which the timer will expire.
  1.5354 +
  1.5355 +@panic KERN-EXEC 15, if this function is called while a request for a timer
  1.5356 +       event is still outstanding.
  1.5357 +*/
  1.5358 +	{
  1.5359 +
  1.5360 +	aStatus=KRequestPending;
  1.5361 +	TInt64 time=aTime.Int64();
  1.5362 +	time -= ((TInt64)User::UTCOffset().Int()) * 1000000;
  1.5363 +	Exec::TimerAt(iHandle,aStatus,I64LOW(time),I64HIGH(time));
  1.5364 +	}
  1.5365 +
  1.5366 +
  1.5367 +
  1.5368 +
  1.5369 +EXPORT_C void RTimer::AtUTC(TRequestStatus &aStatus,const TTime &aUTCTime)
  1.5370 +//
  1.5371 +// Request an absolute timer in UTC time.
  1.5372 +//
  1.5373 +/**
  1.5374 +Requests an event at a given UTC time.
  1.5375 +
  1.5376 +If the machine is off at that time, it is automatically turned on.
  1.5377 +
  1.5378 +@param aStatus On completion, contains the status of the request:
  1.5379 +               KErrNone, the timer completed normally at the requested time;
  1.5380 +               KErrCancel, the timer was cancelled;
  1.5381 +               KErrAbort, the timer was aborted because the system time changed;
  1.5382 +               KErrUnderflow, the requested completion time is in the past;
  1.5383 +               KErrOverFlow, the requested completion time is too far in the future;
  1.5384 +@param aTime   The time at which the timer will expire.
  1.5385 +
  1.5386 +@panic KERN-EXEC 15, if this function is called while a request for a timer
  1.5387 +       event is still outstanding.
  1.5388 +*/
  1.5389 +	{
  1.5390 +
  1.5391 +	aStatus=KRequestPending;
  1.5392 +	Exec::TimerAt(iHandle,aStatus,I64LOW(aUTCTime.Int64()),I64HIGH(aUTCTime.Int64()));
  1.5393 +	}
  1.5394 +
  1.5395 +
  1.5396 +
  1.5397 +
  1.5398 +EXPORT_C void RTimer::Lock(TRequestStatus &aStatus,TTimerLockSpec aLock)
  1.5399 +//
  1.5400 +// Request an absolute timer.
  1.5401 +//
  1.5402 +/**
  1.5403 +Requests an event on a specified second fraction.
  1.5404 +
  1.5405 +@param aStatus On completion, contains the status of the request:
  1.5406 +               KErrGeneral, the first time this is called;
  1.5407 +               KErrNone, the timer completed normally at the requested time;
  1.5408 +               KErrCancel, the timer was cancelled;
  1.5409 +               KErrAbort, the timer was aborted because the system time changed;
  1.5410 +               KErrUnderflow, the requested completion time is in the past;
  1.5411 +               KErrOverFlow, the requested completion time is too far in the future.
  1.5412 +@param aLock   The fraction of a second at which the timer completes.
  1.5413 +
  1.5414 +@panic KERN-EXEC 15, if this function is called while a request for a timer
  1.5415 +       event is still outstanding.
  1.5416 +*/
  1.5417 +	{
  1.5418 +	aStatus=KRequestPending;
  1.5419 +	Exec::TimerLock(iHandle,aStatus,aLock);
  1.5420 +	}
  1.5421 +
  1.5422 +
  1.5423 +/**
  1.5424 +Requests an event to be triggered when aSeconds is exactly, (ie not greater or 
  1.5425 +less than), the time elapsed (to the nearest second) since the last user activity.
  1.5426 +If the event trigger time has been "missed", instead of triggering late,
  1.5427 +the timer waits for the next user activity, to try and satisfy the condition.
  1.5428 +
  1.5429 +That is to say, if there was user activity within the last aSeconds,
  1.5430 +the event will be triggered after aSeconds of continuous inactivity following that activity.
  1.5431 +Otherwise, if there has been no such activity within this time, an event is
  1.5432 +triggered after aSeconds of continuous inactivity following the next user activity
  1.5433 +in the future.
  1.5434 +
  1.5435 +It follows from this, that you can request an event directly after the next
  1.5436 +user activity by supplying a time interval of zero.
  1.5437 +
  1.5438 +
  1.5439 +@param aStatus  On completion, contains the status of the request:
  1.5440 +                KErrNone, the timer completed normally;
  1.5441 +                KErrCancel, the timer was cancelled;
  1.5442 +                KErrArgument, if aSeconds is less then zero;
  1.5443 +                KErrOverflow, if aSecond reaches its limit (which is platform specific but greater then one and a half day).
  1.5444 +@param aSeconds The time interval in seconds.
  1.5445 +
  1.5446 +@panic KERN-EXEC 15, if this function is called while a request for a timer
  1.5447 +       event is still outstanding.
  1.5448 +*/
  1.5449 +EXPORT_C void RTimer::Inactivity(TRequestStatus &aStatus, TTimeIntervalSeconds aSeconds)
  1.5450 +	{
  1.5451 +	aStatus=KRequestPending;
  1.5452 +	Exec::TimerInactivity(iHandle, aStatus, aSeconds.Int());
  1.5453 +	}
  1.5454 +
  1.5455 +
  1.5456 +
  1.5457 +
  1.5458 +EXPORT_C TInt RChangeNotifier::Logon(TRequestStatus& aStatus) const
  1.5459 +/**
  1.5460 +Issues a request for notification when changes occur in the environment. 
  1.5461 +
  1.5462 +A switch in locale, or crossing over past midnight, are examples of changes
  1.5463 +that are reported.
  1.5464 +
  1.5465 +When a change in the environment occurs, the request completes and the 
  1.5466 +TRquestStatus object will contain one or more of the bit values defined
  1.5467 +by the TChanges enum.
  1.5468 +
  1.5469 +Alternatively, if an outstanding request is cancelled by a call to
  1.5470 +this handle's LogonCancel() member function, then the request completes
  1.5471 +with a KErrCancel.
  1.5472 +
  1.5473 +Note that if this is the first notification request after creation of
  1.5474 +the change notifier, then this request completes immediately.
  1.5475 +
  1.5476 +@param aStatus A reference to the request status object.
  1.5477 +
  1.5478 +@return KErrInUse, if there is an outstanding request; KErrNone otherwise.
  1.5479 +
  1.5480 +@see TChanges
  1.5481 +@see RChangeNotifier::Logon()
  1.5482 +*/
  1.5483 +	{
  1.5484 +	
  1.5485 +	aStatus=KRequestPending;
  1.5486 +	return(Exec::ChangeNotifierLogon(iHandle,aStatus));
  1.5487 +	}
  1.5488 +
  1.5489 +
  1.5490 +
  1.5491 +
  1.5492 +EXPORT_C TInt RChangeNotifier::LogonCancel() const
  1.5493 +/**
  1.5494 +Cancels an outstanding change notification request.
  1.5495 +
  1.5496 +@return KErrGeneral, if there is no outstanding request; KErrNone otherwise.
  1.5497 +
  1.5498 +@see RChangeNotifier::Logon()
  1.5499 +*/
  1.5500 +	{
  1.5501 +	
  1.5502 +	return(Exec::ChangeNotifierLogoff(iHandle));
  1.5503 +	}
  1.5504 +
  1.5505 +
  1.5506 +
  1.5507 +
  1.5508 +EXPORT_C void UserSvr::CaptureEventHook()
  1.5509 +//
  1.5510 +// Capture the event hook
  1.5511 +//
  1.5512 +	{
  1.5513 +
  1.5514 +	Exec::CaptureEventHook();
  1.5515 +	}
  1.5516 +
  1.5517 +EXPORT_C void UserSvr::ReleaseEventHook()
  1.5518 +//
  1.5519 +// Release the event hook
  1.5520 +//
  1.5521 +	{
  1.5522 +
  1.5523 +	Exec::ReleaseEventHook();
  1.5524 +	}
  1.5525 +
  1.5526 +EXPORT_C void UserSvr::RequestEvent(TRawEventBuf &anEvent,TRequestStatus &aStatus)
  1.5527 +//
  1.5528 +// Request the next event.
  1.5529 +//
  1.5530 +	{
  1.5531 +
  1.5532 +	aStatus=KRequestPending;
  1.5533 +	Exec::RequestEvent(anEvent,aStatus);
  1.5534 +	}
  1.5535 +
  1.5536 +EXPORT_C void UserSvr::RequestEventCancel()
  1.5537 +//
  1.5538 +// Cancel the event request.
  1.5539 +//
  1.5540 +	{
  1.5541 +
  1.5542 +	Exec::RequestEventCancel();
  1.5543 +	}
  1.5544 +
  1.5545 +/**
  1.5546 +Add an event to the queue.
  1.5547 +
  1.5548 +@param anEvent The raw hardware event to be added to the event queue.
  1.5549 +@return KErrNone, if successful; KErrPermissionDenied, if the caller has 
  1.5550 +insufficient capability; otherwise, one of the other system-wide error codes.
  1.5551 +
  1.5552 +@capability SwEvent
  1.5553 +@capability PowerMgmt for ESwitchOff, ERestartSystem, ECaseOpen and ECaseClose
  1.5554 +*/
  1.5555 +EXPORT_C TInt UserSvr::AddEvent(const TRawEvent& anEvent)
  1.5556 +	{
  1.5557 +
  1.5558 +    return(Exec::AddEvent(anEvent));
  1.5559 +	}
  1.5560 +
  1.5561 +EXPORT_C void UserSvr::ScreenInfo(TDes8 &anInfo)
  1.5562 +//
  1.5563 +// Get the screen info.
  1.5564 +//
  1.5565 +	{
  1.5566 +
  1.5567 +	Exec::HalFunction(EHalGroupDisplay,EDisplayHalScreenInfo,(TAny*)&anInfo,NULL);
  1.5568 +	}
  1.5569 +
  1.5570 +#ifdef __USERSIDE_THREAD_DATA__
  1.5571 +
  1.5572 +EXPORT_C TAny* UserSvr::DllTls(TInt aHandle)
  1.5573 +//
  1.5574 +// Return the value of the Thread Local Storage variable.
  1.5575 +//
  1.5576 +	{
  1.5577 +	return LocalThreadData()->DllTls(aHandle, KDllUid_Default);
  1.5578 +	}
  1.5579 +
  1.5580 +EXPORT_C TAny* UserSvr::DllTls(TInt aHandle, TInt aDllUid)
  1.5581 +//
  1.5582 +// Return the value of the Thread Local Storage variable.
  1.5583 +//
  1.5584 +	{
  1.5585 +	return LocalThreadData()->DllTls(aHandle, aDllUid);
  1.5586 +	}
  1.5587 +
  1.5588 +#else
  1.5589 +
  1.5590 +EXPORT_C TAny* UserSvr::DllTls(TInt aHandle)
  1.5591 +//
  1.5592 +// Return the value of the Thread Local Storage variable.
  1.5593 +//
  1.5594 +	{
  1.5595 +
  1.5596 +	return Exec::DllTls(aHandle, KDllUid_Default);
  1.5597 +	}
  1.5598 +
  1.5599 +EXPORT_C TAny* UserSvr::DllTls(TInt aHandle, TInt aDllUid)
  1.5600 +//
  1.5601 +// Return the value of the Thread Local Storage variable.
  1.5602 +//
  1.5603 +	{
  1.5604 +
  1.5605 +	return Exec::DllTls(aHandle, aDllUid);
  1.5606 +	}
  1.5607 +
  1.5608 +#endif
  1.5609 +
  1.5610 +EXPORT_C void UserSvr::DllFileName(TInt aHandle, TDes& aFileName)
  1.5611 +//
  1.5612 +// Return the filename of this dll
  1.5613 +//
  1.5614 +	{
  1.5615 +	TBuf8<KMaxFileName> n8;
  1.5616 +	Exec::DllFileName(aHandle, n8);
  1.5617 +	aFileName.Copy(n8);
  1.5618 +	}
  1.5619 +
  1.5620 +EXPORT_C TBool UserSvr::TestBootSequence()
  1.5621 +//
  1.5622 +// Is the machine being booted by the test department?
  1.5623 +//
  1.5624 +    {
  1.5625 +
  1.5626 +	return Exec::HalFunction(EHalGroupPower,EPowerHalTestBootSequence,NULL,NULL);
  1.5627 +    }
  1.5628 +
  1.5629 +/**
  1.5630 +Register whether the W/S takes care of turning the screen on
  1.5631 +*/
  1.5632 +EXPORT_C void UserSvr::WsRegisterSwitchOnScreenHandling(TBool aState)
  1.5633 +    {
  1.5634 +
  1.5635 +	Exec::HalFunction(EHalGroupDisplay,EDisplayHalWsRegisterSwitchOnScreenHandling,(TAny*)aState,NULL);
  1.5636 +    }
  1.5637 +
  1.5638 +EXPORT_C void UserSvr::WsSwitchOnScreen()
  1.5639 +//
  1.5640 +// W/S switch on the screen
  1.5641 +//
  1.5642 +    {
  1.5643 +
  1.5644 +	Exec::HalFunction(EHalGroupDisplay,EDisplayHalWsSwitchOnScreen,NULL,NULL);
  1.5645 +    }
  1.5646 +
  1.5647 +
  1.5648 +EXPORT_C TUint32 UserSvr::DebugMask()
  1.5649 +/**
  1.5650 +Return the kernel debug mask at index 0
  1.5651 +*/
  1.5652 +    {
  1.5653 +	return Exec::DebugMask();
  1.5654 +    }
  1.5655 +
  1.5656 +
  1.5657 +EXPORT_C TUint32 UserSvr::DebugMask(TUint aIndex)
  1.5658 +/**
  1.5659 +Return the kernel debug mask at the given index position
  1.5660 +
  1.5661 +@param aIndex An index of which 32 bit mask word is to be accessed
  1.5662 +*/
  1.5663 +    {
  1.5664 +	return Exec::DebugMaskIndex(aIndex);
  1.5665 +    }
  1.5666 +
  1.5667 +
  1.5668 +
  1.5669 +EXPORT_C TTrapHandler *User::TrapHandler()
  1.5670 +/**
  1.5671 +Gets a pointer to the current thread's trap handler.
  1.5672 +
  1.5673 +Note that TTrapHandler is an abstract base class; a trap handler must be
  1.5674 +implemented as a derived class.
  1.5675 +
  1.5676 +@return A pointer to the current thread's trap handler, if any. NULL, if no 
  1.5677 +        pre-existing trap handler is set.
  1.5678 +*/
  1.5679 +	{
  1.5680 +
  1.5681 +	return GetTrapHandler();
  1.5682 +	}
  1.5683 +
  1.5684 +
  1.5685 +
  1.5686 +
  1.5687 +EXPORT_C TTrapHandler *User::SetTrapHandler(TTrapHandler *aHandler)
  1.5688 +/**
  1.5689 +Sets the current thread's trap handler and returns a pointer to any pre-existing 
  1.5690 +trap handler.
  1.5691 +
  1.5692 +Pass a NULL pointer to this function to clear the trap handler.
  1.5693 +
  1.5694 +The trap handler works with the TRAP mechanism to handle the effects of a 
  1.5695 +leave.
  1.5696 +
  1.5697 +Note that TTrapHandler is an abstract base class; a trap handler must be
  1.5698 +implemented as a derived class.
  1.5699 +
  1.5700 +@param aHandler A pointer to the trap handler which is to be installed as 
  1.5701 +                the current thread's trap handler.
  1.5702 +                
  1.5703 +@return A pointer to the current thread's pre-existing trap handler, if any. 
  1.5704 +        NULL, if no pre-existing trap handler is set.
  1.5705 +        
  1.5706 +@see TRAP
  1.5707 +@see TRAPD
  1.5708 +*/
  1.5709 +	{
  1.5710 +
  1.5711 +	TTrapHandler* prev;
  1.5712 +#if defined(__USERSIDE_THREAD_DATA__) && defined(__LEAVE_EQUALS_THROW__)
  1.5713 +	prev = LocalThreadData()->iTrapHandler;
  1.5714 +#else
  1.5715 +	prev = Exec::SetTrapHandler(aHandler);
  1.5716 +#endif
  1.5717 +#ifdef __USERSIDE_THREAD_DATA__
  1.5718 +	LocalThreadData()->iTrapHandler = aHandler;
  1.5719 +#endif
  1.5720 +	return prev;	
  1.5721 +	}
  1.5722 +
  1.5723 +#ifndef __LEAVE_EQUALS_THROW__
  1.5724 +EXPORT_C TTrapHandler* User::MarkCleanupStack()
  1.5725 +/**
  1.5726 +If there's a TTrapHandler installed marks the cleanup stack and returns 
  1.5727 +the TTrapHandler for subsequent use in UnMarkCleanupStack. 
  1.5728 +
  1.5729 +Only intended for use in the defintion of TRAP and TRAPD and only when 
  1.5730 +User::Leave is defined in terms of THROW.
  1.5731 +
  1.5732 +@return A pointer to the current thread's pre-existing trap handler, if any. 
  1.5733 +        NULL, if no pre-existing trap handler is set.
  1.5734 +
  1.5735 +@see TRAP
  1.5736 +@see TRAPD
  1.5737 +*/
  1.5738 +	{ 
  1.5739 +	return (TTrapHandler*)0; 
  1.5740 +	}
  1.5741 +
  1.5742 +
  1.5743 +EXPORT_C void User::UnMarkCleanupStack(TTrapHandler* /*aHandler*/)
  1.5744 +/**
  1.5745 +If passed a non-null TTrapHandler unmarks the cleanup stack.
  1.5746 +
  1.5747 +Only intended for use in the defintion of TRAP and TRAPD and only when 
  1.5748 +User::Leave is defined in terms of THROW.
  1.5749 +
  1.5750 +@see TRAP
  1.5751 +@see TRAPD
  1.5752 +*/
  1.5753 +	{}
  1.5754 +
  1.5755 +#else
  1.5756 +
  1.5757 +EXPORT_C TTrapHandler* User::MarkCleanupStack()
  1.5758 +/**
  1.5759 +If there's a TTrapHandler installed marks the cleanup stack and returns 
  1.5760 +the TTrapHandler for subsequent use in UnMarkCleanupStack. 
  1.5761 +
  1.5762 +Only intended for use in the defintion of TRAP and TRAPD and only when 
  1.5763 +User::Leave is defined in terms of THROW.
  1.5764 +
  1.5765 +@return A pointer to the current thread's pre-existing trap handler, if any. 
  1.5766 +        NULL, if no pre-existing trap handler is set.
  1.5767 +
  1.5768 +@see TRAP
  1.5769 +@see TRAPD
  1.5770 +*/
  1.5771 +	{
  1.5772 +
  1.5773 +	TTrapHandler* pH = GetTrapHandler();
  1.5774 +	if (pH)
  1.5775 +		pH->Trap();
  1.5776 +	return pH;
  1.5777 +	}
  1.5778 +
  1.5779 +EXPORT_C void User::UnMarkCleanupStack(TTrapHandler* aHandler)
  1.5780 +/**
  1.5781 +If passed a non-null TTrapHandler unmarks the cleanup stack.
  1.5782 +
  1.5783 +Only intended for use in the defintion of TRAP and TRAPD and only when 
  1.5784 +User::Leave is defined in terms of THROW.
  1.5785 +
  1.5786 +@see TRAP
  1.5787 +@see TRAPD
  1.5788 +*/
  1.5789 +	{
  1.5790 +
  1.5791 +	if (aHandler)
  1.5792 +		aHandler->UnTrap();
  1.5793 +	}
  1.5794 +
  1.5795 +#endif
  1.5796 +
  1.5797 +
  1.5798 +EXPORT_C TInt User::Beep(TInt aFrequency,TTimeIntervalMicroSeconds32 aDuration)
  1.5799 +/**
  1.5800 +Makes a beep tone with a specified frequency and duration.
  1.5801 +
  1.5802 +This function should not be used. It exists to maintain compatibility with
  1.5803 +older versions of Symban OS.
  1.5804 +*/
  1.5805 +	{
  1.5806 +
  1.5807 +	return Exec::HalFunction(EHalGroupSound,ESoundHalBeep,(TAny*)aFrequency,(TAny*)aDuration.Int());
  1.5808 +	}
  1.5809 +
  1.5810 +
  1.5811 +
  1.5812 +
  1.5813 +// Unused, exists only for BC reasons
  1.5814 +EXPORT_C TInt UserSvr::HalGet(TInt, TAny*)
  1.5815 +	{
  1.5816 +	return KErrNotSupported;
  1.5817 +	}
  1.5818 +
  1.5819 +// Unused, exists only for BC reasons
  1.5820 +EXPORT_C TInt UserSvr::HalSet(TInt, TAny*)
  1.5821 +	{
  1.5822 +	return KErrNotSupported;
  1.5823 +	}
  1.5824 +
  1.5825 +EXPORT_C TInt UserSvr::HalFunction(TInt aGroup, TInt aFunction, TAny* a1, TAny* a2)
  1.5826 +	{
  1.5827 +
  1.5828 +	return Exec::HalFunction(aGroup, aFunction, a1, a2);
  1.5829 +	}
  1.5830 +
  1.5831 +EXPORT_C TInt UserSvr::HalFunction(TInt aGroup, TInt aFunction, TAny* a1, TAny* a2, TInt aDeviceNumber)
  1.5832 +	{
  1.5833 +
  1.5834 +	return Exec::HalFunction(aGroup | (aDeviceNumber<<16), aFunction, a1, a2);
  1.5835 +	}
  1.5836 +
  1.5837 +/**
  1.5838 +@capability WriteDeviceData
  1.5839 +*/
  1.5840 +EXPORT_C TInt UserSvr::SetMemoryThresholds(TInt aLowThreshold, TInt aGoodThreshold)
  1.5841 +	{
  1.5842 +	return Exec::SetMemoryThresholds(aLowThreshold,aGoodThreshold);
  1.5843 +	}
  1.5844 +
  1.5845 +/**
  1.5846 +@deprecated
  1.5847 +@internalAll
  1.5848 +@return EFalse
  1.5849 +*/
  1.5850 +EXPORT_C TBool UserSvr::IpcV1Available()
  1.5851 +	{
  1.5852 +	return EFalse;
  1.5853 +	}
  1.5854 +
  1.5855 +
  1.5856 +
  1.5857 +EXPORT_C void User::SetDebugMask(TUint32 aVal)
  1.5858 +/**
  1.5859 +Sets the debug mask.
  1.5860 +
  1.5861 +@param aVal A set of bit values as defined in nk_trace.h
  1.5862 +*/
  1.5863 +	{
  1.5864 +	Exec::SetDebugMask(aVal);
  1.5865 +	}
  1.5866 +
  1.5867 +EXPORT_C void User::SetDebugMask(TUint32 aVal, TUint aIndex)
  1.5868 +/**
  1.5869 +Sets the debug mask at the given index
  1.5870 +
  1.5871 +@param aVal A set of bit values as defined in nk_trace.h
  1.5872 +@param aIndex An index of which 32 bit mask word is to be accessed
  1.5873 +*/
  1.5874 +	{
  1.5875 +	Exec::SetDebugMaskIndex(aVal, aIndex);
  1.5876 +	}
  1.5877 +
  1.5878 +
  1.5879 +/**
  1.5880 +Gets machine information.
  1.5881 +
  1.5882 +@publishedPartner
  1.5883 +@deprecated Use HAL::Get() from the HAL library instead.
  1.5884 +*/
  1.5885 +EXPORT_C TInt UserHal::MachineInfo(TDes8& anInfo)
  1.5886 +    {
  1.5887 +	TInt bufLength=anInfo.MaxLength();
  1.5888 +	__ASSERT_ALWAYS(bufLength==sizeof(TMachineInfoV2) || bufLength==sizeof(TMachineInfoV1),Panic(ETDes8BadDescriptorType));
  1.5889 +
  1.5890 +	// assemble a TMachineInfoV1 buffer
  1.5891 +	TMachineInfoV2* info=&((TMachineInfoV2Buf&)anInfo)();
  1.5892 +	// Variant stuff
  1.5893 +	TVariantInfoV01Buf infoBuf;
  1.5894 +	TInt r = Exec::HalFunction(EHalGroupVariant, EVariantHalVariantInfo, (TAny*)&infoBuf, NULL);
  1.5895 +	if (KErrNone != r) return r;			// must always be implemented!
  1.5896 +	TVariantInfoV01& variantInfo = infoBuf();
  1.5897 +
  1.5898 +	info->iRomVersion=variantInfo.iRomVersion;
  1.5899 +	info->iMachineUniqueId=variantInfo.iMachineUniqueId;
  1.5900 +	info->iLedCapabilities=variantInfo.iLedCapabilities;
  1.5901 +	info->iProcessorClockInKHz=variantInfo.iProcessorClockInKHz;
  1.5902 +	info->iSpeedFactor=variantInfo.iSpeedFactor;
  1.5903 +
  1.5904 +	// Video driver stuff
  1.5905 +	TVideoInfoV01Buf vidinfoBuf;
  1.5906 +	r = Exec::HalFunction(EHalGroupDisplay, EDisplayHalCurrentModeInfo, (TAny*)&vidinfoBuf, NULL);
  1.5907 +	if (KErrNone == r)
  1.5908 +		{
  1.5909 +		TVideoInfoV01& vidinfo = vidinfoBuf();
  1.5910 +		info->iDisplaySizeInPixels=vidinfo.iSizeInPixels;
  1.5911 +		info->iPhysicalScreenSize=vidinfo.iSizeInTwips;
  1.5912 +		}
  1.5913 +	else								// no display driver
  1.5914 +		{
  1.5915 +		info->iDisplaySizeInPixels.iWidth=0;
  1.5916 +		info->iDisplaySizeInPixels.iHeight=0;
  1.5917 +		info->iPhysicalScreenSize.iWidth=0;
  1.5918 +		info->iPhysicalScreenSize.iHeight=0;
  1.5919 +		}
  1.5920 +	TInt colors = 0;
  1.5921 +	r = Exec::HalFunction(EHalGroupDisplay, EDisplayHalColors, &colors, NULL);
  1.5922 +	info->iMaximumDisplayColors=(KErrNone == r)?colors:0;
  1.5923 +	TInt val;
  1.5924 +	info->iBacklightPresent= (KErrNone == Exec::HalFunction(EHalGroupDisplay, EDisplayHalBacklightOn, &val, NULL));
  1.5925 +
  1.5926 +	// Pointing device stuff
  1.5927 +	TDigitiserInfoV01Buf xyinfoBuf;
  1.5928 +	r = Exec::HalFunction(EHalGroupDigitiser, EDigitiserHalXYInfo, (TAny*)&xyinfoBuf, NULL);
  1.5929 +	if (KErrNone == r)
  1.5930 +		{
  1.5931 +		info->iXYInputType=EXYInputPointer;					// XY is Digitiser
  1.5932 +		TDigitiserInfoV01& xyinfo = xyinfoBuf();
  1.5933 +		info->iXYInputSizeInPixels=xyinfo.iDigitiserSize;
  1.5934 +		info->iOffsetToDisplayInPixels=xyinfo.iOffsetToDisplay;
  1.5935 +		}
  1.5936 +	else
  1.5937 +		{
  1.5938 +		TMouseInfoV01Buf mouseinfoBuf;
  1.5939 +		r = Exec::HalFunction(EHalGroupMouse, EMouseHalMouseInfo, (TAny*)&mouseinfoBuf, NULL);
  1.5940 +		if (KErrNone == r)
  1.5941 +			{
  1.5942 +			info->iXYInputType=EXYInputMouse;				// XY is Mouse
  1.5943 +			TMouseInfoV01& mouseinfo = mouseinfoBuf();
  1.5944 +			info->iXYInputSizeInPixels=mouseinfo.iMouseAreaSize;
  1.5945 +			info->iOffsetToDisplayInPixels=mouseinfo.iOffsetToDisplay;
  1.5946 +			}
  1.5947 +		else
  1.5948 +			{
  1.5949 +			info->iXYInputType=EXYInputNone;				// no XY
  1.5950 +			info->iXYInputSizeInPixels.iWidth=0;
  1.5951 +			info->iXYInputSizeInPixels.iHeight=0;
  1.5952 +			info->iOffsetToDisplayInPixels.iX=0;
  1.5953 +			info->iOffsetToDisplayInPixels.iY=0;
  1.5954 +			}
  1.5955 +		}
  1.5956 +
  1.5957 +	// Keyboard stuff
  1.5958 +	TKeyboardInfoV01Buf kbdinfoBuf;
  1.5959 +	info->iKeyboardPresent= (KErrNone == Exec::HalFunction(EHalGroupKeyboard, EKeyboardHalKeyboardInfo, (TAny*)&kbdinfoBuf, NULL));
  1.5960 +
  1.5961 +	// Unused, obsolete parameters
  1.5962 +	info->iKeyboardId=0;
  1.5963 +	info->iDisplayId=0;
  1.5964 +	if(bufLength==sizeof(TMachineInfoV2))
  1.5965 +		{
  1.5966 +		// assemble a TMachineInfoV2 buffer
  1.5967 +		info->iLanguageIndex=0;
  1.5968 +		info->iKeyboardIndex=0;
  1.5969 +		}
  1.5970 +
  1.5971 +	anInfo.SetLength(bufLength);
  1.5972 +
  1.5973 +    return KErrNone;
  1.5974 +    }
  1.5975 +
  1.5976 +/**
  1.5977 +Gets memory information.
  1.5978 +
  1.5979 +@see HAL::Get()
  1.5980 +
  1.5981 +@publishedPartner
  1.5982 +@deprecated Use HAL::Get() from the HAL library instead with attributes EMemoryRAM, EMemoryRAMFree or EMemoryROM.
  1.5983 +*/
  1.5984 +EXPORT_C TInt UserHal::MemoryInfo(TDes8& anInfo)
  1.5985 +    {
  1.5986 +    return Exec::HalFunction(EHalGroupKernel,EKernelHalMemoryInfo,(TAny*)&anInfo,NULL);
  1.5987 +    }
  1.5988 +
  1.5989 +/**
  1.5990 +Gets ROM configuration information.
  1.5991 +
  1.5992 +@publishedPartner
  1.5993 +@deprecated No replacement.
  1.5994 +*/
  1.5995 +EXPORT_C TInt UserHal::RomInfo(TDes8& anInfo)
  1.5996 +    {
  1.5997 +    return Exec::HalFunction(EHalGroupKernel,EKernelHalRomInfo,(TAny*)&anInfo,NULL);
  1.5998 +    }
  1.5999 +
  1.6000 +
  1.6001 +
  1.6002 +
  1.6003 +/**
  1.6004 +Gets drive information.
  1.6005 +
  1.6006 +@param anInfo A package buffer (TPckgBuf) containing a TDriveInfoV1 structure.
  1.6007 +              On return, this structure will contain the drive information.
  1.6008 +	
  1.6009 +@return KErrNone 
  1.6010 +
  1.6011 +@see TDriveInfoV1Buf
  1.6012 +@see TDriveInfoV1
  1.6013 +@see TPckgBuf
  1.6014 +*/
  1.6015 +EXPORT_C TInt UserHal::DriveInfo(TDes8& anInfo)
  1.6016 +    {
  1.6017 +	TDriveInfoV1Buf8 anInfo8;
  1.6018 +    TInt r = Exec::HalFunction(EHalGroupMedia,EMediaHalDriveInfo,(TAny*)&anInfo8,NULL);
  1.6019 +	TDriveInfoV18& driveInfo8 = anInfo8();
  1.6020 +	TDriveInfoV1* driveInfo = NULL;
  1.6021 +	switch(((SBuf8*)&anInfo)->length>>KShiftDesType8) //type
  1.6022 +		{
  1.6023 +		case EPtr:
  1.6024 +			 driveInfo = &((TPckg<TDriveInfoV1>&)anInfo)();
  1.6025 +			 break;
  1.6026 +		case EBuf:		
  1.6027 +			 driveInfo = &((TDriveInfoV1Buf&)anInfo)();
  1.6028 +			 break;
  1.6029 +		default:
  1.6030 +			__ASSERT_ALWAYS(EFalse,Panic(ETDes8BadDescriptorType));
  1.6031 +		}
  1.6032 +
  1.6033 +	// A compile time assert to make sure that this function is examined if TDriveInfoV1
  1.6034 +	// structure changes
  1.6035 +	extern int TDriveInfoV1_structure_assert[(
  1.6036 +		_FOFF(TDriveInfoV1,iRegisteredDriveBitmask)+4 == sizeof(TDriveInfoV1)
  1.6037 +		&&
  1.6038 +		sizeof(TDriveInfoV1) == 816
  1.6039 +		)?1:-1];
  1.6040 +	(void)TDriveInfoV1_structure_assert;
  1.6041 +
  1.6042 +	// Set length to size of old EKA1 TDriveInfoV1 (Will Panic if not big enough)
  1.6043 +	TInt len = (TUint)_FOFF(TDriveInfoV1,iRegisteredDriveBitmask);
  1.6044 +	anInfo.SetLength(len);
  1.6045 +
  1.6046 +	// Fill in info for old EKA1 TDriveInfoV1
  1.6047 +	driveInfo->iTotalSupportedDrives = driveInfo8.iTotalSupportedDrives;
  1.6048 +	driveInfo->iTotalSockets = driveInfo8.iTotalSockets;
  1.6049 +	driveInfo->iRuggedFileSystem = driveInfo8.iRuggedFileSystem;
  1.6050 +	TInt index;
  1.6051 +	for(index=0;index<KMaxLocalDrives;index++)
  1.6052 +		driveInfo->iDriveName[index].Copy(driveInfo8.iDriveName[index]);
  1.6053 +	for(index=0;index<KMaxPBusSockets;index++)
  1.6054 +		driveInfo->iSocketName[index].Copy(driveInfo8.iSocketName[index]);
  1.6055 +
  1.6056 +	// If anInfo is big enough then set new EKA2 members of TDriveInfoV1
  1.6057 +	if((TUint)anInfo.MaxLength()>=(TUint)sizeof(TDriveInfoV1))
  1.6058 +		{
  1.6059 +		anInfo.SetLength(sizeof(TDriveInfoV1));
  1.6060 +		driveInfo->iRegisteredDriveBitmask = driveInfo8.iRegisteredDriveBitmask;
  1.6061 +		}
  1.6062 +	return r;
  1.6063 +    }
  1.6064 +
  1.6065 +
  1.6066 +
  1.6067 +
  1.6068 +/**
  1.6069 +Gets the startup reason.
  1.6070 +
  1.6071 +@see HAL::Get() 
  1.6072 +
  1.6073 +@publishedPartner
  1.6074 +@deprecated Use HAL::Get() from the HAL library instead with attributes ESystemStartupReason.
  1.6075 +*/
  1.6076 +EXPORT_C TInt UserHal::StartupReason(TMachineStartupType& aReason)
  1.6077 +    {
  1.6078 +    return Exec::HalFunction(EHalGroupKernel,EKernelHalStartupReason,(TAny*)&aReason,NULL);
  1.6079 +    }
  1.6080 +
  1.6081 +
  1.6082 +
  1.6083 +
  1.6084 +/**
  1.6085 +Gets the reason why the kernel last faulted.
  1.6086 +
  1.6087 +@param aReason An integer that, on return, contains the reason code describing
  1.6088 +               why the kernel faulted. This is the fault number passed 
  1.6089 +               in a call to Kern::Fault().
  1.6090 +
  1.6091 +@return KErrNone
  1.6092 +
  1.6093 +@see Kern::Fault()
  1.6094 +*/
  1.6095 +EXPORT_C TInt UserHal::FaultReason(TInt &aReason)
  1.6096 +	{
  1.6097 +
  1.6098 +	return Exec::HalFunction(EHalGroupKernel,EKernelHalFaultReason,(TAny *)&aReason,NULL);
  1.6099 +	}
  1.6100 +
  1.6101 +
  1.6102 +
  1.6103 +
  1.6104 +/**
  1.6105 +Gets the exception Id that describes the type of fault when
  1.6106 +the kernel last faulted.
  1.6107 +
  1.6108 +The Id is the value contained in TArmExcInfo::iExcCode.
  1.6109 + 
  1.6110 +@param anId An integer that, on return, contains the exception Id.
  1.6111 +
  1.6112 +@return KErrNone
  1.6113 +
  1.6114 +@see TArmExcInfo::iExcCode
  1.6115 +@see TArmExcInfo
  1.6116 +*/
  1.6117 +EXPORT_C TInt UserHal::ExceptionId(TInt &anId)
  1.6118 +	{
  1.6119 +
  1.6120 +	return Exec::HalFunction(EHalGroupKernel,EKernelHalExceptionId, (TAny *)&anId, NULL);
  1.6121 +	}
  1.6122 +
  1.6123 +
  1.6124 +
  1.6125 +/**
  1.6126 +Gets the available exception information that describes the last kernel fault.
  1.6127 +
  1.6128 +@param aInfo A TExcInfo structure that, on return, contains the available
  1.6129 +             exception information.
  1.6130 +             
  1.6131 +@return KErrNone
  1.6132 +
  1.6133 +@see TExcInfo        
  1.6134 +*/
  1.6135 +EXPORT_C TInt UserHal::ExceptionInfo(TExcInfo &aInfo)
  1.6136 +	{
  1.6137 +
  1.6138 +	return Exec::HalFunction(EHalGroupKernel,EKernelHalExceptionInfo, (TAny *)&aInfo, NULL);
  1.6139 +	}
  1.6140 +
  1.6141 +
  1.6142 +
  1.6143 +
  1.6144 +/**
  1.6145 +Gets the page size for this device.
  1.6146 +
  1.6147 +@param anId An integer that, on return, contains the page size, in bytes,
  1.6148 +            for this device.
  1.6149 +
  1.6150 +@return KErrNone
  1.6151 +*/
  1.6152 +EXPORT_C TInt UserHal::PageSizeInBytes(TInt& aSize)
  1.6153 +    {
  1.6154 +
  1.6155 +    return Exec::HalFunction(EHalGroupKernel,EKernelHalPageSizeInBytes,(TAny*)&aSize,NULL);
  1.6156 +    }
  1.6157 +
  1.6158 +
  1.6159 +
  1.6160 +
  1.6161 +/**
  1.6162 +Switches the  device off.
  1.6163 +
  1.6164 +@return KErrNone, if successful; KErrPermissionDenied, if the calling process
  1.6165 +        has insufficient capability.
  1.6166 +
  1.6167 +@capability PowerMgmt
  1.6168 +*/
  1.6169 +EXPORT_C TInt UserHal::SwitchOff()
  1.6170 +    {
  1.6171 +	if(!RProcess().HasCapability(ECapabilityPowerMgmt,__PLATSEC_DIAGNOSTIC_STRING("Checked by UserHal::SwitchOff")))
  1.6172 +		return KErrPermissionDenied;
  1.6173 +	TInt r = Power::EnableWakeupEvents(EPwStandby);
  1.6174 +	if(r!=KErrNone)
  1.6175 +		return r;
  1.6176 +	TRequestStatus s;
  1.6177 +	Power::RequestWakeupEventNotification(s);
  1.6178 +	Power::PowerDown();
  1.6179 +	User::WaitForRequest(s);
  1.6180 +	return s.Int();
  1.6181 +//	return Exec::HalFunction(EHalGroupPower,EPowerHalSwitchOff,NULL,NULL);
  1.6182 +	}
  1.6183 +
  1.6184 +
  1.6185 +
  1.6186 +
  1.6187 +/**
  1.6188 +Sets the calibration data for the digitiser (i.e. XY) input device.
  1.6189 +
  1.6190 +@param aCalibration The calibration data.
  1.6191 +
  1.6192 +@return KErrNone, if successful; KErrPermissionDenied, if the calling process
  1.6193 +        has insufficient capability.
  1.6194 +
  1.6195 +@see TDigitizerCalibration
  1.6196 +
  1.6197 +@capability WriteDeviceData
  1.6198 +*/
  1.6199 +EXPORT_C TInt UserHal::SetXYInputCalibration(const TDigitizerCalibration& aCalibration)
  1.6200 +    {
  1.6201 +    return Exec::HalFunction(EHalGroupDigitiser,EDigitiserHalSetXYInputCalibration,(TAny*)&aCalibration,NULL);
  1.6202 +    }
  1.6203 +
  1.6204 +
  1.6205 +
  1.6206 +
  1.6207 +/**
  1.6208 +Gets the points on the display that the user should point to in order
  1.6209 +to calibrate the digitiser (i.e. XY) input device.
  1.6210 +
  1.6211 +@param aCalibration A TDigitizerCalibration object that, on return, contains
  1.6212 +       the appropriate information.
  1.6213 +       
  1.6214 +@return KerrNone, if successful; otherwise one of the other system wide
  1.6215 +        error codes. 
  1.6216 +*/
  1.6217 +EXPORT_C TInt UserHal::CalibrationPoints(TDigitizerCalibration& aCalibration)
  1.6218 +    {
  1.6219 +
  1.6220 +    return Exec::HalFunction(EHalGroupDigitiser,EDigitiserHalCalibrationPoints,(TAny*)&aCalibration,NULL);
  1.6221 +    }
  1.6222 +
  1.6223 +
  1.6224 +
  1.6225 +
  1.6226 +/**
  1.6227 +Gets the platform tick period.
  1.6228 +
  1.6229 +@param aTime The tick period in microseconds.
  1.6230 +
  1.6231 +@return KErrNone, if successful; otherwise one of the other system wide
  1.6232 +        error codes.
  1.6233 +*/
  1.6234 +EXPORT_C TInt UserHal::TickPeriod(TTimeIntervalMicroSeconds32 &aTime)
  1.6235 +    {
  1.6236 +
  1.6237 +    return Exec::HalFunction(EHalGroupKernel,EKernelHalTickPeriod,(TAny*)&aTime,NULL);
  1.6238 +    }
  1.6239 +
  1.6240 +
  1.6241 +
  1.6242 +/**
  1.6243 +Saves the current digitiser (i.e. XY) input device calibration data.
  1.6244 +
  1.6245 +@return KErrNone, if successful; otherwise one of the other system wide
  1.6246 +        error codes, e.g. KErrNotSupported.
  1.6247 +*/
  1.6248 +EXPORT_C TInt UserHal::SaveXYInputCalibration()
  1.6249 +    {
  1.6250 +
  1.6251 +    return Exec::HalFunction(EHalGroupDigitiser,EDigitiserHalSaveXYInputCalibration,NULL,NULL);
  1.6252 +    }
  1.6253 +
  1.6254 +
  1.6255 +
  1.6256 +
  1.6257 +/**
  1.6258 +Restores the digitiser (i.e. XY) input device calibration data.
  1.6259 +
  1.6260 +@param aType A TDigitizerCalibration object that, on return, contains
  1.6261 +       the calibration data.
  1.6262 +
  1.6263 +@return KErrNone, if successful; KErrPermissionDenied, if the calling process
  1.6264 +        has insufficient capability; otherwise one of the other system wide
  1.6265 +        error codes, e.g. KErrNotSupported.
  1.6266 +
  1.6267 +@capability WriteDeviceData
  1.6268 +*/
  1.6269 +EXPORT_C TInt UserHal::RestoreXYInputCalibration(TDigitizerCalibrationType aType)
  1.6270 +    {
  1.6271 +    return Exec::HalFunction(EHalGroupDigitiser,EDigitiserHalRestoreXYInputCalibration,(TAny*)aType,NULL);
  1.6272 +	}
  1.6273 +
  1.6274 +
  1.6275 +
  1.6276 +
  1.6277 +/**
  1.6278 +Gets the machine configuration.
  1.6279 +
  1.6280 +@param aConfig On return contains the machine configuration data.
  1.6281 +@param aSize   On return, contains the size of the data.
  1.6282 +
  1.6283 +@return KErrNone, if sucessful, otherwise one of the other system-wide
  1.6284 +        error codes.
  1.6285 +
  1.6286 +@capability ReadDeviceData
  1.6287 +*/
  1.6288 +EXPORT_C TInt User::MachineConfiguration(TDes8& aConfig,TInt& aSize)
  1.6289 +    {
  1.6290 +	return(Exec::MachineConfiguration(aConfig,aSize));
  1.6291 +    }
  1.6292 +
  1.6293 +
  1.6294 +
  1.6295 +
  1.6296 +EXPORT_C TInt RDebug::Print(TRefByValue<const TDesC> aFmt,...)
  1.6297 +//
  1.6298 +// Print to the comms port
  1.6299 +//
  1.6300 +    {
  1.6301 +
  1.6302 +	TestOverflowTruncate overflow;
  1.6303 +	// coverity[var_decl]
  1.6304 +	VA_LIST list;
  1.6305 +	VA_START(list,aFmt);
  1.6306 +	TBuf<0x100> buf;
  1.6307 +	// coverity[uninit_use_in_call]
  1.6308 +	TRAP_IGNORE(buf.AppendFormatList(aFmt,list,&overflow)); // ignore leave in TTimeOverflowLeave::Overflow()
  1.6309 +#ifdef _UNICODE
  1.6310 +	TPtr8 p(buf.Collapse());
  1.6311 +	Exec::DebugPrint((TAny*)&p, 0);
  1.6312 +#else
  1.6313 +	Exec::DebugPrint((TAny*)&buf, 0);
  1.6314 +#endif
  1.6315 +	return 0;
  1.6316 +    }
  1.6317 +
  1.6318 +class TestOverflowTruncate8 : public TDes8Overflow
  1.6319 +	{
  1.6320 +public:
  1.6321 +	virtual void Overflow(TDes8& /*aDes*/) {}
  1.6322 +	};
  1.6323 +
  1.6324 +EXPORT_C void RDebug::Printf(const char* aFmt, ...)
  1.6325 +//
  1.6326 +// Print to the comms port
  1.6327 +//
  1.6328 +    {
  1.6329 +
  1.6330 +	TestOverflowTruncate8 overflow;
  1.6331 +	// coverity[var_decl]
  1.6332 +	VA_LIST list;
  1.6333 +	VA_START(list,aFmt);
  1.6334 +	TPtrC8 fmt((const TText8*)aFmt);
  1.6335 +	TBuf8<0x100> buf;
  1.6336 +	// coverity[uninit_use_in_call]
  1.6337 +	TRAP_IGNORE(buf.AppendFormatList(fmt,list,&overflow));	
  1.6338 +	Exec::DebugPrint((TAny*)&buf, 0);
  1.6339 +    }
  1.6340 +
  1.6341 +EXPORT_C void RDebug::RawPrint(const TDesC8& aDes)
  1.6342 +	{
  1.6343 +	Exec::DebugPrint((TAny*)&aDes, 1);
  1.6344 +	}
  1.6345 +
  1.6346 +EXPORT_C void RDebug::RawPrint(const TDesC16& aDes)
  1.6347 +//
  1.6348 +// Print to the comms port
  1.6349 +//
  1.6350 +    {
  1.6351 +	TBuf8<0x100> aDes8;
  1.6352 +	if(aDes.Length()>0x100)
  1.6353 +		{
  1.6354 +		TPtrC ptr(aDes.Ptr(), 0x100);
  1.6355 +		aDes8.Copy(ptr);
  1.6356 +		}
  1.6357 +	else
  1.6358 +		aDes8.Copy(aDes);
  1.6359 +	Exec::DebugPrint((TAny*)&aDes8, 1);
  1.6360 +	}
  1.6361 +
  1.6362 +EXPORT_C TUint32 Math::Random()
  1.6363 +/**
  1.6364 +Gets 32 random bits from the kernel's random pool.
  1.6365 +
  1.6366 +@return The 32 random bits.
  1.6367 +*/
  1.6368 +	{
  1.6369 +
  1.6370 +	return Exec::MathRandom();
  1.6371 +	}
  1.6372 +
  1.6373 +
  1.6374 +
  1.6375 +EXPORT_C void User::IMB_Range(TAny* aStart, TAny* aEnd)
  1.6376 +/**
  1.6377 +Does the necessary preparations to guarantee correct execution of code in the 
  1.6378 +specified virtual address range.
  1.6379 +
  1.6380 +The function assumes that this code has been loaded or modified by user code.
  1.6381 +Calling this function against uncommitted memory region is considered as S/W
  1.6382 +bug and may generate exception on some memory models.
  1.6383 +
  1.6384 +The specified addresses are associated with a user writable code chunk as 
  1.6385 +created by RChunk::CreateLocalCode().
  1.6386 +
  1.6387 +The function cleans the data cache to ensure that written data has been
  1.6388 +committed to main memory and then flushes the instruction cache and branch
  1.6389 +target buffer (BTB) to ensure that the code is loaded from main memory when
  1.6390 +it is executed. 
  1.6391 +The Kernel uses the size of the range specified to decide whether to clean/flush 
  1.6392 +line-by-line or to simply clean/flush the entire cache.
  1.6393 +
  1.6394 +@param aStart The start virtual address of the region.
  1.6395 +@param aEnd   The end virtual address of the region. This location is not within 
  1.6396 +              the region.
  1.6397 +              
  1.6398 +@see RChunk::CreateLocalCode()
  1.6399 +@see UserHeap::ChunkHeap()
  1.6400 +*/
  1.6401 +	{
  1.6402 +
  1.6403 +	Exec::IMB_Range(aStart,(TUint32)aEnd-(TUint32)aStart);
  1.6404 +	}
  1.6405 +
  1.6406 +
  1.6407 +
  1.6408 +
  1.6409 +/**
  1.6410 +Sets the specified handle into the specified environment data slot
  1.6411 +for this process.
  1.6412 +
  1.6413 +The APPARC framework (class CApaApplication etc.) uses some of the slots internally,
  1.6414 +so programs that use this framework should ensure that they only use slots available
  1.6415 +for public use.
  1.6416 +
  1.6417 +@param aSlot   An index that identifies the environment data slot.
  1.6418 +               This is a value relative to zero;
  1.6419 +               i.e. 0 is the first item/slot.
  1.6420 +               This can range from 0 to 15.
  1.6421 +@param aHandle The handle to be passed to this process.
  1.6422 +
  1.6423 +@return KErrNone, always.
  1.6424 +
  1.6425 +@panic KERN-EXEC 46 if this function is called by a thread running
  1.6426 +                    in a process that is not the creator of this process, or
  1.6427 +                    the handle is not local.
  1.6428 +@panic KERN-EXEC 51 if aSlot is negative or is greater than or equal to
  1.6429 +                    the value of KArgIndex. 
  1.6430 +@panic KERN-EXEC 52 if the specified slot is already in use.
  1.6431 +
  1.6432 +@see CApaApplication
  1.6433 +@see CApaCommandLine::EnvironmentSlotForPublicUse()
  1.6434 +*/
  1.6435 +EXPORT_C TInt RProcess::SetParameter(TInt aSlot, RHandleBase aHandle)
  1.6436 +	{
  1.6437 +	return Exec::ProcessSetHandleParameter(iHandle, aSlot, aHandle.Handle());
  1.6438 +	}
  1.6439 +
  1.6440 +
  1.6441 +
  1.6442 +
  1.6443 +/**
  1.6444 +Sets the specified 16-bit descriptor data into the specified environment
  1.6445 +data slot for this process.
  1.6446 +
  1.6447 +The APPARC framework (class CApaApplication etc.) uses some of the slots internally,
  1.6448 +so programs that use this framework should ensure that they only use slots available
  1.6449 +for public use.
  1.6450 +
  1.6451 +@param aSlot   An index that identifies the environment data slot.
  1.6452 +               This is a value relative to zero;
  1.6453 +               i.e. 0 is the first item/slot.
  1.6454 +               This can range from 0 to 15.
  1.6455 +@param aDes    The 16-bit descriptor containing data be passed to this process.
  1.6456 +
  1.6457 +@return KErrNone, if successful, otherwise one of the other system
  1.6458 +        wide error codes.
  1.6459 +
  1.6460 +@panic KERN-EXEC 46 if this function is called by a thread running
  1.6461 +                    in a process that is not the creator of this process.
  1.6462 +@panic KERN-EXEC 51 if aSlot is negative or is greater than or equal to
  1.6463 +                    the value of KArgIndex. 
  1.6464 +@panic KERN-EXEC 52 if the specified slot is already in use.
  1.6465 +@panic KERN-EXEC 53 if the length of data passed is negative.
  1.6466 +
  1.6467 +@see CApaApplication
  1.6468 +@see CApaCommandLine::EnvironmentSlotForPublicUse()
  1.6469 +*/
  1.6470 +EXPORT_C TInt RProcess::SetParameter(TInt aSlot, const TDesC16& aDes)
  1.6471 +	{
  1.6472 +	return Exec::ProcessSetDataParameter(iHandle, aSlot, (const TUint8*)aDes.Ptr(), 2*aDes.Length());
  1.6473 +	}
  1.6474 +
  1.6475 +
  1.6476 +
  1.6477 +
  1.6478 +/**
  1.6479 +Sets the specified 8-bit descriptor data into the specified environment
  1.6480 +data slot for this process.
  1.6481 +
  1.6482 +The APPARC framework (class CApaApplication etc.) uses some of the slots internally,
  1.6483 +so programs that use this framework should ensure that they only use slots available
  1.6484 +for public use.
  1.6485 +
  1.6486 +@param aSlot   An index that identifies the environment data slot.
  1.6487 +               This is a value relative to zero;
  1.6488 +               i.e. 0 is the first item/slot.
  1.6489 +               This can range from 0 to 15.
  1.6490 +@param aDes    The 8-bit descriptor containing data be passed to this process.
  1.6491 +
  1.6492 +@return KErrNone, if successful, otherwise one of the other system
  1.6493 +        wide error codes.
  1.6494 +
  1.6495 +@panic KERN-EXEC 46 if this function is called by a thread running
  1.6496 +                    in a process that is not the creator of this process.
  1.6497 +@panic KERN-EXEC 51 if aSlot is negative or is greater than or equal to
  1.6498 +                    the value of KArgIndex. 
  1.6499 +@panic KERN-EXEC 52 if the specified slot is already in use.
  1.6500 +@panic KERN-EXEC 53 if the length of data passed is negative.
  1.6501 +
  1.6502 +@see CApaApplication
  1.6503 +@see CApaCommandLine::EnvironmentSlotForPublicUse()
  1.6504 +*/
  1.6505 +EXPORT_C TInt RProcess::SetParameter(TInt aSlot, const TDesC8& aDes)
  1.6506 +	{
  1.6507 +	return Exec::ProcessSetDataParameter(iHandle, aSlot, aDes.Ptr(), aDes.Length());
  1.6508 +	}
  1.6509 +
  1.6510 +
  1.6511 +
  1.6512 +
  1.6513 +/**
  1.6514 +Sets the specfied sub-session into the specified environment
  1.6515 +data slot for this process.
  1.6516 +
  1.6517 +The APPARC framework (class CApaApplication etc.) uses some of the slots internally,
  1.6518 +so programs that use this framework should ensure that they only use slots available
  1.6519 +for public use.
  1.6520 +
  1.6521 +@param aSlot    An index that identifies the environment data slot.
  1.6522 +                This is a value relative to zero;
  1.6523 +                i.e. 0 is the first item/slot.
  1.6524 +                This can range from 0 to 15.
  1.6525 +@param aSession The sub-session.
  1.6526 +
  1.6527 +@return KErrNone, if successful, otherwise one of the other system
  1.6528 +        wide error codes.
  1.6529 +
  1.6530 +@panic KERN-EXEC 46 if this function is called by a thread running
  1.6531 +                    in a process that is not the creator of this process.
  1.6532 +@panic KERN-EXEC 51 if aSlot is negative or is greater than or equal to
  1.6533 +                    the value of KArgIndex. 
  1.6534 +@panic KERN-EXEC 52 if the specified slot is already in use.
  1.6535 +@panic KERN-EXEC 53 if the length of data passed is negative.
  1.6536 +
  1.6537 +@see CApaApplication
  1.6538 +@see CApaCommandLine::EnvironmentSlotForPublicUse()
  1.6539 +*/
  1.6540 +EXPORT_C TInt RProcess::SetParameter(TInt aSlot, const RSubSessionBase& aSession)
  1.6541 +	{
  1.6542 +	TInt handle = aSession.SubSessionHandle();
  1.6543 +	return Exec::ProcessSetDataParameter(iHandle, aSlot, (const TUint8*)&handle, sizeof(handle));
  1.6544 +	}
  1.6545 +
  1.6546 +
  1.6547 +
  1.6548 +
  1.6549 +/**
  1.6550 +Sets the specfied integer value into the specified environment
  1.6551 +data slot for this process.
  1.6552 +
  1.6553 +The APPARC framework (class CApaApplication etc.) uses some of the slots internally,
  1.6554 +so programs that use this framework should ensure that they only use slots available
  1.6555 +for public use.
  1.6556 +
  1.6557 +@param aSlot   An index that identifies the environment data slot.
  1.6558 +               This is a value relative to zero;
  1.6559 +               i.e. 0 is the first item/slot.
  1.6560 +               This can range from 0 to 15.
  1.6561 +@param aData   The integer value.
  1.6562 +
  1.6563 +@return KErrNone, if successful, otherwise one of the other system
  1.6564 +        wide error codes.
  1.6565 +
  1.6566 +@panic KERN-EXEC 46 if this function is called by a thread running
  1.6567 +                    in a process that is not the creator of this process.
  1.6568 +@panic KERN-EXEC 51 if aSlot is negative or is greater than or equal to
  1.6569 +                    the value of KArgIndex. 
  1.6570 +@panic KERN-EXEC 52 if the specified slot is already in use.
  1.6571 +@panic KERN-EXEC 53 if the length of data passed is negative.
  1.6572 +
  1.6573 +@see CApaApplication
  1.6574 +@see CApaCommandLine::EnvironmentSlotForPublicUse()
  1.6575 +*/
  1.6576 +EXPORT_C TInt RProcess::SetParameter(TInt aSlot, TInt aData)
  1.6577 +	{
  1.6578 +	return Exec::ProcessSetDataParameter(iHandle, aSlot, (TUint8*)&aData, sizeof(aData));
  1.6579 +	}
  1.6580 +
  1.6581 +
  1.6582 +
  1.6583 +
  1.6584 +EXPORT_C TInt User::GetTIntParameter(TInt aSlot,  TInt& aData)
  1.6585 +/**
  1.6586 +Gets the specified environment data item belonging to the
  1.6587 +current process; this is assumed to be a 32 bit value.
  1.6588 +
  1.6589 +Environment data may be stored in the process and is passed to a child process
  1.6590 +on creation of that child process.
  1.6591 +
  1.6592 +On successful return from this function, the data item is deleted from
  1.6593 +the process. 
  1.6594 +
  1.6595 +@param aSlot An index that identifies the data item.
  1.6596 +             This is an index whose value is relative to zero;
  1.6597 +             i.e. 0 is the first item/slot.
  1.6598 +             This can range from 0 to 15, i.e. there are 16 slots. 
  1.6599 +
  1.6600 +@param aData On sucessful return, contains the environment data item.
  1.6601 +
  1.6602 +@return KErrNone, if successful;
  1.6603 +        KErrNotFound, if there is no data; 
  1.6604 +        KErrArgument, if the data is not binary data, or the data item in the
  1.6605 +                      process is longer than 32 bits.
  1.6606 +                      
  1.6607 +@panic KERN-EXEC 51, if aSlot is negative or is greater than or equal to 16.                                   
  1.6608 +*/
  1.6609 +	{
  1.6610 +	TInt ret = Exec::ProcessGetDataParameter(aSlot, (TUint8*)&aData, sizeof(TInt));
  1.6611 +	if (ret < 0)
  1.6612 +		return ret;
  1.6613 +	return KErrNone;
  1.6614 +	}
  1.6615 +
  1.6616 +
  1.6617 +
  1.6618 +
  1.6619 +EXPORT_C TInt User::ParameterLength(TInt aSlot)
  1.6620 +/**
  1.6621 +Gets the length of the specified item of environment data belonging to the
  1.6622 +current process.
  1.6623 +
  1.6624 +Environment data may be stored in the process and is passed to a child process
  1.6625 +on creation of that child process.
  1.6626 +
  1.6627 +@param aSlot An index that identifies the data item whose length is to be
  1.6628 +             retrieved. This is an index whose value is relative to zero;
  1.6629 +             i.e. 0 is the first item/slot.
  1.6630 +             This can range from 0 to 15, i.e. there are 16 slots.  
  1.6631 +             
  1.6632 +@return KErrNotFound, if there is no data; 
  1.6633 +        KErrArgument, if the data is not binary data;
  1.6634 +        The length of the data item.
  1.6635 +             
  1.6636 +@panic KERN-EXEC 51, if aSlot is negative or is greater than or equal to 16.             
  1.6637 +*/
  1.6638 +	{
  1.6639 +	TInt ret = Exec::ProcessDataParameterLength(aSlot);
  1.6640 +	return ret;
  1.6641 +	}
  1.6642 +
  1.6643 +
  1.6644 +
  1.6645 +
  1.6646 +EXPORT_C TInt User::GetDesParameter(TInt aSlot, TDes8& aDes)
  1.6647 +/**
  1.6648 +Gets the specified environment data item belonging to the
  1.6649 +current process; this is assumed to be an 8-bit descriptor.
  1.6650 +
  1.6651 +Environment data may be stored in the process and is passed to a child process
  1.6652 +on creation of that child process.
  1.6653 +
  1.6654 +On successful return from this function, the data item is deleted from
  1.6655 +the process. 
  1.6656 +
  1.6657 +@param aSlot An index that identifies the data item.
  1.6658 +             This is an index whose value is relative to zero;
  1.6659 +             i.e. 0 is the first item/slot.
  1.6660 +             This can range from 0 to 15, i.e. there are 16 slots. 
  1.6661 +
  1.6662 +@param aDes  On sucessful return, contains the environment data item; the
  1.6663 +             length of the descriptor is set to the length of the data item.
  1.6664 +
  1.6665 +@return KErrNone, if successful;
  1.6666 +        KErrNotFound, if there is no data; 
  1.6667 +        KErrArgument, if the data is not binary data, or the data item in the
  1.6668 +                      process is longer than the maximum length of aDes.
  1.6669 +                      
  1.6670 +@panic KERN-EXEC 51, if aSlot is negative or is greater than or equal to 16.                                   
  1.6671 +*/
  1.6672 +	{
  1.6673 +	TInt ret = Exec::ProcessGetDataParameter(aSlot, (TUint8*)aDes.Ptr(), aDes.MaxLength());
  1.6674 +	if (ret < 0)
  1.6675 +		return ret;
  1.6676 +	aDes.SetLength(ret);
  1.6677 +	return KErrNone;
  1.6678 +	}
  1.6679 +
  1.6680 +
  1.6681 +
  1.6682 +
  1.6683 +EXPORT_C TInt User::GetDesParameter(TInt aSlot, TDes16& aDes)
  1.6684 +/**
  1.6685 +Gets the specified environment data item belonging to the
  1.6686 +current process; this is assumed to be an 16-bit descriptor.
  1.6687 +
  1.6688 +Environment data may be stored in the process and is passed to a child process
  1.6689 +on creation of that child process.
  1.6690 +
  1.6691 +On successful return from this function, the data item is deleted from
  1.6692 +the process. 
  1.6693 +
  1.6694 +@param aSlot An index that identifies the data item.
  1.6695 +             This is an index whose value is relative to zero;
  1.6696 +             i.e. 0 is the first item/slot.
  1.6697 +             This can range from 0 to 15, i.e. there are 16 slots. 
  1.6698 +
  1.6699 +@param aDes  On sucessful return, contains the environment data item; the
  1.6700 +             length of the descriptor is set to the length of the data item.
  1.6701 +
  1.6702 +@return KErrNone, if successful;
  1.6703 +        KErrNotFound, if there is no data; 
  1.6704 +        KErrArgument, if the data is not binary data, or the data item in the
  1.6705 +                      process is longer than the maximum length of aDes.
  1.6706 +                      
  1.6707 +@panic KERN-EXEC 51, if aSlot is negative or is greater than or equal to 16.                                   
  1.6708 +*/
  1.6709 +	{
  1.6710 +	TInt ret = Exec::ProcessGetDataParameter(aSlot, (TUint8*)aDes.Ptr(), 2*aDes.MaxLength());
  1.6711 +	if (ret < 0)
  1.6712 +		return ret;
  1.6713 +	aDes.SetLength(ret/2);
  1.6714 +	return KErrNone;
  1.6715 +	}
  1.6716 +
  1.6717 +/**
  1.6718 +Gets the linear address of the exception descriptor for the code module in which
  1.6719 +a specified code address resides.
  1.6720 +
  1.6721 +@param	aCodeAddress The code address in question.
  1.6722 +@return	The address of the exception descriptor, or zero if there is none.
  1.6723 +
  1.6724 +*/
  1.6725 +EXPORT_C TLinAddr UserSvr::ExceptionDescriptor(TLinAddr aCodeAddress)
  1.6726 +	{
  1.6727 +	return Exec::ExceptionDescriptor(aCodeAddress);
  1.6728 +	}
  1.6729 +
  1.6730 +EXPORT_C TInt User::SetFloatingPointMode(TFloatingPointMode aMode, TFloatingPointRoundingMode aRoundingMode)
  1.6731 +/**
  1.6732 +Sets the hardware floating point mode for the current thread. This does not affect
  1.6733 +software floating point calculations. The rounding mode can also be set. New threads created
  1.6734 +by this thread will inherit the mode, thus to set the mode for a whole process, call this
  1.6735 +method before you create any new threads.
  1.6736 +
  1.6737 +@param aMode         The floating point calculation mode to use.
  1.6738 +@param aRoundingMode The floating point rounding mode to use, defaults to nearest.
  1.6739 +
  1.6740 +@return KErrNone if successful, KErrNotSupported if the hardware does not support the
  1.6741 +        chosen mode, or there is no floating point hardware present.
  1.6742 +
  1.6743 +@see TFloatingPointMode
  1.6744 +@see TFloatingPointRoundingMode
  1.6745 +*/
  1.6746 +	{
  1.6747 +	return(Exec::SetFloatingPointMode(aMode, aRoundingMode));
  1.6748 +	}
  1.6749 +
  1.6750 +
  1.6751 +EXPORT_C TUint32 E32Loader::PagingPolicy()
  1.6752 +/**
  1.6753 +	Accessor function returns the code paging policy, as defined at ROM build time.
  1.6754 +
  1.6755 +	@return					Code paging policy only.  This function applies
  1.6756 +							EKernelConfigCodePagingPolicyMask to the config flags
  1.6757 +							before returning the value.
  1.6758 + */
  1.6759 +	{
  1.6760 +	return Exec::KernelConfigFlags() & EKernelConfigCodePagingPolicyMask;
  1.6761 +	}
  1.6762 +
  1.6763 +
  1.6764 +/** Queue a notifier to detect system idle
  1.6765 +
  1.6766 +@internalTechnology
  1.6767 +@prototype
  1.6768 +*/
  1.6769 +EXPORT_C void User::NotifyOnIdle(TRequestStatus& aStatus)
  1.6770 +	{
  1.6771 +	aStatus = KRequestPending;
  1.6772 +	Exec::NotifyOnIdle(&aStatus);
  1.6773 +	}
  1.6774 +
  1.6775 +
  1.6776 +/** Cancel a miscellaneous notification requested by this thread
  1.6777 +
  1.6778 +Cancels a currently outstanding notification for system idle or object
  1.6779 +deletion.
  1.6780 +
  1.6781 +@internalTechnology
  1.6782 +@prototype
  1.6783 +*/
  1.6784 +EXPORT_C void User::CancelMiscNotifier(TRequestStatus& aStatus)
  1.6785 +	{
  1.6786 +	Exec::CancelMiscNotifier(&aStatus);
  1.6787 +	}
  1.6788 +
  1.6789 +
  1.6790 +/** Queue a notifier to detect destruction of this object
  1.6791 +
  1.6792 +To cancel the notifier, use User::CancelMiscNotifier().
  1.6793 +
  1.6794 +@internalTechnology
  1.6795 +@prototype
  1.6796 +*/
  1.6797 +EXPORT_C void RHandleBase::NotifyDestruction(TRequestStatus& aStatus)
  1.6798 +	{
  1.6799 +	aStatus = KRequestPending;
  1.6800 +	Exec::NotifyObjectDestruction(iHandle, &aStatus);
  1.6801 +	}
  1.6802 +