commonservices/sysutil/inc/sysutil.h
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 /*
       
     2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef SYSUTIL_H
       
    21 #define SYSUTIL_H
       
    22 
       
    23 #include <e32base.h>
       
    24 
       
    25 class RFs;
       
    26 class CDeviceTypeInformation;
       
    27 
       
    28 /**
       
    29 Constant conveying the size of the preallocated descriptor buffers used with 
       
    30 the SysUtil version APIs.
       
    31 
       
    32 @see SysUtil::GetSWVersion
       
    33 @see SysUtil::GetLangSWVersion
       
    34 @see SysUtil::GetLangVersion
       
    35 @publishedAll
       
    36 @released
       
    37 */
       
    38 const TInt KSysUtilVersionTextLength = 64;
       
    39 
       
    40 
       
    41 /**
       
    42 SysUtil provides various system utility methods, as follows:
       
    43  - Functions for applications to retrieve SW and language package versions 
       
    44      strings for display purposes 
       
    45  - Functions to check whether there is free space on a disk drive before
       
    46      file creation or writing.
       
    47  - Functions to retrieve Device Type information (e.g. phone model) for display
       
    48      purposes.
       
    49 
       
    50 Version, Attribute strings and free space thresholds are provisioned by 
       
    51 the device creator into the ROM. For details on this see the
       
    52 'SGL.TS0017.324 BAFL How-To FAQ Document' in the OS Developer Library.  
       
    53 
       
    54 @publishedAll
       
    55 @released
       
    56 */
       
    57 class SysUtil
       
    58     {
       
    59 public:
       
    60     IMPORT_C static TInt GetSWVersion( TDes& aValue );
       
    61     IMPORT_C static TInt GetLangSWVersion( TDes& aValue );
       
    62     IMPORT_C static TInt GetLangVersion( TDes& aValue );
       
    63     IMPORT_C static TInt GetPRInformation( TDes& aValue );
       
    64         
       
    65 private:
       
    66     IMPORT_C static TBool FFSSpaceBelowCriticalLevel_OldL(
       
    67         RFs* aFs,
       
    68         TInt aBytesToWrite = 0 );
       
    69     IMPORT_C static TBool MMCSpaceBelowCriticalLevel_OldL(
       
    70         RFs* aFs,
       
    71         TInt aBytesToWrite = 0 );
       
    72     IMPORT_C static TBool DiskSpaceBelowCriticalLevel_OldL(
       
    73         RFs* aFs,
       
    74         TInt aBytesToWrite,
       
    75         TInt aDrive );
       
    76 public:
       
    77     IMPORT_C static TInt GetMMCDriveLetter( RFs & aFs );
       
    78     IMPORT_C static TInt GetFFSDriveLetter( RFs & aFs );
       
    79     
       
    80 public:
       
    81 	IMPORT_C static CDeviceTypeInformation* GetDeviceTypeInfoL();
       
    82 	
       
    83 	IMPORT_C static TBool FFSSpaceBelowCriticalLevelL(
       
    84 	           RFs* aFs,
       
    85 	           TInt64 aBytesToWrite = 0 );
       
    86 	IMPORT_C static TBool MMCSpaceBelowCriticalLevelL(
       
    87 	           RFs* aFs,
       
    88 	           TInt64 aBytesToWrite = 0 );
       
    89 	IMPORT_C static TBool DiskSpaceBelowCriticalLevelL(
       
    90 	           RFs* aFs,
       
    91 	           TInt64 aBytesToWrite,
       
    92 	           TInt aDrive );
       
    93 	};
       
    94 
       
    95 /**
       
    96 This class is used to hold the device type information attributes and provides 
       
    97 member functions to return the attribute values. These values are strings of 
       
    98 UTF-16 characters and no format must be assumed or implied as it varies from 
       
    99 one device manufacturer to the next. Please note that this information does not
       
   100 identify a unique device but identifies the type of device.
       
   101 
       
   102 An instance of this class cannot be created by user code. If device type 
       
   103 information attributes are required then the user should use 
       
   104 SysUtil::GetDeviceTypeInfoL which will return a pointer to an instance of this 
       
   105 class. This instance will contain a full set of device type information 
       
   106 attributes that have been provisioned by the device creator. For 
       
   107 details of how these are provisioned see 'XXX xxx' document in the OS Developer 
       
   108 Library.
       
   109 
       
   110 For standard device type information attributes (attributes which are common 
       
   111 to all device creators) named functions have been provided. These functions 
       
   112 also offer the advantage of a default value being provided when an attribute 
       
   113 has not been provisioned by the device creator. If a default value has been 
       
   114 retrieved KDefaultValue will be returned.
       
   115 
       
   116 Callers who do not care about whether a default value is retrieved or not can 
       
   117 use the API as follows:
       
   118 
       
   119 @code
       
   120 	TPtrC16 modelNamePtrC;
       
   121 	User::LeaveIfError( deviceTypeInfo->GetModelName(modelNamePtrC) );
       
   122 @endcode
       
   123 
       
   124 Where callers wish to avoid the default value it can be tested for as follows:
       
   125 
       
   126 @code
       
   127 	TPtrC16 modelNamePtrC;
       
   128 	if (User::LeaveIfError( deviceTypeInfo->GetModelName(modelNamePtrC)) == CDeviceTypeInformation::KDefaultValue)
       
   129 		{
       
   130 		// We have a default attribute value, do something else
       
   131 		...
       
   132 		}
       
   133 	else
       
   134 		{
       
   135 		// We have a device creator supplied attribute value.
       
   136 		...
       
   137 		}
       
   138 @endcode
       
   139 
       
   140 In addition to named functions, two additional generic functions are provided 
       
   141 that can be used to retrieve any additional device type information attributes 
       
   142 which may be provided by a device creator. These functions can also be used to 
       
   143 retrieve the standard attributes; however, it is recommended that the named 
       
   144 functions be used instead.
       
   145 
       
   146 Any code which owns an instance of this class has the responsibility of 
       
   147 destroying it. This may be achieved by calling delete on the pointer or using 
       
   148 the CleanupStack.
       
   149 
       
   150 @publishedAll
       
   151 @released
       
   152 */
       
   153 NONSHARABLE_CLASS(CDeviceTypeInformation) : public CBase
       
   154 	{
       
   155 public: //publishedAll
       
   156 	/** 
       
   157 	 The maximum length of a device attribute string value.
       
   158 	 */
       
   159 	static const TInt KMaxAttributeLength = 64;
       
   160 	
       
   161 	/** 
       
   162 	 This const is a value returned from calls to the named
       
   163 	 CDeviceTypeInformation APIs. It indicates to the caller that the returned 
       
   164 	 device type information attribute, stored in CDeviceTypeInformation, is a 
       
   165 	 default value. This occurs when the device creator does not provision the 
       
   166 	 attribute value.
       
   167 	 */
       
   168 	static const TInt KDefaultValue = 1;
       
   169 public: // publishedAll
       
   170 	IMPORT_C ~CDeviceTypeInformation();
       
   171 	static CDeviceTypeInformation* NewL();
       
   172 	IMPORT_C TInt GetManufacturerName( TPtrC16& aValue ) const;	
       
   173 	IMPORT_C TInt GetModelName( TPtrC16& aValue ) const;
       
   174 	IMPORT_C TInt GetModelCode( TPtrC16& aValue ) const;
       
   175 	IMPORT_C TInt GetRevisionID( TPtrC16& aValue ) const;
       
   176 	IMPORT_C TInt GetDefaultDeviceName( TPtrC16& aValue ) const;
       
   177 	IMPORT_C TInt GetUIPlatformName( TPtrC16& aValue ) const;
       
   178 	IMPORT_C TInt GetUIPlatformVersion( TPtrC16&  aValue ) const;
       
   179 	IMPORT_C TInt GetUIPlatformVersion( TUint16& aMajor, TUint16& aMinor ) const;
       
   180 	IMPORT_C TInt GetOSVersion( TPtrC16& aValue ) const;
       
   181 	IMPORT_C TInt GetOSVersion( TUint16& aMajor, TUint16& aMinor ) const;
       
   182 
       
   183 public: // publishedPartner
       
   184 	IMPORT_C TInt GetAttribute( const TUid& aAttributeUid, TPtrC16& aValue ) const;
       
   185 private:
       
   186 	CDeviceTypeInformation();
       
   187 	void ConstructL();
       
   188 private:
       
   189 	class TImpl;
       
   190 	TImpl* iImpl;
       
   191 	};
       
   192 
       
   193 #endif // SYSUTIL_H