1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/bafl/sysutil.h Wed Mar 31 12:27:01 2010 +0100
1.3 @@ -0,0 +1,210 @@
1.4 +/*
1.5 +* Copyright (c) 2000-2006 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description: SysUtil API provides functions for applications to retrieve
1.18 +* SW and language package versions and check whether there is
1.19 +* free space on a disk drive.
1.20 +*
1.21 +*/
1.22 +
1.23 +
1.24 +#ifndef SYSUTIL_H
1.25 +#define SYSUTIL_H
1.26 +
1.27 +#include <e32base.h>
1.28 +
1.29 +/**
1.30 +* Helper constant to allocate buffers for GetSWVersion, GetLangSWVersion,
1.31 +* GetLangVersion.
1.32 +*/
1.33 +const TInt KSysUtilVersionTextLength = 64;
1.34 +
1.35 +class RFs;
1.36 +
1.37 +/**
1.38 + * SysUtil provides various utility methods for applications.
1.39 + *
1.40 + * SysUtil API provides functions for applications to retrieve SW and language
1.41 + * package versions and check whether there is free space on a disk drive.
1.42 + *
1.43 + * @lib sysutil.lib
1.44 + * @since S60 v2.0
1.45 + */
1.46 +class SysUtil
1.47 + {
1.48 +
1.49 +public:
1.50 +
1.51 + /**
1.52 + * Obtains the software version string.
1.53 + *
1.54 + * @since S60 v2.0
1.55 + *
1.56 + * Usage example:
1.57 + * @code
1.58 + * TBuf<KSysUtilVersionTextLength> version;
1.59 + * if ( SysUtil::GetSWVersion( version ) == KErrNone )
1.60 + * {
1.61 + * // Use the version string.
1.62 + * ...
1.63 + * }
1.64 + * @endcode
1.65 + *
1.66 + * @param aValue On return, contains the software version string.
1.67 + * The buffer should have space for KSysUtilVersionTextLength
1.68 + * characters.
1.69 + *
1.70 + * @return KErrNone on success, or one of the Symbian error codes if reading
1.71 + * the version string fails.
1.72 + */
1.73 + IMPORT_C static TInt GetSWVersion( TDes& aValue );
1.74 +
1.75 + /**
1.76 + * Returns software version which the currently installed language package
1.77 + * is compatible with.
1.78 + *
1.79 + * @since S60 v2.0
1.80 + *
1.81 + * @param aValue On return, contains the version string.
1.82 + * The buffer should have space for KSysUtilVersionTextLength
1.83 + * characters.
1.84 + *
1.85 + * @return KErrNone on success, or one of the Symbian error codes if reading
1.86 + * the version string fails.
1.87 + */
1.88 + IMPORT_C static TInt GetLangSWVersion( TDes& aValue );
1.89 +
1.90 + /**
1.91 + * Obtains the version of the currently installed language package.
1.92 + *
1.93 + * @since S60 v2.0
1.94 + *
1.95 + * @param aValue On return, contains the language package version string.
1.96 + * The buffer should have space for KSysUtilVersionTextLength
1.97 + * characters.
1.98 + *
1.99 + * @return KErrNone on success, or one of the Symbian error codes if reading
1.100 + * the version string fails.
1.101 + */
1.102 + IMPORT_C static TInt GetLangVersion( TDes& aValue );
1.103 +
1.104 + /**
1.105 + * Checks if free FFS (internal flash file system) storage space is or will
1.106 + * fall below critical level. Static configuration value stored in Central
1.107 + * Repository is used to determine the critical level for the FFS drive.
1.108 + *
1.109 + * @since S60 v2.0
1.110 + *
1.111 + * @param aFs File server session. Must be given if available, e.g. from
1.112 + * EIKON environment. If NULL, this method will create a
1.113 + * temporary session, which causes the method to consume more
1.114 + * time and system resources.
1.115 + * @param aBytesToWrite Number of bytes the caller is about to write to
1.116 + * FFS. If value 0 is given, this method checks
1.117 + * if the current FFS space is already below critical
1.118 + * level.
1.119 + *
1.120 + * @return ETrue if FFS space would go below critical level after writing
1.121 + * aBytesToWrite more data, EFalse otherwise.
1.122 + *
1.123 + * @leave Leaves with one of the Symbian error codes if checking the FFS
1.124 + * space fails, for instance if there is not enough free memory to
1.125 + * create a temporary connection to file server.
1.126 + */
1.127 + IMPORT_C static TBool FFSSpaceBelowCriticalLevelL(
1.128 + RFs* aFs,
1.129 + TInt aBytesToWrite = 0 );
1.130 +
1.131 +
1.132 + /**
1.133 + * Checks if free MMC storage space is or will fall below critical
1.134 + * level. Static configuration value stored in Central Repository is
1.135 + * used to determine the critical level for the MMC drive.
1.136 + * PathInfo API is used to determine the drive letter for the MMC drive.
1.137 + *
1.138 + * @since S60 v2.0
1.139 + *
1.140 + * @param aFs File server session. Must be given if available, e.g. from
1.141 + * EIKON environment. If NULL, this method will create a
1.142 + * temporary session, which causes the method to consume more
1.143 + * time and system resources.
1.144 + * @param aBytesToWrite Number of bytes the caller is about to write to
1.145 + * MMC. If value 0 is given, this method checks
1.146 + * if the current MMC space is already below critical
1.147 + * level.
1.148 + *
1.149 + * @return ETrue if MMC space would go below critical level after writing
1.150 + * aBytesToWrite more data, EFalse otherwise.
1.151 + * EFalse if the system has no MMC drive support.
1.152 + *
1.153 + * @leave Leaves with one of the Symbian error codes if checking the MMC
1.154 + * space fails, for instance if the MMC drive contains no media or
1.155 + * there is not enough free memory to create a temporary connection to
1.156 + * file server.
1.157 + */
1.158 + IMPORT_C static TBool MMCSpaceBelowCriticalLevelL(
1.159 + RFs* aFs,
1.160 + TInt aBytesToWrite = 0 );
1.161 +
1.162 + /**
1.163 + * Checks if free disk drive storage space is or will fall below critical
1.164 + * level. Static configuration values stored in Central Repository are
1.165 + * used to determine a critical level for each drive.
1.166 + *
1.167 + * Usage example:
1.168 + * @code
1.169 + * TInt dataSize = 500;
1.170 + * if ( SysUtil::DiskSpaceBelowCriticalLevelL( &iFsSession, dataSize, EDriveC ) )
1.171 + * {
1.172 + * // Can not write the data, there's not enough free space on disk.
1.173 + * ...
1.174 + * }
1.175 + * else
1.176 + * {
1.177 + * // It's ok to actually write the data.
1.178 + * ...
1.179 + * }
1.180 + * @endcode
1.181 + *
1.182 + * @since S60 v2.0
1.183 + *
1.184 + * @param aFs File server session. Must be given if available, e.g. from
1.185 + * EIKON environment. If NULL, this method will create a
1.186 + * temporary session, which causes the method to consume more
1.187 + * time and system resources.
1.188 + * @param aBytesToWrite Number of bytes the caller is about to write to
1.189 + * disk. If value 0 is given, this method checks
1.190 + * if the current disk space is already below critical
1.191 + * level.
1.192 + * @param aDrive Identifies the disk drive to be checked. Numeric values
1.193 + * for identifying disk drives are defined in TDriveNumber
1.194 + * enumeration.
1.195 + *
1.196 + * @see TDriveNumber in f32file.h.
1.197 + *
1.198 + * @return ETrue if disk space would go below critical level after writing
1.199 + * aBytesToWrite more data, EFalse otherwise.
1.200 + *
1.201 + * @leave Leaves with one of the Symbian error codes if checking the disk
1.202 + * space fails, for instance if the drive contains no media or there
1.203 + * is not enough free memory to create a temporary connection to
1.204 + * file server.
1.205 + */
1.206 + IMPORT_C static TBool DiskSpaceBelowCriticalLevelL(
1.207 + RFs* aFs,
1.208 + TInt aBytesToWrite,
1.209 + TInt aDrive );
1.210 +
1.211 + };
1.212 +
1.213 +#endif // SYSUTIL_H