Update contrib.
1 // Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32\euser\us_exec.cpp
20 #include <e32des8_private.h>
23 #include <videodriver.h>
24 #include "CompareImp.h"
25 #include <e32atomics.h>
27 #include "locmapping.h"
30 #pragma setlocale("english")
34 _LIT(KLitOpeningBracket, "(");
35 _LIT(KLitMinusSign, "-");
36 _LIT(KLitZeroPad, "0");
38 #ifdef SYMBIAN_DISTINCT_LOCALE_MODEL
39 _LIT(KFindLan, "elocl_lan.");
40 _LIT(KFindReg, "elocl_reg.");
41 _LIT(KFindCol, "elocl_col.");
45 // Private use area ranges of printable/non-printable characters.
46 // This is a sorted list of numbers indicating the ranges in which characters
47 // are printable and non-printable. The elements 0, 2, 4... are the first
48 // characters of printable ranges and The elements 1, 3, 5... are the first
49 // characters of non-printable ranges
50 // We will assume that anything in the End User Sub-area is printable.
51 static const TInt PUAPrintableRanges[] =
53 0xE000, 0xF6D9, // End user area + unassigned corporate use area
54 0xF6DB, 0xF6DC, // Replacement for character not in font
55 0xF6DE, 0xF700, // various EIKON and Agenda symbols
56 0x10000, KMaxTInt // everything else printable
59 static TBool IsPUAPrintable(TInt aChar)
61 if (0x110000 <= aChar)
62 return 0; // non-characters not printable
64 while (PUAPrintableRanges[i] <= aChar)
72 EXPORT_C TBool User::JustInTime()
74 Tests whether just-in-time debugging is on or off.
76 The function is used by the Kernel, on the Emulator, to decide whether to do
77 just-in-time debugging for panics. The function applies to the current process.
79 Unless overridden by calling User::SetJustInTime(EFalse), just-in-time debugging
82 @return True, if just-in-time debugging is on. False otherwise.
83 @see RProcess::JustInTime
87 return RProcess().JustInTime();
93 EXPORT_C void User::SetJustInTime(const TBool aBoolean)
95 Sets just-in-time debugging for this process on or off.
97 While the function can be called by code running on both the Emulator and ARM,
98 it only has an effect on the Emulator. Turning just-in-time debugging off
99 prevents the debug Emulator closing down when a panic occurs.
101 By default, just-in-time debugging is on.
103 Note that the emulator handles panics in the nomal manner, i.e. by killing
106 @param aBoolean ETrue, if just-in-time debugging is to be set on. EFalse,
107 if just-in-time debugging is to be set off.
108 EFalse causes _asm 3 calls to be disabled.
109 @see RProcess::SetJustInTime
113 RProcess().SetJustInTime(aBoolean);
117 extern const LCharSet* GetLocaleDefaultCharSet();
118 extern const LCharSet* GetLocalePreferredCharSet();
120 // Convert to folded.
121 EXPORT_C TUint User::Fold(TUint aChar)
125 Folds the specified character.
127 Folding converts the character to a form which can be used in tolerant
128 comparisons without control over the operations performed. Tolerant comparisons
129 are those which ignore character differences like case and accents.
131 The result of folding a character depends on the locale and on whether this
132 is a UNICODE build or not.
134 Note that for a non-UNICODE build, if the binary value of the character aChar
135 is greater than or equal to 0x100, then the character returned is the same as
136 the character passed to the function.
138 @param aChar The character to be folded.
140 @return The folded character.
145 // ASCII chars excluding 'i's can be handled by naive folding
146 if (aChar < 0x80 && aChar != 'I')
147 return (aChar >= 'A' && aChar <= 'Z') ? (aChar | 0x0020) : aChar;
149 return TUnicode(aChar).Fold(TChar::EFoldStandard,GetLocaleCharSet()->iCharDataSet);
155 // Convert to a folded version, specifying the folding methods.
156 EXPORT_C TUint User::Fold(TUint aChar,TInt aFlags)
158 Folds the character according to a specified folding method.
160 @param aChar The character to be folded.
161 @param aFlags A set of flags defining the folding method. They are:
163 TChar::EFoldCase, convert characters to their lower case form,
166 TChar::EFoldAccents, strip accents;
168 TChar::EFoldDigits, convert digits representing values 0..9 to
171 TChar::EFoldSpaces, convert all spaces (ordinary, fixed-width,
172 ideographic, etc.) to ' ';
174 TChar::EFoldKana, convert hiragana to katakana;
176 TChar::EFoldWidth, fold full width and half width variants to
177 their standard forms;
179 TChar::EFoldAll, use all of the above folding methods.
181 @return The folded character.
185 return TUnicode(aChar).Fold(aFlags,GetLocaleCharSet()->iCharDataSet);
191 // Convert to collated.
192 EXPORT_C TUint User::Collate(TUint aChar)
194 Converts the character to its collated form.
196 Collating is the process of removing differences between characters that are
197 deemed unimportant for the purposes of ordering characters. The result of
198 the conversion depends on the locale and on whether this is a UNICODE build
201 Note that for a non UNICODE build, if the binary value of the character aChar
202 is greater than or equal to 0x100, then the character returned is the same as
203 the character passed to the function.
205 @param aChar The character to be folded.
207 @return The converted character.
210 return TUnicode(aChar).Fold(TChar::EFoldStandard,GetLocaleCharSet()->iCharDataSet);
216 // Convert to lower case.
217 EXPORT_C TUint User::LowerCase(TUint aChar)
219 Converts the specified character to lower case.
221 The result of the conversion depends on the locale and on whether this is
222 a UNICODE build or not.
224 Note that for a non-UNICODE build, if the binary value of the character
225 aChar is greater than or equal to 0x100, then the character returned is
226 the same as the character passed to the function.
228 @param aChar The character to be converted to lower case.
230 @return The lower case character.
233 // ASCII chars excluding 'i's can be handled by naive folding
234 if (aChar < 0x80 && aChar != 'I')
235 return (aChar >= 'A' && aChar <= 'Z') ? (aChar | 0x0020) : aChar;
237 return TUnicode(aChar).GetLowerCase(GetLocaleCharSet()->iCharDataSet);
243 // Convert to upper case.
244 EXPORT_C TUint User::UpperCase(TUint aChar)
246 Converts a specified character to upper case.
248 The result of the conversion depends on the locale and on whether this is
249 a UNICODE build or not.
251 Note that for a non UNICODE build, if the binary value of the character aChar
252 is greater than or equal to 0x100, then the character returned is the same as
253 the character passed to the function.
255 @param aChar The character to be converted to upper case.
257 @return The upper case character.
260 // ASCII chars excluding 'i's can be handled by naive folding
261 if (aChar < 0x80 && aChar != 'i')
262 return (aChar >= 'a' && aChar <= 'z') ? (aChar & ~0x0020) : aChar;
264 return TUnicode(aChar).GetUpperCase(GetLocaleCharSet()->iCharDataSet);
270 // Return the title case version of a character, which is the case of composite characters like Dz.
271 EXPORT_C TUint User::TitleCase(TUint aChar)
273 Converts a specified character to its title case version.
275 @param aChar The character to be converted.
277 @return The converted character.
280 return TUnicode(aChar).GetTitleCase(GetLocaleCharSet()->iCharDataSet);
286 EXPORT_C TUint TChar::GetUpperCase() const
288 Gets the character value after conversion to uppercase or the character's
289 own value, if no uppercase form exists.
291 The character object itself is not changed.
293 @return The character value after conversion to uppercase.
296 return User::UpperCase(iChar);
302 EXPORT_C TUint TChar::GetLowerCase() const
304 Gets the character value after conversion to lowercase or the character's
305 own value, if no lowercase form exists.
307 The character object itself is not changed.
309 @return The character value after conversion to lowercase.
312 return User::LowerCase(iChar);
318 EXPORT_C TUint TChar::GetTitleCase() const
320 Gets the character value after conversion to titlecase or the character's
321 own value, if no titlecase form exists.
323 The titlecase form of a character is identical to its uppercase form unless
324 a specific titlecase form exists.
326 @return The value of the character value after conversion to titlecase form.
329 return User::TitleCase(iChar);
335 EXPORT_C TBool TChar::IsLower() const
337 Tests whether the character is lowercase.
339 @return True, if the character is lowercase; false, otherwise.
342 return GetCategory() == TChar::ELlCategory;
348 EXPORT_C TBool TChar::IsUpper() const
350 Tests whether the character is uppercase.
352 @return True, if the character is uppercase; false, otherwise.
355 return GetCategory() == TChar::ELuCategory;
360 // Return TRUE if the character is title case, which is the case of composite characters like Dz.
361 EXPORT_C TBool TChar::IsTitle() const
363 Tests whether this character is in titlecase.
365 @return True, if this character is in titlecase; false, otherwise.
368 return GetCategory() == TChar::ELtCategory;
374 EXPORT_C TBool TChar::IsAlpha() const
376 Tests whether the character is alphabetic.
378 For Unicode, the function returns TRUE for all letters, including those from
379 syllabaries and ideographic scripts. The function returns FALSE for letter-like
380 characters that are in fact diacritics. Specifically, the function returns
381 TRUE for categories: ELuCategory, ELtCategory, ELlCategory, and ELoCategory;
382 it returns FALSE for all other categories including ELmCategory.
384 @return True, if the character is alphabetic; false, otherwise.
386 @see TChar::IsAlphaDigit()
387 @see TChar::TCategory
390 return GetCategory() <= TChar::EMaxLetterOrLetterModifierCategory;
396 EXPORT_C TBool TChar::IsDigit() const
398 Tests whether the character is a standard decimal digit.
400 For Unicode, this function returns TRUE only
401 for the digits '0'...'9' (U+0030...U+0039),
402 not for other digits in scripts like Arabic, Tamil, etc.
404 @return True, if the character is a standard decimal digit; false, otherwise.
406 @see TChar::GetCategory()
407 @see TChar::GetNumericValue
410 return iChar >= '0' && iChar <= '9'; // standard decimal digits only
416 EXPORT_C TBool TChar::IsAlphaDigit() const
418 Tests whether the character is alphabetic or a decimal digit.
420 It is identical to (IsAlpha()||IsDigit()).
422 @return True, if the character is alphabetic or a decimal digit; false, otherwise.
424 @see TChar::IsAlpha()
425 @see TChar::IsDigit()
428 TInt cat = (TInt)GetCategory();
429 return cat <= TChar::EMaxLetterOrLetterModifierCategory ||
430 (iChar < 256 && cat == TChar::ENdCategory); // accept any letter, but accept only standard digits
436 EXPORT_C TBool TChar::IsHexDigit() const
438 Tests whether the character is a hexadecimal digit (0-9, a-f, A-F).
440 @return True, if the character is a hexadecimal digit; false, otherwise.
444 The following code will actually run faster than the non-Unicode version, which needs
445 to call the Exec function.
447 return iChar <= 'f' && iChar >= '0' &&
448 (iChar <= '9' || iChar >= 'a' || (iChar >= 'A' && iChar <= 'F')); // only standard hex digits will do
454 EXPORT_C TBool TChar::IsSpace() const
456 Tests whether the character is a white space character.
458 White space includes spaces, tabs and separators.
460 For Unicode, the function returns TRUE for all characters in the categories:
461 EZsCategory, EZlCategory and EZpCategory, and also for the characters 0x0009
462 (horizontal tab), 0x000A (linefeed), 0x000B (vertical tab), 0x000C (form feed),
463 and 0x000D (carriage return).
465 @return True, if the character is white space; false, otherwise.
467 @see TChar::TCategory
471 The Unicode characters 0009 .. 000D (tab, linefeed, vertical tab, formfeed, carriage return)
472 have the category Cc (control); however, we want to avoid breaking traditional programs
473 by getting IsSpace() to return TRUE for them.
475 return (iChar <= 0x000D && iChar >= 0x0009) ||
476 (GetCategory() & 0xF0) == TChar::ESeparatorGroup;
482 EXPORT_C TBool TChar::IsPunctuation() const
484 Tests whether the character is a punctuation character.
486 For Unicode, punctuation characters are any character in the categories:
487 EPcCategory, EPdCategory, EPsCategory, EPeCategory, EPiCategory,
488 EPfCategory, EPoCategory.
490 @return True, if the character is punctuation; false, otherwise.
492 @see TChar::TCategory
495 return (GetCategory() & 0xF0) == TChar::EPunctuationGroup;
501 EXPORT_C TBool TChar::IsGraph() const
503 Tests whether the character is a graphic character.
505 For Unicode, graphic characters include printable characters but not the space
506 character. Specifically, graphic characters are any character except those
507 in categories: EZsCategory,EZlCategory,EZpCategory, ECcCategory,ECfCategory,
508 ECsCategory, ECoCategory, and ,ECnCategory.
510 Note that for ISO Latin-1, all alphanumeric and punctuation characters are
513 @return True, if the character is a graphic character; false, otherwise.
515 @see TChar::TCategory
518 TUint type = TUnicode(iChar).GetCategory(0);
519 return type <= TChar::EMaxGraphicCategory ||
520 (type == TChar::ECoCategory && IsPUAPrintable(iChar));
526 EXPORT_C TBool TChar::IsPrint() const
528 Tests whether the character is a printable character.
530 For Unicode, printable characters are any character except those in categories:
531 ECcCategory, ECfCategory, ECsCategory, ECoCategory and ECnCategory.
533 Note that for ISO Latin-1, all alphanumeric and punctuation characters, plus
534 space, are printable.
536 @return True, if the character is printable; false, otherwise.
538 @see TChar::TCategory
541 TUint type = TUnicode(iChar).GetCategory(0);
542 return type <= TChar::EMaxPrintableCategory ||
543 (type == TChar::ECoCategory && IsPUAPrintable(iChar));
549 EXPORT_C TBool TChar::IsControl() const
551 Tests whether the character is a control character.
553 For Unicode, the function returns TRUE for all characters in the categories:
554 ECcCategory, ECfCategory, ECsCategory, ECoCategory and ECnCategoryCc.
556 @return True, if the character is a control character; false, otherwise.
558 @see TChar::TCategory
561 return GetCategory() == TChar::ECcCategory;
567 EXPORT_C TBool TChar::IsAssigned() const
569 Tests whether this character has an assigned meaning in the Unicode encoding.
571 All characters outside the range 0x0000 - 0xFFFF are unassigned and there
572 are also many unassigned characters within the Unicode range.
574 Locales can change the assigned/unassigned status of characters. This means
575 that the precise behaviour of this function is locale-dependent.
577 @return True, if this character has an assigned meaning; false, otherwise.
580 return GetCategory() <= TChar::EMaxAssignedCategory;
586 EXPORT_C void TChar::GetInfo(TCharInfo& aInfo) const
588 Gets this character;s standard category information.
590 This includes everything except its CJK width and decomposition, if any.
592 @param aInfo On return, contains the character's standard category information.
595 TUnicode(iChar).GetInfo(aInfo,GetLocaleCharSet()->iCharDataSet);
601 EXPORT_C TChar::TCategory TChar::GetCategory() const
603 Gets this character's Unicode category.
605 @return This character's Unicode category.
608 //for unicode non private user area just use the default charset
609 if (iChar>=0xE000 && iChar<=0xF8FF)
610 return TUnicode(iChar).GetCategory(GetLocaleCharSet()->iCharDataSet);
612 return TUnicode(iChar).GetCategory(GetLocaleDefaultCharSet()->iCharDataSet);
618 EXPORT_C TChar::TBdCategory TChar::GetBdCategory() const
620 Gets the bi-directional category of a character.
622 For more information on the bi-directional algorithm, see Unicode Technical
623 Report No. 9 available at: http://www.unicode.org/unicode/reports/tr9/.
625 @return The character's bi-directional category.
628 return TUnicode(iChar).GetBdCategory(GetLocaleCharSet()->iCharDataSet);
634 EXPORT_C TInt TChar::GetCombiningClass() const
636 Gets this character's combining class.
638 Note that diacritics and other combining characters have non-zero combining
641 @return The combining class.
644 //for unicode non private user area just use the default charset
645 if (iChar>=0xE000 && iChar<=0xF8FF)
646 return TUnicode(iChar).GetCombiningClass(GetLocaleCharSet()->iCharDataSet);
648 return TUnicode(iChar).GetCombiningClass(GetLocaleDefaultCharSet()->iCharDataSet);
654 EXPORT_C TBool TChar::IsMirrored() const
656 Tests whether this character has the mirrored property.
658 Mirrored characters, like ( ) [ ] < >, change direction according to the
659 directionality of the surrounding characters. For example, an opening
660 parenthesis 'faces right' in Hebrew or Arabic, and to say that 2 < 3 you would
661 have to say that 3 > 2, where the '>' is, in this example, a less-than sign to
662 be read right-to-left.
664 @return True, if this character has the mirrored property; false, otherwise.
667 return TUnicode(iChar).IsMirrored(GetLocaleCharSet()->iCharDataSet);
673 EXPORT_C TInt TChar::GetNumericValue() const
675 Gets the integer numeric value of this character.
677 Numeric values need not be in the range 0..9; the Unicode character set
678 includes various other numeric characters such as the Roman and Tamil numerals
681 @return The numeric value: -1 if the character has no integer numeric
682 value,-2 if the character has a fractional numeric value.
685 return TUnicode(iChar).GetNumericValue(GetLocaleCharSet()->iCharDataSet);
691 EXPORT_C TChar::TCjkWidth TChar::GetCjkWidth() const
693 Gets the Chinese, Japanese, Korean (CJK) notional width.
695 Some display systems used in East Asia display characters on a grid of
696 fixed-width character cells like the standard MSDOS display mode.
698 Some characters, e.g. the Japanese katakana syllabary, take up a single
699 character cell and some characters, e.g., kanji, Chinese characters used in
700 Japanese, take up two. These are called half-width and full-width characters.
701 This property is fixed and cannot be overridden for particular locales.
703 For more information on returned widths, see Unicode Technical Report 11 on
704 East Asian Width available at: http://www.unicode.org/unicode/reports/tr11/
706 @return The notional width of an east Asian character.
709 return TUnicode(iChar).GetCjkWidth();
716 Composes a string of Unicode characters to produce a single character result.
718 For example, 0061 ('a') and 030A (combining ring above) compose to give 00E5
719 ('a' with ring above).
721 A canonical decomposition is a relationship between a string of characters -
722 usually a base character and one or more diacritics - and a composed character.
723 The Unicode standard requires that compliant software treats composed
724 characters identically with their canonical decompositions. The mappings used
725 by these functions are fixed and cannot be overridden for particular locales.
727 @param aResult If successful, the composed character value. If unsuccessful,
728 this value contains 0xFFFF.
729 @param aSource String of source Unicode characters.
731 @return True, if the compose operation is successful in combining the entire
732 sequence of characters in the descriptor into a single compound
733 character; false, otherwise.
736 EXPORT_C TBool TChar::Compose(TUint& aResult,const TDesC16& aSource)
739 if(aSource.Length() > 0)
742 if(::CombineAsMuchAsPossible(aSource, combined) == aSource.Length())
744 aResult = (TUint)combined;
755 Maps this character to its maximal canonical decomposition.
757 For example, 01E1 ('a' with dot above and macron) decomposes into 0061 ('a')
758 0307 (dot) and 0304 (macron).
760 Note that this function is used during collation, as performed by
761 the Mem::CompareC() function, to convert the compared strings to their maximal
762 canonical decompositions.
764 @param aResult If successful, the descriptor represents the canonical decomposition
765 of this character. If unsuccessful, the descriptor is empty.
767 @return True if decomposition is successful; false, otherwise.
770 @see TChar::Compose()
772 EXPORT_C TBool TChar::Decompose(TPtrC16& aResult) const
774 return ::DecomposeChar(iChar, aResult);
780 EXPORT_C TInt TFindChunk::Next(TFullName &aResult)
782 Finds the full name of the next chunk which matches the match pattern.
784 @param aResult A reference to a TBuf descriptor with a defined maximum length.
785 If a matching chunk is found, its full name is set into
787 If no matching chunk is found, the descriptor length is set
790 @return KErrNone, if a matching chunk is found;
791 KErrNotFound otherwise.
794 return NextObject(aResult,EChunk);
801 EXPORT_C TUint8 * RChunk::Base() const
803 Gets a pointer to the base of the chunk's reserved region.
805 @return A pointer to the base of the chunk's reserved region.
809 return(Exec::ChunkBase(iHandle));
815 EXPORT_C TInt RChunk::Size() const
817 Gets the current size of this chunk's committed region.
819 @return The size of the chunk's committed region.
823 return(Exec::ChunkSize(iHandle));
829 EXPORT_C TInt RChunk::Bottom() const
831 Gets the offset of the bottom of the double ended chunk's committed region
832 from the base of the chunk's reserved region.
834 Note that the lowest valid address in a double ended chunk is the sum of the
835 base of the chunk's reserved region plus the value of Bottom().
837 @return The offset of the bottom of the chunk's committed region from the
838 base of the chunk's reserved region.
842 return(Exec::ChunkBottom(iHandle));
848 EXPORT_C TInt RChunk::Top() const
850 Gets the offset of the top of the double ended chunk's committed region
851 from the base of the chunk's reserved region.
853 Note that the highest valid address in a double ended chunk is the the sum
854 of the base of the chunk's reserved region plus the value of Top() - 1.
856 @return The offset of the top of the chunk's committed region from the base
857 of the chunk's reserved region.
861 return(Exec::ChunkTop(iHandle));
865 EXPORT_C TInt RChunk::MaxSize() const
867 Gets the maximum size of this chunk.
869 This maximum size of this chunk is set when the chunk is created.
871 @return The maximum size of this chunk.
875 return(Exec::ChunkMaxSize(iHandle));
879 Finds the full name of the next LDD factory object which matches the match pattern.
881 @param aResult A reference to a TBuf descriptor with a defined maximum length.
882 If a matching LDD factory object is found, its full name is set into
884 If no matching LDD factory object is found, the descriptor length is set
887 @return KErrNone, if a matching LDD factory object is found;
888 KErrNotFound otherwise.
890 EXPORT_C TInt TFindLogicalDevice::Next(TFullName &aResult)
892 return NextObject(aResult,ELogicalDevice);
896 Finds the full name of the next PDD factory object which matches the match pattern.
898 @param aResult A reference to a TBuf descriptor with a defined maximum length.
899 If a matching PDD factory object is found, its full name is set into
901 If no matching PDD factory object is found, the descriptor length is set
904 @return KErrNone, if a matching PDD factory object is found;
905 KErrNotFound otherwise.
907 EXPORT_C TInt TFindPhysicalDevice::Next(TFullName &aResult)
909 return NextObject(aResult,EPhysicalDevice);
913 Gets the device capabilities.
915 @param aDes A descriptor into which capability's information is to be written.
917 EXPORT_C void RDevice::GetCaps(TDes8 &aDes) const
920 Exec::LogicalDeviceGetCaps(iHandle,aDes);
924 Checks if a device supports a particular version.
926 @param aVer The requested device version.
928 @return ETrue if supported, EFalse if not.
930 EXPORT_C TBool RDevice::QueryVersionSupported(const TVersion &aVer) const
933 return(Exec::LogicalDeviceQueryVersionSupported(iHandle,aVer));
937 Checks if a specified unit number, additional info and a specific PDD is supported.
939 @param aUnit The requested unit number.
940 @param aPhysicalDevice The requested PDD name.
941 @param anInfo The additional information.
943 @return ETrue if supported, EFalse if not.
945 EXPORT_C TBool RDevice::IsAvailable(TInt aUnit, const TDesC* aPhysicalDevice, const TDesC8* anInfo) const
950 TBuf8<KMaxKernelName> physicalDevice;
951 physicalDevice.Copy(*aPhysicalDevice);
952 r = Exec::LogicalDeviceIsAvailable(iHandle,aUnit,(TDesC8*)&physicalDevice,anInfo);
955 r = Exec::LogicalDeviceIsAvailable(iHandle,aUnit,(TDesC8*)NULL,anInfo);
962 Queues an asynchronous request for the device driver, taking no parameters.
964 The request is handled on the kernel-side by the logical channel's
965 DLogicalChannelBase::Request().
967 Outstanding requests can be cancelled by calling DoCancel().
969 @param aReqNo A number identifying the request to the logical channel.
970 @param aStatus The request status object for this request.
972 EXPORT_C void RBusLogicalChannel::DoRequest(TInt aReqNo,TRequestStatus &aStatus)
978 aStatus=KRequestPending;
979 Exec::ChannelRequest(iHandle,~aReqNo,&aStatus,&a[0]);
986 Queues an asynchronous request for the device driver, taking one parameter.
988 The request is handled on the kernel-side by the logical channel's
989 DLogicalChannelBase::Request().
991 Outstanding requests can be cancelled by calling DoCancel().
993 @param aReqNo A number identifying the request to the logical channel.
994 @param aStatus The request status object for this request.
995 @param a1 A 32-bit value passed to the kernel-side. Its meaning depends
996 on the device driver requirements.
998 EXPORT_C void RBusLogicalChannel::DoRequest(TInt aReqNo,TRequestStatus &aStatus,TAny *a1)
1004 aStatus=KRequestPending;
1005 Exec::ChannelRequest(iHandle,~aReqNo,&aStatus,&a[0]);
1012 Queues an asynchronous request for the device driver, taking two parameters.
1014 The request is handled on the kernel-side by the logical channel's
1015 DLogicalChannelBase::Request().
1017 Outstanding requests can be cancelled by calling DoCancel().
1019 @param aReqNo A number identifying the request to the logical channel.
1020 @param aStatus The request status object for this request.
1021 @param a1 A 32-bit value passed to the kernel-side. Its meaning depends
1022 on the device driver requirements.
1023 @param a2 A 32-bit value passed to the kernel-side. Its meaning depends
1024 on the device driver requirements.
1026 EXPORT_C void RBusLogicalChannel::DoRequest(TInt aReqNo,TRequestStatus &aStatus,TAny *a1,TAny *a2)
1032 aStatus=KRequestPending;
1033 Exec::ChannelRequest(iHandle,~aReqNo,&aStatus,&a[0]);
1040 Cancels one or more outstanding asynchronous requests.
1042 All outstanding requests complete with KErrCancel.
1044 @param aRequestMask A set of bits identifying the requests to be cancelled.
1045 Each bit can be used to identify a separate outstanding
1046 request. It is up to the driver to define how the bits map
1047 to those outstanding requests.
1049 EXPORT_C void RBusLogicalChannel::DoCancel(TUint aRequestMask)
1052 Exec::ChannelRequest(iHandle,KMaxTInt,(TAny*)aRequestMask,0);
1059 Makes a synchronous request to the device driver, taking no parameters.
1061 This function does not return until the request has completed, successfully
1064 @param aFunction A number identifying the request.
1066 @return KErrNone, if successful; otherwise one of the other system-wide
1068 The value returned depends on the implementation of the device driver.
1070 EXPORT_C TInt RBusLogicalChannel::DoControl(TInt aFunction)
1073 return Exec::ChannelRequest(iHandle,aFunction,NULL,NULL);
1080 Makes a synchronous request to the device driver, taking one parameter.
1082 This function does not return until the request has completed, successfully
1085 @param aFunction A number identifying the request.
1086 @param a1 A 32-bit value passed to the kernel-side. Its meaning depends
1087 on the device driver requirements.
1089 @return KErrNone, if successful; otherwise one of the other system-wide
1091 The value returned depends on the implementation of the device driver.
1093 EXPORT_C TInt RBusLogicalChannel::DoControl(TInt aFunction,TAny *a1)
1096 return Exec::ChannelRequest(iHandle,aFunction,a1,NULL);
1103 Makes a synchronous request to the device driver, taking two parameters.
1105 This function does not return until the request has completed, successfully
1108 @param aFunction A number identifying the request.
1109 @param a1 A 32-bit value passed to the kernel-side. Its meaning depends
1110 on the device driver requirements.
1111 @param a2 A 32-bit value passed to the kernel-side. Its meaning depends
1112 on the device driver requirements.
1114 @return KErrNone, if successful; otherwise one of the other system-wide
1116 The value returned depends on the implementation of the device driver.
1118 EXPORT_C TInt RBusLogicalChannel::DoControl(TInt aFunction,TAny *a1,TAny *a2)
1121 return Exec::ChannelRequest(iHandle,aFunction,a1,a2);
1127 EXPORT_C void User::WaitForAnyRequest()
1129 Waits for any asynchronous request to complete.
1131 The current thread waits on its request semaphore.
1133 The function completes, and control returns to the caller when the current
1134 thread's request semaphore is signalled by any of the service providers which
1135 handle these asynchronous requests.
1137 The request status of all outstanding asynchronous requests must be examined
1138 to determine which request is complete.
1144 Exec::WaitForAnyRequest();
1150 EXPORT_C void User::WaitForRequest(TRequestStatus &aStatus)
1152 Waits for a specific asynchronous request to complete.
1154 The current thread waits on its request semaphore.
1156 The function completes and control returns to the caller when the current
1157 thread's request semaphore is signalled by the service provider handling the
1158 request associated with aStatus. Before signalling, the service provider sets
1159 an appropriate value in aStatus, other than KRequestPending.
1161 Note that if other asynchronous requests complete before the one associated
1162 with aStatus, the request semaphore is adjusted so that knowledge of their
1163 completion is not lost. In this a case, a subsequent call to
1164 User::WaitForAnyRequest() or User::WaitForRequest() will complete and return
1167 @param aStatus A reference to the request status object associated with the
1168 specific asynchronous request.
1170 @see KRequestPending
1178 Exec::WaitForAnyRequest();
1179 } while (aStatus==KRequestPending);
1181 Exec::RequestSignal(i);
1187 EXPORT_C void User::WaitForRequest(TRequestStatus &aStatus1,TRequestStatus &aStatus2)
1189 Waits for either of two specific asynchronous requests to complete.
1191 The current thread waits on its request semaphore.
1193 The function completes and control returns to the caller when the current
1194 thread's request semaphore is signalled by either the service provider handling
1195 the request associated with aStatus1 or the service provider handling the
1196 request associated with aStatus2. Before signalling, the completing service
1197 provider sets an appropriate value in the status object, other
1198 than KRequestPending.
1200 Note that if other asynchronous requests complete before the ones associated
1201 with aStatus1 and aStatus2, the request semaphore is adjusted so that knowledge
1202 of their completion is not lost. In this a case, a subsequent call to
1203 User::WaitForAnyRequest() or User::WaitForRequest() will complete and return
1206 @param aStatus1 A reference to the request status object associated with the
1207 first specific asynchronous request.
1208 @param aStatus2 A reference to the request status object associated with the
1209 second specific asynchronous request.
1211 @see KRequestPending
1219 Exec::WaitForAnyRequest();
1220 } while (aStatus1==KRequestPending && aStatus2==KRequestPending);
1222 Exec::RequestSignal(i);
1228 EXPORT_C void User::WaitForNRequest(TRequestStatus * aStatusArray[], TInt aNum)
1230 Waits for any one of specific asynchronous requests to complete.
1232 The current thread waits on its request semaphore.
1234 The function completes and control returns to the caller when the current
1235 thread's request semaphore is signalled by the service provider handling
1236 the request associated with any member of aStatusArray[]. Before signalling,
1237 the completing service provider sets an appropriate value in the status object,
1238 other than KRequestPending.
1240 Note that if other asynchronous requests complete before the ones associated
1241 with aStatusArray the request semaphore is adjusted so that knowledge
1242 of their completion is not lost. In this a case, a subsequent call to
1243 User::WaitForAnyRequest() or User::WaitForRequest() will complete and return
1245 @param aStatusArray[] An array of pointers to the request status objects
1246 @param TInt aNum The size of aStatusArray[]
1249 TRequestStatus* aptr;
1255 Exec::WaitForAnyRequest();
1256 for(TInt j = 0; j<aNum; j++)
1258 aptr = aStatusArray[j];
1261 if(aptr->Int()!= KRequestPending)
1270 Exec::RequestSignal(i);
1276 EXPORT_C TInt TFindLibrary::Next(TFullName &aResult)
1278 Finds the next DLL whose full name matches the match pattern.
1280 If a DLL with a matching name is found, the function copies the full name of
1281 the DLL into the descriptor aResult.
1283 @param aResult A buffer for the fullname of the DLL. This is a template
1284 specialisation of TBuf defining a modifiable buffer descriptor
1285 taking a maximum length of KMaxFullName.
1286 If no matching DLL is found, the descriptor length is
1289 @return KErrNone, if a matching DLL is found;
1290 KErrNotFound, otherwise.
1293 return NextObject(aResult,ELibrary);
1299 EXPORT_C TLibraryFunction RLibrary::Lookup(TInt anOrdinal) const
1301 Gets a pointer to the function at the specified ordinal within this DLL.
1303 @param anOrdinal The ordinal of the required function in this DLL.
1304 This value must be positive.
1306 @return A pointer to the function at position anOrdinal in this DLL.
1307 The value is NULL if there is no function at that ordinal.
1309 @panic USER 116 if anOrdinal is negative
1312 __ASSERT_ALWAYS(anOrdinal>=0,Panic(EBadLookupOrdinal));
1313 return (Exec::LibraryLookup(iHandle,anOrdinal));
1318 EXPORT_C TFileName RLibrary::FileName() const
1320 Gets the name of the DLL's file.
1322 @return The DLL's filname.
1327 TPtr8 n8(((TUint8*)n.Ptr()) + KMaxFileName, KMaxFileName);
1328 Exec::LibraryFileName(iHandle,n8);
1336 EXPORT_C TUidType RLibrary::Type() const
1338 Gets this DLL's UID type.
1340 The UID type is a property of a Symbian OS file; for a DLL, its value is set
1341 during the building of that DLL.
1343 @return The UID type of this DLL. Note that the first TUid component of
1344 the TUidType has the value KDynamicLibraryUid.
1349 Exec::LibraryType(iHandle,u);
1356 EXPORT_C TInt RLibrary::GetRamSizes(TInt& aCodeSize, TInt& aConstDataSize)
1358 Gets the current size of the code and the const data for this DLL.
1360 This function can be called on a RAM loaded DLL or a ROM based DLL.
1362 @param aCodeSize The current size of the code for a RAM loaded DLL.
1363 This is zero for a ROM based DLL.
1365 @param aConstDataSize The current size of the const data for a RAM loaded DLL.
1366 This is zero for a ROM based DLL.
1368 @return KErrNone if successful, otherwise one of the system-wide error codes.
1371 TModuleMemoryInfo info;
1372 TInt r=Exec::LibraryGetMemoryInfo(iHandle,info);
1375 aCodeSize=info.iCodeSize;
1376 aConstDataSize=info.iConstDataSize;
1385 Sets the home time to a specified time value.
1387 @param aTime A reference to a time representation object containing the time
1390 @return KErrNone if successful or one of the system-wide error codes.
1392 @deprecated Set the time using User::SetUTCTime if the UTC time is known;
1393 otherwise, use the timezone server to set the time.
1395 @capability WriteDeviceData
1397 EXPORT_C TInt User::SetHomeTime(const TTime &aTime)
1399 return(Exec::SetUTCTimeAndOffset(aTime.Int64(),0,ETimeSetTime|ETimeSetLocalTime,0));
1403 Sets the secure home time to a specified time value.
1405 @param aTime A reference to a time representation object containing the
1408 @return KErrNone if successful or one of the system-wide error codes.
1411 @capability WriteDeviceData
1413 EXPORT_C TInt User::SetHomeTimeSecure(const TTime &aTime)
1415 return(Exec::SetUTCTimeAndOffset(aTime.Int64(),0,ETimeSetTime|ETimeSetLocalTime|ETimeSetSecure,0));
1421 Sets the UTC time to a specified time value.
1423 @param aUTCTime A reference to a time representation object containing the time
1426 @return KErrNone if successful or one of the system-wide error codes.
1428 @capability WriteDeviceData
1430 EXPORT_C TInt User::SetUTCTime(const TTime &aUTCTime)
1432 return(Exec::SetUTCTimeAndOffset(aUTCTime.Int64(),0,ETimeSetTime,0));
1436 Sets the secure UTC time to a specified time value.
1438 @param aUTCTime A reference to a time representation object containing the secure time
1441 @return KErrNone if successful or one of the system-wide error codes.
1444 @capability WriteDeviceData
1446 EXPORT_C TInt User::SetUTCTimeSecure(const TTime &aUTCTime)
1448 return(Exec::SetUTCTimeAndOffset(aUTCTime.Int64(),0,ETimeSetTime|ETimeSetSecure,0));
1452 Gets the UTC offset - the difference between UTC and the current local time
1453 due to any time zones and daylight savings time that may be in effect. A positive
1454 offset indicates a time ahead of UTC, a negative offset indicates a time behind UTC.
1456 @return The UTC offset, in seconds.
1458 EXPORT_C TTimeIntervalSeconds User::UTCOffset()
1460 return(TTimeIntervalSeconds(Exec::UTCOffset()));
1465 Sets the UTC offset to the given number of seconds. This should include both time
1466 zone differences and the effect of any applicable daylight savings time.
1467 A positive offset indicates a time ahead of UTC, a negative offset indicates a time
1470 @param aOffset The UTC offset, in seconds.
1472 @capability WriteDeviceData
1474 EXPORT_C void User::SetUTCOffset(TTimeIntervalSeconds aOffset)
1476 Exec::SetUTCTimeAndOffset(0,aOffset.Int(),ETimeSetOffset,0);
1481 Sets the UTC time and UTC offset to the specified values, atomically. This is equivalent
1482 to calling both SetUTCTime and SetUTCOffset, but without the possibility of an incorrect
1483 time being observed between the two calls. If the operation is not successful, an error
1484 code will be returned and both the time and offset will be left unchanged.
1486 @param aUTCTime A reference to a time representation object containing the time
1488 @param aOffset The UTC offset, in seconds.
1490 @return KErrNone if successful or one of the system-wide error codes.
1492 @capability WriteDeviceData
1494 EXPORT_C TInt User::SetUTCTimeAndOffset(const TTime &aUTCTime, TTimeIntervalSeconds aOffset)
1496 return(Exec::SetUTCTimeAndOffset(aUTCTime.Int64(),aOffset.Int(),ETimeSetTime|ETimeSetOffset,0));
1501 Gets the current tick count.
1503 The period between ticks is usually 1/64 second, but may be hardware dependent.
1505 @return The machine dependent tick count.
1507 EXPORT_C TUint User::TickCount()
1510 return(Exec::TickCount());
1516 EXPORT_C TTimeIntervalSeconds User::InactivityTime()
1518 Gets the time since the last user activity.
1520 @return The time interval.
1524 return TTimeIntervalSeconds(Exec::UserInactivityTime());
1531 Resets all user inactivity timers.
1533 EXPORT_C void User::ResetInactivityTime()
1535 Exec::ResetInactivityTime();
1542 Gets the nanokernel tick count.
1544 This is the current value of the machine's millisecond tick counter.
1546 On the emulator the resolution defaults to 5 milliseconds; however
1547 you can change it to N milliseconds when you launch the emulator
1548 from the command line by specifying -Dtimerresolution=N as a parameter
1549 to epoc.exe, for example:
1551 epoc.exe -Dtimerresolution=3
1554 On most hardware the resolution is about 1 millisecond.
1556 You can get the nanokernel tick period in microseconds by calling
1557 into the Hardware Abstraction Layer:
1560 TInt nanokernel_tick_period;
1561 HAL::Get(HAL::ENanoTickPeriod, nanokernel_tick_period);
1564 @return The nanokernel tick count.
1566 EXPORT_C TUint32 User::NTickCount()
1569 return Exec::NTickCount();
1576 Gets the fast counter.
1578 This is the current value of the machine's high resolution timer. If a high
1579 resolution timer is not available, it uses the millisecond timer instead.
1581 The freqency of this counter can be determined by reading the HAL attribute
1582 EFastCounterFrequency.
1584 This function is intended for use in profiling and testing; it should not be
1585 used in production code. User::NTickCount() should be used instead.
1587 This is because the implementation of the FastCounter is platform-specific:
1588 its frequency can be anywhere from a few KHz to many MHz. It may also not
1589 be activated when needed, since it is expensive in terms of clock cycles and
1590 battery life, and use of a platform-specific API may be necessary to enable
1593 @return The fast counter value.
1595 @see User::NTickCount()
1597 EXPORT_C TUint32 User::FastCounter()
1600 return Exec::FastCounter();
1606 EXPORT_C TTimerLockSpec User::LockPeriod()
1608 Returns which of the periods the clock is currently in.
1610 @return The fraction of a second at which the timer completes.
1614 return(Exec::LockPeriod());
1620 EXPORT_C TName RHandleBase::Name() const
1622 Gets the name of the handle.
1624 @return The name of the handle.
1629 TPtr8 n8(((TUint8*)n.Ptr()) + KMaxName, KMaxName);
1630 Exec::HandleName(iHandle,n8);
1638 EXPORT_C TFullName RHandleBase::FullName() const
1640 Gets the full name of the handle.
1642 Note: This method is stack consuming (it takes 512 bytes on stack to execute).
1643 For an alternative way to obtain the full name of the object, see RHandleBase::FullName(TDes& aName) const.
1645 @see RHandleBase::FullName(TDes& aName) const
1646 @return The full name of the handle.
1651 TPtr8 n8(((TUint8*)n.Ptr()) + KMaxFullName, KMaxFullName);
1652 Exec::HandleFullName(iHandle,n8);
1660 EXPORT_C void RHandleBase::FullName(TDes& aName) const
1662 Gets the full name of the handle.
1664 @param aName On return, contains the full name of the handle.
1666 @panic KERN-EXEC 35, If full name of the handler is longer that the maximum length of aName descriptor.
1667 To avoid this, the maximum length of aName should be at least KMaxFullName.
1672 // Kernel will copy string in n8, whose data lives in the upper half of aName desciptor data
1673 TPtr8 n8(((TUint8*)aName.Ptr()) + aName.MaxLength(), aName.MaxLength());
1674 Exec::HandleFullName(iHandle,n8);
1675 aName.Copy(n8); // Expands 8bit descriptor into 16bit unicode descriptor.
1681 EXPORT_C void RHandleBase::HandleInfo(THandleInfo* anInfo)
1683 Gets information about the handle.
1685 @param anInfo A pointer to a THandleInfo object supplied by the caller;
1686 on return, contains the handle information.
1690 Exec::HandleInfo(iHandle,anInfo);
1693 EXPORT_C TInt RHandleBase::BTraceId() const
1695 Returns a unique object identifier for use with BTrace
1698 return Exec::GetBTraceId(iHandle);
1703 EXPORT_C TUint RHandleBase::Attributes() const
1705 // Get handle attributes
1709 return Exec::HandleAttributes(iHandle);
1715 EXPORT_C TInt User::AllocLen(const TAny *aCell)
1717 Gets the length of the specified allocated heap cell.
1719 The cell is assumed to be in the current thread's heap.
1721 @param aCell A pointer to the allocated cell whose length
1724 @return The length of the allocated cell.
1728 return(GetHeap()->AllocLen(aCell));
1734 EXPORT_C TAny* User::Alloc(TInt aSize)
1736 Allocates a cell of specified size from the current thread's heap.
1738 If there is insufficient memory available on the heap from which to allocate a cell
1739 of the required size, the function returns NULL.
1741 The resulting size of the allocated cell may be rounded up to a value greater
1742 than aSize, but is guaranteed to be not less than aSize.
1744 @param aSize The size of the cell to be allocated from the current thread's
1747 @return A pointer to the allocated cell. NULL, if there is insufficient memory
1750 @panic USER 47, if the maximum unsigned value of aSize is greater
1751 than or equal to KMaxTInt/2. For example,
1752 calling Alloc(-1) raises this panic.
1756 return(GetHeap()->Alloc(aSize));
1762 EXPORT_C TAny* User::AllocL(TInt aSize)
1764 Allocates a cell of specified size from the current thread's heap, and leaves
1765 if there is insufficient memory in the heap.
1767 The resulting size of the allocated cell may be rounded up to a value greater
1768 than aSize, but is guaranteed to be not less than aSize.
1770 @param aSize The size of the cell to be allocated from the current thread's
1773 @return A pointer to the allocated cell.
1775 @panic USER 47, if the maximum unsigned value of aSize is greater
1776 than or equal to KMaxTInt/2. For example,
1777 calling Alloc(-1) raises this panic.
1781 return(GetHeap()->AllocL(aSize));
1787 EXPORT_C TAny *User::AllocLC(TInt aSize)
1789 Allocates a cell of specified size from the current thread's default heap, and,
1790 if successful, places a pointer to the cell onto the cleanup stack.
1792 The function leaves if there is insufficient memory in the heap.
1794 The resulting size of the allocated cell may be rounded up to a value greater
1795 than aSize, but is guaranteed to be not less than aSize.
1797 @param aSize The size of the cell to be allocated from the current thread's
1800 @return A pointer to the allocated cell.
1802 @panic USER 47, if the maximum unsigned value of aSize is greater
1803 than or equal to KMaxTInt/2. For example,
1804 calling Alloc(-1) raises this panic.
1808 return(GetHeap()->AllocLC(aSize));
1814 EXPORT_C TAny* User::AllocZ(TInt aSize)
1816 Allocates a cell of specified size from the current thread's default heap,
1817 and clears it to binary zeroes.
1819 If there is insufficient memory available on the heap from which to allocate a cell
1820 of the required size, the function returns NULL.
1822 The resulting size of the allocated cell may be rounded up to a value greater
1823 than aSize, but is guaranteed to be not less than aSize.
1825 @param aSize The size of the cell to be allocated from the current thread's
1828 @return A pointer to the allocated cell. NULL, if there is insufficient memory
1831 @panic USER 47, if the maximum unsigned value of aSize is greater
1832 than or equal to KMaxTInt/2. For example,
1833 calling Alloc(-1) raises this panic.
1837 return GetHeap()->AllocZ(aSize);
1843 EXPORT_C TAny* User::AllocZL(TInt aSize)
1845 Allocates a cell of specified size from the current thread's default heap,
1846 clears it to binary zeroes, and leaves if there is insufficient memory in
1849 The resulting size of the allocated cell may be rounded up to a value greater
1850 than aSize, but is guaranteed to be not less than aSize.
1852 @param aSize The size of the cell to be allocated from the current thread's
1855 @return A pointer to the allocated cell.
1857 @panic USER 47, if the maximum unsigned value of aSize is greater
1858 than or equal to KMaxTInt/2. For example,
1859 calling Alloc(-1) raises this panic.
1863 return GetHeap()->AllocZL(aSize);
1869 EXPORT_C TInt User::Available(TInt &aBiggestBlock)
1871 Gets the total free space currently available on the current thread's
1872 default heap, and the space available in the largest free block.
1874 The space available represents the total space which can be allocated.
1876 Note that compressing the heap may reduce the total free space available and the space
1877 available in the largest free block.
1879 @param aBiggestBlock On return, contains the space available in the largest
1880 free block on the current thread's default heap.
1882 @return The total free space currently available on the current thread's heap.
1886 return(GetHeap()->Available(aBiggestBlock));
1892 EXPORT_C void User::Check()
1894 Checks the validity of the current thread's default heap.
1896 The function walks through the list of allocated cells and the list of free
1897 cells checking that the heap is consistent and complete.
1899 @panic USER 47 if any corruption is found, specifically a bad allocated
1901 @panic USER 48 if any corruption is found, specifically a bad allocated
1903 @panic USER 49 if any corruption is found, specifically a bad free heap
1914 EXPORT_C void User::Free(TAny *aCell)
1916 Frees the specified cell and returns it to the current thread's default heap.
1918 @param aCell A pointer to a valid cell to be freed. If NULL this function
1919 call will be ignored.
1921 @panic USER 42, if aCell is not NULL and does not point to a valid cell.
1926 GetHeap()->Free(aCell);
1932 EXPORT_C void User::FreeZ(TAny * &aCell)
1934 Frees the specified cell, returns it to the current thread's default heap, and resets
1935 the pointer to NULL.
1937 @param aCell A reference to a pointer to a valid cell to be freed. If NULL
1938 this function call will be ignored.
1940 @panic USER 42, if aCell is not NULL and does not point to a valid cell.
1945 GetHeap()->FreeZ(aCell);
1951 EXPORT_C TAny* User::ReAlloc(TAny* aCell, TInt aSize, TInt aMode)
1953 Increases or decreases the size of an existing cell in the current
1956 If the cell is being decreased in size, then it is guaranteed not to move,
1957 and the function returns the pointer originally passed in aCell. Note that the
1958 length of the cell will be the same if the difference between the old size
1959 and the new size is smaller than the minimum cell size.
1961 If the cell is being increased in size, i.e. aSize is bigger than its
1962 current size, then the function tries to grow the cell in place.
1963 If successful, then the function returns the pointer originally
1964 passed in aCell. If unsuccessful, then:
1965 -# if the cell cannot be moved, i.e. aMode has the ENeverMove bit set, then
1966 the function returns NULL.
1967 -# if the cell can be moved, i.e. aMode does not have the ENeverMove bit set,
1968 then the function tries to allocate a new replacement cell, and, if
1969 successful, returns a pointer to the new cell; if unsuccessful, it
1972 Note that in debug mode, the function returns NULL if the cell cannot be grown
1973 in place, regardless of whether the ENeverMove bit is set.
1975 If the reallocated cell is at a different location from the original cell, then
1976 the content of the original cell is copied to the reallocated cell.
1978 If the supplied pointer, aCell is NULL, then the function attempts to allocate
1979 a new cell, but only if the cell can be moved, i.e. aMode does not have
1980 the ENeverMove bit set.
1982 Note the following general points:
1983 - If reallocation fails, the content of the original cell is preserved.
1984 - The resulting size of the re-allocated cell may be rounded up to a value
1985 greater than aSize, but is guaranteed to be not less than aSize.
1987 @param aCell A pointer to the cell to be reallocated. This may be NULL.
1989 @param aSize The new size of the cell. This may be bigger or smaller than the
1990 size of the original cell. The value can also be zero, but this is
1991 interpreted as a request for a cell of minimum size; the net
1992 effect is the same as if the caller had explicitly requested
1993 a cell of minimum size.
1994 Note that the minimum size of a heap cell is device dependent.
1996 @param aMode Flags controlling the reallocation. The only bit which has any
1997 effect on this function is that defined by the enumeration
1998 ENeverMove of the enum RAllocator::TReAllocMode.
1999 If this is set, then any successful reallocation guarantees not
2000 to have changed the start address of the cell.
2001 By default, this parameter is zero.
2003 @return A pointer to the reallocated cell. This may be the same as the original
2004 pointer supplied through aCell. NULL if there is insufficient memory to
2005 reallocate the cell, or to grow it in place.
2007 @panic USER 42, if aCell is not NULL, and does not point to a valid cell.
2008 @panic USER 47, if the maximum unsigned value of aSize is greater
2009 than or equal to KMaxTInt/2. For example,
2010 calling ReAlloc(someptr,-1) raises this panic.
2012 @see RAllocator::TReAllocMode
2016 return GetHeap()->ReAlloc(aCell, aSize, aMode);
2022 EXPORT_C TAny* User::ReAllocL(TAny* aCell, TInt aSize, TInt aMode)
2024 Increases or decreases the size of an existing cell, and leaves
2025 if there is insufficient memory in the current thread's default heap.
2027 If the cell is being decreased in size, then it is guaranteed not to move,
2028 and the function returns the pointer originally passed in aCell. Note that the
2029 length of the cell will be the same if the difference between the old size
2030 and the new size is smaller than the minimum cell size.
2032 If the cell is being increased in size, i.e. aSize is bigger than its
2033 current size, then the function tries to grow the cell in place.
2034 If successful, then the function returns the pointer originally
2035 passed in aCell. If unsuccessful, then:
2036 -# if the cell cannot be moved, i.e. aMode has the ENeverMove bit set, then
2037 the function leaves.
2038 -# if the cell can be moved, i.e. aMode does not have the ENeverMove bit set,
2039 then the function tries to allocate a new replacement cell, and, if
2040 successful, returns a pointer to the new cell; if unsuccessful, it
2043 Note that in debug mode, the function leaves if the cell cannot be grown
2044 in place, regardless of whether the ENeverMove bit is set.
2046 If the reallocated cell is at a different location from the original cell, then
2047 the content of the original cell is copied to the reallocated cell.
2049 If the supplied pointer, aCell is NULL, then the function attempts to allocate
2050 a new cell, but only if the cell can be moved, i.e. aMode does not have
2051 the ENeverMove bit set.
2053 Note the following general points:
2054 - If reallocation fails, the content of the original cell is preserved.
2055 - The resulting size of the re-allocated cell may be rounded up to a value
2056 greater than aSize, but is guaranteed to be not less than aSize.
2058 @param aCell A pointer to the cell to be reallocated. This may be NULL.
2060 @param aSize The new size of the cell. This may be bigger or smaller than the
2061 size of the original cell. The value can also be zero, but this is
2062 interpreted as a request for a cell of minimum size; the net
2063 effect is the same as if the caller had explicitly requested
2064 a cell of minimum size.
2065 Note that the minimum size of a heap cell is device dependent.
2067 @param aMode Flags controlling the reallocation. The only bit which has any
2068 effect on this function is that defined by the enumeration
2069 ENeverMove of the enum RAllocator::TReAllocMode.
2070 If this is set, then any successful reallocation guarantees not
2071 to have changed the start address of the cell.
2072 By default, this parameter is zero.
2074 @return A pointer to the reallocated cell. This may be the same as the original
2075 pointer supplied through aCell.
2077 @panic USER 42, if aCell is not NULL, and does not point to a valid cell.
2078 @panic USER 47, if the maximum unsigned value of aSize is greater
2079 than or equal to KMaxTInt/2. For example,
2080 calling ReAlloc(someptr,-1) raises this panic.
2082 @see RAllocator::TReAllocMode
2086 return GetHeap()->ReAllocL(aCell, aSize, aMode);
2092 EXPORT_C RAllocator& User::Allocator()
2094 Gets the current thread's default current heap.
2096 @return The current heap.
2106 EXPORT_C TInt User::AllocSize(TInt &aTotalAllocSize)
2108 Gets the total number of cells allocated on the current thread's default heap,
2109 and the total space allocated to them.
2111 @param aTotalAllocSize On return, contains the total space allocated to
2114 @return The number of cells currently allocated on the current thread's heap.
2118 return(GetHeap()->AllocSize(aTotalAllocSize));
2124 EXPORT_C TInt User::CountAllocCells()
2126 Gets the total number of cells allocated on the current thread's default heap.
2129 @return The number of cells allocated on the current thread's default user heap.
2132 return(GetHeap()->Count());
2138 EXPORT_C TInt User::CountAllocCells(TInt &aFreeCount)
2140 Gets the the total number of cells allocated, and the number of free cells,
2141 on the current thread's default heap.
2143 @param aFreeCount On return, contains the number of free cells
2144 on the current thread's default heap.
2146 @return The number of cells allocated on the current thread's default heap.
2150 return(GetHeap()->Count(aFreeCount));
2156 EXPORT_C RAllocator* User::SwitchAllocator(RAllocator* aA)
2158 Changes the current thread's heap.
2160 @param aA A pointer to the new heap handle.
2162 @return A pointer to the old heap handle.
2166 #ifdef __USERSIDE_THREAD_DATA__
2167 // Just cache the pointer user-side. We still need to let the kernel know what's going on so
2168 // the heap can be cleaned up correctly later.
2169 LocalThreadData()->iHeap=aA;
2171 return Exec::HeapSwitch(aA);
2175 const TText16* const __DefaultDateSuffixTable[KMaxSuffixes] =
2177 _S16("st"),_S16("nd"),_S16("rd"),_S16("th"),_S16("th"),
2178 _S16("th"),_S16("th"),_S16("th"),_S16("th"),_S16("th"),
2179 _S16("th"),_S16("th"),_S16("th"),_S16("th"),_S16("th"),
2180 _S16("th"),_S16("th"),_S16("th"),_S16("th"),_S16("th"),
2181 _S16("st"),_S16("nd"),_S16("rd"),_S16("th"),_S16("th"),
2182 _S16("th"),_S16("th"),_S16("th"),_S16("th"),_S16("th"),
2187 const TText16* const __DefaultDayTable[KMaxDays] =
2198 // The abbreviated day names
2199 const TText16* const __DefaultDayAbbTable[KMaxDays] =
2211 const TText16* const __DefaultMonthTable[KMaxMonths] =
2227 // The abbreviated month names
2228 const TText16* const __DefaultMonthAbbTable[KMaxMonths] =
2244 // The am/pm strings
2245 const TText16* const __DefaultAmPmTable[KMaxAmPms] =
2251 const TText16* const __DefaultLMsgTable[ELocaleMessages_LastMsg] =
2254 _S16("Retry"), // Button 1
2255 _S16("Stop"), // Button 2
2256 _S16("Put the disk back"), // Put the card back - line1
2257 _S16("or data will be lost"), // Put the card back - line2
2258 _S16("Batteries too low"), // Low power - line1
2259 _S16("Cannot complete write to disk"), // Low power - line2
2260 _S16("Disk error - cannot complete write"), // Disk error - line1
2261 _S16("Retry or data will be lost"), // Disk error - line2
2263 _S16("Chimes"), // Chimes
2264 _S16("Rings"), // Rings
2265 _S16("Signal"), // Signal
2266 // MediaDriver diskname (max 16 chars)
2267 _S16("Internal"), // Internal
2268 _S16("External(01)"), // External(01)
2269 _S16("External(02)"), // External(02)
2270 _S16("External(03)"), // External(03)
2271 _S16("External(04)"), // External(04)
2272 _S16("External(05)"), // External(05)
2273 _S16("External(06)"), // External(06)
2274 _S16("External(07)"), // External(07)
2275 _S16("External(08)"), // External(08)
2276 // MediaDriver socketname (max 16 chars)
2277 _S16("Socket(01)"), // Socket(01)
2278 _S16("Socket(02)"), // Socket(02)
2279 _S16("Socket(03)"), // Socket(03)
2280 _S16("Socket(04)") // Socket(04)
2283 LOCAL_C void LocaleLanguageGet(SLocaleLanguage& locale)
2285 TPckg<SLocaleLanguage> localeLanguageBuf(locale);
2286 TInt r = RProperty::Get(KUidSystemCategory, KLocaleLanguageKey, localeLanguageBuf);
2287 __ASSERT_DEBUG(r == KErrNone || r == KErrNotFound, Panic(EBadLocaleParameter));
2288 if(r == KErrNotFound)
2290 locale.iLanguage = ELangEnglish;
2291 locale.iDateSuffixTable = (const TText16*)__DefaultDateSuffixTable;
2292 locale.iDayTable = (const TText16*)__DefaultDayTable;
2293 locale.iDayAbbTable = (const TText16*)__DefaultDayAbbTable;
2294 locale.iMonthTable = (const TText16*)__DefaultMonthTable;
2295 locale.iMonthAbbTable = (const TText16*)__DefaultMonthAbbTable;
2296 locale.iAmPmTable = (const TText16*)__DefaultAmPmTable;
2297 locale.iMsgTable = (const TText16* const*)__DefaultLMsgTable;
2301 LOCAL_C void LocaleSettingsGet(SLocaleLocaleSettings& locale)
2303 TPckg<SLocaleLocaleSettings> localeSettingsBuf(locale);
2304 TInt r = RProperty::Get(KUidSystemCategory, KLocaleDataExtraKey, localeSettingsBuf);
2305 __ASSERT_DEBUG(r == KErrNone || r == KErrNotFound, Panic(EBadLocaleParameter));
2306 if(r == KErrNotFound)
2308 Mem::Copy(&locale.iCurrencySymbol[0], _S16("\x00a3"), sizeof(TText16) << 2);
2309 locale.iLocaleExtraSettingsDllPtr = NULL;
2313 LOCAL_C void LocaleTimeDateFormatGet(SLocaleTimeDateFormat& locale)
2315 TPckg<SLocaleTimeDateFormat> localeTimeDateFormatBuf(locale);
2316 TInt r = RProperty::Get(KUidSystemCategory, KLocaleTimeDateFormatKey, localeTimeDateFormatBuf);
2317 __ASSERT_DEBUG(r == KErrNone || r == KErrNotFound, Panic(EBadLocaleParameter));
2318 if(r == KErrNotFound)
2320 Mem::Copy(&locale.iShortDateFormatSpec[0], _S16("%F%*D/%*M/%Y"), sizeof(TText16) * 13);
2321 Mem::Copy(&locale.iLongDateFormatSpec[0], _S16("%F%*D%X %N %Y"), sizeof(TText16) * 14);
2322 Mem::Copy(&locale.iTimeFormatSpec[0], _S16("%F%*I:%T:%S %*A"), sizeof(TText16) * 16);
2323 locale.iLocaleTimeDateFormatDllPtr = NULL;
2327 EXPORT_C void TDayName::Set(TDay aDay)
2329 Re-retrieves the current locale's text for the specified day of the week.
2331 @param aDay Identifies the day of the week.
2333 @panic USER 184, if the specified day is outside the permitted range.
2337 __ASSERT_ALWAYS(aDay>=EMonday && aDay<=ESunday,Panic(EBadLocaleParameter));
2338 SLocaleLanguage localeLanguage;
2339 LocaleLanguageGet(localeLanguage);
2340 Copy((reinterpret_cast<const TText* const*>(localeLanguage.iDayTable))[aDay]);
2346 EXPORT_C void TDayNameAbb::Set(TDay aDay)
2348 Re-retrieves the current locale's abbreviated text for the specified day of
2351 @param aDay Identifies the day of the week.
2353 @panic USER 184, if the specified day is outside the permitted range.
2357 __ASSERT_ALWAYS(aDay>=EMonday && aDay<=ESunday,Panic(EBadLocaleParameter));
2358 SLocaleLanguage localeLanguage;
2359 LocaleLanguageGet(localeLanguage);
2360 Copy((reinterpret_cast<const TText* const*>(localeLanguage.iDayAbbTable))[aDay]);
2366 EXPORT_C void TMonthName::Set(TMonth aMonth)
2368 Re-retrieves the current locale's text for the specified month.
2370 @param aMonth Identifies the month.
2372 @panic USER 184, if the specified month is outside the permitted range.
2376 __ASSERT_ALWAYS(aMonth>=EJanuary && aMonth<=EDecember,Panic(EBadLocaleParameter));
2377 SLocaleLanguage localeLanguage;
2378 LocaleLanguageGet(localeLanguage);
2379 Copy((reinterpret_cast<const TText* const*>(localeLanguage.iMonthTable))[aMonth]);
2385 EXPORT_C void TMonthNameAbb::Set(TMonth aMonth)
2387 Re-retrieves the current locale's abbreviated text for the specified month.
2389 @param aMonth Identifies the month.
2391 @panic USER 184, if the specified month is outside the permitted range.
2395 __ASSERT_ALWAYS(aMonth>=EJanuary && aMonth<=EDecember,Panic(EBadLocaleParameter));
2396 SLocaleLanguage localeLanguage;
2397 LocaleLanguageGet(localeLanguage);
2398 Copy((reinterpret_cast<const TText* const*>(localeLanguage.iMonthAbbTable))[aMonth]);
2404 EXPORT_C void TDateSuffix::Set(TInt aSuffix)
2406 Re-retrieves the current locale's date suffix text for the specified day of
2409 @param aSuffix A value identifying the day of the month. The value can
2410 range from 0 to 30 so that the first day of the month is
2411 identified by 0, the second day by 1 etc.
2413 @panic USER 69, if aDateSuffix is outside the range 0 to 30.
2417 __ASSERT_ALWAYS(aSuffix>=0 && aSuffix<KMaxSuffixes,Panic(ETLoclSuffixOutOfRange));
2418 SLocaleLanguage localeLanguage;
2419 LocaleLanguageGet(localeLanguage);
2420 Copy((reinterpret_cast<const TText* const*>(localeLanguage.iDateSuffixTable))[aSuffix]);
2426 EXPORT_C void TAmPmName::Set(TAmPm aSelector)
2428 Re-retrieves the current locale's text for identifying time before or after
2429 noon as identified by the specified selector.
2431 @param aSelector The am/pm selector.
2433 @panic USER 69, if aDateSuffix is outside the range 0 to 30.
2437 __ASSERT_ALWAYS(aSelector==EAm || aSelector==EPm,Panic(ETLoclSuffixOutOfRange));
2438 SLocaleLanguage localeLanguage;
2439 LocaleLanguageGet(localeLanguage);
2440 Copy((reinterpret_cast<const TText* const*>(localeLanguage.iAmPmTable))[aSelector]);
2446 EXPORT_C void TCurrencySymbol::Set()
2448 Re-retrieves the current locale's currency symbol(s).
2451 SLocaleLocaleSettings locale;
2452 LocaleSettingsGet(locale);
2453 Copy(&locale.iCurrencySymbol[0]);
2459 EXPORT_C void TShortDateFormatSpec::Set()
2461 Sets the contents of the short date format specification from the system-wide
2465 SLocaleTimeDateFormat locale;
2466 LocaleTimeDateFormatGet(locale);
2467 Copy(&locale.iShortDateFormatSpec[0]);
2473 EXPORT_C void TLongDateFormatSpec::Set()
2475 Sets the contents of the long date format specification from the system-wide
2479 SLocaleTimeDateFormat locale;
2480 LocaleTimeDateFormatGet(locale);
2481 Copy(&locale.iLongDateFormatSpec[0]);
2487 EXPORT_C void TTimeFormatSpec::Set()
2489 Sets the contents of the time string format specification from the system-wide
2493 SLocaleTimeDateFormat locale;
2494 LocaleTimeDateFormatGet(locale);
2495 Copy(&locale.iTimeFormatSpec[0]);
2501 EXPORT_C TInt User::SetCurrencySymbol(const TDesC& aSymbol)
2503 Sets the system wide currency symbol.
2505 On successful return from this function, a call to the Set() member function
2506 of a TCurrencySymbol object fetches the new currency symbol.
2508 @capability WriteDeviceData
2510 @param aSymbol A reference to the descriptor containing the currency symbol
2513 @return KErrNone if successful, otherwise one of the other system wide error codes.
2515 @panic USER 119, if the length of aSymbol is greater than KMaxCurrencySymbol.
2517 @see TCurrencySymbol
2518 @see TCurrencySymbol::Set()
2519 @see KMaxCurrencySymbol
2523 TExtendedLocale locale;
2524 return locale.SetCurrencySymbol(aSymbol);
2530 EXPORT_C TLanguage User::Language()
2532 Gets the language of the current locale.
2534 @return One of the TLanguage enumerators identifying the language of the
2539 SLocaleLanguage localeLanguage;
2540 LocaleLanguageGet(localeLanguage);
2541 return localeLanguage.iLanguage;
2544 EXPORT_C TRegionCode User::RegionCode()
2546 #ifdef SYMBIAN_DISTINCT_LOCALE_MODEL
2549 return static_cast<TRegionCode>(locale.RegionCode());
2551 return static_cast<TRegionCode>(0);
2556 EXPORT_C TLocale::TLocale()
2558 Default constructor.
2560 It constructs the object with the system's locale settings.
2562 A single copy of the locale information is maintained by the system. This
2563 copy may be refreshed under application control with TLocale::Refresh(), and
2564 the settings may be saved to the system with TLocale::Set(). However, the
2565 settings are never updated by the system apart from under application control.
2566 This enables applications to guarantee that consistent locale information
2569 @see TLocale::Refresh()
2578 const TUint8 __DefaultDateSeparator[KMaxDateSeparators] = { 0, '/', '/', 0 };
2579 const TUint8 __DefaultTimeSeparator[KMaxTimeSeparators] = { 0, ':', ':', 0 };
2581 void TLocale::SetDefaults()
2584 iUniversalTimeOffset = 0;
2585 iDateFormat = EDateEuropean;
2586 iTimeFormat = ETime12;
2587 iCurrencySymbolPosition = ELocaleBefore;
2588 iCurrencySpaceBetween = EFalse;
2589 iCurrencyDecimalPlaces = 2;
2590 iNegativeCurrencyFormat = TNegativeCurrencyFormat(EFalse);
2591 iCurrencyTriadsAllowed = ETrue;
2592 iThousandsSeparator = ',';
2593 iDecimalSeparator = '.';
2595 for(; i<KMaxDateSeparators; i++)
2596 iDateSeparator[i] = __DefaultDateSeparator[i];
2597 for(i=0; i<KMaxTimeSeparators; i++)
2598 iTimeSeparator[i] = __DefaultTimeSeparator[i];
2599 iAmPmSymbolPosition = ELocaleAfter;
2600 iAmPmSpaceBetween = ETrue;
2601 iHomeDaylightSavingZone = EDstEuropean;
2603 iStartOfWeek = EMonday;
2604 iClockFormat = EClockAnalog;
2605 iUnitsGeneral = EUnitsImperial;
2606 iUnitsDistanceLong = EUnitsImperial;
2607 iUnitsDistanceShort = EUnitsImperial;
2608 iExtraNegativeCurrencyFormatFlags = 0;
2609 iLanguageDowngrade[0] = ELangNone;
2610 iLanguageDowngrade[1] = ELangNone;
2611 iLanguageDowngrade[2] = ELangNone;
2612 #ifdef SYMBIAN_DISTINCT_LOCALE_MODEL
2613 iRegionCode = ERegGBR;
2617 iDigitType = EDigitTypeWestern;
2618 iDeviceTimeState = TDeviceTimeState(EDeviceUserTime);
2621 EXPORT_C void TLocale::Refresh()
2623 Refreshes the contents of this object with the system's locale settings.
2628 TPckg<TLocale> localeDataBuf(*this);
2629 TInt r = RProperty::Get(KUidSystemCategory, KLocaleDataKey, localeDataBuf);
2630 __ASSERT_DEBUG(r == KErrNone || r == KErrNotFound, Panic(EBadLocaleParameter));
2633 iUniversalTimeOffset = Exec::UTCOffset();
2634 iDaylightSaving = 0;
2636 else if(r == KErrNotFound)
2645 EXPORT_C TInt TLocale::Set() const
2647 Transfers the locale settings from this object to the system. Note that
2648 the timezone offset and daylight savings flags are ignored as setting these
2649 through TLocale is no longer supported.
2651 After this function has been called, other applications may use the new
2652 settings for newly-constructed TLocale objects,
2653 or if they use TLocale::Refresh(), to refresh their settings from
2656 @capability WriteDeviceData
2658 @return KErrNone if successful, otherwise one of the other system wide error codes.
2660 @see TLocale::Refresh()
2663 TPckg<TLocale> localeDataBuf(*this);
2664 TInt r = RProperty::Set(KUidSystemCategory, KLocaleDataKey, localeDataBuf);
2667 Exec::NotifyChanges(EChangesLocale);
2672 TInt TExtendedLocale::DoLoadLocale(const TDesC& aLocaleDllName, TLibraryFunction* aExportList)
2675 TInt r = loader.LoadLocale(aLocaleDllName, aExportList);
2679 #ifdef SYMBIAN_DISTINCT_LOCALE_MODEL
2680 void TExtendedLocale::DoUpdateLanguageSettingsV2(TLibraryFunction* aExportList)
2682 iLocale.iDigitType = EDigitTypeWestern;
2683 iLocale.iLanguageDowngrade[0] = ELangNone;
2684 iLocale.iLanguageDowngrade[1] = ELangNone;
2685 iLocale.iLanguageDowngrade[2] = ELangNone;
2687 iLanguageSettings.iLanguage = (TLanguage)aExportList[FnLanguageV2]();
2688 iLanguageSettings.iDateSuffixTable = (const TText*)aExportList[FnDateSuffixTableV2]();
2689 iLanguageSettings.iDayTable = (const TText*)aExportList[FnDayTableV2]();
2690 iLanguageSettings.iDayAbbTable = (const TText*)aExportList[FnDayAbbTableV2]();
2691 iLanguageSettings.iMonthTable = (const TText*)aExportList[FnMonthTableV2]();
2692 iLanguageSettings.iMonthAbbTable = (const TText*)aExportList[FnMonthAbbTableV2]();
2693 iLanguageSettings.iAmPmTable = (const TText*)aExportList[FnAmPmTableV2]();
2694 iLanguageSettings.iMsgTable = (const TText16* const*)aExportList[FnMsgTableV2]();
2696 TDigitType digitType = (TDigitType)aExportList[FnDigitTypeV2]();
2697 iLocale.SetDigitType(digitType);
2699 TLanguage* languageDowngrade = (TLanguage*)aExportList[FnLanguageDowngradeTableV2]();
2700 iLocale.SetLanguageDowngrade(0,*(languageDowngrade));
2701 iLocale.SetLanguageDowngrade(1,*(languageDowngrade+1));
2702 iLocale.SetLanguageDowngrade(2,*(languageDowngrade+2));
2705 void TExtendedLocale::DoUpdateLocaleSettingsV2(TLibraryFunction* aExportList)
2708 Mem::Copy(&iLocaleExtraSettings.iCurrencySymbol[0], (const TAny*)aExportList[FnCurrencySymbolV2](), sizeof(TText) * (KMaxCurrencySymbol+1));
2709 iLocaleExtraSettings.iLocaleExtraSettingsDllPtr = (TAny*)aExportList[FnCurrencySymbolV2]();
2710 Mem::Copy(&iLocaleTimeDateFormat.iShortDateFormatSpec[0], (const TAny*)aExportList[FnShortDateFormatSpecV2](), sizeof(TText) * (KMaxShortDateFormatSpec+1));
2711 Mem::Copy(&iLocaleTimeDateFormat.iLongDateFormatSpec[0], (const TAny*)aExportList[FnLongDateFormatSpecV2](), sizeof(TText) * (KMaxLongDateFormatSpec+1)) ;
2712 Mem::Copy(&iLocaleTimeDateFormat.iTimeFormatSpec[0], (const TAny*)aExportList[FnTimeFormatSpecV2](), sizeof(TText) * (KMaxTimeFormatSpec+1));
2713 iLocaleTimeDateFormat.iLocaleTimeDateFormatDllPtr = (TAny*)aExportList[FnCurrencySymbolV2]();
2715 iLocale.iExtraNegativeCurrencyFormatFlags=0x80000000;
2717 typedef void (*TLibFn)(TLocale*);
2718 ((TLibFn)aExportList[FnLocaleDataV2])(&iLocale);
2720 if (iLocale.iExtraNegativeCurrencyFormatFlags&0x80000000)
2721 iLocale.iExtraNegativeCurrencyFormatFlags=0;
2725 void TExtendedLocale::DoUpdateLanguageSettings(TLibraryFunction* aExportList)
2727 iLanguageSettings.iLanguage = (TLanguage)aExportList[FnLanguage]();
2728 iLanguageSettings.iDateSuffixTable = (const TText*)aExportList[FnDateSuffixTable]();
2729 iLanguageSettings.iDayTable = (const TText*)aExportList[FnDayTable]();
2730 iLanguageSettings.iDayAbbTable = (const TText*)aExportList[FnDayAbbTable]();
2731 iLanguageSettings.iMonthTable = (const TText*)aExportList[FnMonthTable]();
2732 iLanguageSettings.iMonthAbbTable = (const TText*)aExportList[FnMonthAbbTable]();
2733 iLanguageSettings.iAmPmTable = (const TText*)aExportList[FnAmPmTable]();
2734 iLanguageSettings.iMsgTable = (const TText16* const*)aExportList[FnMsgTable]();
2737 void TExtendedLocale::DoUpdateLocaleSettings(TLibraryFunction* aExportList)
2739 Mem::Copy(&iLocaleExtraSettings.iCurrencySymbol[0], (const TAny*)aExportList[FnCurrencySymbol](), sizeof(TText) * (KMaxCurrencySymbol+1));
2740 iLocaleExtraSettings.iLocaleExtraSettingsDllPtr = (TAny*)aExportList[FnDateSuffixTable]();
2743 void TExtendedLocale::DoUpdateTimeDateFormat(TLibraryFunction* aExportList)
2745 Mem::Copy(&iLocaleTimeDateFormat.iShortDateFormatSpec[0], (const TAny*)aExportList[FnShortDateFormatSpec](), sizeof(TText) * (KMaxShortDateFormatSpec+1));
2746 Mem::Copy(&iLocaleTimeDateFormat.iLongDateFormatSpec[0], (const TAny*)aExportList[FnLongDateFormatSpec](), sizeof(TText) * (KMaxLongDateFormatSpec+1)) ;
2747 Mem::Copy(&iLocaleTimeDateFormat.iTimeFormatSpec[0], (const TAny*)aExportList[FnTimeFormatSpec](), sizeof(TText) * (KMaxTimeFormatSpec+1));
2748 iLocaleTimeDateFormat.iLocaleTimeDateFormatDllPtr = (TAny*)aExportList[FnDateSuffixTable]();
2752 Default constructor.
2754 It constructs an empty object
2756 This is an empty copy of TExtendedLocale. To get the system locale you can
2757 use TExtendedLocale::LoadSystemSettings. The current settings may be saved to the system
2758 with TLocale::SaveSystemSettings().
2760 @see TExtendedLocale::LoadSystemSettings
2761 @see TExtendedLocale::SaveSystemSettings
2763 EXPORT_C TExtendedLocale::TExtendedLocale()
2767 Mem::FillZ(&iLanguageSettings, sizeof(TExtendedLocale) - sizeof(TLocale));
2771 Load system wide locale settings
2773 It initialises this TExtendedLocale with the system wide locale settings.
2774 The settings stored in the TExtendedLocale are overwritten with the system
2777 @see TExtendedLocale::SaveSystemSettings
2779 EXPORT_C void TExtendedLocale::LoadSystemSettings()
2781 LocaleLanguageGet(iLanguageSettings);
2782 LocaleSettingsGet(iLocaleExtraSettings);
2783 LocaleTimeDateFormatGet(iLocaleTimeDateFormat);
2784 iDefaultCharSet = GetLocaleCharSet();
2785 iPreferredCharSet = GetLocalePreferredCharSet();
2790 Make the current locale information system wide
2792 It overwrites the system wide locale information with the locale information
2793 stored in this TExtendedLocale.
2794 This will generate a notification for system locale changes.
2795 In case of an error, the locale might be in an unconsistent state.
2797 @capability WriteDeviceData
2799 @return KErrNone if successful, otherwise one of the other system wide error codes.
2801 EXPORT_C TInt TExtendedLocale::SaveSystemSettings()
2804 TPckg<SLocaleLanguage> localeLanguageBuf(iLanguageSettings);
2805 TInt r = RProperty::Set(KUidSystemCategory, KLocaleLanguageKey, localeLanguageBuf);
2809 TPckg<SLocaleLocaleSettings> localeSettingsBuf(iLocaleExtraSettings);
2810 r = RProperty::Set(KUidSystemCategory, KLocaleDataExtraKey, localeSettingsBuf);
2814 TPckg<SLocaleTimeDateFormat> localeTimeDateFormatBuf(iLocaleTimeDateFormat);
2815 r = RProperty::Set(KUidSystemCategory, KLocaleTimeDateFormatKey, localeTimeDateFormatBuf);
2819 r = Exec::SetGlobalUserData(ELocaleDefaultCharSet, (TInt)iDefaultCharSet);
2823 r = Exec::SetGlobalUserData(ELocalePreferredCharSet, (TInt)iPreferredCharSet);
2833 #ifdef SYMBIAN_DISTINCT_LOCALE_MODEL
2834 TInt TExtendedLocale::CheckLocaleDllName(const TDesC& aLocaleDllName, TInt& languageID)
2838 if(aLocaleDllName.Find(KLoc) == KErrNotFound)
2839 return KErrNotFound;
2841 TInt len = aLocaleDllName.Length() - 6; //6 is the length of KLoc.
2842 TPtrC ptr = aLocaleDllName.Right(len);
2843 for(TInt i =0; i< len; i++)
2845 if(ptr[i] >= '0' && ptr[i] <= '9')
2847 languageID = languageID*10 + (ptr[i] - '0');
2852 return KErrNotFound;
2858 //add file extension, such as "elocl_lan" will be "elocl_lan.012"
2859 void TExtendedLocale::AddExtension(TDes& aFileName, TInt aExtension)
2861 if (aExtension < 10)
2863 aFileName.AppendNum(0);
2864 aFileName.AppendNum(0);
2865 aFileName.AppendNum(aExtension);
2867 else if (aExtension < 100)
2869 aFileName.AppendNum(0);
2870 aFileName.AppendNum(aExtension);
2874 aFileName.AppendNum(aExtension);
2881 Loads a locale Dll and get the locale information
2883 It loads a locale DLL and it initialises the contents of this TExtendedLocale
2884 with the locale information stored in the DLL. The locale information is only
2885 stored in this TExtendedLocale. If you want to set the system wide settings with
2886 the locale information in the DLL, you can call TExtendedLocale::SaveSystemSettings
2887 after calling this function.
2889 @param aLocaleDllName The name of the locale DLL to be loaded
2890 @return KErrNone if successful, system wide error if not
2892 @see TExtendedLocale::SaveSystemSettings
2894 EXPORT_C TInt TExtendedLocale::LoadLocale(const TDesC& aLocaleDllName)
2896 #ifdef SYMBIAN_DISTINCT_LOCALE_MODEL
2897 TLibraryFunction data[KNumLocaleExports];
2898 TInt r = DoLoadLocale(aLocaleDllName, &data[0]);
2901 iLocale.iExtraNegativeCurrencyFormatFlags=0x80000000;
2902 iLocale.iLanguageDowngrade[0] = ELangNone;
2903 iLocale.iLanguageDowngrade[1] = ELangNone;
2904 iLocale.iLanguageDowngrade[2] = ELangNone;
2905 iLocale.iDigitType = EDigitTypeWestern;
2907 typedef void (*TLibFn)(TLocale*);
2908 ((TLibFn)data[FnLocaleData])(&iLocale);
2910 //Locale daylightsavings unchanged - we have travelled through space, not time
2911 if (iLocale.iExtraNegativeCurrencyFormatFlags&0x80000000)
2912 iLocale.iExtraNegativeCurrencyFormatFlags=0;
2914 DoUpdateLanguageSettings(&data[0]);
2915 DoUpdateLocaleSettings(&data[0]);
2916 DoUpdateTimeDateFormat(&data[0]);
2918 iPreferredCharSet = (const LCharSet*)data[FnCharSet]();
2919 iDefaultCharSet = iPreferredCharSet;
2922 else if(r == KErrNotFound)
2927 TInt languageID = -1;
2928 TInt err = CheckLocaleDllName(aLocaleDllName, languageID);
2929 if (err != KErrNone)
2933 while (i < KLocMapLength) //binary search later
2935 if ((LocaleMapping[i].iOldLocaleId) == languageID)
2937 lan = LocaleMapping[i].iNewLocaleID[0];
2938 reg = LocaleMapping[i].iNewLocaleID[1];
2939 col = LocaleMapping[i].iNewLocaleID[2];
2944 if(i == KLocMapLength)
2945 return KErrNotFound;
2947 TBuf<15> lanptr = KFindLan();
2948 TBuf<15> regptr = KFindReg();
2949 TBuf<15> colptr = KFindCol();
2950 AddExtension(lanptr, lan);
2951 AddExtension(regptr, reg);
2952 AddExtension(colptr, col);
2953 err = LoadLocale(lanptr, regptr, colptr);
2959 TLibraryFunction data[KNumLocaleExports];
2960 TInt r = DoLoadLocale(aLocaleDllName, &data[0]);
2963 iLocale.iExtraNegativeCurrencyFormatFlags=0x80000000;
2964 iLocale.iLanguageDowngrade[0] = ELangNone;
2965 iLocale.iLanguageDowngrade[1] = ELangNone;
2966 iLocale.iLanguageDowngrade[2] = ELangNone;
2967 iLocale.iDigitType = EDigitTypeWestern;
2969 typedef void (*TLibFn)(TLocale*);
2970 ((TLibFn)data[FnLocaleData])(&iLocale);
2972 //Locale daylightsavings unchanged - we have travelled through space, not time
2973 if (iLocale.iExtraNegativeCurrencyFormatFlags&0x80000000)
2974 iLocale.iExtraNegativeCurrencyFormatFlags=0;
2976 DoUpdateLanguageSettings(&data[0]);
2977 DoUpdateLocaleSettings(&data[0]);
2978 DoUpdateTimeDateFormat(&data[0]);
2980 iPreferredCharSet = (const LCharSet*)data[FnCharSet]();
2981 iDefaultCharSet = iPreferredCharSet;
2988 Loads locale data from three locale dlls, which are language, region, and collation locale dlls
2990 It loads three locale DLLs and it initialises the contents of this TExtendedLocale
2991 with the locale information stored in the DLLs. The locale information is only
2992 stored in this TExtendedLocale. If you want to set the system wide settings with
2993 the locale information in the DLL, you can call TExtendedLocale::SaveSystemSettings
2994 after calling this function.
2996 @param aLanguageLocaleDllName The name of the language locale DLL to be loaded
2997 @param aRegionLocaleDllName The name of the region locale DLL to be loaded
2998 @param aCollationLocaleDllName The name of the collation locale DLL to be loaded
3000 @return KErrNone if successful, system wide error if not
3002 @see TExtendedLocale::SaveSystemSettings
3004 #ifdef SYMBIAN_DISTINCT_LOCALE_MODEL
3005 EXPORT_C TInt TExtendedLocale::LoadLocale(const TDesC& aLanguageLocaleDllName,
3006 const TDesC& aRegionLocaleDllName,
3007 const TDesC& aCollationLocaleDllName)
3010 TInt err = LoadLocaleAspect(aLanguageLocaleDllName);
3014 err = LoadLocaleAspect(aRegionLocaleDllName);
3018 err = LoadLocaleAspect(aCollationLocaleDllName);
3025 EXPORT_C TInt TExtendedLocale::LoadLocale(const TDesC& /*aLanguageLocaleDllName*/,
3026 const TDesC& /*aRegionLocaleDllName*/,
3027 const TDesC& /*aCollationLocaleDllName*/)
3029 return KErrNotSupported;
3034 Loads a DLL and get some locale information
3036 It loads the specified locale DLL and depending on the aAspectGroup it overwrites
3037 locale information in this TExtendedLocale with the locale information stored in the
3038 DLL. aAspectGroup is a bitmap of TLocaleAspect values specifying what to be overwritten.
3039 The locale information is only stored in this TExtendedLocale. If you want to set the
3040 system wide settings with the locale information in the DLL, you can call
3041 TExtendedLocale::SaveSystemSettings after calling this function.
3043 @param aAspectGroup A bitmap of TLocaleAspect values specifying what to be overwritten in
3044 this TExtendedLocale. (eg.: ELocaleLanguageSettings | ELocaleTimeDateSettings)
3045 @param aLocaleDllName The name of the locale DLL to be loaded
3047 @return KErrNone if the method is successful, a system wide error code if not
3050 @see TExtendedLocale::SaveSystemSettings
3052 EXPORT_C TInt TExtendedLocale::LoadLocaleAspect(TUint aAspectGroup, const TDesC& aLocaleDllName)
3054 #ifdef SYMBIAN_DISTINCT_LOCALE_MODEL
3055 TLibraryFunction data[KNumLocaleExports];
3056 TInt r = DoLoadLocale(aLocaleDllName, &data[0]);
3059 if(aAspectGroup & ELocaleLanguageSettings)
3061 DoUpdateLanguageSettings(&data[0]);
3063 if(aAspectGroup & ELocaleCollateSetting)
3065 iPreferredCharSet = (const LCharSet*)data[FnCharSet]();
3066 iDefaultCharSet = iPreferredCharSet;
3068 if(aAspectGroup & ELocaleLocaleSettings)
3070 DoUpdateLocaleSettings(&data[0]);
3072 if(aAspectGroup & ELocaleTimeDateSettings)
3074 DoUpdateTimeDateFormat(&data[0]);
3079 else if (r == KErrNotFound)
3084 TInt languageID = -1;
3085 TInt err = CheckLocaleDllName(aLocaleDllName, languageID);
3090 while (i < KLocMapLength)
3092 if ((LocaleMapping[i].iOldLocaleId) == languageID)
3094 lan = LocaleMapping[i].iNewLocaleID[0];
3095 reg = LocaleMapping[i].iNewLocaleID[1];
3096 col = LocaleMapping[i].iNewLocaleID[2];
3101 if(i == KLocMapLength)
3102 return KErrNotFound;
3104 TBuf<15> lanptr = KFindLan();
3105 TBuf<15> regptr = KFindReg();
3106 TBuf<15> colptr = KFindCol();
3107 AddExtension(lanptr, lan);
3108 AddExtension(regptr, reg);
3109 AddExtension(colptr, col);
3111 switch (aAspectGroup)
3113 case ELocaleCollateSetting:
3115 err = LoadLocaleAspect(colptr);
3118 case ELocaleLocaleSettings:
3120 err = LoadLocaleAspect(regptr);
3124 case ELocaleLanguageSettings:
3126 err = LoadLocaleAspect(lanptr);
3135 TLibraryFunction data[KNumLocaleExports];
3136 TInt r = DoLoadLocale(aLocaleDllName, &data[0]);
3139 if(aAspectGroup & ELocaleLanguageSettings)
3141 DoUpdateLanguageSettings(&data[0]);
3143 if(aAspectGroup & ELocaleCollateSetting)
3145 iPreferredCharSet = (const LCharSet*)data[FnCharSet]();
3146 iDefaultCharSet = iPreferredCharSet;
3148 if(aAspectGroup & ELocaleLocaleSettings)
3150 DoUpdateLocaleSettings(&data[0]);
3152 if(aAspectGroup & ELocaleTimeDateSettings)
3154 DoUpdateTimeDateFormat(&data[0]);
3162 Loads a DLL and get some locale information
3164 It loads the specified locale DLL, and it overwrites
3165 locale information in this TExtendedLocale with the locale information stored in the
3166 DLL. The locale information is only stored in this TExtendedLocale. If you want to set the
3167 system wide settings with the locale information in the DLL, you can call
3168 TExtendedLocale::SaveSystemSettings after calling this function.
3170 @param aLocaleDllName The name of the locale DLL to be loaded
3172 @return KErrNone if the method is successful, a system wide error code if not
3174 @see TExtendedLocale::SaveSystemSettings
3176 #ifdef SYMBIAN_DISTINCT_LOCALE_MODEL
3177 EXPORT_C TInt TExtendedLocale::LoadLocaleAspect(const TDesC& aLocaleDllName)
3179 TLibraryFunction data[KNumLocaleExports];
3181 TInt result = aLocaleDllName.Find(KFindReg);
3182 if(result != KErrNotFound)
3184 result = DoLoadLocale(aLocaleDllName, &data[0]);
3185 if(result == KErrNone)
3187 DoUpdateLocaleSettingsV2(&data[0]);
3192 result= aLocaleDllName.Find(KFindLan);
3193 if(result != KErrNotFound)
3195 result = DoLoadLocale(aLocaleDllName, &data[0]);
3196 if(result == KErrNone)
3198 DoUpdateLanguageSettingsV2(&data[0]);
3203 result = aLocaleDllName.Find(KFindCol);
3204 if(result != KErrNotFound)
3206 result = DoLoadLocale(aLocaleDllName, &data[0]);
3207 if(result == KErrNone)
3209 iPreferredCharSet = (const LCharSet*)data[1]();
3210 iDefaultCharSet = iPreferredCharSet;
3215 return KErrNotFound;
3218 EXPORT_C TInt TExtendedLocale::LoadLocaleAspect(const TDesC& /*aLocaleDllName*/)
3220 return KErrNotSupported;
3225 Sets the currency symbol
3227 It sets the currency symbol. The maximum lenght for the currency symbol is
3228 KMaxCurrencySymbol. Trying to pass a descriptor longer than that, will result
3231 @param aSymbol The new currency symbol
3233 @panic USER 119, if the length of aSymbol is greater than KMaxCurrencySymbol.
3235 @capability WriteDeviceData
3237 @return KErrNone if successful, otherwise one of the other system wide error codes.
3239 EXPORT_C TInt TExtendedLocale::SetCurrencySymbol(const TDesC &aSymbol)
3241 __ASSERT_ALWAYS(aSymbol.Length()<=KMaxCurrencySymbol,::Panic(ECurrencySymbolOverflow));
3243 LocaleSettingsGet(iLocaleExtraSettings);
3244 Mem::Copy(&iLocaleExtraSettings.iCurrencySymbol[0], aSymbol.Ptr(), aSymbol.Length()*sizeof(TText) );
3245 iLocaleExtraSettings.iCurrencySymbol[aSymbol.Length()] = 0;
3246 TInt r = RProperty::Set(KUidSystemCategory, KLocaleDataExtraKey, TPckg<SLocaleLocaleSettings>(iLocaleExtraSettings));
3251 Returns the name of the DLL containing the given bits of locale information
3253 Given the bits of locale information specified in aLocaleDataSet, it returns the name
3254 of the locale DLL storing the information. TExtendedLocale can contain information from
3257 @param aLocaleDataSet The TLocaleAspect specifying a group of locale properties
3258 @param aDllName The descriptor that will contain the name of DLL containing the specifying
3259 bits of locale information (valid if the method is successful)
3261 @return KErrNone if successful, system wide error otherwise
3263 EXPORT_C TInt TExtendedLocale::GetLocaleDllName(TLocaleAspect aLocaleDataSet, TDes& aDllName)
3265 TBuf8<KMaxFullName> buf;
3267 switch(aLocaleDataSet)
3269 case ELocaleLanguageSettings:
3270 ptr = (TAny*)iLanguageSettings.iDateSuffixTable;
3272 case ELocaleCollateSetting:
3273 ptr = (TAny*)iPreferredCharSet;
3275 case ELocaleLocaleSettings:
3276 ptr = (TAny*)iLocaleExtraSettings.iLocaleExtraSettingsDllPtr;
3278 case ELocaleTimeDateSettings:
3279 ptr = (TAny*)iLocaleTimeDateFormat.iLocaleTimeDateFormatDllPtr;
3282 TInt r = Exec::GetModuleNameFromAddress(ptr, buf);
3291 Get the Currency Symbol from SLocaleLocaleSettings object
3293 @return TPtrC Pointer holding the Currency Symbol
3295 EXPORT_C TPtrC TExtendedLocale::GetCurrencySymbol()
3297 TPtrC outCurrencySymbolPtr(iLocaleExtraSettings.iCurrencySymbol);
3298 return outCurrencySymbolPtr;
3302 Get the Long Date Format from SLocaleTimeDateFormat object
3304 @return TPtrC Pointer holding the Long Date Format
3306 EXPORT_C TPtrC TExtendedLocale::GetLongDateFormatSpec()
3308 TPtrC outLongDateFormatPtr(iLocaleTimeDateFormat.iLongDateFormatSpec);
3309 return outLongDateFormatPtr;
3313 Get the Short Date Format from SLocaleTimeDateFormat object
3315 @return TPtrC Pointer holding the Short Date Format
3317 EXPORT_C TPtrC TExtendedLocale::GetShortDateFormatSpec()
3319 TPtrC outShortDateFormatPtr(iLocaleTimeDateFormat.iShortDateFormatSpec);
3320 return outShortDateFormatPtr;
3324 Get the Time Format from SLocaleTimeDateFormat object
3326 @return TPtrC Pointer holding the Time Format
3328 EXPORT_C TPtrC TExtendedLocale::GetTimeFormatSpec()
3330 TPtrC outTimeFormatPtr(iLocaleTimeDateFormat.iTimeFormatSpec);
3331 return outTimeFormatPtr;
3334 EXPORT_C TInt UserSvr::LocalePropertiesSetDefaults()
3336 _LIT_SECURITY_POLICY_C1(KLocaleWritePolicy,ECapabilityWriteDeviceData);
3337 _LIT_SECURITY_POLICY_PASS(KLocaleReadPolicy);
3339 TInt r = RProperty::Define(KUidSystemCategory, KLocaleLanguageKey, RProperty::EByteArray, KLocaleReadPolicy, KLocaleWritePolicy, sizeof(TPckg<SLocaleLanguage>));
3340 if(r != KErrNone && r != KErrAlreadyExists)
3343 SLocaleLanguage localeLanguage;
3344 localeLanguage.iLanguage = ELangEnglish;
3345 localeLanguage.iDateSuffixTable = (const TText16*)__DefaultDateSuffixTable;
3346 localeLanguage.iDayTable = (const TText16*)__DefaultDayTable;
3347 localeLanguage.iDayAbbTable = (const TText16*)__DefaultDayAbbTable;
3348 localeLanguage.iMonthTable = (const TText16*)__DefaultMonthTable;
3349 localeLanguage.iMonthAbbTable = (const TText16*)__DefaultMonthAbbTable;
3350 localeLanguage.iAmPmTable = (const TText16*)__DefaultAmPmTable;
3351 localeLanguage.iMsgTable = (const TText16* const*)__DefaultLMsgTable;
3352 r = RProperty::Set(KUidSystemCategory, KLocaleLanguageKey, TPckg<SLocaleLanguage>(localeLanguage));
3356 r = RProperty::Define(KUidSystemCategory, KLocaleDataKey, RProperty::EByteArray, KLocaleReadPolicy, KLocaleWritePolicy, sizeof(TPckg<TLocale>));
3357 if(r != KErrNone && r != KErrAlreadyExists)
3361 locale.SetDefaults();
3363 r = RProperty::Set(KUidSystemCategory, KLocaleDataKey, TPckg<TLocale>(locale));
3367 r = RProperty::Define(KUidSystemCategory, KLocaleDataExtraKey, RProperty::EByteArray, KLocaleReadPolicy, KLocaleWritePolicy, sizeof(TPckg<SLocaleLocaleSettings>));
3368 if(r != KErrNone && r != KErrAlreadyExists)
3371 SLocaleLocaleSettings localeSettings;
3372 Mem::Copy(&localeSettings.iCurrencySymbol[0], _S16("\x00a3"), sizeof(TText16) * 2);
3374 r = RProperty::Set(KUidSystemCategory, KLocaleDataExtraKey, TPckg<SLocaleLocaleSettings>(localeSettings));
3378 r = RProperty::Define(KUidSystemCategory, KLocaleTimeDateFormatKey, RProperty::EByteArray, KLocaleReadPolicy, KLocaleWritePolicy, sizeof(TPckg<SLocaleLocaleSettings>));
3379 if(r != KErrNone && r != KErrAlreadyExists)
3382 SLocaleTimeDateFormat localeTimeDateFormat;
3383 Mem::Copy(&localeTimeDateFormat.iShortDateFormatSpec[0], _S16("%F%*D/%*M/%Y"), sizeof(TText16) * 13);
3384 Mem::Copy(&localeTimeDateFormat.iLongDateFormatSpec[0], _S16("%F%*D%X %N %Y"), sizeof(TText16) * 14);
3385 Mem::Copy(&localeTimeDateFormat.iTimeFormatSpec[0], _S16("%F%*I:%T:%S %*A"), sizeof(TText16) * 16);
3387 r = RProperty::Set(KUidSystemCategory, KLocaleTimeDateFormatKey, TPckg<SLocaleTimeDateFormat>(localeTimeDateFormat));
3391 TInt charSet = (TInt)GetLocaleDefaultCharSet();
3392 r = Exec::SetGlobalUserData(ELocaleDefaultCharSet, charSet);
3396 r = Exec::SetGlobalUserData(ELocalePreferredCharSet, charSet);
3402 // TOverflowHandler class created to handle the descriptor overflow in TLoacle::FormatCurrency
3403 NONSHARABLE_CLASS(TOverflowHandler) : public TDesOverflow
3405 void Overflow(TDes& aDes);
3408 void TOverflowHandler::Overflow(TDes&)
3410 Panic(ETDes16Overflow);
3416 EXPORT_C void TLocale::FormatCurrency(TDes& aText, TInt aAmount)
3418 Renders a currency value as text, based on the locale's currency and numeric
3421 These settings include the currency symbol, the symbol's position and the
3422 way negative values are formatted.
3424 @param aText On return, contains the currency value as text, formatted
3425 according to the locale's currency format settings.
3426 @param aAmount The currency value to be formatted.
3428 @panic USER 11, if aText is not long enough to hold the formatted value.
3431 TOverflowHandler overflowHandler;
3432 FormatCurrency(aText,overflowHandler,aAmount);
3438 EXPORT_C void TLocale::FormatCurrency(TDes& aText, TInt64 aAmount)
3440 Renders a currency value as text, based on the locale's currency and numeric
3443 These settings include the currency symbol, the symbol's position and the
3444 way negative values are formatted.
3446 @param aText On return, contains the currency value as text, formatted
3447 according to the locale's currency format settings.
3448 @param aAmount The currency value to be formatted.
3450 @panic USER 11, if aText is not long enough to hold the formatted value.
3453 TOverflowHandler overflowHandler;
3454 FormatCurrency(aText,overflowHandler, aAmount);
3460 EXPORT_C void TLocale::FormatCurrency(TDes& aText, TDesOverflow& aOverflowHandler, TInt aAmount)
3462 Renders a currency value as text, based on the locale's currency and numeric
3465 These settings include the currency symbol, the symbol's position and the
3466 way negative values are formatted. If aText is not long enough to hold the
3467 formatted currency value, the overflow handler's Overflow() function is called.
3469 @param aText On return, contains the currency value as text,
3470 formatted according to the locale's currency format
3472 @param aOverflowHandler An object derived from TDesOverflow which handles
3473 descriptor overflows.
3474 @param aAmount The currency value to be formatted.
3477 TInt64 aLongerInt(aAmount);
3478 FormatCurrency(aText, aOverflowHandler, aLongerInt);
3484 EXPORT_C void TLocale::FormatCurrency(TDes& aText, TDesOverflow& aOverflowHandler, TInt64 aAmount)
3486 Renders a currency value as text, based on the locale's currency and numeric
3489 These settings include the currency symbol, the symbol's position and the
3490 way negative values are formatted. If aText is not long enough to hold the
3491 formatted currency value, the overflow handler's Overflow() function is called.
3493 @param aText On return, contains the currency value as text,
3494 formatted according to the locale's currency format
3496 @param aOverflowHandler An object derived from TDesOverflow which handles
3497 descriptor overflows.
3498 @param aAmount The currency value to be formatted.
3501 // aAmount is in cents (or equivalent) rather than dollars (or equivalent)
3502 const TBool amountIsNegative=(aAmount<0);
3503 if (amountIsNegative)
3507 aText.Num(aAmount, EDecimal);
3508 const TInt currencyDecimalPlaces=CurrencyDecimalPlaces();
3509 TInt positionOfDecimalSeparator=aText.Length();
3510 if (currencyDecimalPlaces>0)
3512 while (positionOfDecimalSeparator <= currencyDecimalPlaces)
3514 if (aText.Length() == aText.MaxLength())
3516 aOverflowHandler.Overflow(aText);
3519 aText.Insert(0,KLitZeroPad);
3520 ++positionOfDecimalSeparator;
3522 positionOfDecimalSeparator=aText.Length();
3523 positionOfDecimalSeparator-=currencyDecimalPlaces;
3524 TBuf<1> decimalSeparator;
3525 decimalSeparator.Append(DecimalSeparator());
3526 if (aText.Length() == aText.MaxLength())
3528 aOverflowHandler.Overflow(aText);
3531 aText.Insert(positionOfDecimalSeparator, decimalSeparator);
3533 if (CurrencyTriadsAllowed())
3535 TBuf<1> thousandsSeparator;
3536 thousandsSeparator.Append(ThousandsSeparator());
3537 TInt numberOfThousandsSeparator = positionOfDecimalSeparator/3;
3538 if ((aText.Length()+numberOfThousandsSeparator) > aText.MaxLength())
3540 aOverflowHandler.Overflow(aText);
3543 for (TInt i=positionOfDecimalSeparator-3; i>0; i-=3)
3545 aText.Insert(i, thousandsSeparator);
3548 TInt positionToInsertCurrencySymbol = 0;
3549 switch (CurrencySymbolPosition())
3553 if ((amountIsNegative) && (NegativeCurrencySymbolOpposite()))
3555 positionToInsertCurrencySymbol=aText.Length();
3558 positionToInsertCurrencySymbol=0;
3563 if ((amountIsNegative) && (NegativeCurrencySymbolOpposite()))
3565 positionToInsertCurrencySymbol=0;
3568 positionToInsertCurrencySymbol=aText.Length();
3572 Panic(ETRegionOutOfRange);
3575 if (CurrencySpaceBetween())
3577 if (aText.Length() == aText.MaxLength())
3579 aOverflowHandler.Overflow(aText);
3582 if ((amountIsNegative) && (NegativeLoseSpace()))
3584 // don't add the space
3588 aText.Insert(positionToInsertCurrencySymbol, KLitSpace);
3589 if (positionToInsertCurrencySymbol>0)
3591 ++positionToInsertCurrencySymbol;
3595 TCurrencySymbol theCurrencySymbol;
3596 if ((aText.Length()+theCurrencySymbol.Length()) > aText.MaxLength())
3598 aOverflowHandler.Overflow(aText);
3601 aText.Insert(positionToInsertCurrencySymbol,theCurrencySymbol);
3602 if (amountIsNegative)
3604 TInt positionToInsertInterveningMinusSign = 0;
3605 if ((CurrencySpaceBetween()) && !(NegativeLoseSpace()))
3607 if (positionToInsertCurrencySymbol>0)
3609 positionToInsertInterveningMinusSign = positionToInsertCurrencySymbol-1;
3613 positionToInsertInterveningMinusSign = theCurrencySymbol.Length()+1;
3618 if (positionToInsertCurrencySymbol>0)
3620 positionToInsertInterveningMinusSign = positionToInsertCurrencySymbol;
3624 positionToInsertInterveningMinusSign = theCurrencySymbol.Length();
3627 switch (NegativeCurrencyFormat())
3631 if ((aText.Length()+2) > aText.MaxLength())
3633 aOverflowHandler.Overflow(aText);
3636 aText.Insert(0, KLitOpeningBracket);
3640 case ELeadingMinusSign:
3642 if (aText.Length() == aText.MaxLength())
3644 aOverflowHandler.Overflow(aText);
3647 aText.Insert(0, KLitMinusSign);
3650 case ETrailingMinusSign:
3652 if (aText.Length() == aText.MaxLength())
3654 aOverflowHandler.Overflow(aText);
3657 aText.Append(KLitMinusSign);
3660 case EInterveningMinusSign:
3662 if (aText.Length() == aText.MaxLength())
3664 aOverflowHandler.Overflow(aText);
3667 aText.Insert(positionToInsertInterveningMinusSign, KLitMinusSign);
3671 Panic(ETRegionOutOfRange);
3678 EXPORT_C void TLocaleMessageText::Set(TLocaleMessage aMsgNo)
3680 // Get some text from Locale
3683 if(TUint(aMsgNo) < ELocaleMessages_LastMsg)
3685 SLocaleLanguage localeLanguage;
3686 LocaleLanguageGet(localeLanguage);
3687 Copy((reinterpret_cast<const TText* const*>(localeLanguage.iMsgTable))[aMsgNo]);
3696 EXPORT_C TInt TFindServer::Next(TFullName &aResult)
3698 Gets the full name of the next server which matches the match pattern.
3700 @param aResult A reference to a descriptor with a defined maximum length.
3701 If a matching server is found, its full name is set into
3702 this descriptor. If no matching server is found,
3703 the descriptor length is set to zero.
3705 @return KErrNone if a matching server is found, KErrNotFound otherwise.
3708 return NextObject(aResult,EServer);
3714 EXPORT_C void RServer2::Receive(RMessage2& aMessage, TRequestStatus &aStatus)
3716 // Receive a message from the server asynchronously.
3720 aStatus=KRequestPending;
3721 Exec::ServerReceive(iHandle, aStatus, &aMessage);
3724 EXPORT_C void RServer2::Cancel()
3726 // Cancel a pending message receive.
3730 Exec::ServerCancel(iHandle);
3736 EXPORT_C TInt TFindMutex::Next(TFullName &aResult)
3738 Finds the next global mutex whose full name matches the match pattern.
3740 If a global mutex with a matching name is found, the function copies its full
3741 name into the specified descriptor. It also saves the find-handle associated
3742 with the global mutex into the TFindHandleBase part of this object.
3744 @param aResult A reference to a descriptor with a defined maximum length.
3745 If a matching global mutex is found, its full name is set
3746 into this descriptor.
3747 If no matching global mutex is found, the descriptor length
3750 @return KErrNone if a matching global mutex is found;
3751 KErrNotFound otherwise.
3754 return NextObject(aResult,EMutex);
3761 Acquire the mutex, waiting for it to become free if necessary.
3763 This function checks if the mutex is currently held. If not the mutex is marked
3764 as held by the current thread and the call returns immediately. If the mutex is
3765 held by another thread the current thread will suspend until the mutex becomes
3766 free. If the mutex is already held by the current thread a count is maintained
3767 of how many times the thread has acquired the mutex.
3769 EXPORT_C void RMutex::Wait()
3772 Exec::MutexWait(iHandle);
3781 This function decrements the count of how many times the current thread has
3782 acquired this mutex. If the count is now zero the mutex is marked as free and,
3783 if any other threads are waiting for the mutex to become free, the highest
3784 priority among those is made ready to run. However the mutex is not marked as
3785 held by any thread - the thread which has just been awakened must actually run
3786 in order to acquire the mutex.
3788 @pre The mutex must previously have been acquired by the current thread calling
3791 @panic KERN-EXEC 1 If the mutex has not previously been acquired by the current
3792 thread calling Wait().
3794 EXPORT_C void RMutex::Signal()
3797 Exec::MutexSignal(iHandle);
3803 Test if this mutex is held by the current thread.
3804 @return True if the current thread has waited on the mutex, false otherwise.
3806 EXPORT_C TBool RMutex::IsHeld()
3808 return Exec::MutexIsHeld(iHandle);
3812 /** Wait on a condition variable
3814 This call releases the specified mutex then atomically blocks the current
3815 thread on this condition variable. The atomicity here is with respect to the
3816 condition variable and mutex concerned. Specifically if the condition variable
3817 is signalled at any time after the mutex is released then this thread will be
3818 awakened. Once the thread has awakened it will reacquire the specified mutex
3819 before this call returns (except in the case where the condition variable has
3822 The usage pattern for this is as follows:
3827 condvar.Wait(mutex);
3832 where CONDITION is an arbitrary condition involving any number of user-side
3833 variables whose integrity is protected by the mutex.
3835 It is necessary to loop while testing the condition because there is **no** guarantee
3836 that the condition has been satisfied when the condition variable is signalled.
3837 Different threads may be waiting on different conditions or the condition may
3838 have already been absorbed by another thread. All that can be said is that the
3839 thread will awaken whenever something happens which **might** affect the condition.
3841 It needs to be stressed that if:
3844 condvar.Wait(mutex);
3847 completes, it does not necessarily mean that the condition is yet satisfied, hence the necessity for the loop.
3849 @param aMutex The mutex to be released and reacquired.
3850 @return KErrNone if the condition variable has been signalled.
3851 KErrInUse if another thread is already waiting on this condition
3852 variable in conjunction with a different mutex.
3853 KErrGeneral if the condition variable is deleted.
3855 @pre The specified mutex is held by the current thread.
3856 @post The specified mutex is held by the current thread unless the return
3857 value is KErrGeneral in which case the condition variable no longer
3860 @panic KERN-EXEC 0 if either the condition variable or mutex handles are not
3862 @panic KERN-EXEC 54 if the current thread does not hold the specified mutex.
3864 @see RCondVar::Signal()
3865 @see RCondVar::Broadcast()
3867 EXPORT_C TInt RCondVar::Wait(RMutex& aMutex)
3869 return Exec::CondVarWait(iHandle, aMutex.Handle(), 0);
3874 /** Wait on a condition variable with timeout
3876 This is the same as RCondVar::Wait(RMutex) except that there is a time limit on
3877 how long the current thread will block while waiting for the condition variable.
3879 @param aMutex The mutex to be released and reacquired.
3880 @param aTimeout The maximum time to wait in microseconds.
3882 @return KErrNone if the condition variable has been signalled.
3883 KErrInUse if another thread is already waiting on this condition
3884 variable in conjunction with a different mutex.
3885 KErrGeneral if the condition variable is deleted.
3886 KErrTimedOut if the timeout expired before the condition variable was
3889 @pre The specified mutex is held by the current thread.
3890 @post The specified mutex is held by the current thread unless the return
3891 value is KErrGeneral in which case the condition variable no longer
3894 @panic KERN-EXEC 0 if either the condition variable or mutex handles are not
3896 @panic KERN-EXEC 54 if the current thread does not hold the specified mutex.
3898 @see RCondVar::Wait(RMutex)
3900 EXPORT_C TInt RCondVar::TimedWait(RMutex& aMutex, TInt aTimeout)
3902 return Exec::CondVarWait(iHandle, aMutex.Handle(), aTimeout);
3906 /** Signal a condition variable
3908 This unblocks a single thread which is currently blocked on the condition
3909 variable. The highest priority waiting thread which is not explicitly suspended
3910 will be the one unblocked. If there are no threads currently waiting this call
3913 It is not required that any mutex is held when calling this function but it is
3914 recommended that the mutex associated with the condition variable is held since
3915 otherwise a race condition can result from the condition variable being signalled
3916 just after the waiting thread testing the condition and before it calls Wait().
3919 EXPORT_C void RCondVar::Signal()
3921 Exec::CondVarSignal(iHandle);
3926 /** Broadcast to a condition variable
3928 This unblocks all threads which are currently blocked on the condition
3929 variable. If there are no threads currently waiting this call does nothing.
3931 It is not required that any mutex is held when calling this function but it is
3932 recommended that the mutex associated with the condition variable is held since
3933 otherwise a race condition can result from the condition variable being signalled
3934 just after the waiting thread testing the condition and before it calls Wait().
3937 EXPORT_C void RCondVar::Broadcast()
3939 Exec::CondVarBroadcast(iHandle);
3945 EXPORT_C TInt TFindProcess::Next(TFullName &aResult)
3947 Gets the full name of the next process which matches the match pattern.
3949 @param aResult A reference to a TBuf descriptor with a defined maximum length.
3950 If a matching process is found, its full name is set into
3951 this descriptor. If no matching process is found, the descriptor
3952 length is set to zero.
3954 @return KErrNone if successful, otherwise one of the other system-wide error
3958 return NextObject(aResult,EProcess);
3964 EXPORT_C TUidType RProcess::Type() const
3966 Gets the Uid type associated with the process.
3968 @return A reference to a TUidType object containing the process type.
3973 Exec::ProcessType(iHandle,u);
3980 EXPORT_C TProcessId RProcess::Id() const
3982 Gets the Id of this process.
3984 @return The Id of this process.
3988 return TProcessId( (TUint)Exec::ProcessId(iHandle) );
3994 EXPORT_C void RProcess::Resume()
3996 Makes the first thread in the process eligible for execution.
3998 @panic KERN-EXEC 32 if the process is not yet fully loaded.
4000 @see RThread::Resume()
4004 Exec::ProcessResume(iHandle);
4009 EXPORT_C TFileName RProcess::FileName() const
4011 Gets a copy of the full path name of the loaded executable on which this
4014 This is the file name which is passed to the Create() member function of this
4017 @return A TBuf descriptor with a defined maximum length containing the full
4018 path name of the file.
4020 @see RProcess::Create()
4025 TPtr8 n8(((TUint8*)n.Ptr()) + KMaxFileName, KMaxFileName);
4026 Exec::ProcessFileName(iHandle,n8);
4034 EXPORT_C void User::CommandLine(TDes &aCommand)
4036 Gets a copy of the data which is passed as an argument to the thread function
4037 of the current process's main thread when it is first scheduled to run.
4039 @param aCommand A modifiable descriptor supplied by the caller into which the
4040 argument data is put. The descriptor must be big enough to
4041 contain the expected data, otherwise the function raises
4044 @see User::CommandLineLength()
4047 TPtr8 aCommand8((TUint8*)aCommand.Ptr(),aCommand.MaxLength()<<1);
4048 Exec::ProcessCommandLine(KCurrentProcessHandle,aCommand8);
4049 aCommand.SetLength(aCommand8.Length()>>1);
4055 EXPORT_C TInt User::CommandLineLength()
4057 Gets the length of the data which is passed as an argument to the thread
4058 function of the current process's main thread when it is first scheduled
4061 @return The length of the argument data.
4064 return Exec::ProcessCommandLineLength(KCurrentProcessHandle);
4070 EXPORT_C TExitType RProcess::ExitType() const
4072 Tests whether the process has ended and, if it has ended, return how it ended.
4074 This information allows the caller to distinguish between normal termination
4077 @return An enumeration whose enumerators describe how the process has ended.
4081 return(Exec::ProcessExitType(iHandle));
4087 EXPORT_C TInt RProcess::ExitReason() const
4089 Gets the specific reason associated with the end of this process.
4091 The reason number together with the category name is a way of distinguishing
4092 between different causes of process termination.
4094 If the process has panicked, this value is the panic number. If the process
4095 has ended as a result of a call to Kill(), then the value is the one supplied
4098 If the process has not ended, then the returned value is zero.
4100 @return The reason associated with the end of the process.
4102 @see RProcess::Kill()
4106 return(Exec::ProcessExitReason(iHandle));
4112 EXPORT_C TExitCategoryName RProcess::ExitCategory() const
4114 Gets the name of the category associated with the end of the process.
4116 The category name together with the reason number is a way of distinguishing
4117 between different causes of process termination.
4119 If the process has panicked, the category name is the panic category name;
4120 for example, E32USER-CBase or KERN-EXEC. If the process has ended as a result
4121 of a call to Kill(), then the category name is Kill.
4123 If the process has not ended, then the category name is empty, i.e. the length
4124 of the category name is zero.
4126 @return A descriptor with a defined maximum length containing the
4127 name of the category associated with the end of the process.
4129 @see RProcess::Kill()
4133 TExitCategoryName n;
4134 TPtr8 n8(((TUint8*)n.Ptr()) + KMaxExitCategoryName, KMaxExitCategoryName);
4135 Exec::ProcessExitCategory(iHandle,n8);
4143 EXPORT_C TProcessPriority RProcess::Priority() const
4145 Gets the priority of this process.
4147 @return One of the TProcessPriority enumerator values.
4151 return(Exec::ProcessPriority(iHandle));
4157 EXPORT_C TInt RProcess::SetPriority(TProcessPriority aPriority) const
4159 Sets the priority of this process to one of the values defined by theTProcessPriority
4160 enumeration. The priority can be set to one of the four values:
4170 The absolute priority of all threads owned by the process (and all threads
4171 owned by those threads etc.) are re-calculated.
4175 The priority values EPriorityWindowServer, EPriorityFileServer, EPriorityRealTimeServer
4176 and EPrioritySupervisor are internal to Symbian OS and any attempt to explicitly
4177 set any of these priority values causes a KERN-EXEC 14 panic to be raised.
4179 Any attempt to set the priority of a process which is protected and is different
4180 from the process owning the thread which invokes this function, causes a KERN-EXEC
4181 1 panic to be raised.
4183 A process can set its own priority whether it is protected or not.
4185 @param aPriority The priority value.
4187 @return KErrNone, if successful; otherwise one of the other system-wide
4193 return Exec::ProcessSetPriority(iHandle,aPriority);
4200 Tests whether "Just In Time" debugging is enabled or not for this process.
4202 @return True, when "Just In Time" debugging is enabled. False otherwise.
4203 @see RProcess::SetJustInTime
4206 EXPORT_C TBool RProcess::JustInTime() const
4209 return (Exec::ProcessFlags(iHandle) & KProcessFlagJustInTime) != 0;
4214 Enables or disables "Just In Time" debugging for this process.
4215 This will only have an effect when running on the emulator.
4217 "Just In Time" debugging catches a thread just before it executes a panic
4218 or exception routine. Capturing a thread early, before it is terminated,
4219 allows the developer to more closely inspect what went wrong, before the
4220 kernel removes the thread. In some cases, the developer can modify context,
4221 program counter, and variables to recover the thread. This is only possible
4224 By default, "Just In Time" debugging is enabled.
4226 @param aBoolean ETrue, to enable just-in-time debugging.
4227 EFalse, to disable just-in-time debugging.
4229 EXPORT_C void RProcess::SetJustInTime(TBool aState) const
4232 TUint32 set = aState ? KProcessFlagJustInTime : 0;
4233 Exec::ProcessSetFlags(iHandle, KProcessFlagJustInTime, set);
4239 EXPORT_C TInt RProcess::SecureApi(TInt /*aState*/)
4241 return ESecureApiOn;
4244 EXPORT_C TInt RProcess::DataCaging(TInt /*aState*/)
4246 return EDataCagingOn;
4251 EXPORT_C TInt RProcess::GetMemoryInfo(TModuleMemoryInfo& aInfo) const
4253 Gets the size and base address of the code and various data
4254 sections of the process.
4256 The run addresses are also returned.
4258 @param aInfo On successful return, contains the base address and size of the
4261 @return KErrNone, if successful; otherwise one of the other system wide error
4266 return Exec::ProcessGetMemoryInfo(iHandle,aInfo);
4270 EXPORT_C TAny* RProcess::ExeExportData(void)
4272 Retrieves pointer to named symbol export data from the current process, i.e. the
4273 process calling this function.
4275 @return Pointer to export data when it is present, NULL if export data not found
4281 return Exec::ProcessExeExportData();
4286 EXPORT_C TInt TFindSemaphore::Next(TFullName &aResult)
4288 Finds the next global semaphore whose full name matches the match pattern.
4290 If a global semaphore with a matching name is found, the function copies its
4291 full name into the descriptor aResult. It also saves the find-handle associated
4292 with the global semaphore into the TFindHandleBase part of this TFindSemaphore
4295 @param aResult A reference to a TBuf descriptor with a defined maximum length.
4296 If a matching global semaphore is found, its full name is set
4297 into this descriptor.
4298 If no matching global semaphore is found, the descriptor length
4301 @return KErrNone if a matching global semaphore is found;
4302 KErrNotFound otherwise.
4305 return NextObject(aResult,ESemaphore);
4311 EXPORT_C void RSemaphore::Wait()
4313 Waits for a signal on the semaphore.
4315 The function decrements the semaphore count by one and returns immediately
4316 if it is zero or positive.
4318 If the semaphore count is negative after being decremented, the calling thread is
4319 added to a queue of threads maintained by this semaphore.
4321 The thread waits until the semaphore is signalled. More than one thread can
4322 be waiting on a particular semaphore at a time. When there are multiple threads
4323 waiting on a semaphore, they are released in priority order.
4325 If the semaphore is deleted, all threads waiting on that semaphore are released.
4329 Exec::SemaphoreWait(iHandle, 0);
4335 EXPORT_C TInt RSemaphore::Wait(TInt aTimeout)
4337 Waits for a signal on the semaphore, or a timeout.
4339 @param aTimeout The timeout value in micoseconds
4341 @return KErrNone if the wait has completed normally.
4342 KErrTimedOut if the timeout has expired.
4343 KErrGeneral if the semaphore is being reset, i.e the semaphore
4344 is about to be deleted.
4345 KErrArgument if aTimeout is negative;
4346 otherwise one of the other system wide error codes.
4350 return Exec::SemaphoreWait(iHandle, aTimeout);
4356 EXPORT_C void RSemaphore::Signal()
4358 Signals the semaphore once.
4360 The function increments the semaphore count by one. If the count was negative
4361 before being incremented, the highest priority thread waiting on the semaphore's queue
4362 of threads is removed from that queue and, provided that it is not suspended
4363 for any other reason, is marked as ready to run.
4367 Exec::SemaphoreSignal1(iHandle);
4373 EXPORT_C void RSemaphore::Signal(TInt aCount)
4375 Signals the semaphore one or more times.
4377 The function increments the semaphore count. If the count was negative
4378 before being incremented, the highest priority thread waiting on the semaphore's queue
4379 of threads is removed from that queue and, provided that it is not suspended
4380 for any other reason, is marked as ready to run.
4382 @param aCount The number of times the semaphore is to be signalled.
4386 __ASSERT_ALWAYS(aCount>=0,Panic(ESemSignalCountNegative));
4387 Exec::SemaphoreSignalN(iHandle,aCount);
4393 EXPORT_C RCriticalSection::RCriticalSection()
4396 Default constructor.
4403 EXPORT_C void RCriticalSection::Close()
4405 Closes the handle to the critical section.
4407 As a critical section object is implemented using a semaphore, this has the
4408 effect of closing the handle to the semaphore.
4412 RSemaphore::Close();
4418 EXPORT_C void RCriticalSection::Wait()
4420 Waits for the critical section to become free.
4422 If no other thread is in the critical section, control returns immediately
4423 and the current thread can continue into the section.
4425 If another thread is already in the critical section, the current thread is
4426 marked as waiting (on a semaphore); the current thread is added to a queue
4427 of threads maintained by this critical section.
4431 if (__e32_atomic_add_acq32(&iBlocked, KMaxTUint32) != 1)
4438 EXPORT_C void RCriticalSection::Signal()
4440 Signals an exit from the critical section.
4442 A thread calls this function when it exits from the critical section.
4443 The first eligible thread waiting on the critical section's queue of threads
4444 is removed from that queue and, provided that it is not suspended for any other
4445 reason, is marked as ready to run. That thread will, therefore, be the next to
4446 proceed into the critical section.
4450 __ASSERT_ALWAYS(iBlocked<1,Panic(ECriticalSectionStraySignal));
4451 if (TInt(__e32_atomic_add_rel32(&iBlocked, 1)) < 0)
4452 RSemaphore::Signal();
4458 EXPORT_C TInt TFindThread::Next(TFullName &aResult)
4460 Gets the full name of the next global thread which matches the match pattern.
4462 @param aResult A reference to a TBuf descriptor with a defined maximum length.
4463 If a matching global thread is found, its full name is set into
4464 this descriptor. If no matching global thread is found,
4465 the descriptor length is set to zero.
4467 @return KErrNone if successful, otherwise one of the other system-wide error
4471 return NextObject(aResult,EThread);
4477 EXPORT_C TThreadId RThread::Id() const
4479 Gets the Id of this thread.
4481 @return The Id of this thread.
4485 return TThreadId( (TUint)Exec::ThreadId(iHandle) );
4491 EXPORT_C void RThread::HandleCount(TInt& aProcessHandleCount, TInt& aThreadHandleCount) const
4493 Gets the number of handles open in this thread, and the number of handles open
4494 in the process which owns this thread.
4496 @param aProcessHandleCount On return, contains the number of handles open in
4497 the process which owns this thread.
4498 @param aThreadHandleCount On return, contains the number of handles open in
4503 Exec::HandleCount(iHandle,aProcessHandleCount,aThreadHandleCount);
4509 EXPORT_C TExceptionHandler User::ExceptionHandler()
4511 Gets a pointer to the exception handler for the current thread.
4513 @return A pointer to the exception handler.
4516 return(Exec::ExceptionHandler(KCurrentThreadHandle));
4522 EXPORT_C TInt User::SetExceptionHandler(TExceptionHandler aHandler,TUint32 aMask)
4524 Sets a new exception handler for the current thread. Note that the handler is not
4525 guaranteed to receive floating point exceptions (KExceptionFpe) when a hardware
4526 floating point implementation is in use - see User::SetFloatingPointMode for
4527 hardware floating point modes and whether they cause user-trappable exceptions.
4529 @param aHandler The new exception handler.
4530 @param aMask One or more flags defining the exception categories which
4531 the handler can handle.
4533 @return KErrNone if successful, otherwise another of the system-wide error codes.
4535 @see KExceptionAbort
4537 @see KExceptionUserInterrupt
4539 @see KExceptionFault
4540 @see KExceptionInteger
4541 @see KExceptionDebug
4544 return(Exec::SetExceptionHandler(KCurrentThreadHandle, aHandler, aMask));
4550 EXPORT_C void User::ModifyExceptionMask(TUint32 aClearMask, TUint32 aSetMask)
4552 Changes the set of exceptions which the current thread's exception
4553 handler can deal with.
4555 aClearMask is the set of flags defining the set of exceptions which the
4556 exception handler no longer deals with, while aSetMask is the set of flags
4557 defining the new set of exceptions to be set.
4559 Flag clearing is done before flag setting.
4561 @param aClearMask One or more flags defining the exceptions which the current
4562 exception handler no longer deals with.
4563 @param aSetMask One or more flags defining the new set of exceptions which
4564 the current exception handler is to deal with.
4567 Exec::ModifyExceptionMask(KCurrentThreadHandle, aClearMask, aSetMask);
4573 _LIT(KLitUserExec, "USER-EXEC");
4574 EXPORT_C TInt User::RaiseException(TExcType aType)
4576 Raises an exception of a specified type on the current thread.
4578 If the thread has an exception handler to handle this type of exception,
4581 If the thread has no exception handler to handle this type of exception, then
4582 the function raises a USER-EXEC 3 panic.
4584 Note that exception handlers are executed in the context of the thread on which
4585 the exception is raised; control returns to the point of the exception.
4587 @param aType The type of exception.
4589 @return KErrNone if successful, otherwise another of the system-wide
4593 if (Exec::IsExceptionHandled(KCurrentThreadHandle,aType,ETrue))
4595 Exec::ThreadSetFlags(KCurrentThreadHandle, 0, KThreadFlagLastChance);
4596 TUint32 type = aType;
4597 User::HandleException(&type);
4600 User::Panic(KLitUserExec, ECausedException);
4607 EXPORT_C TBool User::IsExceptionHandled(TExcType aType)
4609 Tests whether the specified exception type can be handled by the
4612 @param aType The type of exception.
4614 @return True, if the thread has an exception handler which can handle
4615 an exception of type aType.
4616 False, if the thread has no exception handler or the thread has
4617 an exception handler which cannot handle the exception defined
4621 return (Exec::IsExceptionHandled(KCurrentThreadHandle,aType,EFalse));
4627 EXPORT_C void RThread::Context(TDes8 &aDes) const
4629 Gets the register contents of this thread.
4631 @param aDes On return, contains the register contents, starting with R0.
4635 Exec::ThreadContext(iHandle,aDes);
4641 EXPORT_C void RThread::Resume() const
4643 Makes the thread eligible for execution.
4645 After a thread is created, it is put into a suspended state; the thread is
4646 not eligible to run until Resume() is called.
4648 This function must also be called to resume execution of this thread after
4649 it has been explicitly suspended by a call to Suspend().
4651 Note that when a thread is created, it is given the priority EPriorityNormal
4652 by default. The fact that a thread is initially put into a suspended state
4653 means that the thread priority can be changed by calling the thread's
4654 SetPriority() member function before the thread is started by a call to Resume().
4658 Exec::ThreadResume(iHandle);
4664 EXPORT_C void RThread::Suspend() const
4666 Suspends execution of this thread.
4668 The thread is not scheduled to run until a subsequent call to Resume() is made.
4672 Exec::ThreadSuspend(iHandle);
4678 EXPORT_C TThreadPriority RThread::Priority() const
4680 Gets the priority of this thread.
4682 @return The priority.
4686 return(Exec::ThreadPriority(iHandle));
4692 EXPORT_C void RThread::SetProcessPriority(TProcessPriority aPriority) const
4694 Sets the priority of the process which owns this thread to one of the values
4695 defined by the TProcessPriority enumeration.
4697 The priority can be set to one of the four values:
4707 The absolute priority of all threads owned by the process (and all threads
4708 owned by those threads etc.) are re-calculated.
4712 The use of the priority values EPriorityWindowServer, EPriorityFileServer,
4713 EPriorityRealTimeServer and EPrioritySupervisor is restricted to Symbian OS,
4714 and any attempt to explicitly set any of these priority values raises a KERN-EXEC
4717 @param aPriority The priority value.
4719 @deprecated Not allowed on threads in a different process.
4720 Replace with RProcess::SetPriority or RMessagePtr2::SetProcessPriority
4724 Exec::ThreadSetProcessPriority(iHandle,aPriority);
4730 EXPORT_C TProcessPriority RThread::ProcessPriority() const
4732 Gets the priority of the process which owns this thread.
4734 @return The process priority.
4738 return(Exec::ThreadProcessPriority(iHandle));
4744 EXPORT_C void RThread::SetPriority(TThreadPriority aPriority) const
4746 Sets the priority of the thread to one of the values defined by
4747 the TThreadPriority enumeration.
4749 The resulting absolute priority of the thread depends on the value of aPriority
4750 and the priority of the owning process.
4752 Use of the priority value EPriorityNull is restricted to Symbian OS, and any
4753 attempt to explicitly set this value causes a KERN-EXEC 14 panic to be raised.
4755 @param aPriority The priority value.
4757 @capability ProtServ if aPriority is EPriorityAbsoluteRealTime1 or higher
4759 @panic KERN-EXEC 14, if aPriority is invalid or set to EPriorityNull
4760 @panic KERN-EXEC 46, if aPriority is EPriorityAbsoluteRealTime1 or higher
4761 and calling process does not have ProtServ capability
4765 Exec::ThreadSetPriority(iHandle,aPriority);
4771 EXPORT_C User::TCritical User::Critical(RThread aThread)
4773 Gets the critical state associated with the specified thread.
4775 @param aThread The thread whose critical state is to be retrieved.
4777 @return The critical state.
4779 @see User::SetCritical()
4782 TUint32 flags = Exec::ThreadFlags(aThread.Handle());
4783 if (flags & KThreadFlagSystemPermanent)
4784 return ESystemPermanent;
4785 if (flags & KThreadFlagSystemCritical)
4786 return ESystemCritical;
4787 if (flags & KThreadFlagProcessPermanent)
4788 return EProcessPermanent;
4789 if (flags & KThreadFlagProcessCritical)
4790 return EProcessCritical;
4791 return ENotCritical;
4797 EXPORT_C User::TCritical User::Critical()
4799 Gets the critical state associated with the current thread.
4801 @return The critical state.
4803 @see User::SetCritical()
4807 return User::Critical(me);
4814 Sets up or changes the effect that termination of the current
4815 thread has, either on its owning process, or on the whole system.
4817 The precise effect of thread termination is defined by
4818 the following specific values of the TCritical enum:
4826 -# The enum value EAllThreadsCritical cannot be set using this function. It is
4827 associated with a process, not a thread, and, if appropriate, should be set
4828 using User::SetProcessCritical().
4829 -# The states associated with ENotCritical, EProcessCritical,
4830 EProcessPermanent, ESystemCritical and ESystemPermanent
4831 are all mutually exclusive, i.e. the thread can only be in one of these states
4834 @param aCritical The state to be set.
4836 @return KErrNone, if successful;
4837 KErrArgument, if EAllThreadsCritical is passed - this is a
4838 state associated with a process, and
4839 you use User::SetProcessCritical() to set it.
4841 @capability ProtServ if aCritical==ESystemCritical or ESystemPermanent
4843 @see User::Critical()
4844 @see User::ProcessCritical()
4845 @see User::SetProcessCritical()
4847 EXPORT_C TInt User::SetCritical(TCritical aCritical)
4849 const TUint32 clear = KThreadFlagSystemPermanent | KThreadFlagSystemCritical |
4850 KThreadFlagProcessPermanent | KThreadFlagProcessCritical;
4854 case ENotCritical: set = 0; break;
4855 case EProcessCritical: set = KThreadFlagProcessCritical; break;
4856 case EProcessPermanent: set = KThreadFlagProcessPermanent; break;
4857 case ESystemCritical: set = KThreadFlagSystemCritical; break;
4858 case ESystemPermanent: set = KThreadFlagSystemPermanent; break;
4859 default: return KErrArgument;
4861 Exec::ThreadSetFlags(KCurrentThreadHandle, clear, set);
4868 EXPORT_C TInt User::SetRealtimeState(TRealtimeState aState)
4870 const TUint32 clear = KThreadFlagRealtime | KThreadFlagRealtimeTest;
4874 case ERealtimeStateOff: set = 0; break;
4875 case ERealtimeStateOn: set = KThreadFlagRealtime; break;
4876 case ERealtimeStateWarn: set = KThreadFlagRealtime|KThreadFlagRealtimeTest; break;
4877 default: return KErrArgument;
4879 Exec::ThreadSetFlags(KCurrentThreadHandle, clear, set);
4886 EXPORT_C User::TCritical User::ProcessCritical(RProcess aProcess)
4888 Gets the critical state associated with the specified process.
4890 @param aProcess The process whose critical state is to be retrieved.
4892 @return The critical state.
4894 @see User::SetProcessCritical()
4897 TUint32 flags = Exec::ProcessFlags(aProcess.Handle());
4898 if (flags & KProcessFlagSystemPermanent)
4899 return ESystemPermanent;
4900 if (flags & KProcessFlagSystemCritical)
4901 return ESystemCritical;
4902 if (flags & (KThreadFlagProcessPermanent | KThreadFlagProcessCritical))
4903 return EAllThreadsCritical;
4904 return ENotCritical;
4910 EXPORT_C User::TCritical User::ProcessCritical()
4912 Gets the critical state associated with the current process.
4914 @return The critical state.
4916 @see User::SetProcessCritical()
4920 return User::ProcessCritical(me);
4926 EXPORT_C TInt User::SetProcessCritical(TCritical aCritical)
4928 Sets up or changes the effect that termination of subsequently created threads
4929 will have, either on the owning process, or on the whole system.
4931 It is important to note that we are not referring to threads that have already
4932 been created, but threads that will be created subsequent to a call to this function.
4934 The precise effect of thread termination is defined by the following specific
4935 values of the TCritical enum:
4937 - EAllThreadsCritical
4942 -# The enum values EProcessCritical and EProcessPermanent cannot be set using
4943 this function. They are states associated with
4944 a thread, not a process, and, if appropriate, should be set
4945 using User::SetCritical().
4946 -# The states associated with ENotCritical, EAllThreadsCritical,
4947 ESystemCritical and ESystemPermanent are all mutually exclusive, i.e. the
4948 process can only be in one of these states at any one time.
4950 @param aCritical The state to be set.
4952 @return KErrNone, if successful;
4953 KErrArgument, if either EProcessCritical or EProcessPermanent
4954 is passed - these are states associated with a thread, and
4955 you use User::SetCritical() to set them.
4957 @capability ProtServ if aCritical==ESystemCritical or ESystemPermanent
4959 @see User::ProcessCritical()
4960 @see User::SetCritical()
4961 @see User::Critical()
4964 const TUint32 clear = KProcessFlagSystemPermanent | KProcessFlagSystemCritical |
4965 KThreadFlagProcessPermanent | KThreadFlagProcessCritical;
4969 case ENotCritical: set = 0; break;
4970 case EAllThreadsCritical: set = KThreadFlagProcessCritical; break;
4971 case ESystemCritical: set = KProcessFlagSystemCritical; break;
4972 case ESystemPermanent: set = KProcessFlagSystemPermanent|KProcessFlagSystemCritical; break;
4973 default: return KErrArgument;
4975 Exec::ProcessSetFlags(KCurrentProcessHandle, clear, set);
4982 EXPORT_C TBool User::PriorityControl()
4984 Tests whether the current process allows other processes to switch its priority
4985 between 'foreground' and 'background'.
4987 @return True, if the current process allows other processes to switch its priority;
4991 return Exec::ProcessFlags(KCurrentProcessHandle) & KProcessFlagPriorityControl;
4997 EXPORT_C void User::SetPriorityControl(TBool aEnable)
4999 Allows the current process to choose to have its priority switched by another
5000 process between 'foreground' and 'background'.
5002 By default a process does not allow this.
5004 @param aEnable If ETrue, allows other processes to switch the current process's
5006 If EFalse, prevents other processes from switching the current
5010 TUint32 set = aEnable ? KProcessFlagPriorityControl : 0;
5011 Exec::ProcessSetFlags(KCurrentProcessHandle, KProcessFlagPriorityControl, set);
5016 EXPORT_C TInt RThread::RequestCount() const
5018 Gets this thread's request semaphore count.
5020 The request semaphore is created when a thread is created, and is used to
5021 support asynchronous requests.
5023 A negative value implies that this thread is waiting for at least
5024 one asynchronous request to complete.
5026 @return This thread's request semaphore count.
5030 return(Exec::ThreadRequestCount(iHandle));
5036 EXPORT_C TExitType RThread::ExitType() const
5038 Tests whether the thread has ended and, if it has ended, return how it ended.
5040 This information allows the caller to distinguish between normal termination
5043 @return An enumeration whose enumerators describe how the thread has ended.
5047 return(Exec::ThreadExitType(iHandle));
5053 EXPORT_C TInt RThread::ExitReason() const
5055 Gets the specific reason associated with the end of this thread.
5057 The reason number together with the category name is a way of distinguishing
5058 between different causes of thread termination.
5060 If the thread has panicked, this value is the panic number. If the thread
5061 has ended as a result of a call to Kill(), then the value is the one supplied
5064 If the thread is still alive, then the returned value is zero.
5066 @return The reason associated with the end of the thread.
5070 return(Exec::ThreadExitReason(iHandle));
5076 EXPORT_C TExitCategoryName RThread::ExitCategory() const
5078 Gets the name of the category associated with the end of the thread.
5080 The category name together with the reason number is a way of distinguishing
5081 between different causes of thread termination.
5083 If the thread has panicked, the category name is the panic category name;
5084 for example, E32USER-CBase or KERN-EXEC. If the thread has ended as a result
5085 of call to Kill(), then the category name is Kill.
5087 If the thread has not ended, then the category name is empty, i.e. the length
5088 of the category name is zero.
5090 @return A TBuf descriptor with a defined maximum length containing the name
5091 of the category associated with the end of the thread.
5096 TExitCategoryName n;
5097 TPtr8 n8(((TUint8*)n.Ptr()) + KMaxExitCategoryName, KMaxExitCategoryName);
5098 Exec::ThreadExitCategory(iHandle,n8);
5106 EXPORT_C TInt RThread::StackInfo(TThreadStackInfo& aInfo) const
5108 Gets information about a thread's user mode stack.
5110 @param aInfo The TThreadStackInfo object to write the stack infomation to.
5112 @return KErrNone, if sucessful;
5113 KErrGeneral, if the thread doesn't have a user mode stack,
5114 or it has terminated.
5116 @see TThreadStackInfo
5119 return(Exec::ThreadStackInfo(iHandle,aInfo));
5125 EXPORT_C TInt RThread::GetCpuTime(TTimeIntervalMicroSeconds& aCpuTime) const
5127 Gets the CPU usage for this thread.
5129 This function is not supported on version 8.0b or 8.1b, and returns
5130 KErrNotSupported. From 9.1 onwards it may be supported if the kernel has been
5131 compiled with the MONITOR_THREAD_CPU_TIME macro defined.
5133 @param aCpuTime A reference to a time interval object supplied by the caller.
5135 @return KErrNone - if thread CPU time is available.
5137 KErrNotSupported - if this feature is not supported on this
5138 version or build of the OS.
5141 return Exec::ThreadGetCpuTime(iHandle, (TInt64&)aCpuTime.Int64());
5147 EXPORT_C void User::After(TTimeIntervalMicroSeconds32 aInterval)
5149 Suspends the current thread until a specified time interval has expired.
5151 The resolution of the timer depends on the hardware, but is normally
5152 1 Symbian OS tick (approximately 1/64 second).
5154 @param aInterval The time interval for which the current thread is to be
5155 suspended, in microseconds.
5157 @panic USER 86, if the time interval is negative.
5161 __ASSERT_ALWAYS(aInterval.Int()>=0,::Panic(EExecAfterTimeNegative));
5162 TRequestStatus s=KRequestPending;
5163 Exec::After(aInterval.Int(),s);
5164 User::WaitForRequest(s);
5170 EXPORT_C void User::AfterHighRes(TTimeIntervalMicroSeconds32 aInterval)
5172 Suspends the current thread until a specified time interval has expired to
5173 a resolution of 1ms .
5175 @param aInterval The time interval for which the current thread is to be
5176 suspended, in microseconds.
5178 @panic USER 86, if the time interval is negative.
5182 __ASSERT_ALWAYS(aInterval.Int()>=0,::Panic(EExecAfterTimeNegative));
5183 TRequestStatus s=KRequestPending;
5184 Exec::AfterHighRes(aInterval.Int(),s);
5185 User::WaitForRequest(s);
5191 EXPORT_C TInt User::At(const TTime &aTime)
5193 Suspends the current thread until the specified absolute time, in the current time zone.
5195 If the machine is off at that time, the machine will be turned on again.
5197 @param aTime The absolute time, in the current time zone, until which the current thread is to
5200 @return On completion, contains the status of the request to suspend the
5203 KErrNone - suspension of the current thread completed normally at
5206 KErrAbort - suspension of the current thread was aborted
5207 because the system time changed.
5209 KErrUnderflow - the requested completion time is in the past.
5211 KErrOverFlow - the requested completion time is too far in the future.
5215 TRequestStatus s=KRequestPending;
5216 TInt64 time=aTime.Int64();
5217 time -= ((TInt64)User::UTCOffset().Int()) * 1000000;
5219 User::WaitForRequest(s);
5226 EXPORT_C void RTimer::Cancel()
5228 Cancels any outstanding request for a timer event.
5230 Any outstanding timer event completes with KErrCancel.
5234 Exec::TimerCancel(iHandle);
5240 EXPORT_C void RTimer::After(TRequestStatus &aStatus,TTimeIntervalMicroSeconds32 aInterval)
5242 // Request a relative timer.
5245 Requests an event after the specified interval.
5247 The counter for this type of request stops during power-down.
5248 A 5 second timer will complete late if, for example, the machine is turned off
5249 2 seconds after the request is made.
5251 @param aStatus On completion, contains the status of the request.
5252 This is KErrNone if the timer completed normally at the
5253 requested time, otherwise another of the
5254 system-wide error codes.
5256 @param aInterval The time interval, in microseconds, after which an event
5259 @panic USER 87, if aInterval is negative.
5260 @panic KERN-EXEC 15, if this function is called while a request for a timer
5261 event is still outstanding.
5265 __ASSERT_ALWAYS(aInterval.Int()>=0,::Panic(ERTimerAfterTimeNegative));
5266 aStatus=KRequestPending;
5267 Exec::TimerAfter(iHandle,aStatus,aInterval.Int());
5273 EXPORT_C void RTimer::AfterTicks(TRequestStatus& aStatus, TInt aTicks)
5275 // Request a relative timer in system ticks.
5278 Requests an event after the specified interval.
5280 The counter for this type of request stops during power-down.
5281 A 5 tick timer will complete late if, for example, the machine is turned off
5282 2 ticks after the request is made.
5284 @param aStatus On completion, contains the status of the request.
5285 This is KErrNone if the timer completed normally at the
5286 requested time, otherwise another of the
5287 system-wide error codes.
5289 @param aTicks The time interval, in system ticks, after which an event
5292 @panic USER 87, if aTicks is negative.
5293 @panic KERN-EXEC 15, if this function is called while a request for a timer
5294 event is still outstanding.
5297 __ASSERT_ALWAYS(aTicks >= 0, ::Panic(ERTimerAfterTimeNegative));
5298 aStatus = KRequestPending;
5299 Exec::TimerAfter(iHandle, aStatus, -aTicks);
5305 EXPORT_C void RTimer::HighRes(TRequestStatus &aStatus,TTimeIntervalMicroSeconds32 aInterval)
5307 // Request a relative timer to a resolution of 1ms.
5310 Requests an event after the specified interval to a resolution of 1ms.
5311 The "HighRes timer" counter stops during power-down (the same as "after timer").
5313 @param aStatus On completion, contains the status of the request.
5314 This is KErrNone if the timer completed normally at the
5315 requested time, otherwise another of the
5316 system-wide error codes.
5318 @param aInterval The time interval, in microseconds, after which an event
5321 @panic USER 87, if aInterval is negative.
5322 @panic KERN-EXEC 15, if this function is called while a request for a timer
5323 event is still outstanding.
5327 __ASSERT_ALWAYS(aInterval.Int()>=0,::Panic(ERTimerAfterTimeNegative));
5328 aStatus=KRequestPending;
5329 Exec::TimerHighRes(iHandle,aStatus,aInterval.Int());
5335 EXPORT_C void RTimer::At(TRequestStatus &aStatus,const TTime &aTime)
5337 // Request an absolute timer.
5340 Requests an event at a given system time (in the current time zone).
5342 If the machine is off at that time, it is automatically turned on.
5344 @param aStatus On completion, contains the status of the request:
5345 KErrNone, the timer completed normally at the requested time;
5346 KErrCancel, the timer was cancelled;
5347 KErrAbort, the timer was aborted because the system time changed;
5348 KErrUnderflow, the requested completion time is in the past;
5349 KErrOverFlow, the requested completion time is too far in the future;
5350 @param aTime The time at which the timer will expire.
5352 @panic KERN-EXEC 15, if this function is called while a request for a timer
5353 event is still outstanding.
5357 aStatus=KRequestPending;
5358 TInt64 time=aTime.Int64();
5359 time -= ((TInt64)User::UTCOffset().Int()) * 1000000;
5360 Exec::TimerAt(iHandle,aStatus,I64LOW(time),I64HIGH(time));
5366 EXPORT_C void RTimer::AtUTC(TRequestStatus &aStatus,const TTime &aUTCTime)
5368 // Request an absolute timer in UTC time.
5371 Requests an event at a given UTC time.
5373 If the machine is off at that time, it is automatically turned on.
5375 @param aStatus On completion, contains the status of the request:
5376 KErrNone, the timer completed normally at the requested time;
5377 KErrCancel, the timer was cancelled;
5378 KErrAbort, the timer was aborted because the system time changed;
5379 KErrUnderflow, the requested completion time is in the past;
5380 KErrOverFlow, the requested completion time is too far in the future;
5381 @param aTime The time at which the timer will expire.
5383 @panic KERN-EXEC 15, if this function is called while a request for a timer
5384 event is still outstanding.
5388 aStatus=KRequestPending;
5389 Exec::TimerAt(iHandle,aStatus,I64LOW(aUTCTime.Int64()),I64HIGH(aUTCTime.Int64()));
5395 EXPORT_C void RTimer::Lock(TRequestStatus &aStatus,TTimerLockSpec aLock)
5397 // Request an absolute timer.
5400 Requests an event on a specified second fraction.
5402 @param aStatus On completion, contains the status of the request:
5403 KErrGeneral, the first time this is called;
5404 KErrNone, the timer completed normally at the requested time;
5405 KErrCancel, the timer was cancelled;
5406 KErrAbort, the timer was aborted because the system time changed;
5407 KErrUnderflow, the requested completion time is in the past;
5408 KErrOverFlow, the requested completion time is too far in the future.
5409 @param aLock The fraction of a second at which the timer completes.
5411 @panic KERN-EXEC 15, if this function is called while a request for a timer
5412 event is still outstanding.
5415 aStatus=KRequestPending;
5416 Exec::TimerLock(iHandle,aStatus,aLock);
5421 Requests an event to be triggered when aSeconds is exactly, (ie not greater or
5422 less than), the time elapsed (to the nearest second) since the last user activity.
5423 If the event trigger time has been "missed", instead of triggering late,
5424 the timer waits for the next user activity, to try and satisfy the condition.
5426 That is to say, if there was user activity within the last aSeconds,
5427 the event will be triggered after aSeconds of continuous inactivity following that activity.
5428 Otherwise, if there has been no such activity within this time, an event is
5429 triggered after aSeconds of continuous inactivity following the next user activity
5432 It follows from this, that you can request an event directly after the next
5433 user activity by supplying a time interval of zero.
5436 @param aStatus On completion, contains the status of the request:
5437 KErrNone, the timer completed normally;
5438 KErrCancel, the timer was cancelled;
5439 KErrArgument, if aSeconds is less then zero;
5440 KErrOverflow, if aSecond reaches its limit (which is platform specific but greater then one and a half day).
5441 @param aSeconds The time interval in seconds.
5443 @panic KERN-EXEC 15, if this function is called while a request for a timer
5444 event is still outstanding.
5446 EXPORT_C void RTimer::Inactivity(TRequestStatus &aStatus, TTimeIntervalSeconds aSeconds)
5448 aStatus=KRequestPending;
5449 Exec::TimerInactivity(iHandle, aStatus, aSeconds.Int());
5455 EXPORT_C TInt RChangeNotifier::Logon(TRequestStatus& aStatus) const
5457 Issues a request for notification when changes occur in the environment.
5459 A switch in locale, or crossing over past midnight, are examples of changes
5462 When a change in the environment occurs, the request completes and the
5463 TRquestStatus object will contain one or more of the bit values defined
5464 by the TChanges enum.
5466 Alternatively, if an outstanding request is cancelled by a call to
5467 this handle's LogonCancel() member function, then the request completes
5470 Note that if this is the first notification request after creation of
5471 the change notifier, then this request completes immediately.
5473 @param aStatus A reference to the request status object.
5475 @return KErrInUse, if there is an outstanding request; KErrNone otherwise.
5478 @see RChangeNotifier::Logon()
5482 aStatus=KRequestPending;
5483 return(Exec::ChangeNotifierLogon(iHandle,aStatus));
5489 EXPORT_C TInt RChangeNotifier::LogonCancel() const
5491 Cancels an outstanding change notification request.
5493 @return KErrGeneral, if there is no outstanding request; KErrNone otherwise.
5495 @see RChangeNotifier::Logon()
5499 return(Exec::ChangeNotifierLogoff(iHandle));
5505 EXPORT_C void UserSvr::CaptureEventHook()
5507 // Capture the event hook
5511 Exec::CaptureEventHook();
5514 EXPORT_C void UserSvr::ReleaseEventHook()
5516 // Release the event hook
5520 Exec::ReleaseEventHook();
5523 EXPORT_C void UserSvr::RequestEvent(TRawEventBuf &anEvent,TRequestStatus &aStatus)
5525 // Request the next event.
5529 aStatus=KRequestPending;
5530 Exec::RequestEvent(anEvent,aStatus);
5533 EXPORT_C void UserSvr::RequestEventCancel()
5535 // Cancel the event request.
5539 Exec::RequestEventCancel();
5543 Add an event to the queue.
5545 @param anEvent The raw hardware event to be added to the event queue.
5546 @return KErrNone, if successful; KErrPermissionDenied, if the caller has
5547 insufficient capability; otherwise, one of the other system-wide error codes.
5550 @capability PowerMgmt for ESwitchOff, ERestartSystem, ECaseOpen and ECaseClose
5552 EXPORT_C TInt UserSvr::AddEvent(const TRawEvent& anEvent)
5555 return(Exec::AddEvent(anEvent));
5558 EXPORT_C void UserSvr::ScreenInfo(TDes8 &anInfo)
5560 // Get the screen info.
5564 Exec::HalFunction(EHalGroupDisplay,EDisplayHalScreenInfo,(TAny*)&anInfo,NULL);
5567 #ifdef __USERSIDE_THREAD_DATA__
5569 EXPORT_C TAny* UserSvr::DllTls(TInt aHandle)
5571 // Return the value of the Thread Local Storage variable.
5574 return LocalThreadData()->DllTls(aHandle, KDllUid_Default);
5577 EXPORT_C TAny* UserSvr::DllTls(TInt aHandle, TInt aDllUid)
5579 // Return the value of the Thread Local Storage variable.
5582 return LocalThreadData()->DllTls(aHandle, aDllUid);
5587 EXPORT_C TAny* UserSvr::DllTls(TInt aHandle)
5589 // Return the value of the Thread Local Storage variable.
5593 return Exec::DllTls(aHandle, KDllUid_Default);
5596 EXPORT_C TAny* UserSvr::DllTls(TInt aHandle, TInt aDllUid)
5598 // Return the value of the Thread Local Storage variable.
5602 return Exec::DllTls(aHandle, aDllUid);
5607 EXPORT_C void UserSvr::DllFileName(TInt aHandle, TDes& aFileName)
5609 // Return the filename of this dll
5612 TBuf8<KMaxFileName> n8;
5613 Exec::DllFileName(aHandle, n8);
5617 EXPORT_C TBool UserSvr::TestBootSequence()
5619 // Is the machine being booted by the test department?
5623 return Exec::HalFunction(EHalGroupPower,EPowerHalTestBootSequence,NULL,NULL);
5627 Register whether the W/S takes care of turning the screen on
5629 EXPORT_C void UserSvr::WsRegisterSwitchOnScreenHandling(TBool aState)
5632 Exec::HalFunction(EHalGroupDisplay,EDisplayHalWsRegisterSwitchOnScreenHandling,(TAny*)aState,NULL);
5635 EXPORT_C void UserSvr::WsSwitchOnScreen()
5637 // W/S switch on the screen
5641 Exec::HalFunction(EHalGroupDisplay,EDisplayHalWsSwitchOnScreen,NULL,NULL);
5645 EXPORT_C TUint32 UserSvr::DebugMask()
5647 Return the kernel debug mask at index 0
5650 return Exec::DebugMask();
5654 EXPORT_C TUint32 UserSvr::DebugMask(TUint aIndex)
5656 Return the kernel debug mask at the given index position
5658 @param aIndex An index of which 32 bit mask word is to be accessed
5661 return Exec::DebugMaskIndex(aIndex);
5666 EXPORT_C TTrapHandler *User::TrapHandler()
5668 Gets a pointer to the current thread's trap handler.
5670 Note that TTrapHandler is an abstract base class; a trap handler must be
5671 implemented as a derived class.
5673 @return A pointer to the current thread's trap handler, if any. NULL, if no
5674 pre-existing trap handler is set.
5678 return GetTrapHandler();
5684 EXPORT_C TTrapHandler *User::SetTrapHandler(TTrapHandler *aHandler)
5686 Sets the current thread's trap handler and returns a pointer to any pre-existing
5689 Pass a NULL pointer to this function to clear the trap handler.
5691 The trap handler works with the TRAP mechanism to handle the effects of a
5694 Note that TTrapHandler is an abstract base class; a trap handler must be
5695 implemented as a derived class.
5697 @param aHandler A pointer to the trap handler which is to be installed as
5698 the current thread's trap handler.
5700 @return A pointer to the current thread's pre-existing trap handler, if any.
5701 NULL, if no pre-existing trap handler is set.
5709 #if defined(__USERSIDE_THREAD_DATA__) && defined(__LEAVE_EQUALS_THROW__)
5710 prev = LocalThreadData()->iTrapHandler;
5712 prev = Exec::SetTrapHandler(aHandler);
5714 #ifdef __USERSIDE_THREAD_DATA__
5715 LocalThreadData()->iTrapHandler = aHandler;
5720 #ifndef __LEAVE_EQUALS_THROW__
5721 EXPORT_C TTrapHandler* User::MarkCleanupStack()
5723 If there's a TTrapHandler installed marks the cleanup stack and returns
5724 the TTrapHandler for subsequent use in UnMarkCleanupStack.
5726 Only intended for use in the defintion of TRAP and TRAPD and only when
5727 User::Leave is defined in terms of THROW.
5729 @return A pointer to the current thread's pre-existing trap handler, if any.
5730 NULL, if no pre-existing trap handler is set.
5736 return (TTrapHandler*)0;
5740 EXPORT_C void User::UnMarkCleanupStack(TTrapHandler* /*aHandler*/)
5742 If passed a non-null TTrapHandler unmarks the cleanup stack.
5744 Only intended for use in the defintion of TRAP and TRAPD and only when
5745 User::Leave is defined in terms of THROW.
5754 EXPORT_C TTrapHandler* User::MarkCleanupStack()
5756 If there's a TTrapHandler installed marks the cleanup stack and returns
5757 the TTrapHandler for subsequent use in UnMarkCleanupStack.
5759 Only intended for use in the defintion of TRAP and TRAPD and only when
5760 User::Leave is defined in terms of THROW.
5762 @return A pointer to the current thread's pre-existing trap handler, if any.
5763 NULL, if no pre-existing trap handler is set.
5770 TTrapHandler* pH = GetTrapHandler();
5776 EXPORT_C void User::UnMarkCleanupStack(TTrapHandler* aHandler)
5778 If passed a non-null TTrapHandler unmarks the cleanup stack.
5780 Only intended for use in the defintion of TRAP and TRAPD and only when
5781 User::Leave is defined in terms of THROW.
5795 EXPORT_C TInt User::Beep(TInt aFrequency,TTimeIntervalMicroSeconds32 aDuration)
5797 Makes a beep tone with a specified frequency and duration.
5799 This function should not be used. It exists to maintain compatibility with
5800 older versions of Symban OS.
5804 return Exec::HalFunction(EHalGroupSound,ESoundHalBeep,(TAny*)aFrequency,(TAny*)aDuration.Int());
5810 // Unused, exists only for BC reasons
5811 EXPORT_C TInt UserSvr::HalGet(TInt, TAny*)
5813 return KErrNotSupported;
5816 // Unused, exists only for BC reasons
5817 EXPORT_C TInt UserSvr::HalSet(TInt, TAny*)
5819 return KErrNotSupported;
5822 EXPORT_C TInt UserSvr::HalFunction(TInt aGroup, TInt aFunction, TAny* a1, TAny* a2)
5825 return Exec::HalFunction(aGroup, aFunction, a1, a2);
5828 EXPORT_C TInt UserSvr::HalFunction(TInt aGroup, TInt aFunction, TAny* a1, TAny* a2, TInt aDeviceNumber)
5831 return Exec::HalFunction(aGroup | (aDeviceNumber<<16), aFunction, a1, a2);
5835 @capability WriteDeviceData
5837 EXPORT_C TInt UserSvr::SetMemoryThresholds(TInt aLowThreshold, TInt aGoodThreshold)
5839 return Exec::SetMemoryThresholds(aLowThreshold,aGoodThreshold);
5847 EXPORT_C TBool UserSvr::IpcV1Available()
5854 EXPORT_C void User::SetDebugMask(TUint32 aVal)
5856 Sets the debug mask.
5858 @param aVal A set of bit values as defined in nk_trace.h
5861 Exec::SetDebugMask(aVal);
5864 EXPORT_C void User::SetDebugMask(TUint32 aVal, TUint aIndex)
5866 Sets the debug mask at the given index
5868 @param aVal A set of bit values as defined in nk_trace.h
5869 @param aIndex An index of which 32 bit mask word is to be accessed
5872 Exec::SetDebugMaskIndex(aVal, aIndex);
5877 Gets machine information.
5880 @deprecated Use HAL::Get() from the HAL library instead.
5882 EXPORT_C TInt UserHal::MachineInfo(TDes8& anInfo)
5884 TInt bufLength=anInfo.MaxLength();
5885 __ASSERT_ALWAYS(bufLength==sizeof(TMachineInfoV2) || bufLength==sizeof(TMachineInfoV1),Panic(ETDes8BadDescriptorType));
5887 // assemble a TMachineInfoV1 buffer
5888 TMachineInfoV2* info=&((TMachineInfoV2Buf&)anInfo)();
5890 TVariantInfoV01Buf infoBuf;
5891 TInt r = Exec::HalFunction(EHalGroupVariant, EVariantHalVariantInfo, (TAny*)&infoBuf, NULL);
5892 if (KErrNone != r) return r; // must always be implemented!
5893 TVariantInfoV01& variantInfo = infoBuf();
5895 info->iRomVersion=variantInfo.iRomVersion;
5896 info->iMachineUniqueId=variantInfo.iMachineUniqueId;
5897 info->iLedCapabilities=variantInfo.iLedCapabilities;
5898 info->iProcessorClockInKHz=variantInfo.iProcessorClockInKHz;
5899 info->iSpeedFactor=variantInfo.iSpeedFactor;
5901 // Video driver stuff
5902 TVideoInfoV01Buf vidinfoBuf;
5903 r = Exec::HalFunction(EHalGroupDisplay, EDisplayHalCurrentModeInfo, (TAny*)&vidinfoBuf, NULL);
5906 TVideoInfoV01& vidinfo = vidinfoBuf();
5907 info->iDisplaySizeInPixels=vidinfo.iSizeInPixels;
5908 info->iPhysicalScreenSize=vidinfo.iSizeInTwips;
5910 else // no display driver
5912 info->iDisplaySizeInPixels.iWidth=0;
5913 info->iDisplaySizeInPixels.iHeight=0;
5914 info->iPhysicalScreenSize.iWidth=0;
5915 info->iPhysicalScreenSize.iHeight=0;
5918 r = Exec::HalFunction(EHalGroupDisplay, EDisplayHalColors, &colors, NULL);
5919 info->iMaximumDisplayColors=(KErrNone == r)?colors:0;
5921 info->iBacklightPresent= (KErrNone == Exec::HalFunction(EHalGroupDisplay, EDisplayHalBacklightOn, &val, NULL));
5923 // Pointing device stuff
5924 TDigitiserInfoV01Buf xyinfoBuf;
5925 r = Exec::HalFunction(EHalGroupDigitiser, EDigitiserHalXYInfo, (TAny*)&xyinfoBuf, NULL);
5928 info->iXYInputType=EXYInputPointer; // XY is Digitiser
5929 TDigitiserInfoV01& xyinfo = xyinfoBuf();
5930 info->iXYInputSizeInPixels=xyinfo.iDigitiserSize;
5931 info->iOffsetToDisplayInPixels=xyinfo.iOffsetToDisplay;
5935 TMouseInfoV01Buf mouseinfoBuf;
5936 r = Exec::HalFunction(EHalGroupMouse, EMouseHalMouseInfo, (TAny*)&mouseinfoBuf, NULL);
5939 info->iXYInputType=EXYInputMouse; // XY is Mouse
5940 TMouseInfoV01& mouseinfo = mouseinfoBuf();
5941 info->iXYInputSizeInPixels=mouseinfo.iMouseAreaSize;
5942 info->iOffsetToDisplayInPixels=mouseinfo.iOffsetToDisplay;
5946 info->iXYInputType=EXYInputNone; // no XY
5947 info->iXYInputSizeInPixels.iWidth=0;
5948 info->iXYInputSizeInPixels.iHeight=0;
5949 info->iOffsetToDisplayInPixels.iX=0;
5950 info->iOffsetToDisplayInPixels.iY=0;
5955 TKeyboardInfoV01Buf kbdinfoBuf;
5956 info->iKeyboardPresent= (KErrNone == Exec::HalFunction(EHalGroupKeyboard, EKeyboardHalKeyboardInfo, (TAny*)&kbdinfoBuf, NULL));
5958 // Unused, obsolete parameters
5959 info->iKeyboardId=0;
5961 if(bufLength==sizeof(TMachineInfoV2))
5963 // assemble a TMachineInfoV2 buffer
5964 info->iLanguageIndex=0;
5965 info->iKeyboardIndex=0;
5968 anInfo.SetLength(bufLength);
5974 Gets memory information.
5979 @deprecated Use HAL::Get() from the HAL library instead with attributes EMemoryRAM, EMemoryRAMFree or EMemoryROM.
5981 EXPORT_C TInt UserHal::MemoryInfo(TDes8& anInfo)
5983 return Exec::HalFunction(EHalGroupKernel,EKernelHalMemoryInfo,(TAny*)&anInfo,NULL);
5987 Gets ROM configuration information.
5990 @deprecated No replacement.
5992 EXPORT_C TInt UserHal::RomInfo(TDes8& anInfo)
5994 return Exec::HalFunction(EHalGroupKernel,EKernelHalRomInfo,(TAny*)&anInfo,NULL);
6001 Gets drive information.
6003 @param anInfo A package buffer (TPckgBuf) containing a TDriveInfoV1 structure.
6004 On return, this structure will contain the drive information.
6008 @see TDriveInfoV1Buf
6012 EXPORT_C TInt UserHal::DriveInfo(TDes8& anInfo)
6014 TDriveInfoV1Buf8 anInfo8;
6015 TInt r = Exec::HalFunction(EHalGroupMedia,EMediaHalDriveInfo,(TAny*)&anInfo8,NULL);
6016 TDriveInfoV18& driveInfo8 = anInfo8();
6017 TDriveInfoV1* driveInfo = NULL;
6018 switch(((SBuf8*)&anInfo)->length>>KShiftDesType8) //type
6021 driveInfo = &((TPckg<TDriveInfoV1>&)anInfo)();
6024 driveInfo = &((TDriveInfoV1Buf&)anInfo)();
6027 __ASSERT_ALWAYS(EFalse,Panic(ETDes8BadDescriptorType));
6030 // A compile time assert to make sure that this function is examined if TDriveInfoV1
6031 // structure changes
6032 extern int TDriveInfoV1_structure_assert[(
6033 _FOFF(TDriveInfoV1,iRegisteredDriveBitmask)+4 == sizeof(TDriveInfoV1)
6035 sizeof(TDriveInfoV1) == 816
6037 (void)TDriveInfoV1_structure_assert;
6039 // Set length to size of old EKA1 TDriveInfoV1 (Will Panic if not big enough)
6040 TInt len = (TUint)_FOFF(TDriveInfoV1,iRegisteredDriveBitmask);
6041 anInfo.SetLength(len);
6043 // Fill in info for old EKA1 TDriveInfoV1
6044 driveInfo->iTotalSupportedDrives = driveInfo8.iTotalSupportedDrives;
6045 driveInfo->iTotalSockets = driveInfo8.iTotalSockets;
6046 driveInfo->iRuggedFileSystem = driveInfo8.iRuggedFileSystem;
6048 for(index=0;index<KMaxLocalDrives;index++)
6049 driveInfo->iDriveName[index].Copy(driveInfo8.iDriveName[index]);
6050 for(index=0;index<KMaxPBusSockets;index++)
6051 driveInfo->iSocketName[index].Copy(driveInfo8.iSocketName[index]);
6053 // If anInfo is big enough then set new EKA2 members of TDriveInfoV1
6054 if((TUint)anInfo.MaxLength()>=(TUint)sizeof(TDriveInfoV1))
6056 anInfo.SetLength(sizeof(TDriveInfoV1));
6057 driveInfo->iRegisteredDriveBitmask = driveInfo8.iRegisteredDriveBitmask;
6066 Gets the startup reason.
6071 @deprecated Use HAL::Get() from the HAL library instead with attributes ESystemStartupReason.
6073 EXPORT_C TInt UserHal::StartupReason(TMachineStartupType& aReason)
6075 return Exec::HalFunction(EHalGroupKernel,EKernelHalStartupReason,(TAny*)&aReason,NULL);
6082 Gets the reason why the kernel last faulted.
6084 @param aReason An integer that, on return, contains the reason code describing
6085 why the kernel faulted. This is the fault number passed
6086 in a call to Kern::Fault().
6092 EXPORT_C TInt UserHal::FaultReason(TInt &aReason)
6095 return Exec::HalFunction(EHalGroupKernel,EKernelHalFaultReason,(TAny *)&aReason,NULL);
6102 Gets the exception Id that describes the type of fault when
6103 the kernel last faulted.
6105 The Id is the value contained in TArmExcInfo::iExcCode.
6107 @param anId An integer that, on return, contains the exception Id.
6111 @see TArmExcInfo::iExcCode
6114 EXPORT_C TInt UserHal::ExceptionId(TInt &anId)
6117 return Exec::HalFunction(EHalGroupKernel,EKernelHalExceptionId, (TAny *)&anId, NULL);
6123 Gets the available exception information that describes the last kernel fault.
6125 @param aInfo A TExcInfo structure that, on return, contains the available
6126 exception information.
6132 EXPORT_C TInt UserHal::ExceptionInfo(TExcInfo &aInfo)
6135 return Exec::HalFunction(EHalGroupKernel,EKernelHalExceptionInfo, (TAny *)&aInfo, NULL);
6142 Gets the page size for this device.
6144 @param anId An integer that, on return, contains the page size, in bytes,
6149 EXPORT_C TInt UserHal::PageSizeInBytes(TInt& aSize)
6152 return Exec::HalFunction(EHalGroupKernel,EKernelHalPageSizeInBytes,(TAny*)&aSize,NULL);
6159 Switches the device off.
6161 @return KErrNone, if successful; KErrPermissionDenied, if the calling process
6162 has insufficient capability.
6164 @capability PowerMgmt
6166 EXPORT_C TInt UserHal::SwitchOff()
6168 if(!RProcess().HasCapability(ECapabilityPowerMgmt,__PLATSEC_DIAGNOSTIC_STRING("Checked by UserHal::SwitchOff")))
6169 return KErrPermissionDenied;
6170 TInt r = Power::EnableWakeupEvents(EPwStandby);
6174 Power::RequestWakeupEventNotification(s);
6176 User::WaitForRequest(s);
6178 // return Exec::HalFunction(EHalGroupPower,EPowerHalSwitchOff,NULL,NULL);
6185 Sets the calibration data for the digitiser (i.e. XY) input device.
6187 @param aCalibration The calibration data.
6189 @return KErrNone, if successful; KErrPermissionDenied, if the calling process
6190 has insufficient capability.
6192 @see TDigitizerCalibration
6194 @capability WriteDeviceData
6196 EXPORT_C TInt UserHal::SetXYInputCalibration(const TDigitizerCalibration& aCalibration)
6198 return Exec::HalFunction(EHalGroupDigitiser,EDigitiserHalSetXYInputCalibration,(TAny*)&aCalibration,NULL);
6205 Gets the points on the display that the user should point to in order
6206 to calibrate the digitiser (i.e. XY) input device.
6208 @param aCalibration A TDigitizerCalibration object that, on return, contains
6209 the appropriate information.
6211 @return KerrNone, if successful; otherwise one of the other system wide
6214 EXPORT_C TInt UserHal::CalibrationPoints(TDigitizerCalibration& aCalibration)
6217 return Exec::HalFunction(EHalGroupDigitiser,EDigitiserHalCalibrationPoints,(TAny*)&aCalibration,NULL);
6224 Gets the platform tick period.
6226 @param aTime The tick period in microseconds.
6228 @return KErrNone, if successful; otherwise one of the other system wide
6231 EXPORT_C TInt UserHal::TickPeriod(TTimeIntervalMicroSeconds32 &aTime)
6234 return Exec::HalFunction(EHalGroupKernel,EKernelHalTickPeriod,(TAny*)&aTime,NULL);
6240 Saves the current digitiser (i.e. XY) input device calibration data.
6242 @return KErrNone, if successful; otherwise one of the other system wide
6243 error codes, e.g. KErrNotSupported.
6245 EXPORT_C TInt UserHal::SaveXYInputCalibration()
6248 return Exec::HalFunction(EHalGroupDigitiser,EDigitiserHalSaveXYInputCalibration,NULL,NULL);
6255 Restores the digitiser (i.e. XY) input device calibration data.
6257 @param aType A TDigitizerCalibration object that, on return, contains
6258 the calibration data.
6260 @return KErrNone, if successful; KErrPermissionDenied, if the calling process
6261 has insufficient capability; otherwise one of the other system wide
6262 error codes, e.g. KErrNotSupported.
6264 @capability WriteDeviceData
6266 EXPORT_C TInt UserHal::RestoreXYInputCalibration(TDigitizerCalibrationType aType)
6268 return Exec::HalFunction(EHalGroupDigitiser,EDigitiserHalRestoreXYInputCalibration,(TAny*)aType,NULL);
6275 Gets the machine configuration.
6277 @param aConfig On return contains the machine configuration data.
6278 @param aSize On return, contains the size of the data.
6280 @return KErrNone, if sucessful, otherwise one of the other system-wide
6283 @capability ReadDeviceData
6285 EXPORT_C TInt User::MachineConfiguration(TDes8& aConfig,TInt& aSize)
6287 return(Exec::MachineConfiguration(aConfig,aSize));
6293 EXPORT_C TInt RDebug::Print(TRefByValue<const TDesC> aFmt,...)
6295 // Print to the comms port
6299 TestOverflowTruncate overflow;
6300 // coverity[var_decl]
6302 VA_START(list,aFmt);
6304 // coverity[uninit_use_in_call]
6305 TRAP_IGNORE(buf.AppendFormatList(aFmt,list,&overflow)); // ignore leave in TTimeOverflowLeave::Overflow()
6307 TPtr8 p(buf.Collapse());
6308 Exec::DebugPrint((TAny*)&p, 0);
6310 Exec::DebugPrint((TAny*)&buf, 0);
6315 class TestOverflowTruncate8 : public TDes8Overflow
6318 virtual void Overflow(TDes8& /*aDes*/) {}
6321 EXPORT_C void RDebug::Printf(const char* aFmt, ...)
6323 // Print to the comms port
6327 TestOverflowTruncate8 overflow;
6328 // coverity[var_decl]
6330 VA_START(list,aFmt);
6331 TPtrC8 fmt((const TText8*)aFmt);
6333 // coverity[uninit_use_in_call]
6334 TRAP_IGNORE(buf.AppendFormatList(fmt,list,&overflow));
6335 Exec::DebugPrint((TAny*)&buf, 0);
6338 EXPORT_C void RDebug::RawPrint(const TDesC8& aDes)
6340 Exec::DebugPrint((TAny*)&aDes, 1);
6343 EXPORT_C void RDebug::RawPrint(const TDesC16& aDes)
6345 // Print to the comms port
6349 if(aDes.Length()>0x100)
6351 TPtrC ptr(aDes.Ptr(), 0x100);
6356 Exec::DebugPrint((TAny*)&aDes8, 1);
6359 EXPORT_C TUint32 Math::Random()
6361 Gets 32 random bits from the kernel's random pool.
6363 @return The 32 random bits.
6367 return Exec::MathRandom();
6372 EXPORT_C void User::IMB_Range(TAny* aStart, TAny* aEnd)
6374 Does the necessary preparations to guarantee correct execution of code in the
6375 specified virtual address range.
6377 The function assumes that this code has been loaded or modified by user code.
6378 Calling this function against uncommitted memory region is considered as S/W
6379 bug and may generate exception on some memory models.
6381 The specified addresses are associated with a user writable code chunk as
6382 created by RChunk::CreateLocalCode().
6384 The function cleans the data cache to ensure that written data has been
6385 committed to main memory and then flushes the instruction cache and branch
6386 target buffer (BTB) to ensure that the code is loaded from main memory when
6388 The Kernel uses the size of the range specified to decide whether to clean/flush
6389 line-by-line or to simply clean/flush the entire cache.
6391 @param aStart The start virtual address of the region.
6392 @param aEnd The end virtual address of the region. This location is not within
6395 @see RChunk::CreateLocalCode()
6396 @see UserHeap::ChunkHeap()
6400 Exec::IMB_Range(aStart,(TUint32)aEnd-(TUint32)aStart);
6407 Sets the specified handle into the specified environment data slot
6410 The APPARC framework (class CApaApplication etc.) uses some of the slots internally,
6411 so programs that use this framework should ensure that they only use slots available
6414 @param aSlot An index that identifies the environment data slot.
6415 This is a value relative to zero;
6416 i.e. 0 is the first item/slot.
6417 This can range from 0 to 15.
6418 @param aHandle The handle to be passed to this process.
6420 @return KErrNone, always.
6422 @panic KERN-EXEC 46 if this function is called by a thread running
6423 in a process that is not the creator of this process, or
6424 the handle is not local.
6425 @panic KERN-EXEC 51 if aSlot is negative or is greater than or equal to
6426 the value of KArgIndex.
6427 @panic KERN-EXEC 52 if the specified slot is already in use.
6429 @see CApaApplication
6430 @see CApaCommandLine::EnvironmentSlotForPublicUse()
6432 EXPORT_C TInt RProcess::SetParameter(TInt aSlot, RHandleBase aHandle)
6434 return Exec::ProcessSetHandleParameter(iHandle, aSlot, aHandle.Handle());
6441 Sets the specified 16-bit descriptor data into the specified environment
6442 data slot for this process.
6444 The APPARC framework (class CApaApplication etc.) uses some of the slots internally,
6445 so programs that use this framework should ensure that they only use slots available
6448 @param aSlot An index that identifies the environment data slot.
6449 This is a value relative to zero;
6450 i.e. 0 is the first item/slot.
6451 This can range from 0 to 15.
6452 @param aDes The 16-bit descriptor containing data be passed to this process.
6454 @return KErrNone, if successful, otherwise one of the other system
6457 @panic KERN-EXEC 46 if this function is called by a thread running
6458 in a process that is not the creator of this process.
6459 @panic KERN-EXEC 51 if aSlot is negative or is greater than or equal to
6460 the value of KArgIndex.
6461 @panic KERN-EXEC 52 if the specified slot is already in use.
6462 @panic KERN-EXEC 53 if the length of data passed is negative.
6464 @see CApaApplication
6465 @see CApaCommandLine::EnvironmentSlotForPublicUse()
6467 EXPORT_C TInt RProcess::SetParameter(TInt aSlot, const TDesC16& aDes)
6469 return Exec::ProcessSetDataParameter(iHandle, aSlot, (const TUint8*)aDes.Ptr(), 2*aDes.Length());
6476 Sets the specified 8-bit descriptor data into the specified environment
6477 data slot for this process.
6479 The APPARC framework (class CApaApplication etc.) uses some of the slots internally,
6480 so programs that use this framework should ensure that they only use slots available
6483 @param aSlot An index that identifies the environment data slot.
6484 This is a value relative to zero;
6485 i.e. 0 is the first item/slot.
6486 This can range from 0 to 15.
6487 @param aDes The 8-bit descriptor containing data be passed to this process.
6489 @return KErrNone, if successful, otherwise one of the other system
6492 @panic KERN-EXEC 46 if this function is called by a thread running
6493 in a process that is not the creator of this process.
6494 @panic KERN-EXEC 51 if aSlot is negative or is greater than or equal to
6495 the value of KArgIndex.
6496 @panic KERN-EXEC 52 if the specified slot is already in use.
6497 @panic KERN-EXEC 53 if the length of data passed is negative.
6499 @see CApaApplication
6500 @see CApaCommandLine::EnvironmentSlotForPublicUse()
6502 EXPORT_C TInt RProcess::SetParameter(TInt aSlot, const TDesC8& aDes)
6504 return Exec::ProcessSetDataParameter(iHandle, aSlot, aDes.Ptr(), aDes.Length());
6511 Sets the specfied sub-session into the specified environment
6512 data slot for this process.
6514 The APPARC framework (class CApaApplication etc.) uses some of the slots internally,
6515 so programs that use this framework should ensure that they only use slots available
6518 @param aSlot An index that identifies the environment data slot.
6519 This is a value relative to zero;
6520 i.e. 0 is the first item/slot.
6521 This can range from 0 to 15.
6522 @param aSession The sub-session.
6524 @return KErrNone, if successful, otherwise one of the other system
6527 @panic KERN-EXEC 46 if this function is called by a thread running
6528 in a process that is not the creator of this process.
6529 @panic KERN-EXEC 51 if aSlot is negative or is greater than or equal to
6530 the value of KArgIndex.
6531 @panic KERN-EXEC 52 if the specified slot is already in use.
6532 @panic KERN-EXEC 53 if the length of data passed is negative.
6534 @see CApaApplication
6535 @see CApaCommandLine::EnvironmentSlotForPublicUse()
6537 EXPORT_C TInt RProcess::SetParameter(TInt aSlot, const RSubSessionBase& aSession)
6539 TInt handle = aSession.SubSessionHandle();
6540 return Exec::ProcessSetDataParameter(iHandle, aSlot, (const TUint8*)&handle, sizeof(handle));
6547 Sets the specfied integer value into the specified environment
6548 data slot for this process.
6550 The APPARC framework (class CApaApplication etc.) uses some of the slots internally,
6551 so programs that use this framework should ensure that they only use slots available
6554 @param aSlot An index that identifies the environment data slot.
6555 This is a value relative to zero;
6556 i.e. 0 is the first item/slot.
6557 This can range from 0 to 15.
6558 @param aData The integer value.
6560 @return KErrNone, if successful, otherwise one of the other system
6563 @panic KERN-EXEC 46 if this function is called by a thread running
6564 in a process that is not the creator of this process.
6565 @panic KERN-EXEC 51 if aSlot is negative or is greater than or equal to
6566 the value of KArgIndex.
6567 @panic KERN-EXEC 52 if the specified slot is already in use.
6568 @panic KERN-EXEC 53 if the length of data passed is negative.
6570 @see CApaApplication
6571 @see CApaCommandLine::EnvironmentSlotForPublicUse()
6573 EXPORT_C TInt RProcess::SetParameter(TInt aSlot, TInt aData)
6575 return Exec::ProcessSetDataParameter(iHandle, aSlot, (TUint8*)&aData, sizeof(aData));
6581 EXPORT_C TInt User::GetTIntParameter(TInt aSlot, TInt& aData)
6583 Gets the specified environment data item belonging to the
6584 current process; this is assumed to be a 32 bit value.
6586 Environment data may be stored in the process and is passed to a child process
6587 on creation of that child process.
6589 On successful return from this function, the data item is deleted from
6592 @param aSlot An index that identifies the data item.
6593 This is an index whose value is relative to zero;
6594 i.e. 0 is the first item/slot.
6595 This can range from 0 to 15, i.e. there are 16 slots.
6597 @param aData On sucessful return, contains the environment data item.
6599 @return KErrNone, if successful;
6600 KErrNotFound, if there is no data;
6601 KErrArgument, if the data is not binary data, or the data item in the
6602 process is longer than 32 bits.
6604 @panic KERN-EXEC 51, if aSlot is negative or is greater than or equal to 16.
6607 TInt ret = Exec::ProcessGetDataParameter(aSlot, (TUint8*)&aData, sizeof(TInt));
6616 EXPORT_C TInt User::ParameterLength(TInt aSlot)
6618 Gets the length of the specified item of environment data belonging to the
6621 Environment data may be stored in the process and is passed to a child process
6622 on creation of that child process.
6624 @param aSlot An index that identifies the data item whose length is to be
6625 retrieved. This is an index whose value is relative to zero;
6626 i.e. 0 is the first item/slot.
6627 This can range from 0 to 15, i.e. there are 16 slots.
6629 @return KErrNotFound, if there is no data;
6630 KErrArgument, if the data is not binary data;
6631 The length of the data item.
6633 @panic KERN-EXEC 51, if aSlot is negative or is greater than or equal to 16.
6636 TInt ret = Exec::ProcessDataParameterLength(aSlot);
6643 EXPORT_C TInt User::GetDesParameter(TInt aSlot, TDes8& aDes)
6645 Gets the specified environment data item belonging to the
6646 current process; this is assumed to be an 8-bit descriptor.
6648 Environment data may be stored in the process and is passed to a child process
6649 on creation of that child process.
6651 On successful return from this function, the data item is deleted from
6654 @param aSlot An index that identifies the data item.
6655 This is an index whose value is relative to zero;
6656 i.e. 0 is the first item/slot.
6657 This can range from 0 to 15, i.e. there are 16 slots.
6659 @param aDes On sucessful return, contains the environment data item; the
6660 length of the descriptor is set to the length of the data item.
6662 @return KErrNone, if successful;
6663 KErrNotFound, if there is no data;
6664 KErrArgument, if the data is not binary data, or the data item in the
6665 process is longer than the maximum length of aDes.
6667 @panic KERN-EXEC 51, if aSlot is negative or is greater than or equal to 16.
6670 TInt ret = Exec::ProcessGetDataParameter(aSlot, (TUint8*)aDes.Ptr(), aDes.MaxLength());
6673 aDes.SetLength(ret);
6680 EXPORT_C TInt User::GetDesParameter(TInt aSlot, TDes16& aDes)
6682 Gets the specified environment data item belonging to the
6683 current process; this is assumed to be an 16-bit descriptor.
6685 Environment data may be stored in the process and is passed to a child process
6686 on creation of that child process.
6688 On successful return from this function, the data item is deleted from
6691 @param aSlot An index that identifies the data item.
6692 This is an index whose value is relative to zero;
6693 i.e. 0 is the first item/slot.
6694 This can range from 0 to 15, i.e. there are 16 slots.
6696 @param aDes On sucessful return, contains the environment data item; the
6697 length of the descriptor is set to the length of the data item.
6699 @return KErrNone, if successful;
6700 KErrNotFound, if there is no data;
6701 KErrArgument, if the data is not binary data, or the data item in the
6702 process is longer than the maximum length of aDes.
6704 @panic KERN-EXEC 51, if aSlot is negative or is greater than or equal to 16.
6707 TInt ret = Exec::ProcessGetDataParameter(aSlot, (TUint8*)aDes.Ptr(), 2*aDes.MaxLength());
6710 aDes.SetLength(ret/2);
6715 Gets the linear address of the exception descriptor for the code module in which
6716 a specified code address resides.
6718 @param aCodeAddress The code address in question.
6719 @return The address of the exception descriptor, or zero if there is none.
6722 EXPORT_C TLinAddr UserSvr::ExceptionDescriptor(TLinAddr aCodeAddress)
6724 return Exec::ExceptionDescriptor(aCodeAddress);
6727 EXPORT_C TInt User::SetFloatingPointMode(TFloatingPointMode aMode, TFloatingPointRoundingMode aRoundingMode)
6729 Sets the hardware floating point mode for the current thread. This does not affect
6730 software floating point calculations. The rounding mode can also be set. New threads created
6731 by this thread will inherit the mode, thus to set the mode for a whole process, call this
6732 method before you create any new threads.
6734 @param aMode The floating point calculation mode to use.
6735 @param aRoundingMode The floating point rounding mode to use, defaults to nearest.
6737 @return KErrNone if successful, KErrNotSupported if the hardware does not support the
6738 chosen mode, or there is no floating point hardware present.
6740 @see TFloatingPointMode
6741 @see TFloatingPointRoundingMode
6744 return(Exec::SetFloatingPointMode(aMode, aRoundingMode));
6748 EXPORT_C TUint32 E32Loader::PagingPolicy()
6750 Accessor function returns the code paging policy, as defined at ROM build time.
6752 @return Code paging policy only. This function applies
6753 EKernelConfigCodePagingPolicyMask to the config flags
6754 before returning the value.
6757 return Exec::KernelConfigFlags() & EKernelConfigCodePagingPolicyMask;
6761 /** Queue a notifier to detect system idle
6766 EXPORT_C void User::NotifyOnIdle(TRequestStatus& aStatus)
6768 aStatus = KRequestPending;
6769 Exec::NotifyOnIdle(&aStatus);
6773 /** Cancel a miscellaneous notification requested by this thread
6775 Cancels a currently outstanding notification for system idle or object
6781 EXPORT_C void User::CancelMiscNotifier(TRequestStatus& aStatus)
6783 Exec::CancelMiscNotifier(&aStatus);
6787 /** Queue a notifier to detect destruction of this object
6789 To cancel the notifier, use User::CancelMiscNotifier().
6794 EXPORT_C void RHandleBase::NotifyDestruction(TRequestStatus& aStatus)
6796 aStatus = KRequestPending;
6797 Exec::NotifyObjectDestruction(iHandle, &aStatus);