williamr@2: /* williamr@4: * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@2: * All rights reserved. williamr@2: * This component and the accompanying materials are made available williamr@4: * under the terms of "Eclipse Public License v1.0" williamr@2: * which accompanies this distribution, and is available williamr@4: * at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@2: * williamr@2: * Initial Contributors: williamr@2: * Nokia Corporation - initial contribution. williamr@2: * williamr@2: * Contributors: williamr@2: * williamr@4: * Description: williamr@2: * williamr@2: */ williamr@2: williamr@2: williamr@4: williamr@2: #ifndef SYSUTIL_H williamr@2: #define SYSUTIL_H williamr@2: williamr@2: #include williamr@2: williamr@4: class RFs; williamr@4: class CDeviceTypeInformation; williamr@4: williamr@2: /** williamr@4: Constant conveying the size of the preallocated descriptor buffers used with williamr@4: the SysUtil version APIs. williamr@4: williamr@4: @see SysUtil::GetSWVersion williamr@4: @see SysUtil::GetLangSWVersion williamr@4: @see SysUtil::GetLangVersion williamr@4: @publishedAll williamr@4: @released williamr@2: */ williamr@2: const TInt KSysUtilVersionTextLength = 64; williamr@2: williamr@2: williamr@2: /** williamr@4: SysUtil provides various system utility methods, as follows: williamr@4: - Functions for applications to retrieve SW and language package versions williamr@4: strings for display purposes williamr@4: - Functions to check whether there is free space on a disk drive before williamr@4: file creation or writing. williamr@4: - Functions to retrieve Device Type information (e.g. phone model) for display williamr@4: purposes. williamr@4: williamr@4: Version, Attribute strings and free space thresholds are provisioned by williamr@4: the device creator into the ROM. For details on this see the williamr@4: 'SGL.TS0017.324 BAFL How-To FAQ Document' in the OS Developer Library. williamr@4: williamr@4: @publishedAll williamr@4: @released williamr@4: */ williamr@2: class SysUtil williamr@2: { williamr@2: public: williamr@2: IMPORT_C static TInt GetSWVersion( TDes& aValue ); williamr@2: IMPORT_C static TInt GetLangSWVersion( TDes& aValue ); williamr@2: IMPORT_C static TInt GetLangVersion( TDes& aValue ); williamr@4: IMPORT_C static TInt GetPRInformation( TDes& aValue ); williamr@4: williamr@4: private: williamr@4: IMPORT_C static TBool FFSSpaceBelowCriticalLevel_OldL( williamr@2: RFs* aFs, williamr@2: TInt aBytesToWrite = 0 ); williamr@4: IMPORT_C static TBool MMCSpaceBelowCriticalLevel_OldL( williamr@2: RFs* aFs, williamr@2: TInt aBytesToWrite = 0 ); williamr@4: IMPORT_C static TBool DiskSpaceBelowCriticalLevel_OldL( williamr@2: RFs* aFs, williamr@2: TInt aBytesToWrite, williamr@2: TInt aDrive ); williamr@4: public: williamr@4: IMPORT_C static TInt GetMMCDriveLetter( RFs & aFs ); williamr@4: IMPORT_C static TInt GetFFSDriveLetter( RFs & aFs ); williamr@4: williamr@4: public: williamr@4: IMPORT_C static CDeviceTypeInformation* GetDeviceTypeInfoL(); williamr@4: williamr@4: IMPORT_C static TBool FFSSpaceBelowCriticalLevelL( williamr@4: RFs* aFs, williamr@4: TInt64 aBytesToWrite = 0 ); williamr@4: IMPORT_C static TBool MMCSpaceBelowCriticalLevelL( williamr@4: RFs* aFs, williamr@4: TInt64 aBytesToWrite = 0 ); williamr@4: IMPORT_C static TBool DiskSpaceBelowCriticalLevelL( williamr@4: RFs* aFs, williamr@4: TInt64 aBytesToWrite, williamr@4: TInt aDrive ); williamr@4: }; williamr@2: williamr@4: /** williamr@4: This class is used to hold the device type information attributes and provides williamr@4: member functions to return the attribute values. These values are strings of williamr@4: UTF-16 characters and no format must be assumed or implied as it varies from williamr@4: one device manufacturer to the next. Please note that this information does not williamr@4: identify a unique device but identifies the type of device. williamr@4: williamr@4: An instance of this class cannot be created by user code. If device type williamr@4: information attributes are required then the user should use williamr@4: SysUtil::GetDeviceTypeInfoL which will return a pointer to an instance of this williamr@4: class. This instance will contain a full set of device type information williamr@4: attributes that have been provisioned by the device creator. For williamr@4: details of how these are provisioned see 'XXX xxx' document in the OS Developer williamr@4: Library. williamr@4: williamr@4: For standard device type information attributes (attributes which are common williamr@4: to all device creators) named functions have been provided. These functions williamr@4: also offer the advantage of a default value being provided when an attribute williamr@4: has not been provisioned by the device creator. If a default value has been williamr@4: retrieved KDefaultValue will be returned. williamr@4: williamr@4: Callers who do not care about whether a default value is retrieved or not can williamr@4: use the API as follows: williamr@4: williamr@4: @code williamr@4: TPtrC16 modelNamePtrC; williamr@4: User::LeaveIfError( deviceTypeInfo->GetModelName(modelNamePtrC) ); williamr@4: @endcode williamr@4: williamr@4: Where callers wish to avoid the default value it can be tested for as follows: williamr@4: williamr@4: @code williamr@4: TPtrC16 modelNamePtrC; williamr@4: if (User::LeaveIfError( deviceTypeInfo->GetModelName(modelNamePtrC)) == CDeviceTypeInformation::KDefaultValue) williamr@4: { williamr@4: // We have a default attribute value, do something else williamr@4: ... williamr@4: } williamr@4: else williamr@4: { williamr@4: // We have a device creator supplied attribute value. williamr@4: ... williamr@4: } williamr@4: @endcode williamr@4: williamr@4: In addition to named functions, two additional generic functions are provided williamr@4: that can be used to retrieve any additional device type information attributes williamr@4: which may be provided by a device creator. These functions can also be used to williamr@4: retrieve the standard attributes; however, it is recommended that the named williamr@4: functions be used instead. williamr@4: williamr@4: Any code which owns an instance of this class has the responsibility of williamr@4: destroying it. This may be achieved by calling delete on the pointer or using williamr@4: the CleanupStack. williamr@4: williamr@4: @publishedAll williamr@4: @released williamr@4: */ williamr@4: NONSHARABLE_CLASS(CDeviceTypeInformation) : public CBase williamr@4: { williamr@4: public: //publishedAll williamr@4: /** williamr@4: The maximum length of a device attribute string value. williamr@4: */ williamr@4: static const TInt KMaxAttributeLength = 64; williamr@4: williamr@4: /** williamr@4: This const is a value returned from calls to the named williamr@4: CDeviceTypeInformation APIs. It indicates to the caller that the returned williamr@4: device type information attribute, stored in CDeviceTypeInformation, is a williamr@4: default value. This occurs when the device creator does not provision the williamr@4: attribute value. williamr@4: */ williamr@4: static const TInt KDefaultValue = 1; williamr@4: public: // publishedAll williamr@4: IMPORT_C ~CDeviceTypeInformation(); williamr@4: static CDeviceTypeInformation* NewL(); williamr@4: IMPORT_C TInt GetManufacturerName( TPtrC16& aValue ) const; williamr@4: IMPORT_C TInt GetModelName( TPtrC16& aValue ) const; williamr@4: IMPORT_C TInt GetModelCode( TPtrC16& aValue ) const; williamr@4: IMPORT_C TInt GetRevisionID( TPtrC16& aValue ) const; williamr@4: IMPORT_C TInt GetDefaultDeviceName( TPtrC16& aValue ) const; williamr@4: IMPORT_C TInt GetUIPlatformName( TPtrC16& aValue ) const; williamr@4: IMPORT_C TInt GetUIPlatformVersion( TPtrC16& aValue ) const; williamr@4: IMPORT_C TInt GetUIPlatformVersion( TUint16& aMajor, TUint16& aMinor ) const; williamr@4: IMPORT_C TInt GetOSVersion( TPtrC16& aValue ) const; williamr@4: IMPORT_C TInt GetOSVersion( TUint16& aMajor, TUint16& aMinor ) const; williamr@4: williamr@4: public: // publishedPartner williamr@4: IMPORT_C TInt GetAttribute( const TUid& aAttributeUid, TPtrC16& aValue ) const; williamr@4: private: williamr@4: CDeviceTypeInformation(); williamr@4: void ConstructL(); williamr@4: private: williamr@4: class TImpl; williamr@4: TImpl* iImpl; williamr@4: }; williamr@2: williamr@2: #endif // SYSUTIL_H