1 /* |
1 /* |
2 * Copyright (c) 2000-2006 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * 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 |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
8 * |
8 * |
9 * Initial Contributors: |
9 * Initial Contributors: |
10 * Nokia Corporation - initial contribution. |
10 * Nokia Corporation - initial contribution. |
11 * |
11 * |
12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description: SysUtil API provides functions for applications to retrieve |
14 * Description: |
15 * SW and language package versions and check whether there is |
|
16 * free space on a disk drive. |
|
17 * |
15 * |
18 */ |
16 */ |
|
17 |
19 |
18 |
20 |
19 |
21 #ifndef SYSUTIL_H |
20 #ifndef SYSUTIL_H |
22 #define SYSUTIL_H |
21 #define SYSUTIL_H |
23 |
22 |
24 #include <e32base.h> |
23 #include <e32base.h> |
25 |
24 |
|
25 class RFs; |
|
26 class CDeviceTypeInformation; |
|
27 |
26 /** |
28 /** |
27 * Helper constant to allocate buffers for GetSWVersion, GetLangSWVersion, |
29 Constant conveying the size of the preallocated descriptor buffers used with |
28 * GetLangVersion. |
30 the SysUtil version APIs. |
|
31 |
|
32 @see SysUtil::GetSWVersion |
|
33 @see SysUtil::GetLangSWVersion |
|
34 @see SysUtil::GetLangVersion |
|
35 @publishedAll |
|
36 @released |
29 */ |
37 */ |
30 const TInt KSysUtilVersionTextLength = 64; |
38 const TInt KSysUtilVersionTextLength = 64; |
31 |
39 |
32 class RFs; |
|
33 |
40 |
34 /** |
41 /** |
35 * SysUtil provides various utility methods for applications. |
42 SysUtil provides various system utility methods, as follows: |
36 * |
43 - Functions for applications to retrieve SW and language package versions |
37 * SysUtil API provides functions for applications to retrieve SW and language |
44 strings for display purposes |
38 * package versions and check whether there is free space on a disk drive. |
45 - Functions to check whether there is free space on a disk drive before |
39 * |
46 file creation or writing. |
40 * @lib sysutil.lib |
47 - Functions to retrieve Device Type information (e.g. phone model) for display |
41 * @since S60 v2.0 |
48 purposes. |
42 */ |
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 */ |
43 class SysUtil |
57 class SysUtil |
44 { |
58 { |
45 |
|
46 public: |
59 public: |
47 |
|
48 /** |
|
49 * Obtains the software version string. |
|
50 * |
|
51 * @since S60 v2.0 |
|
52 * |
|
53 * Usage example: |
|
54 * @code |
|
55 * TBuf<KSysUtilVersionTextLength> version; |
|
56 * if ( SysUtil::GetSWVersion( version ) == KErrNone ) |
|
57 * { |
|
58 * // Use the version string. |
|
59 * ... |
|
60 * } |
|
61 * @endcode |
|
62 * |
|
63 * @param aValue On return, contains the software version string. |
|
64 * The buffer should have space for KSysUtilVersionTextLength |
|
65 * characters. |
|
66 * |
|
67 * @return KErrNone on success, or one of the Symbian error codes if reading |
|
68 * the version string fails. |
|
69 */ |
|
70 IMPORT_C static TInt GetSWVersion( TDes& aValue ); |
60 IMPORT_C static TInt GetSWVersion( TDes& aValue ); |
71 |
|
72 /** |
|
73 * Returns software version which the currently installed language package |
|
74 * is compatible with. |
|
75 * |
|
76 * @since S60 v2.0 |
|
77 * |
|
78 * @param aValue On return, contains the version string. |
|
79 * The buffer should have space for KSysUtilVersionTextLength |
|
80 * characters. |
|
81 * |
|
82 * @return KErrNone on success, or one of the Symbian error codes if reading |
|
83 * the version string fails. |
|
84 */ |
|
85 IMPORT_C static TInt GetLangSWVersion( TDes& aValue ); |
61 IMPORT_C static TInt GetLangSWVersion( TDes& aValue ); |
86 |
|
87 /** |
|
88 * Obtains the version of the currently installed language package. |
|
89 * |
|
90 * @since S60 v2.0 |
|
91 * |
|
92 * @param aValue On return, contains the language package version string. |
|
93 * The buffer should have space for KSysUtilVersionTextLength |
|
94 * characters. |
|
95 * |
|
96 * @return KErrNone on success, or one of the Symbian error codes if reading |
|
97 * the version string fails. |
|
98 */ |
|
99 IMPORT_C static TInt GetLangVersion( TDes& aValue ); |
62 IMPORT_C static TInt GetLangVersion( TDes& aValue ); |
100 |
63 IMPORT_C static TInt GetPRInformation( TDes& aValue ); |
101 /** |
64 |
102 * Checks if free FFS (internal flash file system) storage space is or will |
65 private: |
103 * fall below critical level. Static configuration value stored in Central |
66 IMPORT_C static TBool FFSSpaceBelowCriticalLevel_OldL( |
104 * Repository is used to determine the critical level for the FFS drive. |
|
105 * |
|
106 * @since S60 v2.0 |
|
107 * |
|
108 * @param aFs File server session. Must be given if available, e.g. from |
|
109 * EIKON environment. If NULL, this method will create a |
|
110 * temporary session, which causes the method to consume more |
|
111 * time and system resources. |
|
112 * @param aBytesToWrite Number of bytes the caller is about to write to |
|
113 * FFS. If value 0 is given, this method checks |
|
114 * if the current FFS space is already below critical |
|
115 * level. |
|
116 * |
|
117 * @return ETrue if FFS space would go below critical level after writing |
|
118 * aBytesToWrite more data, EFalse otherwise. |
|
119 * |
|
120 * @leave Leaves with one of the Symbian error codes if checking the FFS |
|
121 * space fails, for instance if there is not enough free memory to |
|
122 * create a temporary connection to file server. |
|
123 */ |
|
124 IMPORT_C static TBool FFSSpaceBelowCriticalLevelL( |
|
125 RFs* aFs, |
67 RFs* aFs, |
126 TInt aBytesToWrite = 0 ); |
68 TInt aBytesToWrite = 0 ); |
127 |
69 IMPORT_C static TBool MMCSpaceBelowCriticalLevel_OldL( |
128 |
|
129 /** |
|
130 * Checks if free MMC storage space is or will fall below critical |
|
131 * level. Static configuration value stored in Central Repository is |
|
132 * used to determine the critical level for the MMC drive. |
|
133 * PathInfo API is used to determine the drive letter for the MMC drive. |
|
134 * |
|
135 * @since S60 v2.0 |
|
136 * |
|
137 * @param aFs File server session. Must be given if available, e.g. from |
|
138 * EIKON environment. If NULL, this method will create a |
|
139 * temporary session, which causes the method to consume more |
|
140 * time and system resources. |
|
141 * @param aBytesToWrite Number of bytes the caller is about to write to |
|
142 * MMC. If value 0 is given, this method checks |
|
143 * if the current MMC space is already below critical |
|
144 * level. |
|
145 * |
|
146 * @return ETrue if MMC space would go below critical level after writing |
|
147 * aBytesToWrite more data, EFalse otherwise. |
|
148 * EFalse if the system has no MMC drive support. |
|
149 * |
|
150 * @leave Leaves with one of the Symbian error codes if checking the MMC |
|
151 * space fails, for instance if the MMC drive contains no media or |
|
152 * there is not enough free memory to create a temporary connection to |
|
153 * file server. |
|
154 */ |
|
155 IMPORT_C static TBool MMCSpaceBelowCriticalLevelL( |
|
156 RFs* aFs, |
70 RFs* aFs, |
157 TInt aBytesToWrite = 0 ); |
71 TInt aBytesToWrite = 0 ); |
158 |
72 IMPORT_C static TBool DiskSpaceBelowCriticalLevel_OldL( |
159 /** |
|
160 * Checks if free disk drive storage space is or will fall below critical |
|
161 * level. Static configuration values stored in Central Repository are |
|
162 * used to determine a critical level for each drive. |
|
163 * |
|
164 * Usage example: |
|
165 * @code |
|
166 * TInt dataSize = 500; |
|
167 * if ( SysUtil::DiskSpaceBelowCriticalLevelL( &iFsSession, dataSize, EDriveC ) ) |
|
168 * { |
|
169 * // Can not write the data, there's not enough free space on disk. |
|
170 * ... |
|
171 * } |
|
172 * else |
|
173 * { |
|
174 * // It's ok to actually write the data. |
|
175 * ... |
|
176 * } |
|
177 * @endcode |
|
178 * |
|
179 * @since S60 v2.0 |
|
180 * |
|
181 * @param aFs File server session. Must be given if available, e.g. from |
|
182 * EIKON environment. If NULL, this method will create a |
|
183 * temporary session, which causes the method to consume more |
|
184 * time and system resources. |
|
185 * @param aBytesToWrite Number of bytes the caller is about to write to |
|
186 * disk. If value 0 is given, this method checks |
|
187 * if the current disk space is already below critical |
|
188 * level. |
|
189 * @param aDrive Identifies the disk drive to be checked. Numeric values |
|
190 * for identifying disk drives are defined in TDriveNumber |
|
191 * enumeration. |
|
192 * |
|
193 * @see TDriveNumber in f32file.h. |
|
194 * |
|
195 * @return ETrue if disk space would go below critical level after writing |
|
196 * aBytesToWrite more data, EFalse otherwise. |
|
197 * |
|
198 * @leave Leaves with one of the Symbian error codes if checking the disk |
|
199 * space fails, for instance if the drive contains no media or there |
|
200 * is not enough free memory to create a temporary connection to |
|
201 * file server. |
|
202 */ |
|
203 IMPORT_C static TBool DiskSpaceBelowCriticalLevelL( |
|
204 RFs* aFs, |
73 RFs* aFs, |
205 TInt aBytesToWrite, |
74 TInt aBytesToWrite, |
206 TInt aDrive ); |
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 }; |
207 |
94 |
208 }; |
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 }; |
209 |
192 |
210 #endif // SYSUTIL_H |
193 #endif // SYSUTIL_H |