sl@0: // Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32\euser\us_exec.cpp sl@0: // sl@0: // sl@0: sl@0: #include "us_std.h" sl@0: #include "us_data.h" sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include "CompareImp.h" sl@0: #include sl@0: sl@0: #include "locmapping.h" sl@0: sl@0: #ifdef __VC32__ sl@0: #pragma setlocale("english") sl@0: #endif sl@0: sl@0: _LIT(KLitSpace, " "); sl@0: _LIT(KLitOpeningBracket, "("); sl@0: _LIT(KLitMinusSign, "-"); sl@0: _LIT(KLitZeroPad, "0"); sl@0: sl@0: #ifdef SYMBIAN_DISTINCT_LOCALE_MODEL sl@0: _LIT(KFindLan, "elocl_lan."); sl@0: _LIT(KFindReg, "elocl_reg."); sl@0: _LIT(KFindCol, "elocl_col."); sl@0: _LIT(KLoc, "elocl."); sl@0: #endif sl@0: sl@0: // Private use area ranges of printable/non-printable characters. sl@0: // This is a sorted list of numbers indicating the ranges in which characters sl@0: // are printable and non-printable. The elements 0, 2, 4... are the first sl@0: // characters of printable ranges and The elements 1, 3, 5... are the first sl@0: // characters of non-printable ranges sl@0: // We will assume that anything in the End User Sub-area is printable. sl@0: static const TInt PUAPrintableRanges[] = sl@0: { sl@0: 0xE000, 0xF6D9, // End user area + unassigned corporate use area sl@0: 0xF6DB, 0xF6DC, // Replacement for character not in font sl@0: 0xF6DE, 0xF700, // various EIKON and Agenda symbols sl@0: 0x10000, KMaxTInt // everything else printable sl@0: }; sl@0: sl@0: static TBool IsPUAPrintable(TInt aChar) sl@0: { sl@0: if (0x110000 <= aChar) sl@0: return 0; // non-characters not printable sl@0: TInt i = 0; sl@0: while (PUAPrintableRanges[i] <= aChar) sl@0: ++i; sl@0: return i & 1; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TBool User::JustInTime() sl@0: /** sl@0: Tests whether just-in-time debugging is on or off. sl@0: sl@0: The function is used by the Kernel, on the Emulator, to decide whether to do sl@0: just-in-time debugging for panics. The function applies to the current process. sl@0: sl@0: Unless overridden by calling User::SetJustInTime(EFalse), just-in-time debugging sl@0: is on by default. sl@0: sl@0: @return True, if just-in-time debugging is on. False otherwise. sl@0: @see RProcess::JustInTime sl@0: */ sl@0: { sl@0: sl@0: return RProcess().JustInTime(); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C void User::SetJustInTime(const TBool aBoolean) sl@0: /** sl@0: Sets just-in-time debugging for this process on or off. sl@0: sl@0: While the function can be called by code running on both the Emulator and ARM, sl@0: it only has an effect on the Emulator. Turning just-in-time debugging off sl@0: prevents the debug Emulator closing down when a panic occurs. sl@0: sl@0: By default, just-in-time debugging is on. sl@0: sl@0: Note that the emulator handles panics in the nomal manner, i.e. by killing sl@0: the thread. sl@0: sl@0: @param aBoolean ETrue, if just-in-time debugging is to be set on. EFalse, sl@0: if just-in-time debugging is to be set off. sl@0: EFalse causes _asm 3 calls to be disabled. sl@0: @see RProcess::SetJustInTime sl@0: */ sl@0: { sl@0: sl@0: RProcess().SetJustInTime(aBoolean); sl@0: } sl@0: sl@0: sl@0: extern const LCharSet* GetLocaleDefaultCharSet(); sl@0: extern const LCharSet* GetLocalePreferredCharSet(); sl@0: sl@0: // Convert to folded. sl@0: EXPORT_C TUint User::Fold(TUint aChar) sl@0: /** sl@0: @deprecated sl@0: sl@0: Folds the specified character. sl@0: sl@0: Folding converts the character to a form which can be used in tolerant sl@0: comparisons without control over the operations performed. Tolerant comparisons sl@0: are those which ignore character differences like case and accents. sl@0: sl@0: The result of folding a character depends on the locale and on whether this sl@0: is a UNICODE build or not. sl@0: sl@0: Note that for a non-UNICODE build, if the binary value of the character aChar sl@0: is greater than or equal to 0x100, then the character returned is the same as sl@0: the character passed to the function. sl@0: sl@0: @param aChar The character to be folded. sl@0: sl@0: @return The folded character. sl@0: sl@0: @see TChar::Fold() sl@0: */ sl@0: { sl@0: // ASCII chars excluding 'i's can be handled by naive folding sl@0: if (aChar < 0x80 && aChar != 'I') sl@0: return (aChar >= 'A' && aChar <= 'Z') ? (aChar | 0x0020) : aChar; sl@0: else sl@0: return TUnicode(aChar).Fold(TChar::EFoldStandard,GetLocaleCharSet()->iCharDataSet); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: // Convert to a folded version, specifying the folding methods. sl@0: EXPORT_C TUint User::Fold(TUint aChar,TInt aFlags) sl@0: /** sl@0: Folds the character according to a specified folding method. sl@0: sl@0: @param aChar The character to be folded. sl@0: @param aFlags A set of flags defining the folding method. They are: sl@0: sl@0: TChar::EFoldCase, convert characters to their lower case form, sl@0: if any; sl@0: sl@0: TChar::EFoldAccents, strip accents; sl@0: sl@0: TChar::EFoldDigits, convert digits representing values 0..9 to sl@0: characters '0'..'9'; sl@0: sl@0: TChar::EFoldSpaces, convert all spaces (ordinary, fixed-width, sl@0: ideographic, etc.) to ' '; sl@0: sl@0: TChar::EFoldKana, convert hiragana to katakana; sl@0: sl@0: TChar::EFoldWidth, fold full width and half width variants to sl@0: their standard forms; sl@0: sl@0: TChar::EFoldAll, use all of the above folding methods. sl@0: sl@0: @return The folded character. sl@0: @see TChar::Fold() sl@0: */ sl@0: { sl@0: return TUnicode(aChar).Fold(aFlags,GetLocaleCharSet()->iCharDataSet); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: // Convert to collated. sl@0: EXPORT_C TUint User::Collate(TUint aChar) sl@0: /** sl@0: Converts the character to its collated form. sl@0: sl@0: Collating is the process of removing differences between characters that are sl@0: deemed unimportant for the purposes of ordering characters. The result of sl@0: the conversion depends on the locale and on whether this is a UNICODE build sl@0: or not. sl@0: sl@0: Note that for a non UNICODE build, if the binary value of the character aChar sl@0: is greater than or equal to 0x100, then the character returned is the same as sl@0: the character passed to the function. sl@0: sl@0: @param aChar The character to be folded. sl@0: sl@0: @return The converted character. sl@0: */ sl@0: { sl@0: return TUnicode(aChar).Fold(TChar::EFoldStandard,GetLocaleCharSet()->iCharDataSet); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: // Convert to lower case. sl@0: EXPORT_C TUint User::LowerCase(TUint aChar) sl@0: /** sl@0: Converts the specified character to lower case. sl@0: sl@0: The result of the conversion depends on the locale and on whether this is sl@0: a UNICODE build or not. sl@0: sl@0: Note that for a non-UNICODE build, if the binary value of the character sl@0: aChar is greater than or equal to 0x100, then the character returned is sl@0: the same as the character passed to the function. sl@0: sl@0: @param aChar The character to be converted to lower case. sl@0: sl@0: @return The lower case character. sl@0: */ sl@0: { sl@0: // ASCII chars excluding 'i's can be handled by naive folding sl@0: if (aChar < 0x80 && aChar != 'I') sl@0: return (aChar >= 'A' && aChar <= 'Z') ? (aChar | 0x0020) : aChar; sl@0: else sl@0: return TUnicode(aChar).GetLowerCase(GetLocaleCharSet()->iCharDataSet); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: // Convert to upper case. sl@0: EXPORT_C TUint User::UpperCase(TUint aChar) sl@0: /** sl@0: Converts a specified character to upper case. sl@0: sl@0: The result of the conversion depends on the locale and on whether this is sl@0: a UNICODE build or not. sl@0: sl@0: Note that for a non UNICODE build, if the binary value of the character aChar sl@0: is greater than or equal to 0x100, then the character returned is the same as sl@0: the character passed to the function. sl@0: sl@0: @param aChar The character to be converted to upper case. sl@0: sl@0: @return The upper case character. sl@0: */ sl@0: { sl@0: // ASCII chars excluding 'i's can be handled by naive folding sl@0: if (aChar < 0x80 && aChar != 'i') sl@0: return (aChar >= 'a' && aChar <= 'z') ? (aChar & ~0x0020) : aChar; sl@0: else sl@0: return TUnicode(aChar).GetUpperCase(GetLocaleCharSet()->iCharDataSet); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: // Return the title case version of a character, which is the case of composite characters like Dz. sl@0: EXPORT_C TUint User::TitleCase(TUint aChar) sl@0: /** sl@0: Converts a specified character to its title case version. sl@0: sl@0: @param aChar The character to be converted. sl@0: sl@0: @return The converted character. sl@0: */ sl@0: { sl@0: return TUnicode(aChar).GetTitleCase(GetLocaleCharSet()->iCharDataSet); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TUint TChar::GetUpperCase() const sl@0: /** sl@0: Gets the character value after conversion to uppercase or the character's sl@0: own value, if no uppercase form exists. sl@0: sl@0: The character object itself is not changed. sl@0: sl@0: @return The character value after conversion to uppercase. sl@0: */ sl@0: { sl@0: return User::UpperCase(iChar); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TUint TChar::GetLowerCase() const sl@0: /** sl@0: Gets the character value after conversion to lowercase or the character's sl@0: own value, if no lowercase form exists. sl@0: sl@0: The character object itself is not changed. sl@0: sl@0: @return The character value after conversion to lowercase. sl@0: */ sl@0: { sl@0: return User::LowerCase(iChar); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TUint TChar::GetTitleCase() const sl@0: /** sl@0: Gets the character value after conversion to titlecase or the character's sl@0: own value, if no titlecase form exists. sl@0: sl@0: The titlecase form of a character is identical to its uppercase form unless sl@0: a specific titlecase form exists. sl@0: sl@0: @return The value of the character value after conversion to titlecase form. sl@0: */ sl@0: { sl@0: return User::TitleCase(iChar); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TBool TChar::IsLower() const sl@0: /** sl@0: Tests whether the character is lowercase. sl@0: sl@0: @return True, if the character is lowercase; false, otherwise. sl@0: */ sl@0: { sl@0: return GetCategory() == TChar::ELlCategory; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TBool TChar::IsUpper() const sl@0: /** sl@0: Tests whether the character is uppercase. sl@0: sl@0: @return True, if the character is uppercase; false, otherwise. sl@0: */ sl@0: { sl@0: return GetCategory() == TChar::ELuCategory; sl@0: } sl@0: sl@0: sl@0: sl@0: // Return TRUE if the character is title case, which is the case of composite characters like Dz. sl@0: EXPORT_C TBool TChar::IsTitle() const sl@0: /** sl@0: Tests whether this character is in titlecase. sl@0: sl@0: @return True, if this character is in titlecase; false, otherwise. sl@0: */ sl@0: { sl@0: return GetCategory() == TChar::ELtCategory; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TBool TChar::IsAlpha() const sl@0: /** sl@0: Tests whether the character is alphabetic. sl@0: sl@0: For Unicode, the function returns TRUE for all letters, including those from sl@0: syllabaries and ideographic scripts. The function returns FALSE for letter-like sl@0: characters that are in fact diacritics. Specifically, the function returns sl@0: TRUE for categories: ELuCategory, ELtCategory, ELlCategory, and ELoCategory; sl@0: it returns FALSE for all other categories including ELmCategory. sl@0: sl@0: @return True, if the character is alphabetic; false, otherwise. sl@0: sl@0: @see TChar::IsAlphaDigit() sl@0: @see TChar::TCategory sl@0: */ sl@0: { sl@0: return GetCategory() <= TChar::EMaxLetterOrLetterModifierCategory; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TBool TChar::IsDigit() const sl@0: /** sl@0: Tests whether the character is a standard decimal digit. sl@0: sl@0: For Unicode, this function returns TRUE only sl@0: for the digits '0'...'9' (U+0030...U+0039), sl@0: not for other digits in scripts like Arabic, Tamil, etc. sl@0: sl@0: @return True, if the character is a standard decimal digit; false, otherwise. sl@0: sl@0: @see TChar::GetCategory() sl@0: @see TChar::GetNumericValue sl@0: */ sl@0: { sl@0: return iChar >= '0' && iChar <= '9'; // standard decimal digits only sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TBool TChar::IsAlphaDigit() const sl@0: /** sl@0: Tests whether the character is alphabetic or a decimal digit. sl@0: sl@0: It is identical to (IsAlpha()||IsDigit()). sl@0: sl@0: @return True, if the character is alphabetic or a decimal digit; false, otherwise. sl@0: sl@0: @see TChar::IsAlpha() sl@0: @see TChar::IsDigit() sl@0: */ sl@0: { sl@0: TInt cat = (TInt)GetCategory(); sl@0: return cat <= TChar::EMaxLetterOrLetterModifierCategory || sl@0: (iChar < 256 && cat == TChar::ENdCategory); // accept any letter, but accept only standard digits sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TBool TChar::IsHexDigit() const sl@0: /** sl@0: Tests whether the character is a hexadecimal digit (0-9, a-f, A-F). sl@0: sl@0: @return True, if the character is a hexadecimal digit; false, otherwise. sl@0: */ sl@0: { sl@0: /* sl@0: The following code will actually run faster than the non-Unicode version, which needs sl@0: to call the Exec function. sl@0: */ sl@0: return iChar <= 'f' && iChar >= '0' && sl@0: (iChar <= '9' || iChar >= 'a' || (iChar >= 'A' && iChar <= 'F')); // only standard hex digits will do sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TBool TChar::IsSpace() const sl@0: /** sl@0: Tests whether the character is a white space character. sl@0: sl@0: White space includes spaces, tabs and separators. sl@0: sl@0: For Unicode, the function returns TRUE for all characters in the categories: sl@0: EZsCategory, EZlCategory and EZpCategory, and also for the characters 0x0009 sl@0: (horizontal tab), 0x000A (linefeed), 0x000B (vertical tab), 0x000C (form feed), sl@0: and 0x000D (carriage return). sl@0: sl@0: @return True, if the character is white space; false, otherwise. sl@0: sl@0: @see TChar::TCategory sl@0: */ sl@0: { sl@0: /* sl@0: The Unicode characters 0009 .. 000D (tab, linefeed, vertical tab, formfeed, carriage return) sl@0: have the category Cc (control); however, we want to avoid breaking traditional programs sl@0: by getting IsSpace() to return TRUE for them. sl@0: */ sl@0: return (iChar <= 0x000D && iChar >= 0x0009) || sl@0: (GetCategory() & 0xF0) == TChar::ESeparatorGroup; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TBool TChar::IsPunctuation() const sl@0: /** sl@0: Tests whether the character is a punctuation character. sl@0: sl@0: For Unicode, punctuation characters are any character in the categories: sl@0: EPcCategory, EPdCategory, EPsCategory, EPeCategory, EPiCategory, sl@0: EPfCategory, EPoCategory. sl@0: sl@0: @return True, if the character is punctuation; false, otherwise. sl@0: sl@0: @see TChar::TCategory sl@0: */ sl@0: { sl@0: return (GetCategory() & 0xF0) == TChar::EPunctuationGroup; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TBool TChar::IsGraph() const sl@0: /** sl@0: Tests whether the character is a graphic character. sl@0: sl@0: For Unicode, graphic characters include printable characters but not the space sl@0: character. Specifically, graphic characters are any character except those sl@0: in categories: EZsCategory,EZlCategory,EZpCategory, ECcCategory,ECfCategory, sl@0: ECsCategory, ECoCategory, and ,ECnCategory. sl@0: sl@0: Note that for ISO Latin-1, all alphanumeric and punctuation characters are sl@0: graphic. sl@0: sl@0: @return True, if the character is a graphic character; false, otherwise. sl@0: sl@0: @see TChar::TCategory sl@0: */ sl@0: { sl@0: TUint type = TUnicode(iChar).GetCategory(0); sl@0: return type <= TChar::EMaxGraphicCategory || sl@0: (type == TChar::ECoCategory && IsPUAPrintable(iChar)); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TBool TChar::IsPrint() const sl@0: /** sl@0: Tests whether the character is a printable character. sl@0: sl@0: For Unicode, printable characters are any character except those in categories: sl@0: ECcCategory, ECfCategory, ECsCategory, ECoCategory and ECnCategory. sl@0: sl@0: Note that for ISO Latin-1, all alphanumeric and punctuation characters, plus sl@0: space, are printable. sl@0: sl@0: @return True, if the character is printable; false, otherwise. sl@0: sl@0: @see TChar::TCategory sl@0: */ sl@0: { sl@0: TUint type = TUnicode(iChar).GetCategory(0); sl@0: return type <= TChar::EMaxPrintableCategory || sl@0: (type == TChar::ECoCategory && IsPUAPrintable(iChar)); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TBool TChar::IsControl() const sl@0: /** sl@0: Tests whether the character is a control character. sl@0: sl@0: For Unicode, the function returns TRUE for all characters in the categories: sl@0: ECcCategory, ECfCategory, ECsCategory, ECoCategory and ECnCategoryCc. sl@0: sl@0: @return True, if the character is a control character; false, otherwise. sl@0: sl@0: @see TChar::TCategory sl@0: */ sl@0: { sl@0: return GetCategory() == TChar::ECcCategory; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TBool TChar::IsAssigned() const sl@0: /** sl@0: Tests whether this character has an assigned meaning in the Unicode encoding. sl@0: sl@0: All characters outside the range 0x0000 - 0xFFFF are unassigned and there sl@0: are also many unassigned characters within the Unicode range. sl@0: sl@0: Locales can change the assigned/unassigned status of characters. This means sl@0: that the precise behaviour of this function is locale-dependent. sl@0: sl@0: @return True, if this character has an assigned meaning; false, otherwise. sl@0: */ sl@0: { sl@0: return GetCategory() <= TChar::EMaxAssignedCategory; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C void TChar::GetInfo(TCharInfo& aInfo) const sl@0: /** sl@0: Gets this character;s standard category information. sl@0: sl@0: This includes everything except its CJK width and decomposition, if any. sl@0: sl@0: @param aInfo On return, contains the character's standard category information. sl@0: */ sl@0: { sl@0: TUnicode(iChar).GetInfo(aInfo,GetLocaleCharSet()->iCharDataSet); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TChar::TCategory TChar::GetCategory() const sl@0: /** sl@0: Gets this character's Unicode category. sl@0: sl@0: @return This character's Unicode category. sl@0: */ sl@0: { sl@0: //for unicode non private user area just use the default charset sl@0: if (iChar>=0xE000 && iChar<=0xF8FF) sl@0: return TUnicode(iChar).GetCategory(GetLocaleCharSet()->iCharDataSet); sl@0: else sl@0: return TUnicode(iChar).GetCategory(GetLocaleDefaultCharSet()->iCharDataSet); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TChar::TBdCategory TChar::GetBdCategory() const sl@0: /** sl@0: Gets the bi-directional category of a character. sl@0: sl@0: For more information on the bi-directional algorithm, see Unicode Technical sl@0: Report No. 9 available at: http://www.unicode.org/unicode/reports/tr9/. sl@0: sl@0: @return The character's bi-directional category. sl@0: */ sl@0: { sl@0: return TUnicode(iChar).GetBdCategory(GetLocaleCharSet()->iCharDataSet); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TInt TChar::GetCombiningClass() const sl@0: /** sl@0: Gets this character's combining class. sl@0: sl@0: Note that diacritics and other combining characters have non-zero combining sl@0: classes. sl@0: sl@0: @return The combining class. sl@0: */ sl@0: { sl@0: //for unicode non private user area just use the default charset sl@0: if (iChar>=0xE000 && iChar<=0xF8FF) sl@0: return TUnicode(iChar).GetCombiningClass(GetLocaleCharSet()->iCharDataSet); sl@0: else sl@0: return TUnicode(iChar).GetCombiningClass(GetLocaleDefaultCharSet()->iCharDataSet); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TBool TChar::IsMirrored() const sl@0: /** sl@0: Tests whether this character has the mirrored property. sl@0: sl@0: Mirrored characters, like ( ) [ ] < >, change direction according to the sl@0: directionality of the surrounding characters. For example, an opening sl@0: parenthesis 'faces right' in Hebrew or Arabic, and to say that 2 < 3 you would sl@0: have to say that 3 > 2, where the '>' is, in this example, a less-than sign to sl@0: be read right-to-left. sl@0: sl@0: @return True, if this character has the mirrored property; false, otherwise. sl@0: */ sl@0: { sl@0: return TUnicode(iChar).IsMirrored(GetLocaleCharSet()->iCharDataSet); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TInt TChar::GetNumericValue() const sl@0: /** sl@0: Gets the integer numeric value of this character. sl@0: sl@0: Numeric values need not be in the range 0..9; the Unicode character set sl@0: includes various other numeric characters such as the Roman and Tamil numerals sl@0: for 500, 1000, etc. sl@0: sl@0: @return The numeric value: -1 if the character has no integer numeric sl@0: value,-2 if the character has a fractional numeric value. sl@0: */ sl@0: { sl@0: return TUnicode(iChar).GetNumericValue(GetLocaleCharSet()->iCharDataSet); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TChar::TCjkWidth TChar::GetCjkWidth() const sl@0: /** sl@0: Gets the Chinese, Japanese, Korean (CJK) notional width. sl@0: sl@0: Some display systems used in East Asia display characters on a grid of sl@0: fixed-width character cells like the standard MSDOS display mode. sl@0: sl@0: Some characters, e.g. the Japanese katakana syllabary, take up a single sl@0: character cell and some characters, e.g., kanji, Chinese characters used in sl@0: Japanese, take up two. These are called half-width and full-width characters. sl@0: This property is fixed and cannot be overridden for particular locales. sl@0: sl@0: For more information on returned widths, see Unicode Technical Report 11 on sl@0: East Asian Width available at: http://www.unicode.org/unicode/reports/tr11/ sl@0: sl@0: @return The notional width of an east Asian character. sl@0: */ sl@0: { sl@0: return TUnicode(iChar).GetCjkWidth(); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Composes a string of Unicode characters to produce a single character result. sl@0: sl@0: For example, 0061 ('a') and 030A (combining ring above) compose to give 00E5 sl@0: ('a' with ring above). sl@0: sl@0: A canonical decomposition is a relationship between a string of characters - sl@0: usually a base character and one or more diacritics - and a composed character. sl@0: The Unicode standard requires that compliant software treats composed sl@0: characters identically with their canonical decompositions. The mappings used sl@0: by these functions are fixed and cannot be overridden for particular locales. sl@0: sl@0: @param aResult If successful, the composed character value. If unsuccessful, sl@0: this value contains 0xFFFF. sl@0: @param aSource String of source Unicode characters. sl@0: sl@0: @return True, if the compose operation is successful in combining the entire sl@0: sequence of characters in the descriptor into a single compound sl@0: character; false, otherwise. sl@0: */ sl@0: sl@0: EXPORT_C TBool TChar::Compose(TUint& aResult,const TDesC16& aSource) sl@0: { sl@0: aResult = 0xFFFF; sl@0: if(aSource.Length() > 0) sl@0: { sl@0: TChar combined; sl@0: if(::CombineAsMuchAsPossible(aSource, combined) == aSource.Length()) sl@0: { sl@0: aResult = (TUint)combined; sl@0: return ETrue; sl@0: } sl@0: } sl@0: return EFalse; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Maps this character to its maximal canonical decomposition. sl@0: sl@0: For example, 01E1 ('a' with dot above and macron) decomposes into 0061 ('a') sl@0: 0307 (dot) and 0304 (macron). sl@0: sl@0: Note that this function is used during collation, as performed by sl@0: the Mem::CompareC() function, to convert the compared strings to their maximal sl@0: canonical decompositions. sl@0: sl@0: @param aResult If successful, the descriptor represents the canonical decomposition sl@0: of this character. If unsuccessful, the descriptor is empty. sl@0: sl@0: @return True if decomposition is successful; false, otherwise. sl@0: sl@0: @see Mem::CompareC() sl@0: @see TChar::Compose() sl@0: */ sl@0: EXPORT_C TBool TChar::Decompose(TPtrC16& aResult) const sl@0: { sl@0: return ::DecomposeChar(iChar, aResult); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TInt TFindChunk::Next(TFullName &aResult) sl@0: /** sl@0: Finds the full name of the next chunk which matches the match pattern. sl@0: sl@0: @param aResult A reference to a TBuf descriptor with a defined maximum length. sl@0: If a matching chunk is found, its full name is set into sl@0: this descriptor. sl@0: If no matching chunk is found, the descriptor length is set sl@0: to zero. sl@0: sl@0: @return KErrNone, if a matching chunk is found; sl@0: KErrNotFound otherwise. sl@0: */ sl@0: { sl@0: return NextObject(aResult,EChunk); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TUint8 * RChunk::Base() const sl@0: /** sl@0: Gets a pointer to the base of the chunk's reserved region. sl@0: sl@0: @return A pointer to the base of the chunk's reserved region. sl@0: */ sl@0: { sl@0: sl@0: return(Exec::ChunkBase(iHandle)); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TInt RChunk::Size() const sl@0: /** sl@0: Gets the current size of this chunk's committed region. sl@0: sl@0: @return The size of the chunk's committed region. sl@0: */ sl@0: { sl@0: sl@0: return(Exec::ChunkSize(iHandle)); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TInt RChunk::Bottom() const sl@0: /** sl@0: Gets the offset of the bottom of the double ended chunk's committed region sl@0: from the base of the chunk's reserved region. sl@0: sl@0: Note that the lowest valid address in a double ended chunk is the sum of the sl@0: base of the chunk's reserved region plus the value of Bottom(). sl@0: sl@0: @return The offset of the bottom of the chunk's committed region from the sl@0: base of the chunk's reserved region. sl@0: */ sl@0: { sl@0: sl@0: return(Exec::ChunkBottom(iHandle)); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TInt RChunk::Top() const sl@0: /** sl@0: Gets the offset of the top of the double ended chunk's committed region sl@0: from the base of the chunk's reserved region. sl@0: sl@0: Note that the highest valid address in a double ended chunk is the the sum sl@0: of the base of the chunk's reserved region plus the value of Top() - 1. sl@0: sl@0: @return The offset of the top of the chunk's committed region from the base sl@0: of the chunk's reserved region. sl@0: */ sl@0: { sl@0: sl@0: return(Exec::ChunkTop(iHandle)); sl@0: } sl@0: sl@0: sl@0: EXPORT_C TInt RChunk::MaxSize() const sl@0: /** sl@0: Gets the maximum size of this chunk. sl@0: sl@0: This maximum size of this chunk is set when the chunk is created. sl@0: sl@0: @return The maximum size of this chunk. sl@0: */ sl@0: { sl@0: sl@0: return(Exec::ChunkMaxSize(iHandle)); sl@0: } sl@0: sl@0: /** sl@0: Finds the full name of the next LDD factory object which matches the match pattern. sl@0: sl@0: @param aResult A reference to a TBuf descriptor with a defined maximum length. sl@0: If a matching LDD factory object is found, its full name is set into sl@0: this descriptor. sl@0: If no matching LDD factory object is found, the descriptor length is set sl@0: to zero. sl@0: sl@0: @return KErrNone, if a matching LDD factory object is found; sl@0: KErrNotFound otherwise. sl@0: */ sl@0: EXPORT_C TInt TFindLogicalDevice::Next(TFullName &aResult) sl@0: { sl@0: return NextObject(aResult,ELogicalDevice); sl@0: } sl@0: sl@0: /** sl@0: Finds the full name of the next PDD factory object which matches the match pattern. sl@0: sl@0: @param aResult A reference to a TBuf descriptor with a defined maximum length. sl@0: If a matching PDD factory object is found, its full name is set into sl@0: this descriptor. sl@0: If no matching PDD factory object is found, the descriptor length is set sl@0: to zero. sl@0: sl@0: @return KErrNone, if a matching PDD factory object is found; sl@0: KErrNotFound otherwise. sl@0: */ sl@0: EXPORT_C TInt TFindPhysicalDevice::Next(TFullName &aResult) sl@0: { sl@0: return NextObject(aResult,EPhysicalDevice); sl@0: } sl@0: sl@0: /** sl@0: Gets the device capabilities. sl@0: sl@0: @param aDes A descriptor into which capability's information is to be written. sl@0: */ sl@0: EXPORT_C void RDevice::GetCaps(TDes8 &aDes) const sl@0: { sl@0: sl@0: Exec::LogicalDeviceGetCaps(iHandle,aDes); sl@0: } sl@0: sl@0: /** sl@0: Checks if a device supports a particular version. sl@0: sl@0: @param aVer The requested device version. sl@0: sl@0: @return ETrue if supported, EFalse if not. sl@0: */ sl@0: EXPORT_C TBool RDevice::QueryVersionSupported(const TVersion &aVer) const sl@0: { sl@0: sl@0: return(Exec::LogicalDeviceQueryVersionSupported(iHandle,aVer)); sl@0: } sl@0: sl@0: /** sl@0: Checks if a specified unit number, additional info and a specific PDD is supported. sl@0: sl@0: @param aUnit The requested unit number. sl@0: @param aPhysicalDevice The requested PDD name. sl@0: @param anInfo The additional information. sl@0: sl@0: @return ETrue if supported, EFalse if not. sl@0: */ sl@0: EXPORT_C TBool RDevice::IsAvailable(TInt aUnit, const TDesC* aPhysicalDevice, const TDesC8* anInfo) const sl@0: { sl@0: TInt r; sl@0: if(aPhysicalDevice) sl@0: { sl@0: TBuf8 physicalDevice; sl@0: physicalDevice.Copy(*aPhysicalDevice); sl@0: r = Exec::LogicalDeviceIsAvailable(iHandle,aUnit,(TDesC8*)&physicalDevice,anInfo); sl@0: } sl@0: else sl@0: r = Exec::LogicalDeviceIsAvailable(iHandle,aUnit,(TDesC8*)NULL,anInfo); sl@0: sl@0: return r; sl@0: } sl@0: sl@0: sl@0: /** sl@0: Queues an asynchronous request for the device driver, taking no parameters. sl@0: sl@0: The request is handled on the kernel-side by the logical channel's sl@0: DLogicalChannelBase::Request(). sl@0: sl@0: Outstanding requests can be cancelled by calling DoCancel(). sl@0: sl@0: @param aReqNo A number identifying the request to the logical channel. sl@0: @param aStatus The request status object for this request. sl@0: */ sl@0: EXPORT_C void RBusLogicalChannel::DoRequest(TInt aReqNo,TRequestStatus &aStatus) sl@0: { sl@0: sl@0: TAny *a[2]; sl@0: a[0]=NULL; sl@0: a[1]=NULL; sl@0: aStatus=KRequestPending; sl@0: Exec::ChannelRequest(iHandle,~aReqNo,&aStatus,&a[0]); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Queues an asynchronous request for the device driver, taking one parameter. sl@0: sl@0: The request is handled on the kernel-side by the logical channel's sl@0: DLogicalChannelBase::Request(). sl@0: sl@0: Outstanding requests can be cancelled by calling DoCancel(). sl@0: sl@0: @param aReqNo A number identifying the request to the logical channel. sl@0: @param aStatus The request status object for this request. sl@0: @param a1 A 32-bit value passed to the kernel-side. Its meaning depends sl@0: on the device driver requirements. sl@0: */ sl@0: EXPORT_C void RBusLogicalChannel::DoRequest(TInt aReqNo,TRequestStatus &aStatus,TAny *a1) sl@0: { sl@0: sl@0: TAny *a[2]; sl@0: a[0]=a1; sl@0: a[1]=NULL; sl@0: aStatus=KRequestPending; sl@0: Exec::ChannelRequest(iHandle,~aReqNo,&aStatus,&a[0]); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Queues an asynchronous request for the device driver, taking two parameters. sl@0: sl@0: The request is handled on the kernel-side by the logical channel's sl@0: DLogicalChannelBase::Request(). sl@0: sl@0: Outstanding requests can be cancelled by calling DoCancel(). sl@0: sl@0: @param aReqNo A number identifying the request to the logical channel. sl@0: @param aStatus The request status object for this request. sl@0: @param a1 A 32-bit value passed to the kernel-side. Its meaning depends sl@0: on the device driver requirements. sl@0: @param a2 A 32-bit value passed to the kernel-side. Its meaning depends sl@0: on the device driver requirements. sl@0: */ sl@0: EXPORT_C void RBusLogicalChannel::DoRequest(TInt aReqNo,TRequestStatus &aStatus,TAny *a1,TAny *a2) sl@0: { sl@0: sl@0: TAny *a[2]; sl@0: a[0]=a1; sl@0: a[1]=a2; sl@0: aStatus=KRequestPending; sl@0: Exec::ChannelRequest(iHandle,~aReqNo,&aStatus,&a[0]); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Cancels one or more outstanding asynchronous requests. sl@0: sl@0: All outstanding requests complete with KErrCancel. sl@0: sl@0: @param aRequestMask A set of bits identifying the requests to be cancelled. sl@0: Each bit can be used to identify a separate outstanding sl@0: request. It is up to the driver to define how the bits map sl@0: to those outstanding requests. sl@0: */ sl@0: EXPORT_C void RBusLogicalChannel::DoCancel(TUint aRequestMask) sl@0: { sl@0: sl@0: Exec::ChannelRequest(iHandle,KMaxTInt,(TAny*)aRequestMask,0); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Makes a synchronous request to the device driver, taking no parameters. sl@0: sl@0: This function does not return until the request has completed, successfully sl@0: or otherwise. sl@0: sl@0: @param aFunction A number identifying the request. sl@0: sl@0: @return KErrNone, if successful; otherwise one of the other system-wide sl@0: error codes. sl@0: The value returned depends on the implementation of the device driver. sl@0: */ sl@0: EXPORT_C TInt RBusLogicalChannel::DoControl(TInt aFunction) sl@0: { sl@0: sl@0: return Exec::ChannelRequest(iHandle,aFunction,NULL,NULL); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Makes a synchronous request to the device driver, taking one parameter. sl@0: sl@0: This function does not return until the request has completed, successfully sl@0: or otherwise. sl@0: sl@0: @param aFunction A number identifying the request. sl@0: @param a1 A 32-bit value passed to the kernel-side. Its meaning depends sl@0: on the device driver requirements. sl@0: sl@0: @return KErrNone, if successful; otherwise one of the other system-wide sl@0: error codes. sl@0: The value returned depends on the implementation of the device driver. sl@0: */ sl@0: EXPORT_C TInt RBusLogicalChannel::DoControl(TInt aFunction,TAny *a1) sl@0: { sl@0: sl@0: return Exec::ChannelRequest(iHandle,aFunction,a1,NULL); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Makes a synchronous request to the device driver, taking two parameters. sl@0: sl@0: This function does not return until the request has completed, successfully sl@0: or otherwise. sl@0: sl@0: @param aFunction A number identifying the request. sl@0: @param a1 A 32-bit value passed to the kernel-side. Its meaning depends sl@0: on the device driver requirements. sl@0: @param a2 A 32-bit value passed to the kernel-side. Its meaning depends sl@0: on the device driver requirements. sl@0: sl@0: @return KErrNone, if successful; otherwise one of the other system-wide sl@0: error codes. sl@0: The value returned depends on the implementation of the device driver. sl@0: */ sl@0: EXPORT_C TInt RBusLogicalChannel::DoControl(TInt aFunction,TAny *a1,TAny *a2) sl@0: { sl@0: sl@0: return Exec::ChannelRequest(iHandle,aFunction,a1,a2); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C void User::WaitForAnyRequest() sl@0: /** sl@0: Waits for any asynchronous request to complete. sl@0: sl@0: The current thread waits on its request semaphore. sl@0: sl@0: The function completes, and control returns to the caller when the current sl@0: thread's request semaphore is signalled by any of the service providers which sl@0: handle these asynchronous requests. sl@0: sl@0: The request status of all outstanding asynchronous requests must be examined sl@0: to determine which request is complete. sl@0: sl@0: @see TRequestStatus sl@0: */ sl@0: { sl@0: sl@0: Exec::WaitForAnyRequest(); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C void User::WaitForRequest(TRequestStatus &aStatus) sl@0: /** sl@0: Waits for a specific asynchronous request to complete. sl@0: sl@0: The current thread waits on its request semaphore. sl@0: sl@0: The function completes and control returns to the caller when the current sl@0: thread's request semaphore is signalled by the service provider handling the sl@0: request associated with aStatus. Before signalling, the service provider sets sl@0: an appropriate value in aStatus, other than KRequestPending. sl@0: sl@0: Note that if other asynchronous requests complete before the one associated sl@0: with aStatus, the request semaphore is adjusted so that knowledge of their sl@0: completion is not lost. In this a case, a subsequent call to sl@0: User::WaitForAnyRequest() or User::WaitForRequest() will complete and return sl@0: immediately. sl@0: sl@0: @param aStatus A reference to the request status object associated with the sl@0: specific asynchronous request. sl@0: sl@0: @see KRequestPending sl@0: */ sl@0: { sl@0: sl@0: TInt i=(-1); sl@0: do sl@0: { sl@0: i++; sl@0: Exec::WaitForAnyRequest(); sl@0: } while (aStatus==KRequestPending); sl@0: if (i) sl@0: Exec::RequestSignal(i); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C void User::WaitForRequest(TRequestStatus &aStatus1,TRequestStatus &aStatus2) sl@0: /** sl@0: Waits for either of two specific asynchronous requests to complete. sl@0: sl@0: The current thread waits on its request semaphore. sl@0: sl@0: The function completes and control returns to the caller when the current sl@0: thread's request semaphore is signalled by either the service provider handling sl@0: the request associated with aStatus1 or the service provider handling the sl@0: request associated with aStatus2. Before signalling, the completing service sl@0: provider sets an appropriate value in the status object, other sl@0: than KRequestPending. sl@0: sl@0: Note that if other asynchronous requests complete before the ones associated sl@0: with aStatus1 and aStatus2, the request semaphore is adjusted so that knowledge sl@0: of their completion is not lost. In this a case, a subsequent call to sl@0: User::WaitForAnyRequest() or User::WaitForRequest() will complete and return sl@0: immediately. sl@0: sl@0: @param aStatus1 A reference to the request status object associated with the sl@0: first specific asynchronous request. sl@0: @param aStatus2 A reference to the request status object associated with the sl@0: second specific asynchronous request. sl@0: sl@0: @see KRequestPending sl@0: */ sl@0: { sl@0: sl@0: TInt i=(-1); sl@0: do sl@0: { sl@0: i++; sl@0: Exec::WaitForAnyRequest(); sl@0: } while (aStatus1==KRequestPending && aStatus2==KRequestPending); sl@0: if (i) sl@0: Exec::RequestSignal(i); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C void User::WaitForNRequest(TRequestStatus * aStatusArray[], TInt aNum) sl@0: /** sl@0: Waits for any one of specific asynchronous requests to complete. sl@0: sl@0: The current thread waits on its request semaphore. sl@0: sl@0: The function completes and control returns to the caller when the current sl@0: thread's request semaphore is signalled by the service provider handling sl@0: the request associated with any member of aStatusArray[]. Before signalling, sl@0: the completing service provider sets an appropriate value in the status object, sl@0: other than KRequestPending. sl@0: sl@0: Note that if other asynchronous requests complete before the ones associated sl@0: with aStatusArray the request semaphore is adjusted so that knowledge sl@0: of their completion is not lost. In this a case, a subsequent call to sl@0: User::WaitForAnyRequest() or User::WaitForRequest() will complete and return sl@0: immediately. sl@0: @param aStatusArray[] An array of pointers to the request status objects sl@0: @param TInt aNum The size of aStatusArray[] sl@0: */ sl@0: { sl@0: TRequestStatus* aptr; sl@0: TBool m = ETrue; sl@0: TInt i = (-1); sl@0: do sl@0: { sl@0: i++; sl@0: Exec::WaitForAnyRequest(); sl@0: for(TInt j = 0; jInt()!= KRequestPending) sl@0: { sl@0: m = EFalse; sl@0: break; sl@0: } sl@0: } sl@0: } sl@0: }while(m); sl@0: if(i) sl@0: Exec::RequestSignal(i); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TInt TFindLibrary::Next(TFullName &aResult) sl@0: /** sl@0: Finds the next DLL whose full name matches the match pattern. sl@0: sl@0: If a DLL with a matching name is found, the function copies the full name of sl@0: the DLL into the descriptor aResult. sl@0: sl@0: @param aResult A buffer for the fullname of the DLL. This is a template sl@0: specialisation of TBuf defining a modifiable buffer descriptor sl@0: taking a maximum length of KMaxFullName. sl@0: If no matching DLL is found, the descriptor length is sl@0: set to zero. sl@0: sl@0: @return KErrNone, if a matching DLL is found; sl@0: KErrNotFound, otherwise. sl@0: */ sl@0: { sl@0: return NextObject(aResult,ELibrary); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TLibraryFunction RLibrary::Lookup(TInt anOrdinal) const sl@0: /** sl@0: Gets a pointer to the function at the specified ordinal within this DLL. sl@0: sl@0: @param anOrdinal The ordinal of the required function in this DLL. sl@0: This value must be positive. sl@0: sl@0: @return A pointer to the function at position anOrdinal in this DLL. sl@0: The value is NULL if there is no function at that ordinal. sl@0: sl@0: @panic USER 116 if anOrdinal is negative sl@0: */ sl@0: { sl@0: __ASSERT_ALWAYS(anOrdinal>=0,Panic(EBadLookupOrdinal)); sl@0: return (Exec::LibraryLookup(iHandle,anOrdinal)); sl@0: } sl@0: sl@0: sl@0: sl@0: EXPORT_C TFileName RLibrary::FileName() const sl@0: /** sl@0: Gets the name of the DLL's file. sl@0: sl@0: @return The DLL's filname. sl@0: */ sl@0: { sl@0: sl@0: TFileName n; sl@0: TPtr8 n8(((TUint8*)n.Ptr()) + KMaxFileName, KMaxFileName); sl@0: Exec::LibraryFileName(iHandle,n8); sl@0: n.Copy(n8); sl@0: return(n); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TUidType RLibrary::Type() const sl@0: /** sl@0: Gets this DLL's UID type. sl@0: sl@0: The UID type is a property of a Symbian OS file; for a DLL, its value is set sl@0: during the building of that DLL. sl@0: sl@0: @return The UID type of this DLL. Note that the first TUid component of sl@0: the TUidType has the value KDynamicLibraryUid. sl@0: */ sl@0: { sl@0: sl@0: TUidType u; sl@0: Exec::LibraryType(iHandle,u); sl@0: return(u); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TInt RLibrary::GetRamSizes(TInt& aCodeSize, TInt& aConstDataSize) sl@0: /** sl@0: Gets the current size of the code and the const data for this DLL. sl@0: sl@0: This function can be called on a RAM loaded DLL or a ROM based DLL. sl@0: sl@0: @param aCodeSize The current size of the code for a RAM loaded DLL. sl@0: This is zero for a ROM based DLL. sl@0: sl@0: @param aConstDataSize The current size of the const data for a RAM loaded DLL. sl@0: This is zero for a ROM based DLL. sl@0: sl@0: @return KErrNone if successful, otherwise one of the system-wide error codes. sl@0: */ sl@0: { sl@0: TModuleMemoryInfo info; sl@0: TInt r=Exec::LibraryGetMemoryInfo(iHandle,info); sl@0: if (r==KErrNone) sl@0: { sl@0: aCodeSize=info.iCodeSize; sl@0: aConstDataSize=info.iConstDataSize; sl@0: } sl@0: return r; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Sets the home time to a specified time value. sl@0: sl@0: @param aTime A reference to a time representation object containing the time sl@0: value. sl@0: sl@0: @return KErrNone if successful or one of the system-wide error codes. sl@0: sl@0: @deprecated Set the time using User::SetUTCTime if the UTC time is known; sl@0: otherwise, use the timezone server to set the time. sl@0: sl@0: @capability WriteDeviceData sl@0: */ sl@0: EXPORT_C TInt User::SetHomeTime(const TTime &aTime) sl@0: { sl@0: return(Exec::SetUTCTimeAndOffset(aTime.Int64(),0,ETimeSetTime|ETimeSetLocalTime,0)); sl@0: } sl@0: sl@0: /** sl@0: Sets the secure home time to a specified time value. sl@0: sl@0: @param aTime A reference to a time representation object containing the sl@0: secure time value. sl@0: sl@0: @return KErrNone if successful or one of the system-wide error codes. sl@0: sl@0: @capability TCB sl@0: @capability WriteDeviceData sl@0: */ sl@0: EXPORT_C TInt User::SetHomeTimeSecure(const TTime &aTime) sl@0: { sl@0: return(Exec::SetUTCTimeAndOffset(aTime.Int64(),0,ETimeSetTime|ETimeSetLocalTime|ETimeSetSecure,0)); sl@0: } sl@0: sl@0: sl@0: sl@0: /** sl@0: Sets the UTC time to a specified time value. sl@0: sl@0: @param aUTCTime A reference to a time representation object containing the time sl@0: value. sl@0: sl@0: @return KErrNone if successful or one of the system-wide error codes. sl@0: sl@0: @capability WriteDeviceData sl@0: */ sl@0: EXPORT_C TInt User::SetUTCTime(const TTime &aUTCTime) sl@0: { sl@0: return(Exec::SetUTCTimeAndOffset(aUTCTime.Int64(),0,ETimeSetTime,0)); sl@0: } sl@0: sl@0: /** sl@0: Sets the secure UTC time to a specified time value. sl@0: sl@0: @param aUTCTime A reference to a time representation object containing the secure time sl@0: value. sl@0: sl@0: @return KErrNone if successful or one of the system-wide error codes. sl@0: sl@0: @capability TCB sl@0: @capability WriteDeviceData sl@0: */ sl@0: EXPORT_C TInt User::SetUTCTimeSecure(const TTime &aUTCTime) sl@0: { sl@0: return(Exec::SetUTCTimeAndOffset(aUTCTime.Int64(),0,ETimeSetTime|ETimeSetSecure,0)); sl@0: } sl@0: sl@0: /** sl@0: Gets the UTC offset - the difference between UTC and the current local time sl@0: due to any time zones and daylight savings time that may be in effect. A positive sl@0: offset indicates a time ahead of UTC, a negative offset indicates a time behind UTC. sl@0: sl@0: @return The UTC offset, in seconds. sl@0: */ sl@0: EXPORT_C TTimeIntervalSeconds User::UTCOffset() sl@0: { sl@0: return(TTimeIntervalSeconds(Exec::UTCOffset())); sl@0: } sl@0: sl@0: sl@0: /** sl@0: Sets the UTC offset to the given number of seconds. This should include both time sl@0: zone differences and the effect of any applicable daylight savings time. sl@0: A positive offset indicates a time ahead of UTC, a negative offset indicates a time sl@0: behind UTC. sl@0: sl@0: @param aOffset The UTC offset, in seconds. sl@0: sl@0: @capability WriteDeviceData sl@0: */ sl@0: EXPORT_C void User::SetUTCOffset(TTimeIntervalSeconds aOffset) sl@0: { sl@0: Exec::SetUTCTimeAndOffset(0,aOffset.Int(),ETimeSetOffset,0); sl@0: } sl@0: sl@0: sl@0: /** sl@0: Sets the UTC time and UTC offset to the specified values, atomically. This is equivalent sl@0: to calling both SetUTCTime and SetUTCOffset, but without the possibility of an incorrect sl@0: time being observed between the two calls. If the operation is not successful, an error sl@0: code will be returned and both the time and offset will be left unchanged. sl@0: sl@0: @param aUTCTime A reference to a time representation object containing the time sl@0: value. sl@0: @param aOffset The UTC offset, in seconds. sl@0: sl@0: @return KErrNone if successful or one of the system-wide error codes. sl@0: sl@0: @capability WriteDeviceData sl@0: */ sl@0: EXPORT_C TInt User::SetUTCTimeAndOffset(const TTime &aUTCTime, TTimeIntervalSeconds aOffset) sl@0: { sl@0: return(Exec::SetUTCTimeAndOffset(aUTCTime.Int64(),aOffset.Int(),ETimeSetTime|ETimeSetOffset,0)); sl@0: } sl@0: sl@0: sl@0: /** sl@0: Gets the current tick count. sl@0: sl@0: The period between ticks is usually 1/64 second, but may be hardware dependent. sl@0: sl@0: @return The machine dependent tick count. sl@0: */ sl@0: EXPORT_C TUint User::TickCount() sl@0: { sl@0: sl@0: return(Exec::TickCount()); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TTimeIntervalSeconds User::InactivityTime() sl@0: /** sl@0: Gets the time since the last user activity. sl@0: sl@0: @return The time interval. sl@0: */ sl@0: { sl@0: sl@0: return TTimeIntervalSeconds(Exec::UserInactivityTime()); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Resets all user inactivity timers. sl@0: */ sl@0: EXPORT_C void User::ResetInactivityTime() sl@0: { sl@0: Exec::ResetInactivityTime(); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Gets the nanokernel tick count. sl@0: sl@0: This is the current value of the machine's millisecond tick counter. sl@0: sl@0: On the emulator the resolution defaults to 5 milliseconds; however sl@0: you can change it to N milliseconds when you launch the emulator sl@0: from the command line by specifying -Dtimerresolution=N as a parameter sl@0: to epoc.exe, for example: sl@0: @code sl@0: epoc.exe -Dtimerresolution=3 sl@0: @endcode sl@0: sl@0: On most hardware the resolution is about 1 millisecond. sl@0: sl@0: You can get the nanokernel tick period in microseconds by calling sl@0: into the Hardware Abstraction Layer: sl@0: sl@0: @code sl@0: TInt nanokernel_tick_period; sl@0: HAL::Get(HAL::ENanoTickPeriod, nanokernel_tick_period); sl@0: @endcode sl@0: sl@0: @return The nanokernel tick count. sl@0: */ sl@0: EXPORT_C TUint32 User::NTickCount() sl@0: { sl@0: sl@0: return Exec::NTickCount(); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Gets the fast counter. sl@0: sl@0: This is the current value of the machine's high resolution timer. If a high sl@0: resolution timer is not available, it uses the millisecond timer instead. sl@0: sl@0: The freqency of this counter can be determined by reading the HAL attribute sl@0: EFastCounterFrequency. sl@0: sl@0: This function is intended for use in profiling and testing; it should not be sl@0: used in production code. User::NTickCount() should be used instead. sl@0: sl@0: This is because the implementation of the FastCounter is platform-specific: sl@0: its frequency can be anywhere from a few KHz to many MHz. It may also not sl@0: be activated when needed, since it is expensive in terms of clock cycles and sl@0: battery life, and use of a platform-specific API may be necessary to enable sl@0: it. sl@0: sl@0: @return The fast counter value. sl@0: sl@0: @see User::NTickCount() sl@0: */ sl@0: EXPORT_C TUint32 User::FastCounter() sl@0: { sl@0: sl@0: return Exec::FastCounter(); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TTimerLockSpec User::LockPeriod() sl@0: /** sl@0: Returns which of the periods the clock is currently in. sl@0: sl@0: @return The fraction of a second at which the timer completes. sl@0: */ sl@0: { sl@0: sl@0: return(Exec::LockPeriod()); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TName RHandleBase::Name() const sl@0: /** sl@0: Gets the name of the handle. sl@0: sl@0: @return The name of the handle. sl@0: */ sl@0: { sl@0: sl@0: TName n; sl@0: TPtr8 n8(((TUint8*)n.Ptr()) + KMaxName, KMaxName); sl@0: Exec::HandleName(iHandle,n8); sl@0: n.Copy(n8); sl@0: return(n); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TFullName RHandleBase::FullName() const sl@0: /** sl@0: Gets the full name of the handle. sl@0: sl@0: Note: This method is stack consuming (it takes 512 bytes on stack to execute). sl@0: For an alternative way to obtain the full name of the object, see RHandleBase::FullName(TDes& aName) const. sl@0: sl@0: @see RHandleBase::FullName(TDes& aName) const sl@0: @return The full name of the handle. sl@0: */ sl@0: { sl@0: sl@0: TFullName n; sl@0: TPtr8 n8(((TUint8*)n.Ptr()) + KMaxFullName, KMaxFullName); sl@0: Exec::HandleFullName(iHandle,n8); sl@0: n.Copy(n8); sl@0: return(n); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C void RHandleBase::FullName(TDes& aName) const sl@0: /** sl@0: Gets the full name of the handle. sl@0: sl@0: @param aName On return, contains the full name of the handle. sl@0: sl@0: @panic KERN-EXEC 35, If full name of the handler is longer that the maximum length of aName descriptor. sl@0: To avoid this, the maximum length of aName should be at least KMaxFullName. sl@0: @see KMaxFullName sl@0: */ sl@0: { sl@0: sl@0: // Kernel will copy string in n8, whose data lives in the upper half of aName desciptor data sl@0: TPtr8 n8(((TUint8*)aName.Ptr()) + aName.MaxLength(), aName.MaxLength()); sl@0: Exec::HandleFullName(iHandle,n8); sl@0: aName.Copy(n8); // Expands 8bit descriptor into 16bit unicode descriptor. sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C void RHandleBase::HandleInfo(THandleInfo* anInfo) sl@0: /** sl@0: Gets information about the handle. sl@0: sl@0: @param anInfo A pointer to a THandleInfo object supplied by the caller; sl@0: on return, contains the handle information. sl@0: */ sl@0: { sl@0: sl@0: Exec::HandleInfo(iHandle,anInfo); sl@0: } sl@0: sl@0: EXPORT_C TInt RHandleBase::BTraceId() const sl@0: /** sl@0: Returns a unique object identifier for use with BTrace sl@0: */ sl@0: { sl@0: return Exec::GetBTraceId(iHandle); sl@0: } sl@0: sl@0: sl@0: sl@0: EXPORT_C TUint RHandleBase::Attributes() const sl@0: // sl@0: // Get handle attributes sl@0: // sl@0: { sl@0: sl@0: return Exec::HandleAttributes(iHandle); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TInt User::AllocLen(const TAny *aCell) sl@0: /** sl@0: Gets the length of the specified allocated heap cell. sl@0: sl@0: The cell is assumed to be in the current thread's heap. sl@0: sl@0: @param aCell A pointer to the allocated cell whose length sl@0: is to be fetched. sl@0: sl@0: @return The length of the allocated cell. sl@0: */ sl@0: { sl@0: sl@0: return(GetHeap()->AllocLen(aCell)); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TAny* User::Alloc(TInt aSize) sl@0: /** sl@0: Allocates a cell of specified size from the current thread's heap. sl@0: sl@0: If there is insufficient memory available on the heap from which to allocate a cell sl@0: of the required size, the function returns NULL. sl@0: sl@0: The resulting size of the allocated cell may be rounded up to a value greater sl@0: than aSize, but is guaranteed to be not less than aSize. sl@0: sl@0: @param aSize The size of the cell to be allocated from the current thread's sl@0: heap. sl@0: sl@0: @return A pointer to the allocated cell. NULL, if there is insufficient memory sl@0: available. sl@0: sl@0: @panic USER 47, if the maximum unsigned value of aSize is greater sl@0: than or equal to KMaxTInt/2. For example, sl@0: calling Alloc(-1) raises this panic. sl@0: */ sl@0: { sl@0: sl@0: return(GetHeap()->Alloc(aSize)); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TAny* User::AllocL(TInt aSize) sl@0: /** sl@0: Allocates a cell of specified size from the current thread's heap, and leaves sl@0: if there is insufficient memory in the heap. sl@0: sl@0: The resulting size of the allocated cell may be rounded up to a value greater sl@0: than aSize, but is guaranteed to be not less than aSize. sl@0: sl@0: @param aSize The size of the cell to be allocated from the current thread's sl@0: heap. sl@0: sl@0: @return A pointer to the allocated cell. sl@0: sl@0: @panic USER 47, if the maximum unsigned value of aSize is greater sl@0: than or equal to KMaxTInt/2. For example, sl@0: calling Alloc(-1) raises this panic. sl@0: */ sl@0: { sl@0: sl@0: return(GetHeap()->AllocL(aSize)); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TAny *User::AllocLC(TInt aSize) sl@0: /** sl@0: Allocates a cell of specified size from the current thread's default heap, and, sl@0: if successful, places a pointer to the cell onto the cleanup stack. sl@0: sl@0: The function leaves if there is insufficient memory in the heap. sl@0: sl@0: The resulting size of the allocated cell may be rounded up to a value greater sl@0: than aSize, but is guaranteed to be not less than aSize. sl@0: sl@0: @param aSize The size of the cell to be allocated from the current thread's sl@0: default heap. sl@0: sl@0: @return A pointer to the allocated cell. sl@0: sl@0: @panic USER 47, if the maximum unsigned value of aSize is greater sl@0: than or equal to KMaxTInt/2. For example, sl@0: calling Alloc(-1) raises this panic. sl@0: */ sl@0: { sl@0: sl@0: return(GetHeap()->AllocLC(aSize)); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TAny* User::AllocZ(TInt aSize) sl@0: /** sl@0: Allocates a cell of specified size from the current thread's default heap, sl@0: and clears it to binary zeroes. sl@0: sl@0: If there is insufficient memory available on the heap from which to allocate a cell sl@0: of the required size, the function returns NULL. sl@0: sl@0: The resulting size of the allocated cell may be rounded up to a value greater sl@0: than aSize, but is guaranteed to be not less than aSize. sl@0: sl@0: @param aSize The size of the cell to be allocated from the current thread's sl@0: default heap. sl@0: sl@0: @return A pointer to the allocated cell. NULL, if there is insufficient memory sl@0: available. sl@0: sl@0: @panic USER 47, if the maximum unsigned value of aSize is greater sl@0: than or equal to KMaxTInt/2. For example, sl@0: calling Alloc(-1) raises this panic. sl@0: */ sl@0: { sl@0: sl@0: return GetHeap()->AllocZ(aSize); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TAny* User::AllocZL(TInt aSize) sl@0: /** sl@0: Allocates a cell of specified size from the current thread's default heap, sl@0: clears it to binary zeroes, and leaves if there is insufficient memory in sl@0: the heap. sl@0: sl@0: The resulting size of the allocated cell may be rounded up to a value greater sl@0: than aSize, but is guaranteed to be not less than aSize. sl@0: sl@0: @param aSize The size of the cell to be allocated from the current thread's sl@0: heap. sl@0: sl@0: @return A pointer to the allocated cell. sl@0: sl@0: @panic USER 47, if the maximum unsigned value of aSize is greater sl@0: than or equal to KMaxTInt/2. For example, sl@0: calling Alloc(-1) raises this panic. sl@0: */ sl@0: { sl@0: sl@0: return GetHeap()->AllocZL(aSize); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TInt User::Available(TInt &aBiggestBlock) sl@0: /** sl@0: Gets the total free space currently available on the current thread's sl@0: default heap, and the space available in the largest free block. sl@0: sl@0: The space available represents the total space which can be allocated. sl@0: sl@0: Note that compressing the heap may reduce the total free space available and the space sl@0: available in the largest free block. sl@0: sl@0: @param aBiggestBlock On return, contains the space available in the largest sl@0: free block on the current thread's default heap. sl@0: sl@0: @return The total free space currently available on the current thread's heap. sl@0: */ sl@0: { sl@0: sl@0: return(GetHeap()->Available(aBiggestBlock)); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C void User::Check() sl@0: /** sl@0: Checks the validity of the current thread's default heap. sl@0: sl@0: The function walks through the list of allocated cells and the list of free sl@0: cells checking that the heap is consistent and complete. sl@0: sl@0: @panic USER 47 if any corruption is found, specifically a bad allocated sl@0: heap cell size. sl@0: @panic USER 48 if any corruption is found, specifically a bad allocated sl@0: heap cell address. sl@0: @panic USER 49 if any corruption is found, specifically a bad free heap sl@0: cell address. sl@0: */ sl@0: { sl@0: sl@0: GetHeap()->Check(); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C void User::Free(TAny *aCell) sl@0: /** sl@0: Frees the specified cell and returns it to the current thread's default heap. sl@0: sl@0: @param aCell A pointer to a valid cell to be freed. If NULL this function sl@0: call will be ignored. sl@0: sl@0: @panic USER 42, if aCell is not NULL and does not point to a valid cell. sl@0: */ sl@0: { sl@0: sl@0: if (aCell) sl@0: GetHeap()->Free(aCell); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C void User::FreeZ(TAny * &aCell) sl@0: /** sl@0: Frees the specified cell, returns it to the current thread's default heap, and resets sl@0: the pointer to NULL. sl@0: sl@0: @param aCell A reference to a pointer to a valid cell to be freed. If NULL sl@0: this function call will be ignored. sl@0: sl@0: @panic USER 42, if aCell is not NULL and does not point to a valid cell. sl@0: */ sl@0: { sl@0: sl@0: if (aCell) sl@0: GetHeap()->FreeZ(aCell); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TAny* User::ReAlloc(TAny* aCell, TInt aSize, TInt aMode) sl@0: /** sl@0: Increases or decreases the size of an existing cell in the current sl@0: thread's heap. sl@0: sl@0: If the cell is being decreased in size, then it is guaranteed not to move, sl@0: and the function returns the pointer originally passed in aCell. Note that the sl@0: length of the cell will be the same if the difference between the old size sl@0: and the new size is smaller than the minimum cell size. sl@0: sl@0: If the cell is being increased in size, i.e. aSize is bigger than its sl@0: current size, then the function tries to grow the cell in place. sl@0: If successful, then the function returns the pointer originally sl@0: passed in aCell. If unsuccessful, then: sl@0: -# if the cell cannot be moved, i.e. aMode has the ENeverMove bit set, then sl@0: the function returns NULL. sl@0: -# if the cell can be moved, i.e. aMode does not have the ENeverMove bit set, sl@0: then the function tries to allocate a new replacement cell, and, if sl@0: successful, returns a pointer to the new cell; if unsuccessful, it sl@0: returns NULL. sl@0: sl@0: Note that in debug mode, the function returns NULL if the cell cannot be grown sl@0: in place, regardless of whether the ENeverMove bit is set. sl@0: sl@0: If the reallocated cell is at a different location from the original cell, then sl@0: the content of the original cell is copied to the reallocated cell. sl@0: sl@0: If the supplied pointer, aCell is NULL, then the function attempts to allocate sl@0: a new cell, but only if the cell can be moved, i.e. aMode does not have sl@0: the ENeverMove bit set. sl@0: sl@0: Note the following general points: sl@0: - If reallocation fails, the content of the original cell is preserved. sl@0: - The resulting size of the re-allocated cell may be rounded up to a value sl@0: greater than aSize, but is guaranteed to be not less than aSize. sl@0: sl@0: @param aCell A pointer to the cell to be reallocated. This may be NULL. sl@0: sl@0: @param aSize The new size of the cell. This may be bigger or smaller than the sl@0: size of the original cell. The value can also be zero, but this is sl@0: interpreted as a request for a cell of minimum size; the net sl@0: effect is the same as if the caller had explicitly requested sl@0: a cell of minimum size. sl@0: Note that the minimum size of a heap cell is device dependent. sl@0: sl@0: @param aMode Flags controlling the reallocation. The only bit which has any sl@0: effect on this function is that defined by the enumeration sl@0: ENeverMove of the enum RAllocator::TReAllocMode. sl@0: If this is set, then any successful reallocation guarantees not sl@0: to have changed the start address of the cell. sl@0: By default, this parameter is zero. sl@0: sl@0: @return A pointer to the reallocated cell. This may be the same as the original sl@0: pointer supplied through aCell. NULL if there is insufficient memory to sl@0: reallocate the cell, or to grow it in place. sl@0: sl@0: @panic USER 42, if aCell is not NULL, and does not point to a valid cell. sl@0: @panic USER 47, if the maximum unsigned value of aSize is greater sl@0: than or equal to KMaxTInt/2. For example, sl@0: calling ReAlloc(someptr,-1) raises this panic. sl@0: sl@0: @see RAllocator::TReAllocMode sl@0: */ sl@0: { sl@0: sl@0: return GetHeap()->ReAlloc(aCell, aSize, aMode); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TAny* User::ReAllocL(TAny* aCell, TInt aSize, TInt aMode) sl@0: /** sl@0: Increases or decreases the size of an existing cell, and leaves sl@0: if there is insufficient memory in the current thread's default heap. sl@0: sl@0: If the cell is being decreased in size, then it is guaranteed not to move, sl@0: and the function returns the pointer originally passed in aCell. Note that the sl@0: length of the cell will be the same if the difference between the old size sl@0: and the new size is smaller than the minimum cell size. sl@0: sl@0: If the cell is being increased in size, i.e. aSize is bigger than its sl@0: current size, then the function tries to grow the cell in place. sl@0: If successful, then the function returns the pointer originally sl@0: passed in aCell. If unsuccessful, then: sl@0: -# if the cell cannot be moved, i.e. aMode has the ENeverMove bit set, then sl@0: the function leaves. sl@0: -# if the cell can be moved, i.e. aMode does not have the ENeverMove bit set, sl@0: then the function tries to allocate a new replacement cell, and, if sl@0: successful, returns a pointer to the new cell; if unsuccessful, it sl@0: leaves. sl@0: sl@0: Note that in debug mode, the function leaves if the cell cannot be grown sl@0: in place, regardless of whether the ENeverMove bit is set. sl@0: sl@0: If the reallocated cell is at a different location from the original cell, then sl@0: the content of the original cell is copied to the reallocated cell. sl@0: sl@0: If the supplied pointer, aCell is NULL, then the function attempts to allocate sl@0: a new cell, but only if the cell can be moved, i.e. aMode does not have sl@0: the ENeverMove bit set. sl@0: sl@0: Note the following general points: sl@0: - If reallocation fails, the content of the original cell is preserved. sl@0: - The resulting size of the re-allocated cell may be rounded up to a value sl@0: greater than aSize, but is guaranteed to be not less than aSize. sl@0: sl@0: @param aCell A pointer to the cell to be reallocated. This may be NULL. sl@0: sl@0: @param aSize The new size of the cell. This may be bigger or smaller than the sl@0: size of the original cell. The value can also be zero, but this is sl@0: interpreted as a request for a cell of minimum size; the net sl@0: effect is the same as if the caller had explicitly requested sl@0: a cell of minimum size. sl@0: Note that the minimum size of a heap cell is device dependent. sl@0: sl@0: @param aMode Flags controlling the reallocation. The only bit which has any sl@0: effect on this function is that defined by the enumeration sl@0: ENeverMove of the enum RAllocator::TReAllocMode. sl@0: If this is set, then any successful reallocation guarantees not sl@0: to have changed the start address of the cell. sl@0: By default, this parameter is zero. sl@0: sl@0: @return A pointer to the reallocated cell. This may be the same as the original sl@0: pointer supplied through aCell. sl@0: sl@0: @panic USER 42, if aCell is not NULL, and does not point to a valid cell. sl@0: @panic USER 47, if the maximum unsigned value of aSize is greater sl@0: than or equal to KMaxTInt/2. For example, sl@0: calling ReAlloc(someptr,-1) raises this panic. sl@0: sl@0: @see RAllocator::TReAllocMode sl@0: */ sl@0: { sl@0: sl@0: return GetHeap()->ReAllocL(aCell, aSize, aMode); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C RAllocator& User::Allocator() sl@0: /** sl@0: Gets the current thread's default current heap. sl@0: sl@0: @return The current heap. sl@0: */ sl@0: { sl@0: sl@0: return *GetHeap(); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TInt User::AllocSize(TInt &aTotalAllocSize) sl@0: /** sl@0: Gets the total number of cells allocated on the current thread's default heap, sl@0: and the total space allocated to them. sl@0: sl@0: @param aTotalAllocSize On return, contains the total space allocated to sl@0: the cells. sl@0: sl@0: @return The number of cells currently allocated on the current thread's heap. sl@0: */ sl@0: { sl@0: sl@0: return(GetHeap()->AllocSize(aTotalAllocSize)); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TInt User::CountAllocCells() sl@0: /** sl@0: Gets the total number of cells allocated on the current thread's default heap. sl@0: sl@0: sl@0: @return The number of cells allocated on the current thread's default user heap. sl@0: */ sl@0: { sl@0: return(GetHeap()->Count()); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TInt User::CountAllocCells(TInt &aFreeCount) sl@0: /** sl@0: Gets the the total number of cells allocated, and the number of free cells, sl@0: on the current thread's default heap. sl@0: sl@0: @param aFreeCount On return, contains the number of free cells sl@0: on the current thread's default heap. sl@0: sl@0: @return The number of cells allocated on the current thread's default heap. sl@0: */ sl@0: { sl@0: sl@0: return(GetHeap()->Count(aFreeCount)); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C RAllocator* User::SwitchAllocator(RAllocator* aA) sl@0: /** sl@0: Changes the current thread's heap. sl@0: sl@0: @param aA A pointer to the new heap handle. sl@0: sl@0: @return A pointer to the old heap handle. sl@0: */ sl@0: { sl@0: sl@0: #ifdef __USERSIDE_THREAD_DATA__ sl@0: // Just cache the pointer user-side. We still need to let the kernel know what's going on so sl@0: // the heap can be cleaned up correctly later. sl@0: LocalThreadData()->iHeap=aA; sl@0: #endif sl@0: return Exec::HeapSwitch(aA); sl@0: } sl@0: sl@0: // The suffix table sl@0: const TText16* const __DefaultDateSuffixTable[KMaxSuffixes] = sl@0: { sl@0: _S16("st"),_S16("nd"),_S16("rd"),_S16("th"),_S16("th"), sl@0: _S16("th"),_S16("th"),_S16("th"),_S16("th"),_S16("th"), sl@0: _S16("th"),_S16("th"),_S16("th"),_S16("th"),_S16("th"), sl@0: _S16("th"),_S16("th"),_S16("th"),_S16("th"),_S16("th"), sl@0: _S16("st"),_S16("nd"),_S16("rd"),_S16("th"),_S16("th"), sl@0: _S16("th"),_S16("th"),_S16("th"),_S16("th"),_S16("th"), sl@0: _S16("st") sl@0: }; sl@0: sl@0: // The day names sl@0: const TText16* const __DefaultDayTable[KMaxDays] = sl@0: { sl@0: _S16("Monday"), sl@0: _S16("Tuesday"), sl@0: _S16("Wednesday"), sl@0: _S16("Thursday"), sl@0: _S16("Friday"), sl@0: _S16("Saturday"), sl@0: _S16("Sunday") sl@0: }; sl@0: sl@0: // The abbreviated day names sl@0: const TText16* const __DefaultDayAbbTable[KMaxDays] = sl@0: { sl@0: _S16("Mon"), sl@0: _S16("Tue"), sl@0: _S16("Wed"), sl@0: _S16("Thu"), sl@0: _S16("Fri"), sl@0: _S16("Sat"), sl@0: _S16("Sun") sl@0: }; sl@0: sl@0: // The month names sl@0: const TText16* const __DefaultMonthTable[KMaxMonths] = sl@0: { sl@0: _S16("January"), sl@0: _S16("February"), sl@0: _S16("March"), sl@0: _S16("April"), sl@0: _S16("May"), sl@0: _S16("June"), sl@0: _S16("July"), sl@0: _S16("August"), sl@0: _S16("September"), sl@0: _S16("October"), sl@0: _S16("November"), sl@0: _S16("December") sl@0: }; sl@0: sl@0: // The abbreviated month names sl@0: const TText16* const __DefaultMonthAbbTable[KMaxMonths] = sl@0: { sl@0: _S16("Jan"), sl@0: _S16("Feb"), sl@0: _S16("Mar"), sl@0: _S16("Apr"), sl@0: _S16("May"), sl@0: _S16("Jun"), sl@0: _S16("Jul"), sl@0: _S16("Aug"), sl@0: _S16("Sep"), sl@0: _S16("Oct"), sl@0: _S16("Nov"), sl@0: _S16("Dec") sl@0: }; sl@0: sl@0: // The am/pm strings sl@0: const TText16* const __DefaultAmPmTable[KMaxAmPms] = sl@0: { sl@0: _S16("am"), sl@0: _S16("pm") sl@0: }; sl@0: sl@0: const TText16* const __DefaultLMsgTable[ELocaleMessages_LastMsg] = sl@0: { sl@0: // Fileserver sl@0: _S16("Retry"), // Button 1 sl@0: _S16("Stop"), // Button 2 sl@0: _S16("Put the disk back"), // Put the card back - line1 sl@0: _S16("or data will be lost"), // Put the card back - line2 sl@0: _S16("Batteries too low"), // Low power - line1 sl@0: _S16("Cannot complete write to disk"), // Low power - line2 sl@0: _S16("Disk error - cannot complete write"), // Disk error - line1 sl@0: _S16("Retry or data will be lost"), // Disk error - line2 sl@0: // SoundDriver sl@0: _S16("Chimes"), // Chimes sl@0: _S16("Rings"), // Rings sl@0: _S16("Signal"), // Signal sl@0: // MediaDriver diskname (max 16 chars) sl@0: _S16("Internal"), // Internal sl@0: _S16("External(01)"), // External(01) sl@0: _S16("External(02)"), // External(02) sl@0: _S16("External(03)"), // External(03) sl@0: _S16("External(04)"), // External(04) sl@0: _S16("External(05)"), // External(05) sl@0: _S16("External(06)"), // External(06) sl@0: _S16("External(07)"), // External(07) sl@0: _S16("External(08)"), // External(08) sl@0: // MediaDriver socketname (max 16 chars) sl@0: _S16("Socket(01)"), // Socket(01) sl@0: _S16("Socket(02)"), // Socket(02) sl@0: _S16("Socket(03)"), // Socket(03) sl@0: _S16("Socket(04)") // Socket(04) sl@0: }; sl@0: sl@0: LOCAL_C void LocaleLanguageGet(SLocaleLanguage& locale) sl@0: { sl@0: TPckg localeLanguageBuf(locale); sl@0: TInt r = RProperty::Get(KUidSystemCategory, KLocaleLanguageKey, localeLanguageBuf); sl@0: __ASSERT_DEBUG(r == KErrNone || r == KErrNotFound, Panic(EBadLocaleParameter)); sl@0: if(r == KErrNotFound) sl@0: { sl@0: locale.iLanguage = ELangEnglish; sl@0: locale.iDateSuffixTable = (const TText16*)__DefaultDateSuffixTable; sl@0: locale.iDayTable = (const TText16*)__DefaultDayTable; sl@0: locale.iDayAbbTable = (const TText16*)__DefaultDayAbbTable; sl@0: locale.iMonthTable = (const TText16*)__DefaultMonthTable; sl@0: locale.iMonthAbbTable = (const TText16*)__DefaultMonthAbbTable; sl@0: locale.iAmPmTable = (const TText16*)__DefaultAmPmTable; sl@0: locale.iMsgTable = (const TText16* const*)__DefaultLMsgTable; sl@0: } sl@0: } sl@0: sl@0: LOCAL_C void LocaleSettingsGet(SLocaleLocaleSettings& locale) sl@0: { sl@0: TPckg localeSettingsBuf(locale); sl@0: TInt r = RProperty::Get(KUidSystemCategory, KLocaleDataExtraKey, localeSettingsBuf); sl@0: __ASSERT_DEBUG(r == KErrNone || r == KErrNotFound, Panic(EBadLocaleParameter)); sl@0: if(r == KErrNotFound) sl@0: { sl@0: Mem::Copy(&locale.iCurrencySymbol[0], _S16("\x00a3"), sizeof(TText16) << 2); sl@0: locale.iLocaleExtraSettingsDllPtr = NULL; sl@0: } sl@0: } sl@0: sl@0: LOCAL_C void LocaleTimeDateFormatGet(SLocaleTimeDateFormat& locale) sl@0: { sl@0: TPckg localeTimeDateFormatBuf(locale); sl@0: TInt r = RProperty::Get(KUidSystemCategory, KLocaleTimeDateFormatKey, localeTimeDateFormatBuf); sl@0: __ASSERT_DEBUG(r == KErrNone || r == KErrNotFound, Panic(EBadLocaleParameter)); sl@0: if(r == KErrNotFound) sl@0: { sl@0: Mem::Copy(&locale.iShortDateFormatSpec[0], _S16("%F%*D/%*M/%Y"), sizeof(TText16) * 13); sl@0: Mem::Copy(&locale.iLongDateFormatSpec[0], _S16("%F%*D%X %N %Y"), sizeof(TText16) * 14); sl@0: Mem::Copy(&locale.iTimeFormatSpec[0], _S16("%F%*I:%T:%S %*A"), sizeof(TText16) * 16); sl@0: locale.iLocaleTimeDateFormatDllPtr = NULL; sl@0: } sl@0: } sl@0: sl@0: EXPORT_C void TDayName::Set(TDay aDay) sl@0: /** sl@0: Re-retrieves the current locale's text for the specified day of the week. sl@0: sl@0: @param aDay Identifies the day of the week. sl@0: sl@0: @panic USER 184, if the specified day is outside the permitted range. sl@0: */ sl@0: { sl@0: sl@0: __ASSERT_ALWAYS(aDay>=EMonday && aDay<=ESunday,Panic(EBadLocaleParameter)); sl@0: SLocaleLanguage localeLanguage; sl@0: LocaleLanguageGet(localeLanguage); sl@0: Copy((reinterpret_cast(localeLanguage.iDayTable))[aDay]); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C void TDayNameAbb::Set(TDay aDay) sl@0: /** sl@0: Re-retrieves the current locale's abbreviated text for the specified day of sl@0: the week. sl@0: sl@0: @param aDay Identifies the day of the week. sl@0: sl@0: @panic USER 184, if the specified day is outside the permitted range. sl@0: */ sl@0: { sl@0: sl@0: __ASSERT_ALWAYS(aDay>=EMonday && aDay<=ESunday,Panic(EBadLocaleParameter)); sl@0: SLocaleLanguage localeLanguage; sl@0: LocaleLanguageGet(localeLanguage); sl@0: Copy((reinterpret_cast(localeLanguage.iDayAbbTable))[aDay]); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C void TMonthName::Set(TMonth aMonth) sl@0: /** sl@0: Re-retrieves the current locale's text for the specified month. sl@0: sl@0: @param aMonth Identifies the month. sl@0: sl@0: @panic USER 184, if the specified month is outside the permitted range. sl@0: */ sl@0: { sl@0: sl@0: __ASSERT_ALWAYS(aMonth>=EJanuary && aMonth<=EDecember,Panic(EBadLocaleParameter)); sl@0: SLocaleLanguage localeLanguage; sl@0: LocaleLanguageGet(localeLanguage); sl@0: Copy((reinterpret_cast(localeLanguage.iMonthTable))[aMonth]); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C void TMonthNameAbb::Set(TMonth aMonth) sl@0: /** sl@0: Re-retrieves the current locale's abbreviated text for the specified month. sl@0: sl@0: @param aMonth Identifies the month. sl@0: sl@0: @panic USER 184, if the specified month is outside the permitted range. sl@0: */ sl@0: { sl@0: sl@0: __ASSERT_ALWAYS(aMonth>=EJanuary && aMonth<=EDecember,Panic(EBadLocaleParameter)); sl@0: SLocaleLanguage localeLanguage; sl@0: LocaleLanguageGet(localeLanguage); sl@0: Copy((reinterpret_cast(localeLanguage.iMonthAbbTable))[aMonth]); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C void TDateSuffix::Set(TInt aSuffix) sl@0: /** sl@0: Re-retrieves the current locale's date suffix text for the specified day of sl@0: the month. sl@0: sl@0: @param aSuffix A value identifying the day of the month. The value can sl@0: range from 0 to 30 so that the first day of the month is sl@0: identified by 0, the second day by 1 etc. sl@0: sl@0: @panic USER 69, if aDateSuffix is outside the range 0 to 30. sl@0: */ sl@0: { sl@0: sl@0: __ASSERT_ALWAYS(aSuffix>=0 && aSuffix(localeLanguage.iDateSuffixTable))[aSuffix]); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C void TAmPmName::Set(TAmPm aSelector) sl@0: /** sl@0: Re-retrieves the current locale's text for identifying time before or after sl@0: noon as identified by the specified selector. sl@0: sl@0: @param aSelector The am/pm selector. sl@0: sl@0: @panic USER 69, if aDateSuffix is outside the range 0 to 30. sl@0: */ sl@0: { sl@0: sl@0: __ASSERT_ALWAYS(aSelector==EAm || aSelector==EPm,Panic(ETLoclSuffixOutOfRange)); sl@0: SLocaleLanguage localeLanguage; sl@0: LocaleLanguageGet(localeLanguage); sl@0: Copy((reinterpret_cast(localeLanguage.iAmPmTable))[aSelector]); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C void TCurrencySymbol::Set() sl@0: /** sl@0: Re-retrieves the current locale's currency symbol(s). sl@0: */ sl@0: { sl@0: SLocaleLocaleSettings locale; sl@0: LocaleSettingsGet(locale); sl@0: Copy(&locale.iCurrencySymbol[0]); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C void TShortDateFormatSpec::Set() sl@0: /** sl@0: Sets the contents of the short date format specification from the system-wide sl@0: settings. sl@0: */ sl@0: { sl@0: SLocaleTimeDateFormat locale; sl@0: LocaleTimeDateFormatGet(locale); sl@0: Copy(&locale.iShortDateFormatSpec[0]); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C void TLongDateFormatSpec::Set() sl@0: /** sl@0: Sets the contents of the long date format specification from the system-wide sl@0: settings. sl@0: */ sl@0: { sl@0: SLocaleTimeDateFormat locale; sl@0: LocaleTimeDateFormatGet(locale); sl@0: Copy(&locale.iLongDateFormatSpec[0]); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C void TTimeFormatSpec::Set() sl@0: /** sl@0: Sets the contents of the time string format specification from the system-wide sl@0: settings. sl@0: */ sl@0: { sl@0: SLocaleTimeDateFormat locale; sl@0: LocaleTimeDateFormatGet(locale); sl@0: Copy(&locale.iTimeFormatSpec[0]); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TInt User::SetCurrencySymbol(const TDesC& aSymbol) sl@0: /** sl@0: Sets the system wide currency symbol. sl@0: sl@0: On successful return from this function, a call to the Set() member function sl@0: of a TCurrencySymbol object fetches the new currency symbol. sl@0: sl@0: @capability WriteDeviceData sl@0: sl@0: @param aSymbol A reference to the descriptor containing the currency symbol sl@0: to be set. sl@0: sl@0: @return KErrNone if successful, otherwise one of the other system wide error codes. sl@0: sl@0: @panic USER 119, if the length of aSymbol is greater than KMaxCurrencySymbol. sl@0: sl@0: @see TCurrencySymbol sl@0: @see TCurrencySymbol::Set() sl@0: @see KMaxCurrencySymbol sl@0: */ sl@0: { sl@0: sl@0: TExtendedLocale locale; sl@0: return locale.SetCurrencySymbol(aSymbol); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TLanguage User::Language() sl@0: /** sl@0: Gets the language of the current locale. sl@0: sl@0: @return One of the TLanguage enumerators identifying the language of the sl@0: current locale. sl@0: */ sl@0: { sl@0: sl@0: SLocaleLanguage localeLanguage; sl@0: LocaleLanguageGet(localeLanguage); sl@0: return localeLanguage.iLanguage; sl@0: } sl@0: sl@0: EXPORT_C TRegionCode User::RegionCode() sl@0: { sl@0: #ifdef SYMBIAN_DISTINCT_LOCALE_MODEL sl@0: TLocale locale; sl@0: locale.Refresh(); sl@0: return static_cast(locale.RegionCode()); sl@0: #else sl@0: return static_cast(0); sl@0: #endif sl@0: } sl@0: sl@0: sl@0: EXPORT_C TLocale::TLocale() sl@0: /** sl@0: Default constructor. sl@0: sl@0: It constructs the object with the system's locale settings. sl@0: sl@0: A single copy of the locale information is maintained by the system. This sl@0: copy may be refreshed under application control with TLocale::Refresh(), and sl@0: the settings may be saved to the system with TLocale::Set(). However, the sl@0: settings are never updated by the system apart from under application control. sl@0: This enables applications to guarantee that consistent locale information sl@0: is used. sl@0: sl@0: @see TLocale::Refresh() sl@0: @see TLocale::Set() sl@0: */ sl@0: { sl@0: sl@0: Refresh(); sl@0: } sl@0: sl@0: sl@0: const TUint8 __DefaultDateSeparator[KMaxDateSeparators] = { 0, '/', '/', 0 }; sl@0: const TUint8 __DefaultTimeSeparator[KMaxTimeSeparators] = { 0, ':', ':', 0 }; sl@0: sl@0: void TLocale::SetDefaults() sl@0: { sl@0: iCountryCode = 44; sl@0: iUniversalTimeOffset = 0; sl@0: iDateFormat = EDateEuropean; sl@0: iTimeFormat = ETime12; sl@0: iCurrencySymbolPosition = ELocaleBefore; sl@0: iCurrencySpaceBetween = EFalse; sl@0: iCurrencyDecimalPlaces = 2; sl@0: iNegativeCurrencyFormat = TNegativeCurrencyFormat(EFalse); sl@0: iCurrencyTriadsAllowed = ETrue; sl@0: iThousandsSeparator = ','; sl@0: iDecimalSeparator = '.'; sl@0: TInt i=0; sl@0: for(; i localeDataBuf(*this); sl@0: TInt r = RProperty::Get(KUidSystemCategory, KLocaleDataKey, localeDataBuf); sl@0: __ASSERT_DEBUG(r == KErrNone || r == KErrNotFound, Panic(EBadLocaleParameter)); sl@0: if(r == KErrNone) sl@0: { sl@0: iUniversalTimeOffset = Exec::UTCOffset(); sl@0: iDaylightSaving = 0; sl@0: } sl@0: else if(r == KErrNotFound) sl@0: { sl@0: SetDefaults(); sl@0: } sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TInt TLocale::Set() const sl@0: /** sl@0: Transfers the locale settings from this object to the system. Note that sl@0: the timezone offset and daylight savings flags are ignored as setting these sl@0: through TLocale is no longer supported. sl@0: sl@0: After this function has been called, other applications may use the new sl@0: settings for newly-constructed TLocale objects, sl@0: or if they use TLocale::Refresh(), to refresh their settings from sl@0: the system copy. sl@0: sl@0: @capability WriteDeviceData sl@0: sl@0: @return KErrNone if successful, otherwise one of the other system wide error codes. sl@0: sl@0: @see TLocale::Refresh() sl@0: */ sl@0: { sl@0: TPckg localeDataBuf(*this); sl@0: TInt r = RProperty::Set(KUidSystemCategory, KLocaleDataKey, localeDataBuf); sl@0: if(r == KErrNone) sl@0: { sl@0: Exec::NotifyChanges(EChangesLocale); sl@0: } sl@0: return r; sl@0: } sl@0: sl@0: TInt TExtendedLocale::DoLoadLocale(const TDesC& aLocaleDllName, TLibraryFunction* aExportList) sl@0: { sl@0: RLoader loader; sl@0: TInt r = loader.LoadLocale(aLocaleDllName, aExportList); sl@0: return r; sl@0: } sl@0: sl@0: #ifdef SYMBIAN_DISTINCT_LOCALE_MODEL sl@0: void TExtendedLocale::DoUpdateLanguageSettingsV2(TLibraryFunction* aExportList) sl@0: { sl@0: iLocale.iDigitType = EDigitTypeWestern; sl@0: iLocale.iLanguageDowngrade[0] = ELangNone; sl@0: iLocale.iLanguageDowngrade[1] = ELangNone; sl@0: iLocale.iLanguageDowngrade[2] = ELangNone; sl@0: sl@0: iLanguageSettings.iLanguage = (TLanguage)aExportList[FnLanguageV2](); sl@0: iLanguageSettings.iDateSuffixTable = (const TText*)aExportList[FnDateSuffixTableV2](); sl@0: iLanguageSettings.iDayTable = (const TText*)aExportList[FnDayTableV2](); sl@0: iLanguageSettings.iDayAbbTable = (const TText*)aExportList[FnDayAbbTableV2](); sl@0: iLanguageSettings.iMonthTable = (const TText*)aExportList[FnMonthTableV2](); sl@0: iLanguageSettings.iMonthAbbTable = (const TText*)aExportList[FnMonthAbbTableV2](); sl@0: iLanguageSettings.iAmPmTable = (const TText*)aExportList[FnAmPmTableV2](); sl@0: iLanguageSettings.iMsgTable = (const TText16* const*)aExportList[FnMsgTableV2](); sl@0: sl@0: TDigitType digitType = (TDigitType)aExportList[FnDigitTypeV2](); sl@0: iLocale.SetDigitType(digitType); sl@0: sl@0: TLanguage* languageDowngrade = (TLanguage*)aExportList[FnLanguageDowngradeTableV2](); sl@0: iLocale.SetLanguageDowngrade(0,*(languageDowngrade)); sl@0: iLocale.SetLanguageDowngrade(1,*(languageDowngrade+1)); sl@0: iLocale.SetLanguageDowngrade(2,*(languageDowngrade+2)); sl@0: } sl@0: sl@0: void TExtendedLocale::DoUpdateLocaleSettingsV2(TLibraryFunction* aExportList) sl@0: { sl@0: sl@0: Mem::Copy(&iLocaleExtraSettings.iCurrencySymbol[0], (const TAny*)aExportList[FnCurrencySymbolV2](), sizeof(TText) * (KMaxCurrencySymbol+1)); sl@0: iLocaleExtraSettings.iLocaleExtraSettingsDllPtr = (TAny*)aExportList[FnCurrencySymbolV2](); sl@0: Mem::Copy(&iLocaleTimeDateFormat.iShortDateFormatSpec[0], (const TAny*)aExportList[FnShortDateFormatSpecV2](), sizeof(TText) * (KMaxShortDateFormatSpec+1)); sl@0: Mem::Copy(&iLocaleTimeDateFormat.iLongDateFormatSpec[0], (const TAny*)aExportList[FnLongDateFormatSpecV2](), sizeof(TText) * (KMaxLongDateFormatSpec+1)) ; sl@0: Mem::Copy(&iLocaleTimeDateFormat.iTimeFormatSpec[0], (const TAny*)aExportList[FnTimeFormatSpecV2](), sizeof(TText) * (KMaxTimeFormatSpec+1)); sl@0: iLocaleTimeDateFormat.iLocaleTimeDateFormatDllPtr = (TAny*)aExportList[FnCurrencySymbolV2](); sl@0: sl@0: iLocale.iExtraNegativeCurrencyFormatFlags=0x80000000; sl@0: sl@0: typedef void (*TLibFn)(TLocale*); sl@0: ((TLibFn)aExportList[FnLocaleDataV2])(&iLocale); sl@0: sl@0: if (iLocale.iExtraNegativeCurrencyFormatFlags&0x80000000) sl@0: iLocale.iExtraNegativeCurrencyFormatFlags=0; sl@0: } sl@0: #endif sl@0: sl@0: void TExtendedLocale::DoUpdateLanguageSettings(TLibraryFunction* aExportList) sl@0: { sl@0: iLanguageSettings.iLanguage = (TLanguage)aExportList[FnLanguage](); sl@0: iLanguageSettings.iDateSuffixTable = (const TText*)aExportList[FnDateSuffixTable](); sl@0: iLanguageSettings.iDayTable = (const TText*)aExportList[FnDayTable](); sl@0: iLanguageSettings.iDayAbbTable = (const TText*)aExportList[FnDayAbbTable](); sl@0: iLanguageSettings.iMonthTable = (const TText*)aExportList[FnMonthTable](); sl@0: iLanguageSettings.iMonthAbbTable = (const TText*)aExportList[FnMonthAbbTable](); sl@0: iLanguageSettings.iAmPmTable = (const TText*)aExportList[FnAmPmTable](); sl@0: iLanguageSettings.iMsgTable = (const TText16* const*)aExportList[FnMsgTable](); sl@0: } sl@0: sl@0: void TExtendedLocale::DoUpdateLocaleSettings(TLibraryFunction* aExportList) sl@0: { sl@0: Mem::Copy(&iLocaleExtraSettings.iCurrencySymbol[0], (const TAny*)aExportList[FnCurrencySymbol](), sizeof(TText) * (KMaxCurrencySymbol+1)); sl@0: iLocaleExtraSettings.iLocaleExtraSettingsDllPtr = (TAny*)aExportList[FnDateSuffixTable](); sl@0: } sl@0: sl@0: void TExtendedLocale::DoUpdateTimeDateFormat(TLibraryFunction* aExportList) sl@0: { sl@0: Mem::Copy(&iLocaleTimeDateFormat.iShortDateFormatSpec[0], (const TAny*)aExportList[FnShortDateFormatSpec](), sizeof(TText) * (KMaxShortDateFormatSpec+1)); sl@0: Mem::Copy(&iLocaleTimeDateFormat.iLongDateFormatSpec[0], (const TAny*)aExportList[FnLongDateFormatSpec](), sizeof(TText) * (KMaxLongDateFormatSpec+1)) ; sl@0: Mem::Copy(&iLocaleTimeDateFormat.iTimeFormatSpec[0], (const TAny*)aExportList[FnTimeFormatSpec](), sizeof(TText) * (KMaxTimeFormatSpec+1)); sl@0: iLocaleTimeDateFormat.iLocaleTimeDateFormatDllPtr = (TAny*)aExportList[FnDateSuffixTable](); sl@0: } sl@0: sl@0: /** sl@0: Default constructor. sl@0: sl@0: It constructs an empty object sl@0: sl@0: This is an empty copy of TExtendedLocale. To get the system locale you can sl@0: use TExtendedLocale::LoadSystemSettings. The current settings may be saved to the system sl@0: with TLocale::SaveSystemSettings(). sl@0: sl@0: @see TExtendedLocale::LoadSystemSettings sl@0: @see TExtendedLocale::SaveSystemSettings sl@0: */ sl@0: EXPORT_C TExtendedLocale::TExtendedLocale() sl@0: : iLocale(0) sl@0: { sl@0: sl@0: Mem::FillZ(&iLanguageSettings, sizeof(TExtendedLocale) - sizeof(TLocale)); sl@0: } sl@0: sl@0: /** sl@0: Load system wide locale settings sl@0: sl@0: It initialises this TExtendedLocale with the system wide locale settings. sl@0: The settings stored in the TExtendedLocale are overwritten with the system sl@0: wide locale. sl@0: sl@0: @see TExtendedLocale::SaveSystemSettings sl@0: */ sl@0: EXPORT_C void TExtendedLocale::LoadSystemSettings() sl@0: { sl@0: LocaleLanguageGet(iLanguageSettings); sl@0: LocaleSettingsGet(iLocaleExtraSettings); sl@0: LocaleTimeDateFormatGet(iLocaleTimeDateFormat); sl@0: iDefaultCharSet = GetLocaleCharSet(); sl@0: iPreferredCharSet = GetLocalePreferredCharSet(); sl@0: iLocale.Refresh(); sl@0: } sl@0: sl@0: /** sl@0: Make the current locale information system wide sl@0: sl@0: It overwrites the system wide locale information with the locale information sl@0: stored in this TExtendedLocale. sl@0: This will generate a notification for system locale changes. sl@0: In case of an error, the locale might be in an unconsistent state. sl@0: sl@0: @capability WriteDeviceData sl@0: sl@0: @return KErrNone if successful, otherwise one of the other system wide error codes. sl@0: */ sl@0: EXPORT_C TInt TExtendedLocale::SaveSystemSettings() sl@0: { sl@0: sl@0: TPckg localeLanguageBuf(iLanguageSettings); sl@0: TInt r = RProperty::Set(KUidSystemCategory, KLocaleLanguageKey, localeLanguageBuf); sl@0: if(r != KErrNone) sl@0: return r; sl@0: sl@0: TPckg localeSettingsBuf(iLocaleExtraSettings); sl@0: r = RProperty::Set(KUidSystemCategory, KLocaleDataExtraKey, localeSettingsBuf); sl@0: if(r != KErrNone) sl@0: return r; sl@0: sl@0: TPckg localeTimeDateFormatBuf(iLocaleTimeDateFormat); sl@0: r = RProperty::Set(KUidSystemCategory, KLocaleTimeDateFormatKey, localeTimeDateFormatBuf); sl@0: if(r != KErrNone) sl@0: return r; sl@0: sl@0: r = Exec::SetGlobalUserData(ELocaleDefaultCharSet, (TInt)iDefaultCharSet); sl@0: if(r != KErrNone) sl@0: return r; sl@0: sl@0: r = Exec::SetGlobalUserData(ELocalePreferredCharSet, (TInt)iPreferredCharSet); sl@0: sl@0: if(r == KErrNone) sl@0: { sl@0: iLocale.Set(); sl@0: } sl@0: sl@0: return r; sl@0: } sl@0: sl@0: #ifdef SYMBIAN_DISTINCT_LOCALE_MODEL sl@0: TInt TExtendedLocale::CheckLocaleDllName(const TDesC& aLocaleDllName, TInt& languageID) sl@0: { sl@0: languageID = 0; sl@0: sl@0: if(aLocaleDllName.Find(KLoc) == KErrNotFound) sl@0: return KErrNotFound; sl@0: sl@0: TInt len = aLocaleDllName.Length() - 6; //6 is the length of KLoc. sl@0: TPtrC ptr = aLocaleDllName.Right(len); sl@0: for(TInt i =0; i< len; i++) sl@0: { sl@0: if(ptr[i] >= '0' && ptr[i] <= '9') sl@0: { sl@0: languageID = languageID*10 + (ptr[i] - '0'); sl@0: } sl@0: else sl@0: { sl@0: languageID = 0; sl@0: return KErrNotFound; sl@0: } sl@0: } sl@0: return KErrNone; sl@0: } sl@0: sl@0: //add file extension, such as "elocl_lan" will be "elocl_lan.012" sl@0: void TExtendedLocale::AddExtension(TDes& aFileName, TInt aExtension) sl@0: { sl@0: if (aExtension < 10) sl@0: { sl@0: aFileName.AppendNum(0); sl@0: aFileName.AppendNum(0); sl@0: aFileName.AppendNum(aExtension); sl@0: } sl@0: else if (aExtension < 100) sl@0: { sl@0: aFileName.AppendNum(0); sl@0: aFileName.AppendNum(aExtension); sl@0: } sl@0: else sl@0: { sl@0: aFileName.AppendNum(aExtension); sl@0: } sl@0: return; sl@0: } sl@0: #endif sl@0: sl@0: /** sl@0: Loads a locale Dll and get the locale information sl@0: sl@0: It loads a locale DLL and it initialises the contents of this TExtendedLocale sl@0: with the locale information stored in the DLL. The locale information is only sl@0: stored in this TExtendedLocale. If you want to set the system wide settings with sl@0: the locale information in the DLL, you can call TExtendedLocale::SaveSystemSettings sl@0: after calling this function. sl@0: sl@0: @param aLocaleDllName The name of the locale DLL to be loaded sl@0: @return KErrNone if successful, system wide error if not sl@0: sl@0: @see TExtendedLocale::SaveSystemSettings sl@0: */ sl@0: EXPORT_C TInt TExtendedLocale::LoadLocale(const TDesC& aLocaleDllName) sl@0: { sl@0: #ifdef SYMBIAN_DISTINCT_LOCALE_MODEL sl@0: TLibraryFunction data[KNumLocaleExports]; sl@0: TInt r = DoLoadLocale(aLocaleDllName, &data[0]); sl@0: if(r == KErrNone) sl@0: { sl@0: iLocale.iExtraNegativeCurrencyFormatFlags=0x80000000; sl@0: iLocale.iLanguageDowngrade[0] = ELangNone; sl@0: iLocale.iLanguageDowngrade[1] = ELangNone; sl@0: iLocale.iLanguageDowngrade[2] = ELangNone; sl@0: iLocale.iDigitType = EDigitTypeWestern; sl@0: sl@0: typedef void (*TLibFn)(TLocale*); sl@0: ((TLibFn)data[FnLocaleData])(&iLocale); sl@0: sl@0: //Locale daylightsavings unchanged - we have travelled through space, not time sl@0: if (iLocale.iExtraNegativeCurrencyFormatFlags&0x80000000) sl@0: iLocale.iExtraNegativeCurrencyFormatFlags=0; sl@0: sl@0: DoUpdateLanguageSettings(&data[0]); sl@0: DoUpdateLocaleSettings(&data[0]); sl@0: DoUpdateTimeDateFormat(&data[0]); sl@0: sl@0: iPreferredCharSet = (const LCharSet*)data[FnCharSet](); sl@0: iDefaultCharSet = iPreferredCharSet; sl@0: return r; sl@0: } sl@0: else if(r == KErrNotFound) sl@0: { sl@0: TInt lan = 0; sl@0: TInt reg = 0; sl@0: TInt col = 0; sl@0: TInt languageID = -1; sl@0: TInt err = CheckLocaleDllName(aLocaleDllName, languageID); sl@0: if (err != KErrNone) sl@0: return err; sl@0: sl@0: TInt i = 0; sl@0: while (i < KLocMapLength) //binary search later sl@0: { sl@0: if ((LocaleMapping[i].iOldLocaleId) == languageID) sl@0: { sl@0: lan = LocaleMapping[i].iNewLocaleID[0]; sl@0: reg = LocaleMapping[i].iNewLocaleID[1]; sl@0: col = LocaleMapping[i].iNewLocaleID[2]; sl@0: break; sl@0: } sl@0: i++; sl@0: } sl@0: if(i == KLocMapLength) sl@0: return KErrNotFound; sl@0: sl@0: TBuf<15> lanptr = KFindLan(); sl@0: TBuf<15> regptr = KFindReg(); sl@0: TBuf<15> colptr = KFindCol(); sl@0: AddExtension(lanptr, lan); sl@0: AddExtension(regptr, reg); sl@0: AddExtension(colptr, col); sl@0: err = LoadLocale(lanptr, regptr, colptr); sl@0: sl@0: return err; sl@0: } sl@0: return r; sl@0: #else sl@0: TLibraryFunction data[KNumLocaleExports]; sl@0: TInt r = DoLoadLocale(aLocaleDllName, &data[0]); sl@0: if(r == KErrNone) sl@0: { sl@0: iLocale.iExtraNegativeCurrencyFormatFlags=0x80000000; sl@0: iLocale.iLanguageDowngrade[0] = ELangNone; sl@0: iLocale.iLanguageDowngrade[1] = ELangNone; sl@0: iLocale.iLanguageDowngrade[2] = ELangNone; sl@0: iLocale.iDigitType = EDigitTypeWestern; sl@0: sl@0: typedef void (*TLibFn)(TLocale*); sl@0: ((TLibFn)data[FnLocaleData])(&iLocale); sl@0: sl@0: //Locale daylightsavings unchanged - we have travelled through space, not time sl@0: if (iLocale.iExtraNegativeCurrencyFormatFlags&0x80000000) sl@0: iLocale.iExtraNegativeCurrencyFormatFlags=0; sl@0: sl@0: DoUpdateLanguageSettings(&data[0]); sl@0: DoUpdateLocaleSettings(&data[0]); sl@0: DoUpdateTimeDateFormat(&data[0]); sl@0: sl@0: iPreferredCharSet = (const LCharSet*)data[FnCharSet](); sl@0: iDefaultCharSet = iPreferredCharSet; sl@0: } sl@0: return r; sl@0: #endif sl@0: } sl@0: sl@0: /** sl@0: Loads locale data from three locale dlls, which are language, region, and collation locale dlls sl@0: sl@0: It loads three locale DLLs and it initialises the contents of this TExtendedLocale sl@0: with the locale information stored in the DLLs. The locale information is only sl@0: stored in this TExtendedLocale. If you want to set the system wide settings with sl@0: the locale information in the DLL, you can call TExtendedLocale::SaveSystemSettings sl@0: after calling this function. sl@0: sl@0: @param aLanguageLocaleDllName The name of the language locale DLL to be loaded sl@0: @param aRegionLocaleDllName The name of the region locale DLL to be loaded sl@0: @param aCollationLocaleDllName The name of the collation locale DLL to be loaded sl@0: sl@0: @return KErrNone if successful, system wide error if not sl@0: sl@0: @see TExtendedLocale::SaveSystemSettings sl@0: */ sl@0: #ifdef SYMBIAN_DISTINCT_LOCALE_MODEL sl@0: EXPORT_C TInt TExtendedLocale::LoadLocale(const TDesC& aLanguageLocaleDllName, sl@0: const TDesC& aRegionLocaleDllName, sl@0: const TDesC& aCollationLocaleDllName) sl@0: { sl@0: sl@0: TInt err = LoadLocaleAspect(aLanguageLocaleDllName); sl@0: if(err != KErrNone) sl@0: return err; sl@0: sl@0: err = LoadLocaleAspect(aRegionLocaleDllName); sl@0: if(err != KErrNone) sl@0: return err; sl@0: sl@0: err = LoadLocaleAspect(aCollationLocaleDllName); sl@0: if(err != KErrNone) sl@0: return err; sl@0: sl@0: return err; sl@0: } sl@0: #else sl@0: EXPORT_C TInt TExtendedLocale::LoadLocale(const TDesC& /*aLanguageLocaleDllName*/, sl@0: const TDesC& /*aRegionLocaleDllName*/, sl@0: const TDesC& /*aCollationLocaleDllName*/) sl@0: { sl@0: return KErrNotSupported; sl@0: } sl@0: #endif sl@0: sl@0: /** sl@0: Loads a DLL and get some locale information sl@0: sl@0: It loads the specified locale DLL and depending on the aAspectGroup it overwrites sl@0: locale information in this TExtendedLocale with the locale information stored in the sl@0: DLL. aAspectGroup is a bitmap of TLocaleAspect values specifying what to be overwritten. sl@0: The locale information is only stored in this TExtendedLocale. If you want to set the sl@0: system wide settings with the locale information in the DLL, you can call sl@0: TExtendedLocale::SaveSystemSettings after calling this function. sl@0: sl@0: @param aAspectGroup A bitmap of TLocaleAspect values specifying what to be overwritten in sl@0: this TExtendedLocale. (eg.: ELocaleLanguageSettings | ELocaleTimeDateSettings) sl@0: @param aLocaleDllName The name of the locale DLL to be loaded sl@0: sl@0: @return KErrNone if the method is successful, a system wide error code if not sl@0: sl@0: @see TLocaleAspect sl@0: @see TExtendedLocale::SaveSystemSettings sl@0: */ sl@0: EXPORT_C TInt TExtendedLocale::LoadLocaleAspect(TUint aAspectGroup, const TDesC& aLocaleDllName) sl@0: { sl@0: #ifdef SYMBIAN_DISTINCT_LOCALE_MODEL sl@0: TLibraryFunction data[KNumLocaleExports]; sl@0: TInt r = DoLoadLocale(aLocaleDllName, &data[0]); sl@0: if(r == KErrNone) sl@0: { sl@0: if(aAspectGroup & ELocaleLanguageSettings) sl@0: { sl@0: DoUpdateLanguageSettings(&data[0]); sl@0: } sl@0: if(aAspectGroup & ELocaleCollateSetting) sl@0: { sl@0: iPreferredCharSet = (const LCharSet*)data[FnCharSet](); sl@0: iDefaultCharSet = iPreferredCharSet; sl@0: } sl@0: if(aAspectGroup & ELocaleLocaleSettings) sl@0: { sl@0: DoUpdateLocaleSettings(&data[0]); sl@0: } sl@0: if(aAspectGroup & ELocaleTimeDateSettings) sl@0: { sl@0: DoUpdateTimeDateFormat(&data[0]); sl@0: } sl@0: return r; sl@0: } sl@0: sl@0: else if (r == KErrNotFound) sl@0: { sl@0: TInt lan = 0; sl@0: TInt reg = 0; sl@0: TInt col = 0; sl@0: TInt languageID = -1; sl@0: TInt err = CheckLocaleDllName(aLocaleDllName, languageID); sl@0: if(err != KErrNone) sl@0: return err; sl@0: sl@0: TInt i = 0; sl@0: while (i < KLocMapLength) sl@0: { sl@0: if ((LocaleMapping[i].iOldLocaleId) == languageID) sl@0: { sl@0: lan = LocaleMapping[i].iNewLocaleID[0]; sl@0: reg = LocaleMapping[i].iNewLocaleID[1]; sl@0: col = LocaleMapping[i].iNewLocaleID[2]; sl@0: break; sl@0: } sl@0: i++; sl@0: } sl@0: if(i == KLocMapLength) sl@0: return KErrNotFound; sl@0: sl@0: TBuf<15> lanptr = KFindLan(); sl@0: TBuf<15> regptr = KFindReg(); sl@0: TBuf<15> colptr = KFindCol(); sl@0: AddExtension(lanptr, lan); sl@0: AddExtension(regptr, reg); sl@0: AddExtension(colptr, col); sl@0: sl@0: switch (aAspectGroup) sl@0: { sl@0: case ELocaleCollateSetting: sl@0: { sl@0: err = LoadLocaleAspect(colptr); sl@0: break; sl@0: } sl@0: case ELocaleLocaleSettings: sl@0: { sl@0: err = LoadLocaleAspect(regptr); sl@0: break; sl@0: } sl@0: sl@0: case ELocaleLanguageSettings: sl@0: { sl@0: err = LoadLocaleAspect(lanptr); sl@0: break; sl@0: } sl@0: } sl@0: return err; sl@0: } sl@0: sl@0: return r; sl@0: #else sl@0: TLibraryFunction data[KNumLocaleExports]; sl@0: TInt r = DoLoadLocale(aLocaleDllName, &data[0]); sl@0: if(r == KErrNone) sl@0: { sl@0: if(aAspectGroup & ELocaleLanguageSettings) sl@0: { sl@0: DoUpdateLanguageSettings(&data[0]); sl@0: } sl@0: if(aAspectGroup & ELocaleCollateSetting) sl@0: { sl@0: iPreferredCharSet = (const LCharSet*)data[FnCharSet](); sl@0: iDefaultCharSet = iPreferredCharSet; sl@0: } sl@0: if(aAspectGroup & ELocaleLocaleSettings) sl@0: { sl@0: DoUpdateLocaleSettings(&data[0]); sl@0: } sl@0: if(aAspectGroup & ELocaleTimeDateSettings) sl@0: { sl@0: DoUpdateTimeDateFormat(&data[0]); sl@0: } sl@0: } sl@0: return r; sl@0: #endif sl@0: } sl@0: sl@0: /** sl@0: Loads a DLL and get some locale information sl@0: sl@0: It loads the specified locale DLL, and it overwrites sl@0: locale information in this TExtendedLocale with the locale information stored in the sl@0: DLL. The locale information is only stored in this TExtendedLocale. If you want to set the sl@0: system wide settings with the locale information in the DLL, you can call sl@0: TExtendedLocale::SaveSystemSettings after calling this function. sl@0: sl@0: @param aLocaleDllName The name of the locale DLL to be loaded sl@0: sl@0: @return KErrNone if the method is successful, a system wide error code if not sl@0: sl@0: @see TExtendedLocale::SaveSystemSettings sl@0: */ sl@0: #ifdef SYMBIAN_DISTINCT_LOCALE_MODEL sl@0: EXPORT_C TInt TExtendedLocale::LoadLocaleAspect(const TDesC& aLocaleDllName) sl@0: { sl@0: TLibraryFunction data[KNumLocaleExports]; sl@0: sl@0: TInt result = aLocaleDllName.Find(KFindReg); sl@0: if(result != KErrNotFound) sl@0: { sl@0: result = DoLoadLocale(aLocaleDllName, &data[0]); sl@0: if(result == KErrNone) sl@0: { sl@0: DoUpdateLocaleSettingsV2(&data[0]); sl@0: return result; sl@0: } sl@0: } sl@0: sl@0: result= aLocaleDllName.Find(KFindLan); sl@0: if(result != KErrNotFound) sl@0: { sl@0: result = DoLoadLocale(aLocaleDllName, &data[0]); sl@0: if(result == KErrNone) sl@0: { sl@0: DoUpdateLanguageSettingsV2(&data[0]); sl@0: return result; sl@0: } sl@0: } sl@0: sl@0: result = aLocaleDllName.Find(KFindCol); sl@0: if(result != KErrNotFound) sl@0: { sl@0: result = DoLoadLocale(aLocaleDllName, &data[0]); sl@0: if(result == KErrNone) sl@0: { sl@0: iPreferredCharSet = (const LCharSet*)data[1](); sl@0: iDefaultCharSet = iPreferredCharSet; sl@0: return result; sl@0: } sl@0: } sl@0: sl@0: return KErrNotFound; sl@0: } sl@0: #else sl@0: EXPORT_C TInt TExtendedLocale::LoadLocaleAspect(const TDesC& /*aLocaleDllName*/) sl@0: { sl@0: return KErrNotSupported; sl@0: } sl@0: #endif sl@0: sl@0: /** sl@0: Sets the currency symbol sl@0: sl@0: It sets the currency symbol. The maximum lenght for the currency symbol is sl@0: KMaxCurrencySymbol. Trying to pass a descriptor longer than that, will result sl@0: in a panic. sl@0: sl@0: @param aSymbol The new currency symbol sl@0: sl@0: @panic USER 119, if the length of aSymbol is greater than KMaxCurrencySymbol. sl@0: sl@0: @capability WriteDeviceData sl@0: sl@0: @return KErrNone if successful, otherwise one of the other system wide error codes. sl@0: */ sl@0: EXPORT_C TInt TExtendedLocale::SetCurrencySymbol(const TDesC &aSymbol) sl@0: { sl@0: __ASSERT_ALWAYS(aSymbol.Length()<=KMaxCurrencySymbol,::Panic(ECurrencySymbolOverflow)); sl@0: sl@0: LocaleSettingsGet(iLocaleExtraSettings); sl@0: Mem::Copy(&iLocaleExtraSettings.iCurrencySymbol[0], aSymbol.Ptr(), aSymbol.Length()*sizeof(TText) ); sl@0: iLocaleExtraSettings.iCurrencySymbol[aSymbol.Length()] = 0; sl@0: TInt r = RProperty::Set(KUidSystemCategory, KLocaleDataExtraKey, TPckg(iLocaleExtraSettings)); sl@0: return r; sl@0: } sl@0: sl@0: /** sl@0: Returns the name of the DLL containing the given bits of locale information sl@0: sl@0: Given the bits of locale information specified in aLocaleDataSet, it returns the name sl@0: of the locale DLL storing the information. TExtendedLocale can contain information from sl@0: different DLLs. sl@0: sl@0: @param aLocaleDataSet The TLocaleAspect specifying a group of locale properties sl@0: @param aDllName The descriptor that will contain the name of DLL containing the specifying sl@0: bits of locale information (valid if the method is successful) sl@0: sl@0: @return KErrNone if successful, system wide error otherwise sl@0: */ sl@0: EXPORT_C TInt TExtendedLocale::GetLocaleDllName(TLocaleAspect aLocaleDataSet, TDes& aDllName) sl@0: { sl@0: TBuf8 buf; sl@0: TAny* ptr = 0; sl@0: switch(aLocaleDataSet) sl@0: { sl@0: case ELocaleLanguageSettings: sl@0: ptr = (TAny*)iLanguageSettings.iDateSuffixTable; sl@0: break; sl@0: case ELocaleCollateSetting: sl@0: ptr = (TAny*)iPreferredCharSet; sl@0: break; sl@0: case ELocaleLocaleSettings: sl@0: ptr = (TAny*)iLocaleExtraSettings.iLocaleExtraSettingsDllPtr; sl@0: break; sl@0: case ELocaleTimeDateSettings: sl@0: ptr = (TAny*)iLocaleTimeDateFormat.iLocaleTimeDateFormatDllPtr; sl@0: break; sl@0: } sl@0: TInt r = Exec::GetModuleNameFromAddress(ptr, buf); sl@0: if (r == KErrNone) sl@0: { sl@0: aDllName.Copy(buf); sl@0: } sl@0: return r; sl@0: } sl@0: sl@0: /** sl@0: Get the Currency Symbol from SLocaleLocaleSettings object sl@0: sl@0: @return TPtrC Pointer holding the Currency Symbol sl@0: */ sl@0: EXPORT_C TPtrC TExtendedLocale::GetCurrencySymbol() sl@0: { sl@0: TPtrC outCurrencySymbolPtr(iLocaleExtraSettings.iCurrencySymbol); sl@0: return outCurrencySymbolPtr; sl@0: } sl@0: sl@0: /** sl@0: Get the Long Date Format from SLocaleTimeDateFormat object sl@0: sl@0: @return TPtrC Pointer holding the Long Date Format sl@0: */ sl@0: EXPORT_C TPtrC TExtendedLocale::GetLongDateFormatSpec() sl@0: { sl@0: TPtrC outLongDateFormatPtr(iLocaleTimeDateFormat.iLongDateFormatSpec); sl@0: return outLongDateFormatPtr; sl@0: } sl@0: sl@0: /** sl@0: Get the Short Date Format from SLocaleTimeDateFormat object sl@0: sl@0: @return TPtrC Pointer holding the Short Date Format sl@0: */ sl@0: EXPORT_C TPtrC TExtendedLocale::GetShortDateFormatSpec() sl@0: { sl@0: TPtrC outShortDateFormatPtr(iLocaleTimeDateFormat.iShortDateFormatSpec); sl@0: return outShortDateFormatPtr; sl@0: } sl@0: sl@0: /** sl@0: Get the Time Format from SLocaleTimeDateFormat object sl@0: sl@0: @return TPtrC Pointer holding the Time Format sl@0: */ sl@0: EXPORT_C TPtrC TExtendedLocale::GetTimeFormatSpec() sl@0: { sl@0: TPtrC outTimeFormatPtr(iLocaleTimeDateFormat.iTimeFormatSpec); sl@0: return outTimeFormatPtr; sl@0: } sl@0: sl@0: EXPORT_C TInt UserSvr::LocalePropertiesSetDefaults() sl@0: { sl@0: _LIT_SECURITY_POLICY_C1(KLocaleWritePolicy,ECapabilityWriteDeviceData); sl@0: _LIT_SECURITY_POLICY_PASS(KLocaleReadPolicy); sl@0: sl@0: TInt r = RProperty::Define(KUidSystemCategory, KLocaleLanguageKey, RProperty::EByteArray, KLocaleReadPolicy, KLocaleWritePolicy, sizeof(TPckg)); sl@0: if(r != KErrNone && r != KErrAlreadyExists) sl@0: return r; sl@0: sl@0: SLocaleLanguage localeLanguage; sl@0: localeLanguage.iLanguage = ELangEnglish; sl@0: localeLanguage.iDateSuffixTable = (const TText16*)__DefaultDateSuffixTable; sl@0: localeLanguage.iDayTable = (const TText16*)__DefaultDayTable; sl@0: localeLanguage.iDayAbbTable = (const TText16*)__DefaultDayAbbTable; sl@0: localeLanguage.iMonthTable = (const TText16*)__DefaultMonthTable; sl@0: localeLanguage.iMonthAbbTable = (const TText16*)__DefaultMonthAbbTable; sl@0: localeLanguage.iAmPmTable = (const TText16*)__DefaultAmPmTable; sl@0: localeLanguage.iMsgTable = (const TText16* const*)__DefaultLMsgTable; sl@0: r = RProperty::Set(KUidSystemCategory, KLocaleLanguageKey, TPckg(localeLanguage)); sl@0: if(r != KErrNone) sl@0: return r; sl@0: sl@0: r = RProperty::Define(KUidSystemCategory, KLocaleDataKey, RProperty::EByteArray, KLocaleReadPolicy, KLocaleWritePolicy, sizeof(TPckg)); sl@0: if(r != KErrNone && r != KErrAlreadyExists) sl@0: return r; sl@0: sl@0: TLocale locale(0); sl@0: locale.SetDefaults(); sl@0: sl@0: r = RProperty::Set(KUidSystemCategory, KLocaleDataKey, TPckg(locale)); sl@0: if(r != KErrNone) sl@0: return r; sl@0: sl@0: r = RProperty::Define(KUidSystemCategory, KLocaleDataExtraKey, RProperty::EByteArray, KLocaleReadPolicy, KLocaleWritePolicy, sizeof(TPckg)); sl@0: if(r != KErrNone && r != KErrAlreadyExists) sl@0: return r; sl@0: sl@0: SLocaleLocaleSettings localeSettings; sl@0: Mem::Copy(&localeSettings.iCurrencySymbol[0], _S16("\x00a3"), sizeof(TText16) * 2); sl@0: sl@0: r = RProperty::Set(KUidSystemCategory, KLocaleDataExtraKey, TPckg(localeSettings)); sl@0: if(r != KErrNone) sl@0: return r; sl@0: sl@0: r = RProperty::Define(KUidSystemCategory, KLocaleTimeDateFormatKey, RProperty::EByteArray, KLocaleReadPolicy, KLocaleWritePolicy, sizeof(TPckg)); sl@0: if(r != KErrNone && r != KErrAlreadyExists) sl@0: return r; sl@0: sl@0: SLocaleTimeDateFormat localeTimeDateFormat; sl@0: Mem::Copy(&localeTimeDateFormat.iShortDateFormatSpec[0], _S16("%F%*D/%*M/%Y"), sizeof(TText16) * 13); sl@0: Mem::Copy(&localeTimeDateFormat.iLongDateFormatSpec[0], _S16("%F%*D%X %N %Y"), sizeof(TText16) * 14); sl@0: Mem::Copy(&localeTimeDateFormat.iTimeFormatSpec[0], _S16("%F%*I:%T:%S %*A"), sizeof(TText16) * 16); sl@0: sl@0: r = RProperty::Set(KUidSystemCategory, KLocaleTimeDateFormatKey, TPckg(localeTimeDateFormat)); sl@0: if(r != KErrNone) sl@0: return r; sl@0: sl@0: TInt charSet = (TInt)GetLocaleDefaultCharSet(); sl@0: r = Exec::SetGlobalUserData(ELocaleDefaultCharSet, charSet); sl@0: if(r != KErrNone) sl@0: return r; sl@0: sl@0: r = Exec::SetGlobalUserData(ELocalePreferredCharSet, charSet); sl@0: sl@0: return r; sl@0: } sl@0: sl@0: sl@0: // TOverflowHandler class created to handle the descriptor overflow in TLoacle::FormatCurrency sl@0: NONSHARABLE_CLASS(TOverflowHandler) : public TDesOverflow sl@0: { sl@0: void Overflow(TDes& aDes); sl@0: }; sl@0: sl@0: void TOverflowHandler::Overflow(TDes&) sl@0: { sl@0: Panic(ETDes16Overflow); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C void TLocale::FormatCurrency(TDes& aText, TInt aAmount) sl@0: /** sl@0: Renders a currency value as text, based on the locale's currency and numeric sl@0: format settings. sl@0: sl@0: These settings include the currency symbol, the symbol's position and the sl@0: way negative values are formatted. sl@0: sl@0: @param aText On return, contains the currency value as text, formatted sl@0: according to the locale's currency format settings. sl@0: @param aAmount The currency value to be formatted. sl@0: sl@0: @panic USER 11, if aText is not long enough to hold the formatted value. sl@0: */ sl@0: { sl@0: TOverflowHandler overflowHandler; sl@0: FormatCurrency(aText,overflowHandler,aAmount); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C void TLocale::FormatCurrency(TDes& aText, TInt64 aAmount) sl@0: /** sl@0: Renders a currency value as text, based on the locale's currency and numeric sl@0: format settings. sl@0: sl@0: These settings include the currency symbol, the symbol's position and the sl@0: way negative values are formatted. sl@0: sl@0: @param aText On return, contains the currency value as text, formatted sl@0: according to the locale's currency format settings. sl@0: @param aAmount The currency value to be formatted. sl@0: sl@0: @panic USER 11, if aText is not long enough to hold the formatted value. sl@0: */ sl@0: { sl@0: TOverflowHandler overflowHandler; sl@0: FormatCurrency(aText,overflowHandler, aAmount); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C void TLocale::FormatCurrency(TDes& aText, TDesOverflow& aOverflowHandler, TInt aAmount) sl@0: /** sl@0: Renders a currency value as text, based on the locale's currency and numeric sl@0: format settings. sl@0: sl@0: These settings include the currency symbol, the symbol's position and the sl@0: way negative values are formatted. If aText is not long enough to hold the sl@0: formatted currency value, the overflow handler's Overflow() function is called. sl@0: sl@0: @param aText On return, contains the currency value as text, sl@0: formatted according to the locale's currency format sl@0: settings. sl@0: @param aOverflowHandler An object derived from TDesOverflow which handles sl@0: descriptor overflows. sl@0: @param aAmount The currency value to be formatted. sl@0: */ sl@0: { sl@0: TInt64 aLongerInt(aAmount); sl@0: FormatCurrency(aText, aOverflowHandler, aLongerInt); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C void TLocale::FormatCurrency(TDes& aText, TDesOverflow& aOverflowHandler, TInt64 aAmount) sl@0: /** sl@0: Renders a currency value as text, based on the locale's currency and numeric sl@0: format settings. sl@0: sl@0: These settings include the currency symbol, the symbol's position and the sl@0: way negative values are formatted. If aText is not long enough to hold the sl@0: formatted currency value, the overflow handler's Overflow() function is called. sl@0: sl@0: @param aText On return, contains the currency value as text, sl@0: formatted according to the locale's currency format sl@0: settings. sl@0: @param aOverflowHandler An object derived from TDesOverflow which handles sl@0: descriptor overflows. sl@0: @param aAmount The currency value to be formatted. sl@0: */ sl@0: { sl@0: // aAmount is in cents (or equivalent) rather than dollars (or equivalent) sl@0: const TBool amountIsNegative=(aAmount<0); sl@0: if (amountIsNegative) sl@0: { sl@0: aAmount=-aAmount; sl@0: } sl@0: aText.Num(aAmount, EDecimal); sl@0: const TInt currencyDecimalPlaces=CurrencyDecimalPlaces(); sl@0: TInt positionOfDecimalSeparator=aText.Length(); sl@0: if (currencyDecimalPlaces>0) sl@0: { sl@0: while (positionOfDecimalSeparator <= currencyDecimalPlaces) sl@0: { sl@0: if (aText.Length() == aText.MaxLength()) sl@0: { sl@0: aOverflowHandler.Overflow(aText); sl@0: return; sl@0: } sl@0: aText.Insert(0,KLitZeroPad); sl@0: ++positionOfDecimalSeparator; sl@0: } sl@0: positionOfDecimalSeparator=aText.Length(); sl@0: positionOfDecimalSeparator-=currencyDecimalPlaces; sl@0: TBuf<1> decimalSeparator; sl@0: decimalSeparator.Append(DecimalSeparator()); sl@0: if (aText.Length() == aText.MaxLength()) sl@0: { sl@0: aOverflowHandler.Overflow(aText); sl@0: return; sl@0: } sl@0: aText.Insert(positionOfDecimalSeparator, decimalSeparator); sl@0: } sl@0: if (CurrencyTriadsAllowed()) sl@0: { sl@0: TBuf<1> thousandsSeparator; sl@0: thousandsSeparator.Append(ThousandsSeparator()); sl@0: TInt numberOfThousandsSeparator = positionOfDecimalSeparator/3; sl@0: if ((aText.Length()+numberOfThousandsSeparator) > aText.MaxLength()) sl@0: { sl@0: aOverflowHandler.Overflow(aText); sl@0: return; sl@0: } sl@0: for (TInt i=positionOfDecimalSeparator-3; i>0; i-=3) sl@0: { sl@0: aText.Insert(i, thousandsSeparator); sl@0: } sl@0: } sl@0: TInt positionToInsertCurrencySymbol = 0; sl@0: switch (CurrencySymbolPosition()) sl@0: { sl@0: case ELocaleBefore: sl@0: { sl@0: if ((amountIsNegative) && (NegativeCurrencySymbolOpposite())) sl@0: { sl@0: positionToInsertCurrencySymbol=aText.Length(); sl@0: } sl@0: else sl@0: positionToInsertCurrencySymbol=0; sl@0: } sl@0: break; sl@0: case ELocaleAfter: sl@0: { sl@0: if ((amountIsNegative) && (NegativeCurrencySymbolOpposite())) sl@0: { sl@0: positionToInsertCurrencySymbol=0; sl@0: } sl@0: else sl@0: positionToInsertCurrencySymbol=aText.Length(); sl@0: } sl@0: break; sl@0: default: sl@0: Panic(ETRegionOutOfRange); sl@0: break; sl@0: } sl@0: if (CurrencySpaceBetween()) sl@0: { sl@0: if (aText.Length() == aText.MaxLength()) sl@0: { sl@0: aOverflowHandler.Overflow(aText); sl@0: return; sl@0: } sl@0: if ((amountIsNegative) && (NegativeLoseSpace())) sl@0: { sl@0: // don't add the space sl@0: } sl@0: else sl@0: { sl@0: aText.Insert(positionToInsertCurrencySymbol, KLitSpace); sl@0: if (positionToInsertCurrencySymbol>0) sl@0: { sl@0: ++positionToInsertCurrencySymbol; sl@0: } sl@0: } sl@0: } sl@0: TCurrencySymbol theCurrencySymbol; sl@0: if ((aText.Length()+theCurrencySymbol.Length()) > aText.MaxLength()) sl@0: { sl@0: aOverflowHandler.Overflow(aText); sl@0: return; sl@0: } sl@0: aText.Insert(positionToInsertCurrencySymbol,theCurrencySymbol); sl@0: if (amountIsNegative) sl@0: { sl@0: TInt positionToInsertInterveningMinusSign = 0; sl@0: if ((CurrencySpaceBetween()) && !(NegativeLoseSpace())) sl@0: { sl@0: if (positionToInsertCurrencySymbol>0) sl@0: { sl@0: positionToInsertInterveningMinusSign = positionToInsertCurrencySymbol-1; sl@0: } sl@0: else sl@0: { sl@0: positionToInsertInterveningMinusSign = theCurrencySymbol.Length()+1; sl@0: } sl@0: } sl@0: else sl@0: { sl@0: if (positionToInsertCurrencySymbol>0) sl@0: { sl@0: positionToInsertInterveningMinusSign = positionToInsertCurrencySymbol; sl@0: } sl@0: else sl@0: { sl@0: positionToInsertInterveningMinusSign = theCurrencySymbol.Length(); sl@0: } sl@0: } sl@0: switch (NegativeCurrencyFormat()) sl@0: { sl@0: case EInBrackets: sl@0: { sl@0: if ((aText.Length()+2) > aText.MaxLength()) sl@0: { sl@0: aOverflowHandler.Overflow(aText); sl@0: return; sl@0: } sl@0: aText.Insert(0, KLitOpeningBracket); sl@0: aText.Append(')'); sl@0: } sl@0: break; sl@0: case ELeadingMinusSign: sl@0: { sl@0: if (aText.Length() == aText.MaxLength()) sl@0: { sl@0: aOverflowHandler.Overflow(aText); sl@0: return; sl@0: } sl@0: aText.Insert(0, KLitMinusSign); sl@0: } sl@0: break; sl@0: case ETrailingMinusSign: sl@0: { sl@0: if (aText.Length() == aText.MaxLength()) sl@0: { sl@0: aOverflowHandler.Overflow(aText); sl@0: return; sl@0: } sl@0: aText.Append(KLitMinusSign); sl@0: } sl@0: break; sl@0: case EInterveningMinusSign: sl@0: { sl@0: if (aText.Length() == aText.MaxLength()) sl@0: { sl@0: aOverflowHandler.Overflow(aText); sl@0: return; sl@0: } sl@0: aText.Insert(positionToInsertInterveningMinusSign, KLitMinusSign); sl@0: } sl@0: break; sl@0: default: sl@0: Panic(ETRegionOutOfRange); sl@0: break; sl@0: } sl@0: } sl@0: } sl@0: sl@0: sl@0: EXPORT_C void TLocaleMessageText::Set(TLocaleMessage aMsgNo) sl@0: // sl@0: // Get some text from Locale sl@0: // sl@0: { sl@0: if(TUint(aMsgNo) < ELocaleMessages_LastMsg) sl@0: { sl@0: SLocaleLanguage localeLanguage; sl@0: LocaleLanguageGet(localeLanguage); sl@0: Copy((reinterpret_cast(localeLanguage.iMsgTable))[aMsgNo]); sl@0: } sl@0: else sl@0: SetLength(0); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TInt TFindServer::Next(TFullName &aResult) sl@0: /** sl@0: Gets the full name of the next server which matches the match pattern. sl@0: sl@0: @param aResult A reference to a descriptor with a defined maximum length. sl@0: If a matching server is found, its full name is set into sl@0: this descriptor. If no matching server is found, sl@0: the descriptor length is set to zero. sl@0: sl@0: @return KErrNone if a matching server is found, KErrNotFound otherwise. sl@0: */ sl@0: { sl@0: return NextObject(aResult,EServer); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C void RServer2::Receive(RMessage2& aMessage, TRequestStatus &aStatus) sl@0: // sl@0: // Receive a message from the server asynchronously. sl@0: // sl@0: { sl@0: sl@0: aStatus=KRequestPending; sl@0: Exec::ServerReceive(iHandle, aStatus, &aMessage); sl@0: } sl@0: sl@0: EXPORT_C void RServer2::Cancel() sl@0: // sl@0: // Cancel a pending message receive. sl@0: // sl@0: { sl@0: sl@0: Exec::ServerCancel(iHandle); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TInt TFindMutex::Next(TFullName &aResult) sl@0: /** sl@0: Finds the next global mutex whose full name matches the match pattern. sl@0: sl@0: If a global mutex with a matching name is found, the function copies its full sl@0: name into the specified descriptor. It also saves the find-handle associated sl@0: with the global mutex into the TFindHandleBase part of this object. sl@0: sl@0: @param aResult A reference to a descriptor with a defined maximum length. sl@0: If a matching global mutex is found, its full name is set sl@0: into this descriptor. sl@0: If no matching global mutex is found, the descriptor length sl@0: is set to zero. sl@0: sl@0: @return KErrNone if a matching global mutex is found; sl@0: KErrNotFound otherwise. sl@0: */ sl@0: { sl@0: return NextObject(aResult,EMutex); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Acquire the mutex, waiting for it to become free if necessary. sl@0: sl@0: This function checks if the mutex is currently held. If not the mutex is marked sl@0: as held by the current thread and the call returns immediately. If the mutex is sl@0: held by another thread the current thread will suspend until the mutex becomes sl@0: free. If the mutex is already held by the current thread a count is maintained sl@0: of how many times the thread has acquired the mutex. sl@0: */ sl@0: EXPORT_C void RMutex::Wait() sl@0: { sl@0: sl@0: Exec::MutexWait(iHandle); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Release the mutex. sl@0: sl@0: This function decrements the count of how many times the current thread has sl@0: acquired this mutex. If the count is now zero the mutex is marked as free and, sl@0: if any other threads are waiting for the mutex to become free, the highest sl@0: priority among those is made ready to run. However the mutex is not marked as sl@0: held by any thread - the thread which has just been awakened must actually run sl@0: in order to acquire the mutex. sl@0: sl@0: @pre The mutex must previously have been acquired by the current thread calling sl@0: Wait(). sl@0: sl@0: @panic KERN-EXEC 1 If the mutex has not previously been acquired by the current sl@0: thread calling Wait(). sl@0: */ sl@0: EXPORT_C void RMutex::Signal() sl@0: { sl@0: sl@0: Exec::MutexSignal(iHandle); sl@0: } sl@0: sl@0: sl@0: sl@0: /** sl@0: Test if this mutex is held by the current thread. sl@0: @return True if the current thread has waited on the mutex, false otherwise. sl@0: */ sl@0: EXPORT_C TBool RMutex::IsHeld() sl@0: { sl@0: return Exec::MutexIsHeld(iHandle); sl@0: } sl@0: sl@0: sl@0: /** Wait on a condition variable sl@0: sl@0: This call releases the specified mutex then atomically blocks the current sl@0: thread on this condition variable. The atomicity here is with respect to the sl@0: condition variable and mutex concerned. Specifically if the condition variable sl@0: is signalled at any time after the mutex is released then this thread will be sl@0: awakened. Once the thread has awakened it will reacquire the specified mutex sl@0: before this call returns (except in the case where the condition variable has sl@0: been deleted). sl@0: sl@0: The usage pattern for this is as follows: sl@0: sl@0: @code sl@0: mutex.Wait(); sl@0: while(!CONDITION) sl@0: condvar.Wait(mutex); sl@0: STATEMENTS; sl@0: mutex.Signal(); sl@0: @endcode sl@0: sl@0: where CONDITION is an arbitrary condition involving any number of user-side sl@0: variables whose integrity is protected by the mutex. sl@0: sl@0: It is necessary to loop while testing the condition because there is **no** guarantee sl@0: that the condition has been satisfied when the condition variable is signalled. sl@0: Different threads may be waiting on different conditions or the condition may sl@0: have already been absorbed by another thread. All that can be said is that the sl@0: thread will awaken whenever something happens which **might** affect the condition. sl@0: sl@0: It needs to be stressed that if: sl@0: sl@0: @code sl@0: condvar.Wait(mutex); sl@0: @endcode sl@0: sl@0: completes, it does not necessarily mean that the condition is yet satisfied, hence the necessity for the loop. sl@0: sl@0: @param aMutex The mutex to be released and reacquired. sl@0: @return KErrNone if the condition variable has been signalled. sl@0: KErrInUse if another thread is already waiting on this condition sl@0: variable in conjunction with a different mutex. sl@0: KErrGeneral if the condition variable is deleted. sl@0: sl@0: @pre The specified mutex is held by the current thread. sl@0: @post The specified mutex is held by the current thread unless the return sl@0: value is KErrGeneral in which case the condition variable no longer sl@0: exists. sl@0: sl@0: @panic KERN-EXEC 0 if either the condition variable or mutex handles are not sl@0: valid. sl@0: @panic KERN-EXEC 54 if the current thread does not hold the specified mutex. sl@0: sl@0: @see RCondVar::Signal() sl@0: @see RCondVar::Broadcast() sl@0: */ sl@0: EXPORT_C TInt RCondVar::Wait(RMutex& aMutex) sl@0: { sl@0: return Exec::CondVarWait(iHandle, aMutex.Handle(), 0); sl@0: } sl@0: sl@0: sl@0: sl@0: /** Wait on a condition variable with timeout sl@0: sl@0: This is the same as RCondVar::Wait(RMutex) except that there is a time limit on sl@0: how long the current thread will block while waiting for the condition variable. sl@0: sl@0: @param aMutex The mutex to be released and reacquired. sl@0: @param aTimeout The maximum time to wait in microseconds. sl@0: 0 means no maximum. sl@0: @return KErrNone if the condition variable has been signalled. sl@0: KErrInUse if another thread is already waiting on this condition sl@0: variable in conjunction with a different mutex. sl@0: KErrGeneral if the condition variable is deleted. sl@0: KErrTimedOut if the timeout expired before the condition variable was sl@0: signalled. sl@0: sl@0: @pre The specified mutex is held by the current thread. sl@0: @post The specified mutex is held by the current thread unless the return sl@0: value is KErrGeneral in which case the condition variable no longer sl@0: exists. sl@0: sl@0: @panic KERN-EXEC 0 if either the condition variable or mutex handles are not sl@0: valid. sl@0: @panic KERN-EXEC 54 if the current thread does not hold the specified mutex. sl@0: sl@0: @see RCondVar::Wait(RMutex) sl@0: */ sl@0: EXPORT_C TInt RCondVar::TimedWait(RMutex& aMutex, TInt aTimeout) sl@0: { sl@0: return Exec::CondVarWait(iHandle, aMutex.Handle(), aTimeout); sl@0: } sl@0: sl@0: sl@0: /** Signal a condition variable sl@0: sl@0: This unblocks a single thread which is currently blocked on the condition sl@0: variable. The highest priority waiting thread which is not explicitly suspended sl@0: will be the one unblocked. If there are no threads currently waiting this call sl@0: does nothing. sl@0: sl@0: It is not required that any mutex is held when calling this function but it is sl@0: recommended that the mutex associated with the condition variable is held since sl@0: otherwise a race condition can result from the condition variable being signalled sl@0: just after the waiting thread testing the condition and before it calls Wait(). sl@0: sl@0: */ sl@0: EXPORT_C void RCondVar::Signal() sl@0: { sl@0: Exec::CondVarSignal(iHandle); sl@0: } sl@0: sl@0: sl@0: sl@0: /** Broadcast to a condition variable sl@0: sl@0: This unblocks all threads which are currently blocked on the condition sl@0: variable. If there are no threads currently waiting this call does nothing. sl@0: sl@0: It is not required that any mutex is held when calling this function but it is sl@0: recommended that the mutex associated with the condition variable is held since sl@0: otherwise a race condition can result from the condition variable being signalled sl@0: just after the waiting thread testing the condition and before it calls Wait(). sl@0: sl@0: */ sl@0: EXPORT_C void RCondVar::Broadcast() sl@0: { sl@0: Exec::CondVarBroadcast(iHandle); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TInt TFindProcess::Next(TFullName &aResult) sl@0: /** sl@0: Gets the full name of the next process which matches the match pattern. sl@0: sl@0: @param aResult A reference to a TBuf descriptor with a defined maximum length. sl@0: If a matching process is found, its full name is set into sl@0: this descriptor. If no matching process is found, the descriptor sl@0: length is set to zero. sl@0: sl@0: @return KErrNone if successful, otherwise one of the other system-wide error sl@0: codes. sl@0: */ sl@0: { sl@0: return NextObject(aResult,EProcess); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TUidType RProcess::Type() const sl@0: /** sl@0: Gets the Uid type associated with the process. sl@0: sl@0: @return A reference to a TUidType object containing the process type. sl@0: */ sl@0: { sl@0: sl@0: TUidType u; sl@0: Exec::ProcessType(iHandle,u); sl@0: return(u); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TProcessId RProcess::Id() const sl@0: /** sl@0: Gets the Id of this process. sl@0: sl@0: @return The Id of this process. sl@0: */ sl@0: { sl@0: sl@0: return TProcessId( (TUint)Exec::ProcessId(iHandle) ); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C void RProcess::Resume() sl@0: /** sl@0: Makes the first thread in the process eligible for execution. sl@0: sl@0: @panic KERN-EXEC 32 if the process is not yet fully loaded. sl@0: sl@0: @see RThread::Resume() sl@0: */ sl@0: { sl@0: sl@0: Exec::ProcessResume(iHandle); sl@0: } sl@0: sl@0: sl@0: sl@0: EXPORT_C TFileName RProcess::FileName() const sl@0: /** sl@0: Gets a copy of the full path name of the loaded executable on which this sl@0: process is based. sl@0: sl@0: This is the file name which is passed to the Create() member function of this sl@0: RProcess. sl@0: sl@0: @return A TBuf descriptor with a defined maximum length containing the full sl@0: path name of the file. sl@0: sl@0: @see RProcess::Create() sl@0: */ sl@0: { sl@0: sl@0: TFileName n; sl@0: TPtr8 n8(((TUint8*)n.Ptr()) + KMaxFileName, KMaxFileName); sl@0: Exec::ProcessFileName(iHandle,n8); sl@0: n.Copy(n8); sl@0: return(n); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C void User::CommandLine(TDes &aCommand) sl@0: /** sl@0: Gets a copy of the data which is passed as an argument to the thread function sl@0: of the current process's main thread when it is first scheduled to run. sl@0: sl@0: @param aCommand A modifiable descriptor supplied by the caller into which the sl@0: argument data is put. The descriptor must be big enough to sl@0: contain the expected data, otherwise the function raises sl@0: a panic. sl@0: sl@0: @see User::CommandLineLength() sl@0: */ sl@0: { sl@0: TPtr8 aCommand8((TUint8*)aCommand.Ptr(),aCommand.MaxLength()<<1); sl@0: Exec::ProcessCommandLine(KCurrentProcessHandle,aCommand8); sl@0: aCommand.SetLength(aCommand8.Length()>>1); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TInt User::CommandLineLength() sl@0: /** sl@0: Gets the length of the data which is passed as an argument to the thread sl@0: function of the current process's main thread when it is first scheduled sl@0: to run. sl@0: sl@0: @return The length of the argument data. sl@0: */ sl@0: { sl@0: return Exec::ProcessCommandLineLength(KCurrentProcessHandle); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TExitType RProcess::ExitType() const sl@0: /** sl@0: Tests whether the process has ended and, if it has ended, return how it ended. sl@0: sl@0: This information allows the caller to distinguish between normal termination sl@0: and a panic. sl@0: sl@0: @return An enumeration whose enumerators describe how the process has ended. sl@0: */ sl@0: { sl@0: sl@0: return(Exec::ProcessExitType(iHandle)); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TInt RProcess::ExitReason() const sl@0: /** sl@0: Gets the specific reason associated with the end of this process. sl@0: sl@0: The reason number together with the category name is a way of distinguishing sl@0: between different causes of process termination. sl@0: sl@0: If the process has panicked, this value is the panic number. If the process sl@0: has ended as a result of a call to Kill(), then the value is the one supplied sl@0: by Kill(). sl@0: sl@0: If the process has not ended, then the returned value is zero. sl@0: sl@0: @return The reason associated with the end of the process. sl@0: sl@0: @see RProcess::Kill() sl@0: */ sl@0: { sl@0: sl@0: return(Exec::ProcessExitReason(iHandle)); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TExitCategoryName RProcess::ExitCategory() const sl@0: /** sl@0: Gets the name of the category associated with the end of the process. sl@0: sl@0: The category name together with the reason number is a way of distinguishing sl@0: between different causes of process termination. sl@0: sl@0: If the process has panicked, the category name is the panic category name; sl@0: for example, E32USER-CBase or KERN-EXEC. If the process has ended as a result sl@0: of a call to Kill(), then the category name is Kill. sl@0: sl@0: If the process has not ended, then the category name is empty, i.e. the length sl@0: of the category name is zero. sl@0: sl@0: @return A descriptor with a defined maximum length containing the sl@0: name of the category associated with the end of the process. sl@0: sl@0: @see RProcess::Kill() sl@0: */ sl@0: { sl@0: sl@0: TExitCategoryName n; sl@0: TPtr8 n8(((TUint8*)n.Ptr()) + KMaxExitCategoryName, KMaxExitCategoryName); sl@0: Exec::ProcessExitCategory(iHandle,n8); sl@0: n.Copy(n8); sl@0: return(n); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TProcessPriority RProcess::Priority() const sl@0: /** sl@0: Gets the priority of this process. sl@0: sl@0: @return One of the TProcessPriority enumerator values. sl@0: */ sl@0: { sl@0: sl@0: return(Exec::ProcessPriority(iHandle)); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TInt RProcess::SetPriority(TProcessPriority aPriority) const sl@0: /** sl@0: Sets the priority of this process to one of the values defined by theTProcessPriority sl@0: enumeration. The priority can be set to one of the four values: sl@0: sl@0: EPriorityLow sl@0: sl@0: EPriorityBackground sl@0: sl@0: EPriorityForeground sl@0: sl@0: EPriorityHigh sl@0: sl@0: The absolute priority of all threads owned by the process (and all threads sl@0: owned by those threads etc.) are re-calculated. sl@0: sl@0: Notes: sl@0: sl@0: The priority values EPriorityWindowServer, EPriorityFileServer, EPriorityRealTimeServer sl@0: and EPrioritySupervisor are internal to Symbian OS and any attempt to explicitly sl@0: set any of these priority values causes a KERN-EXEC 14 panic to be raised. sl@0: sl@0: Any attempt to set the priority of a process which is protected and is different sl@0: from the process owning the thread which invokes this function, causes a KERN-EXEC sl@0: 1 panic to be raised. sl@0: sl@0: A process can set its own priority whether it is protected or not. sl@0: sl@0: @param aPriority The priority value. sl@0: sl@0: @return KErrNone, if successful; otherwise one of the other system-wide sl@0: error codes. sl@0: sl@0: */ sl@0: { sl@0: sl@0: return Exec::ProcessSetPriority(iHandle,aPriority); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Tests whether "Just In Time" debugging is enabled or not for this process. sl@0: sl@0: @return True, when "Just In Time" debugging is enabled. False otherwise. sl@0: @see RProcess::SetJustInTime sl@0: */ sl@0: sl@0: EXPORT_C TBool RProcess::JustInTime() const sl@0: { sl@0: sl@0: return (Exec::ProcessFlags(iHandle) & KProcessFlagJustInTime) != 0; sl@0: } sl@0: sl@0: sl@0: /** sl@0: Enables or disables "Just In Time" debugging for this process. sl@0: This will only have an effect when running on the emulator. sl@0: sl@0: "Just In Time" debugging catches a thread just before it executes a panic sl@0: or exception routine. Capturing a thread early, before it is terminated, sl@0: allows the developer to more closely inspect what went wrong, before the sl@0: kernel removes the thread. In some cases, the developer can modify context, sl@0: program counter, and variables to recover the thread. This is only possible sl@0: on the emulator. sl@0: sl@0: By default, "Just In Time" debugging is enabled. sl@0: sl@0: @param aBoolean ETrue, to enable just-in-time debugging. sl@0: EFalse, to disable just-in-time debugging. sl@0: */ sl@0: EXPORT_C void RProcess::SetJustInTime(TBool aState) const sl@0: { sl@0: sl@0: TUint32 set = aState ? KProcessFlagJustInTime : 0; sl@0: Exec::ProcessSetFlags(iHandle, KProcessFlagJustInTime, set); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TInt RProcess::SecureApi(TInt /*aState*/) sl@0: { sl@0: return ESecureApiOn; sl@0: } sl@0: sl@0: EXPORT_C TInt RProcess::DataCaging(TInt /*aState*/) sl@0: { sl@0: return EDataCagingOn; sl@0: } sl@0: sl@0: sl@0: sl@0: EXPORT_C TInt RProcess::GetMemoryInfo(TModuleMemoryInfo& aInfo) const sl@0: /** sl@0: Gets the size and base address of the code and various data sl@0: sections of the process. sl@0: sl@0: The run addresses are also returned. sl@0: sl@0: @param aInfo On successful return, contains the base address and size of the sl@0: sections. sl@0: sl@0: @return KErrNone, if successful; otherwise one of the other system wide error sl@0: codes. sl@0: */ sl@0: { sl@0: sl@0: return Exec::ProcessGetMemoryInfo(iHandle,aInfo); sl@0: } sl@0: sl@0: sl@0: EXPORT_C TAny* RProcess::ExeExportData(void) sl@0: /** sl@0: Retrieves pointer to named symbol export data from the current process, i.e. the sl@0: process calling this function. sl@0: sl@0: @return Pointer to export data when it is present, NULL if export data not found sl@0: @internalTechnology sl@0: @released sl@0: */ sl@0: { sl@0: sl@0: return Exec::ProcessExeExportData(); sl@0: } sl@0: sl@0: sl@0: sl@0: EXPORT_C TInt TFindSemaphore::Next(TFullName &aResult) sl@0: /** sl@0: Finds the next global semaphore whose full name matches the match pattern. sl@0: sl@0: If a global semaphore with a matching name is found, the function copies its sl@0: full name into the descriptor aResult. It also saves the find-handle associated sl@0: with the global semaphore into the TFindHandleBase part of this TFindSemaphore sl@0: object. sl@0: sl@0: @param aResult A reference to a TBuf descriptor with a defined maximum length. sl@0: If a matching global semaphore is found, its full name is set sl@0: into this descriptor. sl@0: If no matching global semaphore is found, the descriptor length sl@0: is set to zero. sl@0: sl@0: @return KErrNone if a matching global semaphore is found; sl@0: KErrNotFound otherwise. sl@0: */ sl@0: { sl@0: return NextObject(aResult,ESemaphore); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C void RSemaphore::Wait() sl@0: /** sl@0: Waits for a signal on the semaphore. sl@0: sl@0: The function decrements the semaphore count by one and returns immediately sl@0: if it is zero or positive. sl@0: sl@0: If the semaphore count is negative after being decremented, the calling thread is sl@0: added to a queue of threads maintained by this semaphore. sl@0: sl@0: The thread waits until the semaphore is signalled. More than one thread can sl@0: be waiting on a particular semaphore at a time. When there are multiple threads sl@0: waiting on a semaphore, they are released in priority order. sl@0: sl@0: If the semaphore is deleted, all threads waiting on that semaphore are released. sl@0: */ sl@0: { sl@0: sl@0: Exec::SemaphoreWait(iHandle, 0); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TInt RSemaphore::Wait(TInt aTimeout) sl@0: /** sl@0: Waits for a signal on the semaphore, or a timeout. sl@0: sl@0: @param aTimeout The timeout value in micoseconds sl@0: sl@0: @return KErrNone if the wait has completed normally. sl@0: KErrTimedOut if the timeout has expired. sl@0: KErrGeneral if the semaphore is being reset, i.e the semaphore sl@0: is about to be deleted. sl@0: KErrArgument if aTimeout is negative; sl@0: otherwise one of the other system wide error codes. sl@0: */ sl@0: { sl@0: sl@0: return Exec::SemaphoreWait(iHandle, aTimeout); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C void RSemaphore::Signal() sl@0: /** sl@0: Signals the semaphore once. sl@0: sl@0: The function increments the semaphore count by one. If the count was negative sl@0: before being incremented, the highest priority thread waiting on the semaphore's queue sl@0: of threads is removed from that queue and, provided that it is not suspended sl@0: for any other reason, is marked as ready to run. sl@0: */ sl@0: { sl@0: sl@0: Exec::SemaphoreSignal1(iHandle); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C void RSemaphore::Signal(TInt aCount) sl@0: /** sl@0: Signals the semaphore one or more times. sl@0: sl@0: The function increments the semaphore count. If the count was negative sl@0: before being incremented, the highest priority thread waiting on the semaphore's queue sl@0: of threads is removed from that queue and, provided that it is not suspended sl@0: for any other reason, is marked as ready to run. sl@0: sl@0: @param aCount The number of times the semaphore is to be signalled. sl@0: */ sl@0: { sl@0: sl@0: __ASSERT_ALWAYS(aCount>=0,Panic(ESemSignalCountNegative)); sl@0: Exec::SemaphoreSignalN(iHandle,aCount); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C RCriticalSection::RCriticalSection() sl@0: : iBlocked(1) sl@0: /** sl@0: Default constructor. sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C void RCriticalSection::Close() sl@0: /** sl@0: Closes the handle to the critical section. sl@0: sl@0: As a critical section object is implemented using a semaphore, this has the sl@0: effect of closing the handle to the semaphore. sl@0: */ sl@0: { sl@0: sl@0: RSemaphore::Close(); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C void RCriticalSection::Wait() sl@0: /** sl@0: Waits for the critical section to become free. sl@0: sl@0: If no other thread is in the critical section, control returns immediately sl@0: and the current thread can continue into the section. sl@0: sl@0: If another thread is already in the critical section, the current thread is sl@0: marked as waiting (on a semaphore); the current thread is added to a queue sl@0: of threads maintained by this critical section. sl@0: */ sl@0: { sl@0: sl@0: if (__e32_atomic_add_acq32(&iBlocked, KMaxTUint32) != 1) sl@0: RSemaphore::Wait(); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C void RCriticalSection::Signal() sl@0: /** sl@0: Signals an exit from the critical section. sl@0: sl@0: A thread calls this function when it exits from the critical section. sl@0: The first eligible thread waiting on the critical section's queue of threads sl@0: is removed from that queue and, provided that it is not suspended for any other sl@0: reason, is marked as ready to run. That thread will, therefore, be the next to sl@0: proceed into the critical section. sl@0: */ sl@0: { sl@0: sl@0: __ASSERT_ALWAYS(iBlocked<1,Panic(ECriticalSectionStraySignal)); sl@0: if (TInt(__e32_atomic_add_rel32(&iBlocked, 1)) < 0) sl@0: RSemaphore::Signal(); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TInt TFindThread::Next(TFullName &aResult) sl@0: /** sl@0: Gets the full name of the next global thread which matches the match pattern. sl@0: sl@0: @param aResult A reference to a TBuf descriptor with a defined maximum length. sl@0: If a matching global thread is found, its full name is set into sl@0: this descriptor. If no matching global thread is found, sl@0: the descriptor length is set to zero. sl@0: sl@0: @return KErrNone if successful, otherwise one of the other system-wide error sl@0: codes. sl@0: */ sl@0: { sl@0: return NextObject(aResult,EThread); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TThreadId RThread::Id() const sl@0: /** sl@0: Gets the Id of this thread. sl@0: sl@0: @return The Id of this thread. sl@0: */ sl@0: { sl@0: sl@0: return TThreadId( (TUint)Exec::ThreadId(iHandle) ); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C void RThread::HandleCount(TInt& aProcessHandleCount, TInt& aThreadHandleCount) const sl@0: /** sl@0: Gets the number of handles open in this thread, and the number of handles open sl@0: in the process which owns this thread. sl@0: sl@0: @param aProcessHandleCount On return, contains the number of handles open in sl@0: the process which owns this thread. sl@0: @param aThreadHandleCount On return, contains the number of handles open in sl@0: this thread. sl@0: */ sl@0: { sl@0: sl@0: Exec::HandleCount(iHandle,aProcessHandleCount,aThreadHandleCount); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TExceptionHandler User::ExceptionHandler() sl@0: /** sl@0: Gets a pointer to the exception handler for the current thread. sl@0: sl@0: @return A pointer to the exception handler. sl@0: */ sl@0: { sl@0: return(Exec::ExceptionHandler(KCurrentThreadHandle)); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TInt User::SetExceptionHandler(TExceptionHandler aHandler,TUint32 aMask) sl@0: /** sl@0: Sets a new exception handler for the current thread. Note that the handler is not sl@0: guaranteed to receive floating point exceptions (KExceptionFpe) when a hardware sl@0: floating point implementation is in use - see User::SetFloatingPointMode for sl@0: hardware floating point modes and whether they cause user-trappable exceptions. sl@0: sl@0: @param aHandler The new exception handler. sl@0: @param aMask One or more flags defining the exception categories which sl@0: the handler can handle. sl@0: sl@0: @return KErrNone if successful, otherwise another of the system-wide error codes. sl@0: sl@0: @see KExceptionAbort sl@0: @see KExceptionKill sl@0: @see KExceptionUserInterrupt sl@0: @see KExceptionFpe sl@0: @see KExceptionFault sl@0: @see KExceptionInteger sl@0: @see KExceptionDebug sl@0: */ sl@0: { sl@0: return(Exec::SetExceptionHandler(KCurrentThreadHandle, aHandler, aMask)); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C void User::ModifyExceptionMask(TUint32 aClearMask, TUint32 aSetMask) sl@0: /** sl@0: Changes the set of exceptions which the current thread's exception sl@0: handler can deal with. sl@0: sl@0: aClearMask is the set of flags defining the set of exceptions which the sl@0: exception handler no longer deals with, while aSetMask is the set of flags sl@0: defining the new set of exceptions to be set. sl@0: sl@0: Flag clearing is done before flag setting. sl@0: sl@0: @param aClearMask One or more flags defining the exceptions which the current sl@0: exception handler no longer deals with. sl@0: @param aSetMask One or more flags defining the new set of exceptions which sl@0: the current exception handler is to deal with. sl@0: */ sl@0: { sl@0: Exec::ModifyExceptionMask(KCurrentThreadHandle, aClearMask, aSetMask); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: _LIT(KLitUserExec, "USER-EXEC"); sl@0: EXPORT_C TInt User::RaiseException(TExcType aType) sl@0: /** sl@0: Raises an exception of a specified type on the current thread. sl@0: sl@0: If the thread has an exception handler to handle this type of exception, sl@0: then it is called. sl@0: sl@0: If the thread has no exception handler to handle this type of exception, then sl@0: the function raises a USER-EXEC 3 panic. sl@0: sl@0: Note that exception handlers are executed in the context of the thread on which sl@0: the exception is raised; control returns to the point of the exception. sl@0: sl@0: @param aType The type of exception. sl@0: sl@0: @return KErrNone if successful, otherwise another of the system-wide sl@0: error codes. sl@0: */ sl@0: { sl@0: if (Exec::IsExceptionHandled(KCurrentThreadHandle,aType,ETrue)) sl@0: { sl@0: Exec::ThreadSetFlags(KCurrentThreadHandle, 0, KThreadFlagLastChance); sl@0: TUint32 type = aType; sl@0: User::HandleException(&type); sl@0: } sl@0: else sl@0: User::Panic(KLitUserExec, ECausedException); sl@0: return KErrNone; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TBool User::IsExceptionHandled(TExcType aType) sl@0: /** sl@0: Tests whether the specified exception type can be handled by the sl@0: current thread. sl@0: sl@0: @param aType The type of exception. sl@0: sl@0: @return True, if the thread has an exception handler which can handle sl@0: an exception of type aType. sl@0: False, if the thread has no exception handler or the thread has sl@0: an exception handler which cannot handle the exception defined sl@0: by aType. sl@0: */ sl@0: { sl@0: return (Exec::IsExceptionHandled(KCurrentThreadHandle,aType,EFalse)); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C void RThread::Context(TDes8 &aDes) const sl@0: /** sl@0: Gets the register contents of this thread. sl@0: sl@0: @param aDes On return, contains the register contents, starting with R0. sl@0: */ sl@0: { sl@0: sl@0: Exec::ThreadContext(iHandle,aDes); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C void RThread::Resume() const sl@0: /** sl@0: Makes the thread eligible for execution. sl@0: sl@0: After a thread is created, it is put into a suspended state; the thread is sl@0: not eligible to run until Resume() is called. sl@0: sl@0: This function must also be called to resume execution of this thread after sl@0: it has been explicitly suspended by a call to Suspend(). sl@0: sl@0: Note that when a thread is created, it is given the priority EPriorityNormal sl@0: by default. The fact that a thread is initially put into a suspended state sl@0: means that the thread priority can be changed by calling the thread's sl@0: SetPriority() member function before the thread is started by a call to Resume(). sl@0: */ sl@0: { sl@0: sl@0: Exec::ThreadResume(iHandle); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C void RThread::Suspend() const sl@0: /** sl@0: Suspends execution of this thread. sl@0: sl@0: The thread is not scheduled to run until a subsequent call to Resume() is made. sl@0: */ sl@0: { sl@0: sl@0: Exec::ThreadSuspend(iHandle); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TThreadPriority RThread::Priority() const sl@0: /** sl@0: Gets the priority of this thread. sl@0: sl@0: @return The priority. sl@0: */ sl@0: { sl@0: sl@0: return(Exec::ThreadPriority(iHandle)); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C void RThread::SetProcessPriority(TProcessPriority aPriority) const sl@0: /** sl@0: Sets the priority of the process which owns this thread to one of the values sl@0: defined by the TProcessPriority enumeration. sl@0: sl@0: The priority can be set to one of the four values: sl@0: sl@0: EPriorityLow sl@0: sl@0: EPriorityBackground sl@0: sl@0: EPriorityForeground sl@0: sl@0: EPriorityHigh sl@0: sl@0: The absolute priority of all threads owned by the process (and all threads sl@0: owned by those threads etc.) are re-calculated. sl@0: sl@0: Note: sl@0: sl@0: The use of the priority values EPriorityWindowServer, EPriorityFileServer, sl@0: EPriorityRealTimeServer and EPrioritySupervisor is restricted to Symbian OS, sl@0: and any attempt to explicitly set any of these priority values raises a KERN-EXEC sl@0: 14 panic. sl@0: sl@0: @param aPriority The priority value. sl@0: sl@0: @deprecated Not allowed on threads in a different process. sl@0: Replace with RProcess::SetPriority or RMessagePtr2::SetProcessPriority sl@0: */ sl@0: { sl@0: sl@0: Exec::ThreadSetProcessPriority(iHandle,aPriority); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TProcessPriority RThread::ProcessPriority() const sl@0: /** sl@0: Gets the priority of the process which owns this thread. sl@0: sl@0: @return The process priority. sl@0: */ sl@0: { sl@0: sl@0: return(Exec::ThreadProcessPriority(iHandle)); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C void RThread::SetPriority(TThreadPriority aPriority) const sl@0: /** sl@0: Sets the priority of the thread to one of the values defined by sl@0: the TThreadPriority enumeration. sl@0: sl@0: The resulting absolute priority of the thread depends on the value of aPriority sl@0: and the priority of the owning process. sl@0: sl@0: Use of the priority value EPriorityNull is restricted to Symbian OS, and any sl@0: attempt to explicitly set this value causes a KERN-EXEC 14 panic to be raised. sl@0: sl@0: @param aPriority The priority value. sl@0: sl@0: @capability ProtServ if aPriority is EPriorityAbsoluteRealTime1 or higher sl@0: sl@0: @panic KERN-EXEC 14, if aPriority is invalid or set to EPriorityNull sl@0: @panic KERN-EXEC 46, if aPriority is EPriorityAbsoluteRealTime1 or higher sl@0: and calling process does not have ProtServ capability sl@0: */ sl@0: { sl@0: sl@0: Exec::ThreadSetPriority(iHandle,aPriority); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C User::TCritical User::Critical(RThread aThread) sl@0: /** sl@0: Gets the critical state associated with the specified thread. sl@0: sl@0: @param aThread The thread whose critical state is to be retrieved. sl@0: sl@0: @return The critical state. sl@0: sl@0: @see User::SetCritical() sl@0: */ sl@0: { sl@0: TUint32 flags = Exec::ThreadFlags(aThread.Handle()); sl@0: if (flags & KThreadFlagSystemPermanent) sl@0: return ESystemPermanent; sl@0: if (flags & KThreadFlagSystemCritical) sl@0: return ESystemCritical; sl@0: if (flags & KThreadFlagProcessPermanent) sl@0: return EProcessPermanent; sl@0: if (flags & KThreadFlagProcessCritical) sl@0: return EProcessCritical; sl@0: return ENotCritical; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C User::TCritical User::Critical() sl@0: /** sl@0: Gets the critical state associated with the current thread. sl@0: sl@0: @return The critical state. sl@0: sl@0: @see User::SetCritical() sl@0: */ sl@0: { sl@0: RThread me; sl@0: return User::Critical(me); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Sets up or changes the effect that termination of the current sl@0: thread has, either on its owning process, or on the whole system. sl@0: sl@0: The precise effect of thread termination is defined by sl@0: the following specific values of the TCritical enum: sl@0: - ENotCritical sl@0: - EProcessCritical sl@0: - EProcessPermanent sl@0: - ESystemCritical sl@0: - ESystemPermanent sl@0: sl@0: Notes: sl@0: -# The enum value EAllThreadsCritical cannot be set using this function. It is sl@0: associated with a process, not a thread, and, if appropriate, should be set sl@0: using User::SetProcessCritical(). sl@0: -# The states associated with ENotCritical, EProcessCritical, sl@0: EProcessPermanent, ESystemCritical and ESystemPermanent sl@0: are all mutually exclusive, i.e. the thread can only be in one of these states sl@0: at any one time sl@0: sl@0: @param aCritical The state to be set. sl@0: sl@0: @return KErrNone, if successful; sl@0: KErrArgument, if EAllThreadsCritical is passed - this is a sl@0: state associated with a process, and sl@0: you use User::SetProcessCritical() to set it. sl@0: sl@0: @capability ProtServ if aCritical==ESystemCritical or ESystemPermanent sl@0: sl@0: @see User::Critical() sl@0: @see User::ProcessCritical() sl@0: @see User::SetProcessCritical() sl@0: */ sl@0: EXPORT_C TInt User::SetCritical(TCritical aCritical) sl@0: { sl@0: const TUint32 clear = KThreadFlagSystemPermanent | KThreadFlagSystemCritical | sl@0: KThreadFlagProcessPermanent | KThreadFlagProcessCritical; sl@0: TUint32 set; sl@0: switch (aCritical) sl@0: { sl@0: case ENotCritical: set = 0; break; sl@0: case EProcessCritical: set = KThreadFlagProcessCritical; break; sl@0: case EProcessPermanent: set = KThreadFlagProcessPermanent; break; sl@0: case ESystemCritical: set = KThreadFlagSystemCritical; break; sl@0: case ESystemPermanent: set = KThreadFlagSystemPermanent; break; sl@0: default: return KErrArgument; sl@0: } sl@0: Exec::ThreadSetFlags(KCurrentThreadHandle, clear, set); sl@0: return KErrNone; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TInt User::SetRealtimeState(TRealtimeState aState) sl@0: { sl@0: const TUint32 clear = KThreadFlagRealtime | KThreadFlagRealtimeTest; sl@0: TUint32 set; sl@0: switch (aState) sl@0: { sl@0: case ERealtimeStateOff: set = 0; break; sl@0: case ERealtimeStateOn: set = KThreadFlagRealtime; break; sl@0: case ERealtimeStateWarn: set = KThreadFlagRealtime|KThreadFlagRealtimeTest; break; sl@0: default: return KErrArgument; sl@0: } sl@0: Exec::ThreadSetFlags(KCurrentThreadHandle, clear, set); sl@0: return KErrNone; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C User::TCritical User::ProcessCritical(RProcess aProcess) sl@0: /** sl@0: Gets the critical state associated with the specified process. sl@0: sl@0: @param aProcess The process whose critical state is to be retrieved. sl@0: sl@0: @return The critical state. sl@0: sl@0: @see User::SetProcessCritical() sl@0: */ sl@0: { sl@0: TUint32 flags = Exec::ProcessFlags(aProcess.Handle()); sl@0: if (flags & KProcessFlagSystemPermanent) sl@0: return ESystemPermanent; sl@0: if (flags & KProcessFlagSystemCritical) sl@0: return ESystemCritical; sl@0: if (flags & (KThreadFlagProcessPermanent | KThreadFlagProcessCritical)) sl@0: return EAllThreadsCritical; sl@0: return ENotCritical; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C User::TCritical User::ProcessCritical() sl@0: /** sl@0: Gets the critical state associated with the current process. sl@0: sl@0: @return The critical state. sl@0: sl@0: @see User::SetProcessCritical() sl@0: */ sl@0: { sl@0: RProcess me; sl@0: return User::ProcessCritical(me); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TInt User::SetProcessCritical(TCritical aCritical) sl@0: /** sl@0: Sets up or changes the effect that termination of subsequently created threads sl@0: will have, either on the owning process, or on the whole system. sl@0: sl@0: It is important to note that we are not referring to threads that have already sl@0: been created, but threads that will be created subsequent to a call to this function. sl@0: sl@0: The precise effect of thread termination is defined by the following specific sl@0: values of the TCritical enum: sl@0: - ENotCritical sl@0: - EAllThreadsCritical sl@0: - ESystemCritical sl@0: - ESystemPermanent sl@0: sl@0: Notes: sl@0: -# The enum values EProcessCritical and EProcessPermanent cannot be set using sl@0: this function. They are states associated with sl@0: a thread, not a process, and, if appropriate, should be set sl@0: using User::SetCritical(). sl@0: -# The states associated with ENotCritical, EAllThreadsCritical, sl@0: ESystemCritical and ESystemPermanent are all mutually exclusive, i.e. the sl@0: process can only be in one of these states at any one time. sl@0: sl@0: @param aCritical The state to be set. sl@0: sl@0: @return KErrNone, if successful; sl@0: KErrArgument, if either EProcessCritical or EProcessPermanent sl@0: is passed - these are states associated with a thread, and sl@0: you use User::SetCritical() to set them. sl@0: sl@0: @capability ProtServ if aCritical==ESystemCritical or ESystemPermanent sl@0: sl@0: @see User::ProcessCritical() sl@0: @see User::SetCritical() sl@0: @see User::Critical() sl@0: */ sl@0: { sl@0: const TUint32 clear = KProcessFlagSystemPermanent | KProcessFlagSystemCritical | sl@0: KThreadFlagProcessPermanent | KThreadFlagProcessCritical; sl@0: TUint32 set; sl@0: switch (aCritical) sl@0: { sl@0: case ENotCritical: set = 0; break; sl@0: case EAllThreadsCritical: set = KThreadFlagProcessCritical; break; sl@0: case ESystemCritical: set = KProcessFlagSystemCritical; break; sl@0: case ESystemPermanent: set = KProcessFlagSystemPermanent|KProcessFlagSystemCritical; break; sl@0: default: return KErrArgument; sl@0: } sl@0: Exec::ProcessSetFlags(KCurrentProcessHandle, clear, set); sl@0: return KErrNone; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TBool User::PriorityControl() sl@0: /** sl@0: Tests whether the current process allows other processes to switch its priority sl@0: between 'foreground' and 'background'. sl@0: sl@0: @return True, if the current process allows other processes to switch its priority; sl@0: false, otherwise. sl@0: */ sl@0: { sl@0: return Exec::ProcessFlags(KCurrentProcessHandle) & KProcessFlagPriorityControl; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C void User::SetPriorityControl(TBool aEnable) sl@0: /** sl@0: Allows the current process to choose to have its priority switched by another sl@0: process between 'foreground' and 'background'. sl@0: sl@0: By default a process does not allow this. sl@0: sl@0: @param aEnable If ETrue, allows other processes to switch the current process's sl@0: priority. sl@0: If EFalse, prevents other processes from switching the current sl@0: process's priority. sl@0: */ sl@0: { sl@0: TUint32 set = aEnable ? KProcessFlagPriorityControl : 0; sl@0: Exec::ProcessSetFlags(KCurrentProcessHandle, KProcessFlagPriorityControl, set); sl@0: } sl@0: sl@0: sl@0: sl@0: EXPORT_C TInt RThread::RequestCount() const sl@0: /** sl@0: Gets this thread's request semaphore count. sl@0: sl@0: The request semaphore is created when a thread is created, and is used to sl@0: support asynchronous requests. sl@0: sl@0: A negative value implies that this thread is waiting for at least sl@0: one asynchronous request to complete. sl@0: sl@0: @return This thread's request semaphore count. sl@0: */ sl@0: { sl@0: sl@0: return(Exec::ThreadRequestCount(iHandle)); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TExitType RThread::ExitType() const sl@0: /** sl@0: Tests whether the thread has ended and, if it has ended, return how it ended. sl@0: sl@0: This information allows the caller to distinguish between normal termination sl@0: and a panic. sl@0: sl@0: @return An enumeration whose enumerators describe how the thread has ended. sl@0: */ sl@0: { sl@0: sl@0: return(Exec::ThreadExitType(iHandle)); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TInt RThread::ExitReason() const sl@0: /** sl@0: Gets the specific reason associated with the end of this thread. sl@0: sl@0: The reason number together with the category name is a way of distinguishing sl@0: between different causes of thread termination. sl@0: sl@0: If the thread has panicked, this value is the panic number. If the thread sl@0: has ended as a result of a call to Kill(), then the value is the one supplied sl@0: by Kill(). sl@0: sl@0: If the thread is still alive, then the returned value is zero. sl@0: sl@0: @return The reason associated with the end of the thread. sl@0: */ sl@0: { sl@0: sl@0: return(Exec::ThreadExitReason(iHandle)); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TExitCategoryName RThread::ExitCategory() const sl@0: /** sl@0: Gets the name of the category associated with the end of the thread. sl@0: sl@0: The category name together with the reason number is a way of distinguishing sl@0: between different causes of thread termination. sl@0: sl@0: If the thread has panicked, the category name is the panic category name; sl@0: for example, E32USER-CBase or KERN-EXEC. If the thread has ended as a result sl@0: of call to Kill(), then the category name is Kill. sl@0: sl@0: If the thread has not ended, then the category name is empty, i.e. the length sl@0: of the category name is zero. sl@0: sl@0: @return A TBuf descriptor with a defined maximum length containing the name sl@0: of the category associated with the end of the thread. sl@0: sl@0: @see TBuf sl@0: */ sl@0: { sl@0: TExitCategoryName n; sl@0: TPtr8 n8(((TUint8*)n.Ptr()) + KMaxExitCategoryName, KMaxExitCategoryName); sl@0: Exec::ThreadExitCategory(iHandle,n8); sl@0: n.Copy(n8); sl@0: return(n); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TInt RThread::StackInfo(TThreadStackInfo& aInfo) const sl@0: /** sl@0: Gets information about a thread's user mode stack. sl@0: sl@0: @param aInfo The TThreadStackInfo object to write the stack infomation to. sl@0: sl@0: @return KErrNone, if sucessful; sl@0: KErrGeneral, if the thread doesn't have a user mode stack, sl@0: or it has terminated. sl@0: sl@0: @see TThreadStackInfo sl@0: */ sl@0: { sl@0: return(Exec::ThreadStackInfo(iHandle,aInfo)); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TInt RThread::GetCpuTime(TTimeIntervalMicroSeconds& aCpuTime) const sl@0: /** sl@0: Gets the CPU usage for this thread. sl@0: sl@0: This function is not supported on version 8.0b or 8.1b, and returns sl@0: KErrNotSupported. From 9.1 onwards it may be supported if the kernel has been sl@0: compiled with the MONITOR_THREAD_CPU_TIME macro defined. sl@0: sl@0: @param aCpuTime A reference to a time interval object supplied by the caller. sl@0: sl@0: @return KErrNone - if thread CPU time is available. sl@0: sl@0: KErrNotSupported - if this feature is not supported on this sl@0: version or build of the OS. sl@0: */ sl@0: { sl@0: return Exec::ThreadGetCpuTime(iHandle, (TInt64&)aCpuTime.Int64()); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C void User::After(TTimeIntervalMicroSeconds32 aInterval) sl@0: /** sl@0: Suspends the current thread until a specified time interval has expired. sl@0: sl@0: The resolution of the timer depends on the hardware, but is normally sl@0: 1 Symbian OS tick (approximately 1/64 second). sl@0: sl@0: @param aInterval The time interval for which the current thread is to be sl@0: suspended, in microseconds. sl@0: sl@0: @panic USER 86, if the time interval is negative. sl@0: */ sl@0: { sl@0: sl@0: __ASSERT_ALWAYS(aInterval.Int()>=0,::Panic(EExecAfterTimeNegative)); sl@0: TRequestStatus s=KRequestPending; sl@0: Exec::After(aInterval.Int(),s); sl@0: User::WaitForRequest(s); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C void User::AfterHighRes(TTimeIntervalMicroSeconds32 aInterval) sl@0: /** sl@0: Suspends the current thread until a specified time interval has expired to sl@0: a resolution of 1ms . sl@0: sl@0: @param aInterval The time interval for which the current thread is to be sl@0: suspended, in microseconds. sl@0: sl@0: @panic USER 86, if the time interval is negative. sl@0: */ sl@0: { sl@0: sl@0: __ASSERT_ALWAYS(aInterval.Int()>=0,::Panic(EExecAfterTimeNegative)); sl@0: TRequestStatus s=KRequestPending; sl@0: Exec::AfterHighRes(aInterval.Int(),s); sl@0: User::WaitForRequest(s); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TInt User::At(const TTime &aTime) sl@0: /** sl@0: Suspends the current thread until the specified absolute time, in the current time zone. sl@0: sl@0: If the machine is off at that time, the machine will be turned on again. sl@0: sl@0: @param aTime The absolute time, in the current time zone, until which the current thread is to sl@0: be suspended. sl@0: sl@0: @return On completion, contains the status of the request to suspend the sl@0: current thread: sl@0: sl@0: KErrNone - suspension of the current thread completed normally at sl@0: the requested time. sl@0: sl@0: KErrAbort - suspension of the current thread was aborted sl@0: because the system time changed. sl@0: sl@0: KErrUnderflow - the requested completion time is in the past. sl@0: sl@0: KErrOverFlow - the requested completion time is too far in the future. sl@0: */ sl@0: { sl@0: sl@0: TRequestStatus s=KRequestPending; sl@0: TInt64 time=aTime.Int64(); sl@0: time -= ((TInt64)User::UTCOffset().Int()) * 1000000; sl@0: Exec::At(time,s); sl@0: User::WaitForRequest(s); sl@0: return(s.Int()); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C void RTimer::Cancel() sl@0: /** sl@0: Cancels any outstanding request for a timer event. sl@0: sl@0: Any outstanding timer event completes with KErrCancel. sl@0: */ sl@0: { sl@0: sl@0: Exec::TimerCancel(iHandle); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C void RTimer::After(TRequestStatus &aStatus,TTimeIntervalMicroSeconds32 aInterval) sl@0: // sl@0: // Request a relative timer. sl@0: // sl@0: /** sl@0: Requests an event after the specified interval. sl@0: sl@0: The counter for this type of request stops during power-down. sl@0: A 5 second timer will complete late if, for example, the machine is turned off sl@0: 2 seconds after the request is made. sl@0: sl@0: @param aStatus On completion, contains the status of the request. sl@0: This is KErrNone if the timer completed normally at the sl@0: requested time, otherwise another of the sl@0: system-wide error codes. sl@0: sl@0: @param aInterval The time interval, in microseconds, after which an event sl@0: is to occur. sl@0: sl@0: @panic USER 87, if aInterval is negative. sl@0: @panic KERN-EXEC 15, if this function is called while a request for a timer sl@0: event is still outstanding. sl@0: */ sl@0: { sl@0: sl@0: __ASSERT_ALWAYS(aInterval.Int()>=0,::Panic(ERTimerAfterTimeNegative)); sl@0: aStatus=KRequestPending; sl@0: Exec::TimerAfter(iHandle,aStatus,aInterval.Int()); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C void RTimer::AfterTicks(TRequestStatus& aStatus, TInt aTicks) sl@0: // sl@0: // Request a relative timer in system ticks. sl@0: // sl@0: /** sl@0: Requests an event after the specified interval. sl@0: sl@0: The counter for this type of request stops during power-down. sl@0: A 5 tick timer will complete late if, for example, the machine is turned off sl@0: 2 ticks after the request is made. sl@0: sl@0: @param aStatus On completion, contains the status of the request. sl@0: This is KErrNone if the timer completed normally at the sl@0: requested time, otherwise another of the sl@0: system-wide error codes. sl@0: sl@0: @param aTicks The time interval, in system ticks, after which an event sl@0: is to occur. sl@0: sl@0: @panic USER 87, if aTicks is negative. sl@0: @panic KERN-EXEC 15, if this function is called while a request for a timer sl@0: event is still outstanding. sl@0: */ sl@0: { sl@0: __ASSERT_ALWAYS(aTicks >= 0, ::Panic(ERTimerAfterTimeNegative)); sl@0: aStatus = KRequestPending; sl@0: Exec::TimerAfter(iHandle, aStatus, -aTicks); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C void RTimer::HighRes(TRequestStatus &aStatus,TTimeIntervalMicroSeconds32 aInterval) sl@0: // sl@0: // Request a relative timer to a resolution of 1ms. sl@0: // sl@0: /** sl@0: Requests an event after the specified interval to a resolution of 1ms. sl@0: The "HighRes timer" counter stops during power-down (the same as "after timer"). sl@0: sl@0: @param aStatus On completion, contains the status of the request. sl@0: This is KErrNone if the timer completed normally at the sl@0: requested time, otherwise another of the sl@0: system-wide error codes. sl@0: sl@0: @param aInterval The time interval, in microseconds, after which an event sl@0: is to occur. sl@0: sl@0: @panic USER 87, if aInterval is negative. sl@0: @panic KERN-EXEC 15, if this function is called while a request for a timer sl@0: event is still outstanding. sl@0: */ sl@0: { sl@0: sl@0: __ASSERT_ALWAYS(aInterval.Int()>=0,::Panic(ERTimerAfterTimeNegative)); sl@0: aStatus=KRequestPending; sl@0: Exec::TimerHighRes(iHandle,aStatus,aInterval.Int()); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C void RTimer::At(TRequestStatus &aStatus,const TTime &aTime) sl@0: // sl@0: // Request an absolute timer. sl@0: // sl@0: /** sl@0: Requests an event at a given system time (in the current time zone). sl@0: sl@0: If the machine is off at that time, it is automatically turned on. sl@0: sl@0: @param aStatus On completion, contains the status of the request: sl@0: KErrNone, the timer completed normally at the requested time; sl@0: KErrCancel, the timer was cancelled; sl@0: KErrAbort, the timer was aborted because the system time changed; sl@0: KErrUnderflow, the requested completion time is in the past; sl@0: KErrOverFlow, the requested completion time is too far in the future; sl@0: @param aTime The time at which the timer will expire. sl@0: sl@0: @panic KERN-EXEC 15, if this function is called while a request for a timer sl@0: event is still outstanding. sl@0: */ sl@0: { sl@0: sl@0: aStatus=KRequestPending; sl@0: TInt64 time=aTime.Int64(); sl@0: time -= ((TInt64)User::UTCOffset().Int()) * 1000000; sl@0: Exec::TimerAt(iHandle,aStatus,I64LOW(time),I64HIGH(time)); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C void RTimer::AtUTC(TRequestStatus &aStatus,const TTime &aUTCTime) sl@0: // sl@0: // Request an absolute timer in UTC time. sl@0: // sl@0: /** sl@0: Requests an event at a given UTC time. sl@0: sl@0: If the machine is off at that time, it is automatically turned on. sl@0: sl@0: @param aStatus On completion, contains the status of the request: sl@0: KErrNone, the timer completed normally at the requested time; sl@0: KErrCancel, the timer was cancelled; sl@0: KErrAbort, the timer was aborted because the system time changed; sl@0: KErrUnderflow, the requested completion time is in the past; sl@0: KErrOverFlow, the requested completion time is too far in the future; sl@0: @param aTime The time at which the timer will expire. sl@0: sl@0: @panic KERN-EXEC 15, if this function is called while a request for a timer sl@0: event is still outstanding. sl@0: */ sl@0: { sl@0: sl@0: aStatus=KRequestPending; sl@0: Exec::TimerAt(iHandle,aStatus,I64LOW(aUTCTime.Int64()),I64HIGH(aUTCTime.Int64())); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C void RTimer::Lock(TRequestStatus &aStatus,TTimerLockSpec aLock) sl@0: // sl@0: // Request an absolute timer. sl@0: // sl@0: /** sl@0: Requests an event on a specified second fraction. sl@0: sl@0: @param aStatus On completion, contains the status of the request: sl@0: KErrGeneral, the first time this is called; sl@0: KErrNone, the timer completed normally at the requested time; sl@0: KErrCancel, the timer was cancelled; sl@0: KErrAbort, the timer was aborted because the system time changed; sl@0: KErrUnderflow, the requested completion time is in the past; sl@0: KErrOverFlow, the requested completion time is too far in the future. sl@0: @param aLock The fraction of a second at which the timer completes. sl@0: sl@0: @panic KERN-EXEC 15, if this function is called while a request for a timer sl@0: event is still outstanding. sl@0: */ sl@0: { sl@0: aStatus=KRequestPending; sl@0: Exec::TimerLock(iHandle,aStatus,aLock); sl@0: } sl@0: sl@0: sl@0: /** sl@0: Requests an event to be triggered when aSeconds is exactly, (ie not greater or sl@0: less than), the time elapsed (to the nearest second) since the last user activity. sl@0: If the event trigger time has been "missed", instead of triggering late, sl@0: the timer waits for the next user activity, to try and satisfy the condition. sl@0: sl@0: That is to say, if there was user activity within the last aSeconds, sl@0: the event will be triggered after aSeconds of continuous inactivity following that activity. sl@0: Otherwise, if there has been no such activity within this time, an event is sl@0: triggered after aSeconds of continuous inactivity following the next user activity sl@0: in the future. sl@0: sl@0: It follows from this, that you can request an event directly after the next sl@0: user activity by supplying a time interval of zero. sl@0: sl@0: sl@0: @param aStatus On completion, contains the status of the request: sl@0: KErrNone, the timer completed normally; sl@0: KErrCancel, the timer was cancelled; sl@0: KErrArgument, if aSeconds is less then zero; sl@0: KErrOverflow, if aSecond reaches its limit (which is platform specific but greater then one and a half day). sl@0: @param aSeconds The time interval in seconds. sl@0: sl@0: @panic KERN-EXEC 15, if this function is called while a request for a timer sl@0: event is still outstanding. sl@0: */ sl@0: EXPORT_C void RTimer::Inactivity(TRequestStatus &aStatus, TTimeIntervalSeconds aSeconds) sl@0: { sl@0: aStatus=KRequestPending; sl@0: Exec::TimerInactivity(iHandle, aStatus, aSeconds.Int()); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TInt RChangeNotifier::Logon(TRequestStatus& aStatus) const sl@0: /** sl@0: Issues a request for notification when changes occur in the environment. sl@0: sl@0: A switch in locale, or crossing over past midnight, are examples of changes sl@0: that are reported. sl@0: sl@0: When a change in the environment occurs, the request completes and the sl@0: TRquestStatus object will contain one or more of the bit values defined sl@0: by the TChanges enum. sl@0: sl@0: Alternatively, if an outstanding request is cancelled by a call to sl@0: this handle's LogonCancel() member function, then the request completes sl@0: with a KErrCancel. sl@0: sl@0: Note that if this is the first notification request after creation of sl@0: the change notifier, then this request completes immediately. sl@0: sl@0: @param aStatus A reference to the request status object. sl@0: sl@0: @return KErrInUse, if there is an outstanding request; KErrNone otherwise. sl@0: sl@0: @see TChanges sl@0: @see RChangeNotifier::Logon() sl@0: */ sl@0: { sl@0: sl@0: aStatus=KRequestPending; sl@0: return(Exec::ChangeNotifierLogon(iHandle,aStatus)); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TInt RChangeNotifier::LogonCancel() const sl@0: /** sl@0: Cancels an outstanding change notification request. sl@0: sl@0: @return KErrGeneral, if there is no outstanding request; KErrNone otherwise. sl@0: sl@0: @see RChangeNotifier::Logon() sl@0: */ sl@0: { sl@0: sl@0: return(Exec::ChangeNotifierLogoff(iHandle)); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C void UserSvr::CaptureEventHook() sl@0: // sl@0: // Capture the event hook sl@0: // sl@0: { sl@0: sl@0: Exec::CaptureEventHook(); sl@0: } sl@0: sl@0: EXPORT_C void UserSvr::ReleaseEventHook() sl@0: // sl@0: // Release the event hook sl@0: // sl@0: { sl@0: sl@0: Exec::ReleaseEventHook(); sl@0: } sl@0: sl@0: EXPORT_C void UserSvr::RequestEvent(TRawEventBuf &anEvent,TRequestStatus &aStatus) sl@0: // sl@0: // Request the next event. sl@0: // sl@0: { sl@0: sl@0: aStatus=KRequestPending; sl@0: Exec::RequestEvent(anEvent,aStatus); sl@0: } sl@0: sl@0: EXPORT_C void UserSvr::RequestEventCancel() sl@0: // sl@0: // Cancel the event request. sl@0: // sl@0: { sl@0: sl@0: Exec::RequestEventCancel(); sl@0: } sl@0: sl@0: /** sl@0: Add an event to the queue. sl@0: sl@0: @param anEvent The raw hardware event to be added to the event queue. sl@0: @return KErrNone, if successful; KErrPermissionDenied, if the caller has sl@0: insufficient capability; otherwise, one of the other system-wide error codes. sl@0: sl@0: @capability SwEvent sl@0: @capability PowerMgmt for ESwitchOff, ERestartSystem, ECaseOpen and ECaseClose sl@0: */ sl@0: EXPORT_C TInt UserSvr::AddEvent(const TRawEvent& anEvent) sl@0: { sl@0: sl@0: return(Exec::AddEvent(anEvent)); sl@0: } sl@0: sl@0: EXPORT_C void UserSvr::ScreenInfo(TDes8 &anInfo) sl@0: // sl@0: // Get the screen info. sl@0: // sl@0: { sl@0: sl@0: Exec::HalFunction(EHalGroupDisplay,EDisplayHalScreenInfo,(TAny*)&anInfo,NULL); sl@0: } sl@0: sl@0: #ifdef __USERSIDE_THREAD_DATA__ sl@0: sl@0: EXPORT_C TAny* UserSvr::DllTls(TInt aHandle) sl@0: // sl@0: // Return the value of the Thread Local Storage variable. sl@0: // sl@0: { sl@0: return LocalThreadData()->DllTls(aHandle, KDllUid_Default); sl@0: } sl@0: sl@0: EXPORT_C TAny* UserSvr::DllTls(TInt aHandle, TInt aDllUid) sl@0: // sl@0: // Return the value of the Thread Local Storage variable. sl@0: // sl@0: { sl@0: return LocalThreadData()->DllTls(aHandle, aDllUid); sl@0: } sl@0: sl@0: #else sl@0: sl@0: EXPORT_C TAny* UserSvr::DllTls(TInt aHandle) sl@0: // sl@0: // Return the value of the Thread Local Storage variable. sl@0: // sl@0: { sl@0: sl@0: return Exec::DllTls(aHandle, KDllUid_Default); sl@0: } sl@0: sl@0: EXPORT_C TAny* UserSvr::DllTls(TInt aHandle, TInt aDllUid) sl@0: // sl@0: // Return the value of the Thread Local Storage variable. sl@0: // sl@0: { sl@0: sl@0: return Exec::DllTls(aHandle, aDllUid); sl@0: } sl@0: sl@0: #endif sl@0: sl@0: EXPORT_C void UserSvr::DllFileName(TInt aHandle, TDes& aFileName) sl@0: // sl@0: // Return the filename of this dll sl@0: // sl@0: { sl@0: TBuf8 n8; sl@0: Exec::DllFileName(aHandle, n8); sl@0: aFileName.Copy(n8); sl@0: } sl@0: sl@0: EXPORT_C TBool UserSvr::TestBootSequence() sl@0: // sl@0: // Is the machine being booted by the test department? sl@0: // sl@0: { sl@0: sl@0: return Exec::HalFunction(EHalGroupPower,EPowerHalTestBootSequence,NULL,NULL); sl@0: } sl@0: sl@0: /** sl@0: Register whether the W/S takes care of turning the screen on sl@0: */ sl@0: EXPORT_C void UserSvr::WsRegisterSwitchOnScreenHandling(TBool aState) sl@0: { sl@0: sl@0: Exec::HalFunction(EHalGroupDisplay,EDisplayHalWsRegisterSwitchOnScreenHandling,(TAny*)aState,NULL); sl@0: } sl@0: sl@0: EXPORT_C void UserSvr::WsSwitchOnScreen() sl@0: // sl@0: // W/S switch on the screen sl@0: // sl@0: { sl@0: sl@0: Exec::HalFunction(EHalGroupDisplay,EDisplayHalWsSwitchOnScreen,NULL,NULL); sl@0: } sl@0: sl@0: sl@0: EXPORT_C TUint32 UserSvr::DebugMask() sl@0: /** sl@0: Return the kernel debug mask at index 0 sl@0: */ sl@0: { sl@0: return Exec::DebugMask(); sl@0: } sl@0: sl@0: sl@0: EXPORT_C TUint32 UserSvr::DebugMask(TUint aIndex) sl@0: /** sl@0: Return the kernel debug mask at the given index position sl@0: sl@0: @param aIndex An index of which 32 bit mask word is to be accessed sl@0: */ sl@0: { sl@0: return Exec::DebugMaskIndex(aIndex); sl@0: } sl@0: sl@0: sl@0: sl@0: EXPORT_C TTrapHandler *User::TrapHandler() sl@0: /** sl@0: Gets a pointer to the current thread's trap handler. sl@0: sl@0: Note that TTrapHandler is an abstract base class; a trap handler must be sl@0: implemented as a derived class. sl@0: sl@0: @return A pointer to the current thread's trap handler, if any. NULL, if no sl@0: pre-existing trap handler is set. sl@0: */ sl@0: { sl@0: sl@0: return GetTrapHandler(); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TTrapHandler *User::SetTrapHandler(TTrapHandler *aHandler) sl@0: /** sl@0: Sets the current thread's trap handler and returns a pointer to any pre-existing sl@0: trap handler. sl@0: sl@0: Pass a NULL pointer to this function to clear the trap handler. sl@0: sl@0: The trap handler works with the TRAP mechanism to handle the effects of a sl@0: leave. sl@0: sl@0: Note that TTrapHandler is an abstract base class; a trap handler must be sl@0: implemented as a derived class. sl@0: sl@0: @param aHandler A pointer to the trap handler which is to be installed as sl@0: the current thread's trap handler. sl@0: sl@0: @return A pointer to the current thread's pre-existing trap handler, if any. sl@0: NULL, if no pre-existing trap handler is set. sl@0: sl@0: @see TRAP sl@0: @see TRAPD sl@0: */ sl@0: { sl@0: sl@0: TTrapHandler* prev; sl@0: #if defined(__USERSIDE_THREAD_DATA__) && defined(__LEAVE_EQUALS_THROW__) sl@0: prev = LocalThreadData()->iTrapHandler; sl@0: #else sl@0: prev = Exec::SetTrapHandler(aHandler); sl@0: #endif sl@0: #ifdef __USERSIDE_THREAD_DATA__ sl@0: LocalThreadData()->iTrapHandler = aHandler; sl@0: #endif sl@0: return prev; sl@0: } sl@0: sl@0: #ifndef __LEAVE_EQUALS_THROW__ sl@0: EXPORT_C TTrapHandler* User::MarkCleanupStack() sl@0: /** sl@0: If there's a TTrapHandler installed marks the cleanup stack and returns sl@0: the TTrapHandler for subsequent use in UnMarkCleanupStack. sl@0: sl@0: Only intended for use in the defintion of TRAP and TRAPD and only when sl@0: User::Leave is defined in terms of THROW. sl@0: sl@0: @return A pointer to the current thread's pre-existing trap handler, if any. sl@0: NULL, if no pre-existing trap handler is set. sl@0: sl@0: @see TRAP sl@0: @see TRAPD sl@0: */ sl@0: { sl@0: return (TTrapHandler*)0; sl@0: } sl@0: sl@0: sl@0: EXPORT_C void User::UnMarkCleanupStack(TTrapHandler* /*aHandler*/) sl@0: /** sl@0: If passed a non-null TTrapHandler unmarks the cleanup stack. sl@0: sl@0: Only intended for use in the defintion of TRAP and TRAPD and only when sl@0: User::Leave is defined in terms of THROW. sl@0: sl@0: @see TRAP sl@0: @see TRAPD sl@0: */ sl@0: {} sl@0: sl@0: #else sl@0: sl@0: EXPORT_C TTrapHandler* User::MarkCleanupStack() sl@0: /** sl@0: If there's a TTrapHandler installed marks the cleanup stack and returns sl@0: the TTrapHandler for subsequent use in UnMarkCleanupStack. sl@0: sl@0: Only intended for use in the defintion of TRAP and TRAPD and only when sl@0: User::Leave is defined in terms of THROW. sl@0: sl@0: @return A pointer to the current thread's pre-existing trap handler, if any. sl@0: NULL, if no pre-existing trap handler is set. sl@0: sl@0: @see TRAP sl@0: @see TRAPD sl@0: */ sl@0: { sl@0: sl@0: TTrapHandler* pH = GetTrapHandler(); sl@0: if (pH) sl@0: pH->Trap(); sl@0: return pH; sl@0: } sl@0: sl@0: EXPORT_C void User::UnMarkCleanupStack(TTrapHandler* aHandler) sl@0: /** sl@0: If passed a non-null TTrapHandler unmarks the cleanup stack. sl@0: sl@0: Only intended for use in the defintion of TRAP and TRAPD and only when sl@0: User::Leave is defined in terms of THROW. sl@0: sl@0: @see TRAP sl@0: @see TRAPD sl@0: */ sl@0: { sl@0: sl@0: if (aHandler) sl@0: aHandler->UnTrap(); sl@0: } sl@0: sl@0: #endif sl@0: sl@0: sl@0: EXPORT_C TInt User::Beep(TInt aFrequency,TTimeIntervalMicroSeconds32 aDuration) sl@0: /** sl@0: Makes a beep tone with a specified frequency and duration. sl@0: sl@0: This function should not be used. It exists to maintain compatibility with sl@0: older versions of Symban OS. sl@0: */ sl@0: { sl@0: sl@0: return Exec::HalFunction(EHalGroupSound,ESoundHalBeep,(TAny*)aFrequency,(TAny*)aDuration.Int()); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: // Unused, exists only for BC reasons sl@0: EXPORT_C TInt UserSvr::HalGet(TInt, TAny*) sl@0: { sl@0: return KErrNotSupported; sl@0: } sl@0: sl@0: // Unused, exists only for BC reasons sl@0: EXPORT_C TInt UserSvr::HalSet(TInt, TAny*) sl@0: { sl@0: return KErrNotSupported; sl@0: } sl@0: sl@0: EXPORT_C TInt UserSvr::HalFunction(TInt aGroup, TInt aFunction, TAny* a1, TAny* a2) sl@0: { sl@0: sl@0: return Exec::HalFunction(aGroup, aFunction, a1, a2); sl@0: } sl@0: sl@0: EXPORT_C TInt UserSvr::HalFunction(TInt aGroup, TInt aFunction, TAny* a1, TAny* a2, TInt aDeviceNumber) sl@0: { sl@0: sl@0: return Exec::HalFunction(aGroup | (aDeviceNumber<<16), aFunction, a1, a2); sl@0: } sl@0: sl@0: /** sl@0: @capability WriteDeviceData sl@0: */ sl@0: EXPORT_C TInt UserSvr::SetMemoryThresholds(TInt aLowThreshold, TInt aGoodThreshold) sl@0: { sl@0: return Exec::SetMemoryThresholds(aLowThreshold,aGoodThreshold); sl@0: } sl@0: sl@0: /** sl@0: @deprecated sl@0: @internalAll sl@0: @return EFalse sl@0: */ sl@0: EXPORT_C TBool UserSvr::IpcV1Available() sl@0: { sl@0: return EFalse; sl@0: } sl@0: sl@0: sl@0: sl@0: EXPORT_C void User::SetDebugMask(TUint32 aVal) sl@0: /** sl@0: Sets the debug mask. sl@0: sl@0: @param aVal A set of bit values as defined in nk_trace.h sl@0: */ sl@0: { sl@0: Exec::SetDebugMask(aVal); sl@0: } sl@0: sl@0: EXPORT_C void User::SetDebugMask(TUint32 aVal, TUint aIndex) sl@0: /** sl@0: Sets the debug mask at the given index sl@0: sl@0: @param aVal A set of bit values as defined in nk_trace.h sl@0: @param aIndex An index of which 32 bit mask word is to be accessed sl@0: */ sl@0: { sl@0: Exec::SetDebugMaskIndex(aVal, aIndex); sl@0: } sl@0: sl@0: sl@0: /** sl@0: Gets machine information. sl@0: sl@0: @publishedPartner sl@0: @deprecated Use HAL::Get() from the HAL library instead. sl@0: */ sl@0: EXPORT_C TInt UserHal::MachineInfo(TDes8& anInfo) sl@0: { sl@0: TInt bufLength=anInfo.MaxLength(); sl@0: __ASSERT_ALWAYS(bufLength==sizeof(TMachineInfoV2) || bufLength==sizeof(TMachineInfoV1),Panic(ETDes8BadDescriptorType)); sl@0: sl@0: // assemble a TMachineInfoV1 buffer sl@0: TMachineInfoV2* info=&((TMachineInfoV2Buf&)anInfo)(); sl@0: // Variant stuff sl@0: TVariantInfoV01Buf infoBuf; sl@0: TInt r = Exec::HalFunction(EHalGroupVariant, EVariantHalVariantInfo, (TAny*)&infoBuf, NULL); sl@0: if (KErrNone != r) return r; // must always be implemented! sl@0: TVariantInfoV01& variantInfo = infoBuf(); sl@0: sl@0: info->iRomVersion=variantInfo.iRomVersion; sl@0: info->iMachineUniqueId=variantInfo.iMachineUniqueId; sl@0: info->iLedCapabilities=variantInfo.iLedCapabilities; sl@0: info->iProcessorClockInKHz=variantInfo.iProcessorClockInKHz; sl@0: info->iSpeedFactor=variantInfo.iSpeedFactor; sl@0: sl@0: // Video driver stuff sl@0: TVideoInfoV01Buf vidinfoBuf; sl@0: r = Exec::HalFunction(EHalGroupDisplay, EDisplayHalCurrentModeInfo, (TAny*)&vidinfoBuf, NULL); sl@0: if (KErrNone == r) sl@0: { sl@0: TVideoInfoV01& vidinfo = vidinfoBuf(); sl@0: info->iDisplaySizeInPixels=vidinfo.iSizeInPixels; sl@0: info->iPhysicalScreenSize=vidinfo.iSizeInTwips; sl@0: } sl@0: else // no display driver sl@0: { sl@0: info->iDisplaySizeInPixels.iWidth=0; sl@0: info->iDisplaySizeInPixels.iHeight=0; sl@0: info->iPhysicalScreenSize.iWidth=0; sl@0: info->iPhysicalScreenSize.iHeight=0; sl@0: } sl@0: TInt colors = 0; sl@0: r = Exec::HalFunction(EHalGroupDisplay, EDisplayHalColors, &colors, NULL); sl@0: info->iMaximumDisplayColors=(KErrNone == r)?colors:0; sl@0: TInt val; sl@0: info->iBacklightPresent= (KErrNone == Exec::HalFunction(EHalGroupDisplay, EDisplayHalBacklightOn, &val, NULL)); sl@0: sl@0: // Pointing device stuff sl@0: TDigitiserInfoV01Buf xyinfoBuf; sl@0: r = Exec::HalFunction(EHalGroupDigitiser, EDigitiserHalXYInfo, (TAny*)&xyinfoBuf, NULL); sl@0: if (KErrNone == r) sl@0: { sl@0: info->iXYInputType=EXYInputPointer; // XY is Digitiser sl@0: TDigitiserInfoV01& xyinfo = xyinfoBuf(); sl@0: info->iXYInputSizeInPixels=xyinfo.iDigitiserSize; sl@0: info->iOffsetToDisplayInPixels=xyinfo.iOffsetToDisplay; sl@0: } sl@0: else sl@0: { sl@0: TMouseInfoV01Buf mouseinfoBuf; sl@0: r = Exec::HalFunction(EHalGroupMouse, EMouseHalMouseInfo, (TAny*)&mouseinfoBuf, NULL); sl@0: if (KErrNone == r) sl@0: { sl@0: info->iXYInputType=EXYInputMouse; // XY is Mouse sl@0: TMouseInfoV01& mouseinfo = mouseinfoBuf(); sl@0: info->iXYInputSizeInPixels=mouseinfo.iMouseAreaSize; sl@0: info->iOffsetToDisplayInPixels=mouseinfo.iOffsetToDisplay; sl@0: } sl@0: else sl@0: { sl@0: info->iXYInputType=EXYInputNone; // no XY sl@0: info->iXYInputSizeInPixels.iWidth=0; sl@0: info->iXYInputSizeInPixels.iHeight=0; sl@0: info->iOffsetToDisplayInPixels.iX=0; sl@0: info->iOffsetToDisplayInPixels.iY=0; sl@0: } sl@0: } sl@0: sl@0: // Keyboard stuff sl@0: TKeyboardInfoV01Buf kbdinfoBuf; sl@0: info->iKeyboardPresent= (KErrNone == Exec::HalFunction(EHalGroupKeyboard, EKeyboardHalKeyboardInfo, (TAny*)&kbdinfoBuf, NULL)); sl@0: sl@0: // Unused, obsolete parameters sl@0: info->iKeyboardId=0; sl@0: info->iDisplayId=0; sl@0: if(bufLength==sizeof(TMachineInfoV2)) sl@0: { sl@0: // assemble a TMachineInfoV2 buffer sl@0: info->iLanguageIndex=0; sl@0: info->iKeyboardIndex=0; sl@0: } sl@0: sl@0: anInfo.SetLength(bufLength); sl@0: sl@0: return KErrNone; sl@0: } sl@0: sl@0: /** sl@0: Gets memory information. sl@0: sl@0: @see HAL::Get() sl@0: sl@0: @publishedPartner sl@0: @deprecated Use HAL::Get() from the HAL library instead with attributes EMemoryRAM, EMemoryRAMFree or EMemoryROM. sl@0: */ sl@0: EXPORT_C TInt UserHal::MemoryInfo(TDes8& anInfo) sl@0: { sl@0: return Exec::HalFunction(EHalGroupKernel,EKernelHalMemoryInfo,(TAny*)&anInfo,NULL); sl@0: } sl@0: sl@0: /** sl@0: Gets ROM configuration information. sl@0: sl@0: @publishedPartner sl@0: @deprecated No replacement. sl@0: */ sl@0: EXPORT_C TInt UserHal::RomInfo(TDes8& anInfo) sl@0: { sl@0: return Exec::HalFunction(EHalGroupKernel,EKernelHalRomInfo,(TAny*)&anInfo,NULL); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Gets drive information. sl@0: sl@0: @param anInfo A package buffer (TPckgBuf) containing a TDriveInfoV1 structure. sl@0: On return, this structure will contain the drive information. sl@0: sl@0: @return KErrNone sl@0: sl@0: @see TDriveInfoV1Buf sl@0: @see TDriveInfoV1 sl@0: @see TPckgBuf sl@0: */ sl@0: EXPORT_C TInt UserHal::DriveInfo(TDes8& anInfo) sl@0: { sl@0: TDriveInfoV1Buf8 anInfo8; sl@0: TInt r = Exec::HalFunction(EHalGroupMedia,EMediaHalDriveInfo,(TAny*)&anInfo8,NULL); sl@0: TDriveInfoV18& driveInfo8 = anInfo8(); sl@0: TDriveInfoV1* driveInfo = NULL; sl@0: switch(((SBuf8*)&anInfo)->length>>KShiftDesType8) //type sl@0: { sl@0: case EPtr: sl@0: driveInfo = &((TPckg&)anInfo)(); sl@0: break; sl@0: case EBuf: sl@0: driveInfo = &((TDriveInfoV1Buf&)anInfo)(); sl@0: break; sl@0: default: sl@0: __ASSERT_ALWAYS(EFalse,Panic(ETDes8BadDescriptorType)); sl@0: } sl@0: sl@0: // A compile time assert to make sure that this function is examined if TDriveInfoV1 sl@0: // structure changes sl@0: extern int TDriveInfoV1_structure_assert[( sl@0: _FOFF(TDriveInfoV1,iRegisteredDriveBitmask)+4 == sizeof(TDriveInfoV1) sl@0: && sl@0: sizeof(TDriveInfoV1) == 816 sl@0: )?1:-1]; sl@0: (void)TDriveInfoV1_structure_assert; sl@0: sl@0: // Set length to size of old EKA1 TDriveInfoV1 (Will Panic if not big enough) sl@0: TInt len = (TUint)_FOFF(TDriveInfoV1,iRegisteredDriveBitmask); sl@0: anInfo.SetLength(len); sl@0: sl@0: // Fill in info for old EKA1 TDriveInfoV1 sl@0: driveInfo->iTotalSupportedDrives = driveInfo8.iTotalSupportedDrives; sl@0: driveInfo->iTotalSockets = driveInfo8.iTotalSockets; sl@0: driveInfo->iRuggedFileSystem = driveInfo8.iRuggedFileSystem; sl@0: TInt index; sl@0: for(index=0;indexiDriveName[index].Copy(driveInfo8.iDriveName[index]); sl@0: for(index=0;indexiSocketName[index].Copy(driveInfo8.iSocketName[index]); sl@0: sl@0: // If anInfo is big enough then set new EKA2 members of TDriveInfoV1 sl@0: if((TUint)anInfo.MaxLength()>=(TUint)sizeof(TDriveInfoV1)) sl@0: { sl@0: anInfo.SetLength(sizeof(TDriveInfoV1)); sl@0: driveInfo->iRegisteredDriveBitmask = driveInfo8.iRegisteredDriveBitmask; sl@0: } sl@0: return r; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Gets the startup reason. sl@0: sl@0: @see HAL::Get() sl@0: sl@0: @publishedPartner sl@0: @deprecated Use HAL::Get() from the HAL library instead with attributes ESystemStartupReason. sl@0: */ sl@0: EXPORT_C TInt UserHal::StartupReason(TMachineStartupType& aReason) sl@0: { sl@0: return Exec::HalFunction(EHalGroupKernel,EKernelHalStartupReason,(TAny*)&aReason,NULL); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Gets the reason why the kernel last faulted. sl@0: sl@0: @param aReason An integer that, on return, contains the reason code describing sl@0: why the kernel faulted. This is the fault number passed sl@0: in a call to Kern::Fault(). sl@0: sl@0: @return KErrNone sl@0: sl@0: @see Kern::Fault() sl@0: */ sl@0: EXPORT_C TInt UserHal::FaultReason(TInt &aReason) sl@0: { sl@0: sl@0: return Exec::HalFunction(EHalGroupKernel,EKernelHalFaultReason,(TAny *)&aReason,NULL); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Gets the exception Id that describes the type of fault when sl@0: the kernel last faulted. sl@0: sl@0: The Id is the value contained in TArmExcInfo::iExcCode. sl@0: sl@0: @param anId An integer that, on return, contains the exception Id. sl@0: sl@0: @return KErrNone sl@0: sl@0: @see TArmExcInfo::iExcCode sl@0: @see TArmExcInfo sl@0: */ sl@0: EXPORT_C TInt UserHal::ExceptionId(TInt &anId) sl@0: { sl@0: sl@0: return Exec::HalFunction(EHalGroupKernel,EKernelHalExceptionId, (TAny *)&anId, NULL); sl@0: } sl@0: sl@0: sl@0: sl@0: /** sl@0: Gets the available exception information that describes the last kernel fault. sl@0: sl@0: @param aInfo A TExcInfo structure that, on return, contains the available sl@0: exception information. sl@0: sl@0: @return KErrNone sl@0: sl@0: @see TExcInfo sl@0: */ sl@0: EXPORT_C TInt UserHal::ExceptionInfo(TExcInfo &aInfo) sl@0: { sl@0: sl@0: return Exec::HalFunction(EHalGroupKernel,EKernelHalExceptionInfo, (TAny *)&aInfo, NULL); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Gets the page size for this device. sl@0: sl@0: @param anId An integer that, on return, contains the page size, in bytes, sl@0: for this device. sl@0: sl@0: @return KErrNone sl@0: */ sl@0: EXPORT_C TInt UserHal::PageSizeInBytes(TInt& aSize) sl@0: { sl@0: sl@0: return Exec::HalFunction(EHalGroupKernel,EKernelHalPageSizeInBytes,(TAny*)&aSize,NULL); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Switches the device off. sl@0: sl@0: @return KErrNone, if successful; KErrPermissionDenied, if the calling process sl@0: has insufficient capability. sl@0: sl@0: @capability PowerMgmt sl@0: */ sl@0: EXPORT_C TInt UserHal::SwitchOff() sl@0: { sl@0: if(!RProcess().HasCapability(ECapabilityPowerMgmt,__PLATSEC_DIAGNOSTIC_STRING("Checked by UserHal::SwitchOff"))) sl@0: return KErrPermissionDenied; sl@0: TInt r = Power::EnableWakeupEvents(EPwStandby); sl@0: if(r!=KErrNone) sl@0: return r; sl@0: TRequestStatus s; sl@0: Power::RequestWakeupEventNotification(s); sl@0: Power::PowerDown(); sl@0: User::WaitForRequest(s); sl@0: return s.Int(); sl@0: // return Exec::HalFunction(EHalGroupPower,EPowerHalSwitchOff,NULL,NULL); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Sets the calibration data for the digitiser (i.e. XY) input device. sl@0: sl@0: @param aCalibration The calibration data. sl@0: sl@0: @return KErrNone, if successful; KErrPermissionDenied, if the calling process sl@0: has insufficient capability. sl@0: sl@0: @see TDigitizerCalibration sl@0: sl@0: @capability WriteDeviceData sl@0: */ sl@0: EXPORT_C TInt UserHal::SetXYInputCalibration(const TDigitizerCalibration& aCalibration) sl@0: { sl@0: return Exec::HalFunction(EHalGroupDigitiser,EDigitiserHalSetXYInputCalibration,(TAny*)&aCalibration,NULL); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Gets the points on the display that the user should point to in order sl@0: to calibrate the digitiser (i.e. XY) input device. sl@0: sl@0: @param aCalibration A TDigitizerCalibration object that, on return, contains sl@0: the appropriate information. sl@0: sl@0: @return KerrNone, if successful; otherwise one of the other system wide sl@0: error codes. sl@0: */ sl@0: EXPORT_C TInt UserHal::CalibrationPoints(TDigitizerCalibration& aCalibration) sl@0: { sl@0: sl@0: return Exec::HalFunction(EHalGroupDigitiser,EDigitiserHalCalibrationPoints,(TAny*)&aCalibration,NULL); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Gets the platform tick period. sl@0: sl@0: @param aTime The tick period in microseconds. sl@0: sl@0: @return KErrNone, if successful; otherwise one of the other system wide sl@0: error codes. sl@0: */ sl@0: EXPORT_C TInt UserHal::TickPeriod(TTimeIntervalMicroSeconds32 &aTime) sl@0: { sl@0: sl@0: return Exec::HalFunction(EHalGroupKernel,EKernelHalTickPeriod,(TAny*)&aTime,NULL); sl@0: } sl@0: sl@0: sl@0: sl@0: /** sl@0: Saves the current digitiser (i.e. XY) input device calibration data. sl@0: sl@0: @return KErrNone, if successful; otherwise one of the other system wide sl@0: error codes, e.g. KErrNotSupported. sl@0: */ sl@0: EXPORT_C TInt UserHal::SaveXYInputCalibration() sl@0: { sl@0: sl@0: return Exec::HalFunction(EHalGroupDigitiser,EDigitiserHalSaveXYInputCalibration,NULL,NULL); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Restores the digitiser (i.e. XY) input device calibration data. sl@0: sl@0: @param aType A TDigitizerCalibration object that, on return, contains sl@0: the calibration data. sl@0: sl@0: @return KErrNone, if successful; KErrPermissionDenied, if the calling process sl@0: has insufficient capability; otherwise one of the other system wide sl@0: error codes, e.g. KErrNotSupported. sl@0: sl@0: @capability WriteDeviceData sl@0: */ sl@0: EXPORT_C TInt UserHal::RestoreXYInputCalibration(TDigitizerCalibrationType aType) sl@0: { sl@0: return Exec::HalFunction(EHalGroupDigitiser,EDigitiserHalRestoreXYInputCalibration,(TAny*)aType,NULL); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Gets the machine configuration. sl@0: sl@0: @param aConfig On return contains the machine configuration data. sl@0: @param aSize On return, contains the size of the data. sl@0: sl@0: @return KErrNone, if sucessful, otherwise one of the other system-wide sl@0: error codes. sl@0: sl@0: @capability ReadDeviceData sl@0: */ sl@0: EXPORT_C TInt User::MachineConfiguration(TDes8& aConfig,TInt& aSize) sl@0: { sl@0: return(Exec::MachineConfiguration(aConfig,aSize)); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TInt RDebug::Print(TRefByValue aFmt,...) sl@0: // sl@0: // Print to the comms port sl@0: // sl@0: { sl@0: sl@0: TestOverflowTruncate overflow; sl@0: // coverity[var_decl] sl@0: VA_LIST list; sl@0: VA_START(list,aFmt); sl@0: TBuf<0x100> buf; sl@0: // coverity[uninit_use_in_call] sl@0: TRAP_IGNORE(buf.AppendFormatList(aFmt,list,&overflow)); // ignore leave in TTimeOverflowLeave::Overflow() sl@0: #ifdef _UNICODE sl@0: TPtr8 p(buf.Collapse()); sl@0: Exec::DebugPrint((TAny*)&p, 0); sl@0: #else sl@0: Exec::DebugPrint((TAny*)&buf, 0); sl@0: #endif sl@0: return 0; sl@0: } sl@0: sl@0: class TestOverflowTruncate8 : public TDes8Overflow sl@0: { sl@0: public: sl@0: virtual void Overflow(TDes8& /*aDes*/) {} sl@0: }; sl@0: sl@0: EXPORT_C void RDebug::Printf(const char* aFmt, ...) sl@0: // sl@0: // Print to the comms port sl@0: // sl@0: { sl@0: sl@0: TestOverflowTruncate8 overflow; sl@0: // coverity[var_decl] sl@0: VA_LIST list; sl@0: VA_START(list,aFmt); sl@0: TPtrC8 fmt((const TText8*)aFmt); sl@0: TBuf8<0x100> buf; sl@0: // coverity[uninit_use_in_call] sl@0: TRAP_IGNORE(buf.AppendFormatList(fmt,list,&overflow)); sl@0: Exec::DebugPrint((TAny*)&buf, 0); sl@0: } sl@0: sl@0: EXPORT_C void RDebug::RawPrint(const TDesC8& aDes) sl@0: { sl@0: Exec::DebugPrint((TAny*)&aDes, 1); sl@0: } sl@0: sl@0: EXPORT_C void RDebug::RawPrint(const TDesC16& aDes) sl@0: // sl@0: // Print to the comms port sl@0: // sl@0: { sl@0: TBuf8<0x100> aDes8; sl@0: if(aDes.Length()>0x100) sl@0: { sl@0: TPtrC ptr(aDes.Ptr(), 0x100); sl@0: aDes8.Copy(ptr); sl@0: } sl@0: else sl@0: aDes8.Copy(aDes); sl@0: Exec::DebugPrint((TAny*)&aDes8, 1); sl@0: } sl@0: sl@0: EXPORT_C TUint32 Math::Random() sl@0: /** sl@0: Gets 32 random bits from the kernel's random pool. sl@0: sl@0: @return The 32 random bits. sl@0: */ sl@0: { sl@0: sl@0: return Exec::MathRandom(); sl@0: } sl@0: sl@0: sl@0: sl@0: EXPORT_C void User::IMB_Range(TAny* aStart, TAny* aEnd) sl@0: /** sl@0: Does the necessary preparations to guarantee correct execution of code in the sl@0: specified virtual address range. sl@0: sl@0: The function assumes that this code has been loaded or modified by user code. sl@0: Calling this function against uncommitted memory region is considered as S/W sl@0: bug and may generate exception on some memory models. sl@0: sl@0: The specified addresses are associated with a user writable code chunk as sl@0: created by RChunk::CreateLocalCode(). sl@0: sl@0: The function cleans the data cache to ensure that written data has been sl@0: committed to main memory and then flushes the instruction cache and branch sl@0: target buffer (BTB) to ensure that the code is loaded from main memory when sl@0: it is executed. sl@0: The Kernel uses the size of the range specified to decide whether to clean/flush sl@0: line-by-line or to simply clean/flush the entire cache. sl@0: sl@0: @param aStart The start virtual address of the region. sl@0: @param aEnd The end virtual address of the region. This location is not within sl@0: the region. sl@0: sl@0: @see RChunk::CreateLocalCode() sl@0: @see UserHeap::ChunkHeap() sl@0: */ sl@0: { sl@0: sl@0: Exec::IMB_Range(aStart,(TUint32)aEnd-(TUint32)aStart); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Sets the specified handle into the specified environment data slot sl@0: for this process. sl@0: sl@0: The APPARC framework (class CApaApplication etc.) uses some of the slots internally, sl@0: so programs that use this framework should ensure that they only use slots available sl@0: for public use. sl@0: sl@0: @param aSlot An index that identifies the environment data slot. sl@0: This is a value relative to zero; sl@0: i.e. 0 is the first item/slot. sl@0: This can range from 0 to 15. sl@0: @param aHandle The handle to be passed to this process. sl@0: sl@0: @return KErrNone, always. sl@0: sl@0: @panic KERN-EXEC 46 if this function is called by a thread running sl@0: in a process that is not the creator of this process, or sl@0: the handle is not local. sl@0: @panic KERN-EXEC 51 if aSlot is negative or is greater than or equal to sl@0: the value of KArgIndex. sl@0: @panic KERN-EXEC 52 if the specified slot is already in use. sl@0: sl@0: @see CApaApplication sl@0: @see CApaCommandLine::EnvironmentSlotForPublicUse() sl@0: */ sl@0: EXPORT_C TInt RProcess::SetParameter(TInt aSlot, RHandleBase aHandle) sl@0: { sl@0: return Exec::ProcessSetHandleParameter(iHandle, aSlot, aHandle.Handle()); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Sets the specified 16-bit descriptor data into the specified environment sl@0: data slot for this process. sl@0: sl@0: The APPARC framework (class CApaApplication etc.) uses some of the slots internally, sl@0: so programs that use this framework should ensure that they only use slots available sl@0: for public use. sl@0: sl@0: @param aSlot An index that identifies the environment data slot. sl@0: This is a value relative to zero; sl@0: i.e. 0 is the first item/slot. sl@0: This can range from 0 to 15. sl@0: @param aDes The 16-bit descriptor containing data be passed to this process. sl@0: sl@0: @return KErrNone, if successful, otherwise one of the other system sl@0: wide error codes. sl@0: sl@0: @panic KERN-EXEC 46 if this function is called by a thread running sl@0: in a process that is not the creator of this process. sl@0: @panic KERN-EXEC 51 if aSlot is negative or is greater than or equal to sl@0: the value of KArgIndex. sl@0: @panic KERN-EXEC 52 if the specified slot is already in use. sl@0: @panic KERN-EXEC 53 if the length of data passed is negative. sl@0: sl@0: @see CApaApplication sl@0: @see CApaCommandLine::EnvironmentSlotForPublicUse() sl@0: */ sl@0: EXPORT_C TInt RProcess::SetParameter(TInt aSlot, const TDesC16& aDes) sl@0: { sl@0: return Exec::ProcessSetDataParameter(iHandle, aSlot, (const TUint8*)aDes.Ptr(), 2*aDes.Length()); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Sets the specified 8-bit descriptor data into the specified environment sl@0: data slot for this process. sl@0: sl@0: The APPARC framework (class CApaApplication etc.) uses some of the slots internally, sl@0: so programs that use this framework should ensure that they only use slots available sl@0: for public use. sl@0: sl@0: @param aSlot An index that identifies the environment data slot. sl@0: This is a value relative to zero; sl@0: i.e. 0 is the first item/slot. sl@0: This can range from 0 to 15. sl@0: @param aDes The 8-bit descriptor containing data be passed to this process. sl@0: sl@0: @return KErrNone, if successful, otherwise one of the other system sl@0: wide error codes. sl@0: sl@0: @panic KERN-EXEC 46 if this function is called by a thread running sl@0: in a process that is not the creator of this process. sl@0: @panic KERN-EXEC 51 if aSlot is negative or is greater than or equal to sl@0: the value of KArgIndex. sl@0: @panic KERN-EXEC 52 if the specified slot is already in use. sl@0: @panic KERN-EXEC 53 if the length of data passed is negative. sl@0: sl@0: @see CApaApplication sl@0: @see CApaCommandLine::EnvironmentSlotForPublicUse() sl@0: */ sl@0: EXPORT_C TInt RProcess::SetParameter(TInt aSlot, const TDesC8& aDes) sl@0: { sl@0: return Exec::ProcessSetDataParameter(iHandle, aSlot, aDes.Ptr(), aDes.Length()); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Sets the specfied sub-session into the specified environment sl@0: data slot for this process. sl@0: sl@0: The APPARC framework (class CApaApplication etc.) uses some of the slots internally, sl@0: so programs that use this framework should ensure that they only use slots available sl@0: for public use. sl@0: sl@0: @param aSlot An index that identifies the environment data slot. sl@0: This is a value relative to zero; sl@0: i.e. 0 is the first item/slot. sl@0: This can range from 0 to 15. sl@0: @param aSession The sub-session. sl@0: sl@0: @return KErrNone, if successful, otherwise one of the other system sl@0: wide error codes. sl@0: sl@0: @panic KERN-EXEC 46 if this function is called by a thread running sl@0: in a process that is not the creator of this process. sl@0: @panic KERN-EXEC 51 if aSlot is negative or is greater than or equal to sl@0: the value of KArgIndex. sl@0: @panic KERN-EXEC 52 if the specified slot is already in use. sl@0: @panic KERN-EXEC 53 if the length of data passed is negative. sl@0: sl@0: @see CApaApplication sl@0: @see CApaCommandLine::EnvironmentSlotForPublicUse() sl@0: */ sl@0: EXPORT_C TInt RProcess::SetParameter(TInt aSlot, const RSubSessionBase& aSession) sl@0: { sl@0: TInt handle = aSession.SubSessionHandle(); sl@0: return Exec::ProcessSetDataParameter(iHandle, aSlot, (const TUint8*)&handle, sizeof(handle)); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Sets the specfied integer value into the specified environment sl@0: data slot for this process. sl@0: sl@0: The APPARC framework (class CApaApplication etc.) uses some of the slots internally, sl@0: so programs that use this framework should ensure that they only use slots available sl@0: for public use. sl@0: sl@0: @param aSlot An index that identifies the environment data slot. sl@0: This is a value relative to zero; sl@0: i.e. 0 is the first item/slot. sl@0: This can range from 0 to 15. sl@0: @param aData The integer value. sl@0: sl@0: @return KErrNone, if successful, otherwise one of the other system sl@0: wide error codes. sl@0: sl@0: @panic KERN-EXEC 46 if this function is called by a thread running sl@0: in a process that is not the creator of this process. sl@0: @panic KERN-EXEC 51 if aSlot is negative or is greater than or equal to sl@0: the value of KArgIndex. sl@0: @panic KERN-EXEC 52 if the specified slot is already in use. sl@0: @panic KERN-EXEC 53 if the length of data passed is negative. sl@0: sl@0: @see CApaApplication sl@0: @see CApaCommandLine::EnvironmentSlotForPublicUse() sl@0: */ sl@0: EXPORT_C TInt RProcess::SetParameter(TInt aSlot, TInt aData) sl@0: { sl@0: return Exec::ProcessSetDataParameter(iHandle, aSlot, (TUint8*)&aData, sizeof(aData)); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TInt User::GetTIntParameter(TInt aSlot, TInt& aData) sl@0: /** sl@0: Gets the specified environment data item belonging to the sl@0: current process; this is assumed to be a 32 bit value. sl@0: sl@0: Environment data may be stored in the process and is passed to a child process sl@0: on creation of that child process. sl@0: sl@0: On successful return from this function, the data item is deleted from sl@0: the process. sl@0: sl@0: @param aSlot An index that identifies the data item. sl@0: This is an index whose value is relative to zero; sl@0: i.e. 0 is the first item/slot. sl@0: This can range from 0 to 15, i.e. there are 16 slots. sl@0: sl@0: @param aData On sucessful return, contains the environment data item. sl@0: sl@0: @return KErrNone, if successful; sl@0: KErrNotFound, if there is no data; sl@0: KErrArgument, if the data is not binary data, or the data item in the sl@0: process is longer than 32 bits. sl@0: sl@0: @panic KERN-EXEC 51, if aSlot is negative or is greater than or equal to 16. sl@0: */ sl@0: { sl@0: TInt ret = Exec::ProcessGetDataParameter(aSlot, (TUint8*)&aData, sizeof(TInt)); sl@0: if (ret < 0) sl@0: return ret; sl@0: return KErrNone; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TInt User::ParameterLength(TInt aSlot) sl@0: /** sl@0: Gets the length of the specified item of environment data belonging to the sl@0: current process. sl@0: sl@0: Environment data may be stored in the process and is passed to a child process sl@0: on creation of that child process. sl@0: sl@0: @param aSlot An index that identifies the data item whose length is to be sl@0: retrieved. This is an index whose value is relative to zero; sl@0: i.e. 0 is the first item/slot. sl@0: This can range from 0 to 15, i.e. there are 16 slots. sl@0: sl@0: @return KErrNotFound, if there is no data; sl@0: KErrArgument, if the data is not binary data; sl@0: The length of the data item. sl@0: sl@0: @panic KERN-EXEC 51, if aSlot is negative or is greater than or equal to 16. sl@0: */ sl@0: { sl@0: TInt ret = Exec::ProcessDataParameterLength(aSlot); sl@0: return ret; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TInt User::GetDesParameter(TInt aSlot, TDes8& aDes) sl@0: /** sl@0: Gets the specified environment data item belonging to the sl@0: current process; this is assumed to be an 8-bit descriptor. sl@0: sl@0: Environment data may be stored in the process and is passed to a child process sl@0: on creation of that child process. sl@0: sl@0: On successful return from this function, the data item is deleted from sl@0: the process. sl@0: sl@0: @param aSlot An index that identifies the data item. sl@0: This is an index whose value is relative to zero; sl@0: i.e. 0 is the first item/slot. sl@0: This can range from 0 to 15, i.e. there are 16 slots. sl@0: sl@0: @param aDes On sucessful return, contains the environment data item; the sl@0: length of the descriptor is set to the length of the data item. sl@0: sl@0: @return KErrNone, if successful; sl@0: KErrNotFound, if there is no data; sl@0: KErrArgument, if the data is not binary data, or the data item in the sl@0: process is longer than the maximum length of aDes. sl@0: sl@0: @panic KERN-EXEC 51, if aSlot is negative or is greater than or equal to 16. sl@0: */ sl@0: { sl@0: TInt ret = Exec::ProcessGetDataParameter(aSlot, (TUint8*)aDes.Ptr(), aDes.MaxLength()); sl@0: if (ret < 0) sl@0: return ret; sl@0: aDes.SetLength(ret); sl@0: return KErrNone; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C TInt User::GetDesParameter(TInt aSlot, TDes16& aDes) sl@0: /** sl@0: Gets the specified environment data item belonging to the sl@0: current process; this is assumed to be an 16-bit descriptor. sl@0: sl@0: Environment data may be stored in the process and is passed to a child process sl@0: on creation of that child process. sl@0: sl@0: On successful return from this function, the data item is deleted from sl@0: the process. sl@0: sl@0: @param aSlot An index that identifies the data item. sl@0: This is an index whose value is relative to zero; sl@0: i.e. 0 is the first item/slot. sl@0: This can range from 0 to 15, i.e. there are 16 slots. sl@0: sl@0: @param aDes On sucessful return, contains the environment data item; the sl@0: length of the descriptor is set to the length of the data item. sl@0: sl@0: @return KErrNone, if successful; sl@0: KErrNotFound, if there is no data; sl@0: KErrArgument, if the data is not binary data, or the data item in the sl@0: process is longer than the maximum length of aDes. sl@0: sl@0: @panic KERN-EXEC 51, if aSlot is negative or is greater than or equal to 16. sl@0: */ sl@0: { sl@0: TInt ret = Exec::ProcessGetDataParameter(aSlot, (TUint8*)aDes.Ptr(), 2*aDes.MaxLength()); sl@0: if (ret < 0) sl@0: return ret; sl@0: aDes.SetLength(ret/2); sl@0: return KErrNone; sl@0: } sl@0: sl@0: /** sl@0: Gets the linear address of the exception descriptor for the code module in which sl@0: a specified code address resides. sl@0: sl@0: @param aCodeAddress The code address in question. sl@0: @return The address of the exception descriptor, or zero if there is none. sl@0: sl@0: */ sl@0: EXPORT_C TLinAddr UserSvr::ExceptionDescriptor(TLinAddr aCodeAddress) sl@0: { sl@0: return Exec::ExceptionDescriptor(aCodeAddress); sl@0: } sl@0: sl@0: EXPORT_C TInt User::SetFloatingPointMode(TFloatingPointMode aMode, TFloatingPointRoundingMode aRoundingMode) sl@0: /** sl@0: Sets the hardware floating point mode for the current thread. This does not affect sl@0: software floating point calculations. The rounding mode can also be set. New threads created sl@0: by this thread will inherit the mode, thus to set the mode for a whole process, call this sl@0: method before you create any new threads. sl@0: sl@0: @param aMode The floating point calculation mode to use. sl@0: @param aRoundingMode The floating point rounding mode to use, defaults to nearest. sl@0: sl@0: @return KErrNone if successful, KErrNotSupported if the hardware does not support the sl@0: chosen mode, or there is no floating point hardware present. sl@0: sl@0: @see TFloatingPointMode sl@0: @see TFloatingPointRoundingMode sl@0: */ sl@0: { sl@0: return(Exec::SetFloatingPointMode(aMode, aRoundingMode)); sl@0: } sl@0: sl@0: sl@0: EXPORT_C TUint32 E32Loader::PagingPolicy() sl@0: /** sl@0: Accessor function returns the code paging policy, as defined at ROM build time. sl@0: sl@0: @return Code paging policy only. This function applies sl@0: EKernelConfigCodePagingPolicyMask to the config flags sl@0: before returning the value. sl@0: */ sl@0: { sl@0: return Exec::KernelConfigFlags() & EKernelConfigCodePagingPolicyMask; sl@0: } sl@0: sl@0: sl@0: /** Queue a notifier to detect system idle sl@0: sl@0: @internalTechnology sl@0: @prototype sl@0: */ sl@0: EXPORT_C void User::NotifyOnIdle(TRequestStatus& aStatus) sl@0: { sl@0: aStatus = KRequestPending; sl@0: Exec::NotifyOnIdle(&aStatus); sl@0: } sl@0: sl@0: sl@0: /** Cancel a miscellaneous notification requested by this thread sl@0: sl@0: Cancels a currently outstanding notification for system idle or object sl@0: deletion. sl@0: sl@0: @internalTechnology sl@0: @prototype sl@0: */ sl@0: EXPORT_C void User::CancelMiscNotifier(TRequestStatus& aStatus) sl@0: { sl@0: Exec::CancelMiscNotifier(&aStatus); sl@0: } sl@0: sl@0: sl@0: /** Queue a notifier to detect destruction of this object sl@0: sl@0: To cancel the notifier, use User::CancelMiscNotifier(). sl@0: sl@0: @internalTechnology sl@0: @prototype sl@0: */ sl@0: EXPORT_C void RHandleBase::NotifyDestruction(TRequestStatus& aStatus) sl@0: { sl@0: aStatus = KRequestPending; sl@0: Exec::NotifyObjectDestruction(iHandle, &aStatus); sl@0: } sl@0: